From 8372cf1bd8946ccb41d6d0aa851d977e8de33b1b Mon Sep 17 00:00:00 2001 From: Utsav Oza Date: Fri, 12 Jun 2020 18:43:09 +0530 Subject: [PATCH] Derive Serialize and Deserialize traits for font styles for #[cfg_attr(feature = "servo")] --- components/canvas/canvas_data.rs | 4 +--- components/canvas/canvas_paint_thread.rs | 1 - components/style/properties/properties.mako.rs | 3 ++- components/style/values/computed/font.rs | 17 +++-------------- components/style/values/specified/font.rs | 6 ++---- 5 files changed, 8 insertions(+), 23 deletions(-) diff --git a/components/canvas/canvas_data.rs b/components/canvas/canvas_data.rs index ec59074582a..23f23e4252c 100644 --- a/components/canvas/canvas_data.rs +++ b/components/canvas/canvas_data.rs @@ -409,7 +409,6 @@ pub struct CanvasData<'a> { /// An old webrender image key that can be deleted when the current epoch ends. very_old_image_key: Option, font_cache_thread: Mutex, - _canvas_id: CanvasId, } fn create_backend() -> Box { @@ -421,7 +420,6 @@ impl<'a> CanvasData<'a> { size: Size2D, webrender_api: Box, antialias: AntialiasMode, - canvas_id: CanvasId, font_cache_thread: FontCacheThread, ) -> CanvasData<'a> { let backend = create_backend(); @@ -437,7 +435,6 @@ impl<'a> CanvasData<'a> { old_image_key: None, very_old_image_key: None, font_cache_thread: Mutex::new(font_cache_thread), - _canvas_id: canvas_id, } } @@ -495,6 +492,7 @@ impl<'a> CanvasData<'a> { } } + // https://html.spec.whatwg.org/multipage/#text-preparation-algorithm pub fn fill_text( &mut self, text: String, diff --git a/components/canvas/canvas_paint_thread.rs b/components/canvas/canvas_paint_thread.rs index 763e7d04a18..836a1bc6a6d 100644 --- a/components/canvas/canvas_paint_thread.rs +++ b/components/canvas/canvas_paint_thread.rs @@ -134,7 +134,6 @@ impl<'a> CanvasPaintThread<'a> { size, self.webrender_api.clone(), antialias, - canvas_id.clone(), font_cache_thread, ); self.canvases.insert(canvas_id.clone(), canvas_data); diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 7bf6813994b..1c51b6d55b0 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -2601,7 +2601,8 @@ pub mod style_structs { % for style_struct in data.active_style_structs(): % if style_struct.name == "Font": - #[derive(Clone, Debug, MallocSizeOf, Serialize, Deserialize)] + #[derive(Clone, Debug, MallocSizeOf)] + #[cfg_attr(feature = "servo", derive(Serialize, Deserialize))] % else: #[derive(Clone, Debug, MallocSizeOf, PartialEq)] % endif diff --git a/components/style/values/computed/font.rs b/components/style/values/computed/font.rs index 68f60c02e14..25a93d68348 100644 --- a/components/style/values/computed/font.rs +++ b/components/style/values/computed/font.rs @@ -93,9 +93,8 @@ impl From for FontKitFontWeight { ToAnimatedZero, ToCss, ToResolvedValue, - Serialize, - Deserialize, )] +#[cfg_attr(feature = "servo", derive(Serialize, Deserialize))] /// The computed value of font-size pub struct FontSize { /// The size. @@ -478,20 +477,10 @@ impl From<&SingleFontFamily> for FontKitFamilyName { } } -#[cfg(feature = "servo")] #[derive( - Clone, - Debug, - Eq, - Hash, - MallocSizeOf, - PartialEq, - ToComputedValue, - ToResolvedValue, - ToShmem, - Serialize, - Deserialize, + Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem, )] +#[cfg_attr(feature = "servo", derive(Serialize, Deserialize))] /// A list of SingleFontFamily pub struct FontFamilyList(Box<[SingleFontFamily]>); diff --git a/components/style/values/specified/font.rs b/components/style/values/specified/font.rs index 9d70648ce71..1a77a3864ef 100644 --- a/components/style/values/specified/font.rs +++ b/components/style/values/specified/font.rs @@ -496,9 +496,8 @@ impl ToComputedValue for FontStretch { ToCss, ToResolvedValue, ToShmem, - Serialize, - Deserialize, )] +#[cfg_attr(feature = "servo", derive(Serialize, Deserialize))] #[allow(missing_docs)] pub enum KeywordSize { #[css(keyword = "xx-small")] @@ -542,9 +541,8 @@ impl Default for KeywordSize { ToCss, ToResolvedValue, ToShmem, - Serialize, - Deserialize, )] +#[cfg_attr(feature = "servo", derive(Serialize, Deserialize))] /// Additional information for keyword-derived font sizes. pub struct KeywordInfo { /// The keyword used