mirror of
https://github.com/servo/servo.git
synced 2025-09-13 00:18:22 +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
|
@ -9,14 +9,12 @@ use std::sync::Arc;
|
|||
use atomic_refcell::AtomicRefCell;
|
||||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use servo_url::ServoUrl;
|
||||
use style::computed_values::font_stretch::T as FontStretch;
|
||||
use style::computed_values::font_style::T as FontStyle;
|
||||
use style::stylesheets::DocumentStyleSheet;
|
||||
use style::values::computed::font::FontWeight;
|
||||
|
||||
use crate::font::FontDescriptor;
|
||||
use crate::platform::font_list::LocalFontIdentifier;
|
||||
use crate::system_font_service::{
|
||||
CSSFontFaceDescriptors, ComputedFontStyleDescriptor, FontIdentifier,
|
||||
};
|
||||
|
@ -160,29 +158,17 @@ impl Debug for FontTemplate {
|
|||
/// is common, regardless of the number of instances of
|
||||
/// this font handle per thread.
|
||||
impl FontTemplate {
|
||||
/// Create a new [`FontTemplate`] for a system font installed locally.
|
||||
pub fn new_for_local_font(
|
||||
identifier: LocalFontIdentifier,
|
||||
descriptor: FontTemplateDescriptor,
|
||||
) -> FontTemplate {
|
||||
FontTemplate {
|
||||
identifier: FontIdentifier::Local(identifier),
|
||||
descriptor,
|
||||
stylesheet: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new [`FontTemplate`] for a `@font-family` with a `url(...)` `src` font.
|
||||
pub fn new_for_remote_web_font(
|
||||
url: ServoUrl,
|
||||
/// Create a new [`FontTemplate`].
|
||||
pub fn new(
|
||||
identifier: FontIdentifier,
|
||||
descriptor: FontTemplateDescriptor,
|
||||
stylesheet: Option<DocumentStyleSheet>,
|
||||
) -> Result<FontTemplate, &'static str> {
|
||||
Ok(FontTemplate {
|
||||
identifier: FontIdentifier::Web(url),
|
||||
) -> FontTemplate {
|
||||
FontTemplate {
|
||||
identifier,
|
||||
descriptor,
|
||||
stylesheet,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new [`FontTemplate`] for a `@font-family` with a `local(...)` `src`. This takes in
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue