Bug 599882. Make baselines not depend on relative positioning of kids. r=dbaron
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 17 Oct 2012 17:01:55 -0400
changeset 110592 4f40efa904b00ea9250e97c1ad781b96f2e21477
parent 110591 50d6355b80c44f79bd42b12af7e00b8614d0cb59
child 110593 91e2659887c63a431ce0d07ec326a8df0664d644
push id23700
push userryanvm@gmail.com
push dateThu, 18 Oct 2012 02:10:26 +0000
treeherdermozilla-central@5142bbd4da12 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs599882
milestone19.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 599882. Make baselines not depend on relative positioning of kids. r=dbaron
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
layout/reftests/bugs/599882-1-ref.html
layout/reftests/bugs/599882-1a.html
layout/reftests/bugs/599882-1b.html
layout/reftests/bugs/599882-2-ref.html
layout/reftests/bugs/599882-2.html
layout/reftests/bugs/reftest.list
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -3413,34 +3413,36 @@ nsLayoutUtils::GetFirstLinePosition(cons
       return false;
     }
 
     if (fType == nsGkAtoms::fieldSetFrame) {
       LinePosition kidPosition;
       nsIFrame* kid = aFrame->GetFirstPrincipalChild();
       // kid might be a legend frame here, but that's ok.
       if (GetFirstLinePosition(kid, &kidPosition)) {
-        *aResult = kidPosition + kid->GetPosition().y;
+        *aResult = kidPosition + (kid->GetPosition().y -
+                                  kid->GetRelativeOffset().y);
         return true;
       }
       return false;
     }
 
     // No baseline.
     return false;
   }
 
   for (nsBlockFrame::const_line_iterator line = block->begin_lines(),
                                      line_end = block->end_lines();
        line != line_end; ++line) {
     if (line->IsBlock()) {
       nsIFrame *kid = line->mFirstChild;
       LinePosition kidPosition;
       if (GetFirstLinePosition(kid, &kidPosition)) {
-        *aResult = kidPosition + kid->GetPosition().y;
+        *aResult = kidPosition + (kid->GetPosition().y -
+                                  kid->GetRelativeOffset().y);
         return true;
       }
     } else {
       // XXX Is this the right test?  We have some bogus empty lines
       // floating around, but IsEmpty is perhaps too weak.
       if (line->GetHeight() != 0 || !line->IsEmpty()) {
         nscoord top = line->mBounds.y;
         aResult->mTop = top;
@@ -3463,22 +3465,24 @@ nsLayoutUtils::GetLastLineBaseline(const
 
   for (nsBlockFrame::const_reverse_line_iterator line = block->rbegin_lines(),
                                              line_end = block->rend_lines();
        line != line_end; ++line) {
     if (line->IsBlock()) {
       nsIFrame *kid = line->mFirstChild;
       nscoord kidBaseline;
       if (GetLastLineBaseline(kid, &kidBaseline)) {
-        *aResult = kidBaseline + kid->GetPosition().y;
+        // Ignore relative positioning for baseline calculations
+        *aResult = kidBaseline + kid->GetPosition().y -
+          kid->GetRelativeOffset().y;
         return true;
       } else if (kid->GetType() == nsGkAtoms::scrollFrame) {
         // Use the bottom of the scroll frame.
         // XXX CSS2.1 really doesn't say what to do here.
-        *aResult = kid->GetRect().YMost();
+        *aResult = kid->GetRect().YMost() - kid->GetRelativeOffset().y;
         return true;
       }
     } else {
       // XXX Is this the right test?  We have some bogus empty lines
       // floating around, but IsEmpty is perhaps too weak.
       if (line->GetHeight() != 0 || !line->IsEmpty()) {
         *aResult = line->mBounds.y + line->GetAscent();
         return true;
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -1077,17 +1077,17 @@ public:
       LinePosition result;
       result.mTop = mTop + aOffset;
       result.mBaseline = mBaseline + aOffset;
       result.mBottom = mBottom + aOffset;
       return result;
     }
   };
   static bool GetFirstLinePosition(const nsIFrame* aFrame,
-                                     LinePosition* aResult);
+                                   LinePosition* aResult);
 
 
   /**
    * Derive a baseline of |aFrame| (measured from its top border edge)
    * from its last in-flow line box (not descending into anything with
    * 'overflow' not 'visible', potentially including aFrame itself).
    *
    * Returns true if a baseline was found (and fills in aResult).
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/599882-1-ref.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style type="text/css">
+  .positioned {
+    display:block;
+  }
+
+  .container {
+    display:inline-block;
+  }
+</style>
+</head>
+<body>
+<span style="vertical-align: baseline">Baseline aligned</span>
+<span class="container"><span class="positioned">&nbsp;</span></span>
+ </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/599882-1a.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style type="text/css">
+  .positioned {
+    display:block;
+    position: relative; 
+    top:200px;
+  }
+
+  .container {
+    display:inline-block;
+  }
+
+</style>
+</head>
+<body>
+<span style="vertical-align: baseline">Baseline aligned</span>
+<span class="container"><span class="positioned">&nbsp;</span></span>
+ </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/599882-1b.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style type="text/css">
+  .positioned {
+    display:block;
+    position: relative; 
+    top:200px;
+  }
+
+  .container {
+    display:inline-table;
+  }
+
+</style>
+</head>
+<body>
+<span style="vertical-align: baseline">Baseline aligned</span>
+<span class="container"><span class="positioned">&nbsp;</span></span>
+ </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/599882-2-ref.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<body>
+<ul>
+  <li>
+    <div class="positioned">&nbsp;</div>
+</ul>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/599882-2.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style type="text/css">
+  .positioned {
+    position: relative; 
+    top:200px;
+  }
+
+</style>
+</head>
+<body>
+<ul>
+  <li>
+    <div class="positioned">&nbsp;</div>
+  </li>
+</ul>
+ </body>
+</html>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1584,16 +1584,19 @@ skip-if(!browserIsRemote) == 593243-2.ht
 == 593544-1.html 593544-1-ref.html
 == 594333-1.html 594333-1-ref.html
 == 594624-1.html 594624-1-ref.html
 == 594737-1.html 594737-1-ref.html
 == 597721-1.html 597721-1-ref.html
 random-if(winWidget) needs-focus == 598726-1.html 598726-1-ref.html # Fails on Windows, bug 782196
 == 599113-1.html 599113-1-ref.html
 fails-if(!haveTestPlugin) == 599476.html 599476-ref.html
+== 599882-1a.html 599882-1-ref.html
+== 599882-1b.html 599882-1-ref.html
+== 599882-2.html 599882-2-ref.html
 == 600045-1.html 600045-1-ref.html
 == 600803-1.html 600803-1-ref.html
 == 603423-1.html 603423-1-ref.html
 == 600974-1.html 600974-1-ref.html
 == 600974-2.html 600974-1-ref.html
 == 600974-3.html 600974-1-ref.html
 == 602200-1.html 602200-1-ref.html
 == 602200-2.html 602200-2-ref.html