Bug 1229437 part 4 - Reparent floats inside pulled ruby column. r=dbaron

--HG--
extra : rebase_source : 8685d4aabbc0e0569cf453916d9cfb28bbe37ec9
This commit is contained in:
Xidorn Quan 2015-12-21 14:02:46 +11:00
Родитель 25ee3640a7
Коммит 4c680388ca
1 изменённых файлов: 33 добавлений и 4 удалений

Просмотреть файл

@ -724,7 +724,7 @@ nsRubyBaseContainerFrame::PullOneColumn(nsLineLayout* aLineLayout,
nsIFrame* nextBase = GetNextInFlowChild(aPullFrameState.mBase);
MOZ_ASSERT(!nextBase || nextBase->GetType() == nsGkAtoms::rubyBaseFrame);
aColumn.mBaseFrame = static_cast<nsRubyBaseFrame*>(nextBase);
aIsComplete = !aColumn.mBaseFrame;
bool foundFrame = !!aColumn.mBaseFrame;
bool pullingIntraLevelWhitespace =
aColumn.mBaseFrame && aColumn.mBaseFrame->IsIntraLevelWhitespace();
@ -735,13 +735,17 @@ nsRubyBaseContainerFrame::PullOneColumn(nsLineLayout* aLineLayout,
MOZ_ASSERT(!nextText || nextText->GetType() == nsGkAtoms::rubyTextFrame);
nsRubyTextFrame* textFrame = static_cast<nsRubyTextFrame*>(nextText);
aColumn.mTextFrames.AppendElement(textFrame);
// If there exists any frame in continations, we haven't
// completed the reflow process.
aIsComplete = aIsComplete && !nextText;
foundFrame = foundFrame || nextText;
if (nextText && !pullingIntraLevelWhitespace) {
pullingIntraLevelWhitespace = textFrame->IsIntraLevelWhitespace();
}
}
// If there exists any frame in continations, we haven't
// completed the reflow process.
aIsComplete = !foundFrame;
if (!foundFrame) {
return;
}
aColumn.mIsIntraLevelWhitespace = pullingIntraLevelWhitespace;
if (pullingIntraLevelWhitespace) {
@ -757,6 +761,31 @@ nsRubyBaseContainerFrame::PullOneColumn(nsLineLayout* aLineLayout,
textFrame = nullptr;
}
}
} else {
// We are not pulling an intra-level whitespace, which means all
// elements we are going to pull can have non-whitespace content,
// which may contain float which we need to reparent.
nsBlockFrame* oldFloatCB = nullptr;
for (nsIFrame* frame : aColumn) {
oldFloatCB = nsLayoutUtils::GetFloatContainingBlock(frame);
break;
}
#ifdef DEBUG
MOZ_ASSERT(oldFloatCB, "Must have found a float containing block");
for (nsIFrame* frame : aColumn) {
MOZ_ASSERT(nsLayoutUtils::GetFloatContainingBlock(frame) == oldFloatCB,
"All frames in the same ruby column should share "
"the same old float containing block");
}
#endif
nsBlockFrame* newFloatCB =
nsLayoutUtils::GetAsBlock(aLineLayout->LineContainerFrame());
MOZ_ASSERT(newFloatCB, "Must have a float containing block");
if (oldFloatCB != newFloatCB) {
for (nsIFrame* frame : aColumn) {
newFloatCB->ReparentFloats(frame, oldFloatCB, false);
}
}
}
// Pull the frames of this column.