From ce0fb3b747b3ded3dcd5419de0a0601ba8cea7b4 Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Sun, 3 Aug 2025 18:45:38 +0200 Subject: [PATCH] More cleanup and documentation --- components/script/script_thread.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 4e3456c11c8..c322fbaf5f9 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -1374,6 +1374,12 @@ impl ScriptThread { saw_any_reflows } + /// Schedule a rendering update ("update the rendering"), if necessary. This + /// can be necessary for a couple reasons. For instance, when the DOM + /// changes a scheduled rendering update becomes necessary if one isn't + /// scheduled already. Another example is if rAFs are running but no display + /// lists are being produced. In that case the [`ScriptThread`] is + /// responsible for scheduling animation ticks. fn maybe_schedule_rendering_opportunity_after_ipc_message( &self, built_any_display_lists: bool, @@ -1430,6 +1436,8 @@ impl ScriptThread { ); } + /// Fulfill the possibly-pending pending `document.fonts.ready` promise if + /// all web fonts have loaded. fn maybe_fulfill_font_ready_promises(&self, can_gc: CanGc) { let mut sent_message = false; for (_, document) in self.documents.borrow().iter() { @@ -1441,7 +1449,10 @@ impl ScriptThread { } } - fn maybe_send_document_state_messages(&self) { + /// If waiting for an idle `Pipeline` state in order to dump a screenshot at + /// the right time, inform the `Constellation` this `Pipeline` has entered + /// the idle state when applicable. + fn maybe_send_idle_document_state_to_constellation(&self) { if !opts::get().wait_for_stable_image { return; } @@ -1665,8 +1676,10 @@ impl ScriptThread { self.update_the_rendering(can_gc); self.maybe_fulfill_font_ready_promises(can_gc); + self.maybe_send_idle_document_state_to_constellation(); + + // This must happen last to detect if any change above makes a rendering update necessary. self.maybe_schedule_rendering_opportunity_after_ipc_message(built_any_display_lists); - self.maybe_send_document_state_messages(); true }