Bug 419285. nsCSSFrameConstructor should stop looking for first-letter content after a <br>. r+sr=dbaron
authorRobert O'Callahan <robert@ocallahan.org>
Tue, 29 Jul 2008 22:02:00 -0700
changeset 16291 a50ca180ed3e4ec916fa16b72b991ae7305dc790
parent 16290 20427bfb85bc38f7f0aec97dfab6485a7f3ab14e
child 16292 36b049ebc16d8cd13b681d49e162971054a10867
push id905
push userrocallahan@mozilla.com
push dateWed, 30 Jul 2008 05:02:06 +0000
treeherdermozilla-central@a50ca180ed3e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs419285
milestone1.9.1a2pre
Bug 419285. nsCSSFrameConstructor should stop looking for first-letter content after a <br>. r+sr=dbaron
layout/base/nsCSSFrameConstructor.cpp
layout/generic/nsFirstLetterFrame.cpp
layout/reftests/bugs/419285-1-ref.html
layout/reftests/bugs/419285-1.html
layout/reftests/bugs/reftest.list
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -11885,17 +11885,18 @@ nsCSSFrameConstructor::WrapFramesInFirst
   nsresult rv = NS_OK;
 
   nsIFrame* prevFrame = nsnull;
   nsIFrame* frame = aParentFrameList;
 
   while (frame) {
     nsIFrame* nextFrame = frame->GetNextSibling();
 
-    if (nsGkAtoms::textFrame == frame->GetType()) {
+    nsIAtom* frameType = frame->GetType();
+    if (nsGkAtoms::textFrame == frameType) {
       // Wrap up first-letter content in a letter frame
       nsIContent* textContent = frame->GetContent();
       if (IsFirstLetterContent(textContent)) {
         // Create letter frame to wrap up the text
         rv = CreateLetterFrame(aState, aBlockFrame, textContent,
                                aParentFrame, aLetterFrames);
         if (NS_FAILED(rv)) {
           return rv;
@@ -11904,17 +11905,17 @@ nsCSSFrameConstructor::WrapFramesInFirst
         // Provide adjustment information for parent
         *aModifiedParent = aParentFrame;
         *aTextFrame = frame;
         *aPrevFrame = prevFrame;
         *aStopLooking = PR_TRUE;
         return NS_OK;
       }
     }
-    else if (IsInlineFrame(frame)) {
+    else if (IsInlineFrame(frame) && frameType != nsGkAtoms::brFrame) {
       nsIFrame* kids = frame->GetFirstChild(nsnull);
       WrapFramesInFirstLetterFrame(aState, aBlockFrame, frame, kids,
                                    aModifiedParent, aTextFrame,
                                    aPrevFrame, aLetterFrames, aStopLooking);
       if (*aStopLooking) {
         return NS_OK;
       }
     }
--- a/layout/generic/nsFirstLetterFrame.cpp
+++ b/layout/generic/nsFirstLetterFrame.cpp
@@ -231,16 +231,18 @@ nsFirstLetterFrame::Reflow(nsPresContext
 
     ll.EndLineReflow();
   }
   else {
     // Pretend we are a span and reflow the child frame
     nsLineLayout* ll = aReflowState.mLineLayout;
     PRBool        pushedFrame;
 
+    NS_ASSERTION(ll->GetFirstLetterStyleOK() || GetPrevInFlow(),
+                 "First-in-flow first-letter should have first-letter style enabled in nsLineLayout!");
     ll->BeginSpan(this, &aReflowState, bp.left, availSize.width);
     ll->ReflowFrame(kid, aReflowStatus, &aMetrics, pushedFrame);
     ll->EndSpan(this);
   }
 
   // Place and size the child and update the output metrics
   kid->SetRect(nsRect(bp.left, bp.top, aMetrics.width, aMetrics.height));
   kid->FinishAndStoreOverflow(&aMetrics);
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/419285-1-ref.html
@@ -0,0 +1,7 @@
+<!DOCTYPE HTML>
+<html>
+<body style="line-height:50px">
+<p><br>Hello
+<p><span style="font-size:200%">"</span><br>Hello
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/419285-1.html
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<style>
+p::first-letter { font-size:200%; }
+</style>
+</head>
+<body style="line-height:50px">
+<p><br>Hello
+<p>"<br>Hello
+</body>
+</html>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -784,16 +784,17 @@ skip-if(MOZ_WIDGET_TOOLKIT=="cocoa") == 
 == 414851-1.html 414851-1-ref.html
 == 416106-1.xhtml 416106-1-ref.xhtml
 == 416752-1.html 416752-1-ref.html
 == 417178-1.html 417178-1-ref.html
 == 417246-1.html 417246-1-ref.html
 == 417676.html 417676-ref.html
 == 418766-1a.html 418766-1-ref.html
 == 418766-1b.html 418766-1-ref.html
+== 419285-1.html 419285-1-ref.html
 == 419060.html 419060-ref.html
 == 419531-1.html 419531-1-ref.html
 == 420069-1.html 420069-1-ref.html
 == 420069-2.html 420069-2-ref.html
 == 420351-1.html 420351-1-ref.html
 == 421069.html 421069-ref.html
 == 421069.html 421069-ref2.html
 == 421069-ref.html 421069-ref2.html