本文整理汇总了C++中nsHTMLReflowState::ComputedLogicalPadding方法的典型用法代码示例。如果您正苦于以下问题:C++ nsHTMLReflowState::ComputedLogicalPadding方法的具体用法?C++ nsHTMLReflowState::ComputedLogicalPadding怎么用?C++ nsHTMLReflowState::ComputedLogicalPadding使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsHTMLReflowState
的用法示例。
在下文中一共展示了nsHTMLReflowState::ComputedLogicalPadding方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: availSize
void
nsTableCellFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsTableCellFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
if (aReflowState.mFlags.mSpecialBSizeReflow) {
FirstInFlow()->AddStateBits(NS_TABLE_CELL_HAD_SPECIAL_REFLOW);
}
// see if a special bsize reflow needs to occur due to having a pct height
nsTableFrame::CheckRequestSpecialBSizeReflow(aReflowState);
aStatus = NS_FRAME_COMPLETE;
WritingMode wm = aReflowState.GetWritingMode();
LogicalSize availSize(wm, aReflowState.AvailableISize(),
aReflowState.AvailableBSize());
LogicalMargin borderPadding = aReflowState.ComputedLogicalPadding();
LogicalMargin border = GetBorderWidth(wm);
borderPadding += border;
// reduce available space by insets, if we're in a constrained situation
availSize.ISize(wm) -= borderPadding.IStartEnd(wm);
if (NS_UNCONSTRAINEDSIZE != availSize.BSize(wm)) {
availSize.BSize(wm) -= borderPadding.BStartEnd(wm);
}
// Try to reflow the child into the available space. It might not
// fit or might need continuing.
if (availSize.BSize(wm) < 0) {
availSize.BSize(wm) = 1;
}
nsHTMLReflowMetrics kidSize(wm, aDesiredSize.mFlags);
kidSize.ClearSize();
SetPriorAvailISize(aReflowState.AvailableISize());
nsIFrame* firstKid = mFrames.FirstChild();
NS_ASSERTION(firstKid, "Frame construction error, a table cell always has an inner cell frame");
nsTableFrame* tableFrame = GetTableFrame();
if (aReflowState.mFlags.mSpecialBSizeReflow) {
const_cast<nsHTMLReflowState&>(aReflowState).
SetComputedBSize(BSize(wm) - borderPadding.BStartEnd(wm));
DISPLAY_REFLOW_CHANGE();
}
else if (aPresContext->IsPaginated()) {
nscoord computedUnpaginatedBSize =
CalcUnpaginatedBSize(aPresContext, (nsTableCellFrame&)*this,
*tableFrame, borderPadding.BStartEnd(wm));
if (computedUnpaginatedBSize > 0) {
const_cast<nsHTMLReflowState&>(aReflowState).SetComputedBSize(computedUnpaginatedBSize);
DISPLAY_REFLOW_CHANGE();
}
}
else {
SetHasPctOverBSize(false);
}
WritingMode kidWM = firstKid->GetWritingMode();
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, firstKid,
availSize.ConvertTo(kidWM, wm));
// Don't be a percent height observer if we're in the middle of
// special-bsize reflow, in case we get an accidental NotifyPercentBSize()
// call (which we shouldn't honor during special-bsize reflow)
if (!aReflowState.mFlags.mSpecialBSizeReflow) {
// mPercentBSizeObserver is for children of cells in quirks mode,
// but only those than are tables in standards mode. NeedsToObserve
// will determine how far this is propagated to descendants.
kidReflowState.mPercentBSizeObserver = this;
}
// Don't propagate special bsize reflow state to our kids
kidReflowState.mFlags.mSpecialBSizeReflow = false;
if (aReflowState.mFlags.mSpecialBSizeReflow ||
FirstInFlow()->HasAnyStateBits(NS_TABLE_CELL_HAD_SPECIAL_REFLOW)) {
// We need to force the kid to have mBResize set if we've had a
// special reflow in the past, since the non-special reflow needs to
// resize back to what it was without the special bsize reflow.
kidReflowState.SetBResize(true);
}
nsSize containerSize =
aReflowState.ComputedSizeAsContainerIfConstrained();
LogicalPoint kidOrigin(wm, borderPadding.IStart(wm),
borderPadding.BStart(wm));
nsRect origRect = firstKid->GetRect();
nsRect origVisualOverflow = firstKid->GetVisualOverflowRect();
bool firstReflow = firstKid->HasAnyStateBits(NS_FRAME_FIRST_REFLOW);
ReflowChild(firstKid, aPresContext, kidSize, kidReflowState,
wm, kidOrigin, containerSize, 0, aStatus);
if (NS_FRAME_OVERFLOW_IS_INCOMPLETE(aStatus)) {
// Don't pass OVERFLOW_INCOMPLETE through tables until they can actually handle it
//.........这里部分代码省略.........
示例2: gridOrigin
void
nsGridContainerFrame::ReflowChildren(GridItemCSSOrderIterator& aIter,
const LogicalRect& aContentArea,
const nsTArray<TrackSize>& aColSizes,
const nsTArray<TrackSize>& aRowSizes,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
WritingMode wm = aReflowState.GetWritingMode();
const LogicalPoint gridOrigin(aContentArea.Origin(wm));
const nscoord gridWidth = aContentArea.Width(wm);
nsPresContext* pc = PresContext();
for (; !aIter.AtEnd(); aIter.Next()) {
nsIFrame* child = *aIter;
GridArea* area = GetGridAreaForChild(child);
MOZ_ASSERT(area && area->IsDefinite());
LogicalRect cb = ContainingBlockFor(wm, *area, aColSizes, aRowSizes);
cb += gridOrigin;
nsHTMLReflowState childRS(pc, aReflowState, child, cb.Size(wm));
const LogicalMargin margin = childRS.ComputedLogicalMargin();
if (childRS.ComputedBSize() == NS_AUTOHEIGHT) {
// XXX the start of an align-self:stretch impl. Needs min-/max-bsize
// clamping though, and check the prop value is actually 'stretch'!
LogicalMargin bp = childRS.ComputedLogicalBorderPadding();
bp.ApplySkipSides(child->GetLogicalSkipSides());
nscoord bSize = cb.BSize(wm) - bp.BStartEnd(wm) - margin.BStartEnd(wm);
childRS.SetComputedBSize(std::max(bSize, 0));
}
LogicalPoint childPos = cb.Origin(wm);
childPos.I(wm) += margin.IStart(wm);
childPos.B(wm) += margin.BStart(wm);
nsHTMLReflowMetrics childSize(childRS);
nsReflowStatus childStatus;
ReflowChild(child, pc, childSize, childRS, wm, childPos,
gridWidth, 0, childStatus);
FinishReflowChild(child, pc, childSize, &childRS, wm, childPos,
gridWidth, 0);
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, child);
// XXX deal with 'childStatus' not being COMPLETE
}
if (IsAbsoluteContainer()) {
nsFrameList children(GetChildList(GetAbsoluteListID()));
if (!children.IsEmpty()) {
LogicalMargin pad(aReflowState.ComputedLogicalPadding());
pad.ApplySkipSides(GetLogicalSkipSides(&aReflowState));
// 'gridOrigin' is the origin of the grid (the start of the first track),
// with respect to the grid container's padding-box (CB).
const LogicalPoint gridOrigin(wm, pad.IStart(wm), pad.BStart(wm));
const LogicalRect gridCB(wm, 0, 0,
aContentArea.ISize(wm) + pad.IStartEnd(wm),
aContentArea.BSize(wm) + pad.BStartEnd(wm));
for (nsFrameList::Enumerator e(children); !e.AtEnd(); e.Next()) {
nsIFrame* child = e.get();
GridArea* area = GetGridAreaForChild(child);
MOZ_ASSERT(area);
LogicalRect itemCB(ContainingBlockForAbsPos(wm, *area,
aColSizes, aRowSizes,
gridOrigin, gridCB));
// nsAbsoluteContainingBlock::Reflow uses physical coordinates.
nsRect* cb = static_cast<nsRect*>(child->Properties().Get(
GridItemContainingBlockRect()));
if (!cb) {
cb = new nsRect;
child->Properties().Set(GridItemContainingBlockRect(), cb);
}
*cb = itemCB.GetPhysicalRect(wm, gridWidth);
}
// This rect isn't used at all for layout so we use it to optimize
// away the virtual GetType() call in the callee in most cases.
// @see nsAbsoluteContainingBlock::Reflow
nsRect dummyRect(0, 0, VERY_LIKELY_A_GRID_CONTAINER, 0);
GetAbsoluteContainingBlock()->Reflow(this, pc, aReflowState, aStatus,
dummyRect, true,
true, true, // XXX could be optimized
&aDesiredSize.mOverflowAreas);
}
}
}
示例3: legendMargin
void
nsFieldSetFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsFieldSetFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
NS_PRECONDITION(aReflowState.ComputedISize() != NS_INTRINSICSIZE,
"Should have a precomputed inline-size!");
// Initialize OUT parameter
aStatus = NS_FRAME_COMPLETE;
nsOverflowAreas ocBounds;
nsReflowStatus ocStatus = NS_FRAME_COMPLETE;
if (GetPrevInFlow()) {
ReflowOverflowContainerChildren(aPresContext, aReflowState, ocBounds, 0,
ocStatus);
}
//------------ Handle Incremental Reflow -----------------
bool reflowInner;
bool reflowLegend;
nsIFrame* legend = GetLegend();
nsIFrame* inner = GetInner();
if (aReflowState.ShouldReflowAllKids()) {
reflowInner = inner != nullptr;
reflowLegend = legend != nullptr;
} else {
reflowInner = inner && NS_SUBTREE_DIRTY(inner);
reflowLegend = legend && NS_SUBTREE_DIRTY(legend);
}
// We don't allow fieldsets to break vertically. If we did, we'd
// need logic here to push and pull overflow frames.
// Since we're not applying our padding in this frame, we need to add it here
// to compute the available width for our children.
WritingMode wm = GetWritingMode();
WritingMode innerWM = inner ? inner->GetWritingMode() : wm;
WritingMode legendWM = legend ? legend->GetWritingMode() : wm;
LogicalSize innerAvailSize = aReflowState.ComputedSizeWithPadding(innerWM);
LogicalSize legendAvailSize = aReflowState.ComputedSizeWithPadding(legendWM);
innerAvailSize.BSize(innerWM) = legendAvailSize.BSize(legendWM) =
NS_UNCONSTRAINEDSIZE;
NS_ASSERTION(!inner ||
nsLayoutUtils::IntrinsicForContainer(aReflowState.rendContext,
inner,
nsLayoutUtils::MIN_ISIZE) <=
innerAvailSize.ISize(innerWM),
"Bogus availSize.ISize; should be bigger");
NS_ASSERTION(!legend ||
nsLayoutUtils::IntrinsicForContainer(aReflowState.rendContext,
legend,
nsLayoutUtils::MIN_ISIZE) <=
legendAvailSize.ISize(legendWM),
"Bogus availSize.ISize; should be bigger");
// get our border and padding
LogicalMargin border = aReflowState.ComputedLogicalBorderPadding() -
aReflowState.ComputedLogicalPadding();
// Figure out how big the legend is if there is one.
// get the legend's margin
LogicalMargin legendMargin(wm);
// reflow the legend only if needed
Maybe<nsHTMLReflowState> legendReflowState;
if (legend) {
legendReflowState.emplace(aPresContext, aReflowState, legend,
legendAvailSize);
}
if (reflowLegend) {
nsHTMLReflowMetrics legendDesiredSize(aReflowState);
// We'll move the legend to its proper place later, so the position
// and containerSize passed here are unimportant.
const nsSize dummyContainerSize;
ReflowChild(legend, aPresContext, legendDesiredSize, *legendReflowState,
wm, LogicalPoint(wm), dummyContainerSize,
NS_FRAME_NO_MOVE_FRAME, aStatus);
#ifdef NOISY_REFLOW
printf(" returned (%d, %d)\n",
legendDesiredSize.Width(), legendDesiredSize.Height());
#endif
// figure out the legend's rectangle
legendMargin = legend->GetLogicalUsedMargin(wm);
mLegendRect =
LogicalRect(wm, 0, 0,
legendDesiredSize.ISize(wm) + legendMargin.IStartEnd(wm),
legendDesiredSize.BSize(wm) + legendMargin.BStartEnd(wm));
nscoord oldSpace = mLegendSpace;
mLegendSpace = 0;
if (mLegendRect.BSize(wm) > border.BStart(wm)) {
// center the border on the legend
mLegendSpace = mLegendRect.BSize(wm) - border.BStart(wm);
} else {
mLegendRect.BStart(wm) =
(border.BStart(wm) - mLegendRect.BSize(wm)) / 2;
//.........这里部分代码省略.........
示例4: contentsReflowState
void
nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aButtonDesiredSize,
const nsHTMLReflowState& aButtonReflowState,
nsIFrame* aFirstKid)
{
WritingMode wm = GetWritingMode();
bool isVertical = wm.IsVertical();
LogicalSize availSize = aButtonReflowState.ComputedSize(wm);
availSize.BSize(wm) = NS_INTRINSICSIZE;
// Buttons have some bonus renderer-determined border/padding,
// which occupies part of the button's content-box area:
const LogicalMargin focusPadding =
LogicalMargin(wm, mRenderer.GetAddedButtonBorderAndPadding());
// shorthand for a value we need to use in a bunch of places
const LogicalMargin& clbp = aButtonReflowState.ComputedLogicalBorderPadding();
// Indent the child inside us by the focus border. We must do this separate
// from the regular border.
availSize.ISize(wm) -= focusPadding.IStartEnd(wm);
// See whether out availSize's inline-size is big enough. If it's smaller than
// our intrinsic min iSize, that means that the kid wouldn't really fit; for a
// better look in such cases we adjust the available iSize and our inline-start
// offset to allow the kid to spill start-wards into our padding.
nscoord ioffset = focusPadding.IStart(wm) + clbp.IStart(wm);
nscoord extraISize = GetMinISize(aButtonReflowState.rendContext) -
aButtonReflowState.ComputedISize();
if (extraISize > 0) {
nscoord extraIStart = extraISize / 2;
nscoord extraIEnd = extraISize - extraIStart;
NS_ASSERTION(extraIEnd >=0, "How'd that happen?");
// Do not allow the extras to be bigger than the relevant padding
const LogicalMargin& padding = aButtonReflowState.ComputedLogicalPadding();
extraIStart = std::min(extraIStart, padding.IStart(wm));
extraIEnd = std::min(extraIEnd, padding.IEnd(wm));
ioffset -= extraIStart;
availSize.ISize(wm) = availSize.ISize(wm) + extraIStart + extraIEnd;
}
availSize.ISize(wm) = std::max(availSize.ISize(wm), 0);
// Give child a clone of the button's reflow state, with height/width reduced
// by focusPadding, so that descendants with height:100% don't protrude.
nsHTMLReflowState adjustedButtonReflowState =
CloneReflowStateWithReducedContentBox(aButtonReflowState,
focusPadding.GetPhysicalMargin(wm));
nsHTMLReflowState contentsReflowState(aPresContext,
adjustedButtonReflowState,
aFirstKid, availSize);
nsReflowStatus contentsReflowStatus;
nsHTMLReflowMetrics contentsDesiredSize(aButtonReflowState);
nscoord boffset = focusPadding.BStart(wm) + clbp.BStart(wm);
ReflowChild(aFirstKid, aPresContext,
contentsDesiredSize, contentsReflowState,
isVertical ? boffset : ioffset,
isVertical ? ioffset : boffset,
0, contentsReflowStatus);
MOZ_ASSERT(NS_FRAME_IS_COMPLETE(contentsReflowStatus),
"We gave button-contents frame unconstrained available height, "
"so it should be complete");
// Compute the button's content-box height:
nscoord buttonContentBoxBSize = 0;
if (aButtonReflowState.ComputedBSize() != NS_INTRINSICSIZE) {
// Button has a fixed block-size -- that's its content-box bSize.
buttonContentBoxBSize = aButtonReflowState.ComputedBSize();
} else {
// Button is intrinsically sized -- it should shrinkwrap the
// button-contents' bSize, plus any focus-padding space:
buttonContentBoxBSize =
contentsDesiredSize.BSize(wm) + focusPadding.BStartEnd(wm);
// Make sure we obey min/max-bSize in the case when we're doing intrinsic
// sizing (we get it for free when we have a non-intrinsic
// aButtonReflowState.ComputedBSize()). Note that we do this before
// adjusting for borderpadding, since mComputedMaxBSize and
// mComputedMinBSize are content bSizes.
buttonContentBoxBSize =
NS_CSS_MINMAX(buttonContentBoxBSize,
aButtonReflowState.ComputedMinBSize(),
aButtonReflowState.ComputedMaxBSize());
}
// Center child in the block-direction in the button
// (technically, inside of the button's focus-padding area)
nscoord extraSpace =
buttonContentBoxBSize - focusPadding.BStartEnd(wm) -
contentsDesiredSize.BSize(wm);
boffset = std::max(0, extraSpace / 2);
// Adjust boffset to be in terms of the button's frame-rect, instead of
// its focus-padding rect:
boffset += focusPadding.BStart(wm) + clbp.BStart(wm);
//.........这里部分代码省略.........