本文整理汇总了C++中nsHTMLReflowState::ComputedMaxBSize方法的典型用法代码示例。如果您正苦于以下问题:C++ nsHTMLReflowState::ComputedMaxBSize方法的具体用法?C++ nsHTMLReflowState::ComputedMaxBSize怎么用?C++ nsHTMLReflowState::ComputedMaxBSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsHTMLReflowState
的用法示例。
在下文中一共展示了nsHTMLReflowState::ComputedMaxBSize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: contentRect
//.........这里部分代码省略.........
// Make sure that the column has a next-in-flow. If not, we must
// create one to hold the overflowing stuff, even if we're just
// going to put it on our overflow list and let *our*
// next in flow handle it.
if (!kidNextInFlow) {
NS_ASSERTION(aStatus & NS_FRAME_REFLOW_NEXTINFLOW,
"We have to create a continuation, but the block doesn't want us to reflow it?");
// We need to create a continuing column
nsresult rv = CreateNextInFlow(child, kidNextInFlow);
if (NS_FAILED(rv)) {
NS_NOTREACHED("Couldn't create continuation");
child = nullptr;
break;
}
}
// Make sure we reflow a next-in-flow when it switches between being
// normal or overflow container
if (NS_FRAME_OVERFLOW_IS_INCOMPLETE(aStatus)) {
if (!(kidNextInFlow->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER)) {
aStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
reflowNext = true;
kidNextInFlow->AddStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER);
}
}
else if (kidNextInFlow->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER) {
aStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
reflowNext = true;
kidNextInFlow->RemoveStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER);
}
if ((contentBEnd > aReflowState.ComputedMaxBSize() ||
contentBEnd > aReflowState.ComputedBSize()) &&
aConfig.mBalanceColCount < INT32_MAX) {
// We overflowed vertically, but have not exceeded the number of
// columns. We're going to go into overflow columns now, so balancing
// no longer applies.
aColData.mHasExcessHeight = true;
}
if (columnCount >= aConfig.mBalanceColCount) {
// No more columns allowed here. Stop.
aStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
kidNextInFlow->AddStateBits(NS_FRAME_IS_DIRTY);
// Move any of our leftover columns to our overflow list. Our
// next-in-flow will eventually pick them up.
const nsFrameList& continuationColumns = mFrames.RemoveFramesAfter(child);
if (continuationColumns.NotEmpty()) {
SetOverflowFrames(continuationColumns);
}
child = nullptr;
break;
}
}
if (PresContext()->HasPendingInterrupt()) {
// Stop the loop now while |child| still points to the frame that bailed
// out. We could keep going here and condition a bunch of the code in
// this loop on whether there's an interrupt, or even just keep going and
// trying to reflow the blocks (even though we know they'll interrupt
// right after their first line), but stopping now is conceptually the
// simplest (and probably fastest) thing.
break;
}
示例2: legendMargin
//.........这里部分代码省略.........
mLegendRect.SetEmpty();
mLegendSpace = 0;
} else {
// mLegendSpace and mLegendRect haven't changed, but we need
// the used margin when placing the legend.
legendMargin = legend->GetLogicalUsedMargin(wm);
}
// This containerSize is incomplete as yet: it does not include the size
// of the |inner| frame itself.
nsSize containerSize = (LogicalSize(wm, 0, mLegendSpace) +
border.Size(wm)).GetPhysicalSize(wm);
// reflow the content frame only if needed
if (reflowInner) {
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, inner,
innerAvailSize, nullptr,
nsHTMLReflowState::CALLER_WILL_INIT);
// Override computed padding, in case it's percentage padding
kidReflowState.Init(aPresContext, nullptr, nullptr,
&aReflowState.ComputedPhysicalPadding());
// Our child is "height:100%" but we actually want its height to be reduced
// by the amount of content-height the legend is eating up, unless our
// height is unconstrained (in which case the child's will be too).
if (aReflowState.ComputedBSize() != NS_UNCONSTRAINEDSIZE) {
kidReflowState.SetComputedBSize(
std::max(0, aReflowState.ComputedBSize() - mLegendSpace));
}
if (aReflowState.ComputedMinBSize() > 0) {
kidReflowState.ComputedMinBSize() =
std::max(0, aReflowState.ComputedMinBSize() - mLegendSpace);
}
if (aReflowState.ComputedMaxBSize() != NS_UNCONSTRAINEDSIZE) {
kidReflowState.ComputedMaxBSize() =
std::max(0, aReflowState.ComputedMaxBSize() - mLegendSpace);
}
nsHTMLReflowMetrics kidDesiredSize(kidReflowState,
aDesiredSize.mFlags);
// Reflow the frame
NS_ASSERTION(kidReflowState.ComputedPhysicalMargin() == nsMargin(0,0,0,0),
"Margins on anonymous fieldset child not supported!");
LogicalPoint pt(wm, border.IStart(wm), border.BStart(wm) + mLegendSpace);
// We don't know the correct containerSize until we have reflowed |inner|,
// so we use a dummy value for now; FinishReflowChild will fix the position
// if necessary.
const nsSize dummyContainerSize;
ReflowChild(inner, aPresContext, kidDesiredSize, kidReflowState,
wm, pt, dummyContainerSize, 0, aStatus);
// Update containerSize to account for size of the inner frame, so that
// FinishReflowChild can position it correctly.
containerSize += kidDesiredSize.PhysicalSize();
FinishReflowChild(inner, aPresContext, kidDesiredSize,
&kidReflowState, wm, pt, containerSize, 0);
NS_FRAME_TRACE_REFLOW_OUT("FieldSet::Reflow", aStatus);
} else if (inner) {
// |inner| didn't need to be reflowed but we do need to include its size
// in containerSize.
containerSize += inner->GetSize();
}
LogicalRect contentRect(wm);
if (inner) {
示例3: childPos
void
nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aButtonDesiredSize,
const nsHTMLReflowState& aButtonReflowState,
nsIFrame* aFirstKid)
{
WritingMode wm = GetWritingMode();
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:
LogicalMargin focusPadding =
LogicalMargin(wm, mRenderer.GetAddedButtonBorderAndPadding());
// 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. In that case, we overflow into our internal
// focuspadding (which other browsers don't have) so that there's a
// little more space for it.
// Note that GetMinISize includes the focusPadding.
nscoord IOverflow = GetMinISize(aButtonReflowState.rendContext) -
aButtonReflowState.ComputedISize();
nscoord IFocusPadding = focusPadding.IStartEnd(wm);
nscoord focusPaddingReduction = std::min(IFocusPadding,
std::max(IOverflow, 0));
if (focusPaddingReduction > 0) {
nscoord startReduction = focusPadding.IStart(wm);
if (focusPaddingReduction != IFocusPadding) {
startReduction = NSToCoordRound(startReduction *
(float(focusPaddingReduction) /
float(IFocusPadding)));
}
focusPadding.IStart(wm) -= startReduction;
focusPadding.IEnd(wm) -= focusPaddingReduction - startReduction;
}
// 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);
LogicalPoint childPos(wm);
childPos.I(wm) = focusPadding.IStart(wm) + clbp.IStart(wm);
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);
childPos.B(wm) = 0; // This will be set properly later, after reflowing the
// child to determine its size.
// We just pass a dummy containerSize here, as the child will be
// repositioned later by FinishReflowChild.
nsSize dummyContainerSize;
ReflowChild(aFirstKid, aPresContext,
contentsDesiredSize, contentsReflowState,
wm, childPos, dummyContainerSize, 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 size:
LogicalSize buttonContentBox(wm);
if (aButtonReflowState.ComputedBSize() != NS_INTRINSICSIZE) {
// Button has a fixed block-size -- that's its content-box bSize.
buttonContentBox.BSize(wm) = aButtonReflowState.ComputedBSize();
} else {
// Button is intrinsically sized -- it should shrinkwrap the
// button-contents' bSize, plus any focus-padding space:
buttonContentBox.BSize(wm) =
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.
buttonContentBox.BSize(wm) =
NS_CSS_MINMAX(buttonContentBox.BSize(wm),
aButtonReflowState.ComputedMinBSize(),
aButtonReflowState.ComputedMaxBSize());
}
if (aButtonReflowState.ComputedISize() != NS_INTRINSICSIZE) {
buttonContentBox.ISize(wm) = aButtonReflowState.ComputedISize();
} else {
buttonContentBox.ISize(wm) =
contentsDesiredSize.ISize(wm) + focusPadding.IStartEnd(wm);
buttonContentBox.ISize(wm) =
//.........这里部分代码省略.........
示例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);
//.........这里部分代码省略.........
示例5: wrappersDesiredSize
//.........这里部分代码省略.........
if (!outerWrapperFrame) { // display:none?
if (contentBoxBSize == NS_INTRINSICSIZE) {
contentBoxBSize = 0;
borderBoxBSize =
aReflowState.ComputedLogicalBorderPadding().BStartEnd(myWM);
}
} else {
NS_ASSERTION(outerWrapperFrame == mFrames.FirstChild(), "huh?");
nsHTMLReflowMetrics wrappersDesiredSize(aReflowState);
WritingMode wrapperWM = outerWrapperFrame->GetWritingMode();
LogicalSize availSize = aReflowState.ComputedSize(wrapperWM);
availSize.BSize(wrapperWM) = NS_UNCONSTRAINEDSIZE;
nsHTMLReflowState wrapperReflowState(aPresContext, aReflowState,
outerWrapperFrame, availSize);
// Convert wrapper margin into my own writing-mode (in case it differs):
LogicalMargin wrapperMargin =
wrapperReflowState.ComputedLogicalMargin().ConvertTo(myWM, wrapperWM);
// offsets of wrapper frame within this frame:
LogicalPoint
wrapperOffset(myWM,
aReflowState.ComputedLogicalBorderPadding().IStart(myWM) +
wrapperMargin.IStart(myWM),
aReflowState.ComputedLogicalBorderPadding().BStart(myWM) +
wrapperMargin.BStart(myWM));
nsReflowStatus childStatus;
// We initially reflow the child with a dummy containerSize; positioning
// will be fixed later.
const nsSize dummyContainerSize;
ReflowChild(outerWrapperFrame, aPresContext, wrappersDesiredSize,
wrapperReflowState, myWM, wrapperOffset, dummyContainerSize, 0,
childStatus);
MOZ_ASSERT(NS_FRAME_IS_FULLY_COMPLETE(childStatus),
"We gave our child unconstrained available block-size, "
"so it should be complete");
nscoord wrappersMarginBoxBSize =
wrappersDesiredSize.BSize(myWM) + wrapperMargin.BStartEnd(myWM);
if (contentBoxBSize == NS_INTRINSICSIZE) {
// We are intrinsically sized -- we should shrinkwrap the outer wrapper's
// block-size:
contentBoxBSize = wrappersMarginBoxBSize;
// 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
// aReflowState.ComputedBSize()). Note that we do this before
// adjusting for borderpadding, since ComputedMaxBSize and
// ComputedMinBSize are content heights.
contentBoxBSize =
NS_CSS_MINMAX(contentBoxBSize,
aReflowState.ComputedMinBSize(),
aReflowState.ComputedMaxBSize());
borderBoxBSize = contentBoxBSize +
aReflowState.ComputedLogicalBorderPadding().BStartEnd(myWM);
}
// Center child in block axis
nscoord extraSpace = contentBoxBSize - wrappersMarginBoxBSize;
wrapperOffset.B(myWM) += std::max(0, extraSpace / 2);
// Needed in FinishReflowChild, for logical-to-physical conversion:
nsSize borderBoxSize = LogicalSize(myWM, borderBoxISize, borderBoxBSize).
GetPhysicalSize(myWM);
// Place the child
FinishReflowChild(outerWrapperFrame, aPresContext, wrappersDesiredSize,
&wrapperReflowState, myWM, wrapperOffset,
borderBoxSize, 0);
nsSize contentBoxSize =
LogicalSize(myWM, contentBoxISize, contentBoxBSize).
GetPhysicalSize(myWM);
aDesiredSize.SetBlockStartAscent(
wrappersDesiredSize.BlockStartAscent() +
outerWrapperFrame->BStart(aReflowState.GetWritingMode(),
contentBoxSize));
}
LogicalSize logicalDesiredSize(myWM, borderBoxISize, borderBoxBSize);
aDesiredSize.SetSize(myWM, logicalDesiredSize);
aDesiredSize.SetOverflowAreasToDesiredBounds();
if (outerWrapperFrame) {
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, outerWrapperFrame);
}
FinishAndStoreOverflow(&aDesiredSize);
aStatus = NS_FRAME_COMPLETE;
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
}
示例6: StyleColumn
nsColumnSetFrame::ReflowConfig
nsColumnSetFrame::ChooseColumnStrategy(const nsHTMLReflowState& aReflowState,
bool aForceAuto = false,
nscoord aFeasibleBSize = NS_INTRINSICSIZE,
nscoord aInfeasibleBSize = 0)
{
nscoord knownFeasibleBSize = aFeasibleBSize;
nscoord knownInfeasibleBSize = aInfeasibleBSize;
const nsStyleColumn* colStyle = StyleColumn();
nscoord availContentISize = GetAvailableContentISize(aReflowState);
if (aReflowState.ComputedISize() != NS_INTRINSICSIZE) {
availContentISize = aReflowState.ComputedISize();
}
nscoord consumedBSize = GetConsumedBSize();
// The effective computed height is the height of the current continuation
// of the column set frame. This should be the same as the computed height
// if we have an unconstrained available height.
nscoord computedBSize = GetEffectiveComputedBSize(aReflowState,
consumedBSize);
nscoord colBSize = GetAvailableContentBSize(aReflowState);
if (aReflowState.ComputedBSize() != NS_INTRINSICSIZE) {
colBSize = aReflowState.ComputedBSize();
} else if (aReflowState.ComputedMaxBSize() != NS_INTRINSICSIZE) {
colBSize = std::min(colBSize, aReflowState.ComputedMaxBSize());
}
nscoord colGap = GetColumnGap(this, colStyle);
int32_t numColumns = colStyle->mColumnCount;
// If column-fill is set to 'balance', then we want to balance the columns.
const bool isBalancing = colStyle->mColumnFill == NS_STYLE_COLUMN_FILL_BALANCE
&& !aForceAuto;
if (isBalancing) {
const uint32_t MAX_NESTED_COLUMN_BALANCING = 2;
uint32_t cnt = 0;
for (const nsHTMLReflowState* rs = aReflowState.parentReflowState;
rs && cnt < MAX_NESTED_COLUMN_BALANCING; rs = rs->parentReflowState) {
if (rs->mFlags.mIsColumnBalancing) {
++cnt;
}
}
if (cnt == MAX_NESTED_COLUMN_BALANCING) {
numColumns = 1;
}
}
nscoord colISize;
// In vertical writing-mode, "column-width" (inline size) will actually be
// physical height, but its CSS name is still column-width.
if (colStyle->mColumnWidth.GetUnit() == eStyleUnit_Coord) {
colISize = colStyle->mColumnWidth.GetCoordValue();
NS_ASSERTION(colISize >= 0, "negative column width");
// Reduce column count if necessary to make columns fit in the
// available width. Compute max number of columns that fit in
// availContentISize, satisfying colGap*(maxColumns - 1) +
// colISize*maxColumns <= availContentISize
if (availContentISize != NS_INTRINSICSIZE && colGap + colISize > 0
&& numColumns > 0) {
// This expression uses truncated rounding, which is what we
// want
int32_t maxColumns =
std::min(nscoord(nsStyleColumn::kMaxColumnCount),
(availContentISize + colGap) / (colGap + colISize));
numColumns = std::max(1, std::min(numColumns, maxColumns));
}
} else if (numColumns > 0 && availContentISize != NS_INTRINSICSIZE) {
nscoord iSizeMinusGaps = availContentISize - colGap * (numColumns - 1);
colISize = iSizeMinusGaps / numColumns;
} else {
colISize = NS_INTRINSICSIZE;
}
// Take care of the situation where there's only one column but it's
// still too wide
colISize = std::max(1, std::min(colISize, availContentISize));
nscoord expectedISizeLeftOver = 0;
if (colISize != NS_INTRINSICSIZE && availContentISize != NS_INTRINSICSIZE) {
// distribute leftover space
// First, determine how many columns will be showing if the column
// count is auto
if (numColumns <= 0) {
// choose so that colGap*(nominalColumnCount - 1) +
// colISize*nominalColumnCount is nearly availContentISize
// make sure to round down
if (colGap + colISize > 0) {
numColumns = (availContentISize + colGap) / (colGap + colISize);
// The number of columns should never exceed kMaxColumnCount.
numColumns = std::min(nscoord(nsStyleColumn::kMaxColumnCount),
numColumns);
}
if (numColumns <= 0) {
numColumns = 1;
}
}
//.........这里部分代码省略.........