script: Update the rendering when receiving IPC messages instead of just reflowing (#34486)

This changes fixes two issues:

1. A reflow of all `Document`s currently done unconditionally after
   receving IPC messages in the `ScriptThread`. Reflowing without first
   updating the animation timeline can lead to transitions finshing as
   soon as they start (because it looks like time advancement is
   measaured between calls to `update-the-rendering`).
2. Fix an issue where not all `Pipeline`s were updated during *update
   the rendering*. The previous code only took into account top level
   frames and their children. It's not guaranteed that a particular
   `ScriptThread` is managing any top level frames, depending on the
   origens of those frames. We should update the rendering of those
   non-top-level iframes regardless.

   The new code attempts to order the frames according to the
   specification as much as possible without knowing the entire frame
   tree, without skipping any documents managed by the `ScriptThread` in
   question.

In addition, `Documents` is pulled out the `script_thread.rs` and
renamed to `DocumentCollection`.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2024-12-09 12:33:58 +01:00 committed by GitHub
parent 38927bbeb6
commit a0743f60b3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 321 additions and 200 deletions

View file

@ -2107,6 +2107,7 @@ impl Document {
/// <https://html.spec.whatwg.org/multipage/#run-the-animation-frame-callbacks>
pub(crate) fn run_the_animation_frame_callbacks(&self, can_gc: CanGc) {
let _realm = enter_realm(self);
rooted_vec!(let mut animation_frame_list);
mem::swap(
&mut *animation_frame_list,