From 0254fd06350614e9ad521811ad189f305a5a9afe Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 11 Sep 2017 16:35:11 +0200 Subject: [PATCH 01/10] Do not use CVAS for the list-style-type property --- components/style/counter_style/mod.rs | 4 ++-- components/style/properties/longhand/list.mako.rs | 5 +---- components/style/values/computed/mod.rs | 1 + components/style/values/generics/mod.rs | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/components/style/counter_style/mod.rs b/components/style/counter_style/mod.rs index 094f14a1cdc..6bdd22d8e07 100644 --- a/components/style/counter_style/mod.rs +++ b/components/style/counter_style/mod.rs @@ -342,7 +342,7 @@ impl ToCss for System { } /// https://drafts.csswg.org/css-counter-styles/#typedef-symbol -#[derive(Clone, Debug, Eq, PartialEq)] +#[derive(Clone, Debug, Eq, PartialEq, ToComputedValue)] pub enum Symbol { /// String(String), @@ -489,7 +489,7 @@ impl Parse for Fallback { } /// https://drafts.csswg.org/css-counter-styles/#descdef-counter-style-symbols -#[derive(Clone, Debug, Eq, PartialEq)] +#[derive(Clone, Debug, Eq, PartialEq, ToComputedValue)] pub struct Symbols(pub Vec); impl Parse for Symbols { diff --git a/components/style/properties/longhand/list.mako.rs b/components/style/properties/longhand/list.mako.rs index 2540922ca2e..01f4b6145bf 100644 --- a/components/style/properties/longhand/list.mako.rs +++ b/components/style/properties/longhand/list.mako.rs @@ -33,7 +33,6 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu <%helpers:longhand name="list-style-type" animation_value_type="discrete" boxed="True" spec="https://drafts.csswg.org/css-lists/#propdef-list-style-type"> use values::CustomIdent; - use values::computed::ComputedValueAsSpecified; use values::generics::CounterStyleOrNone; pub use self::computed_value::T as SpecifiedValue; @@ -42,15 +41,13 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu use values::generics::CounterStyleOrNone; /// | | none - #[derive(Clone, Debug, Eq, PartialEq, ToCss)] + #[derive(Clone, Debug, Eq, PartialEq, ToComputedValue, ToCss)] pub enum T { CounterStyle(CounterStyleOrNone), String(String), } } - impl ComputedValueAsSpecified for SpecifiedValue {} - #[cfg(feature = "gecko")] impl SpecifiedValue { /// Convert from gecko keyword to list-style-type. diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index 53a7fbe74c4..268baa23deb 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -339,6 +339,7 @@ trivial_to_computed_value!(bool); trivial_to_computed_value!(i32); trivial_to_computed_value!(f32); trivial_to_computed_value!(BorderStyle); +trivial_to_computed_value!(String); /// A `` value. pub type Number = CSSFloat; diff --git a/components/style/values/generics/mod.rs b/components/style/values/generics/mod.rs index ba39c19bd6a..0f419da0383 100644 --- a/components/style/values/generics/mod.rs +++ b/components/style/values/generics/mod.rs @@ -71,7 +71,7 @@ impl SymbolsType { /// /// Since wherever is used, 'none' is a valid value as /// well, we combine them into one type to make code simpler. -#[derive(Clone, Debug, Eq, PartialEq, ToCss)] +#[derive(Clone, Debug, Eq, PartialEq, ToComputedValue, ToCss)] pub enum CounterStyleOrNone { /// `none` None, From 5e8ee277fc394cecf07812868b665b5198bdf11e Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 11 Sep 2017 16:45:46 +0200 Subject: [PATCH 02/10] Do not use CVAS for specified::Attr --- components/style/macros.rs | 2 +- components/style/values/computed/mod.rs | 12 +++++++----- components/style/values/specified/mod.rs | 5 +---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/components/style/macros.rs b/components/style/macros.rs index aeec5516fda..e2791e6f09f 100644 --- a/components/style/macros.rs +++ b/components/style/macros.rs @@ -5,7 +5,7 @@ //! Various macro helpers. macro_rules! trivial_to_computed_value { - ($name: ident) => { + ($name:ty) => { impl $crate::values::computed::ToComputedValue for $name { type ComputedValue = $name; diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index 268baa23deb..46191a30400 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -4,7 +4,7 @@ //! Computed values. -use Atom; +use {Atom, Namespace}; use context::QuirksMode; use euclid::Size2D; use font_metrics::FontMetricsProvider; @@ -332,13 +332,15 @@ impl ToComputedValue for T } } -trivial_to_computed_value!(Atom); +trivial_to_computed_value!(()); +trivial_to_computed_value!(bool); +trivial_to_computed_value!(f32); +trivial_to_computed_value!(i32); trivial_to_computed_value!(u8); trivial_to_computed_value!(u16); -trivial_to_computed_value!(bool); -trivial_to_computed_value!(i32); -trivial_to_computed_value!(f32); +trivial_to_computed_value!(Atom); trivial_to_computed_value!(BorderStyle); +trivial_to_computed_value!(Namespace); trivial_to_computed_value!(String); /// A `` value. diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 7c91096bb8b..9efed2e144f 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -21,7 +21,6 @@ use super::computed::{Context, ToComputedValue}; use super::generics::{GreaterThanOrEqualToOne, NonNegative}; use super::generics::grid::{GridLine as GenericGridLine, TrackBreadth as GenericTrackBreadth}; use super::generics::grid::{TrackSize as GenericTrackSize, TrackList as GenericTrackList}; -use values::computed::ComputedValueAsSpecified; use values::specified::calc::CalcNode; pub use properties::animated_properties::TransitionProperty; @@ -681,8 +680,8 @@ pub type NamespaceId = (); /// An attr(...) rule /// /// `[namespace? `|`]? ident` -#[derive(Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] +#[derive(Clone, Debug, Eq, PartialEq, ToComputedValue)] pub struct Attr { /// Optional namespace pub namespace: Option<(Namespace, NamespaceId)>, @@ -777,5 +776,3 @@ impl ToCss for Attr { dest.write_str(")") } } - -impl ComputedValueAsSpecified for Attr {} From d27c5954a1a6966228ef18da098540a43fd9766b Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 11 Sep 2017 16:35:11 +0200 Subject: [PATCH 03/10] Do not use CVAS for the content property --- components/style/properties/longhand/counters.mako.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/components/style/properties/longhand/counters.mako.rs b/components/style/properties/longhand/counters.mako.rs index 190351895c7..16aca0ff60f 100644 --- a/components/style/properties/longhand/counters.mako.rs +++ b/components/style/properties/longhand/counters.mako.rs @@ -8,7 +8,6 @@ <%helpers:longhand name="content" boxed="True" animation_value_type="discrete" spec="https://drafts.csswg.org/css-content/#propdef-content"> - use values::computed::ComputedValueAsSpecified; #[cfg(feature = "gecko")] use values::generics::CounterStyleOrNone; #[cfg(feature = "gecko")] @@ -22,8 +21,6 @@ pub use self::computed_value::T as SpecifiedValue; pub use self::computed_value::ContentItem; - impl ComputedValueAsSpecified for SpecifiedValue {} - pub mod computed_value { use cssparser; use std::fmt; @@ -39,8 +36,8 @@ #[cfg(feature = "gecko")] use values::specified::Attr; - #[derive(Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Debug, Eq, PartialEq, ToComputedValue)] pub enum ContentItem { /// Literal string content. String(String), @@ -100,8 +97,8 @@ } } - #[derive(Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Debug, Eq, PartialEq, ToComputedValue)] pub enum T { Normal, None, From f2b1c6b7cf8e844bcd99c6f0cb87f76f6ac3de68 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 11 Sep 2017 16:35:11 +0200 Subject: [PATCH 04/10] Do not use CVAS for the -servo-under-display-none property --- components/style/properties/longhand/inherited_box.mako.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/components/style/properties/longhand/inherited_box.mako.rs b/components/style/properties/longhand/inherited_box.mako.rs index 16779dfbf03..23a621309f2 100644 --- a/components/style/properties/longhand/inherited_box.mako.rs +++ b/components/style/properties/longhand/inherited_box.mako.rs @@ -256,17 +256,14 @@ ${helpers.single_keyword("image-rendering", spec="Nonstandard (internal layout use only)"> use std::fmt; use style_traits::ToCss; - use values::computed::ComputedValueAsSpecified; - - #[derive(Clone, Copy, Debug, Eq, PartialEq)] - #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] + #[cfg_attr(feature = "servo", derive(Deserialize, HeapSizeOf, Serialize))] + #[derive(Clone, Copy, Debug, Eq, PartialEq, ToComputedValue)] pub struct SpecifiedValue(pub bool); pub mod computed_value { pub type T = super::SpecifiedValue; } - impl ComputedValueAsSpecified for SpecifiedValue {} pub fn get_initial_value() -> computed_value::T { SpecifiedValue(false) From 4f61c0d48ca0866ddd0023122f5b1f9c18520715 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 11 Sep 2017 16:35:11 +0200 Subject: [PATCH 05/10] Do not use CVAS for the paint-order property --- .../style/properties/longhand/inherited_svg.mako.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/components/style/properties/longhand/inherited_svg.mako.rs b/components/style/properties/longhand/inherited_svg.mako.rs index 3d3b82541fc..7ab12214619 100644 --- a/components/style/properties/longhand/inherited_svg.mako.rs +++ b/components/style/properties/longhand/inherited_svg.mako.rs @@ -136,8 +136,6 @@ ${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)", animation_value_type="discrete" products="gecko" spec="https://www.w3.org/TR/SVG2/painting.html#PaintOrder"> - - use values::computed::ComputedValueAsSpecified; use std::fmt; use style_traits::ToCss; @@ -164,8 +162,8 @@ ${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)", /// /// Higher priority values, i.e. the values specified first, /// will be painted first (and may be covered by paintings of lower priority) - #[derive(Clone, Copy, Debug, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Copy, Debug, PartialEq, ToComputedValue)] pub struct SpecifiedValue(pub u8); pub mod computed_value { @@ -258,10 +256,8 @@ ${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)", Ok(()) } } - - - impl ComputedValueAsSpecified for SpecifiedValue { } + <%helpers:vector_longhand name="-moz-context-properties" animation_value_type="none" products="gecko" From 83cddadedc9f664aacd44d0b412e78234d39be70 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 11 Sep 2017 16:35:11 +0200 Subject: [PATCH 06/10] Do not use CVAS for the quotes property --- components/style/properties/longhand/list.mako.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/components/style/properties/longhand/list.mako.rs b/components/style/properties/longhand/list.mako.rs index 01f4b6145bf..10d81fc4691 100644 --- a/components/style/properties/longhand/list.mako.rs +++ b/components/style/properties/longhand/list.mako.rs @@ -141,18 +141,15 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu use cssparser::serialize_string; use std::fmt; use style_traits::ToCss; - use values::computed::ComputedValueAsSpecified; pub use self::computed_value::T as SpecifiedValue; pub mod computed_value { - #[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - pub struct T(pub Vec<(String,String)>); + #[derive(Clone, Debug, PartialEq, ToComputedValue)] + pub struct T(pub Vec<(String, String)>); } - impl ComputedValueAsSpecified for SpecifiedValue {} - impl ToCss for SpecifiedValue { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { if self.0.is_empty() { From 6ac5e94f467439fe9a9899d8b6876622bff51882 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 11 Sep 2017 16:35:11 +0200 Subject: [PATCH 07/10] Do not use CVAS for the cursor property --- components/style/properties/longhand/pointing.mako.rs | 9 +++------ components/style/values/computed/mod.rs | 2 ++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/components/style/properties/longhand/pointing.mako.rs b/components/style/properties/longhand/pointing.mako.rs index 121e5193b4c..0965640482e 100644 --- a/components/style/properties/longhand/pointing.mako.rs +++ b/components/style/properties/longhand/pointing.mako.rs @@ -9,12 +9,9 @@ <%helpers:longhand name="cursor" boxed="${product == 'gecko'}" animation_value_type="discrete" spec="https://drafts.csswg.org/css-ui/#cursor"> pub use self::computed_value::T as SpecifiedValue; - use values::computed::ComputedValueAsSpecified; #[cfg(feature = "gecko")] use values::specified::url::SpecifiedUrl; - impl ComputedValueAsSpecified for SpecifiedValue {} - pub mod computed_value { #[cfg(feature = "gecko")] use std::fmt; @@ -25,7 +22,7 @@ use values::specified::url::SpecifiedUrl; #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - #[derive(Clone, Copy, Debug, PartialEq, ToCss)] + #[derive(Clone, Copy, Debug, PartialEq, ToComputedValue, ToCss)] pub enum Keyword { Auto, Cursor(Cursor), @@ -35,14 +32,14 @@ pub type T = Keyword; #[cfg(feature = "gecko")] - #[derive(Clone, Debug, PartialEq)] + #[derive(Clone, Debug, PartialEq, ToComputedValue)] pub struct Image { pub url: SpecifiedUrl, pub hotspot: Option<(f32, f32)>, } #[cfg(feature = "gecko")] - #[derive(Clone, Debug, PartialEq)] + #[derive(Clone, Debug, PartialEq, ToComputedValue)] pub struct T { pub images: Vec, pub keyword: Keyword, diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index 46191a30400..339417ff2e7 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -19,6 +19,7 @@ use std::fmt; #[cfg(feature = "servo")] use std::sync::Arc; use style_traits::ToCss; +use style_traits::cursor::Cursor; use super::{CSSFloat, CSSInteger}; use super::generics::{GreaterThanOrEqualToOne, NonNegative}; use super::generics::grid::{GridLine as GenericGridLine, TrackBreadth as GenericTrackBreadth}; @@ -340,6 +341,7 @@ trivial_to_computed_value!(u8); trivial_to_computed_value!(u16); trivial_to_computed_value!(Atom); trivial_to_computed_value!(BorderStyle); +trivial_to_computed_value!(Cursor); trivial_to_computed_value!(Namespace); trivial_to_computed_value!(String); From 4f36b30e3418616adaadee8d6134249f25331b59 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 11 Sep 2017 16:35:11 +0200 Subject: [PATCH 08/10] Do not use CVAS for the text-decoration-line property --- components/style/properties/longhand/text.mako.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/components/style/properties/longhand/text.mako.rs b/components/style/properties/longhand/text.mako.rs index 0bb640e02e2..78d98d63791 100644 --- a/components/style/properties/longhand/text.mako.rs +++ b/components/style/properties/longhand/text.mako.rs @@ -146,12 +146,10 @@ ${helpers.single_keyword("unicode-bidi", spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-line"> use std::fmt; use style_traits::ToCss; - use values::computed::ComputedValueAsSpecified; - - impl ComputedValueAsSpecified for SpecifiedValue {} bitflags! { #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(ToComputedValue)] pub flags SpecifiedValue: u8 { const NONE = 0, const UNDERLINE = 0x01, From b16c2572a9a5faa56c7c4f94b7693a72c4a53c23 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 11 Sep 2017 16:35:11 +0200 Subject: [PATCH 09/10] Do not use CVAS for the -moz-force-broken-image-icon property --- components/style/properties/longhand/ui.mako.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/components/style/properties/longhand/ui.mako.rs b/components/style/properties/longhand/ui.mako.rs index c33f41a654e..2e3f52d12be 100644 --- a/components/style/properties/longhand/ui.mako.rs +++ b/components/style/properties/longhand/ui.mako.rs @@ -49,12 +49,10 @@ ${helpers.single_keyword("-moz-window-shadow", "none default menu tooltip sheet" spec="None (Nonstandard Firefox-only property)"> use std::fmt; use style_traits::ToCss; - use values::computed::ComputedValueAsSpecified; - pub mod computed_value { - #[derive(Clone, Copy, Debug, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] + #[derive(Clone, Copy, Debug, PartialEq, ToComputedValue)] pub struct T(pub bool); } @@ -76,8 +74,6 @@ ${helpers.single_keyword("-moz-window-shadow", "none default menu tooltip sheet" computed_value::T(false) } - impl ComputedValueAsSpecified for SpecifiedValue {} - pub fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>) -> Result> { match input.expect_integer()? { From 3fb52a0ef90dd8f2433e3ce0fd606412430225d5 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Mon, 11 Sep 2017 16:47:01 +0200 Subject: [PATCH 10/10] Do not use CVAS for gecko::SpecifiedUrl --- components/style/gecko/url.rs | 1 + components/style/values/specified/mod.rs | 6 ------ 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/components/style/gecko/url.rs b/components/style/gecko/url.rs index b206ad761e7..0c2348fbaa2 100644 --- a/components/style/gecko/url.rs +++ b/components/style/gecko/url.rs @@ -30,6 +30,7 @@ pub struct SpecifiedUrl { /// a property with this specified url value. pub image_value: Option>, } +trivial_to_computed_value!(SpecifiedUrl); impl SpecifiedUrl { /// Try to parse a URL from a string value that is a valid CSS token for a diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 9efed2e144f..2b08912f73e 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -83,8 +83,6 @@ pub mod url { use cssparser::Parser; use parser::{Parse, ParserContext}; use style_traits::ParseError; -#[cfg(feature = "gecko")] -use values::computed::ComputedValueAsSpecified; #[cfg(feature = "servo")] pub use ::servo::url::*; @@ -99,10 +97,6 @@ impl Parse for SpecifiedUrl { } impl Eq for SpecifiedUrl {} - -#[cfg(feature = "gecko")] -impl ComputedValueAsSpecified for SpecifiedUrl {} - } /// Parse an `` value, handling `calc()` correctly.