diff --git a/layout/generic/nsRubyBaseContainerFrame.cpp b/layout/generic/nsRubyBaseContainerFrame.cpp index 67a659536004..047e0cd27aec 100644 --- a/layout/generic/nsRubyBaseContainerFrame.cpp +++ b/layout/generic/nsRubyBaseContainerFrame.cpp @@ -724,7 +724,7 @@ nsRubyBaseContainerFrame::PullOneColumn(nsLineLayout* aLineLayout, nsIFrame* nextBase = GetNextInFlowChild(aPullFrameState.mBase); MOZ_ASSERT(!nextBase || nextBase->GetType() == nsGkAtoms::rubyBaseFrame); aColumn.mBaseFrame = static_cast(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(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.