Changeset 246432 in webkit


Ignore:
Timestamp:
Jun 14, 2019 6:05:13 AM (5 years ago)
Author:
ajuma@chromium.org
Message:

IntersectionObserver rootMargin detection fails when root is an element
https://bugs.webkit.org/show_bug.cgi?id=198784

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

Import https://github.com/web-platform-tests/wpt/pull/17323.

  • web-platform-tests/intersection-observer/root-margin-root-element-expected.txt: Added.
  • web-platform-tests/intersection-observer/root-margin-root-element.html: Added.

Source/WebCore:

When computing a target's bounds in root space, we were applying the root's
clip rect (if any), and then intersecting with the root rect expanded by the
root margin. This meant that if a target did not intersect the non-expanded root
rect, we would get an empty intersection even if the target did intersect the
expanded root rect. Fix this by not applying the root's clip rect when computing
a target's bounds in root space. Add a new VisibleRectContextOption::ApplyContainerClip
that determines whether RenderObject::computeVisibleRectInContainer should apply
the container's clip.

Test: imported/w3c/web-platform-tests/intersection-observer/root-margin-root-element.html

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::applyCachedClipAndScrollPosition const):

  • rendering/RenderObject.cpp:

(WebCore::RenderObject::visibleRectContextForRepaint):

  • rendering/RenderObject.h:
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r246406 r246432  
     12019-06-14  Ali Juma  <ajuma@chromium.org>
     2
     3        IntersectionObserver rootMargin detection fails when `root` is an element
     4        https://bugs.webkit.org/show_bug.cgi?id=198784
     5
     6        Reviewed by Simon Fraser.
     7
     8        Import https://github.com/web-platform-tests/wpt/pull/17323.
     9
     10        * web-platform-tests/intersection-observer/root-margin-root-element-expected.txt: Added.
     11        * web-platform-tests/intersection-observer/root-margin-root-element.html: Added.
     12
    1132019-06-13  Youenn Fablet  <youenn@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r246431 r246432  
     12019-06-14  Ali Juma  <ajuma@chromium.org>
     2
     3        IntersectionObserver rootMargin detection fails when `root` is an element
     4        https://bugs.webkit.org/show_bug.cgi?id=198784
     5
     6        Reviewed by Simon Fraser.
     7
     8        When computing a target's bounds in root space, we were applying the root's
     9        clip rect (if any), and then intersecting with the root rect expanded by the
     10        root margin. This meant that if a target did not intersect the non-expanded root
     11        rect, we would get an empty intersection even if the target did intersect the
     12        expanded root rect. Fix this by not applying the root's clip rect when computing
     13        a target's bounds in root space. Add a new VisibleRectContextOption::ApplyContainerClip
     14        that determines whether RenderObject::computeVisibleRectInContainer should apply
     15        the container's clip.
     16
     17        Test: imported/w3c/web-platform-tests/intersection-observer/root-margin-root-element.html
     18
     19        * rendering/RenderBox.cpp:
     20        (WebCore::RenderBox::applyCachedClipAndScrollPosition const):
     21        * rendering/RenderObject.cpp:
     22        (WebCore::RenderObject::visibleRectContextForRepaint):
     23        * rendering/RenderObject.h:
     24
    1252019-06-14  Carlos Garcia Campos  <cgarcia@igalia.com>
    226
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r246389 r246432  
    994994
    995995    // Do not clip scroll layer contents to reduce the number of repaints while scrolling.
    996     if (!context.m_options.contains(VisibleRectContextOption::ApplyCompositedClips) && usesCompositedScrolling()) {
     996    if ((!context.m_options.contains(VisibleRectContextOption::ApplyCompositedClips) && usesCompositedScrolling())
     997        || (!context.m_options.contains(VisibleRectContextOption::ApplyContainerClip) && this == container)) {
    997998        flipForWritingMode(rect);
    998999        return true;
  • trunk/Source/WebCore/rendering/RenderObject.cpp

    r246285 r246432  
    987987RenderObject::VisibleRectContext RenderObject::visibleRectContextForRepaint()
    988988{
    989     VisibleRectContext context;
     989    VisibleRectContext context(false, false, { VisibleRectContextOption::ApplyContainerClip });
    990990    if (shouldApplyCompositedContainerScrollsForRepaint())
    991991        context.m_options.add(VisibleRectContextOption::ApplyCompositedContainerScrolls);
  • trunk/Source/WebCore/rendering/RenderObject.h

    r246285 r246432  
    669669        ApplyCompositedClips = 1 << 1,
    670670        ApplyCompositedContainerScrolls  = 1 << 2,
     671        ApplyContainerClip = 1 << 3,
    671672    };
    672673    struct VisibleRectContext {
Note: See TracChangeset for help on using the changeset viewer.