当前位置: 首页>>代码示例>>C++>>正文


C++ nsIntRect::SetRect方法代码示例

本文整理汇总了C++中nsIntRect::SetRect方法的典型用法代码示例。如果您正苦于以下问题:C++ nsIntRect::SetRect方法的具体用法?C++ nsIntRect::SetRect怎么用?C++ nsIntRect::SetRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nsIntRect的用法示例。


在下文中一共展示了nsIntRect::SetRect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetFrame

nsresult
BoxObject::GetOffsetRect(nsIntRect& aRect)
{
    aRect.SetRect(0, 0, 0, 0);

    if (!mContent)
        return NS_ERROR_NOT_INITIALIZED;

    // Get the Frame for our content
    nsIFrame* frame = GetFrame(true);
    if (frame) {
        // Get its origin
        nsPoint origin = frame->GetPositionIgnoringScrolling();

        // Find the frame parent whose content is the document element.
        Element* docElement = mContent->GetComposedDoc()->GetRootElement();
        nsIFrame* parent = frame->GetParent();
        for (;;) {
            // If we've hit the document element, break here
            if (parent->GetContent() == docElement) {
                break;
            }

            nsIFrame* next = parent->GetParent();
            if (!next) {
                NS_WARNING("We should have hit the document element...");
                origin += parent->GetPosition();
                break;
            }

            // Add the parent's origin to our own to get to the
            // right coordinate system
            origin += next->GetPositionOfChildIgnoringScrolling(parent);
            parent = next;
        }

        // For the origin, add in the border for the frame
        const nsStyleBorder* border = frame->StyleBorder();
        origin.x += border->GetComputedBorderWidth(NS_SIDE_LEFT);
        origin.y += border->GetComputedBorderWidth(NS_SIDE_TOP);

        // And subtract out the border for the parent
        const nsStyleBorder* parentBorder = parent->StyleBorder();
        origin.x -= parentBorder->GetComputedBorderWidth(NS_SIDE_LEFT);
        origin.y -= parentBorder->GetComputedBorderWidth(NS_SIDE_TOP);

        aRect.x = nsPresContext::AppUnitsToIntCSSPixels(origin.x);
        aRect.y = nsPresContext::AppUnitsToIntCSSPixels(origin.y);

        // Get the union of all rectangles in this and continuation frames.
        // It doesn't really matter what we use as aRelativeTo here, since
        // we only care about the size. Using 'parent' might make things
        // a bit faster by speeding up the internal GetOffsetTo operations.
        nsRect rcFrame = nsLayoutUtils::GetAllInFlowRectsUnion(frame, parent);
        aRect.width = nsPresContext::AppUnitsToIntCSSPixels(rcFrame.width);
        aRect.height = nsPresContext::AppUnitsToIntCSSPixels(rcFrame.height);
    }

    return NS_OK;
}
开发者ID:Nazi-Nigger,项目名称:gecko-dev,代码行数:60,代码来源:BoxObject.cpp

示例2: rect

bool
AndroidGeckoSoftwareLayerClient::BeginDrawing(int aWidth, int aHeight, int aTileWidth, int aTileHeight, nsIntRect &aDirtyRect, const nsAString &aMetadata, bool aHasDirectTexture)
{
    NS_ASSERTION(!isNull(), "BeginDrawing() called on null software layer client!");
    JNIEnv *env = AndroidBridge::GetJNIEnv();
    if (!env)
        return false;

    AndroidBridge::AutoLocalJNIFrame(env, 1);
    jstring jMetadata = env->NewString(nsPromiseFlatString(aMetadata).get(), aMetadata.Length());

    jobject rectObject = env->CallObjectMethod(wrapped_obj, jBeginDrawingMethod,
                                               aWidth, aHeight, aTileWidth, aTileHeight,
                                               jMetadata, aHasDirectTexture);

    if (rectObject == nsnull)
        return false;

    AndroidRect rect(env, rectObject);
    nsIntRect newDirtyRect = aDirtyRect.Intersect(nsIntRect(rect.Top(), rect.Left(),
                                                            rect.Width(), rect.Height()));
    aDirtyRect.SetRect(newDirtyRect.x, newDirtyRect.y, newDirtyRect.width, newDirtyRect.height);

    return true;
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例3: grect

void
LayerManagerOGL::WorldTransformRect(nsIntRect& aRect)
{
    gfxRect grect(aRect.x, aRect.y, aRect.width, aRect.height);
    grect = mWorldMatrix.TransformBounds(grect);
    aRect.SetRect(grect.X(), grect.Y(), grect.Width(), grect.Height());
}
开发者ID:,项目名称:,代码行数:7,代码来源:


注:本文中的nsIntRect::SetRect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。