Changeset 249845 in webkit


Ignore:
Timestamp:
Sep 13, 2019 11:46:56 AM (5 years ago)
Author:
ajuma@chromium.org
Message:

IntersectionObserverEntry#intersectionRatio can be larger than 1
https://bugs.webkit.org/show_bug.cgi?id=200776

Reviewed by Simon Fraser.

Source/WebCore:

When computing the intersection between a target and an intersection observer's
root, RenderBox::computeVisibleRectInContainer is used to map the target rect
up the containing block chain, clipping along the way. When a RenderBox has
a transform, this method expands the given rect to the enclosing rect in device
pixels. This is fine for the use case of computing an invalidation rect, but for
the intersection observer use case it means that it is possible for the computed
intersection rect to be slightly larger than the original target rect, resulting
in an intersection ratio greater than 1.

Fix this by performing a final intersection between the intersection rect as
computed above and the target rect.

Test: intersection-observer/intersection-clipped-to-target.html

  • dom/Document.cpp:

(WebCore::computeIntersectionState):

LayoutTests:

  • intersection-observer/intersection-clipped-to-target-expected.txt: Added.
  • intersection-observer/intersection-clipped-to-target.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r249844 r249845  
     12019-09-13  Ali Juma  <ajuma@chromium.org>
     2
     3        IntersectionObserverEntry#intersectionRatio can be larger than 1
     4        https://bugs.webkit.org/show_bug.cgi?id=200776
     5
     6        Reviewed by Simon Fraser.
     7
     8        * intersection-observer/intersection-clipped-to-target-expected.txt: Added.
     9        * intersection-observer/intersection-clipped-to-target.html: Added.
     10
    1112019-09-13  Russell Epstein  <repstein@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r249843 r249845  
     12019-09-13  Ali Juma  <ajuma@chromium.org>
     2
     3        IntersectionObserverEntry#intersectionRatio can be larger than 1
     4        https://bugs.webkit.org/show_bug.cgi?id=200776
     5
     6        Reviewed by Simon Fraser.
     7
     8        When computing the intersection between a target and an intersection observer's
     9        root, RenderBox::computeVisibleRectInContainer is used to map the target rect
     10        up the containing block chain, clipping along the way. When a RenderBox has
     11        a transform, this method expands the given rect to the enclosing rect in device
     12        pixels. This is fine for the use case of computing an invalidation rect, but for
     13        the intersection observer use case it means that it is possible for the computed
     14        intersection rect to be slightly larger than the original target rect, resulting
     15        in an intersection ratio greater than 1.
     16
     17        Fix this by performing a final intersection between the intersection rect as
     18        computed above and the target rect.
     19
     20        Test: intersection-observer/intersection-clipped-to-target.html
     21
     22        * dom/Document.cpp:
     23        (WebCore::computeIntersectionState):
     24
    1252019-09-13  Nikolas Zimmermann  <zimmermann@kde.org>
    226
  • trunk/Source/WebCore/dom/Document.cpp

    r249779 r249845  
    74207420    IntersectionObservationState intersectionState;
    74217421    intersectionState.isIntersecting = rootLocalTargetRect && rootLocalIntersectionRect.edgeInclusiveIntersect(*rootLocalTargetRect);
     7422    intersectionState.absoluteTargetRect = targetRenderer->localToAbsoluteQuad(FloatRect(localTargetBounds)).boundingBox();
     7423    intersectionState.absoluteRootBounds = rootRenderer->localToAbsoluteQuad(localRootBounds).boundingBox();
    74227424
    74237425    if (intersectionState.isIntersecting) {
     
    74297431            intersectionState.absoluteIntersectionRect = targetRenderer->view().frameView().rootViewToContents(rootViewIntersectionRect);
    74307432        }
    7431     }
    7432 
    7433     intersectionState.absoluteTargetRect = targetRenderer->localToAbsoluteQuad(FloatRect(localTargetBounds)).boundingBox();
    7434     intersectionState.absoluteRootBounds = rootRenderer->localToAbsoluteQuad(localRootBounds).boundingBox();
     7433        intersectionState.isIntersecting = intersectionState.absoluteIntersectionRect.edgeInclusiveIntersect(intersectionState.absoluteTargetRect);
     7434    }
     7435
    74357436    return intersectionState;
    74367437}
Note: See TracChangeset for help on using the changeset viewer.