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

@ -1205,13 +1205,11 @@ impl ScriptThread {
.documents
.borrow()
.iter()
.any(|(_, doc)| doc.has_received_raf_tick());
.any(|(_, doc)| doc.is_fully_active() && doc.has_received_raf_tick());
let any_animations_running = self
.documents
.borrow()
.iter()
.any(|(_, document)| document.animations().running_animation_count() != 0);
let any_animations_running = self.documents.borrow().iter().any(|(_, document)| {
document.is_fully_active() && document.animations().running_animation_count() != 0
});
// TODO: The specification says to filter out non-renderable documents,
// as well as those for which a rendering update would be unnecessary,
@ -1251,6 +1249,10 @@ impl ScriptThread {
.find_document(*pipeline_id)
.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
// `process_pending_compositor_events` handles the focusing steps as well as other events
// from the compositor.
@ -1350,14 +1352,17 @@ impl ScriptThread {
// ticks). In this case, don't schedule an opportunity, just wait for the next
// one.
if self.documents.borrow().iter().any(|(_, document)| {
document.animations().running_animation_count() != 0 ||
document.has_active_request_animation_frame_callbacks()
document.is_fully_active() &&
(document.animations().running_animation_count() != 0 ||
document.has_active_request_animation_frame_callbacks())
}) {
return;
}
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 {
return;
};