Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (235942 => 235943)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2018-09-12 16:47:19 UTC (rev 235942)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2018-09-12 17:03:13 UTC (rev 235943)
@@ -1,3 +1,14 @@
+2018-09-12 Ali Juma <[email protected]>
+
+ [IntersectionObserver] Implement rootMargin expansion
+ https://bugs.webkit.org/show_bug.cgi?id=189525
+
+ Reviewed by Simon Fraser.
+
+ Rebasline expectation for test that now passes.
+
+ * web-platform-tests/intersection-observer/root-margin-expected.txt:
+
2018-09-11 Ali Juma <[email protected]>
[IntersectionObserver] Update WPTs to the latest upstream version
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/root-margin-expected.txt (235942 => 235943)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/root-margin-expected.txt 2018-09-12 16:47:19 UTC (rev 235942)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/root-margin-expected.txt 2018-09-12 17:03:13 UTC (rev 235943)
@@ -1,8 +1,8 @@
PASS Root margin tests
-FAIL First rAF. assert_equals: entries[0].rootBounds.left expected -30 but got 0
-FAIL document.scrollingElement.scrollLeft = 100 assert_equals: entries.length expected 2 but got 1
-FAIL document.scrollingElement.scrollTop = document.documentElement.clientHeight + 200 assert_equals: entries.length expected 2 but got 1
-FAIL document.scrollingElement.scrollTop = document.documentElement.clientHeight + 300 assert_equals: entries.length expected 3 but got 1
+PASS First rAF.
+PASS document.scrollingElement.scrollLeft = 100
+PASS document.scrollingElement.scrollTop = document.documentElement.clientHeight + 200
+PASS document.scrollingElement.scrollTop = document.documentElement.clientHeight + 300
Modified: trunk/Source/WebCore/ChangeLog (235942 => 235943)
--- trunk/Source/WebCore/ChangeLog 2018-09-12 16:47:19 UTC (rev 235942)
+++ trunk/Source/WebCore/ChangeLog 2018-09-12 17:03:13 UTC (rev 235943)
@@ -1,3 +1,23 @@
+2018-09-12 Ali Juma <[email protected]>
+
+ [IntersectionObserver] Implement rootMargin expansion
+ https://bugs.webkit.org/show_bug.cgi?id=189525
+
+ Reviewed by Simon Fraser.
+
+ 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):
+
2018-09-12 Fujii Hironori <[email protected]>
[Win][Clang] error: non-constant-_expression_ cannot be narrowed from type 'int' to 'SHORT'
Modified: trunk/Source/WebCore/dom/Document.cpp (235942 => 235943)
--- trunk/Source/WebCore/dom/Document.cpp 2018-09-12 16:47:19 UTC (rev 235942)
+++ trunk/Source/WebCore/dom/Document.cpp 2018-09-12 17:03:13 UTC (rev 235943)
@@ -7485,6 +7485,18 @@
m_intersectionObservers.removeFirst(&observer);
}
+static void expandRootBoundsWithRootMargin(FloatRect& localRootBounds, const LengthBox& rootMargin)
+{
+ FloatBoxExtent rootMarginFloatBox(
+ floatValueForLength(rootMargin.top(), localRootBounds.height()),
+ floatValueForLength(rootMargin.right(), localRootBounds.width()),
+ floatValueForLength(rootMargin.bottom(), localRootBounds.height()),
+ floatValueForLength(rootMargin.left(), localRootBounds.width())
+ );
+
+ localRootBounds.expand(rootMarginFloatBox);
+}
+
static void computeIntersectionRects(FrameView& frameView, IntersectionObserver& observer, Element& target, FloatRect& absTargetRect, FloatRect& absIntersectionRect, FloatRect& absRootBounds)
{
// FIXME: Implement intersection computation for the cross-document case.
@@ -7495,7 +7507,6 @@
if (!targetRenderer)
return;
- // FIXME: Expand localRootBounds using the observer's rootMargin.
FloatRect localRootBounds;
RenderBlock* rootRenderer;
if (observer.root()) {
@@ -7516,6 +7527,8 @@
localRootBounds = frameView.layoutViewportRect();
}
+ expandRootBoundsWithRootMargin(localRootBounds, observer.rootMarginBox());
+
LayoutRect localTargetBounds;
if (is<RenderBox>(*targetRenderer))
localTargetBounds = downcast<RenderBox>(targetRenderer)->borderBoundingBox();
Modified: trunk/Source/WebCore/page/IntersectionObserver.h (235942 => 235943)
--- trunk/Source/WebCore/page/IntersectionObserver.h 2018-09-12 16:47:19 UTC (rev 235942)
+++ trunk/Source/WebCore/page/IntersectionObserver.h 2018-09-12 17:03:13 UTC (rev 235943)
@@ -72,6 +72,7 @@
Element* root() const { return m_root; }
String rootMargin() const;
+ const LengthBox& rootMarginBox() const { return m_rootMargin; }
const Vector<double>& thresholds() const { return m_thresholds; }
const Vector<Element*> observationTargets() const { return m_observationTargets; }
Modified: trunk/Source/WebCore/platform/graphics/FloatRect.h (235942 => 235943)
--- trunk/Source/WebCore/platform/graphics/FloatRect.h 2018-09-12 16:47:19 UTC (rev 235942)
+++ trunk/Source/WebCore/platform/graphics/FloatRect.h 2018-09-12 17:03:13 UTC (rev 235943)
@@ -27,6 +27,7 @@
#pragma once
#include "FloatPoint.h"
+#include "LengthBox.h"
#if USE(CG)
typedef struct CGRect CGRect;
@@ -108,6 +109,11 @@
void move(float dx, float dy) { m_location.move(dx, dy); }
void expand(const FloatSize& size) { m_size += size; }
+ void expand(const FloatBoxExtent& box)
+ {
+ m_location.move(-box.left(), -box.top());
+ m_size.expand(box.left() + box.right(), box.top() + box.bottom());
+ }
void expand(float dw, float dh) { m_size.expand(dw, dh); }
void contract(const FloatSize& size) { m_size -= size; }
void contract(float dw, float dh) { m_size.expand(-dw, -dh); }