Bug 1055865 patch 5 - Use normal inline handling for setting the size of a non-floating nsFirstLetterFrame. r=jfkthame
authorL. David Baron <dbaron@dbaron.org>
Mon, 25 Aug 2014 15:32:03 -0700
changeset 223215 d79e57b125ddc191f4bf9b0f670f1fad937ca3ec
parent 223214 a25d5be620425f7bfc4aa4f749a519094357f7ca
child 223216 e0a077aace0cb0d89a798083f2c0bfb5580aa8d6
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1055865
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1055865 patch 5 - Use normal inline handling for setting the size of a non-floating nsFirstLetterFrame. r=jfkthame This is the actual fix for the bug. This changes the vertical sizing of inline ::first-letter frames to work like inlines (and size based on font metrics), so that the line-height calculation that happens later will produces the same results as inlines would produce. In the case we're concerned with of having a text frame child that's 0x0, this changes the inline ::first-letter from from being 0x0 to having a height that is determined from the font metrics.
layout/generic/nsFirstLetterFrame.cpp
layout/reftests/first-letter/429968-1-ref.html
layout/reftests/first-letter/429968-1a.html
layout/reftests/first-letter/429968-1b.html
layout/reftests/first-letter/reftest.list
--- a/layout/generic/nsFirstLetterFrame.cpp
+++ b/layout/generic/nsFirstLetterFrame.cpp
@@ -233,25 +233,25 @@ nsFirstLetterFrame::Reflow(nsPresContext
     nsLineLayout* ll = aReflowState.mLineLayout;
     bool          pushedFrame;
 
     ll->SetInFirstLetter(
       mStyleContext->GetPseudo() == nsCSSPseudoElements::firstLetter);
     ll->BeginSpan(this, &aReflowState, bp.IStart(wm),
                   availSize.ISize(wm), &mBaseline);
     ll->ReflowFrame(kid, aReflowStatus, &kidMetrics, pushedFrame);
-    ll->EndSpan(this);
+    NS_ASSERTION(lineWM.IsVertical() == wm.IsVertical(),
+                 "we're assuming we can mix sizes between lineWM and wm "
+                 "since we shouldn't have orthogonal writing modes within "
+                 "a line.");
+    aMetrics.ISize(lineWM) = ll->EndSpan(this) + bp.IStartEnd(wm);
     ll->SetInFirstLetter(false);
 
-    LogicalSize convertedSize = kidMetrics.Size(lineWM).ConvertTo(wm, lineWM);
-    convertedSize.ISize(wm) += bp.IStartEnd(wm);
-    convertedSize.BSize(wm) += bp.BStartEnd(wm);
-    aMetrics.SetSize(wm, convertedSize);
-    aMetrics.SetBlockStartAscent(kidMetrics.BlockStartAscent() +
-                                 bp.BStart(wm));
+    nsLayoutUtils::SetBSizeFromFontMetrics(this, aMetrics, aReflowState,
+                                           bp, lineWM, wm);
   }
 
   // Ensure that the overflow rect contains the child textframe's overflow rect.
   // Note that if this is floating, the overline/underline drawable area is in
   // the overflow rect of the child textframe.
   aMetrics.UnionOverflowAreasWithDesiredBounds();
   ConsiderChildOverflow(aMetrics.mOverflowAreas, kid);
 
--- a/layout/reftests/first-letter/429968-1-ref.html
+++ b/layout/reftests/first-letter/429968-1-ref.html
@@ -1,10 +1,14 @@
 <!DOCTYPE html>
 <html>
 <head>
 <style>
 body { white-space:pre; color:black; }
+/* FIXME (Bug 1058203): avoid line-height:normal since it seems to have
+   different meaning on ::first-letter or span */
+span.first-letter { text-decoration:underline;
+                    font-size:200%; line-height: 1.2; }
 </style>
 </head>
 <body>
-AB</body>
+<span class="first-letter"></span>AB</body>
 </html>
--- a/layout/reftests/first-letter/429968-1a.html
+++ b/layout/reftests/first-letter/429968-1a.html
@@ -1,11 +1,14 @@
 <!DOCTYPE HTML>
 <html>
 <head>
 <style>
 body { white-space:pre; color:black; }
-#inner::first-letter { color:red; text-decoration:underline; font-size:200%; }
+/* FIXME (Bug 1058203): avoid line-height:normal since it seems to have
+   different meaning on ::first-letter or span */
+#inner::first-letter { color:red; text-decoration:underline;
+                       font-size:200%; line-height: 1.2; }
 </style>
 </head>
 <body><div id="inner"><span>
 </span>AB</div></body>
 </html>
--- a/layout/reftests/first-letter/429968-1b.html
+++ b/layout/reftests/first-letter/429968-1b.html
@@ -1,14 +1,17 @@
 <!DOCTYPE HTML>
 <html>
 <head>
 <style>
 body { white-space:pre; color:blue; }
-#inner::first-letter { color:red; text-decoration:underline; font-size:200%; }
+/* FIXME (Bug 1058203): avoid line-height:normal since it seems to have
+   different meaning on ::first-letter or span */
+#inner::first-letter { color:red; text-decoration:underline;
+                       font-size:200%; line-height: 1.2; }
 </style>
 </head>
 <body><div id="inner"><span>
 </span>AB</div></body>
 <script>
 document.body.offsetTop;
 document.body.style.color = "black";
 </script>
--- a/layout/reftests/first-letter/reftest.list
+++ b/layout/reftests/first-letter/reftest.list
@@ -60,9 +60,9 @@ fails-if(!cocoaWidget) == 329069-5.html 
 == 484400-1.html 484400-1-ref.html
 == 594303-1.html 594303-1-ref.html
 fails-if(winWidget||cocoaWidget) == 617869-1.html 617869-1-ref.html
 == 723509-1.html 723509-1-ref.html
 == 922550-1.html 922550-1-ref.html
 == 958249.html 958249-ref.html
 == font-text-styles.html font-text-styles-ref.html
 fails-if(gtk2Widget) random-if(winWidget&&!d2d) == font-text-styles-floater.html font-text-styles-floater-ref.html # bug 992846
-fails == inline-height-empty.html inline-height-empty-ref.html
+== inline-height-empty.html inline-height-empty-ref.html