fonts: Clean up messaging during web fonts loads (#32332)

Instead of sending a message to the script thread via IPC when a web
font loads and then sending another, just give the `FontContext` a
callback that send a single message to the script thread. This moves all
the cache invalidation internally into `FontContext` as well.

Additionally, the unused LayoutControlMessage::ExitNow enum variant is
removed.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
This commit is contained in:
Martin Robinson 2024-05-22 10:30:35 +02:00 committed by GitHub
parent d47c8ff2ae
commit 9f32809671
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 150 additions and 205 deletions

View file

@ -2124,7 +2124,6 @@ impl ScriptThread {
MediaSessionAction(..) => None,
SetWebGPUPort(..) => None,
ForLayoutFromConstellation(_, id) => Some(id),
ForLayoutFromFontCache(id) => Some(id),
},
MixedMessage::FromDevtools(_) => None,
MixedMessage::FromScript(ref inner_msg) => match *inner_msg {
@ -2358,28 +2357,21 @@ impl ScriptThread {
panic!("should have handled {:?} already", msg)
},
ConstellationControlMsg::ForLayoutFromConstellation(msg, pipeline_id) => {
self.handle_layout_message(msg, pipeline_id)
},
ConstellationControlMsg::ForLayoutFromFontCache(pipeline_id) => {
self.handle_font_cache(pipeline_id)
self.handle_layout_message_from_constellation(msg, pipeline_id)
},
}
}
fn handle_layout_message(&self, msg: LayoutControlMsg, pipeline_id: PipelineId) {
fn handle_layout_message_from_constellation(
&self,
msg: LayoutControlMsg,
pipeline_id: PipelineId,
) {
let Some(window) = self.documents.borrow().find_window(pipeline_id) else {
warn!("Received layout message pipeline {pipeline_id} closed: {msg:?}.");
return;
};
window.layout_mut().handle_constellation_msg(msg);
}
fn handle_font_cache(&self, pipeline_id: PipelineId) {
let Some(window) = self.documents.borrow().find_window(pipeline_id) else {
warn!("Received font cache message pipeline {pipeline_id} closed.");
return;
};
window.layout_mut().handle_font_cache_msg();
window.layout_mut().handle_constellation_message(msg);
}
fn handle_msg_from_webgpu_server(&self, msg: WebGPUMsg) {