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

@ -1162,6 +1162,10 @@ impl ScriptThread {
// as well as those for which a rendering update would be unnecessary,
// but this isn't happening here.
// TODO(#31242): the filtering of docs is extended to not exclude the ones that
// has pending initial observation targets
// https://w3c.github.io/IntersectionObserver/#pending-initial-observation
// If we aren't explicitly running rAFs, this update wasn't requested by the compositor,
// and we are running animations, then wait until the compositor tells us it is time to
// update the rendering via a TickAllAnimations message.
@ -1259,8 +1263,11 @@ impl ScriptThread {
// TODO: Perform pending transition operations from
// https://drafts.csswg.org/css-view-transitions/#perform-pending-transition-operations.
// TODO(#31021): Run the update intersection observations steps from
// https://w3c.github.io/IntersectionObserver/#run-the-update-intersection-observations-steps
// > 19. For each doc of docs, run the update intersection observations steps for doc,
// > passing in the relative high resolution time given now and
// > doc's relevant global object as the timestamp. [INTERSECTIONOBSERVER]
// TODO(stevennovaryo): The time attribute should be relative to the time origin of the global object
document.update_intersection_observer_steps(CrossProcessInstant::now(), can_gc);
// TODO: Mark paint timing from https://w3c.github.io/paint-timing.