layout: Do not trigger dirty_all_nodes when web font loading fails (#43595)

Currently, the `web_font_finished_loading_callback` sends a
`ScriptThreadMessage::WebFontLoaded` message regardless of whether web
font loading succeeds or not, which leads to dirtying all nodes in
`script_thread.rs`. This creates unnecessary reflow. This PR removes the
boolean field from the `WebFontLoaded` message and only sends the
message when the web font loading is successful.

Testing: Existing WPT tests

Signed-off-by: Minghua Wu <michael.wu1107@gmail.com>
This commit is contained in:
minghuaw
2026-03-24 16:03:30 +08:00
committed by GitHub
parent 113b06f2ee
commit 75a56e567b
4 changed files with 10 additions and 8 deletions

View File

@@ -1849,8 +1849,8 @@ impl ScriptThread {
ScriptThreadMessage::WebDriverScriptCommand(pipeline_id, msg) => {
self.handle_webdriver_msg(pipeline_id, msg, cx)
},
ScriptThreadMessage::WebFontLoaded(pipeline_id, success) => {
self.handle_web_font_loaded(pipeline_id, success)
ScriptThreadMessage::WebFontLoaded(pipeline_id) => {
self.handle_web_font_loaded(pipeline_id)
},
ScriptThreadMessage::DispatchIFrameLoadEvent {
target: browsing_context_id,
@@ -3265,7 +3265,7 @@ impl ScriptThread {
}
/// Handles a Web font being loaded. Does nothing if the page no longer exists.
fn handle_web_font_loaded(&self, pipeline_id: PipelineId, _success: bool) {
fn handle_web_font_loaded(&self, pipeline_id: PipelineId) {
let Some(document) = self.documents.borrow().find_document(pipeline_id) else {
warn!("Web font loaded in closed pipeline {}.", pipeline_id);
return;