From 36ff89bd28d4ad0d1fbbb88488846fa4aa0fcd70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Tue, 29 Aug 2017 23:45:45 +0200 Subject: [PATCH] style: Remove HasViewportPercentage. It's not needed since #18268 --- components/style/custom_properties.rs | 8 +-- components/style/macros.rs | 7 +-- components/style/properties/helpers.mako.rs | 8 +-- .../helpers/animated_properties.mako.rs | 1 - .../properties/longhand/background.mako.rs | 1 - .../style/properties/longhand/border.mako.rs | 2 - .../style/properties/longhand/box.mako.rs | 14 +---- .../style/properties/longhand/color.mako.rs | 1 - .../properties/longhand/counters.mako.rs | 2 - .../style/properties/longhand/font.mako.rs | 27 +-------- .../properties/longhand/inherited_box.mako.rs | 2 - .../properties/longhand/inherited_svg.mako.rs | 2 - .../longhand/inherited_table.mako.rs | 2 +- .../longhand/inherited_text.mako.rs | 6 -- .../style/properties/longhand/list.mako.rs | 3 - .../properties/longhand/pointing.mako.rs | 1 - .../properties/longhand/position.mako.rs | 2 - .../style/properties/longhand/table.mako.rs | 1 - .../style/properties/longhand/text.mako.rs | 2 - .../style/properties/longhand/ui.mako.rs | 1 - .../style/properties/properties.mako.rs | 35 +---------- components/style/values/computed/angle.rs | 2 +- .../style/values/computed/percentage.rs | 2 +- .../style/values/generics/background.rs | 2 +- .../style/values/generics/basic_shape.rs | 7 +-- components/style/values/generics/border.rs | 8 +-- components/style/values/generics/counters.rs | 6 +- components/style/values/generics/effects.rs | 6 +- components/style/values/generics/flex.rs | 2 +- components/style/values/generics/gecko.rs | 2 +- components/style/values/generics/grid.rs | 5 +- components/style/values/generics/image.rs | 30 +++------- components/style/values/generics/mod.rs | 5 +- components/style/values/generics/position.rs | 2 +- components/style/values/generics/rect.rs | 2 +- components/style/values/generics/svg.rs | 8 +-- components/style/values/generics/text.rs | 6 +- components/style/values/generics/transform.rs | 10 +--- components/style/values/mod.rs | 5 +- components/style/values/specified/align.rs | 4 -- components/style/values/specified/angle.rs | 2 +- components/style/values/specified/border.rs | 2 +- components/style/values/specified/calc.rs | 9 +-- components/style/values/specified/color.rs | 2 - components/style/values/specified/effects.rs | 2 +- components/style/values/specified/grid.rs | 37 +----------- components/style/values/specified/image.rs | 4 +- components/style/values/specified/length.rs | 29 +++------ components/style/values/specified/mod.rs | 8 +-- .../style/values/specified/percentage.rs | 1 - components/style/values/specified/position.rs | 14 +---- components/style/values/specified/svg.rs | 1 - components/style/values/specified/time.rs | 4 +- .../style/values/specified/transform.rs | 2 +- .../style_derive/has_viewport_percentage.rs | 42 ------------- components/style_derive/lib.rs | 7 --- components/style_traits/lib.rs | 1 - components/style_traits/viewport.rs | 60 ------------------- tests/unit/style/parsing/value.rs | 13 +--- tests/unit/style/properties/mod.rs | 1 - tests/unit/style/properties/viewport.rs | 27 --------- 61 files changed, 73 insertions(+), 437 deletions(-) delete mode 100644 components/style_derive/has_viewport_percentage.rs delete mode 100644 tests/unit/style/properties/viewport.rs diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index c4d979f7a7c..f52495120f4 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -17,7 +17,7 @@ use std::borrow::{Borrow, Cow}; use std::collections::{HashMap, HashSet}; use std::fmt; use std::hash::Hash; -use style_traits::{HasViewportPercentage, ToCss, StyleParseError, ParseError}; +use style_traits::{ToCss, StyleParseError, ParseError}; /// A custom property name is just an `Atom`. /// @@ -51,12 +51,6 @@ pub struct SpecifiedValue { references: HashSet, } -impl HasViewportPercentage for SpecifiedValue { - fn has_viewport_percentage(&self) -> bool { - panic!("has_viewport_percentage called before resolving!"); - } -} - /// This struct is a cheap borrowed version of a `SpecifiedValue`. pub struct BorrowedSpecifiedValue<'a> { css: &'a str, diff --git a/components/style/macros.rs b/components/style/macros.rs index c766d414001..12be15a182a 100644 --- a/components/style/macros.rs +++ b/components/style/macros.rs @@ -57,9 +57,8 @@ macro_rules! define_numbered_css_keyword_enum { } } -/// A macro for implementing `ComputedValueAsSpecified`, `Parse` -/// and `HasViewportPercentage` traits for the enums defined -/// using `define_css_keyword_enum` macro. +/// A macro for implementing `ComputedValueAsSpecified`, and `Parse` traits for +/// the enums defined using `define_css_keyword_enum` macro. /// /// NOTE: We should either move `Parse` trait to `style_traits` /// or `define_css_keyword_enum` macro to this crate, but that @@ -76,7 +75,6 @@ macro_rules! add_impls_for_keyword_enum { } impl $crate::values::computed::ComputedValueAsSpecified for $name {} - no_viewport_percentage!($name); }; } @@ -104,6 +102,5 @@ macro_rules! define_keyword_type { impl $crate::values::computed::ComputedValueAsSpecified for $name {} impl $crate::values::animated::AnimatedValueAsComputed for $name {} - no_viewport_percentage!($name); }; } diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index ec22cabd352..76c78e40e24 100644 --- a/components/style/properties/helpers.mako.rs +++ b/components/style/properties/helpers.mako.rs @@ -83,8 +83,6 @@ #[allow(unused_imports)] use smallvec::SmallVec; use std::fmt; - #[allow(unused_imports)] - use style_traits::HasViewportPercentage; use style_traits::{Separator, ToCss}; pub mod single_value { @@ -179,7 +177,7 @@ } /// The specified value of ${name}. - #[derive(Clone, Debug, HasViewportPercentage, PartialEq)] + #[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedValue(pub Vec); @@ -420,7 +418,6 @@ %> <%call expr="longhand(name, keyword=Keyword(name, values, **keyword_kwargs), **kwargs)"> use properties::longhands::system_font::SystemFont; - no_viewport_percentage!(SpecifiedValue); pub mod computed_value { use cssparser::Parser; @@ -529,7 +526,6 @@ impl ComputedValueAsSpecified for SpecifiedValue {} % endif - no_viewport_percentage!(SpecifiedValue); @@ -948,7 +944,7 @@ } #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - #[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)] + #[derive(Clone, Debug, PartialEq, ToCss)] pub struct SpecifiedValue(pub ${length_type}); % if length_type == "MozLength": diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index 4c2057f61d9..b2299d7f436 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -214,7 +214,6 @@ pub enum TransitionProperty { Unsupported(CustomIdent) } -no_viewport_percentage!(TransitionProperty); impl ComputedValueAsSpecified for TransitionProperty {} diff --git a/components/style/properties/longhand/background.mako.rs b/components/style/properties/longhand/background.mako.rs index f70ef7e06d4..5e608315f19 100644 --- a/components/style/properties/longhand/background.mako.rs +++ b/components/style/properties/longhand/background.mako.rs @@ -69,7 +69,6 @@ ${helpers.predefined_type("background-image", "ImageLayer", pub struct T(pub RepeatKeyword, pub RepeatKeyword); } - no_viewport_percentage!(SpecifiedValue); impl ToCss for computed_value::T { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { diff --git a/components/style/properties/longhand/border.mako.rs b/components/style/properties/longhand/border.mako.rs index f4326fc0399..b6dd5338938 100644 --- a/components/style/properties/longhand/border.mako.rs +++ b/components/style/properties/longhand/border.mako.rs @@ -78,7 +78,6 @@ ${helpers.gecko_keyword_conversion(Keyword('border-style', use std::fmt; use style_traits::ToCss; use values::specified::RGBAColor; - no_viewport_percentage!(SpecifiedValue); pub mod computed_value { use cssparser::RGBA; @@ -230,7 +229,6 @@ ${helpers.predefined_type("border-image-outset", "LengthOrNumberRect", spec="https://drafts.csswg.org/css-backgrounds/#border-image-repeat"> use style_traits::ToCss; - no_viewport_percentage!(SpecifiedValue); pub mod computed_value { pub use super::RepeatKeyword; diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index ae22a94dc4f..b900da81584 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -36,7 +36,6 @@ %> use values::computed::ComputedValueAsSpecified; use style_traits::ToCss; - no_viewport_percentage!(SpecifiedValue); pub mod computed_value { pub use super::SpecifiedValue as T; @@ -222,7 +221,6 @@ ${helpers.single_keyword("position", "static absolute relative fixed", gecko_pref_ident="float_" flags="APPLIES_TO_FIRST_LETTER" spec="https://drafts.csswg.org/css-box/#propdef-float"> - no_viewport_percentage!(SpecifiedValue); impl ToComputedValue for SpecifiedValue { type ComputedValue = computed_value::T; @@ -261,7 +259,6 @@ ${helpers.single_keyword("position", "static absolute relative fixed", gecko_enum_prefix="StyleClear" gecko_ffi_name="mBreakType" spec="https://www.w3.org/TR/CSS2/visuren.html#flow-control"> - no_viewport_percentage!(SpecifiedValue); impl ToComputedValue for SpecifiedValue { type ComputedValue = computed_value::T; @@ -327,7 +324,7 @@ ${helpers.single_keyword("position", "static absolute relative fixed", /// The `vertical-align` value. #[allow(non_camel_case_types)] - #[derive(Clone, Debug, HasViewportPercentage, PartialEq)] + #[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum SpecifiedValue { % for keyword in vertical_align_keywords: @@ -571,7 +568,6 @@ ${helpers.predefined_type("transition-delay", } } } - no_viewport_percentage!(SpecifiedValue); pub fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result> { @@ -641,7 +637,6 @@ ${helpers.predefined_type("animation-timing-function", } } - no_viewport_percentage!(SpecifiedValue); #[inline] pub fn get_initial_value() -> computed_value::T { @@ -842,7 +837,7 @@ ${helpers.predefined_type( /// Multiple transform functions compose a transformation. /// /// Some transformations can be expressed by other more general functions. - #[derive(Clone, Debug, HasViewportPercentage, PartialEq)] + #[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum SpecifiedOperation { /// Represents a 2D 2x3 matrix. @@ -991,7 +986,7 @@ ${helpers.predefined_type( } } - #[derive(Clone, Debug, HasViewportPercentage, PartialEq)] + #[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedValue(Vec); @@ -1705,7 +1700,6 @@ ${helpers.predefined_type("transform-origin", use values::computed::ComputedValueAsSpecified; impl ComputedValueAsSpecified for SpecifiedValue {} - no_viewport_percentage!(SpecifiedValue); pub mod computed_value { pub type T = super::SpecifiedValue; @@ -1850,7 +1844,6 @@ ${helpers.single_keyword("-moz-orient", use values::computed::ComputedValueAsSpecified; impl ComputedValueAsSpecified for SpecifiedValue {} - no_viewport_percentage!(SpecifiedValue); pub mod computed_value { pub use super::SpecifiedValue as T; @@ -1924,7 +1917,6 @@ ${helpers.predefined_type( use values::computed::ComputedValueAsSpecified; impl ComputedValueAsSpecified for SpecifiedValue {} - no_viewport_percentage!(SpecifiedValue); pub mod computed_value { pub use super::SpecifiedValue as T; diff --git a/components/style/properties/longhand/color.mako.rs b/components/style/properties/longhand/color.mako.rs index 9ee704f1424..a2c2c61a33e 100644 --- a/components/style/properties/longhand/color.mako.rs +++ b/components/style/properties/longhand/color.mako.rs @@ -34,7 +34,6 @@ #[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[derive(Clone, Debug, PartialEq, ToCss)] pub struct SpecifiedValue(pub Color); - no_viewport_percentage!(SpecifiedValue); pub mod computed_value { use cssparser; diff --git a/components/style/properties/longhand/counters.mako.rs b/components/style/properties/longhand/counters.mako.rs index 12a4d8d4413..190351895c7 100644 --- a/components/style/properties/longhand/counters.mako.rs +++ b/components/style/properties/longhand/counters.mako.rs @@ -23,7 +23,6 @@ pub use self::computed_value::ContentItem; impl ComputedValueAsSpecified for SpecifiedValue {} - no_viewport_percentage!(SpecifiedValue); pub mod computed_value { use cssparser; @@ -296,7 +295,6 @@ computed_value::T(Vec::new()) } - no_viewport_percentage!(SpecifiedValue); impl ToCss for SpecifiedValue { fn to_css(&self, dest: &mut W) -> fmt::Result diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs index 7dc51dca3d4..5d849c746cf 100644 --- a/components/style/properties/longhand/font.mako.rs +++ b/components/style/properties/longhand/font.mako.rs @@ -76,7 +76,6 @@ macro_rules! impl_gecko_keyword_conversions { use std::fmt; use style_traits::ToCss; - no_viewport_percentage!(SpecifiedValue); pub mod computed_value { use cssparser::{CssStringWriter, Parser, serialize_identifier}; @@ -430,7 +429,6 @@ ${helpers.single_keyword_system("font-variant-caps", spec="https://drafts.csswg.org/css-fonts/#propdef-font-weight"> use properties::longhands::system_font::SystemFont; - no_viewport_percentage!(SpecifiedValue); #[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[derive(Clone, Copy, Debug, Eq, PartialEq, ToCss)] @@ -597,7 +595,7 @@ ${helpers.single_keyword_system("font-variant-caps", use app_units::Au; use properties::longhands::system_font::SystemFont; use std::fmt; - use style_traits::{HasViewportPercentage, ToCss}; + use style_traits::ToCss; use values::FONT_MEDIUM_PX; use values::computed::NonNegativeAu; use values::specified::{AllowQuirks, FontRelativeLength, LengthOrPercentage, NoCalcLength}; @@ -615,15 +613,6 @@ ${helpers.single_keyword_system("font-variant-caps", } } - impl HasViewportPercentage for SpecifiedValue { - fn has_viewport_percentage(&self) -> bool { - match *self { - SpecifiedValue::Length(ref lop) => lop.has_viewport_percentage(), - _ => false - } - } - } - #[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum SpecifiedValue { @@ -1068,7 +1057,6 @@ ${helpers.single_keyword_system("font-variant-caps", spec="https://drafts.csswg.org/css-fonts/#propdef-font-size-adjust"> use properties::longhands::system_font::SystemFont; - no_viewport_percentage!(SpecifiedValue); #[derive(Clone, Copy, Debug, PartialEq, ToCss)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] @@ -1190,7 +1178,6 @@ ${helpers.single_keyword_system("font-variant-caps", use values::computed::ComputedValueAsSpecified; impl ComputedValueAsSpecified for SpecifiedValue {} - no_viewport_percentage!(SpecifiedValue); pub mod computed_value { pub use super::SpecifiedValue as T; @@ -1302,7 +1289,6 @@ ${helpers.single_keyword_system("font-kerning", use style_traits::ToCss; use values::CustomIdent; - no_viewport_percentage!(SpecifiedValue); #[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] @@ -1512,7 +1498,6 @@ macro_rules! exclusive_value { use std::fmt; use style_traits::ToCss; - no_viewport_percentage!(SpecifiedValue); bitflags! { #[cfg_attr(feature = "servo", derive(HeapSizeOf))] @@ -1658,7 +1643,6 @@ macro_rules! exclusive_value { use std::fmt; use style_traits::ToCss; - no_viewport_percentage!(SpecifiedValue); bitflags! { #[cfg_attr(feature = "servo", derive(HeapSizeOf))] @@ -1818,7 +1802,6 @@ macro_rules! exclusive_value { use std::fmt; use style_traits::ToCss; - no_viewport_percentage!(SpecifiedValue); bitflags! { #[cfg_attr(feature = "servo", derive(HeapSizeOf))] @@ -1981,7 +1964,6 @@ ${helpers.single_keyword_system("font-variant-position", Value(computed_value::T), System(SystemFont) } - no_viewport_percentage!(SpecifiedValue); <%self:simple_system_boilerplate name="font_feature_settings"> @@ -2023,7 +2005,6 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control- pub type SpecifiedValue = computed_value::T; - no_viewport_percentage!(SpecifiedValue); pub mod computed_value { @@ -2051,7 +2032,6 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control- use std::fmt; use style_traits::ToCss; use byteorder::{BigEndian, ByteOrder}; - no_viewport_percentage!(SpecifiedValue); #[derive(Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] @@ -2209,7 +2189,6 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control- pub use self::computed_value::T as SpecifiedValue; impl ComputedValueAsSpecified for SpecifiedValue {} - no_viewport_percentage!(SpecifiedValue); pub mod computed_value { use Atom; @@ -2269,7 +2248,6 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control- use std::fmt; use style_traits::ToCss; - no_viewport_percentage!(SpecifiedValue); pub mod computed_value { pub type T = i8; @@ -2369,7 +2347,7 @@ ${helpers.single_keyword("-moz-math-variant", use gecko_bindings::structs::NS_MATHML_DEFAULT_SCRIPT_MIN_SIZE_PT; use values::specified::length::{AU_PER_PT, FontBaseSize, NoCalcLength}; - #[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)] + #[derive(Clone, Debug, PartialEq, ToCss)] pub struct SpecifiedValue(pub NoCalcLength); pub mod computed_value { @@ -2418,7 +2396,6 @@ ${helpers.single_keyword("-moz-math-variant", pub use self::computed_value::T as SpecifiedValue; impl ComputedValueAsSpecified for SpecifiedValue {} - no_viewport_percentage!(SpecifiedValue); pub mod computed_value { use std::fmt; diff --git a/components/style/properties/longhand/inherited_box.mako.rs b/components/style/properties/longhand/inherited_box.mako.rs index 32c9c4440ce..16779dfbf03 100644 --- a/components/style/properties/longhand/inherited_box.mako.rs +++ b/components/style/properties/longhand/inherited_box.mako.rs @@ -66,7 +66,6 @@ ${helpers.single_keyword("image-rendering", use style_traits::ToCss; use values::specified::Angle; - no_viewport_percentage!(SpecifiedValue); use std::f64::consts::PI; const TWO_PI: f64 = 2.0 * PI; @@ -259,7 +258,6 @@ ${helpers.single_keyword("image-rendering", use style_traits::ToCss; use values::computed::ComputedValueAsSpecified; - no_viewport_percentage!(SpecifiedValue); #[derive(Clone, Copy, Debug, Eq, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] diff --git a/components/style/properties/longhand/inherited_svg.mako.rs b/components/style/properties/longhand/inherited_svg.mako.rs index 36ad2598a7b..9b05707f33c 100644 --- a/components/style/properties/longhand/inherited_svg.mako.rs +++ b/components/style/properties/longhand/inherited_svg.mako.rs @@ -259,7 +259,6 @@ ${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)", } } - no_viewport_percentage!(SpecifiedValue); impl ComputedValueAsSpecified for SpecifiedValue { } @@ -271,7 +270,6 @@ ${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)", use values::CustomIdent; use values::computed::ComputedValueAsSpecified; - no_viewport_percentage!(SpecifiedValue); impl ComputedValueAsSpecified for SpecifiedValue { } diff --git a/components/style/properties/longhand/inherited_table.mako.rs b/components/style/properties/longhand/inherited_table.mako.rs index b98cab4204a..c7e060124bf 100644 --- a/components/style/properties/longhand/inherited_table.mako.rs +++ b/components/style/properties/longhand/inherited_table.mako.rs @@ -60,7 +60,7 @@ ${helpers.single_keyword("caption-side", "top bottom", } #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - #[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)] + #[derive(Clone, Debug, PartialEq, ToCss)] pub struct SpecifiedValue { pub horizontal: NonNegativeLength, pub vertical: Option, diff --git a/components/style/properties/longhand/inherited_text.mako.rs b/components/style/properties/longhand/inherited_text.mako.rs index 0e74957c499..346d864b3bb 100644 --- a/components/style/properties/longhand/inherited_text.mako.rs +++ b/components/style/properties/longhand/inherited_text.mako.rs @@ -70,7 +70,6 @@ ${helpers.single_keyword("word-break", animation_value_type="discrete" flags="APPLIES_TO_PLACEHOLDER", spec="https://drafts.csswg.org/css-text/#propdef-text-justify"> - no_viewport_percentage!(SpecifiedValue); impl ToComputedValue for SpecifiedValue { type ComputedValue = computed_value::T; @@ -114,7 +113,6 @@ ${helpers.single_keyword("text-align-last", <%helpers:longhand name="text-align" animation_value_type="discrete" flags="APPLIES_TO_PLACEHOLDER" spec="https://drafts.csswg.org/css-text/#propdef-text-align"> - no_viewport_percentage!(SpecifiedValue); pub mod computed_value { use style_traits::ToCss; macro_rules! define_text_align { @@ -292,7 +290,6 @@ ${helpers.predefined_type("word-spacing", use values::computed::ComputedValueAsSpecified; impl ComputedValueAsSpecified for SpecifiedValue {} - no_viewport_percentage!(SpecifiedValue); #[derive(Clone, Copy, Debug, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] @@ -379,7 +376,6 @@ ${helpers.predefined_type("word-spacing", spec="https://drafts.csswg.org/css-text/#propdef-white-space"> use values::computed::ComputedValueAsSpecified; impl ComputedValueAsSpecified for SpecifiedValue {} - no_viewport_percentage!(SpecifiedValue); % if product != "gecko": impl SpecifiedValue { @@ -435,7 +431,6 @@ ${helpers.predefined_type( use style_traits::ToCss; use unicode_segmentation::UnicodeSegmentation; - no_viewport_percentage!(SpecifiedValue); pub mod computed_value { #[cfg_attr(feature = "servo", derive(HeapSizeOf))] @@ -638,7 +633,6 @@ ${helpers.predefined_type( } impl ComputedValueAsSpecified for SpecifiedValue {} - no_viewport_percentage!(SpecifiedValue); pub fn get_initial_value() -> computed_value::T { SpecifiedValue(HorizontalWritingModeValue::Over, VerticalWritingModeValue::Right) diff --git a/components/style/properties/longhand/list.mako.rs b/components/style/properties/longhand/list.mako.rs index f18d92ebb13..2540922ca2e 100644 --- a/components/style/properties/longhand/list.mako.rs +++ b/components/style/properties/longhand/list.mako.rs @@ -50,7 +50,6 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu } impl ComputedValueAsSpecified for SpecifiedValue {} - no_viewport_percentage!(SpecifiedValue); #[cfg(feature = "gecko")] impl SpecifiedValue { @@ -116,7 +115,6 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu impl ComputedValueAsSpecified for SpecifiedValue {} - no_viewport_percentage!(SpecifiedValue); #[inline] pub fn get_initial_value() -> computed_value::T { @@ -157,7 +155,6 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu } impl ComputedValueAsSpecified for SpecifiedValue {} - no_viewport_percentage!(SpecifiedValue); impl ToCss for SpecifiedValue { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { diff --git a/components/style/properties/longhand/pointing.mako.rs b/components/style/properties/longhand/pointing.mako.rs index dd8f40fd76f..121e5193b4c 100644 --- a/components/style/properties/longhand/pointing.mako.rs +++ b/components/style/properties/longhand/pointing.mako.rs @@ -14,7 +14,6 @@ use values::specified::url::SpecifiedUrl; impl ComputedValueAsSpecified for SpecifiedValue {} - no_viewport_percentage!(SpecifiedValue); pub mod computed_value { #[cfg(feature = "gecko")] diff --git a/components/style/properties/longhand/position.mako.rs b/components/style/properties/longhand/position.mako.rs index 68f3c0b2719..03c5d155588 100644 --- a/components/style/properties/longhand/position.mako.rs +++ b/components/style/properties/longhand/position.mako.rs @@ -311,7 +311,6 @@ ${helpers.predefined_type("object-position", } } - no_viewport_percentage!(SpecifiedValue); impl ComputedValueAsSpecified for SpecifiedValue {} impl ToCss for computed_value::T { @@ -454,7 +453,6 @@ ${helpers.predefined_type("object-position", pub columns: Range, } - no_viewport_percentage!(TemplateAreas); impl ComputedValueAsSpecified for TemplateAreas {} impl Parse for TemplateAreas { diff --git a/components/style/properties/longhand/table.mako.rs b/components/style/properties/longhand/table.mako.rs index 48984916fd6..68f40e22d37 100644 --- a/components/style/properties/longhand/table.mako.rs +++ b/components/style/properties/longhand/table.mako.rs @@ -17,7 +17,6 @@ ${helpers.single_keyword("table-layout", "auto fixed", use values::computed::ComputedValueAsSpecified; impl ComputedValueAsSpecified for SpecifiedValue {} - no_viewport_percentage!(SpecifiedValue); pub type SpecifiedValue = computed_value::T; pub mod computed_value { use std::fmt; diff --git a/components/style/properties/longhand/text.mako.rs b/components/style/properties/longhand/text.mako.rs index 2f39d38302c..0bb640e02e2 100644 --- a/components/style/properties/longhand/text.mako.rs +++ b/components/style/properties/longhand/text.mako.rs @@ -18,7 +18,6 @@ use std::fmt; use style_traits::ToCss; - no_viewport_percentage!(SpecifiedValue); #[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[derive(Clone, Debug, Eq, PartialEq, ToCss)] @@ -150,7 +149,6 @@ ${helpers.single_keyword("unicode-bidi", use values::computed::ComputedValueAsSpecified; impl ComputedValueAsSpecified for SpecifiedValue {} - no_viewport_percentage!(SpecifiedValue); bitflags! { #[cfg_attr(feature = "servo", derive(HeapSizeOf))] diff --git a/components/style/properties/longhand/ui.mako.rs b/components/style/properties/longhand/ui.mako.rs index 1663c379e3c..c33f41a654e 100644 --- a/components/style/properties/longhand/ui.mako.rs +++ b/components/style/properties/longhand/ui.mako.rs @@ -51,7 +51,6 @@ ${helpers.single_keyword("-moz-window-shadow", "none default menu tooltip sheet" use style_traits::ToCss; use values::computed::ComputedValueAsSpecified; - no_viewport_percentage!(SpecifiedValue); pub mod computed_value { #[derive(Clone, Copy, Debug, PartialEq)] diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index c351ac218eb..a45c9937821 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -36,7 +36,7 @@ use selector_parser::PseudoElement; use selectors::parser::SelectorParseError; #[cfg(feature = "servo")] use servo_config::prefs::PREFS; use shared_lock::StylesheetGuards; -use style_traits::{PARSING_MODE_DEFAULT, HasViewportPercentage, ToCss, ParseError}; +use style_traits::{PARSING_MODE_DEFAULT, ToCss, ParseError}; use style_traits::{PropertyDeclarationParseError, StyleParseError, ValueParseError}; use stylesheets::{CssRuleType, MallocSizeOf, MallocSizeOfFn, Origin, UrlExtraData}; #[cfg(feature = "servo")] use values::Either; @@ -873,19 +873,6 @@ impl UnparsedValue { } } -impl<'a, T: HasViewportPercentage> HasViewportPercentage for DeclaredValue<'a, T> { - fn has_viewport_percentage(&self) -> bool { - match *self { - DeclaredValue::Value(ref v) => v.has_viewport_percentage(), - DeclaredValue::WithVariables(_) => { - panic!("DeclaredValue::has_viewport_percentage without \ - resolving variables!") - }, - DeclaredValue::CSSWideKeyword(_) => false, - } - } -} - impl<'a, T: ToCss> ToCss for DeclaredValue<'a, T> { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write, @@ -1299,26 +1286,6 @@ pub enum PropertyDeclaration { Custom(::custom_properties::Name, DeclaredValueOwned>), } -impl HasViewportPercentage for PropertyDeclaration { - fn has_viewport_percentage(&self) -> bool { - match *self { - % for property in data.longhands: - PropertyDeclaration::${property.camel_case}(ref val) => { - val.has_viewport_percentage() - }, - % endfor - PropertyDeclaration::WithVariables(..) => { - panic!("DeclaredValue::has_viewport_percentage without \ - resolving variables!") - }, - PropertyDeclaration::CSSWideKeyword(..) => false, - PropertyDeclaration::Custom(_, ref val) => { - val.borrow().has_viewport_percentage() - } - } - } -} - impl fmt::Debug for PropertyDeclaration { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.id().to_css(f)?; diff --git a/components/style/values/computed/angle.rs b/components/style/values/computed/angle.rs index 467a9501196..9dd159354ff 100644 --- a/components/style/values/computed/angle.rs +++ b/components/style/values/computed/angle.rs @@ -14,7 +14,7 @@ use values::distance::{ComputeSquaredDistance, SquaredDistance}; /// A computed angle. #[animate(fallback = "Self::animate_fallback")] #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] -#[derive(Animate, Clone, Copy, Debug, HasViewportPercentage, PartialEq)] +#[derive(Animate, Clone, Copy, Debug, PartialEq)] #[derive(PartialOrd, ToAnimatedZero)] pub enum Angle { /// An angle with degree unit. diff --git a/components/style/values/computed/percentage.rs b/components/style/values/computed/percentage.rs index 533bd751616..994d4fbbff9 100644 --- a/components/style/values/computed/percentage.rs +++ b/components/style/values/computed/percentage.rs @@ -11,7 +11,7 @@ use values::{CSSFloat, serialize_percentage}; /// A computed percentage. #[cfg_attr(feature = "servo", derive(Deserialize, HeapSizeOf, Serialize))] #[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, Default)] -#[derive(HasViewportPercentage, PartialEq, PartialOrd, ToAnimatedZero)] +#[derive(PartialEq, PartialOrd, ToAnimatedZero)] pub struct Percentage(pub CSSFloat); impl Percentage { diff --git a/components/style/values/generics/background.rs b/components/style/values/generics/background.rs index abcfb655eec..f9050469c74 100644 --- a/components/style/values/generics/background.rs +++ b/components/style/values/generics/background.rs @@ -7,7 +7,7 @@ /// A generic value for the `background-size` property. #[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug)] -#[derive(HasViewportPercentage, PartialEq, ToComputedValue, ToCss)] +#[derive(PartialEq, ToComputedValue, ToCss)] pub enum BackgroundSize { /// ` ` Explicit { diff --git a/components/style/values/generics/basic_shape.rs b/components/style/values/generics/basic_shape.rs index 019ed6599e2..1e892a781a4 100644 --- a/components/style/values/generics/basic_shape.rs +++ b/components/style/values/generics/basic_shape.rs @@ -6,7 +6,7 @@ //! types that are generic over their `ToCss` implementations. use std::fmt; -use style_traits::{HasViewportPercentage, ToCss}; +use style_traits::ToCss; use values::animated::{Animate, Procedure, ToAnimatedZero}; use values::computed::ComputedValueAsSpecified; use values::distance::{ComputeSquaredDistance, SquaredDistance}; @@ -159,11 +159,6 @@ impl ToAnimatedZero for ShapeSource { } } -impl HasViewportPercentage for ShapeSource { - #[inline] - fn has_viewport_percentage(&self) -> bool { false } -} - impl ToCss for InsetRect where L: ToCss + PartialEq { diff --git a/components/style/values/generics/border.rs b/components/style/values/generics/border.rs index 052ef579099..53d813f459b 100644 --- a/components/style/values/generics/border.rs +++ b/components/style/values/generics/border.rs @@ -11,7 +11,7 @@ use values::generics::rect::Rect; /// A generic value for a single side of a `border-image-width` property. #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue, ToCss)] pub enum BorderImageSideWidth { /// `` Length(LengthOrPercentage), @@ -22,7 +22,7 @@ pub enum BorderImageSideWidth { } /// A generic value for the `border-image-slice` property. -#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue)] +#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct BorderImageSlice { /// The offsets. @@ -35,7 +35,7 @@ pub struct BorderImageSlice { /// /// https://drafts.csswg.org/css-backgrounds-3/#border-radius #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, HasViewportPercentage)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug)] #[derive(PartialEq, ToComputedValue)] pub struct BorderRadius { /// The top left radius. @@ -50,7 +50,7 @@ pub struct BorderRadius { /// A generic value for `border-*-radius` longhand properties. #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, HasViewportPercentage)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug)] #[derive(PartialEq, ToComputedValue)] pub struct BorderCornerRadius(pub Size2D); diff --git a/components/style/values/generics/counters.rs b/components/style/values/generics/counters.rs index 180359af764..c6ea4425a39 100644 --- a/components/style/values/generics/counters.rs +++ b/components/style/values/generics/counters.rs @@ -5,7 +5,7 @@ //! Generic types for counters-related CSS values. use std::fmt; -use style_traits::{HasViewportPercentage, ToCss}; +use style_traits::ToCss; use values::CustomIdent; /// A generic value for the `counter-increment` property. @@ -22,10 +22,6 @@ impl CounterIncrement { } } -impl HasViewportPercentage for CounterIncrement { - #[inline] fn has_viewport_percentage(&self) -> bool { false } -} - impl ToCss for CounterIncrement where I: ToCss, diff --git a/components/style/values/generics/effects.rs b/components/style/values/generics/effects.rs index 5d95ae19a8f..b0f061e874e 100644 --- a/components/style/values/generics/effects.rs +++ b/components/style/values/generics/effects.rs @@ -11,7 +11,7 @@ use values::specified::url::SpecifiedUrl; /// A generic value for a single `box-shadow`. #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Animate, Clone, Debug, HasViewportPercentage, PartialEq)] +#[derive(Animate, Clone, Debug, PartialEq)] #[derive(ToAnimatedValue, ToAnimatedZero)] pub struct BoxShadow { /// The base shadow. @@ -25,7 +25,7 @@ pub struct BoxShadow { /// A generic value for a single `filter`. #[cfg_attr(feature = "servo", derive(Deserialize, HeapSizeOf, Serialize))] -#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToAnimatedValue, ToComputedValue, ToCss)] +#[derive(Clone, Debug, PartialEq, ToAnimatedValue, ToComputedValue, ToCss)] pub enum Filter { /// `blur()` #[css(function)] @@ -67,7 +67,7 @@ pub enum Filter { /// Contrary to the canonical order from the spec, the color is serialised /// first, like in Gecko and Webkit. #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Animate, Clone, ComputeSquaredDistance, Debug, HasViewportPercentage)] +#[derive(Animate, Clone, ComputeSquaredDistance, Debug)] #[derive(PartialEq, ToAnimatedValue, ToAnimatedZero, ToCss)] pub struct SimpleShadow { /// Color. diff --git a/components/style/values/generics/flex.rs b/components/style/values/generics/flex.rs index 3d7f2098fce..0ee864555de 100644 --- a/components/style/values/generics/flex.rs +++ b/components/style/values/generics/flex.rs @@ -8,7 +8,7 @@ use values::computed::Percentage; /// A generic value for the `flex-basis` property. #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue, ToCss)] pub enum FlexBasis { /// `auto` Auto, diff --git a/components/style/values/generics/gecko.rs b/components/style/values/generics/gecko.rs index 31c62078861..d450b138e38 100644 --- a/components/style/values/generics/gecko.rs +++ b/components/style/values/generics/gecko.rs @@ -6,7 +6,7 @@ //! unshipped at some point in the future. /// A generic value for scroll snap points. -#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue, ToCss)] pub enum ScrollSnapPoint { /// `none` None, diff --git a/components/style/values/generics/grid.rs b/components/style/values/generics/grid.rs index 4786174825d..95b7a50c728 100644 --- a/components/style/values/generics/grid.rs +++ b/components/style/values/generics/grid.rs @@ -130,7 +130,6 @@ impl Parse for GridLine { } impl ComputedValueAsSpecified for GridLine {} -no_viewport_percentage!(GridLine); define_css_keyword_enum!{ TrackKeyword: "auto" => Auto, @@ -182,7 +181,7 @@ impl ToCss for TrackBreadth { /// /// https://drafts.csswg.org/css-grid/#typedef-track-size #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Debug, HasViewportPercentage, PartialEq)] +#[derive(Clone, Debug, PartialEq)] pub enum TrackSize { /// A flexible `` Breadth(TrackBreadth), @@ -372,7 +371,6 @@ impl Parse for RepeatCount { } impl ComputedValueAsSpecified for RepeatCount {} -no_viewport_percentage!(RepeatCount); /// The structure containing `` and `` values. /// @@ -666,7 +664,6 @@ impl ToCss for LineNameList { } impl ComputedValueAsSpecified for LineNameList {} -no_viewport_percentage!(LineNameList); /// Variants for ` | ` /// Subgrid deferred to Level 2 spec due to lack of implementation. diff --git a/components/style/values/generics/image.rs b/components/style/values/generics/image.rs index 3e977759d70..b9c5a036697 100644 --- a/components/style/values/generics/image.rs +++ b/components/style/values/generics/image.rs @@ -10,7 +10,7 @@ use Atom; use cssparser::serialize_identifier; use custom_properties::SpecifiedValue; use std::fmt; -use style_traits::{HasViewportPercentage, ToCss}; +use style_traits::ToCss; use values::computed::ComputedValueAsSpecified; /// An [image]. @@ -36,7 +36,7 @@ pub enum Image { /// A CSS gradient. /// https://drafts.csswg.org/css-images/#gradients #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToComputedValue)] +#[derive(Clone, Debug, PartialEq, ToComputedValue)] pub struct Gradient { /// Gradients can be linear or radial. pub kind: GradientKind, @@ -50,7 +50,7 @@ pub struct Gradient { /// A linear gradient. Linear(LineDirection), @@ -73,7 +73,7 @@ pub enum GradientKind { /// A circular gradient. @@ -83,7 +83,7 @@ pub enum EndingShape { } /// A circle shape. -#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue)] +#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum Circle { /// A circle radius. @@ -93,7 +93,7 @@ pub enum Circle { } /// An ellipse shape. -#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue, ToCss)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum Ellipse { /// An ellipse pair of radii. @@ -111,13 +111,12 @@ define_css_keyword_enum!(ShapeExtent: "contain" => Contain, "cover" => Cover ); -no_viewport_percentage!(ShapeExtent); impl ComputedValueAsSpecified for ShapeExtent {} /// A gradient item. /// https://drafts.csswg.org/css-images-4/#color-stop-syntax #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue, ToCss)] pub enum GradientItem { /// A color stop. ColorStop(ColorStop), @@ -127,7 +126,7 @@ pub enum GradientItem { /// A color stop. /// https://drafts.csswg.org/css-images/#typedef-color-stop-list -#[derive(Clone, Copy, HasViewportPercentage, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, PartialEq, ToComputedValue, ToCss)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct ColorStop { /// The color of this stop. @@ -215,17 +214,6 @@ impl ToCss for Image } } -impl HasViewportPercentage for Image - where G: HasViewportPercentage -{ - fn has_viewport_percentage(&self) -> bool { - match *self { - Image::Gradient(ref gradient) => gradient.has_viewport_percentage(), - _ => false, - } - } -} - impl ToCss for Gradient where D: LineDirection, L: ToCss, LoP: ToCss, P: ToCss, C: ToCss, A: ToCss { diff --git a/components/style/values/generics/mod.rs b/components/style/values/generics/mod.rs index 0638743da61..bd2695813c1 100644 --- a/components/style/values/generics/mod.rs +++ b/components/style/values/generics/mod.rs @@ -92,7 +92,6 @@ impl CounterStyleOrNone { } } -no_viewport_percentage!(CounterStyleOrNone); impl Parse for CounterStyleOrNone { fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result> { @@ -268,12 +267,12 @@ impl ToCss for FontSettingTagFloat { /// A wrapper of Non-negative values. #[cfg_attr(feature = "servo", derive(Deserialize, HeapSizeOf, Serialize))] -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, HasViewportPercentage)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug)] #[derive(PartialEq, PartialOrd, ToAnimatedZero, ToComputedValue, ToCss)] pub struct NonNegative(pub T); /// A wrapper of greater-than-or-equal-to-one values. #[cfg_attr(feature = "servo", derive(Deserialize, HeapSizeOf, Serialize))] -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, HasViewportPercentage)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug)] #[derive(PartialEq, PartialOrd, ToAnimatedZero, ToComputedValue, ToCss)] pub struct GreaterThanOrEqualToOne(pub T); diff --git a/components/style/values/generics/position.rs b/components/style/values/generics/position.rs index 5a014ca62fd..5c1b2333559 100644 --- a/components/style/values/generics/position.rs +++ b/components/style/values/generics/position.rs @@ -8,7 +8,7 @@ /// A generic type for representing a CSS [position](https://drafts.csswg.org/css-values/#position). #[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug)] -#[derive(HasViewportPercentage, PartialEq, ToAnimatedZero, ToComputedValue)] +#[derive(PartialEq, ToAnimatedZero, ToComputedValue)] pub struct Position { /// The horizontal component of position. pub horizontal: H, diff --git a/components/style/values/generics/rect.rs b/components/style/values/generics/rect.rs index 7c5a7fabfb3..3b98fc664ec 100644 --- a/components/style/values/generics/rect.rs +++ b/components/style/values/generics/rect.rs @@ -13,7 +13,7 @@ use style_traits::{ToCss, ParseError}; /// serialize as few components as possible, like for example in `border-width`. #[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug)] -#[derive(HasViewportPercentage, PartialEq, ToComputedValue)] +#[derive(PartialEq, ToComputedValue)] pub struct Rect(pub T, pub T, pub T, pub T); impl Rect { diff --git a/components/style/values/generics/svg.rs b/components/style/values/generics/svg.rs index 87b0a74bc23..9b0f19ae4bc 100644 --- a/components/style/values/generics/svg.rs +++ b/components/style/values/generics/svg.rs @@ -104,7 +104,7 @@ impl Parse for SVGPaint | | for svg which allow unitless length. /// https://www.w3.org/TR/SVG11/painting.html#StrokeProperties #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToAnimatedValue)] +#[derive(Clone, Copy, Debug, PartialEq, ToAnimatedValue)] #[derive(ToAnimatedZero, ToComputedValue, ToCss)] pub enum SvgLengthOrPercentageOrNumber { /// | @@ -187,7 +187,7 @@ impl Parse for /// An SVG length value supports `context-value` in addition to length. #[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[derive(Clone, ComputeSquaredDistance, Copy, Debug, PartialEq)] -#[derive(HasViewportPercentage, ToAnimatedValue, ToAnimatedZero)] +#[derive(ToAnimatedValue, ToAnimatedZero)] #[derive(ToComputedValue, ToCss)] pub enum SVGLength { /// ` | | ` @@ -198,7 +198,7 @@ pub enum SVGLength { /// Generic value for stroke-dasharray. #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, ComputeSquaredDistance, Debug, HasViewportPercentage, PartialEq, ToAnimatedValue, ToComputedValue)] +#[derive(Clone, ComputeSquaredDistance, Debug, PartialEq, ToAnimatedValue, ToComputedValue)] pub enum SVGStrokeDashArray { /// `[ | | ]#` Values(Vec), @@ -232,7 +232,7 @@ impl ToCss for SVGStrokeDashArray where LengthType: ToCs /// An SVG opacity value accepts `context-{fill,stroke}-opacity` in /// addition to opacity value. #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, ComputeSquaredDistance, Copy, Debug, HasViewportPercentage)] +#[derive(Clone, ComputeSquaredDistance, Copy, Debug)] #[derive(PartialEq, ToAnimatedZero, ToComputedValue, ToCss)] pub enum SVGOpacity { /// `` diff --git a/components/style/values/generics/text.rs b/components/style/values/generics/text.rs index c1d55bd541e..ca14885d6c0 100644 --- a/components/style/values/generics/text.rs +++ b/components/style/values/generics/text.rs @@ -13,7 +13,7 @@ use values::distance::{ComputeSquaredDistance, SquaredDistance}; /// A generic value for the `initial-letter` property. #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue, ToCss)] pub enum InitialLetter { /// `normal` Normal, @@ -31,7 +31,7 @@ impl InitialLetter { /// A generic spacing value for the `letter-spacing` and `word-spacing` properties. #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue, ToCss)] pub enum Spacing { /// `normal` Normal, @@ -111,7 +111,7 @@ where /// A generic value for the `line-height` property. #[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug)] -#[derive(HasViewportPercentage, PartialEq, ToAnimatedValue, ToCss)] +#[derive(PartialEq, ToAnimatedValue, ToCss)] pub enum LineHeight { /// `normal` Normal, diff --git a/components/style/values/generics/transform.rs b/components/style/values/generics/transform.rs index 82e18f436ff..bcd57510e1a 100644 --- a/components/style/values/generics/transform.rs +++ b/components/style/values/generics/transform.rs @@ -5,13 +5,13 @@ //! Generic types for CSS values that are related to transformations. use std::fmt; -use style_traits::{HasViewportPercentage, ToCss}; +use style_traits::ToCss; use values::CSSFloat; /// A generic 2D transformation matrix. #[allow(missing_docs)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue, ToCss)] #[css(comma, function)] pub struct Matrix { pub a: T, @@ -24,7 +24,7 @@ pub struct Matrix { /// A generic transform origin. #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, HasViewportPercentage)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug)] #[derive(PartialEq, ToAnimatedZero, ToComputedValue, ToCss)] pub struct TransformOrigin { /// The horizontal origin. @@ -78,10 +78,6 @@ impl TransformOrigin { } } -impl HasViewportPercentage for TimingFunction { - fn has_viewport_percentage(&self) -> bool { false } -} - impl TimingFunction { /// `ease` #[inline] diff --git a/components/style/values/mod.rs b/components/style/values/mod.rs index 6c54e434808..076e52de6af 100644 --- a/components/style/values/mod.rs +++ b/components/style/values/mod.rs @@ -54,7 +54,7 @@ pub fn serialize_dimension(value: CSSFloat, unit: &str, dest: &mut W) /// Convenience void type to disable some properties and values through types. #[cfg_attr(feature = "servo", derive(Deserialize, HeapSizeOf, Serialize))] -#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue, ToCss)] pub enum Impossible {} impl Parse for Impossible { @@ -68,7 +68,7 @@ impl Parse for Impossible { /// A struct representing one of two kinds of values. #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, HasViewportPercentage)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy)] #[derive(PartialEq, ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)] pub enum Either { /// The first value. @@ -196,4 +196,3 @@ define_css_keyword_enum!(ExtremumLength: "-moz-min-content" => MinContent, "-moz-fit-content" => FitContent, "-moz-available" => FillAvailable); -no_viewport_percentage!(ExtremumLength); diff --git a/components/style/values/specified/align.rs b/components/style/values/specified/align.rs index 2b1b52fa1bc..c5b6212e89c 100644 --- a/components/style/values/specified/align.rs +++ b/components/style/values/specified/align.rs @@ -173,7 +173,6 @@ impl ToCss for AlignJustifyContent { } } -no_viewport_percentage!(AlignJustifyContent); impl Parse for AlignJustifyContent { // normal | | @@ -223,7 +222,6 @@ impl AlignJustifySelf { } } -no_viewport_percentage!(AlignJustifySelf); impl Parse for AlignJustifySelf { // auto | normal | stretch | | @@ -261,7 +259,6 @@ impl AlignItems { } } -no_viewport_percentage!(AlignItems); impl Parse for AlignItems { // normal | stretch | | @@ -305,7 +302,6 @@ impl JustifyItems { } } -no_viewport_percentage!(JustifyItems); impl Parse for JustifyItems { // auto | normal | stretch | | diff --git a/components/style/values/specified/angle.rs b/components/style/values/specified/angle.rs index bb926318b01..3990d6b3b0a 100644 --- a/components/style/values/specified/angle.rs +++ b/components/style/values/specified/angle.rs @@ -20,7 +20,7 @@ use values::specified::calc::CalcNode; /// value serialization. Therefore we are storing a computed angle inside /// to hold the actual value and its unit. #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] -#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq)] pub struct Angle { value: ComputedAngle, was_calc: bool, diff --git a/components/style/values/specified/border.rs b/components/style/values/specified/border.rs index 419074babe6..19863b5d1de 100644 --- a/components/style/values/specified/border.rs +++ b/components/style/values/specified/border.rs @@ -18,7 +18,7 @@ use values::specified::length::{Length, LengthOrPercentage}; /// A specified value for a single side of the `border-width` property. #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)] +#[derive(Clone, Debug, PartialEq, ToCss)] pub enum BorderSideWidth { /// `thin` Thin, diff --git a/components/style/values/specified/calc.rs b/components/style/values/specified/calc.rs index 7f82c047578..93db7730f37 100644 --- a/components/style/values/specified/calc.rs +++ b/components/style/values/specified/calc.rs @@ -11,7 +11,7 @@ use cssparser::{Parser, Token, BasicParseError}; use parser::ParserContext; use std::ascii::AsciiExt; use std::fmt; -use style_traits::{HasViewportPercentage, ToCss, ParseError, StyleParseError}; +use style_traits::{ToCss, ParseError, StyleParseError}; use style_traits::values::specified::AllowedLengthType; use values::{CSSInteger, CSSFloat}; use values::computed; @@ -82,13 +82,6 @@ pub struct CalcLengthOrPercentage { pub mozmm: Option, } -impl HasViewportPercentage for CalcLengthOrPercentage { - fn has_viewport_percentage(&self) -> bool { - self.vw.is_some() || self.vh.is_some() || - self.vmin.is_some() || self.vmax.is_some() - } -} - impl ToCss for CalcLengthOrPercentage { /// https://drafts.csswg.org/css-values/#calc-serialize /// diff --git a/components/style/values/specified/color.rs b/components/style/values/specified/color.rs index 9040fc06a62..724f8eea54b 100644 --- a/components/style/values/specified/color.rs +++ b/components/style/values/specified/color.rs @@ -44,7 +44,6 @@ pub enum Color { InheritFromBodyQuirk, } -no_viewport_percentage!(Color); #[cfg(feature = "gecko")] mod gecko { @@ -305,7 +304,6 @@ impl ToComputedValue for Color { #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct RGBAColor(pub Color); -no_viewport_percentage!(RGBAColor); impl Parse for RGBAColor { fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result> { diff --git a/components/style/values/specified/effects.rs b/components/style/values/specified/effects.rs index 977067be582..cd248224623 100644 --- a/components/style/values/specified/effects.rs +++ b/components/style/values/specified/effects.rs @@ -35,7 +35,7 @@ pub type Filter = GenericFilter; pub type Filter = GenericFilter; /// A value for the `` parts in `Filter`. -#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)] +#[derive(Clone, Debug, PartialEq, ToCss)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct Factor(NumberOrPercentage); diff --git a/components/style/values/specified/grid.rs b/components/style/values/specified/grid.rs index 72ce404d25c..13268392c04 100644 --- a/components/style/values/specified/grid.rs +++ b/components/style/values/specified/grid.rs @@ -9,7 +9,7 @@ use cssparser::{Parser, Token, BasicParseError}; use parser::{Parse, ParserContext}; use std::ascii::AsciiExt; use std::mem; -use style_traits::{HasViewportPercentage, ParseError, StyleParseError}; +use style_traits::{ParseError, StyleParseError}; use values::{CSSFloat, CustomIdent}; use values::generics::grid::{GridTemplateComponent, RepeatCount, TrackBreadth, TrackKeyword, TrackRepeat}; use values::generics::grid::{LineNameList, TrackSize, TrackList, TrackListType}; @@ -38,17 +38,6 @@ impl Parse for TrackBreadth { } } -impl HasViewportPercentage for TrackBreadth { - #[inline] - fn has_viewport_percentage(&self) -> bool { - if let TrackBreadth::Breadth(ref lop) = *self { - lop.has_viewport_percentage() - } else { - false - } - } -} - impl Parse for TrackSize { fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result> { if let Ok(b) = input.try(|i| TrackBreadth::parse(context, i)) { @@ -175,13 +164,6 @@ impl TrackRepeat { } } -impl HasViewportPercentage for TrackRepeat { - #[inline] - fn has_viewport_percentage(&self) -> bool { - self.track_sizes.iter().any(|ref v| v.has_viewport_percentage()) - } -} - impl Parse for TrackList { fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result> { // Merge the line names while parsing values. The resulting values will @@ -278,13 +260,6 @@ impl Parse for TrackList { } } -impl HasViewportPercentage for TrackList { - #[inline] - fn has_viewport_percentage(&self) -> bool { - self.values.iter().any(|ref v| v.has_viewport_percentage()) - } -} - impl Parse for GridTemplateComponent { // FIXME: Derive Parse (probably with None_) fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result> { @@ -307,13 +282,3 @@ impl GridTemplateComponent { LineNameList::parse(context, input).map(GridTemplateComponent::Subgrid) } } - -impl HasViewportPercentage for GridTemplateComponent { - #[inline] - fn has_viewport_percentage(&self) -> bool { - match *self { - GridTemplateComponent::TrackList(ref l) => l.has_viewport_percentage(), - _ => false, - } - } -} diff --git a/components/style/values/specified/image.rs b/components/style/values/specified/image.rs index 42f44043328..7caf67cf472 100644 --- a/components/style/values/specified/image.rs +++ b/components/style/values/specified/image.rs @@ -85,7 +85,7 @@ pub type GradientKind = GenericGradientKind< >; /// A specified gradient line direction. -#[derive(Clone, Debug, HasViewportPercentage, PartialEq)] +#[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum LineDirection { /// An angular direction. @@ -105,7 +105,7 @@ pub enum LineDirection { } /// A binary enum to hold either Position or LegacyPosition. -#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)] +#[derive(Clone, Debug, PartialEq, ToCss)] #[cfg(feature = "gecko")] pub enum GradientPosition { /// 1, 2, 3, 4-valued . diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs index 20951d9dcbc..490161a4df1 100644 --- a/components/style/values/specified/length.rs +++ b/components/style/values/specified/length.rs @@ -14,7 +14,7 @@ use parser::{Parse, ParserContext}; use std::{cmp, fmt, mem}; use std::ascii::AsciiExt; use std::ops::Mul; -use style_traits::{HasViewportPercentage, ToCss, ParseError, StyleParseError}; +use style_traits::{ToCss, ParseError, StyleParseError}; use style_traits::values::specified::AllowedLengthType; use stylesheets::CssRuleType; use super::{AllowQuirks, Number, ToComputedValue, Percentage}; @@ -183,12 +183,6 @@ pub enum ViewportPercentageLength { Vmax(CSSFloat) } -impl HasViewportPercentage for ViewportPercentageLength { - fn has_viewport_percentage(&self) -> bool { - true - } -} - impl ToCss for ViewportPercentageLength { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { match *self { @@ -422,15 +416,6 @@ pub enum NoCalcLength { Physical(PhysicalLength), } -impl HasViewportPercentage for NoCalcLength { - fn has_viewport_percentage(&self) -> bool { - match *self { - NoCalcLength::ViewportPercentage(_) => true, - _ => false, - } - } -} - impl ToCss for NoCalcLength { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { match *self { @@ -545,7 +530,7 @@ impl NoCalcLength { /// /// https://drafts.csswg.org/css-values/#lengths #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)] +#[derive(Clone, Debug, PartialEq, ToCss)] pub enum Length { /// The internal length type that cannot parse `calc` NoCalc(NoCalcLength), @@ -759,7 +744,7 @@ pub type NonNegativeLengthOrNumber = Either`, a ``, or the `auto` keyword. #[allow(missing_docs)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)] +#[derive(Clone, Debug, PartialEq, ToCss)] pub enum LengthOrPercentageOrAuto { Length(NoCalcLength), Percentage(computed::Percentage), @@ -1045,7 +1030,7 @@ impl LengthOrPercentageOrAuto { /// Either a ``, a ``, or the `none` keyword. #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)] +#[derive(Clone, Debug, PartialEq, ToCss)] #[allow(missing_docs)] pub enum LengthOrPercentageOrNone { Length(NoCalcLength), @@ -1193,7 +1178,7 @@ impl LengthOrNumber { /// `auto`, and cannot be `none`. #[allow(missing_docs)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)] +#[derive(Clone, Debug, PartialEq, ToCss)] pub enum MozLength { LengthOrPercentageOrAuto(LengthOrPercentageOrAuto), ExtremumLength(ExtremumLength), @@ -1219,7 +1204,7 @@ impl MozLength { /// A value suitable for a `max-width` or `max-height` property. #[allow(missing_docs)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)] +#[derive(Clone, Debug, PartialEq, ToCss)] pub enum MaxLength { LengthOrPercentageOrNone(LengthOrPercentageOrNone), ExtremumLength(ExtremumLength), diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 642a5ac3053..60b4361cb9a 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -102,7 +102,6 @@ impl Eq for SpecifiedUrl {} #[cfg(feature = "gecko")] impl ComputedValueAsSpecified for SpecifiedUrl {} -no_viewport_percentage!(SpecifiedUrl); } /// Parse an `` value, handling `calc()` correctly. @@ -171,7 +170,6 @@ define_numbered_css_keyword_enum! { BorderStyle: "outset" => outset = 2, } -no_viewport_percentage!(BorderStyle); impl BorderStyle { /// Whether this border style is either none or hidden. @@ -191,7 +189,6 @@ pub struct Number { calc_clamping_mode: Option, } -no_viewport_percentage!(Number); impl Parse for Number { fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result> { @@ -296,7 +293,6 @@ pub enum NumberOrPercentage { Number(Number), } -no_viewport_percentage!(NumberOrPercentage); impl NumberOrPercentage { fn parse_with_clamping_mode<'i, 't>( @@ -329,7 +325,6 @@ impl Parse for NumberOrPercentage { #[derive(Clone, Copy, Debug, PartialEq, PartialOrd, ToCss)] pub struct Opacity(Number); -no_viewport_percentage!(Opacity); impl Parse for Opacity { fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result> { @@ -389,7 +384,6 @@ impl Integer { } } -no_viewport_percentage!(Integer); impl Parse for Integer { fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result> { @@ -498,7 +492,7 @@ pub type LengthOrPercentageOrNumber = Either; /// NonNegativeLengthOrPercentage | NonNegativeNumber pub type NonNegativeLengthOrPercentageOrNumber = Either; -#[derive(Clone, Debug, HasViewportPercentage, PartialEq)] +#[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] /// rect(, , , ) used by clip and image-region pub struct ClipRect { diff --git a/components/style/values/specified/percentage.rs b/components/style/values/specified/percentage.rs index 8ab86b720d0..0373d29016e 100644 --- a/components/style/values/specified/percentage.rs +++ b/components/style/values/specified/percentage.rs @@ -28,7 +28,6 @@ pub struct Percentage { calc_clamping_mode: Option, } -no_viewport_percentage!(Percentage); impl ToCss for Percentage { fn to_css(&self, dest: &mut W) -> fmt::Result diff --git a/components/style/values/specified/position.rs b/components/style/values/specified/position.rs index 0adf66e3d76..fb5e22347e8 100644 --- a/components/style/values/specified/position.rs +++ b/components/style/values/specified/position.rs @@ -10,7 +10,7 @@ use cssparser::Parser; use parser::{Parse, ParserContext}; use std::fmt; -use style_traits::{HasViewportPercentage, ToCss, ParseError}; +use style_traits::{ToCss, ParseError}; use values::computed::{CalcLengthOrPercentage, LengthOrPercentage as ComputedLengthOrPercentage}; use values::computed::{Context, Percentage, ToComputedValue}; use values::generics::position::Position as GenericPosition; @@ -156,18 +156,6 @@ impl ToCss for Position { } } -impl HasViewportPercentage for PositionComponent { - fn has_viewport_percentage(&self) -> bool { - match *self { - PositionComponent::Length(ref lop) | - PositionComponent::Side(_, Some(ref lop)) => { - lop.has_viewport_percentage() - }, - _ => false, - } - } -} - impl Parse for PositionComponent { fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result> { Self::parse_quirky(context, input, AllowQuirks::No) diff --git a/components/style/values/specified/svg.rs b/components/style/values/specified/svg.rs index 178b6892793..bf57a84301e 100644 --- a/components/style/values/specified/svg.rs +++ b/components/style/values/specified/svg.rs @@ -15,7 +15,6 @@ use values::specified::color::RGBAColor; /// Specified SVG Paint value pub type SVGPaint = generic::SVGPaint; -no_viewport_percentage!(SVGPaint); /// Specified SVG Paint Kind value pub type SVGPaintKind = generic::SVGPaintKind; diff --git a/components/style/values/specified/time.rs b/components/style/values/specified/time.rs index 67e5f10dd41..28820158af8 100644 --- a/components/style/values/specified/time.rs +++ b/components/style/values/specified/time.rs @@ -16,7 +16,7 @@ use values::computed::time::Time as ComputedTime; use values::specified::calc::CalcNode; /// A time value according to CSS-VALUES ยง 6.2. -#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct Time { seconds: CSSFloat, @@ -25,7 +25,7 @@ pub struct Time { } /// A time unit. -#[derive(Clone, Copy, Debug, Eq, HasViewportPercentage, PartialEq)] +#[derive(Clone, Copy, Debug, Eq, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum TimeUnit { /// `s` diff --git a/components/style/values/specified/transform.rs b/components/style/values/specified/transform.rs index e3b3e1e51f7..b40dc58b0a2 100644 --- a/components/style/values/specified/transform.rs +++ b/components/style/values/specified/transform.rs @@ -22,7 +22,7 @@ pub type TransformOrigin = GenericTransformOrigin, OriginComp /// The specified value of a component of a CSS ``. #[cfg_attr(feature = "servo", derive(HeapSizeOf))] -#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)] +#[derive(Clone, Debug, PartialEq, ToCss)] pub enum OriginComponent { /// `center` Center, diff --git a/components/style_derive/has_viewport_percentage.rs b/components/style_derive/has_viewport_percentage.rs deleted file mode 100644 index 18856576fb8..00000000000 --- a/components/style_derive/has_viewport_percentage.rs +++ /dev/null @@ -1,42 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use cg; -use quote; -use syn; -use synstructure; - -pub fn derive(input: syn::DeriveInput) -> quote::Tokens { - let name = &input.ident; - let trait_path = &["style_traits", "HasViewportPercentage"]; - let (impl_generics, ty_generics, mut where_clause) = - cg::trait_parts(&input, trait_path); - - let style = synstructure::BindStyle::Ref.into(); - let match_body = synstructure::each_variant(&input, &style, |bindings, _| { - let (first, rest) = match bindings.split_first() { - None => return Some(quote!(false)), - Some(pair) => pair, - }; - where_clause.add_trait_bound(&first.field.ty); - let mut expr = quote!(::style_traits::HasViewportPercentage::has_viewport_percentage(#first)); - for binding in rest { - where_clause.add_trait_bound(&binding.field.ty); - expr = quote!(#expr || ::style_traits::HasViewportPercentage::has_viewport_percentage(#binding)); - } - Some(expr) - }); - - quote! { - impl #impl_generics ::style_traits::HasViewportPercentage for #name #ty_generics #where_clause { - #[allow(unused_variables, unused_imports)] - #[inline] - fn has_viewport_percentage(&self) -> bool { - match *self { - #match_body - } - } - } - } -} diff --git a/components/style_derive/lib.rs b/components/style_derive/lib.rs index f98829e60bf..6e87cc4972a 100644 --- a/components/style_derive/lib.rs +++ b/components/style_derive/lib.rs @@ -13,7 +13,6 @@ use proc_macro::TokenStream; mod animate; mod cg; mod compute_squared_distance; -mod has_viewport_percentage; mod to_animated_value; mod to_animated_zero; mod to_computed_value; @@ -31,12 +30,6 @@ pub fn derive_compute_squared_distance(stream: TokenStream) -> TokenStream { compute_squared_distance::derive(input).to_string().parse().unwrap() } -#[proc_macro_derive(HasViewportPercentage)] -pub fn derive_has_viewport_percentage(stream: TokenStream) -> TokenStream { - let input = syn::parse_derive_input(&stream.to_string()).unwrap(); - has_viewport_percentage::derive(input).to_string().parse().unwrap() -} - #[proc_macro_derive(ToAnimatedValue)] pub fn derive_to_animated_value(stream: TokenStream) -> TokenStream { let input = syn::parse_derive_input(&stream.to_string()).unwrap(); diff --git a/components/style_traits/lib.rs b/components/style_traits/lib.rs index 5de14dfd5e5..0ef1fee83c4 100644 --- a/components/style_traits/lib.rs +++ b/components/style_traits/lib.rs @@ -84,7 +84,6 @@ pub mod values; pub mod viewport; pub use values::{Comma, CommaWithSpace, OneOrMoreSeparated, Separator, Space, ToCss}; -pub use viewport::HasViewportPercentage; /// The error type for all CSS parsing routines. pub type ParseError<'i> = cssparser::ParseError<'i, SelectorParseError<'i, StyleParseError<'i>>>; diff --git a/components/style_traits/viewport.rs b/components/style_traits/viewport.rs index 97c8c0438bc..97b63aa4915 100644 --- a/components/style_traits/viewport.rs +++ b/components/style_traits/viewport.rs @@ -19,66 +19,6 @@ define_css_keyword_enum!(Orientation: "portrait" => Portrait, "landscape" => Landscape); -/// A trait used to query whether this value has viewport units. -pub trait HasViewportPercentage { - /// Returns true if this value has viewport units. - fn has_viewport_percentage(&self) -> bool; -} - -/// A macro used to implement HasViewportPercentage trait -/// for a given type that may never contain viewport units. -#[macro_export] -macro_rules! no_viewport_percentage { - ($($name: ident),+) => { - $(impl $crate::HasViewportPercentage for $name { - #[inline] - fn has_viewport_percentage(&self) -> bool { - false - } - })+ - }; -} - -no_viewport_percentage!(bool, f32); - -impl HasViewportPercentage for Box -where - T: ?Sized + HasViewportPercentage -{ - #[inline] - fn has_viewport_percentage(&self) -> bool { - (**self).has_viewport_percentage() - } -} - -impl HasViewportPercentage for Option { - #[inline] - fn has_viewport_percentage(&self) -> bool { - self.as_ref().map_or(false, T::has_viewport_percentage) - } -} - -impl HasViewportPercentage for TypedSize2D { - #[inline] - fn has_viewport_percentage(&self) -> bool { - self.width.has_viewport_percentage() || self.height.has_viewport_percentage() - } -} - -impl HasViewportPercentage for Vec { - #[inline] - fn has_viewport_percentage(&self) -> bool { - self.iter().any(T::has_viewport_percentage) - } -} - -impl HasViewportPercentage for [T] { - #[inline] - fn has_viewport_percentage(&self) -> bool { - self.iter().any(T::has_viewport_percentage) - } -} - /// A set of viewport descriptors: /// /// https://drafts.csswg.org/css-device-adapt/#viewport-desc diff --git a/tests/unit/style/parsing/value.rs b/tests/unit/style/parsing/value.rs index 6eeff06b26f..5c1f51dcc4c 100644 --- a/tests/unit/style/parsing/value.rs +++ b/tests/unit/style/parsing/value.rs @@ -2,21 +2,12 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use app_units::Au; use cssparser::{Parser, ParserInput}; use style::context::QuirksMode; use style::parser::ParserContext; use style::stylesheets::{CssRuleType, Origin}; -use style::values::specified::{AbsoluteLength, NoCalcLength, Number, ViewportPercentageLength}; -use style_traits::{PARSING_MODE_ALLOW_ALL_NUMERIC_VALUES, HasViewportPercentage}; - -#[test] -fn length_has_viewport_percentage() { - let l = NoCalcLength::ViewportPercentage(ViewportPercentageLength::Vw(100.)); - assert!(l.has_viewport_percentage()); - let l = NoCalcLength::Absolute(AbsoluteLength::Px(Au(100).to_f32_px())); - assert!(!l.has_viewport_percentage()); -} +use style::values::specified::Number; +use style_traits::PARSING_MODE_ALLOW_ALL_NUMERIC_VALUES; #[test] fn test_parsing_allo_all_numeric_values() { diff --git a/tests/unit/style/properties/mod.rs b/tests/unit/style/properties/mod.rs index 023a9250baf..96b8ffdf617 100644 --- a/tests/unit/style/properties/mod.rs +++ b/tests/unit/style/properties/mod.rs @@ -61,4 +61,3 @@ macro_rules! assert_roundtrip_with_context { mod background; mod scaffolding; mod serialization; -mod viewport; diff --git a/tests/unit/style/properties/viewport.rs b/tests/unit/style/properties/viewport.rs deleted file mode 100644 index 205370da8f4..00000000000 --- a/tests/unit/style/properties/viewport.rs +++ /dev/null @@ -1,27 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -use app_units::Au; -use style::properties::PropertyDeclaration; -use style::values::specified::{AbsoluteLength, Length, NoCalcLength, ViewportPercentageLength}; -use style::values::specified::border::BorderSideWidth; -use style_traits::HasViewportPercentage; - -#[test] -fn has_viewport_percentage_for_specified_value() { - //TODO: test all specified value with a HasViewportPercentage impl - let pvw = PropertyDeclaration::BorderTopWidth( - BorderSideWidth::Length( - Length::NoCalc(NoCalcLength::ViewportPercentage(ViewportPercentageLength::Vw(100.))) - ) - ); - assert!(pvw.has_viewport_percentage()); - - let pabs = PropertyDeclaration::BorderTopWidth( - BorderSideWidth::Length( - Length::NoCalc(NoCalcLength::Absolute(AbsoluteLength::Px(Au(100).to_f32_px()))) - ) - ); - assert!(!pabs.has_viewport_percentage()); -}