mirror of
https://github.com/servo/servo.git
synced 2025-09-29 16:19:14 +01:00
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>
This commit is contained in:
parent
1daa0b4fc7
commit
ac567645a7
25 changed files with 482 additions and 425 deletions
|
@ -18,9 +18,7 @@ use webrender_api::{FontInstanceFlags, FontInstanceKey, FontKey};
|
|||
use crate::font::FontDescriptor;
|
||||
use crate::font_context::WebFontDownloadState;
|
||||
use crate::font_template::{FontTemplate, FontTemplateRef, FontTemplateRefMethods, IsOblique};
|
||||
use crate::system_font_service::{
|
||||
FontIdentifier, LowercaseFontFamilyName, SystemFontServiceProxyTrait,
|
||||
};
|
||||
use crate::system_font_service::{FontIdentifier, LowercaseFontFamilyName};
|
||||
use crate::FontContext;
|
||||
|
||||
/// A data structure to store data for fonts. If sent across IPC channels and only a
|
||||
|
@ -171,7 +169,7 @@ impl FontStore {
|
|||
FontIdentifier::Local(local_identifier) => {
|
||||
Arc::new(FontData::from_bytes(local_identifier.read_data_from_file()))
|
||||
},
|
||||
FontIdentifier::Web(_) => unreachable!("Web fonts should always have data."),
|
||||
_ => unreachable!("Web and mock fonts should always have data."),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -196,9 +194,9 @@ pub struct WebRenderFontStore {
|
|||
pub(crate) type CrossThreadWebRenderFontStore = Arc<RwLock<WebRenderFontStore>>;
|
||||
|
||||
impl WebRenderFontStore {
|
||||
pub(crate) fn get_font_instance<Proxy: SystemFontServiceProxyTrait>(
|
||||
pub(crate) fn get_font_instance(
|
||||
&mut self,
|
||||
font_context: &FontContext<Proxy>,
|
||||
font_context: &FontContext,
|
||||
font_template: FontTemplateRef,
|
||||
pt_size: Au,
|
||||
flags: FontInstanceFlags,
|
||||
|
@ -210,18 +208,14 @@ impl WebRenderFontStore {
|
|||
.entry(identifier.clone())
|
||||
.or_insert_with(|| {
|
||||
let data = font_context.get_font_data(&identifier);
|
||||
font_context
|
||||
.system_font_service_proxy
|
||||
.get_web_font(data, identifier.index())
|
||||
font_context.get_web_font(data, identifier.index())
|
||||
});
|
||||
|
||||
*self
|
||||
.webrender_font_instance_map
|
||||
.entry((font_key, pt_size))
|
||||
.or_insert_with(|| {
|
||||
font_context
|
||||
.system_font_service_proxy
|
||||
.get_web_font_instance(font_key, pt_size.to_f32_px(), flags)
|
||||
font_context.get_web_font_instance(font_key, pt_size.to_f32_px(), flags)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue