本文整理汇总了C++中nsHTMLReflowState::ComputedSize方法的典型用法代码示例。如果您正苦于以下问题:C++ nsHTMLReflowState::ComputedSize方法的具体用法?C++ nsHTMLReflowState::ComputedSize怎么用?C++ nsHTMLReflowState::ComputedSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsHTMLReflowState
的用法示例。
在下文中一共展示了nsHTMLReflowState::ComputedSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: an
// Return the inline-size that the float (including margins) will take up
// in the writing mode of the containing block. If this returns
// NS_UNCONSTRAINEDSIZE, we're dealing with an orthogonal block that
// has block-size:auto, and we'll need to actually reflow it to find out
// how much inline-size it will occupy in the containing block's mode.
static nscoord
FloatMarginISize(const nsHTMLReflowState& aCBReflowState,
nscoord aFloatAvailableISize,
nsIFrame *aFloat,
const nsCSSOffsetState& aFloatOffsetState)
{
AutoMaybeDisableFontInflation an(aFloat);
WritingMode wm = aFloatOffsetState.GetWritingMode();
LogicalSize floatSize =
aFloat->ComputeSize(
aCBReflowState.rendContext,
wm,
aCBReflowState.ComputedSize(wm),
aFloatAvailableISize,
aFloatOffsetState.ComputedLogicalMargin().Size(wm),
aFloatOffsetState.ComputedLogicalBorderPadding().Size(wm) -
aFloatOffsetState.ComputedLogicalPadding().Size(wm),
aFloatOffsetState.ComputedLogicalPadding().Size(wm),
nsIFrame::ComputeSizeFlags::eShrinkWrap);
WritingMode cbwm = aCBReflowState.GetWritingMode();
nscoord floatISize = floatSize.ConvertTo(cbwm, wm).ISize(cbwm);
if (floatISize == NS_UNCONSTRAINEDSIZE) {
return NS_UNCONSTRAINEDSIZE; // reflow is needed to get the true size
}
return floatISize +
aFloatOffsetState.ComputedLogicalMargin().Size(wm).
ConvertTo(cbwm, wm).ISize(cbwm) +
aFloatOffsetState.ComputedLogicalBorderPadding().Size(wm).
ConvertTo(cbwm, wm).ISize(cbwm);
}
示例2: reflowState
void
nsMeterFrame::ReflowBarFrame(nsIFrame* aBarFrame,
nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
bool vertical = ResolvedOrientationIsVertical();
WritingMode wm = aBarFrame->GetWritingMode();
LogicalSize availSize = aReflowState.ComputedSize(wm);
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
nsHTMLReflowState reflowState(aPresContext, aReflowState,
aBarFrame, availSize);
nscoord size = vertical ? aReflowState.ComputedHeight()
: aReflowState.ComputedWidth();
nscoord xoffset = aReflowState.ComputedPhysicalBorderPadding().left;
nscoord yoffset = aReflowState.ComputedPhysicalBorderPadding().top;
// NOTE: Introduce a new function getPosition in the content part ?
HTMLMeterElement* meterElement = static_cast<HTMLMeterElement*>(mContent);
double max = meterElement->Max();
double min = meterElement->Min();
double value = meterElement->Value();
double position = max - min;
position = position != 0 ? (value - min) / position : 1;
size = NSToCoordRound(size * position);
if (!vertical && (wm.IsVertical() ? wm.IsVerticalRL() : !wm.IsBidiLTR())) {
xoffset += aReflowState.ComputedWidth() - size;
}
// The bar position is *always* constrained.
if (vertical) {
// We want the bar to begin at the bottom.
yoffset += aReflowState.ComputedHeight() - size;
size -= reflowState.ComputedPhysicalMargin().TopBottom() +
reflowState.ComputedPhysicalBorderPadding().TopBottom();
size = std::max(size, 0);
reflowState.SetComputedHeight(size);
} else {
size -= reflowState.ComputedPhysicalMargin().LeftRight() +
reflowState.ComputedPhysicalBorderPadding().LeftRight();
size = std::max(size, 0);
reflowState.SetComputedWidth(size);
}
xoffset += reflowState.ComputedPhysicalMargin().left;
yoffset += reflowState.ComputedPhysicalMargin().top;
nsHTMLReflowMetrics barDesiredSize(reflowState);
ReflowChild(aBarFrame, aPresContext, barDesiredSize, reflowState, xoffset,
yoffset, 0, aStatus);
FinishReflowChild(aBarFrame, aPresContext, barDesiredSize, &reflowState,
xoffset, yoffset, 0);
}
示例3: childDesiredSize
void
nsMathMLTokenFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
mPresentationData.flags &= ~NS_MATHML_ERROR;
// initializations needed for empty markup like <mtag></mtag>
aDesiredSize.ClearSize();
aDesiredSize.SetBlockStartAscent(0);
aDesiredSize.mBoundingMetrics = nsBoundingMetrics();
nsIFrame* childFrame = GetFirstPrincipalChild();
while (childFrame) {
// ask our children to compute their bounding metrics
nsHTMLReflowMetrics childDesiredSize(aReflowState.GetWritingMode(),
aDesiredSize.mFlags
| NS_REFLOW_CALC_BOUNDING_METRICS);
WritingMode wm = childFrame->GetWritingMode();
LogicalSize availSize = aReflowState.ComputedSize(wm);
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
nsHTMLReflowState childReflowState(aPresContext, aReflowState,
childFrame, availSize);
ReflowChild(childFrame, aPresContext, childDesiredSize,
childReflowState, aStatus);
//NS_ASSERTION(NS_FRAME_IS_COMPLETE(aStatus), "bad status");
SaveReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
childDesiredSize.mBoundingMetrics);
childFrame = childFrame->GetNextSibling();
}
// place and size children
FinalizeReflow(aReflowState.rendContext->GetDrawTarget(), aDesiredSize);
aStatus = NS_FRAME_COMPLETE;
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
}
示例4: contentsReflowState
void
nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aButtonDesiredSize,
const nsHTMLReflowState& aButtonReflowState,
nsIFrame* aFirstKid)
{
// Buttons have some bonus renderer-determined border/padding,
// which occupies part of the button's content-box area:
const nsMargin focusPadding = mRenderer.GetAddedButtonBorderAndPadding();
WritingMode wm = aFirstKid->GetWritingMode();
LogicalSize availSize = aButtonReflowState.ComputedSize(GetWritingMode());
availSize.BSize(wm) = NS_INTRINSICSIZE;
// Indent the child inside us by the focus border. We must do this separate
// from the regular border.
availSize.ISize(wm) -= LogicalMargin(wm, focusPadding).IStartEnd(wm);
// See whether out availSize's width is big enough. If it's smaller than our
// intrinsic min width, that means that the kid wouldn't really fit; for a
// better look in such cases we adjust the available width and our left
// offset to allow the kid to spill left into our padding.
nscoord xoffset = focusPadding.left +
aButtonReflowState.ComputedPhysicalBorderPadding().left;
nscoord extrawidth = GetMinISize(aButtonReflowState.rendContext) -
aButtonReflowState.ComputedWidth();
if (extrawidth > 0) {
nscoord extraleft = extrawidth / 2;
nscoord extraright = extrawidth - extraleft;
NS_ASSERTION(extraright >=0, "How'd that happen?");
// Do not allow the extras to be bigger than the relevant padding
extraleft = std::min(extraleft, aButtonReflowState.ComputedPhysicalPadding().left);
extraright = std::min(extraright, aButtonReflowState.ComputedPhysicalPadding().right);
xoffset -= extraleft;
availSize.Width(wm) = availSize.Width(wm) + extraleft + extraright;
}
availSize.Width(wm) = std::max(availSize.Width(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);
nsHTMLReflowState contentsReflowState(aPresContext,
adjustedButtonReflowState,
aFirstKid, availSize);
nsReflowStatus contentsReflowStatus;
nsHTMLReflowMetrics contentsDesiredSize(aButtonReflowState);
ReflowChild(aFirstKid, aPresContext,
contentsDesiredSize, contentsReflowState,
xoffset,
focusPadding.top + aButtonReflowState.ComputedPhysicalBorderPadding().top,
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 buttonContentBoxHeight = 0;
if (aButtonReflowState.ComputedHeight() != NS_INTRINSICSIZE) {
// Button has a fixed height -- that's its content-box height.
buttonContentBoxHeight = aButtonReflowState.ComputedHeight();
} else {
// Button is intrinsically sized -- it should shrinkwrap the
// button-contents' height, plus any focus-padding space:
buttonContentBoxHeight =
contentsDesiredSize.Height() + focusPadding.TopBottom();
// Make sure we obey min/max-height in the case when we're doing intrinsic
// sizing (we get it for free when we have a non-intrinsic
// aButtonReflowState.ComputedHeight()). Note that we do this before
// adjusting for borderpadding, since mComputedMaxHeight and
// mComputedMinHeight are content heights.
buttonContentBoxHeight =
NS_CSS_MINMAX(buttonContentBoxHeight,
aButtonReflowState.ComputedMinHeight(),
aButtonReflowState.ComputedMaxHeight());
}
// Center child vertically in the button
// (technically, inside of the button's focus-padding area)
nscoord extraSpace =
buttonContentBoxHeight - focusPadding.TopBottom() -
contentsDesiredSize.Height();
nscoord yoffset = std::max(0, extraSpace / 2);
// Adjust yoffset to be in terms of the button's frame-rect, instead of
// its focus-padding rect:
yoffset += focusPadding.top + aButtonReflowState.ComputedPhysicalBorderPadding().top;
// Place the child
FinishReflowChild(aFirstKid, aPresContext,
contentsDesiredSize, &contentsReflowState,
xoffset, yoffset, 0);
// Make sure we have a useful 'ascent' value for the child
if (contentsDesiredSize.BlockStartAscent() ==
//.........这里部分代码省略.........
示例5: baseSize
void
nsMathMLmrootFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
nsReflowStatus childStatus;
mPresentationData.flags &= ~NS_MATHML_ERROR;
aDesiredSize.ClearSize();
aDesiredSize.SetBlockStartAscent(0);
nsBoundingMetrics bmSqr, bmBase, bmIndex;
DrawTarget* drawTarget = aReflowState.rendContext->GetDrawTarget();
//////////////////
// Reflow Children
int32_t count = 0;
nsIFrame* baseFrame = nullptr;
nsIFrame* indexFrame = nullptr;
nsHTMLReflowMetrics baseSize(aReflowState);
nsHTMLReflowMetrics indexSize(aReflowState);
nsIFrame* childFrame = mFrames.FirstChild();
while (childFrame) {
// ask our children to compute their bounding metrics
nsHTMLReflowMetrics childDesiredSize(aReflowState,
aDesiredSize.mFlags
| NS_REFLOW_CALC_BOUNDING_METRICS);
WritingMode wm = childFrame->GetWritingMode();
LogicalSize availSize = aReflowState.ComputedSize(wm);
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
nsHTMLReflowState childReflowState(aPresContext, aReflowState,
childFrame, availSize);
ReflowChild(childFrame, aPresContext,
childDesiredSize, childReflowState, childStatus);
//NS_ASSERTION(NS_FRAME_IS_COMPLETE(childStatus), "bad status");
if (0 == count) {
// base
baseFrame = childFrame;
baseSize = childDesiredSize;
bmBase = childDesiredSize.mBoundingMetrics;
}
else if (1 == count) {
// index
indexFrame = childFrame;
indexSize = childDesiredSize;
bmIndex = childDesiredSize.mBoundingMetrics;
}
count++;
childFrame = childFrame->GetNextSibling();
}
if (2 != count) {
// report an error, encourage people to get their markups in order
ReportChildCountError();
ReflowError(drawTarget, aDesiredSize);
aStatus = NS_FRAME_COMPLETE;
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
// Call DidReflow() for the child frames we successfully did reflow.
DidReflowChildren(mFrames.FirstChild(), childFrame);
return;
}
////////////
// Prepare the radical symbol and the overline bar
float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(this);
RefPtr<nsFontMetrics> fm =
nsLayoutUtils::GetFontMetricsForFrame(this, fontSizeInflation);
nscoord ruleThickness, leading, psi;
GetRadicalParameters(fm, StyleFont()->mMathDisplay ==
NS_MATHML_DISPLAYSTYLE_BLOCK,
ruleThickness, leading, psi);
// built-in: adjust clearance psi to emulate \mathstrut using '1' (TexBook, p.131)
char16_t one = '1';
nsBoundingMetrics bmOne =
nsLayoutUtils::AppUnitBoundsOfString(&one, 1, *fm, drawTarget);
if (bmOne.ascent > bmBase.ascent)
psi += bmOne.ascent - bmBase.ascent;
// make sure that the rule appears on on screen
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
if (ruleThickness < onePixel) {
ruleThickness = onePixel;
}
// adjust clearance psi to get an exact number of pixels -- this
// gives a nicer & uniform look on stacked radicals (bug 130282)
nscoord delta = psi % onePixel;
if (delta)
psi += onePixel - delta; // round up
// Stretch the radical symbol to the appropriate height if it is not big enough.
nsBoundingMetrics contSize = bmBase;
contSize.descent = bmBase.ascent + bmBase.descent + psi;
contSize.ascent = ruleThickness;
//.........这里部分代码省略.........
示例6: 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) =
//.........这里部分代码省略.........
示例7: reflowState
void
nsProgressFrame::ReflowBarFrame(nsIFrame* aBarFrame,
nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
bool vertical = ResolvedOrientationIsVertical();
WritingMode wm = aBarFrame->GetWritingMode();
LogicalSize availSize = aReflowState.ComputedSize(wm);
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
nsHTMLReflowState reflowState(aPresContext, aReflowState,
aBarFrame, availSize);
nscoord size = vertical ? aReflowState.ComputedHeight()
: aReflowState.ComputedWidth();
nscoord xoffset = aReflowState.ComputedPhysicalBorderPadding().left;
nscoord yoffset = aReflowState.ComputedPhysicalBorderPadding().top;
double position = static_cast<HTMLProgressElement*>(mContent)->Position();
// Force the bar's size to match the current progress.
// When indeterminate, the progress' size will be 100%.
if (position >= 0.0) {
size *= position;
}
if (!vertical && (wm.IsVertical() ? wm.IsVerticalRL() : !wm.IsBidiLTR())) {
xoffset += aReflowState.ComputedWidth() - size;
}
// The bar size is fixed in these cases:
// - the progress position is determined: the bar size is fixed according
// to it's value.
// - the progress position is indeterminate and the bar appearance should be
// shown as native: the bar size is forced to 100%.
// Otherwise (when the progress is indeterminate and the bar appearance isn't
// native), the bar size isn't fixed and can be set by the author.
if (position != -1 || ShouldUseNativeStyle()) {
if (vertical) {
// We want the bar to begin at the bottom.
yoffset += aReflowState.ComputedHeight() - size;
size -= reflowState.ComputedPhysicalMargin().TopBottom() +
reflowState.ComputedPhysicalBorderPadding().TopBottom();
size = std::max(size, 0);
reflowState.SetComputedHeight(size);
} else {
size -= reflowState.ComputedPhysicalMargin().LeftRight() +
reflowState.ComputedPhysicalBorderPadding().LeftRight();
size = std::max(size, 0);
reflowState.SetComputedWidth(size);
}
} else if (vertical) {
// For vertical progress bars, we need to position the bar specificly when
// the width isn't constrained (position == -1 and !ShouldUseNativeStyle())
// because aReflowState.ComputedHeight() - size == 0.
yoffset += aReflowState.ComputedHeight() - reflowState.ComputedHeight();
}
xoffset += reflowState.ComputedPhysicalMargin().left;
yoffset += reflowState.ComputedPhysicalMargin().top;
nsHTMLReflowMetrics barDesiredSize(aReflowState);
ReflowChild(aBarFrame, aPresContext, barDesiredSize, reflowState, xoffset,
yoffset, 0, aStatus);
FinishReflowChild(aBarFrame, aPresContext, barDesiredSize, &reflowState,
xoffset, yoffset, 0);
}
示例8: 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);
//.........这里部分代码省略.........
示例9: wrappersDesiredSize
void
nsNumberControlFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
DO_GLOBAL_REFLOW_COUNT("nsNumberControlFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
NS_ASSERTION(mOuterWrapper, "Outer wrapper div must exist!");
NS_ASSERTION(!GetPrevContinuation() && !GetNextContinuation(),
"nsNumberControlFrame should not have continuations; if it does we "
"need to call RegUnregAccessKey only for the first");
NS_ASSERTION(!mFrames.FirstChild() ||
!mFrames.FirstChild()->GetNextSibling(),
"We expect at most one direct child frame");
if (mState & NS_FRAME_FIRST_REFLOW) {
nsFormControlFrame::RegUnRegAccessKey(this, true);
}
// The width of our content box, which is the available width
// for our anonymous content:
const nscoord contentBoxWidth = aReflowState.ComputedWidth();
nscoord contentBoxHeight = aReflowState.ComputedHeight();
nsIFrame* outerWrapperFrame = mOuterWrapper->GetPrimaryFrame();
if (!outerWrapperFrame) { // display:none?
if (contentBoxHeight == NS_INTRINSICSIZE) {
contentBoxHeight = 0;
}
} else {
NS_ASSERTION(outerWrapperFrame == mFrames.FirstChild(), "huh?");
nsHTMLReflowMetrics wrappersDesiredSize(aReflowState);
WritingMode wm = outerWrapperFrame->GetWritingMode();
LogicalSize availSize = aReflowState.ComputedSize(wm);
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
nsHTMLReflowState wrapperReflowState(aPresContext, aReflowState,
outerWrapperFrame, availSize);
// offsets of wrapper frame
nscoord xoffset = aReflowState.ComputedPhysicalBorderPadding().left +
wrapperReflowState.ComputedPhysicalMargin().left;
nscoord yoffset = aReflowState.ComputedPhysicalBorderPadding().top +
wrapperReflowState.ComputedPhysicalMargin().top;
nsReflowStatus childStatus;
ReflowChild(outerWrapperFrame, aPresContext, wrappersDesiredSize,
wrapperReflowState, xoffset, yoffset, 0, childStatus);
MOZ_ASSERT(NS_FRAME_IS_FULLY_COMPLETE(childStatus),
"We gave our child unconstrained height, so it should be complete");
nscoord wrappersMarginBoxHeight = wrappersDesiredSize.Height() +
wrapperReflowState.ComputedPhysicalMargin().TopBottom();
if (contentBoxHeight == NS_INTRINSICSIZE) {
// We are intrinsically sized -- we should shrinkwrap the outer wrapper's
// height:
contentBoxHeight = wrappersMarginBoxHeight;
// Make sure we obey min/max-height in the case when we're doing intrinsic
// sizing (we get it for free when we have a non-intrinsic
// aReflowState.ComputedHeight()). Note that we do this before
// adjusting for borderpadding, since mComputedMaxHeight and
// mComputedMinHeight are content heights.
contentBoxHeight =
NS_CSS_MINMAX(contentBoxHeight,
aReflowState.ComputedMinHeight(),
aReflowState.ComputedMaxHeight());
}
// Center child vertically
nscoord extraSpace = contentBoxHeight - wrappersMarginBoxHeight;
yoffset += std::max(0, extraSpace / 2);
// Place the child
FinishReflowChild(outerWrapperFrame, aPresContext, wrappersDesiredSize,
&wrapperReflowState, xoffset, yoffset, 0);
aDesiredSize.SetBlockStartAscent(
wrappersDesiredSize.BlockStartAscent() +
outerWrapperFrame->BStart(aReflowState.GetWritingMode(),
contentBoxWidth));
}
aDesiredSize.Width() = contentBoxWidth +
aReflowState.ComputedPhysicalBorderPadding().LeftRight();
aDesiredSize.Height() = contentBoxHeight +
aReflowState.ComputedPhysicalBorderPadding().TopBottom();
aDesiredSize.SetOverflowAreasToDesiredBounds();
if (outerWrapperFrame) {
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, outerWrapperFrame);
//.........这里部分代码省略.........
示例10: innerReflowState
//.........这里部分代码省略.........
line = block->begin_lines();
line_end = block->end_lines();
}
for (; anyLines && line != line_end; ++line) {
if (!aClearanceFrame && line->HasClearance()) {
// If we don't have a clearance frame, then we're computing
// the collapsed margin in the first pass, assuming that all
// lines have no clearance. So clear their clearance flags.
line->ClearHasClearance();
line->MarkDirty();
dirtiedLine = true;
}
bool isEmpty;
if (line->IsInline()) {
isEmpty = line->IsEmpty();
} else {
nsIFrame* kid = line->mFirstChild;
if (kid == aClearanceFrame) {
line->SetHasClearance();
line->MarkDirty();
dirtiedLine = true;
goto done;
}
// Here is where we recur. Now that we have determined that a
// generational collapse is required we need to compute the
// child blocks margin and so in so that we can look into
// it. For its margins to be computed we need to have a reflow
// state for it.
// We may have to construct an extra reflow state here if
// we drilled down through a block wrapper. At the moment
// we can only drill down one level so we only have to support
// one extra reflow state.
const nsHTMLReflowState* outerReflowState = &aRS;
if (frame != aRS.frame) {
NS_ASSERTION(frame->GetParent() == aRS.frame,
"Can only drill through one level of block wrapper");
LogicalSize availSpace = aRS.ComputedSize(frame->GetWritingMode());
outerReflowState = new nsHTMLReflowState(prescontext,
aRS, frame, availSpace);
}
{
LogicalSize availSpace =
outerReflowState->ComputedSize(kid->GetWritingMode());
nsHTMLReflowState innerReflowState(prescontext,
*outerReflowState, kid,
availSpace);
// Record that we're being optimistic by assuming the kid
// has no clearance
if (kid->StyleDisplay()->mBreakType != NS_STYLE_CLEAR_NONE) {
*aMayNeedRetry = true;
}
if (ComputeCollapsedBStartMargin(innerReflowState, aMargin,
aClearanceFrame, aMayNeedRetry,
&isEmpty)) {
line->MarkDirty();
dirtiedLine = true;
}
if (isEmpty) {
WritingMode innerWM = innerReflowState.GetWritingMode();
LogicalMargin innerMargin =
innerReflowState.ComputedLogicalMargin().ConvertTo(parentWM, innerWM);
aMargin->Include(innerMargin.BEnd(parentWM));
}
}
if (outerReflowState != &aRS) {
delete const_cast<nsHTMLReflowState*>(outerReflowState);
}
}
if (!isEmpty) {
if (!setBlockIsEmpty && aBlockIsEmpty) {
setBlockIsEmpty = true;
*aBlockIsEmpty = false;
}
goto done;
}
}
if (!setBlockIsEmpty && aBlockIsEmpty) {
// The first time we reach here is when this is the first block
// and we have processed all its normal lines.
setBlockIsEmpty = true;
// All lines are empty, or we wouldn't be here!
*aBlockIsEmpty = aRS.frame->IsSelfEmpty();
}
}
}
done:
if (!setBlockIsEmpty && aBlockIsEmpty) {
*aBlockIsEmpty = aRS.frame->IsEmpty();
}
#ifdef NOISY_BLOCKDIR_MARGINS
nsFrame::ListTag(stdout, aRS.frame);
printf(": => %d\n", aMargin->get());
#endif
return dirtiedLine;
}
示例11: wrappersDesiredSize
void
nsNumberControlFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsNumberControlFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
NS_ASSERTION(mOuterWrapper, "Outer wrapper div must exist!");
NS_ASSERTION(!GetPrevContinuation() && !GetNextContinuation(),
"nsNumberControlFrame should not have continuations; if it does we "
"need to call RegUnregAccessKey only for the first");
NS_ASSERTION(!mFrames.FirstChild() ||
!mFrames.FirstChild()->GetNextSibling(),
"We expect at most one direct child frame");
if (mState & NS_FRAME_FIRST_REFLOW) {
nsFormControlFrame::RegUnRegAccessKey(this, true);
}
const WritingMode myWM = aReflowState.GetWritingMode();
// The ISize of our content box, which is the available ISize
// for our anonymous content:
const nscoord contentBoxISize = aReflowState.ComputedISize();
nscoord contentBoxBSize = aReflowState.ComputedBSize();
// Figure out our border-box sizes as well (by adding borderPadding to
// content-box sizes):
const nscoord borderBoxISize = contentBoxISize +
aReflowState.ComputedLogicalBorderPadding().IStartEnd(myWM);
nscoord borderBoxBSize;
if (contentBoxBSize != NS_INTRINSICSIZE) {
borderBoxBSize = contentBoxBSize +
aReflowState.ComputedLogicalBorderPadding().BStartEnd(myWM);
} // else, we'll figure out borderBoxBSize after we resolve contentBoxBSize.
nsIFrame* outerWrapperFrame = mOuterWrapper->GetPrimaryFrame();
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,
//.........这里部分代码省略.........
示例12: contentRect
//.........这里部分代码省略.........
// boundary, but if so, too bad, this optimization is defeated.)
// We want scrollable overflow here since this is a calculation that
// affects layout.
bool skipResizeHeightShrink = shrinkingHeightOnly
&& child->GetScrollableOverflowRect().YMost() <= aConfig.mColMaxHeight;
nscoord childContentBEnd = 0;
WritingMode wm = child->GetWritingMode();
if (!reflowNext && (skipIncremental || skipResizeHeightShrink)) {
// This child does not need to be reflowed, but we may need to move it
MoveChildTo(this, child, childOrigin);
// If this is the last frame then make sure we get the right status
nsIFrame* kidNext = child->GetNextSibling();
if (kidNext) {
aStatus = (kidNext->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER)
? NS_FRAME_OVERFLOW_INCOMPLETE
: NS_FRAME_NOT_COMPLETE;
} else {
aStatus = mLastFrameStatus;
}
childContentBEnd = nsLayoutUtils::CalculateContentBEnd(wm, child);
#ifdef DEBUG_roc
printf("*** Skipping child #%d %p (incremental %d, resize height shrink %d): status = %d\n",
columnCount, (void*)child, skipIncremental, skipResizeHeightShrink, aStatus);
#endif
} else {
nsSize physicalSize(aConfig.mColWidth, aConfig.mColMaxHeight);
if (aUnboundedLastColumn && columnCount == aConfig.mBalanceColCount - 1) {
physicalSize.height = GetAvailableContentHeight(aReflowState);
}
LogicalSize availSize(wm, physicalSize);
LogicalSize computedSize = aReflowState.ComputedSize(wm);
if (reflowNext)
child->AddStateBits(NS_FRAME_IS_DIRTY);
nsHTMLReflowState kidReflowState(PresContext(), aReflowState, child,
availSize, availSize.ISize(wm),
computedSize.BSize(wm));
kidReflowState.mFlags.mIsTopOfPage = true;
kidReflowState.mFlags.mTableIsSplittable = false;
kidReflowState.mFlags.mIsColumnBalancing = aConfig.mBalanceColCount < INT32_MAX;
// We need to reflow any float placeholders, even if our column height
// hasn't changed.
kidReflowState.mFlags.mMustReflowPlaceholders = !colHeightChanged;
#ifdef DEBUG_roc
printf("*** Reflowing child #%d %p: availHeight=%d\n",
columnCount, (void*)child,availSize.BSize(wm));
#endif
// Note if the column's next in flow is not being changed by this incremental reflow.
// This may allow the current column to avoid trying to pull lines from the next column.
if (child->GetNextSibling() &&
!(GetStateBits() & NS_FRAME_IS_DIRTY) &&
!(child->GetNextSibling()->GetStateBits() & NS_FRAME_IS_DIRTY)) {
kidReflowState.mFlags.mNextInFlowUntouched = true;
}
nsHTMLReflowMetrics kidDesiredSize(wm, aDesiredSize.mFlags);
// XXX it would be cool to consult the float manager for the
// previous block to figure out the region of floats from the
示例13: indent
void
nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegatingFrame,
nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
const nsRect& aContainingBlock,
bool aConstrainHeight,
nsIFrame* aKidFrame,
nsReflowStatus& aStatus,
nsOverflowAreas* aOverflowAreas)
{
#ifdef DEBUG
if (nsBlockFrame::gNoisyReflow) {
nsFrame::IndentBy(stdout,nsBlockFrame::gNoiseIndent);
printf("abs pos ");
if (aKidFrame) {
nsAutoString name;
aKidFrame->GetFrameName(name);
printf("%s ", NS_LossyConvertUTF16toASCII(name).get());
}
char width[16];
char height[16];
PrettyUC(aReflowState.AvailableWidth(), width);
PrettyUC(aReflowState.AvailableHeight(), height);
printf(" a=%s,%s ", width, height);
PrettyUC(aReflowState.ComputedWidth(), width);
PrettyUC(aReflowState.ComputedHeight(), height);
printf("c=%s,%s \n", width, height);
}
AutoNoisyIndenter indent(nsBlockFrame::gNoisy);
#endif // DEBUG
WritingMode wm = aKidFrame->GetWritingMode();
nscoord availISize = LogicalSize(wm, aContainingBlock.Size()).ISize(wm);
if (availISize == -1) {
NS_ASSERTION(aReflowState.ComputedSize(wm).ISize(wm) !=
NS_UNCONSTRAINEDSIZE,
"Must have a useful inline-size _somewhere_");
availISize =
aReflowState.ComputedSizeWithPadding(wm).ISize(wm);
}
nsHTMLReflowMetrics kidDesiredSize(aReflowState);
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, aKidFrame,
LogicalSize(wm, availISize,
NS_UNCONSTRAINEDSIZE),
aContainingBlock.width,
aContainingBlock.height);
// Get the border values
const nsMargin& border = aReflowState.mStyleBorder->GetComputedBorder();
bool constrainHeight = (aReflowState.AvailableHeight() != NS_UNCONSTRAINEDSIZE)
&& aConstrainHeight
// 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->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() -
//.........这里部分代码省略.........
示例14: childDesiredSize
void
nsMathMLmfencedFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
mPresentationData.flags &= ~NS_MATHML_ERROR;
aDesiredSize.ClearSize();
aDesiredSize.SetBlockStartAscent(0);
aDesiredSize.mBoundingMetrics = nsBoundingMetrics();
int32_t i;
const nsStyleFont* font = StyleFont();
float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(this);
RefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
fontSizeInflation);
nscoord axisHeight, em;
GetAxisHeight(*aReflowState.rendContext, fm, axisHeight);
GetEmHeight(fm, em);
// leading to be left at the top and the bottom of stretched chars
nscoord leading = NSToCoordRound(0.2f * em);
/////////////
// Reflow children
// Asking each child to cache its bounding metrics
// Note that we don't use the base method nsMathMLContainerFrame::Reflow()
// because we want to stretch our fences, separators and stretchy frames using
// the *same* initial aDesiredSize.mBoundingMetrics. If we were to use the base
// method here, our stretchy frames will be stretched and placed, and we may
// end up stretching our fences/separators with a different aDesiredSize.
// XXX The above decision was revisited in bug 121748 and this code can be
// refactored to use nsMathMLContainerFrame::Reflow() at some stage.
nsReflowStatus childStatus;
nsIFrame* firstChild = GetFirstPrincipalChild();
nsIFrame* childFrame = firstChild;
nscoord ascent = 0, descent = 0;
if (firstChild || mOpenChar || mCloseChar || mSeparatorsCount > 0) {
// We use the ASCII metrics to get our minimum height. This way,
// if we have borders or a background, they will fit better with
// other elements on the line.
ascent = fm->MaxAscent();
descent = fm->MaxDescent();
}
while (childFrame) {
nsHTMLReflowMetrics childDesiredSize(aReflowState,
aDesiredSize.mFlags
| NS_REFLOW_CALC_BOUNDING_METRICS);
WritingMode wm = childFrame->GetWritingMode();
LogicalSize availSize = aReflowState.ComputedSize(wm);
availSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
nsHTMLReflowState childReflowState(aPresContext, aReflowState,
childFrame, availSize);
ReflowChild(childFrame, aPresContext, childDesiredSize,
childReflowState, childStatus);
//NS_ASSERTION(NS_FRAME_IS_COMPLETE(childStatus), "bad status");
SaveReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
childDesiredSize.mBoundingMetrics);
mozilla::WritingMode outerWM = aReflowState.GetWritingMode();
nscoord childDescent = childDesiredSize.BSize(outerWM) -
childDesiredSize.BlockStartAscent();
if (descent < childDescent)
descent = childDescent;
if (ascent < childDesiredSize.BlockStartAscent())
ascent = childDesiredSize.BlockStartAscent();
childFrame = childFrame->GetNextSibling();
}
/////////////
// Ask stretchy children to stretch themselves
nsBoundingMetrics containerSize;
nsStretchDirection stretchDir = NS_STRETCH_DIRECTION_VERTICAL;
GetPreferredStretchSize(*aReflowState.rendContext,
0, /* i.e., without embellishments */
stretchDir, containerSize);
childFrame = firstChild;
while (childFrame) {
nsIMathMLFrame* mathmlChild = do_QueryFrame(childFrame);
if (mathmlChild) {
nsHTMLReflowMetrics childDesiredSize(aReflowState);
// retrieve the metrics that was stored at the previous pass
GetReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
childDesiredSize.mBoundingMetrics);
mathmlChild->Stretch(*aReflowState.rendContext,
stretchDir, containerSize, childDesiredSize);
// store the updated metrics
SaveReflowAndBoundingMetricsFor(childFrame, childDesiredSize,
childDesiredSize.mBoundingMetrics);
nscoord childDescent = childDesiredSize.Height() - childDesiredSize.BlockStartAscent();
if (descent < childDescent)
descent = childDescent;
//.........这里部分代码省略.........
示例15: indent
void
nsAbsoluteContainingBlock::ReflowAbsoluteFrame(nsIFrame* aDelegatingFrame,
nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
const nsRect& aContainingBlock,
AbsPosReflowFlags aFlags,
nsIFrame* aKidFrame,
nsReflowStatus& aStatus,
nsOverflowAreas* aOverflowAreas)
{
#ifdef DEBUG
if (nsBlockFrame::gNoisyReflow) {
nsFrame::IndentBy(stdout,nsBlockFrame::gNoiseIndent);
printf("abs pos ");
if (aKidFrame) {
nsAutoString name;
aKidFrame->GetFrameName(name);
printf("%s ", NS_LossyConvertUTF16toASCII(name).get());
}
char width[16];
char height[16];
PrettyUC(aReflowState.AvailableWidth(), width, 16);
PrettyUC(aReflowState.AvailableHeight(), height, 16);
printf(" a=%s,%s ", width, height);
PrettyUC(aReflowState.ComputedWidth(), width, 16);
PrettyUC(aReflowState.ComputedHeight(), height, 16);
printf("c=%s,%s \n", width, height);
}
AutoNoisyIndenter indent(nsBlockFrame::gNoisy);
#endif // DEBUG
WritingMode wm = aKidFrame->GetWritingMode();
LogicalSize logicalCBSize(wm, aContainingBlock.Size());
nscoord availISize = logicalCBSize.ISize(wm);
if (availISize == -1) {
NS_ASSERTION(aReflowState.ComputedSize(wm).ISize(wm) !=
NS_UNCONSTRAINEDSIZE,
"Must have a useful inline-size _somewhere_");
availISize =
aReflowState.ComputedSizeWithPadding(wm).ISize(wm);
}
uint32_t rsFlags = 0;
if (aFlags & AbsPosReflowFlags::eIsGridContainerCB) {
// When a grid container generates the abs.pos. CB for a *child* then
// the static-position is the CB origin (i.e. of the grid area rect).
// https://drafts.csswg.org/css-grid/#static-position
nsIFrame* placeholder =
aPresContext->PresShell()->GetPlaceholderFrameFor(aKidFrame);
if (placeholder && placeholder->GetParent() == aDelegatingFrame) {
rsFlags |= nsHTMLReflowState::STATIC_POS_IS_CB_ORIGIN;
}
}
nsHTMLReflowState kidReflowState(aPresContext, aReflowState, aKidFrame,
LogicalSize(wm, availISize,
NS_UNCONSTRAINEDSIZE),
&logicalCBSize, rsFlags);
// Get the border values
WritingMode outerWM = aReflowState.GetWritingMode();
const LogicalMargin border(outerWM,
aReflowState.mStyleBorder->GetComputedBorder());
const LogicalMargin margin =
kidReflowState.ComputedLogicalMargin().ConvertTo(outerWM, wm);
bool constrainBSize = (aReflowState.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) <=
aReflowState.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) {
kidReflowState.AvailableBSize() =
aReflowState.AvailableBSize() - border.ConvertTo(wm, outerWM).BStart(wm) -
kidReflowState.ComputedLogicalMargin().BStart(wm);
if (NS_AUTOOFFSET != kidReflowState.ComputedLogicalOffsets().BStart(wm)) {
kidReflowState.AvailableBSize() -=
kidReflowState.ComputedLogicalOffsets().BStart(wm);
}
}
// 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
//.........这里部分代码省略.........