servo: Merge #18300 - style: Remove HasViewportPercentage (from emilio:die-hvp-die); r=nox

It's not needed since #18268, let's kill it.

Source-Repo: https://github.com/servo/servo
Source-Revision: 5dee83d54d3f05cc631ee89de612c14e21dd92ec

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : e6f1d82f2005c8203891fedd5bd564411817e858
This commit is contained in:
Emilio Cobos Álvarez 2017-08-30 04:31:11 -05:00
Родитель c159686ac3
Коммит 22b2d26b42
61 изменённых файлов: 73 добавлений и 437 удалений

Просмотреть файл

@ -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<Name>,
}
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,

Просмотреть файл

@ -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);
};
}

Просмотреть файл

@ -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<single_value::SpecifiedValue>);
@ -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);
</%call>
</%def>
@ -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":

Просмотреть файл

@ -214,7 +214,6 @@ pub enum TransitionProperty {
Unsupported(CustomIdent)
}
no_viewport_percentage!(TransitionProperty);
impl ComputedValueAsSpecified for TransitionProperty {}

Просмотреть файл

@ -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<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {

Просмотреть файл

@ -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;

Просмотреть файл

@ -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<SpecifiedValue,ParseError<'i>> {
@ -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<SpecifiedOperation>);
@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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<W>(&self, dest: &mut W) -> fmt::Result

Просмотреть файл

@ -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"></%self:simple_system_boilerplate>
@ -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;

Просмотреть файл

@ -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))]

Просмотреть файл

@ -259,7 +259,6 @@ ${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)",
}
}
no_viewport_percentage!(SpecifiedValue);
impl ComputedValueAsSpecified for SpecifiedValue { }
</%helpers:longhand>
@ -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 { }

Просмотреть файл

@ -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<NonNegativeLength>,

Просмотреть файл

@ -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)

Просмотреть файл

@ -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<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {

Просмотреть файл

@ -14,7 +14,6 @@
use values::specified::url::SpecifiedUrl;
impl ComputedValueAsSpecified for SpecifiedValue {}
no_viewport_percentage!(SpecifiedValue);
pub mod computed_value {
#[cfg(feature = "gecko")]

Просмотреть файл

@ -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<u32>,
}
no_viewport_percentage!(TemplateAreas);
impl ComputedValueAsSpecified for TemplateAreas {}
impl Parse for TemplateAreas {

Просмотреть файл

@ -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;

Просмотреть файл

@ -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))]

Просмотреть файл

@ -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)]

Просмотреть файл

@ -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<W>(&self, dest: &mut W) -> fmt::Result
where W: fmt::Write,
@ -1299,26 +1286,6 @@ pub enum PropertyDeclaration {
Custom(::custom_properties::Name, DeclaredValueOwned<Box<::custom_properties::SpecifiedValue>>),
}
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)?;

Просмотреть файл

@ -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.

Просмотреть файл

@ -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 {

Просмотреть файл

@ -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<LengthOrPercentageOrAuto> {
/// `<width> <height>`
Explicit {

Просмотреть файл

@ -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<B, T, U> ToAnimatedZero for ShapeSource<B, T, U> {
}
}
impl<B, T, U> HasViewportPercentage for ShapeSource<B, T, U> {
#[inline]
fn has_viewport_percentage(&self) -> bool { false }
}
impl<L> ToCss for InsetRect<L>
where L: ToCss + PartialEq
{

Просмотреть файл

@ -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<LengthOrPercentage, Number> {
/// `<length-or-percentage>`
Length(LengthOrPercentage),
@ -22,7 +22,7 @@ pub enum BorderImageSideWidth<LengthOrPercentage, Number> {
}
/// 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<NumberOrPercentage> {
/// The offsets.
@ -35,7 +35,7 @@ pub struct BorderImageSlice<NumberOrPercentage> {
///
/// 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<LengthOrPercentage> {
/// The top left radius.
@ -50,7 +50,7 @@ pub struct BorderRadius<LengthOrPercentage> {
/// 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<L>(pub Size2D<L>);

Просмотреть файл

@ -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<I> CounterIncrement<I> {
}
}
impl<I> HasViewportPercentage for CounterIncrement<I> {
#[inline] fn has_viewport_percentage(&self) -> bool { false }
}
impl<I> ToCss for CounterIncrement<I>
where
I: ToCss,

Просмотреть файл

@ -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<Color, SizeLength, BlurShapeLength, ShapeLength> {
/// The base shadow.
@ -25,7 +25,7 @@ pub struct BoxShadow<Color, SizeLength, BlurShapeLength, ShapeLength> {
/// 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<Angle, Factor, Length, DropShadow> {
/// `blur(<length>)`
#[css(function)]
@ -67,7 +67,7 @@ pub enum Filter<Angle, Factor, Length, DropShadow> {
/// 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, SizeLength, ShapeLength> {
/// Color.

Просмотреть файл

@ -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<LengthOrPercentage> {
/// `auto`
Auto,

Просмотреть файл

@ -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<LengthOrPercentage> {
/// `none`
None,

Просмотреть файл

@ -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<L: ToCss> ToCss for TrackBreadth<L> {
///
/// 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<L> {
/// A flexible `<track-breadth>`
Breadth(TrackBreadth<L>),
@ -372,7 +371,6 @@ impl Parse for RepeatCount {
}
impl ComputedValueAsSpecified for RepeatCount {}
no_viewport_percentage!(RepeatCount);
/// The structure containing `<line-names>` and `<track-size>` values.
///
@ -666,7 +664,6 @@ impl ToCss for LineNameList {
}
impl ComputedValueAsSpecified for LineNameList {}
no_viewport_percentage!(LineNameList);
/// Variants for `<grid-template-rows> | <grid-template-columns>`
/// Subgrid deferred to Level 2 spec due to lack of implementation.

Просмотреть файл

@ -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<Gradient, MozImageRect, ImageUrl> {
/// 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<LineDirection, Length, LengthOrPercentage, Position, Color, Angle> {
/// Gradients can be linear or radial.
pub kind: GradientKind<LineDirection, Length, LengthOrPercentage, Position, Angle>,
@ -50,7 +50,7 @@ pub struct Gradient<LineDirection, Length, LengthOrPercentage, Position, Color,
pub compat_mode: CompatMode,
}
#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue)]
#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
/// Whether we used the modern notation or the compatibility `-webkit`, `-moz` prefixes.
pub enum CompatMode {
@ -64,7 +64,7 @@ pub enum CompatMode {
/// A gradient kind.
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue)]
#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue)]
pub enum GradientKind<LineDirection, Length, LengthOrPercentage, Position, Angle> {
/// A linear gradient.
Linear(LineDirection),
@ -73,7 +73,7 @@ pub enum GradientKind<LineDirection, Length, LengthOrPercentage, Position, Angle
}
/// A radial gradient's ending shape.
#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue, ToCss)]
#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue, ToCss)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum EndingShape<Length, LengthOrPercentage> {
/// A circular gradient.
@ -83,7 +83,7 @@ pub enum EndingShape<Length, LengthOrPercentage> {
}
/// 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<Length> {
/// A circle radius.
@ -93,7 +93,7 @@ pub enum Circle<Length> {
}
/// 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<LengthOrPercentage> {
/// 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<Color, LengthOrPercentage> {
/// A color stop.
ColorStop(ColorStop<Color, LengthOrPercentage>),
@ -127,7 +126,7 @@ pub enum GradientItem<Color, LengthOrPercentage> {
/// 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<Color, LengthOrPercentage> {
/// The color of this stop.
@ -215,17 +214,6 @@ impl<G, R, U> ToCss for Image<G, R, U>
}
}
impl<G, R, U> HasViewportPercentage for Image<G, R, U>
where G: HasViewportPercentage
{
fn has_viewport_percentage(&self) -> bool {
match *self {
Image::Gradient(ref gradient) => gradient.has_viewport_percentage(),
_ => false,
}
}
}
impl<D, L, LoP, P, C, A> ToCss for Gradient<D, L, LoP, P, C, A>
where D: LineDirection, L: ToCss, LoP: ToCss, P: ToCss, C: ToCss, A: ToCss
{

Просмотреть файл

@ -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<Self, ParseError<'i>> {
@ -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<T>(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<T>(pub T);

Просмотреть файл

@ -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<H, V> {
/// The horizontal component of position.
pub horizontal: H,

Просмотреть файл

@ -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<T>(pub T, pub T, pub T, pub T);
impl<T> Rect<T> {

Просмотреть файл

@ -104,7 +104,7 @@ impl<ColorType: Parse, UrlPaintServer: Parse> Parse for SVGPaint<ColorType, UrlP
/// A value of <length> | <percentage> | <number> 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<LengthOrPercentage, Number> {
/// <length> | <percentage>
@ -187,7 +187,7 @@ impl <LengthOrPercentageType: Parse, NumberType: Parse> 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<LengthType> {
/// `<length> | <percentage> | <number>`
@ -198,7 +198,7 @@ pub enum SVGLength<LengthType> {
/// 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<LengthType> {
/// `[ <length> | <percentage> | <number> ]#`
Values(Vec<LengthType>),
@ -232,7 +232,7 @@ impl<LengthType> ToCss for SVGStrokeDashArray<LengthType> 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<OpacityType> {
/// `<opacity-value>`

Просмотреть файл

@ -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<Number, Integer> {
/// `normal`
Normal,
@ -31,7 +31,7 @@ impl<N, I> InitialLetter<N, I> {
/// 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<Value> {
/// `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<Number, LengthOrPercentage> {
/// `normal`
Normal,

Просмотреть файл

@ -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<T, U = T> {
pub a: T,
@ -24,7 +24,7 @@ pub struct Matrix<T, U = T> {
/// 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<H, V, Depth> {
/// The horizontal origin.
@ -78,10 +78,6 @@ impl<H, V, D> TransformOrigin<H, V, D> {
}
}
impl<I, N> HasViewportPercentage for TimingFunction<I, N> {
fn has_viewport_percentage(&self) -> bool { false }
}
impl<Integer, Number> TimingFunction<Integer, Number> {
/// `ease`
#[inline]

Просмотреть файл

@ -54,7 +54,7 @@ pub fn serialize_dimension<W>(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<A, B> {
/// 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);

Просмотреть файл

@ -173,7 +173,6 @@ impl ToCss for AlignJustifyContent {
}
}
no_viewport_percentage!(AlignJustifyContent);
impl Parse for AlignJustifyContent {
// normal | <baseline-position> |
@ -223,7 +222,6 @@ impl AlignJustifySelf {
}
}
no_viewport_percentage!(AlignJustifySelf);
impl Parse for AlignJustifySelf {
// auto | normal | stretch | <baseline-position> |
@ -261,7 +259,6 @@ impl AlignItems {
}
}
no_viewport_percentage!(AlignItems);
impl Parse for AlignItems {
// normal | stretch | <baseline-position> |
@ -305,7 +302,6 @@ impl JustifyItems {
}
}
no_viewport_percentage!(JustifyItems);
impl Parse for JustifyItems {
// auto | normal | stretch | <baseline-position> |

Просмотреть файл

@ -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,

Просмотреть файл

@ -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,

Просмотреть файл

@ -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<CSSFloat>,
}
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
///

Просмотреть файл

@ -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<Self, ParseError<'i>> {

Просмотреть файл

@ -35,7 +35,7 @@ pub type Filter = GenericFilter<Angle, Factor, NonNegativeLength, SimpleShadow>;
pub type Filter = GenericFilter<Angle, Factor, NonNegativeLength, Impossible>;
/// A value for the `<factor>` parts in `Filter`.
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)]
#[derive(Clone, Debug, PartialEq, ToCss)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct Factor(NumberOrPercentage);

Просмотреть файл

@ -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<LengthOrPercentage> {
}
}
impl HasViewportPercentage for TrackBreadth<LengthOrPercentage> {
#[inline]
fn has_viewport_percentage(&self) -> bool {
if let TrackBreadth::Breadth(ref lop) = *self {
lop.has_viewport_percentage()
} else {
false
}
}
}
impl Parse for TrackSize<LengthOrPercentage> {
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
if let Ok(b) = input.try(|i| TrackBreadth::parse(context, i)) {
@ -175,13 +164,6 @@ impl TrackRepeat<LengthOrPercentage> {
}
}
impl HasViewportPercentage for TrackRepeat<LengthOrPercentage> {
#[inline]
fn has_viewport_percentage(&self) -> bool {
self.track_sizes.iter().any(|ref v| v.has_viewport_percentage())
}
}
impl Parse for TrackList<LengthOrPercentage> {
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
// Merge the line names while parsing values. The resulting values will
@ -278,13 +260,6 @@ impl Parse for TrackList<LengthOrPercentage> {
}
}
impl HasViewportPercentage for TrackList<LengthOrPercentage> {
#[inline]
fn has_viewport_percentage(&self) -> bool {
self.values.iter().any(|ref v| v.has_viewport_percentage())
}
}
impl Parse for GridTemplateComponent<LengthOrPercentage> {
// FIXME: Derive Parse (probably with None_)
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
@ -307,13 +282,3 @@ impl GridTemplateComponent<LengthOrPercentage> {
LineNameList::parse(context, input).map(GridTemplateComponent::Subgrid)
}
}
impl HasViewportPercentage for GridTemplateComponent<LengthOrPercentage> {
#[inline]
fn has_viewport_percentage(&self) -> bool {
match *self {
GridTemplateComponent::TrackList(ref l) => l.has_viewport_percentage(),
_ => false,
}
}
}

Просмотреть файл

@ -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 <position>.

Просмотреть файл

@ -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<W>(&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<W>(&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<NonNegativeLength, NonNegativeNumber
/// A length or a percentage value.
#[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)]
#[derive(Clone, Debug, PartialEq, ToCss)]
pub enum LengthOrPercentage {
Length(NoCalcLength),
Percentage(computed::Percentage),
@ -929,7 +914,7 @@ impl LengthOrPercentage {
/// Either a `<length>`, a `<percentage>`, 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 `<length>`, a `<percentage>`, 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),

Просмотреть файл

@ -102,7 +102,6 @@ impl Eq for SpecifiedUrl {}
#[cfg(feature = "gecko")]
impl ComputedValueAsSpecified for SpecifiedUrl {}
no_viewport_percentage!(SpecifiedUrl);
}
/// Parse an `<integer>` 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<AllowedNumericType>,
}
no_viewport_percentage!(Number);
impl Parse for Number {
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
@ -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<Self, ParseError<'i>> {
@ -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<Self, ParseError<'i>> {
@ -498,7 +492,7 @@ pub type LengthOrPercentageOrNumber = Either<Number, LengthOrPercentage>;
/// NonNegativeLengthOrPercentage | NonNegativeNumber
pub type NonNegativeLengthOrPercentageOrNumber = Either<NonNegativeNumber, NonNegativeLengthOrPercentage>;
#[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
/// rect(<top>, <left>, <bottom>, <right>) used by clip and image-region
pub struct ClipRect {

Просмотреть файл

@ -28,7 +28,6 @@ pub struct Percentage {
calc_clamping_mode: Option<AllowedNumericType>,
}
no_viewport_percentage!(Percentage);
impl ToCss for Percentage {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result

Просмотреть файл

@ -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<S> HasViewportPercentage for PositionComponent<S> {
fn has_viewport_percentage(&self) -> bool {
match *self {
PositionComponent::Length(ref lop) |
PositionComponent::Side(_, Some(ref lop)) => {
lop.has_viewport_percentage()
},
_ => false,
}
}
}
impl<S: Parse> Parse for PositionComponent<S> {
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
Self::parse_quirky(context, input, AllowQuirks::No)

Просмотреть файл

@ -15,7 +15,6 @@ use values::specified::color::RGBAColor;
/// Specified SVG Paint value
pub type SVGPaint = generic::SVGPaint<RGBAColor, SpecifiedUrl>;
no_viewport_percentage!(SVGPaint);
/// Specified SVG Paint Kind value
pub type SVGPaintKind = generic::SVGPaintKind<RGBAColor, SpecifiedUrl>;

Просмотреть файл

@ -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`

Просмотреть файл

@ -22,7 +22,7 @@ pub type TransformOrigin = GenericTransformOrigin<OriginComponent<X>, OriginComp
/// The specified value of a component of a CSS `<transform-origin>`.
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)]
#[derive(Clone, Debug, PartialEq, ToCss)]
pub enum OriginComponent<S> {
/// `center`
Center,

Просмотреть файл

@ -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
}
}
}
}
}

Просмотреть файл

@ -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();

Просмотреть файл

@ -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>>>;

Просмотреть файл

@ -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<T> HasViewportPercentage for Box<T>
where
T: ?Sized + HasViewportPercentage
{
#[inline]
fn has_viewport_percentage(&self) -> bool {
(**self).has_viewport_percentage()
}
}
impl<T: HasViewportPercentage> HasViewportPercentage for Option<T> {
#[inline]
fn has_viewport_percentage(&self) -> bool {
self.as_ref().map_or(false, T::has_viewport_percentage)
}
}
impl<T: HasViewportPercentage, U> HasViewportPercentage for TypedSize2D<T, U> {
#[inline]
fn has_viewport_percentage(&self) -> bool {
self.width.has_viewport_percentage() || self.height.has_viewport_percentage()
}
}
impl<T: HasViewportPercentage> HasViewportPercentage for Vec<T> {
#[inline]
fn has_viewport_percentage(&self) -> bool {
self.iter().any(T::has_viewport_percentage)
}
}
impl<T: HasViewportPercentage> 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

Просмотреть файл

@ -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() {

Просмотреть файл

@ -61,4 +61,3 @@ macro_rules! assert_roundtrip_with_context {
mod background;
mod scaffolding;
mod serialization;
mod viewport;

Просмотреть файл

@ -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());
}