dom: Implement minimal IntersectionObserver workflow (#35551)

* Add very rough implemnentation of observation steps

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Fix entry reflection and propagate can_gc

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Fix BorrowError and add fragment find descendant

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Implement is descendant in containing block path correctly

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Fix unrooted error and tidy issues

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Fix comments

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Remove is descendant of other node query

I suppose these changes is better separated to other PRs.

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Fix intersection and refactor registration

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Use AppUnit more and propagate GlobalScope better

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Update WPT expectations

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Revert delay changes

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Align compute intersection algo to other browser actual behavior

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Align processing documents and note several issues

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Update WPT

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Minor lint

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Fix top level browsing context

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Make Registration rootable

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Avoid reflow inside observation step algo

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Using borrow for iterating registration

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Fix document disconnect

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Update WPT

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Address comments and minor quality suggestions

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Root the observer before nofifying any of it

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Tidy docs

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Account not found element and refactor observation step

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Fix documentations

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Ignore position of document viewport

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Refactor root intersection rectangle

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Add can GC note to the callback

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Fix top-level browsing context term

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

* Fix minor comments

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>

---------

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>
This commit is contained in:
Steven Novaryo 2025-03-18 19:09:44 +08:00 committed by GitHub
parent 2113e54819
commit 67a5f285ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
48 changed files with 850 additions and 175 deletions

View file

@ -1,4 +1,4 @@
[overflow-clip-margin-intersection-observer.html]
expected: TIMEOUT
[ParentWithOverflowClipMargin]
expected: NOTRUN
expected: TIMEOUT

View file

@ -1,3 +0,0 @@
[callback-cross-realm-report-exception.html]
[IntersectionObserver reports the exception from its callback in the callback's global object]
expected: FAIL

View file

@ -1,3 +0,0 @@
[client-rect.html]
[First rAF should generate notification.]
expected: FAIL

View file

@ -1,12 +1,9 @@
[containing-block.html]
[Not in containing block and not intersecting.]
expected: FAIL
[In containing block and intersecting.]
expected: FAIL
[In containing block and not intersecting.]
expected: FAIL
[Not in containing block and intersecting.]
expected: FAIL
[Not in containing block and not intersecting.]
expected: FAIL

View file

@ -1,3 +0,0 @@
[cross-document-root.html]
[First rAF.]
expected: FAIL

View file

@ -1,6 +1,3 @@
[disconnect.html]
[First rAF.]
expected: FAIL
[observer.disconnect()]
expected: FAIL

View file

@ -1,3 +0,0 @@
[display-none.html]
[display-none]
expected: FAIL

View file

@ -1,4 +0,0 @@
[empty-root-margin.html]
expected: TIMEOUT
[An empty rootMargin string is interpreted as a margin of size zero]
expected: TIMEOUT

View file

@ -1,4 +0,0 @@
[explicit-root-different-document.html]
expected: TIMEOUT
[IntersectionObserver reports a (non-intersecting) entry if different-document from the doc]
expected: NOTRUN

View file

@ -1,6 +0,0 @@
[fixed-position-child-scroll.html]
[First rAF.]
expected: FAIL
[scrollTo(0, 1000)]
expected: FAIL

View file

@ -1,6 +0,0 @@
[fixed-position-iframe-scroll.html]
[First rAF.]
expected: FAIL
[scrollTo(0, 1000)]
expected: FAIL

View file

@ -1,6 +0,0 @@
[fixed-position-scroll.html]
[First rAF.]
expected: FAIL
[scrollTo(0, 1000)]
expected: FAIL

View file

@ -1,3 +0,0 @@
[grow-height-and-scrolled.html]
[IntersectionObserver should only report intersection change after the target grows height and is scrolled.]
expected: FAIL

View file

@ -1,3 +0,0 @@
[inline-with-block-child-client-rect.html]
[First rAF]
expected: FAIL

View file

@ -1,4 +1,3 @@
[intersection-ratio-ib-split.html]
expected: TIMEOUT
[IntersectionObserver on an IB split gets the right intersection ratio]
expected: TIMEOUT
expected: FAIL

View file

@ -1,4 +1,3 @@
[intersection-ratio-with-fractional-bounds-2.html]
expected: TIMEOUT
[IntersectionObserver ratio with fractional bounds]
expected: TIMEOUT
expected: FAIL

View file

@ -1,4 +0,0 @@
[intersection-ratio-with-fractional-bounds-in-iframe.html]
expected: TIMEOUT
[intersectionRatio in iframe should be 1 for totally visible target with fractional bounds]
expected: NOTRUN

View file

@ -1,4 +0,0 @@
[intersection-ratio-with-fractional-bounds.html]
expected: TIMEOUT
[IntersectionObserver ratio with fractional bounds]
expected: TIMEOUT

View file

@ -1,3 +1,6 @@
[isIntersecting-change-events.html]
[Rects in initial notifications should report initial positions.]
[Set scrollTop=100 and check for one new notification.]
expected: FAIL
[Add 4th target.]
expected: FAIL

View file

@ -1,7 +1,4 @@
[isIntersecting-threshold.html]
[At initial scroll position]
expected: FAIL
[Scrolled to half way through target element]
expected: FAIL

View file

@ -1,4 +0,0 @@
[not-in-containing-block-chain.html]
expected: TIMEOUT
[IntersectionObserver reports a (non-intersecting) entry even if not in the containing block chain]
expected: NOTRUN

View file

@ -1,4 +0,0 @@
[observer-callback-arguments.html]
expected: TIMEOUT
[Callback is invoked with |this| value of IntersectionObserver and two arguments]
expected: TIMEOUT

View file

@ -1,4 +0,0 @@
[padding-clip.html]
expected: TIMEOUT
[Scrollport is used rather than content rect to compute intersection ratio]
expected: TIMEOUT

View file

@ -8,8 +8,5 @@
[root.removeChild(target).]
expected: FAIL
[root.insertBefore(target, trailingSpace).]
expected: FAIL
[root.scrollTop = 150 after reinserting target.]
expected: FAIL

View file

@ -1,4 +0,0 @@
[root-margin-rounding.html]
expected: TIMEOUT
[IntersectionObserver root margin cannot end up with negative rect (and thus non-intersecting) due to rounding]
expected: NOTRUN

View file

@ -1,3 +0,0 @@
[rtl-clipped-root.html]
[First rAF]
expected: FAIL

View file

@ -1,3 +0,0 @@
[scroll-margin-non-scrolling-root.html]
[Test scroll margin intersection]
expected: FAIL

View file

@ -1,3 +0,0 @@
[target-in-detached-document.html]
[First rAF.]
expected: FAIL

View file

@ -1,3 +0,0 @@
[target-in-different-window.html]
[IntersectionObserver with target in a different window.]
expected: FAIL

View file

@ -1,4 +1,3 @@
[target-is-root.html]
expected: TIMEOUT
[IntersectionObserver when root == target doesn't compute an intersection]
expected: TIMEOUT
expected: FAIL

View file

@ -1,3 +0,0 @@
[animated-occlusion.html]
[First rAF.]
expected: FAIL

View file

@ -1,7 +1,4 @@
[box-shadow.html]
[First rAF.]
expected: FAIL
[occluder.style.boxShadow = "none"]
expected: FAIL

View file

@ -1,4 +0,0 @@
[position-absolute-overflow-visible-and-not-visible.html]
expected: TIMEOUT
[ParentWithOverflowVisibleAndNotVisible]
expected: NOTRUN

View file

@ -1,7 +1,4 @@
[text-shadow.html]
[First rAF.]
expected: FAIL
[occluder.style.textShadow = "none"]
expected: FAIL

View file

@ -1,3 +0,0 @@
[zero-area-element-hidden.html]
[First rAF.]
expected: FAIL

View file

@ -1,3 +0,0 @@
[zero-area-element-visible.html]
[First rAF should generate a notification.]
expected: FAIL

View file

@ -1,4 +0,0 @@
[ordering.html]
expected: TIMEOUT
[ResizeObserver and IntersectionObserver ordering]
expected: TIMEOUT