diff options
author | Martin Robinson <mrobinson@igalia.com> | 2023-07-10 15:54:39 +0200 |
---|---|---|
committer | Martin Robinson <mrobinson@igalia.com> | 2023-07-10 17:35:50 +0200 |
commit | 3230162fd0ac96dea77c683b2067ae65ec7ed0b4 (patch) | |
tree | a514617f5d3b72eb5e00cf60b86d8478de9b0e02 /components/gfx | |
parent | 1543912589e67734f0b684e1db900f41a4c04a1a (diff) | |
download | servo-3230162fd0ac96dea77c683b2067ae65ec7ed0b4.tar.gz servo-3230162fd0ac96dea77c683b2067ae65ec7ed0b4.zip |
Try to `use` WebRender types more
The newer versions of WebRender move types around between `webrender` and
`webrender_api` and this will reduce the churn during the upgrade.
Diffstat (limited to 'components/gfx')
-rw-r--r-- | components/gfx/font.rs | 5 | ||||
-rw-r--r-- | components/gfx/font_cache_thread.rs | 21 | ||||
-rw-r--r-- | components/gfx/font_context.rs | 7 | ||||
-rw-r--r-- | components/gfx/tests/font_context.rs | 11 | ||||
-rw-r--r-- | components/gfx/text/text_run.rs | 3 |
5 files changed, 18 insertions, 29 deletions
diff --git a/components/gfx/font.rs b/components/gfx/font.rs index 05ffb897a4e..7feb66fcaa3 100644 --- a/components/gfx/font.rs +++ b/components/gfx/font.rs @@ -27,6 +27,7 @@ use style::computed_values::{font_stretch, font_style, font_variant_caps, font_w use style::properties::style_structs::Font as FontStyleStruct; use style::values::computed::font::{GenericFontFamily, SingleFontFamily}; use unicode_script::Script; +use webrender_api::FontInstanceKey; macro_rules! ot_tag { ($t1:expr, $t2:expr, $t3:expr, $t4:expr) => { @@ -145,7 +146,7 @@ pub struct Font { shaper: Option<Shaper>, shape_cache: RefCell<HashMap<ShapeCacheEntry, Arc<GlyphStore>>>, glyph_advance_cache: RefCell<HashMap<u32, FractionalPixel>>, - pub font_key: webrender_api::FontInstanceKey, + pub font_key: FontInstanceKey, } impl Font { @@ -153,7 +154,7 @@ impl Font { handle: FontHandle, descriptor: FontDescriptor, actual_pt_size: Au, - font_key: webrender_api::FontInstanceKey, + font_key: FontInstanceKey, ) -> Font { let metrics = handle.metrics(); diff --git a/components/gfx/font_cache_thread.rs b/components/gfx/font_cache_thread.rs index f6d375e883b..325018102c9 100644 --- a/components/gfx/font_cache_thread.rs +++ b/components/gfx/font_cache_thread.rs @@ -25,6 +25,7 @@ use std::sync::{Arc, Mutex}; use std::{f32, fmt, mem, thread}; use style::font_face::{EffectiveSources, Source}; use style::values::computed::font::FamilyName; +use webrender_api::{FontInstanceKey, FontKey}; /// A list of font templates that make up a given font family. pub struct FontTemplates { @@ -34,13 +35,13 @@ pub struct FontTemplates { #[derive(Clone, Debug, Deserialize, Serialize)] pub struct FontTemplateInfo { pub font_template: Arc<FontTemplateData>, - pub font_key: webrender_api::FontKey, + pub font_key: FontKey, } #[derive(Debug, Deserialize, Serialize)] pub struct SerializedFontTemplateInfo { pub serialized_font_template: SerializedFontTemplate, - pub font_key: webrender_api::FontKey, + pub font_key: FontKey, } #[derive(Debug, Deserialize, Serialize)] @@ -128,11 +129,7 @@ pub enum Command { FontFamilyDescriptor, IpcSender<Reply>, ), - GetFontInstance( - webrender_api::FontKey, - Au, - IpcSender<webrender_api::FontInstanceKey>, - ), + GetFontInstance(FontKey, Au, IpcSender<FontInstanceKey>), AddWebFont(LowercaseString, EffectiveSources, IpcSender<()>), AddDownloadedWebFont(LowercaseString, ServoUrl, Vec<u8>, IpcSender<()>), Exit(IpcSender<()>), @@ -156,8 +153,8 @@ struct FontCache { font_context: FontContextHandle, core_resource_thread: CoreResourceThread, webrender_api: Box<dyn WebrenderApi>, - webrender_fonts: HashMap<Atom, webrender_api::FontKey>, - font_instances: HashMap<(webrender_api::FontKey, Au), webrender_api::FontInstanceKey>, + webrender_fonts: HashMap<Atom, FontKey>, + font_instances: HashMap<(FontKey, Au), FontInstanceKey>, } fn populate_generic_fonts() -> HashMap<FontFamilyName, LowercaseString> { @@ -536,11 +533,7 @@ impl FontCacheThread { } impl FontSource for FontCacheThread { - fn get_font_instance( - &mut self, - key: webrender_api::FontKey, - size: Au, - ) -> webrender_api::FontInstanceKey { + fn get_font_instance(&mut self, key: FontKey, size: Au) -> FontInstanceKey { let (response_chan, response_port) = ipc::channel().expect("failed to create IPC channel"); self.chan .send(Command::GetFontInstance(key, size, response_chan)) diff --git a/components/gfx/font_context.rs b/components/gfx/font_context.rs index 113b384f84d..6a975e6b12f 100644 --- a/components/gfx/font_context.rs +++ b/components/gfx/font_context.rs @@ -21,6 +21,7 @@ use std::rc::Rc; use std::sync::atomic::{AtomicUsize, Ordering}; use style::computed_values::font_variant_caps::T as FontVariantCaps; use style::properties::style_structs::Font as FontStyleStruct; +use webrender_api::{FontInstanceKey, FontKey}; static SMALL_CAPS_SCALE_FACTOR: f32 = 0.8; // Matches FireFox (see gfxFont.h) @@ -29,11 +30,7 @@ static SMALL_CAPS_SCALE_FACTOR: f32 = 0.8; // Matches FireFox (see gfxFont.h) static FONT_CACHE_EPOCH: AtomicUsize = AtomicUsize::new(0); pub trait FontSource { - fn get_font_instance( - &mut self, - key: webrender_api::FontKey, - size: Au, - ) -> webrender_api::FontInstanceKey; + fn get_font_instance(&mut self, key: FontKey, size: Au) -> FontInstanceKey; fn font_template( &mut self, diff --git a/components/gfx/tests/font_context.rs b/components/gfx/tests/font_context.rs index 796f693f418..72dbb7a0bb8 100644 --- a/components/gfx/tests/font_context.rs +++ b/components/gfx/tests/font_context.rs @@ -24,6 +24,7 @@ use style::values::computed::font::{ }; use style::values::computed::font::{FontStretch, FontWeight, SingleFontFamily}; use style::values::generics::font::FontStyle; +use webrender_api::{FontInstanceKey, FontKey, IdNamespace}; struct TestFontSource { handle: FontContextHandle, @@ -68,12 +69,8 @@ impl TestFontSource { } impl FontSource for TestFontSource { - fn get_font_instance( - &mut self, - _key: webrender_api::FontKey, - _size: Au, - ) -> webrender_api::FontInstanceKey { - webrender_api::FontInstanceKey(webrender_api::IdNamespace(0), 0) + fn get_font_instance(&mut self, _key: FontKey, _size: Au) -> FontInstanceKey { + FontInstanceKey(IdNamespace(0), 0) } fn font_template( @@ -89,7 +86,7 @@ impl FontSource for TestFontSource { .and_then(|family| family.find_font_for_style(&template_descriptor, handle)) .map(|template| FontTemplateInfo { font_template: template, - font_key: webrender_api::FontKey(webrender_api::IdNamespace(0), 0), + font_key: FontKey(IdNamespace(0), 0), }) } } diff --git a/components/gfx/text/text_run.rs b/components/gfx/text/text_run.rs index 17eb5bf623a..cf340a2e3dc 100644 --- a/components/gfx/text/text_run.rs +++ b/components/gfx/text/text_run.rs @@ -14,6 +14,7 @@ use std::slice::Iter; use std::sync::Arc; use style::str::char_is_whitespace; use unicode_bidi as bidi; +use webrender_api::FontInstanceKey; use xi_unicode::LineBreakLeafIter; thread_local! { @@ -29,7 +30,7 @@ pub struct TextRun { pub font_template: Arc<FontTemplateData>, pub actual_pt_size: Au, pub font_metrics: FontMetrics, - pub font_key: webrender_api::FontInstanceKey, + pub font_key: FontInstanceKey, /// The glyph runs that make up this text run. pub glyphs: Arc<Vec<GlyphRun>>, pub bidi_level: bidi::Level, |