Bug 501847 part 3. Make nsInlineFrame::SelfIsEmpty return false as needed for inlines that are part of an {ib} split, to avoid weird blank lines in the middle of {ib} splits. r=dbaron
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 18 Sep 2009 14:00:21 -0400
changeset 34461 ce946663a30ae4855fa79d7e54476f4d3f6694e1
parent 34460 61febc552982947a427f065b4b9e470638b9fa9e
child 34462 822ba7ef29bb7dbec1f4a7f2056721d8c5424034
push id10058
push userbzbarsky@mozilla.com
push dateMon, 02 Nov 2009 03:43:27 +0000
treeherdermozilla-central@0f12f3edad42 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs501847
milestone1.9.3a1pre
Bug 501847 part 3. Make nsInlineFrame::SelfIsEmpty return false as needed for inlines that are part of an {ib} split, to avoid weird blank lines in the middle of {ib} splits. r=dbaron
layout/generic/nsInlineFrame.cpp
layout/reftests/ib-split/emptyspan-1-ref.html
layout/reftests/ib-split/emptyspan-1.html
layout/reftests/ib-split/emptyspan-2-ref.html
layout/reftests/ib-split/emptyspan-2.html
layout/reftests/ib-split/emptyspan-3-ref.html
layout/reftests/ib-split/emptyspan-3.html
layout/reftests/ib-split/emptyspan-4-ref.html
layout/reftests/ib-split/emptyspan-4.html
layout/reftests/ib-split/reftest.list
--- a/layout/generic/nsInlineFrame.cpp
+++ b/layout/generic/nsInlineFrame.cpp
@@ -119,26 +119,49 @@ nsInlineFrame::IsSelfEmpty()
   }
 #endif
   const nsStyleMargin* margin = GetStyleMargin();
   const nsStyleBorder* border = GetStyleBorder();
   const nsStylePadding* padding = GetStylePadding();
   // XXX Top and bottom removed, since they shouldn't affect things, but this
   // doesn't really match with nsLineLayout.cpp's setting of
   // ZeroEffectiveSpanBox, anymore, so what should this really be?
-  if (border->GetActualBorderWidth(NS_SIDE_RIGHT) != 0 ||
-      border->GetActualBorderWidth(NS_SIDE_LEFT) != 0 ||
-      !IsPaddingZero(padding->mPadding.GetRightUnit(),
-                     padding->mPadding.GetRight()) ||
-      !IsPaddingZero(padding->mPadding.GetLeftUnit(),
-                     padding->mPadding.GetLeft()) ||
-      !IsMarginZero(margin->mMargin.GetRightUnit(),
-                    margin->mMargin.GetRight()) ||
-      !IsMarginZero(margin->mMargin.GetLeftUnit(),
-                    margin->mMargin.GetLeft())) {
+  PRBool haveRight =
+    border->GetActualBorderWidth(NS_SIDE_RIGHT) != 0 ||
+    !IsPaddingZero(padding->mPadding.GetRightUnit(),
+                   padding->mPadding.GetRight()) ||
+    !IsMarginZero(margin->mMargin.GetRightUnit(),
+                  margin->mMargin.GetRight());
+  PRBool haveLeft =
+    border->GetActualBorderWidth(NS_SIDE_LEFT) != 0 ||
+    !IsPaddingZero(padding->mPadding.GetLeftUnit(),
+                   padding->mPadding.GetLeft()) ||
+    !IsMarginZero(margin->mMargin.GetLeftUnit(),
+                  margin->mMargin.GetLeft());
+  if (haveLeft || haveRight) {
+    if (GetStateBits() & NS_FRAME_IS_SPECIAL) {
+      PRBool haveStart, haveEnd;
+      if (NS_STYLE_DIRECTION_LTR == GetStyleVisibility()->mDirection) {
+        haveStart = haveLeft;
+        haveEnd = haveRight;
+      } else {
+        haveStart = haveRight;
+        haveEnd = haveLeft;
+      }
+      // For special frames, ignore things we know we'll skip in GetSkipSides.
+      // XXXbz should we be doing this for non-special frames too, in a more
+      // general way?
+
+      // Get the first continuation eagerly, as a performance optimization, to
+      // avoid having to get it twice..
+      nsIFrame* firstCont = GetFirstContinuation();
+      return
+        (!haveStart || nsLayoutUtils::FrameIsNonFirstInIBSplit(firstCont)) &&
+        (!haveEnd || nsLayoutUtils::FrameIsNonLastInIBSplit(firstCont));
+    }
     return PR_FALSE;
   }
   return PR_TRUE;
 }
 
 PRBool
 nsInlineFrame::IsEmpty()
 {
new file mode 100644
--- /dev/null
+++ b/layout/reftests/ib-split/emptyspan-1-ref.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<body style="direction: ltr">
+  <span style="display: block">x</span>
+  <span style="border: 5px solid blue; border-left: none; border-right: none;
+               padding-right: 10px"></span>
+</body>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/ib-split/emptyspan-1.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<body style="direction: ltr">
+  <span style="border: 5px solid blue; border-left: none; border-right: none;
+               padding-right: 10px">
+    <span style="display: block">x</span>
+  </span>
+</body>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/ib-split/emptyspan-2-ref.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<body style="direction: rtl">
+  <span style="border: 5px solid blue; border-left: none; border-right: none;
+               padding-right: 10px"></span>
+  <span style="display: block">x</span>
+</body>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/ib-split/emptyspan-2.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<body style="direction: rtl">
+  <span style="border: 5px solid blue; border-left: none; border-right: none;
+               padding-right: 10px">
+    <span style="display: block">x</span>
+  </span>
+</body>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/ib-split/emptyspan-3-ref.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<body style="direction: ltr">
+  <span style="border: 5px solid blue; border-left: none; border-right: none;
+               padding-left: 10px"></span>
+  <span style="display: block">x</span>
+</body>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/ib-split/emptyspan-3.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<body style="direction: ltr">
+  <span style="border: 5px solid blue; border-left: none; border-right: none;
+               padding-left: 10px">
+    <span style="display: block">x</span>
+  </span>
+</body>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/ib-split/emptyspan-4-ref.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<body style="direction: rtl">
+  <span style="display: block">x</span>
+  <span style="border: 5px solid blue; border-left: none; border-right: none;
+               padding-left: 10px"></span>
+</body>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/ib-split/emptyspan-4.html
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<body style="direction: rtl">
+  <span style="border: 5px solid blue; border-left: none; border-right: none;
+               padding-left: 10px">
+    <span style="display: block">x</span>
+  </span>
+</body>
--- a/layout/reftests/ib-split/reftest.list
+++ b/layout/reftests/ib-split/reftest.list
@@ -39,9 +39,13 @@
 == insert-into-split-inline-12.html insert-into-split-inline-12-ref.html
 == insert-into-split-inline-13.html insert-into-split-inline-13-ref.html
 == insert-into-split-inline-14.html insert-into-split-inline-14-ref.html
 == insert-into-split-inline-15.html insert-into-split-inline-15-ref.html
 == insert-into-split-inline-16a.html insert-into-split-inline-16-ref.html
 == insert-into-split-inline-16b.html insert-into-split-inline-16-ref.html
 == float-inside-inline-between-blocks-1.html float-inside-inline-between-blocks-1-ref.html
 == table-pseudo-in-part3-1.html table-pseudo-in-part3-1-ref.html
+== emptyspan-1.html emptyspan-1-ref.html
+== emptyspan-2.html emptyspan-2-ref.html
+== emptyspan-3.html emptyspan-3-ref.html
+== emptyspan-4.html emptyspan-4-ref.html
 == split-inner-inline-1.html split-inner-inline-1-ref.html