WebKit Bugzilla
Attachment 348336 Details for
Bug 189055
: [IntersectionObserver] Implement intersection logic for the same-document implicit root case
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-189055-20180828164451.patch (text/plain), 17.18 KB, created by
Ali Juma
on 2018-08-28 13:44:52 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Ali Juma
Created:
2018-08-28 13:44:52 PDT
Size:
17.18 KB
patch
obsolete
>Subversion Revision: 235428 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 7b07e5a104fb2ef78c8d83385f7bd2c70da98472..11e223c355edcba91231684ce0a60a02dbe0cfaa 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,19 @@ >+2018-08-28 Ali Juma <ajuma@chromium.org> >+ >+ [IntersectionObserver] Implement intersection logic for the same-document implicit root case >+ https://bugs.webkit.org/show_bug.cgi?id=189055 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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 Ali Juma <ajuma@chromium.org> > > [IntersectionObserver] Fix build after r235424 >diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp >index dbe14c73142087963dbf7fe82c63be4097c7fd11..e723591a9133ca518ba0a4e512ed17fc4d74ce8e 100644 >--- a/Source/WebCore/dom/Document.cpp >+++ b/Source/WebCore/dom/Document.cpp >@@ -7444,33 +7444,36 @@ RefPtr<IntersectionObserver> Document::removeIntersectionObserver(IntersectionOb > 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)) >@@ -7519,7 +7522,7 @@ void Document::updateIntersectionObservations() > 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 @@ void Document::updateIntersectionObservations() > > 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. >diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog >index 0365e46f7d61dcddd5b023a99f20339964943aec..83a9028f9744878340937e0721029ce987c6eafb 100644 >--- a/LayoutTests/imported/w3c/ChangeLog >+++ b/LayoutTests/imported/w3c/ChangeLog >@@ -1,3 +1,24 @@ >+2018-08-28 Ali Juma <ajuma@chromium.org> >+ >+ [IntersectionObserver] Implement intersection logic for the same-document implicit root case >+ https://bugs.webkit.org/show_bug.cgi?id=189055 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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 Aditya Keerthi <akeerthi@apple.com> > > [iOS] Support inputmode=none >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/display-none-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/display-none-expected.txt >index 967db203b6440755e4092a55b39b9a15fb87233f..175d78afbd79cef175e10231ae43ac5879f07e05 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/display-none-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/display-none-expected.txt >@@ -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. > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/inline-client-rect-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/inline-client-rect-expected.txt >index eda47367bbaef463fe3833ec57bf090f2d4bb416..8fe8a937229878d7ff6a3afd53b357797c0dc07b 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/inline-client-rect-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/inline-client-rect-expected.txt >@@ -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 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/multiple-targets-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/multiple-targets-expected.txt >index acebac2fcfaa0a7914a240196983002e36aea429..b838960d2c5fd5c83e06ca5581e867a4ae2d4ea6 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/multiple-targets-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/multiple-targets-expected.txt >@@ -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 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/multiple-thresholds-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/multiple-thresholds-expected.txt >index 305679f80c737e5c7a4a46361bb13c61a92626d2..9119f28ca9ad27c5dbdf3f0ae7bb1e42db96f0a4 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/multiple-thresholds-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/multiple-thresholds-expected.txt >@@ -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 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-without-js-reference-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-without-js-reference-expected.txt >index 2e7607f314b8750926650b3043bc218a479bbbe4..c576d041370174430499f068979e5d409137bc08 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-without-js-reference-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/observer-without-js-reference-expected.txt >@@ -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 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/root-margin-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/root-margin-expected.txt >index f396e95425428428bef7a7aa0984d220bf303767..3c36690d0b3d12166156a24876b6c496cdf9e83d 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/root-margin-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/root-margin-expected.txt >@@ -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 >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-no-root-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-no-root-expected.txt >index 7bdff406a781f6db4064c53288967c137470b0c5..d463af72669325653ec5edb153653c485a93b656 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-no-root-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-no-root-expected.txt >@@ -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 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-zero-size-target-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-zero-size-target-expected.txt >index a6f547028c95bcc60a830d635befedf577d89632..be031a0c299cf36819575e4c6b100e06f2c8753c 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-zero-size-target-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/same-document-zero-size-target-expected.txt >@@ -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 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/shadow-content-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/shadow-content-expected.txt >index c7395777f9af1251f1bd3dd908282d7dff7f8ae9..8da2c487e51903e2cb7fa287878d98bcf2725811 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/shadow-content-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/shadow-content-expected.txt >@@ -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. > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/text-target-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/text-target-expected.txt >index 6d7b211fa2eb2e8dbe247fc85e3cb0f8df5dc961..e63a4873994235949b834ffd3d703fddbf107f3a 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/text-target-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/text-target-expected.txt >@@ -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 > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/zero-area-element-hidden-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/zero-area-element-hidden-expected.txt >index 28aa4902b1099488e9bca089552c3bcb7976b22e..29fd5f25a5b18570d857f14bf1b674a92e259702 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/zero-area-element-hidden-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/intersection-observer/zero-area-element-hidden-expected.txt >@@ -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. >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 189055
: 348336