[IntersectionObserver] Account for CSS zoom when computing client rects
authorajuma@chromium.org <ajuma@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Nov 2018 14:59:12 +0000 (14:59 +0000)
committerajuma@chromium.org <ajuma@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Nov 2018 14:59:12 +0000 (14:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191282

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

Update expectation for test case that now passes.

* web-platform-tests/intersection-observer/bounding-box-expected.txt:

Source/WebCore:

When computing rects for an IntersectionObserverEntry, account for the effective zoom when
converting from absolute to client coordinates.

Test: web-platform-tests/intersection-observer/bounding-box.html

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

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237862 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/intersection-observer/bounding-box-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp

index 2087f9a..3a53791 100644 (file)
@@ -1,3 +1,14 @@
+2018-11-06  Ali Juma  <ajuma@chromium.org>
+
+        [IntersectionObserver] Account for CSS zoom when computing client rects
+        https://bugs.webkit.org/show_bug.cgi?id=191282
+
+        Reviewed by Simon Fraser.
+
+        Update expectation for test case that now passes.
+
+        * web-platform-tests/intersection-observer/bounding-box-expected.txt:
+
 2018-11-06  Antoine Quint  <graouts@apple.com>
 
         [Web Animations] Update all tests to match the latest API changes
index fa3f19a..76ca1f2 100644 (file)
@@ -3,5 +3,5 @@ PASS Test that the target's border bounding box is used to calculate intersectio
 PASS First rAF. 
 PASS target.style.transform = 'translateY(195px)' 
 PASS target.style.transform = 'translateY(300px)' 
-FAIL target.style.zoom = 2 assert_equals: entries[3].boundingClientRect.left expected 18 but got 36
+PASS target.style.zoom = 2 
 
index b0ef6c7..87f19a5 100644 (file)
@@ -1,3 +1,18 @@
+2018-11-06  Ali Juma  <ajuma@chromium.org>
+
+        [IntersectionObserver] Account for CSS zoom when computing client rects
+        https://bugs.webkit.org/show_bug.cgi?id=191282
+
+        Reviewed by Simon Fraser.
+
+        When computing rects for an IntersectionObserverEntry, account for the effective zoom when
+        converting from absolute to client coordinates.
+
+        Test: web-platform-tests/intersection-observer/bounding-box.html
+
+        * dom/Document.cpp:
+        (WebCore::Document::updateIntersectionObservations):
+
 2018-11-06  Thibault Saunier  <tsaunier@igalia.com>
 
         [GStreamer][WebRTC] Implement black frame generation
index 43e53ce..d6e6e35 100644 (file)
@@ -7751,10 +7751,11 @@ void Document::updateIntersectionObservations()
                 FloatRect clientRootBounds;
                 if (intersectionState) {
                     auto* targetFrameView = target->document().view();
-                    targetBoundingClientRect = targetFrameView->absoluteToClientRect(intersectionState->absoluteTargetRect);
-                    clientRootBounds = frameView->absoluteToClientRect(intersectionState->absoluteRootBounds);
+                    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());
                     if (intersectionState->isIntersecting)
-                        clientIntersectionRect = targetFrameView->absoluteToClientRect(intersectionState->absoluteIntersectionRect);
+                        clientIntersectionRect = targetFrameView->absoluteToClientRect(intersectionState->absoluteIntersectionRect, target->renderer()->style().effectiveZoom());
                 }
 
                 std::optional<DOMRectInit> reportedRootBounds;