diff --git a/layout/generic/nsInlineFrame.cpp b/layout/generic/nsInlineFrame.cpp index fab5092e91b..ab23b14109c 100644 --- a/layout/generic/nsInlineFrame.cpp +++ b/layout/generic/nsInlineFrame.cpp @@ -303,6 +303,19 @@ nsInlineFrame::ReparentFloatsForInlineChild(nsIFrame* aOurLineContainer, } } +static void +ReParentChildListStyle(nsPresContext* aPresContext, + const nsFrameList::Slice& aFrames, + nsIFrame* aParentFrame) +{ + nsFrameManager *frameManager = aPresContext->FrameManager(); + + for (nsFrameList::Enumerator e(aFrames); !e.AtEnd(); e.Next()) { + NS_ASSERTION(e.get()->GetParent() == aParentFrame, "Bogus parentage"); + frameManager->ReParentStyleContext(e.get()); + } +} + NS_IMETHODIMP nsInlineFrame::Reflow(nsPresContext* aPresContext, nsHTMLReflowMetrics& aMetrics, @@ -353,7 +366,16 @@ nsInlineFrame::Reflow(nsPresContext* aPresContext, } // Insert the new frames at the beginning of the child list // and set their parent pointer - mFrames.InsertFrames(this, nsnull, *prevOverflowFrames); + const nsFrameList::Slice& newFrames = + mFrames.InsertFrames(this, nsnull, *prevOverflowFrames); + // If our prev in flow was under the first continuation of a first-line + // frame then we need to reparent the style contexts to remove the + // the special first-line styling. In the lazilySetParentPointer case + // we reparent the style contexts when we set their parents in + // nsInlineFrame::ReflowFrames and nsInlineFrame::ReflowInlineFrame. + if (aReflowState.mLineLayout->GetInFirstLine()) { + ReParentChildListStyle(aPresContext, newFrames, this); + } } } } @@ -455,6 +477,8 @@ nsInlineFrame::ReflowFrames(nsPresContext* aPresContext, aStatus = NS_FRAME_COMPLETE; nsLineLayout* lineLayout = aReflowState.mLineLayout; + PRBool inFirstLine = aReflowState.mLineLayout->GetInFirstLine(); + nsFrameManager* frameManager = aPresContext->FrameManager(); PRBool ltr = (NS_STYLE_DIRECTION_LTR == aReflowState.mStyleVisibility->mDirection); nscoord leftEdge = 0; // Don't offset by our start borderpadding if we have a prev continuation or @@ -497,6 +521,9 @@ nsInlineFrame::ReflowFrames(nsPresContext* aPresContext, ReparentFloatsForInlineChild(irs.mLineContainer, frame, PR_FALSE); } frame->SetParent(this); + if (inFirstLine) { + frameManager->ReParentStyleContext(frame); + } // We also need to check if frame has a next-in-flow. If it does, then set // its parent frame pointer, too. Otherwise, if we reflow frame and it's // complete we'll fail when deleting its next-in-flow which is no longer @@ -512,6 +539,9 @@ nsInlineFrame::ReflowFrames(nsPresContext* aPresContext, ReparentFloatsForInlineChild(irs.mLineContainer, nextInFlow, PR_FALSE); } nextInFlow->SetParent(this); + if (inFirstLine) { + frameManager->ReParentStyleContext(nextInFlow); + } } // Fix the parent pointer for ::first-letter child frame next-in-flows, @@ -528,6 +558,9 @@ nsInlineFrame::ReflowFrames(nsPresContext* aPresContext, "unexpected frame type"); if (mFrames.ContainsFrame(nextInFlow)) { nextInFlow->SetParent(this); + if (inFirstLine) { + frameManager->ReParentStyleContext(nextInFlow); + } } else { #ifdef DEBUG @@ -710,6 +743,9 @@ nsInlineFrame::ReflowInlineFrame(nsPresContext* aPresContext, } for (nsIFrame* f = aFrame->GetNextSibling(); f; f = f->GetNextSibling()) { f->SetParent(this); + if (lineLayout->GetInFirstLine()) { + aPresContext->FrameManager()->ReParentStyleContext(f); + } } } } @@ -927,19 +963,6 @@ NS_IMETHODIMP nsInlineFrame::GetAccessible(nsIAccessible** aAccessible) // nsLineFrame implementation -static void -ReParentChildListStyle(nsPresContext* aPresContext, - const nsFrameList::Slice& aFrames, - nsIFrame* aParentFrame) -{ - nsFrameManager *frameManager = aPresContext->FrameManager(); - - for (nsFrameList::Enumerator e(aFrames); !e.AtEnd(); e.Next()) { - NS_ASSERTION(e.get()->GetParent() == aParentFrame, "Bogus parentage"); - frameManager->ReParentStyleContext(e.get()); - } -} - nsIFrame* NS_NewFirstLineFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) { diff --git a/layout/reftests/first-line/287088-1-ref.html b/layout/reftests/first-line/287088-1-ref.html new file mode 100644 index 00000000000..0411b1a1a4c --- /dev/null +++ b/layout/reftests/first-line/287088-1-ref.html @@ -0,0 +1,18 @@ + + + + + + +
+Line number one.
Line number two.
Line number three. +
+ +
+ +
+ + + diff --git a/layout/reftests/first-line/287088-1.html b/layout/reftests/first-line/287088-1.html new file mode 100644 index 00000000000..3583b860d9f --- /dev/null +++ b/layout/reftests/first-line/287088-1.html @@ -0,0 +1,18 @@ + + + + + + +
+Line number one.
Line number two.
Line number three.
+
+ +
+ +
+ + + diff --git a/layout/reftests/first-line/287088-2-ref.html b/layout/reftests/first-line/287088-2-ref.html new file mode 100644 index 00000000000..862d6e309c4 --- /dev/null +++ b/layout/reftests/first-line/287088-2-ref.html @@ -0,0 +1,14 @@ + + + + + + +
+Line number one.
Line number two.
Line number three. +
+ + + diff --git a/layout/reftests/first-line/287088-2.html b/layout/reftests/first-line/287088-2.html new file mode 100644 index 00000000000..9d470b13a2f --- /dev/null +++ b/layout/reftests/first-line/287088-2.html @@ -0,0 +1,14 @@ + + + + + + +
+Line number one.
Line number two.
Line number three.
+
+ + + diff --git a/layout/reftests/first-line/reftest.list b/layout/reftests/first-line/reftest.list index 4131a9c2fc4..976659dc1b1 100644 --- a/layout/reftests/first-line/reftest.list +++ b/layout/reftests/first-line/reftest.list @@ -26,6 +26,8 @@ fails == out-of-flow-1d.html out-of-flow-1-ref.html # bug 396645 == stress-11.xhtml stress-11-ref.xhtml == border-not-apply.html border-not-apply-ref.html +== 287088-1.html 287088-1-ref.html +== 287088-2.html 287088-2-ref.html == 403177-1.html 403177-1-ref.html == 469227-2.html 469227-2-ref.html == 469227-3.html 469227-3-ref.html