Bug 1359317 - (intersection-observer) Use targetFrame->GetRectRelativeToSelf() as the initial intersection rect. r=mstange, a=lizzard
authorTobias Schneider <schneider@jancona.com>
Mon, 19 Jun 2017 13:32:07 -0700
changeset 414270 058ee78afe6fcbe4f7f7230a212bd0de7a8dfd09
parent 414269 2c41c817d86a473c59fe46fe1d2062fd95b40b7d
child 414271 214d63665fe952c20edf41cd322f6dbf276abc0e
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange, lizzard
bugs1359317
milestone55.0
Bug 1359317 - (intersection-observer) Use targetFrame->GetRectRelativeToSelf() as the initial intersection rect. r=mstange, a=lizzard
dom/base/DOMIntersectionObserver.cpp
testing/web-platform/meta/MANIFEST.json
testing/web-platform/meta/intersection-observer/bounding-box.html.ini
testing/web-platform/meta/intersection-observer/edge-inclusive-intersection.html.ini
testing/web-platform/meta/intersection-observer/unclipped-root.html.ini
testing/web-platform/mozilla/meta/MANIFEST.json
testing/web-platform/tests/intersection-observer/bounding-box.html
--- a/dom/base/DOMIntersectionObserver.cpp
+++ b/dom/base/DOMIntersectionObserver.cpp
@@ -351,17 +351,17 @@ DOMIntersectionObserver::Update(nsIDocum
         }
       }
 
       targetRect = nsLayoutUtils::GetAllInFlowRectsUnion(
         targetFrame,
         nsLayoutUtils::GetContainingBlockForClientRect(targetFrame),
         nsLayoutUtils::RECTS_ACCOUNT_FOR_TRANSFORMS
       );
-      intersectionRect = Some(targetFrame->GetVisualOverflowRect());
+      intersectionRect = Some(targetFrame->GetRectRelativeToSelf());
 
       nsIFrame* containerFrame = nsLayoutUtils::GetCrossDocParentFrame(targetFrame);
       while (containerFrame && containerFrame != rootFrame) {
         if (containerFrame->IsScrollFrame()) {
           nsIScrollableFrame* scrollFrame = do_QueryFrame(containerFrame);
           nsRect subFrameRect = scrollFrame->GetScrollPortRect();
           nsRect intersectionRectRelativeToContainer =
             nsLayoutUtils::TransformFrameRectToAncestor(targetFrame,
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -104614,16 +104614,22 @@
     ]
    ],
    "input-events/idlharness.html": [
     [
      "/input-events/idlharness.html",
      {}
     ]
    ],
+   "intersection-observer/bounding-box.html": [
+    [
+     "/intersection-observer/bounding-box.html",
+     {}
+    ]
+   ],
    "intersection-observer/client-rect.html": [
     [
      "/intersection-observer/client-rect.html",
      {}
     ]
    ],
    "intersection-observer/containing-block.html": [
     [
@@ -192613,16 +192619,20 @@
   "interfaces/uievents.idl": [
    "3fabcfa40caf9c66bc74bcd83663eddb0f385051",
    "support"
   ],
   "interfaces/webrtc-pc.idl": [
    "4f94c4236168ed722f71d81bd957e0da72b29c71",
    "support"
   ],
+  "intersection-observer/bounding-box.html": [
+   "a3ac1b70ba26234b7c968055171e652f3a8a14d8",
+   "testharness"
+  ],
   "intersection-observer/client-rect.html": [
    "acec9a4f59ebee1840950cf766a45676490eef84",
    "testharness"
   ],
   "intersection-observer/containing-block.html": [
    "8bdf6fa6a3ee09130981bf83728aa9f61a6ebc54",
    "testharness"
   ],
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/intersection-observer/bounding-box.html.ini
@@ -0,0 +1,2 @@
+[bounding-box.html]
+  type: testharness
--- a/testing/web-platform/meta/intersection-observer/edge-inclusive-intersection.html.ini
+++ b/testing/web-platform/meta/intersection-observer/edge-inclusive-intersection.html.ini
@@ -1,3 +1,2 @@
 [edge-inclusive-intersection.html]
   type: testharness
-  disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1359317
--- a/testing/web-platform/meta/intersection-observer/unclipped-root.html.ini
+++ b/testing/web-platform/meta/intersection-observer/unclipped-root.html.ini
@@ -1,3 +1,2 @@
 [unclipped-root.html]
   type: testharness
-  disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1359317
--- a/testing/web-platform/mozilla/meta/MANIFEST.json
+++ b/testing/web-platform/mozilla/meta/MANIFEST.json
@@ -871,17 +871,17 @@
    "ab6633c08a3a501d3766d9ee38da69e26dc8a9e4",
    "testharness"
   ],
   "focus/Selection_addRange.html": [
    "e733930483c74e73210c5a127db1d04f82c966cf",
    "testharness"
   ],
   "focus/Selection_addRange_in_iframe.html": [
-   "7ce21d66cd147f2c0313168f8e4d97628270b67b",
+   "941327d56ba3fb7a358c8fd61e7c2598906c9992",
    "testharness"
   ],
   "focus/Selection_addRange_into_iframe.html": [
    "65143dd5377acc88b180460a46dd4bbb79cbf68e",
    "testharness"
   ],
   "focus/Selection_addRange_into_iframe_iframe.html": [
    "8e8eb8ee04e7a0879828de2c5fb2501c088504a4",
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/intersection-observer/bounding-box.html
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="./resources/intersection-observer-test-utils.js"></script>
+
+<style>
+pre, #log {
+  position: absolute;
+  top: 0;
+  left: 200px;
+}
+#root {
+  overflow: visible;
+  height: 200px;
+  width: 160px;
+  border: 7px solid black;
+}
+#target {
+  margin: 10px;
+  width: 100px;
+  height: 100px;
+  padding: 10px;
+  background-color: green;
+}
+</style>
+
+<div id="root">
+  <div id="target" style="transform: translateY(300px)"></div>
+</div>
+
+<script>
+var entries = [];
+var target;
+
+runTestCycle(function() {
+  target = document.getElementById("target");
+  assert_true(!!target, "target exists");
+  var root = document.getElementById("root");
+  assert_true(!!root, "root exists");
+  var observer = new IntersectionObserver(function(changes) {
+    entries = entries.concat(changes)
+  }, {root: root});
+  observer.observe(target);
+  entries = entries.concat(observer.takeRecords());
+  assert_equals(entries.length, 0, "No initial notifications.");
+  runTestCycle(step0, "First rAF.");
+}, "Test that the target's border bounding box is used to calculate intersection.");
+
+function step0() {
+  var targetBounds = clientBounds(target);
+  target.style.transform = "translateY(195px)";
+  runTestCycle(step1, "target.style.transform = 'translateY(195px)'");
+  checkLastEntry(entries, 0, targetBounds.concat(0, 0, 0, 0, 8, 182, 8, 222, false));
+}
+
+function step1() {
+  var targetBounds = clientBounds(target);
+  target.style.transform = "";
+  checkLastEntry(entries, 1, targetBounds.concat(25, 145, 220, 222, 8, 182, 8, 222, true));
+}
+</script>