Bug 1363650 - (intersection-observer) Use content area as the intersection rectangle for custom root with overflow clip. r=mattwoodrow
authorTobias Schneider <schneider@jancona.com>
Wed, 21 Jun 2017 10:40:44 -0700
changeset 414071 5424426a71897398c11894f0c43c3e6d485f4604
parent 414070 cc58f2b74c4f3c95d9dfed26b6b69f540052ca27
child 414072 d5630ef01b17b62aa3a9e870035e4b3bce724bf4
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1363650
milestone56.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 1363650 - (intersection-observer) Use content area as the intersection rectangle for custom root with overflow clip. r=mattwoodrow
dom/base/DOMIntersectionObserver.cpp
testing/web-platform/meta/intersection-observer/containing-block.html.ini
testing/web-platform/meta/intersection-observer/remove-element.html.ini
testing/web-platform/meta/intersection-observer/same-document-root.html.ini
--- a/dom/base/DOMIntersectionObserver.cpp
+++ b/dom/base/DOMIntersectionObserver.cpp
@@ -263,27 +263,31 @@ DOMIntersectionObserver::Update(nsIDocum
   Element* root = nullptr;
   nsIFrame* rootFrame = nullptr;
   nsRect rootRect;
 
   if (mRoot) {
     root = mRoot;
     rootFrame = root->GetPrimaryFrame();
     if (rootFrame) {
+      nsRect rootRectRelativeToRootFrame;
       if (rootFrame->IsScrollFrame()) {
+        // rootRectRelativeToRootFrame should be the content rect of rootFrame, not including the scrollbars.
         nsIScrollableFrame* scrollFrame = do_QueryFrame(rootFrame);
-        rootRect = nsLayoutUtils::TransformFrameRectToAncestor(
-          rootFrame,
-          rootFrame->GetContentRectRelativeToSelf(),
-          scrollFrame->GetScrolledFrame());
+        rootRectRelativeToRootFrame = scrollFrame->GetScrollPortRect();
       } else {
-        rootRect = nsLayoutUtils::GetAllInFlowRectsUnion(rootFrame,
-          nsLayoutUtils::GetContainingBlockForClientRect(rootFrame),
-          nsLayoutUtils::RECTS_ACCOUNT_FOR_TRANSFORMS);
+        // rootRectRelativeToRootFrame should be the border rect of rootFrame.
+        rootRectRelativeToRootFrame = rootFrame->GetRectRelativeToSelf();
       }
+      nsIFrame* containingBlock =
+        nsLayoutUtils::GetContainingBlockForClientRect(rootFrame);
+      rootRect =
+        nsLayoutUtils::TransformFrameRectToAncestor(rootFrame,
+                                                    rootRectRelativeToRootFrame,
+                                                    containingBlock);
     }
   } else {
     nsCOMPtr<nsIPresShell> presShell = aDocument->GetShell();
     if (presShell) {
       rootFrame = presShell->GetRootScrollFrame();
       if (rootFrame) {
         nsPresContext* presContext = rootFrame->PresContext();
         while (!presContext->IsRootContentDocument()) {
--- a/testing/web-platform/meta/intersection-observer/containing-block.html.ini
+++ b/testing/web-platform/meta/intersection-observer/containing-block.html.ini
@@ -1,3 +1,2 @@
 [containing-block.html]
   type: testharness
-  disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1363650
--- a/testing/web-platform/meta/intersection-observer/remove-element.html.ini
+++ b/testing/web-platform/meta/intersection-observer/remove-element.html.ini
@@ -1,3 +1,2 @@
 [remove-element.html]
   type: testharness
-  disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1363650
--- a/testing/web-platform/meta/intersection-observer/same-document-root.html.ini
+++ b/testing/web-platform/meta/intersection-observer/same-document-root.html.ini
@@ -1,3 +1,2 @@
 [same-document-root.html]
   type: testharness
-  disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1363650