Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (235458 => 235459)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2018-08-29 05:31:57 UTC (rev 235458)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2018-08-29 12:36:15 UTC (rev 235459)
@@ -1,3 +1,24 @@
+2018-08-29 Ali Juma <aj...@chromium.org>
+
+ [IntersectionObserver] Implement intersection logic for the same-document implicit root case
+ https://bugs.webkit.org/show_bug.cgi?id=189055
+
+ Reviewed by Simon Fraser.
+
+ Rebaseline tests.
+
+ * web-platform-tests/intersection-observer/display-none-expected.txt:
+ * web-platform-tests/intersection-observer/inline-client-rect-expected.txt:
+ * web-platform-tests/intersection-observer/multiple-targets-expected.txt:
+ * web-platform-tests/intersection-observer/multiple-thresholds-expected.txt:
+ * web-platform-tests/intersection-observer/observer-without-js-reference-expected.txt:
+ * web-platform-tests/intersection-observer/root-margin-expected.txt:
+ * web-platform-tests/intersection-observer/same-document-no-root-expected.txt:
+ * web-platform-tests/intersection-observer/same-document-zero-size-target-expected.txt:
+ * web-platform-tests/intersection-observer/shadow-content-expected.txt:
+ * web-platform-tests/intersection-observer/text-target-expected.txt:
+ * web-platform-tests/intersection-observer/zero-area-element-hidden-expected.txt:
+
2018-08-28 Ryosuke Niwa <rn...@webkit.org>
Changes to slot children should trigger slotchange
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/display-none-expected.txt (235458 => 235459)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/display-none-expected.txt 2018-08-29 05:31:57 UTC (rev 235458)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/display-none-expected.txt 2018-08-29 12:36:15 UTC (rev 235459)
@@ -1,6 +1,6 @@
PASS IntersectionObserver should send a not-intersecting notification for a target that gets display:none.
-FAIL Intersecting notification after first rAF. assert_equals: entries[0].boundingClientRect.left expected 8 but got 0
-FAIL Not-intersecting notification after setting display:none on target. assert_equals: entries.length expected 2 but got 1
-FAIL Intersecting notification after removing display:none on target. assert_equals: entries.length expected 3 but got 1
+PASS Intersecting notification after first rAF.
+PASS Not-intersecting notification after setting display:none on target.
+PASS Intersecting notification after removing display:none on target.
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/inline-client-rect-expected.txt (235458 => 235459)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/inline-client-rect-expected.txt 2018-08-29 05:31:57 UTC (rev 235458)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/inline-client-rect-expected.txt 2018-08-29 12:36:15 UTC (rev 235459)
@@ -1,6 +1,6 @@
1 2 3 4 5
PASS Inline target
-FAIL First rAF assert_equals: entries[0].boundingClientRect.left expected 320 but got 0
-FAIL scroller.scrollLeft = 90 assert_equals: entries.length expected 2 but got 1
+PASS First rAF
+PASS scroller.scrollLeft = 90
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/multiple-targets-expected.txt (235458 => 235459)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/multiple-targets-expected.txt 2018-08-29 05:31:57 UTC (rev 235458)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/multiple-targets-expected.txt 2018-08-29 12:36:15 UTC (rev 235459)
@@ -1,7 +1,7 @@
PASS One observer with multiple targets.
PASS First rAF.
-FAIL document.scrollingElement.scrollTop = 150 assert_equals: Four notifications. expected 4 but got 3
-FAIL document.scrollingElement.scrollTop = 10000 assert_equals: Six notifications. expected 6 but got 3
-FAIL document.scrollingElement.scrollTop = 0 assert_equals: Nine notifications. expected 9 but got 3
+PASS document.scrollingElement.scrollTop = 150
+PASS document.scrollingElement.scrollTop = 10000
+PASS document.scrollingElement.scrollTop = 0
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/multiple-thresholds-expected.txt (235458 => 235459)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/multiple-thresholds-expected.txt 2018-08-29 05:31:57 UTC (rev 235458)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/multiple-thresholds-expected.txt 2018-08-29 12:36:15 UTC (rev 235459)
@@ -1,11 +1,12 @@
PASS Observer with multiple thresholds.
-FAIL First rAF. assert_equals: entries[0].boundingClientRect.left expected 8 but got 0
-FAIL document.scrollingElement.scrollTop = 120 assert_equals: entries.length expected 2 but got 1
-FAIL document.scrollingElement.scrollTop = 160 assert_equals: entries.length expected 3 but got 1
-FAIL document.scrollingElement.scrollTop = 200 assert_equals: entries.length expected 4 but got 1
-FAIL document.scrollingElement.scrollTop = 240 assert_equals: entries.length expected 5 but got 1
-FAIL document.scrollingElement.scrollTop = window.innerHeight + 140 assert_equals: entries.length expected 6 but got 1
-FAIL document.scrollingElement.scrollTop = window.innerHeight + 160 assert_equals: entries.length expected 7 but got 1
-FAIL document.scrollingElement.scrollTop = window.innerHeight + 200 assert_equals: entries.length expected 8 but got 1
+PASS First rAF.
+PASS document.scrollingElement.scrollTop = 120
+PASS document.scrollingElement.scrollTop = 160
+PASS document.scrollingElement.scrollTop = 200
+PASS document.scrollingElement.scrollTop = 240
+PASS document.scrollingElement.scrollTop = window.innerHeight + 140
+PASS document.scrollingElement.scrollTop = window.innerHeight + 160
+PASS document.scrollingElement.scrollTop = window.innerHeight + 200
+PASS document.scrollingElement.scrollTop = window.innerHeight + 220
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-without-js-reference-expected.txt (235458 => 235459)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-without-js-reference-expected.txt 2018-08-29 05:31:57 UTC (rev 235458)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-without-js-reference-expected.txt 2018-08-29 12:36:15 UTC (rev 235459)
@@ -1,5 +1,5 @@
PASS IntersectionObserver that is unreachable in js should still generate notifications.
PASS First rAF
-FAIL document.scrollingElement.scrollTop = 300 assert_equals: Two notifications. expected 2 but got 1
+PASS document.scrollingElement.scrollTop = 300
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/root-margin-expected.txt (235458 => 235459)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/root-margin-expected.txt 2018-08-29 05:31:57 UTC (rev 235458)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/root-margin-expected.txt 2018-08-29 12:36:15 UTC (rev 235459)
@@ -1,7 +1,7 @@
PASS Root margin tests
-FAIL First rAF. assert_equals: entries[0].boundingClientRect.left expected 972 but got 0
+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
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-no-root-expected.txt (235458 => 235459)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-no-root-expected.txt 2018-08-29 05:31:57 UTC (rev 235458)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-no-root-expected.txt 2018-08-29 12:36:15 UTC (rev 235459)
@@ -1,6 +1,6 @@
PASS IntersectionObserver in a single document using the implicit root.
-FAIL First rAF. assert_equals: entries[0].boundingClientRect.left expected 8 but got 0
-FAIL document.scrollingElement.scrollTop = 300 assert_equals: entries.length expected 2 but got 1
-FAIL document.scrollingElement.scrollTop = 100 assert_equals: entries.length expected 3 but got 1
+PASS First rAF.
+PASS document.scrollingElement.scrollTop = 300
+PASS document.scrollingElement.scrollTop = 100
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-zero-size-target-expected.txt (235458 => 235459)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-zero-size-target-expected.txt 2018-08-29 05:31:57 UTC (rev 235458)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-zero-size-target-expected.txt 2018-08-29 12:36:15 UTC (rev 235459)
@@ -1,6 +1,6 @@
PASS Observing a zero-area target.
-FAIL First rAF assert_equals: entries[0].boundingClientRect.left expected 8 but got 0
+PASS First rAF
FAIL document.scrollingElement.scrollTop = 300 assert_equals: entries.length expected 2 but got 1
FAIL document.scrollingElement.scrollTop = 100 assert_equals: entries.length expected 3 but got 1
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/shadow-content-expected.txt (235458 => 235459)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/shadow-content-expected.txt 2018-08-29 05:31:57 UTC (rev 235458)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/shadow-content-expected.txt 2018-08-29 12:36:15 UTC (rev 235459)
@@ -1,4 +1,4 @@
PASS Observing a target inside shadow DOM.
-FAIL First rAF after creating shadow DOM. assert_equals: entries[0].boundingClientRect.left expected 8 but got 0
+PASS First rAF after creating shadow DOM.
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/text-target-expected.txt (235458 => 235459)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/text-target-expected.txt 2018-08-29 05:31:57 UTC (rev 235458)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/text-target-expected.txt 2018-08-29 12:36:15 UTC (rev 235459)
@@ -1,7 +1,7 @@
PASS IntersectionObserver observing a br element.
-FAIL First rAF. assert_equals: entries[0].boundingClientRect.left expected 8 but got 0
+PASS First rAF.
FAIL document.scrollingElement.scrollTop = 300 assert_equals: entries.length expected 2 but got 1
FAIL document.scrollingElement.scrollTop = 100 assert_equals: entries.length expected 3 but got 1
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/zero-area-element-hidden-expected.txt (235458 => 235459)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/zero-area-element-hidden-expected.txt 2018-08-29 05:31:57 UTC (rev 235458)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/zero-area-element-hidden-expected.txt 2018-08-29 12:36:15 UTC (rev 235459)
@@ -1,4 +1,4 @@
PASS A zero-area hidden target should not be intersecting.
-FAIL First rAF. assert_equals: entries[0].boundingClientRect.left expected 8 but got 0
+PASS First rAF.
Modified: trunk/Source/WebCore/ChangeLog (235458 => 235459)
--- trunk/Source/WebCore/ChangeLog 2018-08-29 05:31:57 UTC (rev 235458)
+++ trunk/Source/WebCore/ChangeLog 2018-08-29 12:36:15 UTC (rev 235459)
@@ -1,3 +1,19 @@
+2018-08-29 Ali Juma <aj...@chromium.org>
+
+ [IntersectionObserver] Implement intersection logic for the same-document implicit root case
+ https://bugs.webkit.org/show_bug.cgi?id=189055
+
+ Reviewed by Simon Fraser.
+
+ Extend the intersection logic to handle computing the intersection of the target and the
+ viewport, for the case where the target is in the main frame.
+
+ Tested by existing tests in imported/w3c/web-platform-tests/intersection-observer.
+
+ * dom/Document.cpp:
+ (WebCore::computeIntersectionRects):
+ (WebCore::Document::updateIntersectionObservations):
+
2018-08-28 Ryosuke Niwa <rn...@webkit.org>
Changes to slot children should trigger slotchange
Modified: trunk/Source/WebCore/dom/Document.cpp (235458 => 235459)
--- trunk/Source/WebCore/dom/Document.cpp 2018-08-29 05:31:57 UTC (rev 235458)
+++ trunk/Source/WebCore/dom/Document.cpp 2018-08-29 12:36:15 UTC (rev 235459)
@@ -7444,34 +7444,37 @@
return observerRef;
}
-static void computeIntersectionRects(IntersectionObserver& observer, Element& target, FloatRect& absTargetRect, FloatRect& absIntersectionRect, FloatRect& absRootBounds)
+static void computeIntersectionRects(FrameView& frameView, IntersectionObserver& observer, Element& target, FloatRect& absTargetRect, FloatRect& absIntersectionRect, FloatRect& absRootBounds)
{
- // FIXME: Implement intersection computation for the case of an implicit root.
- if (!observer.root())
+ // FIXME: Implement intersection computation for the cross-document case.
+ if (observer.trackingDocument() != &target.document())
return;
- if (observer.root()->document() != target.document())
- return;
-
- if (!observer.root()->renderer() || !is<RenderBlock>(observer.root()->renderer()))
- return;
-
- RenderBlock* rootRenderer = downcast<RenderBlock>(observer.root()->renderer());
-
auto* targetRenderer = target.renderer();
if (!targetRenderer)
return;
- if (!rootRenderer->isContainingBlockAncestorFor(*targetRenderer))
- return;
-
// FIXME: Expand localRootBounds using the observer's rootMargin.
FloatRect localRootBounds;
- if (rootRenderer->hasOverflowClip())
- localRootBounds = rootRenderer->contentBoxRect();
- else
- localRootBounds = { FloatPoint(), rootRenderer->size() };
+ RenderBlock* rootRenderer;
+ if (observer.root()) {
+ if (!observer.root()->renderer() || !is<RenderBlock>(observer.root()->renderer()))
+ return;
+ rootRenderer = downcast<RenderBlock>(observer.root()->renderer());
+ if (!rootRenderer->isContainingBlockAncestorFor(*targetRenderer))
+ return;
+
+ if (rootRenderer->hasOverflowClip())
+ localRootBounds = rootRenderer->contentBoxRect();
+ else
+ localRootBounds = { FloatPoint(), rootRenderer->size() };
+ } else {
+ ASSERT(frameView.frame().isMainFrame());
+ rootRenderer = frameView.renderView();
+ localRootBounds = frameView.layoutViewportRect();
+ }
+
LayoutRect localTargetBounds;
if (is<RenderBox>(*targetRenderer))
localTargetBounds = downcast<RenderBox>(targetRenderer)->borderBoundingBox();
@@ -7519,7 +7522,7 @@
FloatRect absTargetRect;
FloatRect absIntersectionRect;
FloatRect absRootBounds;
- computeIntersectionRects(*observer, *target, absTargetRect, absIntersectionRect, absRootBounds);
+ computeIntersectionRects(*frameView, *observer, *target, absTargetRect, absIntersectionRect, absRootBounds);
// FIXME: Handle zero-area intersections (e.g., intersections involving zero-area targets).
bool isIntersecting = absIntersectionRect.area();
@@ -7533,7 +7536,7 @@
if (!registration.previousThresholdIndex || thresholdIndex != registration.previousThresholdIndex) {
FloatRect targetBoundingClientRect = frameView->absoluteToClientRect(absTargetRect);
- FloatRect clientIntersectionRect = frameView->absoluteToClientRect(absIntersectionRect);
+ FloatRect clientIntersectionRect = isIntersecting ? frameView->absoluteToClientRect(absIntersectionRect) : FloatRect();
// FIXME: Once cross-document observation is implemented, only report root bounds if the target document and
// the root document are similar-origin.