diff options
author | Martin Robinson <mrobinson@igalia.com> | 2024-09-25 22:15:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-25 20:15:47 +0000 |
commit | ac567645a75630830a99d90946e0e96d0a759ead (patch) | |
tree | 881ed64b131df03b06dc9e4db118a5356d745a43 /components/shared/webrender/lib.rs | |
parent | 1daa0b4fc7a45f0020e6677c4e67fd78dd4f3eec (diff) | |
download | servo-ac567645a75630830a99d90946e0e96d0a759ead.tar.gz servo-ac567645a75630830a99d90946e0e96d0a759ead.zip |
fonts: Simplify `FontContext` in two ways that affect the unit test (#33541)
This is done by no longer forwarding compositor-bound messages through
SystemFontService and making `FontContext` non-generic:
- Messages from the `FontContext` to the `Compositor` no longer need to be
forwarded through the `SystemFontService`. Instead send these messages
directly through the script IPC channel to the `Compositor`.
- Instead of adding a mock `SystemFontServiceProxy`, simply implement a
mock `SystemFontService` on the other side of an IPC channel in the
`font_context` unit test. This allows making `FontContext`
non-generic, greatly simplifying the code. The extra complexity moves
into the unit test.
These changes necessitate adding a new kind of `FontIdentifier`,
`FontIdentifier::Mock` due to the fact that local fonts have
platform-specific identifiers. This avoids having to pretend like the
system font service can have web fonts -- which was always a bit of a
hack.
These two changes are combined into one PR because they both require
extensive and similar chages in the font_context unit test which
dependended on the details of both of them.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Diffstat (limited to 'components/shared/webrender/lib.rs')
-rw-r--r-- | components/shared/webrender/lib.rs | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/components/shared/webrender/lib.rs b/components/shared/webrender/lib.rs index 14f3d3d338a..accb73df316 100644 --- a/components/shared/webrender/lib.rs +++ b/components/shared/webrender/lib.rs @@ -192,24 +192,6 @@ pub trait WebRenderFontApi { ) -> FontInstanceKey; fn add_font(&self, data: Arc<IpcSharedMemory>, index: u32) -> FontKey; fn add_system_font(&self, handle: NativeFontHandle) -> FontKey; - - /// Forward a `AddFont` message, sending it on to the compositor. This is used to get WebRender - /// [`FontKey`]s for web fonts in the per-layout `FontContext`. - fn forward_add_font_message( - &self, - data: Arc<IpcSharedMemory>, - font_index: u32, - result_sender: IpcSender<FontKey>, - ); - /// Forward a `AddFontInstance` message, sending it on to the compositor. This is used to get - /// WebRender [`FontInstanceKey`]s for web fonts in the per-layout `FontContext`. - fn forward_add_font_instance_message( - &self, - font_key: FontKey, - size: f32, - flags: FontInstanceFlags, - result_receiver: IpcSender<FontInstanceKey>, - ); } pub enum CanvasToCompositorMsg { @@ -260,6 +242,8 @@ pub enum ScriptToCompositorMsg { UpdateImages(Vec<SerializedImageUpdate>), /// Remove the given font resources from our WebRender instance. RemoveFonts(Vec<FontKey>, Vec<FontInstanceKey>), + AddFontInstance(FontKey, f32, FontInstanceFlags, IpcSender<FontInstanceKey>), + AddFont(Arc<IpcSharedMemory>, u32, IpcSender<FontKey>), } /// A mechanism to send messages from networking to the WebRender instance. @@ -294,11 +278,23 @@ impl WebRenderNetApi { pub struct WebRenderScriptApi(IpcSender<ScriptToCompositorMsg>); impl WebRenderScriptApi { - /// Create a new WebrenderIpcSender object that wraps the provided channel sender. + /// Create a new [`WebRenderScriptApi`] object that wraps the provided channel sender. pub fn new(sender: IpcSender<ScriptToCompositorMsg>) -> Self { Self(sender) } + /// Create a new [`WebRenderScriptApi`] object that does not have a listener on the + /// other end. + pub fn dummy() -> Self { + let (sender, _) = ipc::channel().unwrap(); + Self::new(sender) + } + + /// Get the sender for this proxy. + pub fn sender(&self) -> &IpcSender<ScriptToCompositorMsg> { + &self.0 + } + /// Inform WebRender of the existence of this pipeline. pub fn send_initial_transaction(&self, pipeline: WebRenderPipelineId) { if let Err(e) = self |