aboutsummaryrefslogtreecommitdiffstats
path: root/components/servo/lib.rs
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2024-09-25 22:15:47 +0200
committerGitHub <noreply@github.com>2024-09-25 20:15:47 +0000
commitac567645a75630830a99d90946e0e96d0a759ead (patch)
tree881ed64b131df03b06dc9e4db118a5356d745a43 /components/servo/lib.rs
parent1daa0b4fc7a45f0020e6677c4e67fd78dd4f3eec (diff)
downloadservo-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/servo/lib.rs')
-rw-r--r--components/servo/lib.rs56
1 files changed, 15 insertions, 41 deletions
diff --git a/components/servo/lib.rs b/components/servo/lib.rs
index 15438de42fe..7c44981600d 100644
--- a/components/servo/lib.rs
+++ b/components/servo/lib.rs
@@ -1101,59 +1101,33 @@ impl WebRenderFontApi for WebRenderFontApiCompositorProxy {
flags: FontInstanceFlags,
) -> FontInstanceKey {
let (sender, receiver) = unbounded();
- self.0
- .send(CompositorMsg::Forwarded(ForwardedToCompositorMsg::Font(
- FontToCompositorMsg::AddFontInstance(font_key, size, flags, sender),
- )));
+ self.0.send(CompositorMsg::Forwarded(
+ ForwardedToCompositorMsg::SystemFontService(FontToCompositorMsg::AddFontInstance(
+ font_key, size, flags, sender,
+ )),
+ ));
receiver.recv().unwrap()
}
fn add_font(&self, data: Arc<IpcSharedMemory>, index: u32) -> FontKey {
let (sender, receiver) = unbounded();
- self.0
- .send(CompositorMsg::Forwarded(ForwardedToCompositorMsg::Font(
- FontToCompositorMsg::AddFont(sender, index, data),
- )));
+ self.0.send(CompositorMsg::Forwarded(
+ ForwardedToCompositorMsg::SystemFontService(FontToCompositorMsg::AddFont(
+ sender, index, data,
+ )),
+ ));
receiver.recv().unwrap()
}
fn add_system_font(&self, handle: NativeFontHandle) -> FontKey {
let (sender, receiver) = unbounded();
- self.0
- .send(CompositorMsg::Forwarded(ForwardedToCompositorMsg::Font(
- FontToCompositorMsg::AddSystemFont(sender, handle),
- )));
+ self.0.send(CompositorMsg::Forwarded(
+ ForwardedToCompositorMsg::SystemFontService(FontToCompositorMsg::AddSystemFont(
+ sender, handle,
+ )),
+ ));
receiver.recv().unwrap()
}
-
- fn forward_add_font_message(
- &self,
- data: Arc<IpcSharedMemory>,
- font_index: u32,
- result_sender: IpcSender<FontKey>,
- ) {
- let (sender, receiver) = unbounded();
- self.0
- .send(CompositorMsg::Forwarded(ForwardedToCompositorMsg::Font(
- FontToCompositorMsg::AddFont(sender, font_index, data),
- )));
- let _ = result_sender.send(receiver.recv().unwrap());
- }
-
- fn forward_add_font_instance_message(
- &self,
- font_key: FontKey,
- size: f32,
- flags: FontInstanceFlags,
- result_sender: IpcSender<FontInstanceKey>,
- ) {
- let (sender, receiver) = unbounded();
- self.0
- .send(CompositorMsg::Forwarded(ForwardedToCompositorMsg::Font(
- FontToCompositorMsg::AddFontInstance(font_key, size, flags, sender),
- )));
- let _ = result_sender.send(receiver.recv().unwrap());
- }
}
#[derive(Clone)]