Weaken the quirks mode inline box model zeroing-of-containers when those containers have children that are vertical-align: top or bottom, so that it's a little more like when they have children with other values of vertical-align (except that it's an approximation). (Bug 714519) r=roc
authorL. David Baron <dbaron@dbaron.org>
Sun, 01 Jan 2012 17:35:12 -0500
changeset 84858 9152791a6f9039f1be5534b1ea5d88dbec21cb20
parent 84857 a4a07b81ad67f647edddc1a87e79b203802e241a
child 84859 9cf3968475006ca542e693eb56468f73c76e1f76
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs714519
milestone12.0a1
Weaken the quirks mode inline box model zeroing-of-containers when those containers have children that are vertical-align: top or bottom, so that it's a little more like when they have children with other values of vertical-align (except that it's an approximation). (Bug 714519) r=roc
layout/generic/nsLineLayout.cpp
layout/reftests/bugs/714519-1-as.html
layout/reftests/bugs/714519-1-q.html
layout/reftests/bugs/714519-1-ref.html
layout/reftests/bugs/714519-2-as.html
layout/reftests/bugs/714519-2-q.html
layout/reftests/bugs/714519-2-ref.html
layout/reftests/bugs/reftest.list
--- a/layout/generic/nsLineLayout.cpp
+++ b/layout/generic/nsLineLayout.cpp
@@ -2125,16 +2125,65 @@ nsLineLayout::VerticalAlignFrames(PerSpa
     printf("   [span]adjusting for zeroEffectiveSpanBox\n");
     printf("     Original: minY=%d, maxY=%d, height=%d, ascent=%d, logicalHeight=%d, topLeading=%d, bottomLeading=%d\n",
            minY, maxY, spanFramePFD->mBounds.height,
            spanFramePFD->mAscent,
            psd->mLogicalHeight, psd->mTopLeading, psd->mBottomLeading);
 #endif
     nscoord goodMinY = spanFramePFD->mBorderPadding.top - psd->mTopLeading;
     nscoord goodMaxY = goodMinY + psd->mLogicalHeight;
+
+    // For cases like the one in bug 714519 (text-decoration placement
+    // or making nsLineLayout::IsZeroHeight() handle
+    // vertical-align:top/bottom on a descendant of the line that's not
+    // a child of it), we want to treat elements that are
+    // vertical-align: top or bottom somewhat like children for the
+    // purposes of this quirk.  To some extent, this is guessing, since
+    // they might end up being aligned anywhere.  However, we'll guess
+    // that they'll be placed aligned with the top or bottom of this
+    // frame (as though this frame is the only thing in the line).
+    // (Guessing isn't crazy, since all we're doing is reducing the
+    // scope of a quirk and making the behavior more standards-like.)
+    if (maxTopBoxHeight > maxY - minY) {
+      // Distribute maxTopBoxHeight to ascent (baselineY - minY), and
+      // then to descent (maxY - baselineY) by adjusting minY or maxY,
+      // but not to exceed goodMinY and goodMaxY.
+      nscoord distribute = maxTopBoxHeight - (maxY - minY);
+      nscoord ascentSpace = NS_MAX(minY - goodMinY, 0);
+      if (distribute > ascentSpace) {
+        distribute -= ascentSpace;
+        minY -= ascentSpace;
+        nscoord descentSpace = NS_MAX(goodMaxY - maxY, 0);
+        if (distribute > descentSpace) {
+          maxY += descentSpace;
+        } else {
+          maxY += distribute;
+        }
+      } else {
+        minY -= distribute;
+      }
+    }
+    if (maxBottomBoxHeight > maxY - minY) {
+      // Likewise, but preferring descent to ascent.
+      nscoord distribute = maxBottomBoxHeight - (maxY - minY);
+      nscoord descentSpace = NS_MAX(goodMaxY - maxY, 0);
+      if (distribute > descentSpace) {
+        distribute -= descentSpace;
+        maxY += descentSpace;
+        nscoord ascentSpace = NS_MAX(minY - goodMinY, 0);
+        if (distribute > ascentSpace) {
+          minY -= ascentSpace;
+        } else {
+          minY -= distribute;
+        }
+      } else {
+        maxY += distribute;
+      }
+    }
+
     if (minY > goodMinY) {
       nscoord adjust = minY - goodMinY; // positive
 
       // shrink the logical extents
       psd->mLogicalHeight -= adjust;
       psd->mTopLeading -= adjust;
     }
     if (maxY < goodMaxY) {
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/714519-1-as.html
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<title>bug 714519: list numbering of nested vertical-align:top in almost standards mode</title>
+
+<style>
+ol {width: 30em; margin-top: 0 }
+span > span { vertical-align: top }
+</style>
+
+<ol>
+<li><span><span>Short line</span></span></li>
+<li><span><span>This is text that needs to wrap to more than one line to cause the list bullet to disappear</span></span></li>
+<li><span><span>Short line</span></span></li>
+</ol>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/714519-1-q.html
@@ -0,0 +1,12 @@
+<title>bug 714519: list numbering of nested vertical-align:top in quirks mode</title>
+
+<style>
+ol {width: 30em; margin-top: 0 }
+span > span { vertical-align: top }
+</style>
+
+<ol>
+<li><span><span>Short line</span></span></li>
+<li><span><span>This is text that needs to wrap to more than one line to cause the list bullet to disappear</span></span></li>
+<li><span><span>Short line</span></span></li>
+</ol>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/714519-1-ref.html
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML>
+<title>bug 714519: list numbering of nested vertical-align:top (reference)</title>
+
+<style>
+ol {width: 30em; margin-top: 0 }
+</style>
+
+<ol>
+<li>Short line</li>
+<li>This is text that needs to wrap to more than one line to cause the list bullet to disappear</li>
+<li>Short line</li>
+</ol>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/714519-2-as.html
@@ -0,0 +1,9 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<title>bug 714519: underline of nested vertical-align:top in almost standards mode</title>
+
+<style>
+div > span { text-decoration: underline }
+span { vertical-align: top }
+</style>
+
+<div><span><span>Short line</span></span></div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/714519-2-q.html
@@ -0,0 +1,8 @@
+<title>bug 714519: underline of nested vertical-align:top in quirks mode</title>
+
+<style>
+div > span { text-decoration: underline }
+span { vertical-align: top }
+</style>
+
+<div><span><span>Short line</span></span></div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/714519-2-ref.html
@@ -0,0 +1,8 @@
+<!DOCTYPE HTML>
+<title>bug 714519: underline of nested vertical-align:top in almost standards mode</title>
+
+<style>
+div { text-decoration: underline }
+</style>
+
+<div>Short line</div>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1678,8 +1678,12 @@ fails-if(layersGPUAccelerated&&cocoaWidg
 == 696739-1.html 696739-1-ref.html
 needs-focus == 703186-1.html 703186-1-ref.html
 needs-focus == 703186-2.html 703186-2-ref.html
 needs-focus != 703186-1.html 703186-2.html
 == 711359-1.html 711359-1-ref.html
 == 712849-1.html 712849-1-ref.html
 == 713856-static.html  713856-ref.html
 == 713856-dynamic.html 713856-ref.html
+== 714519-1-as.html 714519-1-ref.html
+== 714519-1-q.html 714519-1-ref.html
+== 714519-2-as.html 714519-2-ref.html
+== 714519-2-q.html 714519-2-ref.html