Title: [271433] trunk
Revision
271433
Author
[email protected]
Date
2021-01-12 23:24:08 -0800 (Tue, 12 Jan 2021)

Log Message

The rootBounds of IntersectionObserverEntry is not correct when {root:document}
https://bugs.webkit.org/show_bug.cgi?id=219495

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

* web-platform-tests/intersection-observer/same-document-with-document-root-expected.txt:

Source/WebCore:

When {root:document}, rootBounds should be the root intersection rectangle which is the document's viewport,
per [1]. The coordinator of rootBounds should be layoutViewportRect, for root intersection rectangle is not affected by pinch zoom [2].

[1] https://www.w3.org/TR/intersection-observer/#dom-intersectionobserverentry-rootbounds
[2] https://w3c.github.io/IntersectionObserver/#intersectionobserver-root-intersection-rectangle

* dom/Document.cpp:
(WebCore::computeIntersectionState):
(WebCore::Document::updateIntersectionObservations):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (271432 => 271433)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-01-13 07:04:32 UTC (rev 271432)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-01-13 07:24:08 UTC (rev 271433)
@@ -1,3 +1,12 @@
+2021-01-12  Cathie Chen  <[email protected]>
+
+        The rootBounds of IntersectionObserverEntry is not correct when {root:document}
+        https://bugs.webkit.org/show_bug.cgi?id=219495
+
+        Reviewed by Darin Adler.
+
+        * web-platform-tests/intersection-observer/same-document-with-document-root-expected.txt:
+
 2021-01-12  Manuel Rego Casasnovas  <[email protected]>
 
         [selectors] Update tests from WPT

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-with-document-root-expected.txt (271432 => 271433)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-with-document-root-expected.txt	2021-01-13 07:04:32 UTC (rev 271432)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-with-document-root-expected.txt	2021-01-13 07:24:08 UTC (rev 271433)
@@ -1,5 +1,5 @@
 
 PASS IntersectionObserver in a single document using document as root.
 PASS First rAF.
-FAIL document.scrollingElement.scrollTop = 300 assert_equals: entries.length expected 2 but got 1
+PASS document.scrollingElement.scrollTop = 300
 

Modified: trunk/Source/WebCore/ChangeLog (271432 => 271433)


--- trunk/Source/WebCore/ChangeLog	2021-01-13 07:04:32 UTC (rev 271432)
+++ trunk/Source/WebCore/ChangeLog	2021-01-13 07:24:08 UTC (rev 271433)
@@ -1,3 +1,20 @@
+2021-01-12  Cathie Chen  <[email protected]>
+
+        The rootBounds of IntersectionObserverEntry is not correct when {root:document}
+        https://bugs.webkit.org/show_bug.cgi?id=219495
+
+        Reviewed by Darin Adler.
+
+        When {root:document}, rootBounds should be the root intersection rectangle which is the document's viewport,
+        per [1]. The coordinator of rootBounds should be layoutViewportRect, for root intersection rectangle is not affected by pinch zoom [2].
+
+        [1] https://www.w3.org/TR/intersection-observer/#dom-intersectionobserverentry-rootbounds
+        [2] https://w3c.github.io/IntersectionObserver/#intersectionobserver-root-intersection-rectangle
+
+        * dom/Document.cpp:
+        (WebCore::computeIntersectionState):
+        (WebCore::Document::updateIntersectionObservations):
+
 2021-01-12  Myles C. Maxfield  <[email protected]>
 
         Multi-codepoint CJK grapheme clusters are not oriented correctly in vertical writing mode

Modified: trunk/Source/WebCore/dom/Document.cpp (271432 => 271433)


--- trunk/Source/WebCore/dom/Document.cpp	2021-01-13 07:04:32 UTC (rev 271432)
+++ trunk/Source/WebCore/dom/Document.cpp	2021-01-13 07:24:08 UTC (rev 271433)
@@ -7722,7 +7722,9 @@
         if (!rootRenderer->isContainingBlockAncestorFor(*targetRenderer))
             return WTF::nullopt;
 
-        if (rootRenderer->hasOverflowClip())
+        if (observer.root() == &target.document())
+            localRootBounds = frameView.layoutViewportRect();
+        else if (rootRenderer->hasOverflowClip())
             localRootBounds = rootRenderer->contentBoxRect();
         else
             localRootBounds = { FloatPoint(), rootRenderer->size() };
@@ -7831,8 +7833,7 @@
                 if (intersectionState) {
                     auto* targetFrameView = target->document().view();
                     targetBoundingClientRect = targetFrameView->absoluteToClientRect(intersectionState->absoluteTargetRect, target->renderer()->style().effectiveZoom());
-                    auto* rootRenderer = observer->root() ? observer->root()->renderer() : frameView->renderView();
-                    clientRootBounds = frameView->absoluteToClientRect(intersectionState->absoluteRootBounds, rootRenderer->style().effectiveZoom());
+                    clientRootBounds = frameView->absoluteToLayoutViewportRect(intersectionState->absoluteRootBounds);
                     if (intersectionState->isIntersecting)
                         clientIntersectionRect = targetFrameView->absoluteToClientRect(intersectionState->absoluteIntersectionRect, target->renderer()->style().effectiveZoom());
                 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to