Changeset 235943 in webkit


Ignore:
Timestamp:
Sep 12, 2018 10:03:13 AM (6 years ago)
Author:
ajuma@chromium.org
Message:

[IntersectionObserver] Implement rootMargin expansion
https://bugs.webkit.org/show_bug.cgi?id=189525

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

Rebasline expectation for test that now passes.

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

Source/WebCore:

Expand the root intersection rectangle by the observer's rootMargin when computing
intersections.

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

  • dom/Document.cpp:

(WebCore::expandRootBoundsWithRootMargin):
(WebCore::computeIntersectionRects):

  • page/IntersectionObserver.h:

(WebCore::IntersectionObserver::rootMarginBox const):

  • platform/graphics/FloatRect.h:

(WebCore::FloatRect::expand):

Location:
trunk
Files:
6 edited

Legend:

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

    r235923 r235943  
     12018-09-12  Ali Juma  <ajuma@chromium.org>
     2
     3        [IntersectionObserver] Implement rootMargin expansion
     4        https://bugs.webkit.org/show_bug.cgi?id=189525
     5
     6        Reviewed by Simon Fraser.
     7
     8        Rebasline expectation for test that now passes.
     9
     10        * web-platform-tests/intersection-observer/root-margin-expected.txt:
     11
    1122018-09-11  Ali Juma  <ajuma@chromium.org>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/root-margin-expected.txt

    r235459 r235943  
    22
    33PASS Root margin tests
    4 FAIL First rAF. assert_equals: entries[0].rootBounds.left expected -30 but got 0
    5 FAIL document.scrollingElement.scrollLeft = 100 assert_equals: entries.length expected 2 but got 1
    6 FAIL document.scrollingElement.scrollTop = document.documentElement.clientHeight + 200 assert_equals: entries.length expected 2 but got 1
    7 FAIL document.scrollingElement.scrollTop = document.documentElement.clientHeight + 300 assert_equals: entries.length expected 3 but got 1
     4PASS First rAF.
     5PASS document.scrollingElement.scrollLeft = 100
     6PASS document.scrollingElement.scrollTop = document.documentElement.clientHeight + 200
     7PASS document.scrollingElement.scrollTop = document.documentElement.clientHeight + 300
    88
  • trunk/Source/WebCore/ChangeLog

    r235942 r235943  
     12018-09-12  Ali Juma  <ajuma@chromium.org>
     2
     3        [IntersectionObserver] Implement rootMargin expansion
     4        https://bugs.webkit.org/show_bug.cgi?id=189525
     5
     6        Reviewed by Simon Fraser.
     7
     8        Expand the root intersection rectangle by the observer's rootMargin when computing
     9        intersections.
     10
     11        Test: imported/w3c/web-platform-tests/intersection-observer/root-margin.html
     12
     13        * dom/Document.cpp:
     14        (WebCore::expandRootBoundsWithRootMargin):
     15        (WebCore::computeIntersectionRects):
     16        * page/IntersectionObserver.h:
     17        (WebCore::IntersectionObserver::rootMarginBox const):
     18        * platform/graphics/FloatRect.h:
     19        (WebCore::FloatRect::expand):
     20
    1212018-09-12  Fujii Hironori  <Hironori.Fujii@sony.com>
    222
  • trunk/Source/WebCore/dom/Document.cpp

    r235863 r235943  
    74867486}
    74877487
     7488static void expandRootBoundsWithRootMargin(FloatRect& localRootBounds, const LengthBox& rootMargin)
     7489{
     7490    FloatBoxExtent rootMarginFloatBox(
     7491        floatValueForLength(rootMargin.top(), localRootBounds.height()),
     7492        floatValueForLength(rootMargin.right(), localRootBounds.width()),
     7493        floatValueForLength(rootMargin.bottom(), localRootBounds.height()),
     7494        floatValueForLength(rootMargin.left(), localRootBounds.width())
     7495    );
     7496
     7497    localRootBounds.expand(rootMarginFloatBox);
     7498}
     7499
    74887500static void computeIntersectionRects(FrameView& frameView, IntersectionObserver& observer, Element& target, FloatRect& absTargetRect, FloatRect& absIntersectionRect, FloatRect& absRootBounds)
    74897501{
     
    74967508        return;
    74977509
    7498     // FIXME: Expand localRootBounds using the observer's rootMargin.
    74997510    FloatRect localRootBounds;
    75007511    RenderBlock* rootRenderer;
     
    75167527        localRootBounds = frameView.layoutViewportRect();
    75177528    }
     7529
     7530    expandRootBoundsWithRootMargin(localRootBounds, observer.rootMarginBox());
    75187531
    75197532    LayoutRect localTargetBounds;
  • trunk/Source/WebCore/page/IntersectionObserver.h

    r235736 r235943  
    7373    Element* root() const { return m_root; }
    7474    String rootMargin() const;
     75    const LengthBox& rootMarginBox() const { return m_rootMargin; }
    7576    const Vector<double>& thresholds() const { return m_thresholds; }
    7677    const Vector<Element*> observationTargets() const { return m_observationTargets; }
  • trunk/Source/WebCore/platform/graphics/FloatRect.h

    r235840 r235943  
    2828
    2929#include "FloatPoint.h"
     30#include "LengthBox.h"
    3031
    3132#if USE(CG)
     
    109110
    110111    void expand(const FloatSize& size) { m_size += size; }
     112    void expand(const FloatBoxExtent& box)
     113    {
     114        m_location.move(-box.left(), -box.top());
     115        m_size.expand(box.left() + box.right(), box.top() + box.bottom());
     116    }
    111117    void expand(float dw, float dh) { m_size.expand(dw, dh); }
    112118    void contract(const FloatSize& size) { m_size -= size; }
Note: See TracChangeset for help on using the changeset viewer.