From f21e11f6499d9988568fc383690c31a9dde68d27 Mon Sep 17 00:00:00 2001 From: Timothy Nikkel Date: Tue, 27 Oct 2009 21:00:57 -0500 Subject: [PATCH] Bug 491547. Special case creating a bidi continuation inside a floating first letter frame. r=roc,smontagu --HG-- extra : rebase_source : 20d1d90542c7b78583e1ceff35669f25383e2380 --- layout/base/nsBidiPresUtils.cpp | 34 ++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/layout/base/nsBidiPresUtils.cpp b/layout/base/nsBidiPresUtils.cpp index 289bea91e57..bce1da6f15d 100644 --- a/layout/base/nsBidiPresUtils.cpp +++ b/layout/base/nsBidiPresUtils.cpp @@ -204,7 +204,39 @@ CreateBidiContinuation(nsIFrame* aFrame, if (NS_FAILED(rv)) { return rv; } - + + // Have to special case floating first letter frames because the continuation + // doesn't go in the first letter frame. The continuation goes with the rest + // of the text that the first letter frame was made out of. + if (parent->GetType() == nsGkAtoms::letterFrame && + parent->GetStyleDisplay()->IsFloating()) { + nsIFrame* oldParent = parent; + nsPlaceholderFrame* placeholderFrame = + presShell->FrameManager()->GetPlaceholderFrameFor(parent); + parent = placeholderFrame->GetParent(); + + (*aNewFrame)->SetParent(parent); + nsHTMLContainerFrame::ReparentFrameView(aFrame->PresContext(), *aNewFrame, + oldParent, parent); + + // The continuation will have gotten the first letter style from it's prev + // continuation, so we need to repair the style context so it doesn't have + // the first letter styling. + nsStyleContext* parentSC = oldParent->GetStyleContext()->GetParent(); + if (parentSC) { + nsRefPtr newSC; + newSC = presShell->StyleSet()->ResolveStyleForNonElement(parentSC); + if (newSC) { + (*aNewFrame)->SetStyleContext(newSC); + } + } + + // The list name nsGkAtoms::nextBidi would indicate we don't want reflow + nsFrameList temp(*aNewFrame, *aNewFrame); + rv = parent->InsertFrames(nsGkAtoms::nextBidi, placeholderFrame, temp); + return rv; + } + // The list name nsGkAtoms::nextBidi would indicate we don't want reflow // XXXbz this needs higher-level framelist love nsFrameList temp(*aNewFrame, *aNewFrame);