本文整理汇总了C++中nsRect类的典型用法代码示例。如果您正苦于以下问题:C++ nsRect类的具体用法?C++ nsRect怎么用?C++ nsRect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了nsRect类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1:
NS_IMETHODIMP
nsLineIterator::GetLine(PRInt32 aLineNumber,
nsIFrame** aFirstFrameOnLine,
PRInt32* aNumFramesOnLine,
nsRect& aLineBounds,
PRUint32* aLineFlags)
{
NS_ENSURE_ARG_POINTER(aFirstFrameOnLine);
NS_ENSURE_ARG_POINTER(aNumFramesOnLine);
NS_ENSURE_ARG_POINTER(aLineFlags);
if ((aLineNumber < 0) || (aLineNumber >= mNumLines)) {
*aFirstFrameOnLine = nsnull;
*aNumFramesOnLine = 0;
aLineBounds.SetRect(0, 0, 0, 0);
return NS_OK;
}
nsLineBox* line = mLines[aLineNumber];
*aFirstFrameOnLine = line->mFirstChild;
*aNumFramesOnLine = line->GetChildCount();
aLineBounds = line->mBounds;
PRUint32 flags = 0;
if (line->IsBlock()) {
flags |= NS_LINE_FLAG_IS_BLOCK;
}
else {
if (line->HasBreakAfter())
flags |= NS_LINE_FLAG_ENDS_IN_BREAK;
}
*aLineFlags = flags;
return NS_OK;
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:34,代码来源:nsLineBox.cpp
示例2: GetWindowInnerRect
nsresult
nsScreen::GetRect(nsRect& aRect)
{
// Return window inner rect to prevent fingerprinting.
if (ShouldResistFingerprinting()) {
return GetWindowInnerRect(aRect);
}
nsDeviceContext *context = GetDeviceContext();
if (!context) {
return NS_ERROR_FAILURE;
}
context->GetRect(aRect);
LayoutDevicePoint screenTopLeftDev =
LayoutDevicePixel::FromAppUnits(aRect.TopLeft(),
context->AppUnitsPerDevPixel());
DesktopPoint screenTopLeftDesk =
screenTopLeftDev / context->GetDesktopToDeviceScale();
aRect.x = NSToIntRound(screenTopLeftDesk.x);
aRect.y = NSToIntRound(screenTopLeftDesk.y);
aRect.height = nsPresContext::AppUnitsToIntCSSPixels(aRect.height);
aRect.width = nsPresContext::AppUnitsToIntCSSPixels(aRect.width);
return NS_OK;
}
开发者ID:,项目名称:,代码行数:29,代码来源:
示例3:
void
TouchCaret::SetTouchFramePos(const nsRect& aCaretRect)
{
nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
if (!presShell) {
return;
}
mozilla::dom::Element* touchCaretElement = presShell->GetTouchCaretElement();
if (!touchCaretElement) {
return;
}
// Convert aOrigin to CSS pixels.
RefPtr<nsPresContext> presContext = presShell->GetPresContext();
int32_t x = presContext->AppUnitsToIntCSSPixels(aCaretRect.Center().x);
int32_t y = presContext->AppUnitsToIntCSSPixels(aCaretRect.y);
int32_t padding = presContext->AppUnitsToIntCSSPixels(aCaretRect.height);
nsAutoString styleStr;
styleStr.AppendLiteral("left: ");
styleStr.AppendInt(x);
styleStr.AppendLiteral("px; top: ");
styleStr.AppendInt(y);
styleStr.AppendLiteral("px; padding-top: ");
styleStr.AppendInt(padding);
styleStr.AppendLiteral("px;");
TOUCHCARET_LOG("Set style: %s", NS_ConvertUTF16toUTF8(styleStr).get());
touchCaretElement->SetAttr(kNameSpaceID_None, nsGkAtoms::style,
styleStr, true);
}
开发者ID:logicoftekk,项目名称:cyberfox,代码行数:33,代码来源:TouchCaret.cpp
示例4: AccumulateRectDifference
void
DisplayItemClip::AddOffsetAndComputeDifference(const nsPoint& aOffset,
const nsRect& aBounds,
const DisplayItemClip& aOther,
const nsRect& aOtherBounds,
nsRegion* aDifference)
{
if (mHaveClipRect != aOther.mHaveClipRect ||
mRoundedClipRects.Length() != aOther.mRoundedClipRects.Length()) {
aDifference->Or(*aDifference, aBounds);
aDifference->Or(*aDifference, aOtherBounds);
return;
}
if (mHaveClipRect) {
AccumulateRectDifference(mClipRect + aOffset, aOther.mClipRect,
aBounds.Union(aOtherBounds),
aDifference);
}
for (uint32_t i = 0; i < mRoundedClipRects.Length(); ++i) {
if (mRoundedClipRects[i] + aOffset != aOther.mRoundedClipRects[i]) {
// The corners make it tricky so we'll just add both rects here.
aDifference->Or(*aDifference, mRoundedClipRects[i].mRect.Intersect(aBounds));
aDifference->Or(*aDifference, aOther.mRoundedClipRects[i].mRect.Intersect(aOtherBounds));
}
}
}
开发者ID:aeddi,项目名称:gecko-dev,代码行数:26,代码来源:DisplayItemClip.cpp
示例5: ReduceRectToVerticalEdge
/*
* Reduce rect to 1 app unit width along either left or right edge base on
* aToRightEdge parameter.
*/
static void
ReduceRectToVerticalEdge(nsRect& aRect, bool aToRightEdge)
{
if (aToRightEdge) {
aRect.x = aRect.XMost() - 1;
}
aRect.width = 1;
}
开发者ID:,项目名称:,代码行数:12,代码来源:
示例6:
bool
DisplayItemClip::MayIntersect(const nsRect& aRect) const
{
if (!mHaveClipRect) {
return !aRect.IsEmpty();
}
nsRect r = aRect.Intersect(mClipRect);
if (r.IsEmpty()) {
return false;
}
for (uint32_t i = 0; i < mRoundedClipRects.Length(); ++i) {
const RoundedRect& rr = mRoundedClipRects[i];
if (!nsLayoutUtils::RoundedRectIntersectsRect(rr.mRect, rr.mRadii, r)) {
return false;
}
}
return true;
}
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:18,代码来源:DisplayItemClip.cpp
示例7: GetClipRect
NS_IMETHODIMP nsRenderingContextPh :: GetClipRect( nsRect &aRect, PRBool &aClipValid )
{
PRInt32 x, y, w, h;
if ( !mClipRegion )
return NS_ERROR_FAILURE;
if( !mClipRegion->IsEmpty() ) {
mClipRegion->GetBoundingBox( &x, &y, &w, &h );
aRect.SetRect( x, y, w, h );
aClipValid = PR_TRUE;
}
else {
aRect.SetRect(0,0,0,0);
aClipValid = PR_FALSE;
}
return NS_OK;
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:18,代码来源:nsRenderingContextPh.cpp
示例8: ComputeFullAreaUsingScreen
nsresult
nsDeviceContext::GetRect(nsRect &aRect)
{
if (IsPrinterContext()) {
aRect.SetRect(0, 0, mWidth, mHeight);
} else
ComputeFullAreaUsingScreen ( &aRect );
return NS_OK;
}
开发者ID:,项目名称:,代码行数:10,代码来源:
示例9: AccumulateRectDifference
// Computes the difference between aR1 and aR2, limited to aBounds.
static void
AccumulateRectDifference(const nsRect& aR1, const nsRect& aR2, const nsRect& aBounds, nsRegion* aOut)
{
if (aR1.IsEqualInterior(aR2))
return;
nsRegion r;
r.Xor(aR1, aR2);
r.And(r, aBounds);
aOut->Or(*aOut, r);
}
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:11,代码来源:DisplayItemClip.cpp
示例10: GetSVGBBox
static nsRect
GetSVGBBox(nsIFrame* aNonSVGFrame, nsIFrame* aCurrentFrame,
const nsRect& aCurrentOverflow, const nsRect& aUserSpaceRect)
{
NS_ASSERTION(!aNonSVGFrame->GetPrevContinuation(),
"Need first continuation here");
// Compute union of all overflow areas relative to 'first'.
BBoxCollector collector(aNonSVGFrame, aCurrentFrame, aCurrentOverflow);
nsLayoutUtils::GetAllInFlowBoxes(aNonSVGFrame, &collector);
// Get it into "user space" for non-SVG frames
return collector.mResult - aUserSpaceRect.TopLeft();
}
开发者ID:,项目名称:,代码行数:12,代码来源:
示例11: ClipMarker
static void
ClipMarker(const nsRect& aContentArea,
const nsRect& aMarkerRect,
DisplayListClipState::AutoSaveRestore& aClipState)
{
nscoord rightOverflow = aMarkerRect.XMost() - aContentArea.XMost();
nsRect markerRect = aMarkerRect;
if (rightOverflow > 0) {
// Marker overflows on the right side (content width < marker width).
markerRect.width -= rightOverflow;
aClipState.ClipContentDescendants(markerRect);
} else {
nscoord leftOverflow = aContentArea.x - aMarkerRect.x;
if (leftOverflow > 0) {
// Marker overflows on the left side
markerRect.width -= leftOverflow;
markerRect.x += leftOverflow;
aClipState.ClipContentDescendants(markerRect);
}
}
}
开发者ID:JuannyWang,项目名称:gecko-dev,代码行数:21,代码来源:TextOverflow.cpp
示例12: GetBorderAndPadding
nsresult
nsIFrame::GetClientRect(nsRect& aClientRect)
{
aClientRect = mRect;
aClientRect.MoveTo(0,0);
nsMargin borderPadding;
GetBorderAndPadding(borderPadding);
aClientRect.Deflate(borderPadding);
if (aClientRect.width < 0)
aClientRect.width = 0;
if (aClientRect.height < 0)
aClientRect.height = 0;
// NS_ASSERTION(aClientRect.width >=0 && aClientRect.height >= 0, "Content Size < 0");
return NS_OK;
}
开发者ID:,项目名称:,代码行数:21,代码来源:
示例13: os
void
nsBlockReflowState::ComputeReplacedBlockOffsetsForFloats(nsIFrame* aFrame,
const nsRect& aFloatAvailableSpace,
nscoord& aLeftResult,
nscoord& aRightResult)
{
nsRect contentArea =
mContentArea.GetPhysicalRect(mReflowState.GetWritingMode(), mContainerWidth);
// The frame is clueless about the float manager and therefore we
// only give it free space. An example is a table frame - the
// tables do not flow around floats.
// However, we can let its margins intersect floats.
NS_ASSERTION(aFloatAvailableSpace.x >= contentArea.x, "bad avail space rect x");
NS_ASSERTION(aFloatAvailableSpace.width == 0 ||
aFloatAvailableSpace.XMost() <= contentArea.XMost(),
"bad avail space rect width");
nscoord leftOffset, rightOffset;
if (aFloatAvailableSpace.width == contentArea.width) {
// We don't need to compute margins when there are no floats around.
leftOffset = 0;
rightOffset = 0;
} else {
nsMargin frameMargin;
nsCSSOffsetState os(aFrame, mReflowState.rendContext, contentArea.width);
frameMargin = os.ComputedPhysicalMargin();
nscoord leftFloatXOffset = aFloatAvailableSpace.x - contentArea.x;
leftOffset = std::max(leftFloatXOffset, frameMargin.left) -
frameMargin.left;
leftOffset = std::max(leftOffset, 0); // in case of negative margin
nscoord rightFloatXOffset =
contentArea.XMost() - aFloatAvailableSpace.XMost();
rightOffset = std::max(rightFloatXOffset, frameMargin.right) -
frameMargin.right;
rightOffset = std::max(rightOffset, 0); // in case of negative margin
}
aLeftResult = leftOffset;
aRightResult = rightOffset;
}
开发者ID:,项目名称:,代码行数:40,代码来源:
示例14: GetRect
void CircleArea::GetRect(nsIFrame* aFrame, nsRect& aRect)
{
if (mNumCoords >= 3) {
nscoord x1 = nsPresContext::CSSPixelsToAppUnits(mCoords[0]);
nscoord y1 = nsPresContext::CSSPixelsToAppUnits(mCoords[1]);
nscoord radius = nsPresContext::CSSPixelsToAppUnits(mCoords[2]);
if (radius < 0) {
return;
}
aRect.SetRect(x1 - radius, y1 - radius, x1 + radius, y1 + radius);
}
}
开发者ID:,项目名称:,代码行数:13,代码来源:
示例15: r
void
nsSVGForeignObjectFrame::InvalidateDirtyRect(nsSVGOuterSVGFrame* aOuter,
const nsRect& aRect, PRUint32 aFlags)
{
if (aRect.IsEmpty())
return;
// Don't invalidate areas outside our bounds:
nsRect rect = aRect.Intersect(mRect);
if (rect.IsEmpty())
return;
// The areas dirtied by children are in app units, relative to this frame.
// We need to convert the rect from app units in our userspace to app units
// relative to our nsSVGOuterSVGFrame's content rect.
gfxRect r(aRect.x, aRect.y, aRect.width, aRect.height);
r.Scale(1.0 / nsPresContext::AppUnitsPerCSSPixel());
rect = ToCanvasBounds(r, GetCanvasTM(), PresContext());
rect = nsSVGUtils::FindFilterInvalidation(this, rect);
aOuter->InvalidateWithFlags(rect, aFlags);
}
开发者ID:,项目名称:,代码行数:22,代码来源:
示例16: ProcessMatrix3D
static void
ProcessMatrix3D(gfx3DMatrix& aMatrix,
const nsCSSValue::Array* aData,
nsStyleContext* aContext,
nsPresContext* aPresContext,
bool& aCanStoreInRuleTree,
nsRect& aBounds)
{
NS_PRECONDITION(aData->Count() == 17, "Invalid array!");
gfx3DMatrix temp;
temp._11 = aData->Item(1).GetFloatValue();
temp._12 = aData->Item(2).GetFloatValue();
temp._13 = aData->Item(3).GetFloatValue();
temp._14 = aData->Item(4).GetFloatValue();
temp._21 = aData->Item(5).GetFloatValue();
temp._22 = aData->Item(6).GetFloatValue();
temp._23 = aData->Item(7).GetFloatValue();
temp._24 = aData->Item(8).GetFloatValue();
temp._31 = aData->Item(9).GetFloatValue();
temp._32 = aData->Item(10).GetFloatValue();
temp._33 = aData->Item(11).GetFloatValue();
temp._34 = aData->Item(12).GetFloatValue();
temp._44 = aData->Item(16).GetFloatValue();
temp._41 = ProcessTranslatePart(aData->Item(13),
aContext, aPresContext, aCanStoreInRuleTree,
aBounds.Width());
temp._42 = ProcessTranslatePart(aData->Item(14),
aContext, aPresContext, aCanStoreInRuleTree,
aBounds.Height());
temp._43 = ProcessTranslatePart(aData->Item(15),
aContext, aPresContext, aCanStoreInRuleTree,
aBounds.Height());
aMatrix.PreMultiply(temp);
}
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:38,代码来源:nsStyleTransformMatrix.cpp
示例17: UnionRect
// Computes the smallest rectangle that contains both aRect1 and aRect2 and
// fills 'this' with the result. Returns FALSE if both aRect1 and aRect2 are
// empty and TRUE otherwise
PRBool nsRect::UnionRect(const nsRect &aRect1, const nsRect &aRect2)
{
PRBool result = PR_TRUE;
// Is aRect1 empty?
if (aRect1.IsEmpty()) {
if (aRect2.IsEmpty()) {
// Both rectangles are empty which is an error
Empty();
result = PR_FALSE;
} else {
// aRect1 is empty so set the result to aRect2
*this = aRect2;
}
} else if (aRect2.IsEmpty()) {
// aRect2 is empty so set the result to aRect1
*this = aRect1;
} else {
UnionRectIncludeEmpty(aRect1, aRect2);
}
return result;
}
开发者ID:MozillaOnline,项目名称:gecko-dev,代码行数:26,代码来源:nsRect.cpp
示例18: ProcessTranslatePart
/* Helper function to process a translate function. */
/* static */ gfx3DMatrix
nsStyleTransformMatrix::ProcessTranslate(const nsCSSValue::Array* aData,
nsStyleContext* aContext,
nsPresContext* aPresContext,
PRBool& aCanStoreInRuleTree,
nsRect& aBounds, float aAppUnitsPerMatrixUnit)
{
NS_PRECONDITION(aData->Count() == 2 || aData->Count() == 3, "Invalid array!");
gfx3DMatrix temp;
ProcessTranslatePart(temp._41, aData->Item(1),
aContext, aPresContext, aCanStoreInRuleTree,
aBounds.Width(), aAppUnitsPerMatrixUnit);
/* If we read in a Y component, set it appropriately */
if (aData->Count() == 3) {
ProcessTranslatePart(temp._42, aData->Item(2),
aContext, aPresContext, aCanStoreInRuleTree,
aBounds.Height(), aAppUnitsPerMatrixUnit);
}
return temp;
}
开发者ID:mozilla,项目名称:mozilla-history,代码行数:24,代码来源:nsStyleTransformMatrix.cpp
示例19: ProcessTranslate
/* Helper function to process a translate function. */
static void
ProcessTranslate(gfx3DMatrix& aMatrix,
const nsCSSValue::Array* aData,
nsStyleContext* aContext,
nsPresContext* aPresContext,
bool& aCanStoreInRuleTree,
nsRect& aBounds)
{
NS_PRECONDITION(aData->Count() == 2 || aData->Count() == 3, "Invalid array!");
Point3D temp;
temp.x = ProcessTranslatePart(aData->Item(1),
aContext, aPresContext, aCanStoreInRuleTree,
aBounds.Width());
/* If we read in a Y component, set it appropriately */
if (aData->Count() == 3) {
temp.y = ProcessTranslatePart(aData->Item(2),
aContext, aPresContext, aCanStoreInRuleTree,
aBounds.Height());
}
aMatrix.Translate(temp);
}
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:25,代码来源:nsStyleTransformMatrix.cpp
示例20: imageSize
/* static */ void
nsSVGIntegrationUtils::DrawPaintServer(nsIRenderingContext* aRenderingContext,
nsIFrame* aTarget,
nsIFrame* aPaintServer,
gfxPattern::GraphicsFilter aFilter,
const nsRect& aDest,
const nsRect& aFill,
const nsPoint& aAnchor,
const nsRect& aDirty,
const nsSize& aPaintServerSize)
{
if (aDest.IsEmpty() || aFill.IsEmpty())
return;
PRInt32 appUnitsPerDevPixel = aTarget->PresContext()->AppUnitsPerDevPixel();
nsRect destSize = aDest - aDest.TopLeft();
nsIntSize roundedOut = destSize.ToOutsidePixels(appUnitsPerDevPixel).Size();
gfxIntSize imageSize(roundedOut.width, roundedOut.height);
nsRefPtr<gfxDrawable> drawable =
DrawableFromPaintServer(aPaintServer, aTarget, aPaintServerSize, imageSize);
nsLayoutUtils::DrawPixelSnapped(aRenderingContext, drawable, aFilter,
aDest, aFill, aAnchor, aDirty);
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:24,代码来源:nsSVGIntegrationUtils.cpp
注:本文中的nsRect类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论