本文整理汇总了C++中nsRect::TopLeft方法的典型用法代码示例。如果您正苦于以下问题:C++ nsRect::TopLeft方法的具体用法?C++ nsRect::TopLeft怎么用?C++ nsRect::TopLeft使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsRect
的用法示例。
在下文中一共展示了nsRect::TopLeft方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: imageSize
/* static */ void
nsSVGIntegrationUtils::DrawPaintServer(nsRenderingContext* 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);
if (drawable) {
nsLayoutUtils::DrawPixelSnapped(aRenderingContext, drawable, aFilter,
aDest, aFill, aAnchor, aDirty);
}
}
示例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.SetHeight(nsPresContext::AppUnitsToIntCSSPixels(aRect.Height()));
aRect.SetWidth(nsPresContext::AppUnitsToIntCSSPixels(aRect.Width()));
return NS_OK;
}
示例3: collector
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();
}
示例4: indent
//.........这里部分代码省略.........
// Do the reflow
nsHTMLReflowMetrics kidDesiredSize(kidReflowState);
aKidFrame->Reflow(aPresContext, kidDesiredSize, kidReflowState, aStatus);
const LogicalSize kidSize = kidDesiredSize.Size(wm).ConvertTo(outerWM, wm);
LogicalMargin offsets =
kidReflowState.ComputedLogicalOffsets().ConvertTo(outerWM, wm);
// If we're solving for start in either inline or block direction,
// then compute it now that we know the dimensions.
if ((NS_AUTOOFFSET == offsets.IStart(outerWM)) ||
(NS_AUTOOFFSET == offsets.BStart(outerWM))) {
if (-1 == logicalCBSize.ISize(wm)) {
// Get the containing block width/height
logicalCBSize =
kidReflowState.ComputeContainingBlockRectangle(aPresContext,
&aReflowState);
}
if (NS_AUTOOFFSET == offsets.IStart(outerWM)) {
NS_ASSERTION(NS_AUTOOFFSET != offsets.IEnd(outerWM),
"Can't solve for both start and end");
offsets.IStart(outerWM) =
logicalCBSize.ConvertTo(outerWM, wm).ISize(outerWM) -
offsets.IEnd(outerWM) - margin.IStartEnd(outerWM) -
kidSize.ISize(outerWM);
}
if (NS_AUTOOFFSET == offsets.BStart(outerWM)) {
offsets.BStart(outerWM) =
logicalCBSize.ConvertTo(outerWM, wm).BSize(outerWM) -
offsets.BEnd(outerWM) - margin.BStartEnd(outerWM) -
kidSize.BSize(outerWM);
}
kidReflowState.SetComputedLogicalOffsets(offsets.ConvertTo(wm, outerWM));
}
// Position the child relative to our padding edge
LogicalRect rect(outerWM,
border.IStart(outerWM) + offsets.IStart(outerWM) +
margin.IStart(outerWM),
border.BStart(outerWM) + offsets.BStart(outerWM) +
margin.BStart(outerWM),
kidSize.ISize(outerWM), kidSize.BSize(outerWM));
nsRect r =
rect.GetPhysicalRect(outerWM, logicalCBSize.GetPhysicalSize(wm) +
border.Size(outerWM).GetPhysicalSize(outerWM));
// Offset the frame rect by the given origin of the absolute containing block.
// If the frame is auto-positioned on both sides of an axis, it will be
// positioned based on its containing block and we don't need to offset
// (unless the caller demands it (the STATIC_POS_IS_CB_ORIGIN case)).
if (aContainingBlock.TopLeft() != nsPoint(0, 0)) {
const nsStyleSides& offsets = kidReflowState.mStylePosition->mOffset;
if (!(offsets.GetLeftUnit() == eStyleUnit_Auto &&
offsets.GetRightUnit() == eStyleUnit_Auto) ||
(rsFlags & nsHTMLReflowState::STATIC_POS_IS_CB_ORIGIN)) {
r.x += aContainingBlock.x;
}
if (!(offsets.GetTopUnit() == eStyleUnit_Auto &&
offsets.GetBottomUnit() == eStyleUnit_Auto) ||
(rsFlags & nsHTMLReflowState::STATIC_POS_IS_CB_ORIGIN)) {
r.y += aContainingBlock.y;
}
}
aKidFrame->SetRect(r);
nsView* view = aKidFrame->GetView();
if (view) {
// Size and position the view and set its opacity, visibility, content
// transparency, and clip
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aKidFrame, view,
kidDesiredSize.VisualOverflow());
} else {
nsContainerFrame::PositionChildViews(aKidFrame);
}
aKidFrame->DidReflow(aPresContext, &kidReflowState,
nsDidReflowStatus::FINISHED);
#ifdef DEBUG
if (nsBlockFrame::gNoisyReflow) {
nsFrame::IndentBy(stdout,nsBlockFrame::gNoiseIndent - 1);
printf("abs pos ");
if (aKidFrame) {
nsAutoString name;
aKidFrame->GetFrameName(name);
printf("%s ", NS_LossyConvertUTF16toASCII(name).get());
}
printf("%p rect=%d,%d,%d,%d\n", static_cast<void*>(aKidFrame),
r.x, r.y, r.width, r.height);
}
#endif
if (aOverflowAreas) {
aOverflowAreas->UnionWith(kidDesiredSize.mOverflowAreas + r.TopLeft());
}
}
示例5: indent
//.........这里部分代码省略.........
&& (aDelegatingFrame->GetType() != nsGkAtoms::inlineFrame)
//XXX we don't handle splitting frames for inline absolute containing blocks yet
&& (aKidFrame->GetRect().y <= aReflowState.AvailableHeight());
// Don't split things below the fold. (Ideally we shouldn't *have*
// anything totally below the fold, but we can't position frames
// across next-in-flow breaks yet.
if (constrainHeight) {
kidReflowState.AvailableHeight() = aReflowState.AvailableHeight() - border.top
- kidReflowState.ComputedPhysicalMargin().top;
if (NS_AUTOOFFSET != kidReflowState.ComputedPhysicalOffsets().top)
kidReflowState.AvailableHeight() -= kidReflowState.ComputedPhysicalOffsets().top;
}
// Do the reflow
aKidFrame->Reflow(aPresContext, kidDesiredSize, kidReflowState, aStatus);
// If we're solving for 'left' or 'top', then compute it now that we know the
// width/height
if ((NS_AUTOOFFSET == kidReflowState.ComputedPhysicalOffsets().left) ||
(NS_AUTOOFFSET == kidReflowState.ComputedPhysicalOffsets().top)) {
nscoord aContainingBlockWidth = aContainingBlock.width;
nscoord aContainingBlockHeight = aContainingBlock.height;
if (-1 == aContainingBlockWidth) {
// Get the containing block width/height
kidReflowState.ComputeContainingBlockRectangle(aPresContext,
&aReflowState,
aContainingBlockWidth,
aContainingBlockHeight);
}
if (NS_AUTOOFFSET == kidReflowState.ComputedPhysicalOffsets().left) {
NS_ASSERTION(NS_AUTOOFFSET != kidReflowState.ComputedPhysicalOffsets().right,
"Can't solve for both left and right");
kidReflowState.ComputedPhysicalOffsets().left = aContainingBlockWidth -
kidReflowState.ComputedPhysicalOffsets().right -
kidReflowState.ComputedPhysicalMargin().right -
kidDesiredSize.Width() -
kidReflowState.ComputedPhysicalMargin().left;
}
if (NS_AUTOOFFSET == kidReflowState.ComputedPhysicalOffsets().top) {
kidReflowState.ComputedPhysicalOffsets().top = aContainingBlockHeight -
kidReflowState.ComputedPhysicalOffsets().bottom -
kidReflowState.ComputedPhysicalMargin().bottom -
kidDesiredSize.Height() -
kidReflowState.ComputedPhysicalMargin().top;
}
}
// Position the child relative to our padding edge
nsRect rect(border.left + kidReflowState.ComputedPhysicalOffsets().left + kidReflowState.ComputedPhysicalMargin().left,
border.top + kidReflowState.ComputedPhysicalOffsets().top + kidReflowState.ComputedPhysicalMargin().top,
kidDesiredSize.Width(), kidDesiredSize.Height());
// Offset the frame rect by the given origin of the absolute containing block.
// If the frame is auto-positioned on both sides of an axis, it will be
// positioned based on its containing block and we don't need to offset.
if (aContainingBlock.TopLeft() != nsPoint(0, 0)) {
if (!(kidReflowState.mStylePosition->mOffset.GetLeftUnit() == eStyleUnit_Auto &&
kidReflowState.mStylePosition->mOffset.GetRightUnit() == eStyleUnit_Auto)) {
rect.x += aContainingBlock.x;
}
if (!(kidReflowState.mStylePosition->mOffset.GetTopUnit() == eStyleUnit_Auto &&
kidReflowState.mStylePosition->mOffset.GetBottomUnit() == eStyleUnit_Auto)) {
rect.y += aContainingBlock.y;
}
}
aKidFrame->SetRect(rect);
nsView* view = aKidFrame->GetView();
if (view) {
// Size and position the view and set its opacity, visibility, content
// transparency, and clip
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aKidFrame, view,
kidDesiredSize.VisualOverflow());
} else {
nsContainerFrame::PositionChildViews(aKidFrame);
}
aKidFrame->DidReflow(aPresContext, &kidReflowState, nsDidReflowStatus::FINISHED);
#ifdef DEBUG
if (nsBlockFrame::gNoisyReflow) {
nsFrame::IndentBy(stdout,nsBlockFrame::gNoiseIndent - 1);
printf("abs pos ");
if (aKidFrame) {
nsAutoString name;
aKidFrame->GetFrameName(name);
printf("%s ", NS_LossyConvertUTF16toASCII(name).get());
}
printf("%p rect=%d,%d,%d,%d\n", static_cast<void*>(aKidFrame),
rect.x, rect.y, rect.width, rect.height);
}
#endif
if (aOverflowAreas) {
aOverflowAreas->UnionWith(kidDesiredSize.mOverflowAreas + rect.TopLeft());
}
}
示例6: UpdateDrawResult
DrawResult
TableBackgroundPainter::PaintCell(nsTableCellFrame* aCell,
const TableBackgroundData& aRowGroupBGData,
const TableBackgroundData& aRowBGData,
nsRect& aCellBGRect,
nsRect& aRowBGRect,
nsRect& aRowGroupBGRect,
nsRect& aColBGRect,
bool aPassSelf)
{
MOZ_ASSERT(aCell, "null frame");
const nsStyleTableBorder* cellTableStyle;
cellTableStyle = aCell->StyleTableBorder();
if (NS_STYLE_TABLE_EMPTY_CELLS_SHOW != cellTableStyle->mEmptyCells &&
aCell->GetContentEmpty() && !mIsBorderCollapse) {
return DrawResult::SUCCESS;
}
int32_t colIndex;
aCell->GetColIndex(colIndex);
// We're checking mNumCols instead of mCols.Length() here because mCols can
// be empty even if mNumCols > 0.
NS_ASSERTION(size_t(colIndex) < mNumCols, "out-of-bounds column index");
if (size_t(colIndex) >= mNumCols) {
return DrawResult::SUCCESS;
}
// If callers call PaintRowGroup or PaintRow directly, we haven't processed
// our columns. Ignore column / col group backgrounds in that case.
bool haveColumns = !mCols.IsEmpty();
DrawResult result = DrawResult::SUCCESS;
//Paint column group background
if (haveColumns && mCols[colIndex].mColGroup.IsVisible()) {
DrawResult colGroupResult =
nsCSSRendering::PaintBackgroundWithSC(mPresContext, mRenderingContext,
mCols[colIndex].mColGroup.mFrame, mDirtyRect,
mCols[colIndex].mColGroup.mRect + mRenderPt,
mCols[colIndex].mColGroup.mFrame->StyleContext(),
mCols[colIndex].mColGroup.StyleBorder(mZeroBorder),
mBGPaintFlags, &aColBGRect);
UpdateDrawResult(&result, colGroupResult);
}
//Paint column background
if (haveColumns && mCols[colIndex].mCol.IsVisible()) {
DrawResult colResult =
nsCSSRendering::PaintBackgroundWithSC(mPresContext, mRenderingContext,
mCols[colIndex].mCol.mFrame, mDirtyRect,
mCols[colIndex].mCol.mRect + mRenderPt,
mCols[colIndex].mCol.mFrame->StyleContext(),
mCols[colIndex].mCol.StyleBorder(mZeroBorder),
mBGPaintFlags, &aColBGRect);
UpdateDrawResult(&result, colResult);
}
//Paint row group background
if (aRowGroupBGData.IsVisible()) {
DrawResult rowGroupResult =
nsCSSRendering::PaintBackgroundWithSC(mPresContext, mRenderingContext,
aRowGroupBGData.mFrame, mDirtyRect,
aRowGroupBGData.mRect + mRenderPt,
aRowGroupBGData.mFrame->StyleContext(),
aRowGroupBGData.StyleBorder(mZeroBorder),
mBGPaintFlags, &aRowGroupBGRect);
UpdateDrawResult(&result, rowGroupResult);
}
//Paint row background
if (aRowBGData.IsVisible()) {
DrawResult rowResult =
nsCSSRendering::PaintBackgroundWithSC(mPresContext, mRenderingContext,
aRowBGData.mFrame, mDirtyRect,
aRowBGData.mRect + mRenderPt,
aRowBGData.mFrame->StyleContext(),
aRowBGData.StyleBorder(mZeroBorder),
mBGPaintFlags, &aRowBGRect);
UpdateDrawResult(&result, rowResult);
}
//Paint cell background in border-collapse unless we're just passing
if (mIsBorderCollapse && !aPassSelf) {
DrawResult cellResult =
aCell->PaintCellBackground(mRenderingContext, mDirtyRect,
aCellBGRect.TopLeft(), mBGPaintFlags);
UpdateDrawResult(&result, cellResult);
}
return result;
}
示例7: indent
//.........这里部分代码省略.........
margin.IStart(outerWM) = margin.IEnd(outerWM) = 0;
}
if (kidReflowInput.mFlags.mBOffsetsNeedCSSAlign) {
margin.BStart(outerWM) = margin.BEnd(outerWM) = 0;
}
bool constrainBSize = (aReflowInput.AvailableBSize() != NS_UNCONSTRAINEDSIZE)
&& (aFlags & AbsPosReflowFlags::eConstrainHeight)
// Don't split if told not to (e.g. for fixed frames)
&& (aDelegatingFrame->GetType() != nsGkAtoms::inlineFrame)
//XXX we don't handle splitting frames for inline absolute containing blocks yet
&& (aKidFrame->GetLogicalRect(aContainingBlock.Size()).BStart(wm) <=
aReflowInput.AvailableBSize());
// Don't split things below the fold. (Ideally we shouldn't *have*
// anything totally below the fold, but we can't position frames
// across next-in-flow breaks yet.
if (constrainBSize) {
kidReflowInput.AvailableBSize() =
aReflowInput.AvailableBSize() - border.ConvertTo(wm, outerWM).BStart(wm) -
kidReflowInput.ComputedLogicalMargin().BStart(wm);
if (NS_AUTOOFFSET != kidReflowInput.ComputedLogicalOffsets().BStart(wm)) {
kidReflowInput.AvailableBSize() -=
kidReflowInput.ComputedLogicalOffsets().BStart(wm);
}
}
// Do the reflow
ReflowOutput kidDesiredSize(kidReflowInput);
aKidFrame->Reflow(aPresContext, kidDesiredSize, kidReflowInput, aStatus);
const LogicalSize kidSize = kidDesiredSize.Size(wm).ConvertTo(outerWM, wm);
LogicalMargin offsets =
kidReflowInput.ComputedLogicalOffsets().ConvertTo(outerWM, wm);
// If we're solving for start in either inline or block direction,
// then compute it now that we know the dimensions.
ResolveSizeDependentOffsets(aPresContext, kidReflowInput, kidSize, margin,
&offsets, &logicalCBSize);
// Position the child relative to our padding edge
LogicalRect rect(outerWM,
border.IStart(outerWM) + offsets.IStart(outerWM) +
margin.IStart(outerWM),
border.BStart(outerWM) + offsets.BStart(outerWM) +
margin.BStart(outerWM),
kidSize.ISize(outerWM), kidSize.BSize(outerWM));
nsRect r =
rect.GetPhysicalRect(outerWM, logicalCBSize.GetPhysicalSize(wm) +
border.Size(outerWM).GetPhysicalSize(outerWM));
// Offset the frame rect by the given origin of the absolute containing block.
// If the frame is auto-positioned on both sides of an axis, it will be
// positioned based on its containing block and we don't need to offset
// (unless the caller demands it (the STATIC_POS_IS_CB_ORIGIN case)).
if (aContainingBlock.TopLeft() != nsPoint(0, 0)) {
const nsStyleSides& offsets = kidReflowInput.mStylePosition->mOffset;
if (!(offsets.GetLeftUnit() == eStyleUnit_Auto &&
offsets.GetRightUnit() == eStyleUnit_Auto) ||
(rsFlags & ReflowInput::STATIC_POS_IS_CB_ORIGIN)) {
r.x += aContainingBlock.x;
}
if (!(offsets.GetTopUnit() == eStyleUnit_Auto &&
offsets.GetBottomUnit() == eStyleUnit_Auto) ||
(rsFlags & ReflowInput::STATIC_POS_IS_CB_ORIGIN)) {
r.y += aContainingBlock.y;
}
}
aKidFrame->SetRect(r);
nsView* view = aKidFrame->GetView();
if (view) {
// Size and position the view and set its opacity, visibility, content
// transparency, and clip
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, aKidFrame, view,
kidDesiredSize.VisualOverflow());
} else {
nsContainerFrame::PositionChildViews(aKidFrame);
}
aKidFrame->DidReflow(aPresContext, &kidReflowInput,
nsDidReflowStatus::FINISHED);
#ifdef DEBUG
if (nsBlockFrame::gNoisyReflow) {
nsFrame::IndentBy(stdout,nsBlockFrame::gNoiseIndent - 1);
printf("abs pos ");
nsAutoString name;
aKidFrame->GetFrameName(name);
printf("%s ", NS_LossyConvertUTF16toASCII(name).get());
printf("%p rect=%d,%d,%d,%d\n", static_cast<void*>(aKidFrame),
r.x, r.y, r.width, r.height);
}
#endif
if (aOverflowAreas) {
aOverflowAreas->UnionWith(kidDesiredSize.mOverflowAreas + r.TopLeft());
}
}