Remove unnecessary calls to ReparentFloatsForInlineChild...

This commit is contained in:
Fedor 2019-12-25 15:46:51 +03:00
parent 8eb073fd11
commit 0783506d08
3 changed files with 10 additions and 45 deletions

View File

@ -716,6 +716,8 @@ FloatMarginISize(const ReflowInput& aCBReflowInput,
bool bool
BlockReflowInput::FlowAndPlaceFloat(nsIFrame* aFloat) BlockReflowInput::FlowAndPlaceFloat(nsIFrame* aFloat)
{ {
MOZ_ASSERT(aFloat->GetParent() == mBlock);
WritingMode wm = mReflowInput.GetWritingMode(); WritingMode wm = mReflowInput.GetWritingMode();
// Save away the Y coordinate before placing the float. We will // Save away the Y coordinate before placing the float. We will
// restore mBCoord at the end after placing the float. This is // restore mBCoord at the end after placing the float. This is

View File

@ -376,8 +376,6 @@ nsInlineFrame::Reflow(nsPresContext* aPresContext,
bool lazilySetParentPointer = false; bool lazilySetParentPointer = false;
nsIFrame* lineContainer = aReflowInput.mLineLayout->LineContainerFrame();
// Check for an overflow list with our prev-in-flow // Check for an overflow list with our prev-in-flow
nsInlineFrame* prevInFlow = (nsInlineFrame*)GetPrevInFlow(); nsInlineFrame* prevInFlow = (nsInlineFrame*)GetPrevInFlow();
if (prevInFlow) { if (prevInFlow) {
@ -403,12 +401,6 @@ nsInlineFrame::Reflow(nsPresContext* aPresContext,
mFrames.SetFrames(*prevOverflowFrames); mFrames.SetFrames(*prevOverflowFrames);
lazilySetParentPointer = true; lazilySetParentPointer = true;
} else { } else {
// Assign all floats to our block if necessary
if (lineContainer && lineContainer->GetPrevContinuation()) {
ReparentFloatsForInlineChild(lineContainer,
prevOverflowFrames->FirstChild(),
true);
}
// Insert the new frames at the beginning of the child list // Insert the new frames at the beginning of the child list
// and set their parent pointer // and set their parent pointer
const nsFrameList::Slice& newFrames = const nsFrameList::Slice& newFrames =
@ -442,14 +434,13 @@ nsInlineFrame::Reflow(nsPresContext* aPresContext,
if (aReflowInput.mLineLayout->GetInFirstLine()) { if (aReflowInput.mLineLayout->GetInFirstLine()) {
flags = DrainFlags(flags | eInFirstLine); flags = DrainFlags(flags | eInFirstLine);
} }
DrainSelfOverflowListInternal(flags, lineContainer); DrainSelfOverflowListInternal(flags);
} }
// Set our own reflow state (additional state above and beyond // Set our own reflow state (additional state above and beyond aReflowInput)
// aReflowInput)
InlineReflowInput irs; InlineReflowInput irs;
irs.mPrevFrame = nullptr; irs.mPrevFrame = nullptr;
irs.mLineContainer = lineContainer; irs.mLineContainer = aReflowInput.mLineLayout->LineContainerFrame();
irs.mLineLayout = aReflowInput.mLineLayout; irs.mLineLayout = aReflowInput.mLineLayout;
irs.mNextInFlow = (nsInlineFrame*) GetNextInFlow(); irs.mNextInFlow = (nsInlineFrame*) GetNextInFlow();
irs.mSetParentPointer = lazilySetParentPointer; irs.mSetParentPointer = lazilySetParentPointer;
@ -494,8 +485,7 @@ nsInlineFrame::AttributeChanged(int32_t aNameSpaceID,
} }
bool bool
nsInlineFrame::DrainSelfOverflowListInternal(DrainFlags aFlags, nsInlineFrame::DrainSelfOverflowListInternal(DrainFlags aFlags)
nsIFrame* aLineContainer)
{ {
AutoFrameListPtr overflowFrames(PresContext(), StealOverflowFrames()); AutoFrameListPtr overflowFrames(PresContext(), StealOverflowFrames());
if (overflowFrames) { if (overflowFrames) {
@ -504,9 +494,6 @@ nsInlineFrame::DrainSelfOverflowListInternal(DrainFlags aFlags,
// correct parent pointer. This is sometimes skipped by Reflow. // correct parent pointer. This is sometimes skipped by Reflow.
if (!(aFlags & eDontReparentFrames)) { if (!(aFlags & eDontReparentFrames)) {
nsIFrame* firstChild = overflowFrames->FirstChild(); nsIFrame* firstChild = overflowFrames->FirstChild();
if (aLineContainer && aLineContainer->GetPrevContinuation()) {
ReparentFloatsForInlineChild(aLineContainer, firstChild, true);
}
const bool doReparentSC = (aFlags & eInFirstLine); const bool doReparentSC = (aFlags & eInFirstLine);
RestyleManagerHandle restyleManager = PresContext()->RestyleManager(); RestyleManagerHandle restyleManager = PresContext()->RestyleManager();
for (nsIFrame* f = firstChild; f; f = f->GetNextSibling()) { for (nsIFrame* f = firstChild; f; f = f->GetNextSibling()) {
@ -537,7 +524,7 @@ nsInlineFrame::DrainSelfOverflowList()
break; break;
} }
} }
return DrainSelfOverflowListInternal(flags, lineContainer); return DrainSelfOverflowListInternal(flags);
} }
/* virtual */ bool /* virtual */ bool
@ -606,23 +593,8 @@ nsInlineFrame::ReflowFrames(nsPresContext* aPresContext,
while (frame) { while (frame) {
// Check if we should lazily set the child frame's parent pointer. // Check if we should lazily set the child frame's parent pointer.
if (irs.mSetParentPointer) { if (irs.mSetParentPointer) {
bool havePrevBlock =
irs.mLineContainer && irs.mLineContainer->GetPrevContinuation();
nsIFrame* child = frame; nsIFrame* child = frame;
do { 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); child->SetParent(this);
if (inFirstLine) { if (inFirstLine) {
restyleManager->ReparentStyleContext(child); restyleManager->ReparentStyleContext(child);
@ -1098,20 +1070,13 @@ nsFirstLineFrame::Reflow(nsPresContext* aPresContext,
return; // XXX does this happen? why? return; // XXX does this happen? why?
} }
nsIFrame* lineContainer = aReflowInput.mLineLayout->LineContainerFrame();
// Check for an overflow list with our prev-in-flow // Check for an overflow list with our prev-in-flow
nsFirstLineFrame* prevInFlow = (nsFirstLineFrame*)GetPrevInFlow(); nsFirstLineFrame* prevInFlow = (nsFirstLineFrame*)GetPrevInFlow();
if (prevInFlow) { if (prevInFlow) {
AutoFrameListPtr prevOverflowFrames(aPresContext, AutoFrameListPtr prevOverflowFrames(aPresContext,
prevInFlow->StealOverflowFrames()); prevInFlow->StealOverflowFrames());
if (prevOverflowFrames) { if (prevOverflowFrames) {
// Assign all floats to our block if necessary // Reparent the new frames and their style contexts.
if (lineContainer && lineContainer->GetPrevContinuation()) {
ReparentFloatsForInlineChild(lineContainer,
prevOverflowFrames->FirstChild(),
true);
}
const nsFrameList::Slice& newFrames = const nsFrameList::Slice& newFrames =
mFrames.InsertFrames(this, nullptr, *prevOverflowFrames); mFrames.InsertFrames(this, nullptr, *prevOverflowFrames);
ReparentChildListStyle(aPresContext, newFrames, this); ReparentChildListStyle(aPresContext, newFrames, this);
@ -1125,7 +1090,7 @@ nsFirstLineFrame::Reflow(nsPresContext* aPresContext,
// aReflowInput) // aReflowInput)
InlineReflowInput irs; InlineReflowInput irs;
irs.mPrevFrame = nullptr; irs.mPrevFrame = nullptr;
irs.mLineContainer = lineContainer; irs.mLineContainer = aReflowInput.mLineLayout->LineContainerFrame();
irs.mLineLayout = aReflowInput.mLineLayout; irs.mLineLayout = aReflowInput.mLineLayout;
irs.mNextInFlow = (nsInlineFrame*) GetNextInFlow(); irs.mNextInFlow = (nsInlineFrame*) GetNextInFlow();

View File

@ -179,11 +179,9 @@ private:
/** /**
* Move any frames on our overflow list to the end of our principal list. * Move any frames on our overflow list to the end of our principal list.
* @param aFlags one or more of the above DrainFlags * @param aFlags one or more of the above DrainFlags
* @param aLineContainer the nearest line container ancestor
* @return true if there were any overflow frames * @return true if there were any overflow frames
*/ */
bool DrainSelfOverflowListInternal(DrainFlags aFlags, bool DrainSelfOverflowListInternal(DrainFlags aFlags);
nsIFrame* aLineContainer);
protected: protected:
nscoord mBaseline; nscoord mBaseline;
}; };