本文整理汇总了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;
}
示例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;
}
示例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());
}