Bug 894629 - Reference containing block's content box for relatively positioned elements in RestyleManager::RecomputePosition. r=dbaron
authorCorey Ford <cford@mozilla.com>
Mon, 22 Jul 2013 09:28:31 -0700
changeset 151758 1da1653dd8847d04a1a5bb3fffd486c35f03e302
parent 151757 190563720411aced23463291a39cd5c70f50a647
child 151759 fd715c78c7fd8636ad26ad3fb34e7add73913072
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs894629
milestone25.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 894629 - Reference containing block's content box for relatively positioned elements in RestyleManager::RecomputePosition. r=dbaron
layout/base/RestyleManager.cpp
layout/reftests/position-dynamic-changes/relative/percent-ref.html
layout/reftests/position-dynamic-changes/relative/percent.html
layout/reftests/position-dynamic-changes/relative/reftest.list
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -339,17 +339,17 @@ RestyleManager::RecomputePosition(nsIFra
         // table elements.  If we apply offsets to things we haven't
         // previously offset, we'll get confused.  So bail.
         return true;
       default:
         break;
     }
 
     nsIFrame* cb = aFrame->GetContainingBlock();
-    const nsSize size = cb->GetSize();
+    const nsSize size = cb->GetContentRectRelativeToSelf().Size();
     const nsPoint oldOffsets = aFrame->GetRelativeOffset();
     nsMargin newOffsets;
 
     // Move the frame
     nsHTMLReflowState::ComputeRelativeOffsets(
         cb->StyleVisibility()->mDirection,
         aFrame, size.width, size.height, newOffsets);
     NS_ASSERTION(newOffsets.left == -newOffsets.right &&
new file mode 100644
--- /dev/null
+++ b/layout/reftests/position-dynamic-changes/relative/percent-ref.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <link rel="stylesheet" type="text/css" href="style.css">
+  </head>
+  <body>
+    <div id="container" style="border-width: 10px; padding: 50px"
+      >surrounding <span id="rel"
+        style="left: 50%; top: 50%;"
+        >position&#10;relative</span> text</div>
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/position-dynamic-changes/relative/percent.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+  <head>
+    <link rel="stylesheet" type="text/css" href="style.css">
+  </head>
+  <body>
+    <div id="container" style="border-width: 10px; padding: 50px"
+      >surrounding <span id="rel"
+        style="left: 0; top: 0;"
+        >position&#10;relative</span> text</div>
+    <script>
+      document.addEventListener("MozReftestInvalidate", function() {
+        var rel = document.getElementById("rel");
+        rel.style.top = "50%";
+        rel.style.left = "50%";
+        document.documentElement.removeAttribute("class");
+      }, false);
+    </script>
+  </body>
+</html>
--- a/layout/reftests/position-dynamic-changes/relative/reftest.list
+++ b/layout/reftests/position-dynamic-changes/relative/reftest.list
@@ -1,4 +1,5 @@
 random-if(cocoaWidget) fuzzy-if(d2d,85,20) == move-right-bottom.html move-right-bottom-ref.html # Bug 742176
 random-if(cocoaWidget) fuzzy-if(d2d,85,20) == move-top-left.html move-top-left-ref.html # Bug 688545, bug 742176
 random-if(cocoaWidget) fuzzy-if(d2d,85,80) == move-right-bottom-table.html move-right-bottom-table-ref.html # Bug 742176
 random-if(cocoaWidget) fuzzy-if(d2d,85,80) == move-top-left-table.html move-top-left-table-ref.html # Bug 688545, bug 742176
+== percent.html percent-ref.html