mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
fonts: Store web fonts in the per-Layout FontContext
(#32303)
This moves mangement of web fonts to the per-Layout `FontContext`, preventing web fonts from being available in different Documents. Fixes #12920. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
This commit is contained in:
parent
8d2d955bbb
commit
be5b527ea3
30 changed files with 1010 additions and 558 deletions
|
@ -11,6 +11,7 @@ name = "gfx_traits"
|
|||
path = "lib.rs"
|
||||
|
||||
[dependencies]
|
||||
ipc-channel = { workspace = true }
|
||||
malloc_size_of = { workspace = true }
|
||||
malloc_size_of_derive = { workspace = true }
|
||||
range = { path = "../../range" }
|
||||
|
|
|
@ -341,7 +341,7 @@ where
|
|||
// See also: https://github.com/servo/servo/blob/735480/components/script/script_thread.rs#L313
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct ResourceThreads {
|
||||
core_thread: CoreResourceThread,
|
||||
pub core_thread: CoreResourceThread,
|
||||
storage_thread: IpcSender<StorageThreadMsg>,
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ use libc::c_void;
|
|||
use malloc_size_of_derive::MallocSizeOf;
|
||||
use metrics::PaintTimeMetrics;
|
||||
use net_traits::image_cache::{ImageCache, PendingImageId};
|
||||
use net_traits::ResourceThreads;
|
||||
use profile_traits::mem::Report;
|
||||
use profile_traits::time;
|
||||
use script_traits::{
|
||||
|
@ -164,6 +165,7 @@ pub struct LayoutConfig {
|
|||
pub constellation_chan: IpcSender<LayoutMsg>,
|
||||
pub script_chan: IpcSender<ConstellationControlMsg>,
|
||||
pub image_cache: Arc<dyn ImageCache>,
|
||||
pub resource_threads: ResourceThreads,
|
||||
pub font_cache_thread: FontCacheThread,
|
||||
pub time_profiler_chan: time::ProfilerChan,
|
||||
pub webrender_api_sender: WebRenderScriptApi,
|
||||
|
|
|
@ -188,6 +188,23 @@ pub trait WebRenderFontApi {
|
|||
flags: FontInstanceFlags,
|
||||
) -> FontInstanceKey;
|
||||
fn add_font(&self, data: Arc<Vec<u8>>, index: u32) -> FontKey;
|
||||
/// Forward an already prepared `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,
|
||||
bytes_receiver: IpcBytesReceiver,
|
||||
font_index: u32,
|
||||
result_sender: IpcSender<FontKey>,
|
||||
);
|
||||
/// Forward an already prepared `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>,
|
||||
);
|
||||
fn add_system_font(&self, handle: NativeFontHandle) -> FontKey;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue