diff options
author | Martin Robinson <mrobinson@igalia.com> | 2024-04-17 09:26:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-17 07:26:39 +0000 |
commit | 83dec920dd5cd0cd3907a794e79c826b6521c054 (patch) | |
tree | ecad168ed9669aed165dd2fd498788fdf4a3884c /components | |
parent | ab2b001265d9e9ec92542812bf301c6642f0595b (diff) | |
download | servo-83dec920dd5cd0cd3907a794e79c826b6521c054.tar.gz servo-83dec920dd5cd0cd3907a794e79c826b6521c054.zip |
Rename `FontTemplateInfo` to `FontTemplateAndWebRenderFontKey` (#32100)
This clarifies what this type does a bit. Based on a suggestion by
@mukilan.
Diffstat (limited to 'components')
-rw-r--r-- | components/gfx/font_cache_thread.rs | 16 | ||||
-rw-r--r-- | components/gfx/font_context.rs | 10 | ||||
-rw-r--r-- | components/gfx/tests/font_context.rs | 6 |
3 files changed, 16 insertions, 16 deletions
diff --git a/components/gfx/font_cache_thread.rs b/components/gfx/font_cache_thread.rs index 797a12317d6..d56cf2f115d 100644 --- a/components/gfx/font_cache_thread.rs +++ b/components/gfx/font_cache_thread.rs @@ -42,13 +42,13 @@ pub struct FontTemplates { } #[derive(Clone, Debug)] -pub struct FontTemplateInfo { +pub struct FontTemplateAndWebRenderFontKey { pub font_template: FontTemplateRef, pub font_key: FontKey, } #[derive(Debug, Deserialize, Serialize)] -pub struct SerializedFontTemplateInfo { +pub struct SerializedFontTemplateAndWebRenderFontKey { pub serialized_font_template: SerializedFontTemplate, pub font_key: FontKey, } @@ -151,7 +151,7 @@ pub enum Command { /// Reply messages sent from the font cache thread to the FontContext caller. #[derive(Debug, Deserialize, Serialize)] pub enum Reply { - GetFontTemplateReply(Option<SerializedFontTemplateInfo>), + GetFontTemplateReply(Option<SerializedFontTemplateAndWebRenderFontKey>), } /// The font cache thread itself. It maintains a list of reference counted @@ -218,7 +218,7 @@ impl FontCache { }; let _ = result.send(Reply::GetFontTemplateReply(Some( - SerializedFontTemplateInfo { + SerializedFontTemplateAndWebRenderFontKey { serialized_font_template, font_key: font_template_info.font_key, }, @@ -452,7 +452,7 @@ impl FontCache { &mut self, template_descriptor: &FontTemplateDescriptor, family_descriptor: &FontFamilyDescriptor, - ) -> Option<FontTemplateInfo> { + ) -> Option<FontTemplateAndWebRenderFontKey> { match family_descriptor.scope { FontSearchScope::Any => self .find_font_in_web_family(template_descriptor, &family_descriptor.name) @@ -464,7 +464,7 @@ impl FontCache { self.find_font_in_local_family(template_descriptor, &family_descriptor.name) }, } - .map(|font_template| FontTemplateInfo { + .map(|font_template| FontTemplateAndWebRenderFontKey { font_key: self.get_font_key_for_template(&font_template), font_template, }) @@ -600,7 +600,7 @@ impl FontSource for FontCacheThread { &mut self, template_descriptor: FontTemplateDescriptor, family_descriptor: FontFamilyDescriptor, - ) -> Option<FontTemplateInfo> { + ) -> Option<FontTemplateAndWebRenderFontKey> { let (response_chan, response_port) = ipc::channel().expect("failed to create IPC channel"); self.chan .send(Command::GetFontTemplate( @@ -629,7 +629,7 @@ impl FontSource for FontCacheThread { .serialized_font_template .to_font_template(), )); - FontTemplateInfo { + FontTemplateAndWebRenderFontKey { font_template, font_key: serialized_font_template_info.font_key, } diff --git a/components/gfx/font_context.rs b/components/gfx/font_context.rs index f37c1cd91fd..257aeeb41c2 100644 --- a/components/gfx/font_context.rs +++ b/components/gfx/font_context.rs @@ -20,7 +20,7 @@ use webrender_api::{FontInstanceKey, FontKey}; use crate::font::{ Font, FontDescriptor, FontFamilyDescriptor, FontGroup, FontHandleMethods, FontRef, }; -use crate::font_cache_thread::FontTemplateInfo; +use crate::font_cache_thread::FontTemplateAndWebRenderFontKey; #[cfg(target_os = "macos")] use crate::font_template::FontTemplate; use crate::font_template::FontTemplateDescriptor; @@ -39,7 +39,7 @@ pub trait FontSource { &mut self, template_descriptor: FontTemplateDescriptor, family_descriptor: FontFamilyDescriptor, - ) -> Option<FontTemplateInfo>; + ) -> Option<FontTemplateAndWebRenderFontKey>; } /// The FontContext represents the per-thread/thread state necessary for @@ -54,7 +54,7 @@ pub struct FontContext<S: FontSource> { // so they will never be released. Find out a good time to drop them. // See bug https://github.com/servo/servo/issues/3300 font_cache: HashMap<FontCacheKey, Option<FontRef>>, - font_template_cache: HashMap<FontTemplateCacheKey, Option<FontTemplateInfo>>, + font_template_cache: HashMap<FontTemplateCacheKey, Option<FontTemplateAndWebRenderFontKey>>, font_group_cache: HashMap<FontGroupCacheKey, Rc<RefCell<FontGroup>>, BuildHasherDefault<FnvHasher>>, @@ -183,7 +183,7 @@ impl<S: FontSource> FontContext<S> { &mut self, template_descriptor: &FontTemplateDescriptor, family_descriptor: &FontFamilyDescriptor, - ) -> Option<FontTemplateInfo> { + ) -> Option<FontTemplateAndWebRenderFontKey> { let cache_key = FontTemplateCacheKey { template_descriptor: *template_descriptor, family_descriptor: family_descriptor.clone(), @@ -210,7 +210,7 @@ impl<S: FontSource> FontContext<S> { /// cache thread and a `FontDescriptor` which contains the styling parameters. fn create_font( &mut self, - info: FontTemplateInfo, + info: FontTemplateAndWebRenderFontKey, descriptor: FontDescriptor, synthesized_small_caps: Option<FontRef>, ) -> Result<Font, &'static str> { diff --git a/components/gfx/tests/font_context.rs b/components/gfx/tests/font_context.rs index 9d26f7603dd..8e8de147d3e 100644 --- a/components/gfx/tests/font_context.rs +++ b/components/gfx/tests/font_context.rs @@ -14,7 +14,7 @@ use gfx::font::{ fallback_font_families, FontDescriptor, FontFamilyDescriptor, FontFamilyName, FontHandleMethods, FontSearchScope, }; -use gfx::font_cache_thread::{FontIdentifier, FontTemplateInfo, FontTemplates}; +use gfx::font_cache_thread::{FontIdentifier, FontTemplateAndWebRenderFontKey, FontTemplates}; use gfx::font_context::{FontContext, FontSource}; use gfx::font_template::FontTemplateDescriptor; use servo_arc::Arc; @@ -88,12 +88,12 @@ impl FontSource for TestFontSource { &mut self, template_descriptor: FontTemplateDescriptor, family_descriptor: FontFamilyDescriptor, - ) -> Option<FontTemplateInfo> { + ) -> Option<FontTemplateAndWebRenderFontKey> { self.find_font_count.set(self.find_font_count.get() + 1); self.families .get_mut(family_descriptor.name()) .and_then(|family| family.find_font_for_style(&template_descriptor)) - .map(|template| FontTemplateInfo { + .map(|template| FontTemplateAndWebRenderFontKey { font_template: template, font_key: FontKey(IdNamespace(0), 0), }) |