本文整理汇总了C++中nsHTMLReflowState::GetWritingMode方法的典型用法代码示例。如果您正苦于以下问题:C++ nsHTMLReflowState::GetWritingMode方法的具体用法?C++ nsHTMLReflowState::GetWritingMode怎么用?C++ nsHTMLReflowState::GetWritingMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsHTMLReflowState
的用法示例。
在下文中一共展示了nsHTMLReflowState::GetWritingMode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: textContainers
/* virtual */ void
nsRubyBaseContainerFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsRubyBaseContainerFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
aStatus = NS_FRAME_COMPLETE;
if (!aReflowState.mLineLayout) {
NS_ASSERTION(
aReflowState.mLineLayout,
"No line layout provided to RubyBaseContainerFrame reflow method.");
return;
}
MoveOverflowToChildList();
// Ask text containers to drain overflows
AutoRubyTextContainerArray textContainers(this);
const uint32_t rtcCount = textContainers.Length();
for (uint32_t i = 0; i < rtcCount; i++) {
textContainers[i]->MoveOverflowToChildList();
}
WritingMode lineWM = aReflowState.mLineLayout->GetWritingMode();
LogicalSize availSize(lineWM, aReflowState.AvailableISize(),
aReflowState.AvailableBSize());
// We have a reflow state and a line layout for each RTC.
// They are conceptually the state of the RTCs, but we don't actually
// reflow those RTCs in this code. These two arrays are holders of
// the reflow states and line layouts.
// Since there are pointers refer to reflow states and line layouts,
// it is necessary to guarantee that they won't be moved. For this
// reason, they are wrapped in UniquePtr here.
AutoTArray<UniquePtr<nsHTMLReflowState>, RTC_ARRAY_SIZE> reflowStates;
AutoTArray<UniquePtr<nsLineLayout>, RTC_ARRAY_SIZE> lineLayouts;
reflowStates.SetCapacity(rtcCount);
lineLayouts.SetCapacity(rtcCount);
// Begin the line layout for each ruby text container in advance.
bool hasSpan = false;
for (uint32_t i = 0; i < rtcCount; i++) {
nsRubyTextContainerFrame* textContainer = textContainers[i];
if (textContainer->IsSpanContainer()) {
hasSpan = true;
}
nsHTMLReflowState* reflowState = new nsHTMLReflowState(
aPresContext, *aReflowState.mParentReflowState, textContainer,
availSize.ConvertTo(textContainer->GetWritingMode(), lineWM));
reflowStates.AppendElement(reflowState);
nsLineLayout* lineLayout = new nsLineLayout(aPresContext,
reflowState->mFloatManager,
reflowState, nullptr,
aReflowState.mLineLayout);
lineLayout->SetSuppressLineWrap(true);
lineLayouts.AppendElement(lineLayout);
// Line number is useless for ruby text
// XXX nullptr here may cause problem, see comments for
// nsLineLayout::mBlockRS and nsLineLayout::AddFloat
lineLayout->Init(nullptr, reflowState->CalcLineHeight(), -1);
reflowState->mLineLayout = lineLayout;
// Border and padding are suppressed on ruby text containers.
// If the writing mode is vertical-rl, the horizontal position of
// rt frames will be updated when reflowing this text container,
// hence leave container size 0 here for now.
lineLayout->BeginLineReflow(0, 0, reflowState->ComputedISize(),
NS_UNCONSTRAINEDSIZE,
false, false, lineWM, nsSize(0, 0));
lineLayout->AttachRootFrameToBaseLineLayout();
}
aReflowState.mLineLayout->BeginSpan(this, &aReflowState,
0, aReflowState.AvailableISize(),
&mBaseline);
bool allowInitialLineBreak, allowLineBreak;
GetIsLineBreakAllowed(this, aReflowState.mLineLayout->LineIsBreakable(),
&allowInitialLineBreak, &allowLineBreak);
nscoord isize = 0;
// Reflow columns excluding any span
ReflowState reflowState = {
allowInitialLineBreak, allowLineBreak && !hasSpan,
textContainers, aReflowState, reflowStates
};
isize = ReflowColumns(reflowState, aStatus);
DebugOnly<nscoord> lineSpanSize = aReflowState.mLineLayout->EndSpan(this);
aDesiredSize.ISize(lineWM) = isize;
// When there are no frames inside the ruby base container, EndSpan
// will return 0. However, in this case, the actual width of the
// container could be non-zero because of non-empty ruby annotations.
// XXX When bug 765861 gets fixed, this warning should be upgraded.
NS_WARN_IF_FALSE(NS_INLINE_IS_BREAK(aStatus) ||
isize == lineSpanSize || mFrames.IsEmpty(), "bad isize");
//.........这里部分代码省略.........
示例2: availSize
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();
nsSize availSize(aButtonReflowState.ComputedWidth(), NS_INTRINSICSIZE);
// Indent the child inside us by the focus border. We must do this separate
// from the regular border.
availSize.width -= focusPadding.LeftRight();
// 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 = GetMinWidth(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 += extraleft + extraright;
}
availSize.width = std::max(availSize.width,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.GetWritingMode());
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,
&contentsReflowState, contentsDesiredSize,
xoffset, yoffset, 0);
// Make sure we have a useful 'ascent' value for the child
if (contentsDesiredSize.TopAscent() == nsHTMLReflowMetrics::ASK_FOR_BASELINE) {
contentsDesiredSize.SetTopAscent(aFirstKid->GetBaseline());
}
//.........这里部分代码省略.........
示例3: innerSize
void
nsSubDocumentFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("nsSubDocumentFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
("enter nsSubDocumentFrame::Reflow: maxSize=%d,%d",
aReflowState.AvailableWidth(), aReflowState.AvailableHeight()));
NS_ASSERTION(aReflowState.ComputedWidth() != NS_UNCONSTRAINEDSIZE,
"Shouldn't have unconstrained stuff here "
"thanks to the rules of reflow");
NS_ASSERTION(NS_INTRINSICSIZE != aReflowState.ComputedHeight(),
"Shouldn't have unconstrained stuff here "
"thanks to ComputeAutoSize");
aStatus = NS_FRAME_COMPLETE;
NS_ASSERTION(mContent->GetPrimaryFrame() == this,
"Shouldn't happen");
// XUL <iframe> or <browser>, or HTML <iframe>, <object> or <embed>
aDesiredSize.SetSize(aReflowState.GetWritingMode(),
aReflowState.ComputedSizeWithBorderPadding());
// "offset" is the offset of our content area from our frame's
// top-left corner.
nsPoint offset = nsPoint(aReflowState.ComputedPhysicalBorderPadding().left,
aReflowState.ComputedPhysicalBorderPadding().top);
if (mInnerView) {
const nsMargin& bp = aReflowState.ComputedPhysicalBorderPadding();
nsSize innerSize(aDesiredSize.Width() - bp.LeftRight(),
aDesiredSize.Height() - bp.TopBottom());
// Size & position the view according to 'object-fit' & 'object-position'.
nsIFrame* subDocRoot = ObtainIntrinsicSizeFrame();
IntrinsicSize intrinsSize;
nsSize intrinsRatio;
if (subDocRoot) {
intrinsSize = subDocRoot->GetIntrinsicSize();
intrinsRatio = subDocRoot->GetIntrinsicRatio();
}
nsRect destRect =
nsLayoutUtils::ComputeObjectDestRect(nsRect(offset, innerSize),
intrinsSize, intrinsRatio,
StylePosition());
nsViewManager* vm = mInnerView->GetViewManager();
vm->MoveViewTo(mInnerView, destRect.x, destRect.y);
vm->ResizeView(mInnerView, nsRect(nsPoint(0, 0), destRect.Size()), true);
}
aDesiredSize.SetOverflowAreasToDesiredBounds();
if (!ShouldClipSubdocument()) {
nsIFrame* subdocRootFrame = GetSubdocumentRootFrame();
if (subdocRootFrame) {
aDesiredSize.mOverflowAreas.UnionWith(subdocRootFrame->GetOverflowAreas() + offset);
}
}
FinishAndStoreOverflow(&aDesiredSize);
if (!aPresContext->IsPaginated() && !mPostedReflowCallback) {
PresContext()->PresShell()->PostReflowCallback(this);
mPostedReflowCallback = true;
}
NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS,
("exit nsSubDocumentFrame::Reflow: size=%d,%d status=%x",
aDesiredSize.Width(), aDesiredSize.Height(), aStatus));
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
}
示例4: wrappersDesiredSize
nsresult
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.GetWritingMode());
nsHTMLReflowState wrapperReflowState(aPresContext, aReflowState,
outerWrapperFrame,
nsSize(contentBoxWidth,
NS_UNCONSTRAINEDSIZE));
// offsets of wrapper frame
nscoord xoffset = aReflowState.ComputedPhysicalBorderPadding().left +
wrapperReflowState.ComputedPhysicalMargin().left;
nscoord yoffset = aReflowState.ComputedPhysicalBorderPadding().top +
wrapperReflowState.ComputedPhysicalMargin().top;
nsReflowStatus childStatus;
nsresult rv = ReflowChild(outerWrapperFrame, aPresContext,
wrappersDesiredSize, wrapperReflowState,
xoffset, yoffset, 0, childStatus);
NS_ENSURE_SUCCESS(rv, rv);
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
rv = FinishReflowChild(outerWrapperFrame, aPresContext,
wrappersDesiredSize, &wrapperReflowState,
xoffset, yoffset, 0);
NS_ENSURE_SUCCESS(rv, rv);
aDesiredSize.SetTopAscent(wrappersDesiredSize.TopAscent() +
outerWrapperFrame->GetPosition().y);
}
aDesiredSize.Width() = contentBoxWidth +
aReflowState.ComputedPhysicalBorderPadding().LeftRight();
aDesiredSize.Height() = contentBoxHeight +
aReflowState.ComputedPhysicalBorderPadding().TopBottom();
aDesiredSize.SetOverflowAreasToDesiredBounds();
if (outerWrapperFrame) {
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, outerWrapperFrame);
//.........这里部分代码省略.........
示例5: overflow
void
nsCanvasFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aDesiredSize,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
DO_GLOBAL_REFLOW_COUNT("nsCanvasFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
NS_FRAME_TRACE_REFLOW_IN("nsCanvasFrame::Reflow");
// Initialize OUT parameter
aStatus = NS_FRAME_COMPLETE;
nsCanvasFrame* prevCanvasFrame = static_cast<nsCanvasFrame*>
(GetPrevInFlow());
if (prevCanvasFrame) {
AutoFrameListPtr overflow(aPresContext,
prevCanvasFrame->StealOverflowFrames());
if (overflow) {
NS_ASSERTION(overflow->OnlyChild(),
"must have doc root as canvas frame's only child");
nsContainerFrame::ReparentFrameViewList(*overflow, prevCanvasFrame, this);
// Prepend overflow to the our child list. There may already be
// children placeholders for fixed-pos elements, which don't get
// reflowed but must not be lost until the canvas frame is destroyed.
mFrames.InsertFrames(this, nullptr, *overflow);
}
}
// Set our size up front, since some parts of reflow depend on it
// being already set. Note that the computed height may be
// unconstrained; that's ok. Consumers should watch out for that.
SetSize(nsSize(aReflowState.ComputedWidth(), aReflowState.ComputedHeight()));
// Reflow our one and only normal child frame. It's either the root
// element's frame or a placeholder for that frame, if the root element
// is abs-pos or fixed-pos. We may have additional children which
// are placeholders for continuations of fixed-pos content, but those
// don't need to be reflowed. The normal child is always comes before
// the fixed-pos placeholders, because we insert it at the start
// of the child list, above.
nsHTMLReflowMetrics kidDesiredSize(aReflowState);
if (mFrames.IsEmpty()) {
// We have no child frame, so return an empty size
aDesiredSize.Width() = aDesiredSize.Height() = 0;
} else {
nsIFrame* kidFrame = mFrames.FirstChild();
bool kidDirty = (kidFrame->GetStateBits() & NS_FRAME_IS_DIRTY) != 0;
nsHTMLReflowState
kidReflowState(aPresContext, aReflowState, kidFrame,
aReflowState.AvailableSize(kidFrame->GetWritingMode()));
if (aReflowState.mFlags.mVResize &&
(kidFrame->GetStateBits() & NS_FRAME_CONTAINS_RELATIVE_HEIGHT)) {
// Tell our kid it's being vertically resized too. Bit of a
// hack for framesets.
kidReflowState.mFlags.mVResize = true;
}
nsPoint kidPt(kidReflowState.ComputedPhysicalMargin().left,
kidReflowState.ComputedPhysicalMargin().top);
kidReflowState.ApplyRelativePositioning(&kidPt);
// Reflow the frame
ReflowChild(kidFrame, aPresContext, kidDesiredSize, kidReflowState,
kidPt.x, kidPt.y, 0, aStatus);
// Complete the reflow and position and size the child frame
FinishReflowChild(kidFrame, aPresContext, kidDesiredSize, &kidReflowState,
kidPt.x, kidPt.y, 0);
if (!NS_FRAME_IS_FULLY_COMPLETE(aStatus)) {
nsIFrame* nextFrame = kidFrame->GetNextInFlow();
NS_ASSERTION(nextFrame || aStatus & NS_FRAME_REFLOW_NEXTINFLOW,
"If it's incomplete and has no nif yet, it must flag a nif reflow.");
if (!nextFrame) {
nextFrame = aPresContext->PresShell()->FrameConstructor()->
CreateContinuingFrame(aPresContext, kidFrame, this);
SetOverflowFrames(nsFrameList(nextFrame, nextFrame));
// Root overflow containers will be normal children of
// the canvas frame, but that's ok because there
// aren't any other frames we need to isolate them from
// during reflow.
}
if (NS_FRAME_OVERFLOW_IS_INCOMPLETE(aStatus)) {
nextFrame->AddStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER);
}
}
// If the child frame was just inserted, then we're responsible for making sure
// it repaints
if (kidDirty) {
// But we have a new child, which will affect our background, so
// invalidate our whole rect.
// Note: Even though we request to be sized to our child's size, our
// scroll frame ensures that we are always the size of the viewport.
// Also note: GetPosition() on a CanvasFrame is always going to return
// (0, 0). We only want to invalidate GetRect() since Get*OverflowRect()
//.........这里部分代码省略.........
示例6: finalSize
void
BRFrame::Reflow(nsPresContext* aPresContext,
nsHTMLReflowMetrics& aMetrics,
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus)
{
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("BRFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);
WritingMode wm = aReflowState.GetWritingMode();
LogicalSize finalSize(wm);
finalSize.BSize(wm) = 0; // BR frames with block size 0 are ignored in quirks
// mode by nsLineLayout::VerticalAlignFrames .
// However, it's not always 0. See below.
finalSize.ISize(wm) = 0;
aMetrics.SetBlockStartAscent(0);
// Only when the BR is operating in a line-layout situation will it
// behave like a BR. Additionally, we suppress breaks from BR inside
// of ruby frames. To determine if we're inside ruby, we have to rely
// on the *parent's* ShouldSuppressLineBreak() method, instead of our
// own, because we may have custom "display" value that makes our
// ShouldSuppressLineBreak() return false.
nsLineLayout* ll = aReflowState.mLineLayout;
if (ll && !GetParent()->StyleContext()->ShouldSuppressLineBreak()) {
// Note that the compatibility mode check excludes AlmostStandards
// mode, since this is the inline box model. See bug 161691.
if ( ll->LineIsEmpty() ||
aPresContext->CompatibilityMode() == eCompatibility_FullStandards ) {
// The line is logically empty; any whitespace is trimmed away.
//
// If this frame is going to terminate the line we know
// that nothing else will go on the line. Therefore, in this
// case, we provide some height for the BR frame so that it
// creates some vertical whitespace. It's necessary to use the
// line-height rather than the font size because the
// quirks-mode fix that doesn't apply the block's min
// line-height makes this necessary to make BR cause a line
// of the full line-height
// We also do this in strict mode because BR should act like a
// normal inline frame. That line-height is used is important
// here for cases where the line-height is less than 1.
RefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
nsLayoutUtils::FontSizeInflationFor(this));
if (fm) {
nscoord logicalHeight = aReflowState.CalcLineHeight();
finalSize.BSize(wm) = logicalHeight;
aMetrics.SetBlockStartAscent(nsLayoutUtils::GetCenteredFontBaseline(
fm, logicalHeight, wm.IsLineInverted()));
}
else {
aMetrics.SetBlockStartAscent(aMetrics.BSize(wm) = 0);
}
// XXX temporary until I figure out a better solution; see the
// code in nsLineLayout::VerticalAlignFrames that zaps minY/maxY
// if the width is zero.
// XXX This also fixes bug 10036!
// Warning: nsTextControlFrame::CalculateSizeStandard depends on
// the following line, see bug 228752.
finalSize.ISize(wm) = 1;
}
// Return our reflow status
uint32_t breakType = aReflowState.mStyleDisplay->PhysicalBreakType(wm);
if (NS_STYLE_CLEAR_NONE == breakType) {
breakType = NS_STYLE_CLEAR_LINE;
}
aStatus = NS_INLINE_BREAK | NS_INLINE_BREAK_AFTER |
NS_INLINE_MAKE_BREAK_TYPE(breakType);
ll->SetLineEndsInBR(true);
}
else {
aStatus = NS_FRAME_COMPLETE;
}
aMetrics.SetSize(wm, finalSize);
aMetrics.SetOverflowAreasToDesiredBounds();
mAscent = aMetrics.BlockStartAscent();
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aMetrics);
}
示例7: while
void
nsInlineFrame::ReflowFrames(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState,
InlineReflowState& irs,
nsHTMLReflowMetrics& aMetrics,
nsReflowStatus& aStatus)
{
aStatus = NS_FRAME_COMPLETE;
nsLineLayout* lineLayout = aReflowState.mLineLayout;
bool inFirstLine = aReflowState.mLineLayout->GetInFirstLine();
RestyleManager* restyleManager = aPresContext->RestyleManager();
WritingMode frameWM = aReflowState.GetWritingMode();
WritingMode lineWM = aReflowState.mLineLayout->mRootSpan->mWritingMode;
LogicalMargin framePadding = aReflowState.ComputedLogicalBorderPadding();
nscoord startEdge = 0;
const bool boxDecorationBreakClone =
MOZ_UNLIKELY(StyleBorder()->mBoxDecorationBreak ==
NS_STYLE_BOX_DECORATION_BREAK_CLONE);
// Don't offset by our start borderpadding if we have a prev continuation or
// if we're in a part of an {ib} split other than the first one. For
// box-decoration-break:clone we always offset our start since all
// continuations have border/padding.
if ((!GetPrevContinuation() && !FrameIsNonFirstInIBSplit()) ||
boxDecorationBreakClone) {
startEdge = framePadding.IStart(frameWM);
}
nscoord availableISize = aReflowState.AvailableISize();
NS_ASSERTION(availableISize != NS_UNCONSTRAINEDSIZE,
"should no longer use available widths");
// Subtract off inline axis border+padding from availableISize
availableISize -= startEdge;
availableISize -= framePadding.IEnd(frameWM);
lineLayout->BeginSpan(this, &aReflowState, startEdge,
startEdge + availableISize, &mBaseline);
// First reflow our principal children.
nsIFrame* frame = mFrames.FirstChild();
bool done = false;
while (frame) {
// Check if we should lazily set the child frame's parent pointer.
if (irs.mSetParentPointer) {
bool havePrevBlock =
irs.mLineContainer && irs.mLineContainer->GetPrevContinuation();
nsIFrame* child = frame;
do {
// If our block is the first in flow, then any floats under the pulled
// frame must already belong to our block.
if (havePrevBlock) {
// This has to happen before we update frame's parent; we need to
// know frame's ancestry under its old block.
// The blockChildren.ContainsFrame check performed by
// ReparentFloatsForInlineChild here may be slow, but we can't
// easily avoid it because we don't know where 'frame' originally
// came from. If we really really have to optimize this we could
// cache whether frame->GetParent() is under its containing blocks
// overflowList or not.
ReparentFloatsForInlineChild(irs.mLineContainer, child, false);
}
child->SetParent(this);
if (inFirstLine) {
restyleManager->ReparentStyleContext(child);
nsLayoutUtils::MarkDescendantsDirty(child);
}
// We also need to do the same for |frame|'s next-in-flows that are in
// the sibling list. Otherwise, if we reflow |frame| and it's complete
// we'll crash when trying to delete its next-in-flow.
// This scenario doesn't happen often, but it can happen.
nsIFrame* nextSibling = child->GetNextSibling();
child = child->GetNextInFlow();
if (MOZ_UNLIKELY(child)) {
while (child != nextSibling && nextSibling) {
nextSibling = nextSibling->GetNextSibling();
}
if (!nextSibling) {
child = nullptr;
}
}
MOZ_ASSERT(!child || mFrames.ContainsFrame(child));
} while (child);
// Fix the parent pointer for ::first-letter child frame next-in-flows,
// so nsFirstLetterFrame::Reflow can destroy them safely (bug 401042).
nsIFrame* realFrame = nsPlaceholderFrame::GetRealFrameFor(frame);
if (realFrame->GetType() == nsGkAtoms::letterFrame) {
nsIFrame* child = realFrame->GetFirstPrincipalChild();
if (child) {
NS_ASSERTION(child->GetType() == nsGkAtoms::textFrame,
"unexpected frame type");
nsIFrame* nextInFlow = child->GetNextInFlow();
for ( ; nextInFlow; nextInFlow = nextInFlow->GetNextInFlow()) {
NS_ASSERTION(nextInFlow->GetType() == nsGkAtoms::textFrame,
"unexpected frame type");
if (mFrames.ContainsFrame(nextInFlow)) {
nextInFlow->SetParent(this);
if (inFirstLine) {
restyleManager->ReparentStyleContext(nextInFlow);
nsLayoutUtils::MarkDescendantsDirty(nextInFlow);
}
}
//.........这里部分代码省略.........