Bug 1464813: Remove eDontReparentFrames, since it's not used. r?mats
We only set lazilySetParentPointer on the first reflow, then only call
DrainSelfOverflowListInternal on non-first reflows.
MozReview-Commit-ID: 364IwDoPE3W
--- a/layout/generic/nsInlineFrame.cpp
+++ b/layout/generic/nsInlineFrame.cpp
@@ -320,17 +320,17 @@ nsInlineFrame::Reflow(nsPresContext*
if (nullptr == aReflowInput.mLineLayout) {
NS_ERROR("must have non-null aReflowInput.mLineLayout");
return;
}
if (IsFrameTreeTooDeep(aReflowInput, aMetrics, aStatus)) {
return;
}
- bool lazilySetParentPointer = false;
+ bool lazilySetParentPointer = false;
// Check for an overflow list with our prev-in-flow
nsInlineFrame* prevInFlow = (nsInlineFrame*)GetPrevInFlow();
if (prevInFlow) {
AutoFrameListPtr prevOverflowFrames(aPresContext,
prevInFlow->StealOverflowFrames());
if (prevOverflowFrames) {
// When pushing and pulling frames we need to check for whether any
@@ -375,22 +375,17 @@ nsInlineFrame::Reflow(nsPresContext*
// However, add an assertion in case we get reflowed more than once with
// the initial reflow reason
nsFrameList* overflowFrames = GetOverflowFrames();
NS_ASSERTION(!overflowFrames || overflowFrames->IsEmpty(),
"overflow list is not empty for initial reflow");
}
#endif
if (!(GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
- DrainFlags flags =
- lazilySetParentPointer ? eDontReparentFrames : DrainFlags(0);
- if (aReflowInput.mLineLayout->GetInFirstLine()) {
- flags = DrainFlags(flags | eInFirstLine);
- }
- DrainSelfOverflowListInternal(flags);
+ DrainSelfOverflowListInternal(aReflowInput.mLineLayout->GetInFirstLine());
}
// Set our own reflow state (additional state above and beyond aReflowInput).
InlineReflowInput irs;
irs.mPrevFrame = nullptr;
irs.mLineContainer = aReflowInput.mLineLayout->LineContainerFrame();
irs.mLineLayout = aReflowInput.mLineLayout;
irs.mNextInFlow = (nsInlineFrame*) GetNextInFlow();
@@ -431,56 +426,53 @@ nsInlineFrame::AttributeChanged(int32_t
f->HandleAttributeChangeInDescendant(mContent->AsElement(),
aNameSpaceID, aAttribute);
}
return NS_OK;
}
bool
-nsInlineFrame::DrainSelfOverflowListInternal(DrainFlags aFlags)
+nsInlineFrame::DrainSelfOverflowListInternal(bool aInFirstLine)
{
AutoFrameListPtr overflowFrames(PresContext(), StealOverflowFrames());
- if (overflowFrames) {
- // The frames on our own overflowlist may have been pushed by a
- // previous lazilySetParentPointer Reflow so we need to ensure the
- // correct parent pointer. This is sometimes skipped by Reflow.
- if (!(aFlags & eDontReparentFrames)) {
- nsIFrame* firstChild = overflowFrames->FirstChild();
- const bool doReparentSC = (aFlags & eInFirstLine);
- RestyleManager* restyleManager = PresContext()->RestyleManager();
- for (nsIFrame* f = firstChild; f; f = f->GetNextSibling()) {
- f->SetParent(this);
- if (doReparentSC) {
- restyleManager->ReparentComputedStyleForFirstLine(f);
- nsLayoutUtils::MarkDescendantsDirty(f);
- }
- }
+ if (!overflowFrames || overflowFrames->IsEmpty()) {
+ return false;
+ }
+
+ // The frames on our own overflowlist may have been pushed by a
+ // previous lazilySetParentPointer Reflow so we need to ensure the
+ // correct parent pointer. This is sometimes skipped by Reflow.
+ nsIFrame* firstChild = overflowFrames->FirstChild();
+ RestyleManager* restyleManager = PresContext()->RestyleManager();
+ for (nsIFrame* f = firstChild; f; f = f->GetNextSibling()) {
+ f->SetParent(this);
+ if (MOZ_UNLIKELY(aInFirstLine)) {
+ restyleManager->ReparentComputedStyleForFirstLine(f);
+ nsLayoutUtils::MarkDescendantsDirty(f);
}
- bool result = !overflowFrames->IsEmpty();
- mFrames.AppendFrames(nullptr, *overflowFrames);
- return result;
}
- return false;
+ mFrames.AppendFrames(nullptr, *overflowFrames);
+ return true;
}
/* virtual */ bool
nsInlineFrame::DrainSelfOverflowList()
{
nsIFrame* lineContainer = nsLayoutUtils::FindNearestBlockAncestor(this);
// Add the eInFirstLine flag if we have a ::first-line ancestor frame.
// No need to look further than the nearest line container though.
- DrainFlags flags = DrainFlags(0);
+ bool inFirstLine = false;
for (nsIFrame* p = GetParent(); p != lineContainer; p = p->GetParent()) {
if (p->IsLineFrame()) {
- flags = DrainFlags(flags | eInFirstLine);
+ inFirstLine = true;
break;
}
}
- return DrainSelfOverflowListInternal(flags);
+ return DrainSelfOverflowListInternal(inFirstLine);
}
/* virtual */ bool
nsInlineFrame::CanContinueTextRun() const
{
// We can continue a text run through an inline frame
return true;
}
--- a/layout/generic/nsInlineFrame.h
+++ b/layout/generic/nsInlineFrame.h
@@ -168,28 +168,22 @@ protected:
nsIFrame* aPrevSibling,
InlineReflowInput& aState);
private:
explicit nsInlineFrame(ComputedStyle* aStyle)
: nsInlineFrame(aStyle, kClassID)
{}
- // Helper method for DrainSelfOverflowList() to deal with lazy parenting
- // (which we only do for nsInlineFrame, not nsFirstLineFrame).
- enum DrainFlags {
- eDontReparentFrames = 1, // skip reparenting the overflow list frames
- eInFirstLine = 2, // the request is for an inline descendant of a nsFirstLineFrame
- };
/**
* Move any frames on our overflow list to the end of our principal list.
- * @param aFlags one or more of the above DrainFlags
+ * @param aInFirstLine whether we're in a first-line frame.
* @return true if there were any overflow frames
*/
- bool DrainSelfOverflowListInternal(DrainFlags aFlags);
+ bool DrainSelfOverflowListInternal(bool aInFirstLine);
protected:
nscoord mBaseline;
};
//----------------------------------------------------------------------
/**
* Variation on inline-frame used to manage lines for line layout in