Only consider fully active documents when running the 'update the rendering' steps (#35245)

This is specified in https://html.spec.whatwg.org/multipage/#update-the-rendering step 3.2 but we where not filtering out inactive documents.

Signed-off-by: webbeef <me@webbeef.org>
This commit is contained in:
webbeef 2025-02-01 10:10:20 -08:00 committed by GitHub
parent 8999b539df
commit c4f4d5cc04
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 9 deletions

View file

@ -2264,6 +2264,10 @@ impl Document {
&mut *self.animation_frame_list.borrow_mut(), &mut *self.animation_frame_list.borrow_mut(),
); );
self.pending_animation_ticks
.borrow_mut()
.remove(AnimationTickType::REQUEST_ANIMATION_FRAME);
self.running_animation_callbacks.set(true); self.running_animation_callbacks.set(true);
let was_faking_animation_frames = self.is_faking_animation_frames(); let was_faking_animation_frames = self.is_faking_animation_frames();
let timing = self.global().performance().Now(); let timing = self.global().performance().Now();

View file

@ -1205,13 +1205,11 @@ impl ScriptThread {
.documents .documents
.borrow() .borrow()
.iter() .iter()
.any(|(_, doc)| doc.has_received_raf_tick()); .any(|(_, doc)| doc.is_fully_active() && doc.has_received_raf_tick());
let any_animations_running = self let any_animations_running = self.documents.borrow().iter().any(|(_, document)| {
.documents document.is_fully_active() && document.animations().running_animation_count() != 0
.borrow() });
.iter()
.any(|(_, document)| document.animations().running_animation_count() != 0);
// TODO: The specification says to filter out non-renderable documents, // TODO: The specification says to filter out non-renderable documents,
// as well as those for which a rendering update would be unnecessary, // as well as those for which a rendering update would be unnecessary,
@ -1251,6 +1249,10 @@ impl ScriptThread {
.find_document(*pipeline_id) .find_document(*pipeline_id)
.expect("Got pipeline for Document not managed by this ScriptThread."); .expect("Got pipeline for Document not managed by this ScriptThread.");
if !document.is_fully_active() {
continue;
}
// TODO(#31581): The steps in the "Revealing the document" section need to be implemente // TODO(#31581): The steps in the "Revealing the document" section need to be implemente
// `process_pending_compositor_events` handles the focusing steps as well as other events // `process_pending_compositor_events` handles the focusing steps as well as other events
// from the compositor. // from the compositor.
@ -1350,14 +1352,17 @@ impl ScriptThread {
// ticks). In this case, don't schedule an opportunity, just wait for the next // ticks). In this case, don't schedule an opportunity, just wait for the next
// one. // one.
if self.documents.borrow().iter().any(|(_, document)| { if self.documents.borrow().iter().any(|(_, document)| {
document.animations().running_animation_count() != 0 || document.is_fully_active() &&
document.has_active_request_animation_frame_callbacks() (document.animations().running_animation_count() != 0 ||
document.has_active_request_animation_frame_callbacks())
}) { }) {
return; return;
} }
let Some((_, document)) = self.documents.borrow().iter().find(|(_, document)| { let Some((_, document)) = self.documents.borrow().iter().find(|(_, document)| {
!document.window().layout_blocked() && document.needs_reflow().is_some() document.is_fully_active() &&
!document.window().layout_blocked() &&
document.needs_reflow().is_some()
}) else { }) else {
return; return;
}; };