Bug 1106755 - Make more overflow area computation code apply only to floating ::first-letter. r=jfkthame
authorL. David Baron <dbaron@dbaron.org>
Sat, 31 Jan 2015 11:00:44 -0800
changeset 226932 c469b23c542e71e774217dbebee3b94d83229762
parent 226931 012da03f66554f14fc9cd33433c7123d6b948e94
child 226933 e5c0911f112bbab28ff7b0a47d421727235e1664
push id54952
push userdbaron@mozilla.com
push dateSat, 31 Jan 2015 19:01:02 +0000
treeherdermozilla-inbound@c469b23c542e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1106755
milestone38.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 1106755 - Make more overflow area computation code apply only to floating ::first-letter. r=jfkthame In inline layout there's no need to do anything with overflow areas since RelativePositionFrames handles it. Apparently doing some of the work messes things up somehow, so the easy fix is to make the inline ::first-letter codepath behave more like nsInlineFrame and not do any messing with overflow areas. So this moves the rest of the overflow code in nsFirstLetterFrame::Reflow into the float-only codepath. There don't appear to be any ordering issues with the movement, since the code that the FinishAndStoreOverflow call is moved across deals with creating and destroying continuations of the child. All the added tests pass with the patch, but without the patch overflow-inline-nooverflow.html fails.
layout/generic/nsFirstLetterFrame.cpp
layout/reftests/first-letter/overflow-float-nooverflow-ref.html
layout/reftests/first-letter/overflow-float-nooverflow.html
layout/reftests/first-letter/overflow-float-overflow-notref.html
layout/reftests/first-letter/overflow-float-overflow.html
layout/reftests/first-letter/overflow-inline-nooverflow-ref.html
layout/reftests/first-letter/overflow-inline-nooverflow.html
layout/reftests/first-letter/overflow-inline-overflow-notref.html
layout/reftests/first-letter/overflow-inline-overflow-ref.html
layout/reftests/first-letter/overflow-inline-overflow.html
layout/reftests/first-letter/reftest.list
--- a/layout/generic/nsFirstLetterFrame.cpp
+++ b/layout/generic/nsFirstLetterFrame.cpp
@@ -221,16 +221,25 @@ nsFirstLetterFrame::Reflow(nsPresContext
     kid->FinishAndStoreOverflow(&kidMetrics);
     kid->DidReflow(aPresContext, nullptr, nsDidReflowStatus::FINISHED);
 
     convertedSize.ISize(wm) += bp.IStartEnd(wm);
     convertedSize.BSize(wm) += bp.BStartEnd(wm);
     aMetrics.SetSize(wm, convertedSize);
     aMetrics.SetBlockStartAscent(kidMetrics.BlockStartAscent() +
                                  bp.BStart(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);
+
+    FinishAndStoreOverflow(&aMetrics);
   }
   else {
     // Pretend we are a span and reflow the child frame
     nsLineLayout* ll = aReflowState.mLineLayout;
     bool          pushedFrame;
 
     ll->SetInFirstLetter(
       mStyleContext->GetPseudo() == nsCSSPseudoElements::firstLetter);
@@ -242,22 +251,16 @@ nsFirstLetterFrame::Reflow(nsPresContext
                  "since we shouldn't have orthogonal writing modes within "
                  "a line.");
     aMetrics.ISize(lineWM) = ll->EndSpan(this) + bp.IStartEnd(wm);
     ll->SetInFirstLetter(false);
 
     nsLayoutUtils::SetBSizeFromFontMetrics(this, aMetrics, 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);
-
   if (!NS_INLINE_IS_BREAK_BEFORE(aReflowStatus)) {
     // Create a continuation or remove existing continuations based on
     // the reflow completion status.
     if (NS_FRAME_IS_COMPLETE(aReflowStatus)) {
       if (aReflowState.mLineLayout) {
         aReflowState.mLineLayout->SetFirstLetterStyleOK(false);
       }
       nsIFrame* kidNextInFlow = kid->GetNextInFlow();
@@ -282,18 +285,16 @@ nsFirstLetterFrame::Reflow(nsPresContext
         // text that the first letter frame was made out of.
         nsIFrame* continuation;
         CreateContinuationForFloatingParent(aPresContext, kid,
                                             &continuation, true);
       }
     }
   }
 
-  FinishAndStoreOverflow(&aMetrics);
-
   NS_FRAME_SET_TRUNCATION(aReflowStatus, aReflowState, aMetrics);
 }
 
 /* virtual */ bool
 nsFirstLetterFrame::CanContinueTextRun() const
 {
   // We can continue a text run through a first-letter frame.
   return true;
new file mode 100644
--- /dev/null
+++ b/layout/reftests/first-letter/overflow-float-nooverflow-ref.html
@@ -0,0 +1,14 @@
+<title>::first-letter and overflow</title>
+<style>
+
+div {
+  height: 8em; width: 5em;
+  padding: 3px;
+  background: yellow; color: black;
+  line-height: 1.0;
+}
+div::first-letter { font-size: 1.2em; float: left; }
+
+</style>
+
+<div>Hello world, testing, testing, testing, testing</div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/first-letter/overflow-float-nooverflow.html
@@ -0,0 +1,15 @@
+<title>::first-letter and overflow</title>
+<style>
+
+div {
+  height: 8em; width: 5em;
+  padding: 3px;
+  background: yellow; color: black;
+  overflow: auto;
+  line-height: 1.0;
+}
+div::first-letter { font-size: 1.2em; float: left; }
+
+</style>
+
+<div>Hello world, testing, testing, testing, testing</div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/first-letter/overflow-float-overflow-notref.html
@@ -0,0 +1,14 @@
+<title>::first-letter and overflow</title>
+<style>
+
+div {
+  height: 3em; width: 8em;
+  padding: 3px;
+  background: yellow; color: black;
+  line-height: 1.0;
+}
+div::first-letter { font-size: 4em; float: left; }
+
+</style>
+
+<div>Hello</div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/first-letter/overflow-float-overflow.html
@@ -0,0 +1,15 @@
+<title>::first-letter and overflow</title>
+<style>
+
+div {
+  height: 3em; width: 8em;
+  padding: 3px;
+  background: yellow; color: black;
+  overflow: auto;
+  line-height: 1.0;
+}
+div::first-letter { font-size: 4em; float: left; }
+
+</style>
+
+<div>Hello</div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/first-letter/overflow-inline-nooverflow-ref.html
@@ -0,0 +1,14 @@
+<title>::first-letter and overflow</title>
+<style>
+
+div {
+  height: 8em; width: 5em;
+  padding: 3px;
+  background: yellow; color: black;
+  line-height: 1.0;
+}
+div::first-letter { font-size: 1.2em }
+
+</style>
+
+<div>Hello world, testing, testing, testing, testing</div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/first-letter/overflow-inline-nooverflow.html
@@ -0,0 +1,15 @@
+<title>::first-letter and overflow</title>
+<style>
+
+div {
+  height: 8em; width: 5em;
+  padding: 3px;
+  background: yellow; color: black;
+  overflow: auto;
+  line-height: 1.0;
+}
+div::first-letter { font-size: 1.2em }
+
+</style>
+
+<div>Hello world, testing, testing, testing, testing</div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/first-letter/overflow-inline-overflow-notref.html
@@ -0,0 +1,14 @@
+<title>::first-letter and overflow</title>
+<style>
+
+div {
+  height: 3em; width: 8em;
+  padding: 3px;
+  background: yellow; color: black;
+  line-height: 1.0;
+}
+div::first-letter { font-size: 4em }
+
+</style>
+
+<div>Hello</div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/first-letter/overflow-inline-overflow-ref.html
@@ -0,0 +1,15 @@
+<title>::first-letter and overflow</title>
+<style>
+
+div {
+  height: 3em; width: 8em;
+  padding: 3px;
+  background: yellow; color: black;
+  overflow: auto;
+  line-height: 1.0;
+}
+span { font-size: 4em }
+
+</style>
+
+<div><span>H</span>ello</div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/first-letter/overflow-inline-overflow.html
@@ -0,0 +1,15 @@
+<title>::first-letter and overflow</title>
+<style>
+
+div {
+  height: 3em; width: 8em;
+  padding: 3px;
+  background: yellow; color: black;
+  overflow: auto;
+  line-height: 1.0;
+}
+div::first-letter { font-size: 4em }
+
+</style>
+
+<div>Hello</div>
--- a/layout/reftests/first-letter/reftest.list
+++ b/layout/reftests/first-letter/reftest.list
@@ -62,8 +62,13 @@ HTTP(..) == 329069-5.html 329069-5-ref.h
 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
 == inline-height-empty.html inline-height-empty-ref.html
 HTTP(..) == indic-clusters-1.html indic-clusters-1-ref.html
+== overflow-float-nooverflow.html overflow-float-nooverflow-ref.html
+== overflow-float-overflow.html overflow-float-overflow-notref.html
+== overflow-inline-nooverflow.html overflow-inline-nooverflow-ref.html
+!= overflow-inline-overflow.html overflow-inline-overflow-notref.html
+== overflow-inline-overflow.html overflow-inline-overflow-ref.html