Bug 1569252 Part 2 - Let mHasColumnSpanSiblings propagate to all the continuations. r=dbaron

We want mHasColumnSpanSiblings to propagate to all the
continuations (both fixed ones or fluid ones) in nsFrame::Init() so that
we don't need to traverse all the way to FirstInFlow() for the bit in
nsBlockFrame::ComputeFinalBSize().

For the last ColumnSet or the last non-column-span wrapper, we'll need
to unset the bit for them manually after constructing them.

Differential Revision: https://phabricator.services.mozilla.com/D40761

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ting-Yu Lin 2019-08-07 20:20:25 +00:00
parent 86d713320f
commit 1e717d14b4
3 changed files with 27 additions and 7 deletions

View File

@ -10785,11 +10785,13 @@ void nsCSSFrameConstructor::FinishBuildingColumns(
prevColumnSet->GetParent() == aColumnSetWrapper,
"Should have established column hierarchy!");
// Tag the first ColumnSet to have column-span siblings so that the bit can
// propagate to all the continuations. We don't want the last ColumnSet to
// have this bit, so we will unset the bit for it at the end of this function.
prevColumnSet->SetHasColumnSpanSiblings(true);
nsFrameList finalList;
while (aColumnContentSiblings.NotEmpty()) {
// Tag every ColumnSet except the last one.
prevColumnSet->SetHasColumnSpanSiblings(true);
nsIFrame* f = aColumnContentSiblings.RemoveFirstChild();
if (f->IsColumnSpan()) {
// Do nothing for column-span wrappers. Just move it to the final
@ -10799,6 +10801,9 @@ void nsCSSFrameConstructor::FinishBuildingColumns(
auto* continuingColumnSet = static_cast<nsContainerFrame*>(
CreateContinuingFrame(mPresShell->GetPresContext(), prevColumnSet,
aColumnSetWrapper, false));
MOZ_ASSERT(continuingColumnSet->HasColumnSpanSiblings(),
"The bit should propagate to the next continuation!");
f->SetParent(continuingColumnSet);
SetInitialSingleChild(continuingColumnSet, f);
finalList.AppendFrame(aColumnSetWrapper, continuingColumnSet);
@ -10806,6 +10811,9 @@ void nsCSSFrameConstructor::FinishBuildingColumns(
}
}
// Unset the bit because the last ColumnSet has no column-span siblings.
prevColumnSet->SetHasColumnSpanSiblings(false);
aColumnSetWrapper->AppendFrames(kPrincipalList, finalList);
}
@ -10843,14 +10851,17 @@ nsFrameList nsCSSFrameConstructor::CreateColumnSpanSiblings(
nsFrameList siblings;
nsContainerFrame* lastNonColumnSpanWrapper = aInitialBlock;
// Tag the first non-column-span wrapper to have column-span siblings so that
// the bit can propagate to all the continuations. We don't want the last
// wrapper to have this bit, so we will unset the bit for it at the end of
// this function.
lastNonColumnSpanWrapper->SetHasColumnSpanSiblings(true);
do {
MOZ_ASSERT(aChildList.NotEmpty(), "Why call this if child list is empty?");
MOZ_ASSERT(aChildList.FirstChild()->IsColumnSpan(),
"Must have the child starting with column-span!");
// Tag every non-column-span wrapper except the last one.
lastNonColumnSpanWrapper->SetHasColumnSpanSiblings(true);
// Grab the consecutive column-span kids, and reparent them into a
// block frame.
RefPtr<ComputedStyle> columnSpanWrapperStyle =
@ -10879,6 +10890,8 @@ nsFrameList nsCSSFrameConstructor::CreateColumnSpanSiblings(
lastNonColumnSpanWrapper, parentFrame, false));
nonColumnSpanWrapper->AddStateBits(NS_FRAME_HAS_MULTI_COLUMN_ANCESTOR |
NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN);
MOZ_ASSERT(nonColumnSpanWrapper->HasColumnSpanSiblings(),
"The bit should propagate to the next continuation!");
if (aChildList.NotEmpty()) {
nsFrameList nonColumnSpanKids =
@ -10897,6 +10910,10 @@ nsFrameList nsCSSFrameConstructor::CreateColumnSpanSiblings(
lastNonColumnSpanWrapper = nonColumnSpanWrapper;
} while (aChildList.NotEmpty());
// Unset the bit because the last non-column-span wrapper has no column-span
// siblings.
lastNonColumnSpanWrapper->SetHasColumnSpanSiblings(false);
return siblings;
}

View File

@ -7427,7 +7427,7 @@ nscoord nsBlockFrame::ComputeFinalBSize(const ReflowInput& aReflowInput,
return finalBSize;
}
if (FirstInFlow()->HasColumnSpanSiblings()) {
if (HasColumnSpanSiblings()) {
MOZ_ASSERT(LastInFlow()->GetNextContinuation(),
"Frame constructor should've created column-span siblings!");

View File

@ -630,6 +630,9 @@ void nsFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
NS_FRAME_MAY_BE_TRANSFORMED |
NS_FRAME_HAS_MULTI_COLUMN_ANCESTOR));
// clang-format on
// Copy other bits in nsIFrame from prev-in-flow.
mHasColumnSpanSiblings = aPrevInFlow->HasColumnSpanSiblings();
} else {
PresContext()->ConstructedFrame();
}