servo: Merge #16960 - Derive HasViewportPercentage 🍷 (from servo:derive-all-the-things); r=emilio

Source-Repo: https://github.com/servo/servo
Source-Revision: 4f0b24ac0c3bd04104d705898ceb4d06ef5ea092

--HG--
rename : servo/components/domobject_derive/Cargo.toml => servo/components/style_derive/Cargo.toml
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 498aeee06ee32907459c0ba0c29d40189438fb0b
This commit is contained in:
Anthony Ramine 2017-05-20 11:34:36 -05:00
Π ΠΎΠ΄ΠΈΡ‚Π΅Π»ΡŒ 4eb32a2872
ΠšΠΎΠΌΠΌΠΈΡ‚ b991e3f4f2
40 ΠΈΠ·ΠΌΠ΅Π½Ρ‘Π½Π½Ρ‹Ρ… Ρ„Π°ΠΉΠ»ΠΎΠ²: 258 Π΄ΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠΉ ΠΈ 574 ΡƒΠ΄Π°Π»Π΅Π½ΠΈΠΉ

20
servo/Cargo.lock сгСнСрированный
ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -605,7 +605,7 @@ name = "deny_public_fields"
version = "0.0.1" version = "0.0.1"
dependencies = [ dependencies = [
"syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
"synstructure 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -1146,7 +1146,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
"synstructure 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -1346,7 +1346,7 @@ version = "0.0.1"
dependencies = [ dependencies = [
"quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
"synstructure 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "synstructure 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
@ -2860,6 +2860,7 @@ dependencies = [
"servo_config 0.0.1", "servo_config 0.0.1",
"servo_url 0.0.1", "servo_url 0.0.1",
"smallvec 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"style_derive 0.0.1",
"style_traits 0.0.1", "style_traits 0.0.1",
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2867,6 +2868,15 @@ dependencies = [
"walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "style_derive"
version = "0.0.1"
dependencies = [
"quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
"synstructure 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "style_tests" name = "style_tests"
version = "0.0.1" version = "0.0.1"
@ -2946,7 +2956,7 @@ dependencies = [
[[package]] [[package]]
name = "synstructure" name = "synstructure"
version = "0.5.0" version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
@ -3651,7 +3661,7 @@ dependencies = [
"checksum swapper 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca610b32bb8bfc5e7f705480c3a1edfeb70b6582495d343872c8bee0dcf758c" "checksum swapper 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3ca610b32bb8bfc5e7f705480c3a1edfeb70b6582495d343872c8bee0dcf758c"
"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" "checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad"
"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" "checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
"checksum synstructure 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5ccc9780bf1aa601943988c2876ab22413c01ad1739689aa6af18d0aa0b3f38b" "checksum synstructure 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cf318c34a2f8381a4f3d4db2c91b45bca2b1cd8cbe56caced900647be164800c"
"checksum syntex 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a8f5e3aaa79319573d19938ea38d068056b826db9883a5d47f86c1cecc688f0e" "checksum syntex 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a8f5e3aaa79319573d19938ea38d068056b826db9883a5d47f86c1cecc688f0e"
"checksum syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "867cc5c2d7140ae7eaad2ae9e8bf39cb18a67ca651b7834f88d46ca98faadb9c" "checksum syntex_errors 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "867cc5c2d7140ae7eaad2ae9e8bf39cb18a67ca651b7834f88d46ca98faadb9c"
"checksum syntex_pos 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "13ad4762fe52abc9f4008e85c4fb1b1fe3aa91ccb99ff4826a439c7c598e1047" "checksum syntex_pos 0.58.1 (registry+https://github.com/rust-lang/crates.io-index)" = "13ad4762fe52abc9f4008e85c4fb1b1fe3aa91ccb99ff4826a439c7c598e1047"

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -63,6 +63,7 @@ serde_derive = {version = "0.9", optional = true}
servo_atoms = {path = "../atoms", optional = true} servo_atoms = {path = "../atoms", optional = true}
servo_config = {path = "../config", optional = true} servo_config = {path = "../config", optional = true}
smallvec = "0.3.3" smallvec = "0.3.3"
style_derive = {path = "../style_derive"}
style_traits = {path = "../style_traits"} style_traits = {path = "../style_traits"}
servo_url = {path = "../url", optional = true} servo_url = {path = "../url", optional = true}
time = "0.1" time = "0.1"

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -79,6 +79,8 @@ extern crate selectors;
#[cfg(feature = "servo")] extern crate servo_url; #[cfg(feature = "servo")] extern crate servo_url;
extern crate smallvec; extern crate smallvec;
#[macro_use] #[macro_use]
extern crate style_derive;
#[macro_use]
extern crate style_traits; extern crate style_traits;
extern crate time; extern crate time;
#[allow(unused_extern_crates)] #[allow(unused_extern_crates)]

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -38,19 +38,6 @@ macro_rules! define_numbered_css_keyword_enum {
} }
} }
/// A macro used to implement HasViewportPercentage trait
/// for a given type that may never contain viewport units.
macro_rules! no_viewport_percentage {
($name: ident) => {
impl $crate::values::HasViewportPercentage for $name {
#[inline]
fn has_viewport_percentage(&self) -> bool {
false
}
}
};
}
/// A macro for implementing `ComputedValueAsSpecified`, `Parse` /// A macro for implementing `ComputedValueAsSpecified`, `Parse`
/// and `HasViewportPercentage` traits for the enums defined /// and `HasViewportPercentage` traits for the enums defined
/// using `define_css_keyword_enum` macro. /// using `define_css_keyword_enum` macro.

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -13,8 +13,11 @@
<%def name="predefined_type_inner(name, type, initial_value, parse_method)"> <%def name="predefined_type_inner(name, type, initial_value, parse_method)">
#[allow(unused_imports)] #[allow(unused_imports)]
use app_units::Au; use app_units::Au;
#[allow(unused_imports)]
use cssparser::{Color as CSSParserColor, RGBA}; use cssparser::{Color as CSSParserColor, RGBA};
#[allow(unused_imports)]
use values::specified::AllowQuirks; use values::specified::AllowQuirks;
#[allow(unused_imports)]
use smallvec::SmallVec; use smallvec::SmallVec;
pub use values::specified::${type} as SpecifiedValue; pub use values::specified::${type} as SpecifiedValue;
pub mod computed_value { pub mod computed_value {
@ -78,22 +81,22 @@
% if not gecko_only: % if not gecko_only:
use smallvec::SmallVec; use smallvec::SmallVec;
use std::fmt; use std::fmt;
#[allow(unused_imports)]
use values::HasViewportPercentage; use values::HasViewportPercentage;
use style_traits::ToCss; use style_traits::ToCss;
impl HasViewportPercentage for SpecifiedValue {
fn has_viewport_percentage(&self) -> bool {
let &SpecifiedValue(ref vec) = self;
vec.iter().any(|ref x| x.has_viewport_percentage())
}
}
pub mod single_value { pub mod single_value {
#[allow(unused_imports)]
use cssparser::Parser; use cssparser::Parser;
#[allow(unused_imports)]
use parser::{Parse, ParserContext}; use parser::{Parse, ParserContext};
#[allow(unused_imports)]
use properties::ShorthandId; use properties::ShorthandId;
#[allow(unused_imports)]
use values::computed::{Context, ToComputedValue}; use values::computed::{Context, ToComputedValue};
#[allow(unused_imports)]
use values::{computed, specified}; use values::{computed, specified};
#[allow(unused_imports)]
use values::{Auto, Either, None_, Normal}; use values::{Auto, Either, None_, Normal};
${caller.body()} ${caller.body()}
} }
@ -168,7 +171,7 @@
} }
/// The specified value of ${name}. /// The specified value of ${name}.
#[derive(Debug, Clone, PartialEq)] #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct SpecifiedValue(pub Vec<single_value::SpecifiedValue>); pub struct SpecifiedValue(pub Vec<single_value::SpecifiedValue>);
@ -205,6 +208,7 @@
} }
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> { pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
#[allow(unused_imports)]
use parser::parse_space_or_comma_separated; use parser::parse_space_or_comma_separated;
<% <%
@ -260,22 +264,35 @@
%> %>
/// ${property.spec} /// ${property.spec}
pub mod ${property.ident} { pub mod ${property.ident} {
#![allow(unused_imports)]
% if not property.derived_from: % if not property.derived_from:
#[allow(unused_imports)]
use cssparser::Parser; use cssparser::Parser;
#[allow(unused_imports)]
use parser::{Parse, ParserContext}; use parser::{Parse, ParserContext};
#[allow(unused_imports)]
use properties::{UnparsedValue, ShorthandId}; use properties::{UnparsedValue, ShorthandId};
% endif % endif
#[allow(unused_imports)]
use values::{Auto, Either, None_, Normal}; use values::{Auto, Either, None_, Normal};
#[allow(unused_imports)]
use cascade_info::CascadeInfo; use cascade_info::CascadeInfo;
#[allow(unused_imports)]
use error_reporting::ParseErrorReporter; use error_reporting::ParseErrorReporter;
#[allow(unused_imports)]
use properties::longhands; use properties::longhands;
#[allow(unused_imports)]
use properties::{DeclaredValue, LonghandId, LonghandIdSet}; use properties::{DeclaredValue, LonghandId, LonghandIdSet};
#[allow(unused_imports)]
use properties::{CSSWideKeyword, ComputedValues, PropertyDeclaration}; use properties::{CSSWideKeyword, ComputedValues, PropertyDeclaration};
#[allow(unused_imports)]
use properties::style_structs; use properties::style_structs;
#[allow(unused_imports)]
use stylearc::Arc; use stylearc::Arc;
#[allow(unused_imports)]
use values::computed::{Context, ToComputedValue}; use values::computed::{Context, ToComputedValue};
#[allow(unused_imports)]
use values::{computed, generics, specified}; use values::{computed, generics, specified};
#[allow(unused_imports)]
use Atom; use Atom;
${caller.body()} ${caller.body()}
#[allow(unused_variables)] #[allow(unused_variables)]
@ -461,7 +478,6 @@
keyword = keyword=Keyword(name, values, **keyword_kwargs) keyword = keyword=Keyword(name, values, **keyword_kwargs)
%> %>
<%call expr="longhand(name, keyword=Keyword(name, values, **keyword_kwargs), **kwargs)"> <%call expr="longhand(name, keyword=Keyword(name, values, **keyword_kwargs), **kwargs)">
use values::HasViewportPercentage;
use properties::longhands::system_font::SystemFont; use properties::longhands::system_font::SystemFont;
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
@ -583,7 +599,6 @@
impl ComputedValueAsSpecified for SpecifiedValue {} impl ComputedValueAsSpecified for SpecifiedValue {}
% endif % endif
use values::HasViewportPercentage;
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
</%call> </%call>
</%def> </%def>
@ -745,7 +760,6 @@
% if shorthand: % if shorthand:
/// ${shorthand.spec} /// ${shorthand.spec}
pub mod ${shorthand.ident} { pub mod ${shorthand.ident} {
#[allow(unused_imports)]
use cssparser::Parser; use cssparser::Parser;
use parser::ParserContext; use parser::ParserContext;
use properties::{PropertyDeclaration, SourcePropertyDeclaration, MaybeBoxed}; use properties::{PropertyDeclaration, SourcePropertyDeclaration, MaybeBoxed};

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -34,7 +34,6 @@ ${helpers.predefined_type("background-image", "ImageLayer",
spec="https://drafts.csswg.org/css-backgrounds/#the-background-repeat"> spec="https://drafts.csswg.org/css-backgrounds/#the-background-repeat">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
define_css_keyword_enum!(RepeatKeyword: define_css_keyword_enum!(RepeatKeyword:
"repeat" => Repeat, "repeat" => Repeat,
@ -163,11 +162,8 @@ ${helpers.single_keyword("background-origin",
<%helpers:vector_longhand name="background-size" animation_value_type="ComputedValue" extra_prefixes="webkit" <%helpers:vector_longhand name="background-size" animation_value_type="ComputedValue" extra_prefixes="webkit"
spec="https://drafts.csswg.org/css-backgrounds/#the-background-size"> spec="https://drafts.csswg.org/css-backgrounds/#the-background-size">
use cssparser::Token;
use std::ascii::AsciiExt;
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
#[allow(missing_docs)] #[allow(missing_docs)]
pub mod computed_value { pub mod computed_value {
@ -236,13 +232,7 @@ ${helpers.single_keyword("background-origin",
} }
} }
impl HasViewportPercentage for ExplicitSize { #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
fn has_viewport_percentage(&self) -> bool {
return self.width.has_viewport_percentage() || self.height.has_viewport_percentage();
}
}
#[derive(Clone, PartialEq, Debug)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[allow(missing_docs)] #[allow(missing_docs)]
pub struct ExplicitSize { pub struct ExplicitSize {
@ -266,16 +256,7 @@ ${helpers.single_keyword("background-origin",
} }
} }
impl HasViewportPercentage for SpecifiedValue { #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
fn has_viewport_percentage(&self) -> bool {
match *self {
SpecifiedValue::Explicit(ref explicit_size) => explicit_size.has_viewport_percentage(),
_ => false
}
}
}
#[derive(Clone, PartialEq, Debug)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum SpecifiedValue { pub enum SpecifiedValue {
Explicit(ExplicitSize), Explicit(ExplicitSize),

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -62,7 +62,6 @@ ${helpers.gecko_keyword_conversion(Keyword('border-style',
products="gecko"> products="gecko">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
use values::specified::CSSColor; use values::specified::CSSColor;
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
@ -205,20 +204,8 @@ ${helpers.predefined_type("border-image-source", "ImageLayer",
spec="https://drafts.csswg.org/css-backgrounds/#border-image-outset"> spec="https://drafts.csswg.org/css-backgrounds/#border-image-outset">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
use values::specified::{LengthOrNumber, Number}; use values::specified::{LengthOrNumber, Number};
impl HasViewportPercentage for SpecifiedValue {
fn has_viewport_percentage(&self) -> bool {
let mut viewport_percentage = false;
for value in self.0.iter() {
let vp = value.has_viewport_percentage();
viewport_percentage = vp || viewport_percentage;
}
viewport_percentage
}
}
pub mod computed_value { pub mod computed_value {
use values::computed::LengthOrNumber; use values::computed::LengthOrNumber;
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
@ -227,7 +214,7 @@ ${helpers.predefined_type("border-image-source", "ImageLayer",
pub LengthOrNumber, pub LengthOrNumber); pub LengthOrNumber, pub LengthOrNumber);
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct SpecifiedValue(pub Vec<LengthOrNumber>); pub struct SpecifiedValue(pub Vec<LengthOrNumber>);
@ -321,13 +308,11 @@ ${helpers.predefined_type("border-image-source", "ImageLayer",
spec="https://drafts.csswg.org/css-backgrounds/#border-image-repeat"> spec="https://drafts.csswg.org/css-backgrounds/#border-image-repeat">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
pub mod computed_value { pub mod computed_value {
pub use super::RepeatKeyword; pub use super::RepeatKeyword;
use values::computed;
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
@ -399,23 +384,8 @@ ${helpers.predefined_type("border-image-source", "ImageLayer",
spec="https://drafts.csswg.org/css-backgrounds/#border-image-width"> spec="https://drafts.csswg.org/css-backgrounds/#border-image-width">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
use values::specified::{LengthOrPercentage, Number}; use values::specified::{LengthOrPercentage, Number};
impl HasViewportPercentage for SpecifiedValue {
fn has_viewport_percentage(&self) -> bool {
let mut viewport_percentage = false;
for value in self.0.clone() {
let vp = match value {
SingleSpecifiedValue::LengthOrPercentage(len) => len.has_viewport_percentage(),
_ => false,
};
viewport_percentage = vp || viewport_percentage;
}
viewport_percentage
}
}
pub mod computed_value { pub mod computed_value {
use values::computed::{LengthOrPercentage, Number}; use values::computed::{LengthOrPercentage, Number};
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
@ -432,7 +402,7 @@ ${helpers.predefined_type("border-image-source", "ImageLayer",
} }
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct SpecifiedValue(pub Vec<SingleSpecifiedValue>); pub struct SpecifiedValue(pub Vec<SingleSpecifiedValue>);
@ -458,7 +428,7 @@ ${helpers.predefined_type("border-image-source", "ImageLayer",
} }
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum SingleSpecifiedValue { pub enum SingleSpecifiedValue {
LengthOrPercentage(LengthOrPercentage), LengthOrPercentage(LengthOrPercentage),
@ -599,7 +569,6 @@ ${helpers.predefined_type("border-image-source", "ImageLayer",
spec="https://drafts.csswg.org/css-backgrounds/#border-image-slice"> spec="https://drafts.csswg.org/css-backgrounds/#border-image-slice">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
use values::computed::NumberOrPercentage as ComputedNumberOrPercentage; use values::computed::NumberOrPercentage as ComputedNumberOrPercentage;
use values::specified::{NumberOrPercentage, Percentage}; use values::specified::{NumberOrPercentage, Percentage};

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -31,7 +31,6 @@
%> %>
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
pub mod computed_value { pub mod computed_value {
@ -170,7 +169,6 @@ ${helpers.single_keyword("position", "static absolute relative fixed",
gecko_inexhaustive="True" gecko_inexhaustive="True"
gecko_ffi_name="mFloat" gecko_ffi_name="mFloat"
spec="https://drafts.csswg.org/css-box/#propdef-float"> spec="https://drafts.csswg.org/css-box/#propdef-float">
use values::HasViewportPercentage;
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
impl ToComputedValue for SpecifiedValue { impl ToComputedValue for SpecifiedValue {
type ComputedValue = computed_value::T; type ComputedValue = computed_value::T;
@ -209,7 +207,6 @@ ${helpers.single_keyword("position", "static absolute relative fixed",
gecko_enum_prefix="StyleClear" gecko_enum_prefix="StyleClear"
gecko_ffi_name="mBreakType" gecko_ffi_name="mBreakType"
spec="https://www.w3.org/TR/CSS2/visuren.html#flow-control"> spec="https://www.w3.org/TR/CSS2/visuren.html#flow-control">
use values::HasViewportPercentage;
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
impl ToComputedValue for SpecifiedValue { impl ToComputedValue for SpecifiedValue {
type ComputedValue = computed_value::T; type ComputedValue = computed_value::T;
@ -263,7 +260,6 @@ ${helpers.single_keyword("position", "static absolute relative fixed",
spec="https://www.w3.org/TR/CSS2/visudet.html#propdef-vertical-align"> spec="https://www.w3.org/TR/CSS2/visudet.html#propdef-vertical-align">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
use values::specified::AllowQuirks; use values::specified::AllowQuirks;
<% vertical_align = data.longhands_by_name["vertical-align"] %> <% vertical_align = data.longhands_by_name["vertical-align"] %>
@ -274,18 +270,9 @@ ${helpers.single_keyword("position", "static absolute relative fixed",
${helpers.gecko_keyword_conversion(vertical_align.keyword)} ${helpers.gecko_keyword_conversion(vertical_align.keyword)}
impl HasViewportPercentage for SpecifiedValue {
fn has_viewport_percentage(&self) -> bool {
match *self {
SpecifiedValue::LengthOrPercentage(ref length) => length.has_viewport_percentage(),
_ => false
}
}
}
/// The `vertical-align` value. /// The `vertical-align` value.
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[derive(Debug, Clone, PartialEq)] #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum SpecifiedValue { pub enum SpecifiedValue {
% for keyword in vertical_align_keywords: % for keyword in vertical_align_keywords:
@ -321,10 +308,9 @@ ${helpers.single_keyword("position", "static absolute relative fixed",
/// The computed value for `vertical-align`. /// The computed value for `vertical-align`.
pub mod computed_value { pub mod computed_value {
use app_units::Au;
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::{CSSFloat, computed}; use values::computed;
/// The keywords are the same, and the `LengthOrPercentage` is computed /// The keywords are the same, and the `LengthOrPercentage` is computed
/// here. /// here.
@ -426,7 +412,6 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
use values::specified::Time; use values::specified::Time;
pub use values::specified::Time as SpecifiedValue; pub use values::specified::Time as SpecifiedValue;
use values::HasViewportPercentage;
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
pub mod computed_value { pub mod computed_value {
@ -458,7 +443,6 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
use values::specified::Number; use values::specified::Number;
use euclid::point::{Point2D, TypedPoint2D}; use euclid::point::{Point2D, TypedPoint2D};
use std::fmt; use std::fmt;
use std::marker::PhantomData;
use style_traits::ToCss; use style_traits::ToCss;
// FIXME: This could use static variables and const functions when they are available. // FIXME: This could use static variables and const functions when they are available.
@ -499,7 +483,6 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
pub mod computed_value { pub mod computed_value {
use euclid::point::Point2D; use euclid::point::Point2D;
use parser::{Parse, ParserContext};
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use super::FunctionKeyword; use super::FunctionKeyword;
@ -764,7 +747,6 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
} }
} }
use values::HasViewportPercentage;
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
#[inline] #[inline]
@ -795,8 +777,6 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
pub use properties::animated_properties::TransitionProperty as SpecifiedValue; pub use properties::animated_properties::TransitionProperty as SpecifiedValue;
pub mod computed_value { pub mod computed_value {
use std::fmt;
use style_traits::ToCss;
// NB: Can't generate the type here because it needs all the longhands // NB: Can't generate the type here because it needs all the longhands
// generated beforehand. // generated beforehand.
pub use super::SpecifiedValue as T; pub use super::SpecifiedValue as T;
@ -810,7 +790,6 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
TransitionProperty::All TransitionProperty::All
} }
use values::HasViewportPercentage;
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
impl ComputedValueAsSpecified for SpecifiedValue { } impl ComputedValueAsSpecified for SpecifiedValue { }
@ -839,10 +818,9 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
spec="https://drafts.csswg.org/css-animations/#propdef-animation-name"> spec="https://drafts.csswg.org/css-animations/#propdef-animation-name">
use Atom; use Atom;
use std::fmt; use std::fmt;
use std::ops::Deref;
use style_traits::ToCss; use style_traits::ToCss;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
use values::{HasViewportPercentage, KeyframesName}; use values::KeyframesName;
pub mod computed_value { pub mod computed_value {
pub use super::SpecifiedValue as T; pub use super::SpecifiedValue as T;
@ -937,7 +915,6 @@ ${helpers.single_keyword("overflow-x", "visible hidden scroll auto",
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
use values::HasViewportPercentage;
pub mod computed_value { pub mod computed_value {
pub use super::SpecifiedValue as T; pub use super::SpecifiedValue as T;
@ -1045,18 +1022,8 @@ ${helpers.single_keyword("animation-fill-mode",
spec="Nonstandard (https://www.w3.org/TR/2015/WD-css-snappoints-1-20150326/#scroll-snap-points)"> spec="Nonstandard (https://www.w3.org/TR/2015/WD-css-snappoints-1-20150326/#scroll-snap-points)">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
use values::specified::LengthOrPercentage; use values::specified::LengthOrPercentage;
impl HasViewportPercentage for SpecifiedValue {
fn has_viewport_percentage(&self) -> bool {
match *self {
SpecifiedValue::Repeat(ref length) => length.has_viewport_percentage(),
_ => false
}
}
}
pub mod computed_value { pub mod computed_value {
use values::computed::LengthOrPercentage; use values::computed::LengthOrPercentage;
@ -1065,7 +1032,7 @@ ${helpers.single_keyword("animation-fill-mode",
pub struct T(pub Option<LengthOrPercentage>); pub struct T(pub Option<LengthOrPercentage>);
} }
#[derive(Debug, Clone, PartialEq)] #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum SpecifiedValue { pub enum SpecifiedValue {
None, None,
@ -1175,9 +1142,8 @@ ${helpers.predefined_type("scroll-snap-coordinate",
use values::specified::{LengthOrNumber, LengthOrPercentageOrNumber as LoPoNumber, Number}; use values::specified::{LengthOrNumber, LengthOrPercentageOrNumber as LoPoNumber, Number};
use style_traits::ToCss; use style_traits::ToCss;
use style_traits::values::Css; use style_traits::values::Css;
use values::HasViewportPercentage;
use std::fmt::{self, Display}; use std::fmt;
pub mod computed_value { pub mod computed_value {
use app_units::Au; use app_units::Au;
@ -1253,7 +1219,7 @@ ${helpers.predefined_type("scroll-snap-coordinate",
/// Multiple transform functions compose a transformation. /// Multiple transform functions compose a transformation.
/// ///
/// Some transformations can be expressed by other more general functions. /// Some transformations can be expressed by other more general functions.
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum SpecifiedOperation { pub enum SpecifiedOperation {
/// Represents a 2D 2x3 matrix. /// Represents a 2D 2x3 matrix.
@ -1328,41 +1294,6 @@ ${helpers.predefined_type("scroll-snap-coordinate",
} }
} }
impl HasViewportPercentage for SpecifiedOperation {
fn has_viewport_percentage(&self) -> bool {
match *self {
SpecifiedOperation::Translate(ref l1, None) |
SpecifiedOperation::TranslateX(ref l1) |
SpecifiedOperation::TranslateY(ref l1) => {
l1.has_viewport_percentage()
}
SpecifiedOperation::TranslateZ(ref l1) => {
l1.has_viewport_percentage()
}
SpecifiedOperation::Translate(ref l1, Some(ref l2)) => {
l1.has_viewport_percentage() ||
l2.has_viewport_percentage()
}
SpecifiedOperation::Translate3D(ref l1, ref l2, ref l3) => {
l1.has_viewport_percentage() ||
l2.has_viewport_percentage() ||
l3.has_viewport_percentage()
},
SpecifiedOperation::Perspective(ref length) => length.has_viewport_percentage(),
SpecifiedOperation::PrefixedMatrix{ ref e, ref f, .. } => {
e.has_viewport_percentage() ||
f.has_viewport_percentage()
},
SpecifiedOperation::PrefixedMatrix3D{ ref m41, ref m42, ref m43, .. } => {
m41.has_viewport_percentage() ||
m42.has_viewport_percentage() ||
m43.has_viewport_percentage()
},
_ => false
}
}
}
impl ToCss for SpecifiedOperation { impl ToCss for SpecifiedOperation {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
use self::SpecifiedOperation::*; use self::SpecifiedOperation::*;
@ -1422,14 +1353,7 @@ ${helpers.predefined_type("scroll-snap-coordinate",
} }
} }
impl HasViewportPercentage for SpecifiedValue { #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
fn has_viewport_percentage(&self) -> bool {
let &SpecifiedValue(ref specified_ops) = self;
specified_ops.iter().any(|ref x| x.has_viewport_percentage())
}
}
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct SpecifiedValue(Vec<SpecifiedOperation>); pub struct SpecifiedValue(Vec<SpecifiedOperation>);
@ -2181,7 +2105,6 @@ ${helpers.single_keyword("transform-style",
use app_units::Au; use app_units::Au;
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
use values::specified::{NoCalcLength, LengthOrPercentage, Percentage}; use values::specified::{NoCalcLength, LengthOrPercentage, Percentage};
pub mod computed_value { pub mod computed_value {
@ -2223,15 +2146,7 @@ ${helpers.single_keyword("transform-style",
} }
} }
impl HasViewportPercentage for SpecifiedValue { #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
fn has_viewport_percentage(&self) -> bool {
self.horizontal.has_viewport_percentage() ||
self.vertical.has_viewport_percentage() ||
self.depth.has_viewport_percentage()
}
}
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct SpecifiedValue { pub struct SpecifiedValue {
horizontal: LengthOrPercentage, horizontal: LengthOrPercentage,
@ -2307,7 +2222,6 @@ ${helpers.single_keyword("transform-style",
spec="https://drafts.csswg.org/css-contain/#contain-property"> spec="https://drafts.csswg.org/css-contain/#contain-property">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
impl ComputedValueAsSpecified for SpecifiedValue {} impl ComputedValueAsSpecified for SpecifiedValue {}
@ -2460,7 +2374,6 @@ ${helpers.single_keyword("-moz-orient",
use cssparser::serialize_identifier; use cssparser::serialize_identifier;
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
impl ComputedValueAsSpecified for SpecifiedValue {} impl ComputedValueAsSpecified for SpecifiedValue {}
@ -2533,7 +2446,6 @@ ${helpers.predefined_type("shape-outside", "basic_shape::ShapeWithShapeBox",
use gecko_bindings::structs; use gecko_bindings::structs;
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
impl ComputedValueAsSpecified for SpecifiedValue {} impl ComputedValueAsSpecified for SpecifiedValue {}

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -14,7 +14,7 @@
use cssparser::RGBA; use cssparser::RGBA;
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::specified::{AllowQuirks, Color, CSSColor, CSSRGBA}; use values::specified::{AllowQuirks, Color, CSSColor};
impl ToComputedValue for SpecifiedValue { impl ToComputedValue for SpecifiedValue {
type ComputedValue = computed_value::T; type ComputedValue = computed_value::T;
@ -122,6 +122,7 @@
impl SystemColor { impl SystemColor {
pub fn parse(input: &mut Parser) -> Result<Self, ()> { pub fn parse(input: &mut Parser) -> Result<Self, ()> {
#[cfg(feature = "gecko")]
use std::ascii::AsciiExt; use std::ascii::AsciiExt;
static PARSE_ARRAY: &'static [(&'static str, SystemColor); ${len(system_colors)}] = &[ static PARSE_ARRAY: &'static [(&'static str, SystemColor); ${len(system_colors)}] = &[
% for color in system_colors: % for color in system_colors:

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -9,12 +9,11 @@
<%helpers:longhand name="content" boxed="True" animation_value_type="none" <%helpers:longhand name="content" boxed="True" animation_value_type="none"
spec="https://drafts.csswg.org/css-content/#propdef-content"> spec="https://drafts.csswg.org/css-content/#propdef-content">
use cssparser::Token; use cssparser::Token;
use std::ascii::AsciiExt;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
use values::generics::CounterStyleOrNone; use values::generics::CounterStyleOrNone;
#[cfg(feature = "gecko")]
use values::specified::url::SpecifiedUrl; use values::specified::url::SpecifiedUrl;
use values::HasViewportPercentage;
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
use super::list_style_type; use super::list_style_type;
@ -29,6 +28,7 @@
use cssparser; use cssparser;
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
#[cfg(feature = "gecko")]
use values::specified::url::SpecifiedUrl; use values::specified::url::SpecifiedUrl;
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
@ -256,11 +256,9 @@
spec="https://drafts.csswg.org/css-lists/#propdef-counter-increment"> spec="https://drafts.csswg.org/css-lists/#propdef-counter-increment">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use super::content; use values::CustomIdent;
use values::{HasViewportPercentage, CustomIdent};
use cssparser::{Token, serialize_identifier}; use cssparser::Token;
use std::borrow::{Cow, ToOwned};
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub struct SpecifiedValue(pub Vec<(CustomIdent, specified::Integer)>); pub struct SpecifiedValue(pub Vec<(CustomIdent, specified::Integer)>);
@ -278,7 +276,6 @@
fn to_css<W>(&self, dest: &mut W) -> fmt::Result fn to_css<W>(&self, dest: &mut W) -> fmt::Result
where W: fmt::Write, where W: fmt::Write,
{ {
use cssparser::serialize_identifier;
if self.0.is_empty() { if self.0.is_empty() {
return dest.write_str("none") return dest.write_str("none")
} }
@ -348,8 +345,6 @@
} }
pub fn parse_common(context: &ParserContext, default_value: i32, input: &mut Parser) -> Result<SpecifiedValue, ()> { pub fn parse_common(context: &ParserContext, default_value: i32, input: &mut Parser) -> Result<SpecifiedValue, ()> {
use std::ascii::AsciiExt;
if input.try(|input| input.expect_ident_matching("none")).is_ok() { if input.try(|input| input.expect_ident_matching("none")).is_ok() {
return Ok(SpecifiedValue(Vec::new())) return Ok(SpecifiedValue(Vec::new()))
} }

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -18,10 +18,8 @@ ${helpers.predefined_type("opacity",
animation_value_type="IntermediateBoxShadowList" animation_value_type="IntermediateBoxShadowList"
extra_prefixes="webkit" extra_prefixes="webkit"
spec="https://drafts.csswg.org/css-backgrounds/#box-shadow"> spec="https://drafts.csswg.org/css-backgrounds/#box-shadow">
use cssparser;
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
pub type SpecifiedValue = specified::Shadow; pub type SpecifiedValue = specified::Shadow;
@ -47,9 +45,6 @@ ${helpers.predefined_type("opacity",
} }
pub mod computed_value { pub mod computed_value {
use app_units::Au;
use std::fmt;
use values::computed;
use values::computed::Shadow; use values::computed::Shadow;
pub type T = Shadow; pub type T = Shadow;
@ -91,20 +86,16 @@ ${helpers.predefined_type("clip",
flags="CREATES_STACKING_CONTEXT FIXPOS_CB" flags="CREATES_STACKING_CONTEXT FIXPOS_CB"
spec="https://drafts.fxtf.org/filters/#propdef-filter"> spec="https://drafts.fxtf.org/filters/#propdef-filter">
//pub use self::computed_value::T as SpecifiedValue; //pub use self::computed_value::T as SpecifiedValue;
use cssparser;
use std::fmt; use std::fmt;
use style_traits::{self, ToCss}; use style_traits::ToCss;
use values::{CSSFloat, HasViewportPercentage}; use values::{CSSFloat, HasViewportPercentage};
use values::specified::{Angle, CSSColor, Length, Shadow}; use values::specified::{Angle, Length};
#[cfg(feature = "gecko")]
use values::specified::Shadow;
#[cfg(feature = "gecko")]
use values::specified::url::SpecifiedUrl; use values::specified::url::SpecifiedUrl;
impl HasViewportPercentage for SpecifiedValue { #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
fn has_viewport_percentage(&self) -> bool {
self.0.iter().any(|ref x| x.has_viewport_percentage())
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct SpecifiedValue(pub Vec<SpecifiedFilter>); pub struct SpecifiedValue(pub Vec<SpecifiedFilter>);
@ -139,8 +130,10 @@ ${helpers.predefined_type("clip",
pub mod computed_value { pub mod computed_value {
use app_units::Au; use app_units::Au;
use values::CSSFloat; use values::CSSFloat;
use values::computed::{CSSColor, Shadow}; #[cfg(feature = "gecko")]
use values::computed::Shadow;
use values::computed::Angle; use values::computed::Angle;
#[cfg(feature = "gecko")]
use values::specified::url::SpecifiedUrl; use values::specified::url::SpecifiedUrl;
#[derive(Clone, PartialEq, Debug)] #[derive(Clone, PartialEq, Debug)]

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -68,14 +68,11 @@
use self::computed_value::{FontFamily, FamilyName}; use self::computed_value::{FontFamily, FamilyName};
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
use values::computed::ComputedValueAsSpecified;
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
pub mod computed_value { pub mod computed_value {
use cssparser::{CssStringWriter, Parser, serialize_identifier}; use cssparser::{CssStringWriter, Parser, serialize_identifier};
use properties::longhands::system_font::SystemFont;
use std::fmt::{self, Write}; use std::fmt::{self, Write};
use Atom; use Atom;
use style_traits::ToCss; use style_traits::ToCss;
@ -355,7 +352,6 @@ ${helpers.single_keyword_system("font-variant-caps",
spec="https://drafts.csswg.org/css-fonts/#propdef-font-weight"> spec="https://drafts.csswg.org/css-fonts/#propdef-font-weight">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
use properties::longhands::system_font::SystemFont; use properties::longhands::system_font::SystemFont;
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
@ -449,7 +445,6 @@ ${helpers.single_keyword_system("font-variant-caps",
} }
pub mod computed_value { pub mod computed_value {
use std::fmt;
#[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)] #[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))]
#[repr(u16)] #[repr(u16)]
@ -557,7 +552,7 @@ ${helpers.single_keyword_system("font-variant-caps",
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::{FONT_MEDIUM_PX, HasViewportPercentage}; use values::{FONT_MEDIUM_PX, HasViewportPercentage};
use values::specified::{AllowQuirks, FontRelativeLength, LengthOrPercentage, Length}; use values::specified::{AllowQuirks, FontRelativeLength, LengthOrPercentage};
use values::specified::{NoCalcLength, Percentage}; use values::specified::{NoCalcLength, Percentage};
use values::specified::length::FontBaseSize; use values::specified::length::FontBaseSize;
@ -694,8 +689,7 @@ ${helpers.single_keyword_system("font-variant-caps",
type ComputedValue = Au; type ComputedValue = Au;
#[inline] #[inline]
fn to_computed_value(&self, cx: &Context) -> computed_value::T { fn to_computed_value(&self, cx: &Context) -> computed_value::T {
use gecko_bindings::bindings::Gecko_GetBaseSize; use gecko_bindings::structs::nsIAtom;
use gecko_bindings::structs::{self, nsIAtom};
use values::specified::length::au_to_int_px; use values::specified::length::au_to_int_px;
// Data from nsRuleNode.cpp in Gecko // Data from nsRuleNode.cpp in Gecko
// Mapping from base size and HTML size to pixels // Mapping from base size and HTML size to pixels
@ -977,7 +971,6 @@ ${helpers.single_keyword_system("font-variant-caps",
use properties::longhands::system_font::SystemFont; use properties::longhands::system_font::SystemFont;
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
@ -1119,7 +1112,6 @@ ${helpers.single_keyword_system("font-variant-caps",
spec="https://drafts.csswg.org/css-fonts/#propdef-font-synthesis"> spec="https://drafts.csswg.org/css-fonts/#propdef-font-synthesis">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
impl ComputedValueAsSpecified for SpecifiedValue {} impl ComputedValueAsSpecified for SpecifiedValue {}
@ -1203,7 +1195,6 @@ ${helpers.single_keyword_system("font-kerning",
use properties::longhands::system_font::SystemFont; use properties::longhands::system_font::SystemFont;
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
@ -1339,7 +1330,6 @@ macro_rules! exclusive_value {
use properties::longhands::system_font::SystemFont; use properties::longhands::system_font::SystemFont;
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
@ -1480,7 +1470,6 @@ macro_rules! exclusive_value {
use properties::longhands::system_font::SystemFont; use properties::longhands::system_font::SystemFont;
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
@ -1631,7 +1620,6 @@ macro_rules! exclusive_value {
use properties::longhands::system_font::SystemFont; use properties::longhands::system_font::SystemFont;
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
@ -1784,8 +1772,6 @@ ${helpers.single_keyword_system("font-variant-position",
use properties::longhands::system_font::SystemFont; use properties::longhands::system_font::SystemFont;
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
use values::computed::ComputedValueAsSpecified;
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub enum SpecifiedValue { pub enum SpecifiedValue {
@ -1868,8 +1854,6 @@ ${helpers.single_keyword_system("font-variant-position",
/// <string> [ on | off | <integer> ] /// <string> [ on | off | <integer> ]
fn parse(_context: &ParserContext, input: &mut Parser) -> Result<Self, ()> { fn parse(_context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
use std::io::Cursor; use std::io::Cursor;
use std::str;
use std::ops::Deref;
use byteorder::{ReadBytesExt, BigEndian}; use byteorder::{ReadBytesExt, BigEndian};
let tag = try!(input.expect_string()); let tag = try!(input.expect_string());
@ -1928,7 +1912,6 @@ ${helpers.single_keyword_system("font-variant-position",
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use byteorder::{BigEndian, ByteOrder}; use byteorder::{BigEndian, ByteOrder};
use values::HasViewportPercentage;
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
@ -2063,7 +2046,6 @@ ${helpers.single_keyword_system("font-variant-position",
<%helpers:longhand name="-x-lang" products="gecko" animation_value_type="none" internal="True" <%helpers:longhand name="-x-lang" products="gecko" animation_value_type="none" internal="True"
spec="Internal (not web-exposed)"> spec="Internal (not web-exposed)">
use values::HasViewportPercentage;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
pub use self::computed_value::T as SpecifiedValue; pub use self::computed_value::T as SpecifiedValue;
@ -2102,12 +2084,10 @@ ${helpers.single_keyword_system("font-variant-position",
predefined_type="Number" gecko_ffi_name="mScriptSizeMultiplier" predefined_type="Number" gecko_ffi_name="mScriptSizeMultiplier"
spec="Internal (not web-exposed)" spec="Internal (not web-exposed)"
internal="True" disable_when_testing="True"> internal="True" disable_when_testing="True">
use values::HasViewportPercentage;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
pub use self::computed_value::T as SpecifiedValue; pub use self::computed_value::T as SpecifiedValue;
impl ComputedValueAsSpecified for SpecifiedValue {} impl ComputedValueAsSpecified for SpecifiedValue {}
no_viewport_percentage!(SpecifiedValue);
pub mod computed_value { pub mod computed_value {
pub type T = f32; pub type T = f32;
@ -2130,7 +2110,6 @@ ${helpers.single_keyword_system("font-variant-position",
internal="True" disable_when_testing="True" need_clone="True"> internal="True" disable_when_testing="True" need_clone="True">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
@ -2230,11 +2209,9 @@ ${helpers.single_keyword("-moz-math-variant",
use gecko_bindings::structs::NS_MATHML_DEFAULT_SCRIPT_MIN_SIZE_PT; use gecko_bindings::structs::NS_MATHML_DEFAULT_SCRIPT_MIN_SIZE_PT;
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
use values::computed::ComputedValueAsSpecified;
use values::specified::length::{AU_PER_PT, FontBaseSize, NoCalcLength}; use values::specified::length::{AU_PER_PT, FontBaseSize, NoCalcLength};
#[derive(Clone, PartialEq, Debug)] #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
pub struct SpecifiedValue(pub NoCalcLength); pub struct SpecifiedValue(pub NoCalcLength);
pub mod computed_value { pub mod computed_value {
@ -2272,12 +2249,6 @@ ${helpers.single_keyword("-moz-math-variant",
} }
} }
impl HasViewportPercentage for SpecifiedValue {
fn has_viewport_percentage(&self) -> bool {
self.0.has_viewport_percentage()
}
}
#[inline] #[inline]
pub fn get_initial_value() -> computed_value::T { pub fn get_initial_value() -> computed_value::T {
Au((NS_MATHML_DEFAULT_SCRIPT_MIN_SIZE_PT as f32 * AU_PER_PT) as i32) Au((NS_MATHML_DEFAULT_SCRIPT_MIN_SIZE_PT as f32 * AU_PER_PT) as i32)

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -68,7 +68,6 @@ ${helpers.single_keyword("image-rendering",
use style_traits::ToCss; use style_traits::ToCss;
use values::specified::Angle; use values::specified::Angle;
use values::HasViewportPercentage;
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
use std::f32::consts::PI; use std::f32::consts::PI;
@ -207,7 +206,6 @@ ${helpers.single_keyword("image-rendering",
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
use values::HasViewportPercentage;
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -144,7 +144,6 @@ ${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)",
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
pub const NORMAL: u8 = 0; pub const NORMAL: u8 = 0;
pub const FILL: u8 = 1; pub const FILL: u8 = 1;

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -25,7 +25,6 @@ ${helpers.single_keyword("caption-side", "top bottom",
use app_units::Au; use app_units::Au;
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
use values::specified::{AllowQuirks, Length}; use values::specified::{AllowQuirks, Length};
pub mod computed_value { pub mod computed_value {
@ -65,14 +64,7 @@ ${helpers.single_keyword("caption-side", "top bottom",
} }
} }
impl HasViewportPercentage for SpecifiedValue { #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
fn has_viewport_percentage(&self) -> bool {
self.horizontal.has_viewport_percentage() ||
self.vertical.as_ref().map_or(false, |v| v.has_viewport_percentage())
}
}
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct SpecifiedValue { pub struct SpecifiedValue {
pub horizontal: Length, pub horizontal: Length,

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -10,18 +10,8 @@
spec="https://drafts.csswg.org/css2/visudet.html#propdef-line-height"> spec="https://drafts.csswg.org/css2/visudet.html#propdef-line-height">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
impl HasViewportPercentage for SpecifiedValue { #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
fn has_viewport_percentage(&self) -> bool {
match *self {
SpecifiedValue::LengthOrPercentage(ref length) => length.has_viewport_percentage(),
_ => false
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum SpecifiedValue { pub enum SpecifiedValue {
Normal, Normal,
@ -75,7 +65,6 @@
} }
pub mod computed_value { pub mod computed_value {
use app_units::Au; use app_units::Au;
use std::fmt;
use values::CSSFloat; use values::CSSFloat;
#[derive(PartialEq, Copy, Clone, Debug)] #[derive(PartialEq, Copy, Clone, Debug)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
@ -212,7 +201,6 @@ ${helpers.single_keyword("word-break",
gecko_enum_prefix="StyleTextJustify" gecko_enum_prefix="StyleTextJustify"
animation_value_type="none" animation_value_type="none"
spec="https://drafts.csswg.org/css-text/#propdef-text-justify"> spec="https://drafts.csswg.org/css-text/#propdef-text-justify">
use values::HasViewportPercentage;
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
impl ToComputedValue for SpecifiedValue { impl ToComputedValue for SpecifiedValue {
@ -256,8 +244,6 @@ ${helpers.single_keyword("text-align-last",
// TODO make this a shorthand and implement text-align-last/text-align-all // TODO make this a shorthand and implement text-align-last/text-align-all
<%helpers:longhand name="text-align" animation_value_type="none" need_clone="True" <%helpers:longhand name="text-align" animation_value_type="none" need_clone="True"
spec="https://drafts.csswg.org/css-text/#propdef-text-align"> spec="https://drafts.csswg.org/css-text/#propdef-text-align">
use values::computed::ComputedValueAsSpecified;
use values::HasViewportPercentage;
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
pub mod computed_value { pub mod computed_value {
use style_traits::ToCss; use style_traits::ToCss;
@ -400,6 +386,7 @@ ${helpers.single_keyword("text-align-last",
} }
} }
% else: % else:
use values::computed::ComputedValueAsSpecified;
impl ComputedValueAsSpecified for SpecifiedValue {} impl ComputedValueAsSpecified for SpecifiedValue {}
pub use self::computed_value::T as SpecifiedValue; pub use self::computed_value::T as SpecifiedValue;
pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> { pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
@ -412,19 +399,9 @@ ${helpers.single_keyword("text-align-last",
spec="https://drafts.csswg.org/css-text/#propdef-letter-spacing"> spec="https://drafts.csswg.org/css-text/#propdef-letter-spacing">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
use values::specified::AllowQuirks; use values::specified::AllowQuirks;
impl HasViewportPercentage for SpecifiedValue { #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
fn has_viewport_percentage(&self) -> bool {
match *self {
SpecifiedValue::Specified(ref length) => length.has_viewport_percentage(),
_ => false
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum SpecifiedValue { pub enum SpecifiedValue {
Normal, Normal,
@ -498,19 +475,9 @@ ${helpers.single_keyword("text-align-last",
spec="https://drafts.csswg.org/css-text/#propdef-word-spacing"> spec="https://drafts.csswg.org/css-text/#propdef-word-spacing">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
use values::specified::AllowQuirks; use values::specified::AllowQuirks;
impl HasViewportPercentage for SpecifiedValue { #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
fn has_viewport_percentage(&self) -> bool {
match *self {
SpecifiedValue::Specified(ref length) => length.has_viewport_percentage(),
_ => false
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum SpecifiedValue { pub enum SpecifiedValue {
Normal, Normal,
@ -588,7 +555,6 @@ ${helpers.single_keyword("text-align-last",
use cssparser::RGBA; use cssparser::RGBA;
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
impl ComputedValueAsSpecified for SpecifiedValue {} impl ComputedValueAsSpecified for SpecifiedValue {}
@ -674,7 +640,6 @@ ${helpers.single_keyword("text-align-last",
animation_value_type="none" animation_value_type="none"
spec="https://drafts.csswg.org/css-text/#propdef-white-space"> spec="https://drafts.csswg.org/css-text/#propdef-white-space">
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
use values::HasViewportPercentage;
impl ComputedValueAsSpecified for SpecifiedValue {} impl ComputedValueAsSpecified for SpecifiedValue {}
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
@ -720,28 +685,12 @@ ${helpers.single_keyword("text-align-last",
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::specified::Shadow; use values::specified::Shadow;
use values::HasViewportPercentage;
impl HasViewportPercentage for SpecifiedValue { #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
fn has_viewport_percentage(&self) -> bool {
let &SpecifiedValue(ref vec) = self;
vec.iter().any(|ref x| x.has_viewport_percentage())
}
}
#[derive(Clone, PartialEq, Debug)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct SpecifiedValue(Vec<SpecifiedTextShadow>); pub struct SpecifiedValue(Vec<SpecifiedTextShadow>);
impl HasViewportPercentage for SpecifiedTextShadow { #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
fn has_viewport_percentage(&self) -> bool {
self.offset_x.has_viewport_percentage() ||
self.offset_y.has_viewport_percentage() ||
self.blur_radius.has_viewport_percentage()
}
}
#[derive(Clone, PartialEq, Debug)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct SpecifiedTextShadow { pub struct SpecifiedTextShadow {
pub offset_x: specified::Length, pub offset_x: specified::Length,
@ -891,7 +840,6 @@ ${helpers.single_keyword("text-align-last",
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use unicode_segmentation::UnicodeSegmentation; use unicode_segmentation::UnicodeSegmentation;
use values::HasViewportPercentage;
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);
@ -1097,7 +1045,6 @@ ${helpers.single_keyword("text-align-last",
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-emphasis-position"> spec="https://drafts.csswg.org/css-text-decor/#propdef-text-emphasis-position">
use std::fmt; use std::fmt;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
use values::HasViewportPercentage;
use style_traits::ToCss; use style_traits::ToCss;
define_css_keyword_enum!(HorizontalWritingModeValue: define_css_keyword_enum!(HorizontalWritingModeValue:

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -36,7 +36,6 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::CustomIdent; use values::CustomIdent;
use values::HasViewportPercentage;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
use values::generics::CounterStyleOrNone; use values::generics::CounterStyleOrNone;
@ -105,7 +104,6 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu
boxed="${product == 'gecko'}" boxed="${product == 'gecko'}"
spec="https://drafts.csswg.org/css-lists/#propdef-list-style-image"> spec="https://drafts.csswg.org/css-lists/#propdef-list-style-image">
use std::fmt; use std::fmt;
use values::HasViewportPercentage;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
use values::specified::UrlOrNone; use values::specified::UrlOrNone;
pub use self::computed_value::T as SpecifiedValue; pub use self::computed_value::T as SpecifiedValue;
@ -158,7 +156,6 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
use values::HasViewportPercentage;
pub use self::computed_value::T as SpecifiedValue; pub use self::computed_value::T as SpecifiedValue;

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -17,11 +17,7 @@ ${helpers.predefined_type("outline-color", "CSSColor", "computed::CSSColor::Curr
<%helpers:longhand name="outline-style" need_clone="True" animation_value_type="none" <%helpers:longhand name="outline-style" need_clone="True" animation_value_type="none"
spec="https://drafts.csswg.org/css-ui/#propdef-outline-style"> spec="https://drafts.csswg.org/css-ui/#propdef-outline-style">
use std::fmt;
use style_traits::ToCss;
use values::specified::BorderStyle; use values::specified::BorderStyle;
use values::computed::ComputedValueAsSpecified;
pub type SpecifiedValue = Either<Auto, BorderStyle>; pub type SpecifiedValue = Either<Auto, BorderStyle>;
@ -66,10 +62,8 @@ ${helpers.predefined_type("outline-color", "CSSColor", "computed::CSSColor::Curr
<%helpers:longhand name="outline-width" animation_value_type="ComputedValue" <%helpers:longhand name="outline-width" animation_value_type="ComputedValue"
spec="https://drafts.csswg.org/css-ui/#propdef-outline-width"> spec="https://drafts.csswg.org/css-ui/#propdef-outline-width">
use app_units::Au;
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
impl ToCss for SpecifiedValue { impl ToCss for SpecifiedValue {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
@ -81,16 +75,10 @@ ${helpers.predefined_type("outline-color", "CSSColor", "computed::CSSColor::Curr
specified::parse_border_width(context, input).map(SpecifiedValue) specified::parse_border_width(context, input).map(SpecifiedValue)
} }
impl HasViewportPercentage for SpecifiedValue { #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
fn has_viewport_percentage(&self) -> bool {
let &SpecifiedValue(ref length) = self;
length.has_viewport_percentage()
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct SpecifiedValue(pub specified::Length); pub struct SpecifiedValue(pub specified::Length);
pub mod computed_value { pub mod computed_value {
use app_units::Au; use app_units::Au;
pub type T = Au; pub type T = Au;

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -9,8 +9,8 @@
<%helpers:longhand name="cursor" boxed="${product == 'gecko'}" animation_value_type="none" <%helpers:longhand name="cursor" boxed="${product == 'gecko'}" animation_value_type="none"
spec="https://drafts.csswg.org/css-ui/#cursor"> spec="https://drafts.csswg.org/css-ui/#cursor">
pub use self::computed_value::T as SpecifiedValue; pub use self::computed_value::T as SpecifiedValue;
use values::HasViewportPercentage;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
#[cfg(feature = "gecko")]
use values::specified::url::SpecifiedUrl; use values::specified::url::SpecifiedUrl;
impl ComputedValueAsSpecified for SpecifiedValue {} impl ComputedValueAsSpecified for SpecifiedValue {}
@ -20,6 +20,7 @@
use std::fmt; use std::fmt;
use style_traits::cursor::Cursor; use style_traits::cursor::Cursor;
use style_traits::ToCss; use style_traits::ToCss;
#[cfg(feature = "gecko")]
use values::specified::url::SpecifiedUrl; use values::specified::url::SpecifiedUrl;
#[derive(Clone, PartialEq, Copy, Debug)] #[derive(Clone, PartialEq, Copy, Debug)]

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -178,20 +178,16 @@ ${helpers.predefined_type("flex-basis",
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage; % if not logical:
use values::specified::{AllowQuirks, ${MinMax}Length}; use values::specified::AllowQuirks;
% endif
impl HasViewportPercentage for SpecifiedValue { use values::specified::${MinMax}Length;
fn has_viewport_percentage(&self) -> bool {
self.0.has_viewport_percentage()
}
}
pub mod computed_value { pub mod computed_value {
pub type T = ::values::computed::${MinMax}Length; pub type T = ::values::computed::${MinMax}Length;
} }
#[derive(PartialEq, Clone, Debug)] #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct SpecifiedValue(${MinMax}Length); pub struct SpecifiedValue(${MinMax}Length);
@ -225,7 +221,9 @@ ${helpers.predefined_type("flex-basis",
type ComputedValue = computed_value::T; type ComputedValue = computed_value::T;
#[inline] #[inline]
fn to_computed_value(&self, context: &Context) -> computed_value::T { fn to_computed_value(&self, context: &Context) -> computed_value::T {
use values::computed::${MinMax}Length; % if not logical or "block" in size:
use values::computed::${MinMax}Length;
% endif
let computed = self.0.to_computed_value(context); let computed = self.0.to_computed_value(context);
// filter out keyword values in the block direction // filter out keyword values in the block direction
@ -338,7 +336,6 @@ ${helpers.predefined_type("object-position",
animation_value_type="none"> animation_value_type="none">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
pub type SpecifiedValue = computed_value::T; pub type SpecifiedValue = computed_value::T;
@ -430,8 +427,6 @@ ${helpers.predefined_type("object-position",
use std::ops::Range; use std::ops::Range;
use str::HTML_SPACE_CHARACTERS; use str::HTML_SPACE_CHARACTERS;
use style_traits::ToCss; use style_traits::ToCss;
use style_traits::values::Css;
use values::HasViewportPercentage;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
pub mod computed_value { pub mod computed_value {

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -77,7 +77,6 @@ ${helpers.single_keyword("mask-mode",
pub use properties::longhands::background_repeat::single_value::SpecifiedValue; pub use properties::longhands::background_repeat::single_value::SpecifiedValue;
pub use properties::longhands::background_repeat::single_value::computed_value; pub use properties::longhands::background_repeat::single_value::computed_value;
pub use properties::longhands::background_repeat::single_value::RepeatKeyword; pub use properties::longhands::background_repeat::single_value::RepeatKeyword;
use properties::longhands::background_repeat::single_value;
#[inline] #[inline]
pub fn get_initial_value() -> computed_value::T { pub fn get_initial_value() -> computed_value::T {

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -14,7 +14,6 @@ ${helpers.single_keyword("table-layout", "auto fixed",
spec="Internal-only (for `<col span>` pres attr)" spec="Internal-only (for `<col span>` pres attr)"
animation_value_type="none" animation_value_type="none"
internal="True"> internal="True">
use values::HasViewportPercentage;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
impl ComputedValueAsSpecified for SpecifiedValue {} impl ComputedValueAsSpecified for SpecifiedValue {}

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -16,7 +16,6 @@
spec="https://drafts.csswg.org/css-ui/#propdef-text-overflow"> spec="https://drafts.csswg.org/css-ui/#propdef-text-overflow">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
use cssparser; use cssparser;
@ -107,7 +106,6 @@ ${helpers.single_keyword("unicode-bidi",
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-line"> spec="https://drafts.csswg.org/css-text-decor/#propdef-text-decoration-line">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
impl ComputedValueAsSpecified for SpecifiedValue {} impl ComputedValueAsSpecified for SpecifiedValue {}
@ -237,7 +235,6 @@ ${helpers.predefined_type(
spec="https://drafts.csswg.org/css-inline/#sizing-drop-initials"> spec="https://drafts.csswg.org/css-inline/#sizing-drop-initials">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
use values::specified::{Number, Integer}; use values::specified::{Number, Integer};

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -35,10 +35,8 @@ ${helpers.single_keyword("-moz-window-dragging", "default drag no-drag", product
products="gecko" products="gecko"
animation_value_type="none" animation_value_type="none"
spec="None (Nonstandard Firefox-only property)"> spec="None (Nonstandard Firefox-only property)">
use cssparser::Token;
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use values::HasViewportPercentage;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
no_viewport_percentage!(SpecifiedValue); no_viewport_percentage!(SpecifiedValue);

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -175,7 +175,7 @@ impl<T> ToComputedValue for T
} }
/// A computed `<angle>` value. /// A computed `<angle>` value.
#[derive(Clone, PartialEq, PartialOrd, Copy, Debug)] #[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, PartialOrd)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))]
pub enum Angle { pub enum Angle {
/// An angle with degree unit /// An angle with degree unit

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -32,7 +32,7 @@ pub enum Image<Gradient, ImageRect> {
/// A CSS gradient. /// A CSS gradient.
/// https://drafts.csswg.org/css-images/#gradients /// https://drafts.csswg.org/css-images/#gradients
#[derive(Clone, PartialEq, Debug)] #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct Gradient<LineDirection, Length, LengthOrPercentage, Position, Color> { pub struct Gradient<LineDirection, Length, LengthOrPercentage, Position, Color> {
/// Gradients can be linear or radial. /// Gradients can be linear or radial.
@ -45,7 +45,7 @@ pub struct Gradient<LineDirection, Length, LengthOrPercentage, Position, Color>
pub compat_mode: CompatMode, pub compat_mode: CompatMode,
} }
#[derive(Clone, Copy, PartialEq, Debug)] #[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
/// Whether we used the modern notation or the compatibility `-webkit` prefix. /// Whether we used the modern notation or the compatibility `-webkit` prefix.
pub enum CompatMode { pub enum CompatMode {
@ -56,7 +56,7 @@ pub enum CompatMode {
} }
/// A gradient kind. /// A gradient kind.
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum GradientKind<LineDirection, Length, LengthOrPercentage, Position> { pub enum GradientKind<LineDirection, Length, LengthOrPercentage, Position> {
/// A linear gradient. /// A linear gradient.
@ -66,7 +66,7 @@ pub enum GradientKind<LineDirection, Length, LengthOrPercentage, Position> {
} }
/// A radial gradient's ending shape. /// A radial gradient's ending shape.
#[derive(Clone, Copy, PartialEq, Debug)] #[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum EndingShape<Length, LengthOrPercentage> { pub enum EndingShape<Length, LengthOrPercentage> {
/// A circular gradient. /// A circular gradient.
@ -76,7 +76,7 @@ pub enum EndingShape<Length, LengthOrPercentage> {
} }
/// A circle shape. /// A circle shape.
#[derive(Clone, Copy, PartialEq, Debug)] #[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum Circle<Length> { pub enum Circle<Length> {
/// A circle radius. /// A circle radius.
@ -86,7 +86,7 @@ pub enum Circle<Length> {
} }
/// An ellipse shape. /// An ellipse shape.
#[derive(Clone, Copy, PartialEq, Debug)] #[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum Ellipse<LengthOrPercentage> { pub enum Ellipse<LengthOrPercentage> {
/// An ellipse pair of radii. /// An ellipse pair of radii.
@ -104,10 +104,11 @@ define_css_keyword_enum!(ShapeExtent:
"contain" => Contain, "contain" => Contain,
"cover" => Cover "cover" => Cover
); );
no_viewport_percentage!(ShapeExtent);
/// A gradient item. /// A gradient item.
/// https://drafts.csswg.org/css-images-4/#color-stop-syntax /// https://drafts.csswg.org/css-images-4/#color-stop-syntax
#[derive(Clone, Copy, PartialEq, Debug)] #[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum GradientItem<Color, LengthOrPercentage> { pub enum GradientItem<Color, LengthOrPercentage> {
/// A color stop. /// A color stop.
@ -118,7 +119,7 @@ pub enum GradientItem<Color, LengthOrPercentage> {
/// A color stop. /// A color stop.
/// https://drafts.csswg.org/css-images/#typedef-color-stop-list /// https://drafts.csswg.org/css-images/#typedef-color-stop-list
#[derive(Clone, Copy, PartialEq)] #[derive(Clone, Copy, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct ColorStop<Color, LengthOrPercentage> { pub struct ColorStop<Color, LengthOrPercentage> {
/// The color of this stop. /// The color of this stop.
@ -281,17 +282,6 @@ impl<D, L, LoP, P, C> ToCss for Gradient<D, L, LoP, P, C>
} }
} }
impl<D, L, LoP, P, C> HasViewportPercentage for Gradient<D, L, LoP, P, C>
where L: HasViewportPercentage,
LoP: HasViewportPercentage,
P: HasViewportPercentage,
{
fn has_viewport_percentage(&self) -> bool {
self.kind.has_viewport_percentage() ||
self.items.iter().any(|i| i.has_viewport_percentage())
}
}
impl<D, L, LoP, P, C> ToComputedValue for Gradient<D, L, LoP, P, C> impl<D, L, LoP, P, C> ToComputedValue for Gradient<D, L, LoP, P, C>
where D: ToComputedValue, where D: ToComputedValue,
L: ToComputedValue, L: ToComputedValue,
@ -333,21 +323,6 @@ impl<D, L, LoP, P> GradientKind<D, L, LoP, P> {
} }
} }
impl<D, L, LoP, P> HasViewportPercentage for GradientKind<D, L, LoP, P>
where L: HasViewportPercentage,
LoP: HasViewportPercentage,
P: HasViewportPercentage
{
fn has_viewport_percentage(&self) -> bool {
match *self {
GradientKind::Linear(_) => false,
GradientKind::Radial(ref shape, ref position) => {
shape.has_viewport_percentage() || position.has_viewport_percentage()
},
}
}
}
impl<D, L, LoP, P> ToComputedValue for GradientKind<D, L, LoP, P> impl<D, L, LoP, P> ToComputedValue for GradientKind<D, L, LoP, P>
where D: ToComputedValue, where D: ToComputedValue,
L: ToComputedValue, L: ToComputedValue,
@ -423,22 +398,6 @@ impl<L, LoP> ToCss for EndingShape<L, LoP>
} }
} }
impl<L, LoP> HasViewportPercentage for EndingShape<L, LoP>
where L: HasViewportPercentage, LoP: HasViewportPercentage,
{
fn has_viewport_percentage(&self) -> bool {
match *self {
EndingShape::Circle(Circle::Radius(ref length)) => {
length.has_viewport_percentage()
},
EndingShape::Ellipse(Ellipse::Radii(ref x, ref y)) => {
x.has_viewport_percentage() || y.has_viewport_percentage()
},
_ => false,
}
}
}
impl<L, LoP> ToComputedValue for EndingShape<L, LoP> impl<L, LoP> ToComputedValue for EndingShape<L, LoP>
where L: ToComputedValue, LoP: ToComputedValue, where L: ToComputedValue, LoP: ToComputedValue,
{ {
@ -497,17 +456,6 @@ impl<C, L> ToCss for GradientItem<C, L>
} }
} }
impl<C, L> HasViewportPercentage for GradientItem<C, L>
where L: HasViewportPercentage,
{
fn has_viewport_percentage(&self) -> bool {
match *self {
GradientItem::ColorStop(ref stop) => stop.has_viewport_percentage(),
GradientItem::InterpolationHint(ref hint) => hint.has_viewport_percentage(),
}
}
}
impl<C, L> ToComputedValue for GradientItem<C, L> impl<C, L> ToComputedValue for GradientItem<C, L>
where C: ToComputedValue, L: ToComputedValue, where C: ToComputedValue, L: ToComputedValue,
{ {
@ -562,14 +510,6 @@ impl<C, L> ToCss for ColorStop<C, L>
} }
} }
impl<C, L> HasViewportPercentage for ColorStop<C, L>
where L: HasViewportPercentage,
{
fn has_viewport_percentage(&self) -> bool {
self.position.as_ref().map_or(false, HasViewportPercentage::has_viewport_percentage)
}
}
impl<C, L> ToComputedValue for ColorStop<C, L> impl<C, L> ToComputedValue for ColorStop<C, L>
where C: ToComputedValue, L: ToComputedValue, where C: ToComputedValue, L: ToComputedValue,
{ {

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -5,10 +5,9 @@
//! Generic types for CSS handling of specified and computed values of //! Generic types for CSS handling of specified and computed values of
//! [`position`](https://drafts.csswg.org/css-backgrounds-3/#position) //! [`position`](https://drafts.csswg.org/css-backgrounds-3/#position)
use values::HasViewportPercentage;
use values::computed::{Context, ToComputedValue}; use values::computed::{Context, ToComputedValue};
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
/// A generic type for representing a CSS [position](https://drafts.csswg.org/css-values/#position). /// A generic type for representing a CSS [position](https://drafts.csswg.org/css-values/#position).
pub struct Position<H, V> { pub struct Position<H, V> {
@ -28,13 +27,6 @@ impl<H, V> Position<H, V> {
} }
} }
impl<H: HasViewportPercentage, V: HasViewportPercentage> HasViewportPercentage for Position<H, V> {
#[inline]
fn has_viewport_percentage(&self) -> bool {
self.horizontal.has_viewport_percentage() || self.vertical.has_viewport_percentage()
}
}
impl<H: ToComputedValue, V: ToComputedValue> ToComputedValue for Position<H, V> { impl<H: ToComputedValue, V: ToComputedValue> ToComputedValue for Position<H, V> {
type ComputedValue = Position<<H as ToComputedValue>::ComputedValue, type ComputedValue = Position<<H as ToComputedValue>::ComputedValue,
<V as ToComputedValue>::ComputedValue>; <V as ToComputedValue>::ComputedValue>;

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -16,6 +16,7 @@ use std::borrow::Cow;
use std::fmt::{self, Debug}; use std::fmt::{self, Debug};
use std::hash; use std::hash;
use style_traits::ToCss; use style_traits::ToCss;
pub use style_traits::HasViewportPercentage;
pub mod computed; pub mod computed;
pub mod generics; pub mod generics;
@ -30,24 +31,11 @@ pub type CSSInteger = i32;
/// The default font size. /// The default font size.
pub const FONT_MEDIUM_PX: i32 = 16; pub const FONT_MEDIUM_PX: i32 = 16;
/// 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;
}
impl<T: HasViewportPercentage> HasViewportPercentage for Box<T> {
#[inline]
fn has_viewport_percentage(&self) -> bool {
(**self).has_viewport_percentage()
}
}
define_keyword_type!(None_, "none"); define_keyword_type!(None_, "none");
define_keyword_type!(Auto, "auto"); define_keyword_type!(Auto, "auto");
define_keyword_type!(Normal, "normal"); define_keyword_type!(Normal, "normal");
#[derive(Clone, PartialEq, Copy)] #[derive(Clone, Copy, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
/// A struct representing one of two kinds of values. /// A struct representing one of two kinds of values.
pub enum Either<A, B> { pub enum Either<A, B> {
@ -75,15 +63,6 @@ impl<A: ToCss, B: ToCss> ToCss for Either<A, B> {
} }
} }
impl<A: HasViewportPercentage, B: HasViewportPercentage> HasViewportPercentage for Either<A, B> {
fn has_viewport_percentage(&self) -> bool {
match *self {
Either::First(ref v) => v.has_viewport_percentage(),
Either::Second(ref v) => v.has_viewport_percentage(),
}
}
}
impl<A: Parse, B: Parse> Parse for Either<A, B> { impl<A: Parse, B: Parse> Parse for Either<A, B> {
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Either<A, B>, ()> { fn parse(context: &ParserContext, input: &mut Parser) -> Result<Either<A, B>, ()> {
if let Ok(v) = input.try(|i| A::parse(context, i)) { if let Ok(v) = input.try(|i| A::parse(context, i)) {
@ -209,3 +188,4 @@ define_css_keyword_enum!(ExtremumLength:
"-moz-min-content" => MinContent, "-moz-min-content" => MinContent,
"-moz-fit-content" => FitContent, "-moz-fit-content" => FitContent,
"-moz-available" => FillAvailable); "-moz-available" => FillAvailable);
no_viewport_percentage!(ExtremumLength);

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -221,7 +221,7 @@ impl<L: ToComputedValue> ToComputedValue for TrackBreadth<L> {
} }
} }
#[derive(Clone, PartialEq, Debug)] #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
/// A `<track-size>` type for explicit grid track sizing. Like `<track-breadth>`, this is /// A `<track-size>` type for explicit grid track sizing. Like `<track-breadth>`, this is
/// generic only to avoid code bloat. It only takes `<length-percentage>` /// generic only to avoid code bloat. It only takes `<length-percentage>`
@ -321,17 +321,6 @@ impl<L: ToCss> ToCss for TrackSize<L> {
} }
} }
impl HasViewportPercentage for TrackSize<LengthOrPercentage> {
#[inline]
fn has_viewport_percentage(&self) -> bool {
match *self {
TrackSize::Breadth(ref b) => b.has_viewport_percentage(),
TrackSize::MinMax(ref inf_b, ref b) => inf_b.has_viewport_percentage() || b.has_viewport_percentage(),
TrackSize::FitContent(ref lop) => lop.has_viewport_percentage(),
}
}
}
impl<L: ToComputedValue> ToComputedValue for TrackSize<L> { impl<L: ToComputedValue> ToComputedValue for TrackSize<L> {
type ComputedValue = TrackSize<L::ComputedValue>; type ComputedValue = TrackSize<L::ComputedValue>;

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -54,7 +54,7 @@ pub type GradientKind = GenericGradientKind<
>; >;
/// A specified gradient line direction. /// A specified gradient line direction.
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum LineDirection { pub enum LineDirection {
/// An angular direction. /// An angular direction.

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -531,7 +531,7 @@ impl NoCalcLength {
/// This is commonly used for the `<length>` values. /// This is commonly used for the `<length>` values.
/// ///
/// https://drafts.csswg.org/css-values/#lengths /// https://drafts.csswg.org/css-values/#lengths
#[derive(Clone, PartialEq, Debug)] #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum Length { pub enum Length {
/// The internal length type that cannot parse `calc` /// The internal length type that cannot parse `calc`
@ -549,15 +549,6 @@ impl From<NoCalcLength> for Length {
} }
} }
impl HasViewportPercentage for Length {
fn has_viewport_percentage(&self) -> bool {
match *self {
Length::NoCalc(ref inner) => inner.has_viewport_percentage(),
Length::Calc(ref calc) => calc.has_viewport_percentage(),
}
}
}
impl ToCss for Length { impl ToCss for Length {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
match *self { match *self {
@ -713,7 +704,7 @@ impl<T: Parse> Either<Length, T> {
/// As of today, only `-moz-image-rect` supports percentages without length. /// As of today, only `-moz-image-rect` supports percentages without length.
/// This is not a regression, and that's a non-standard extension anyway, so I'm /// This is not a regression, and that's a non-standard extension anyway, so I'm
/// not implementing it for now. /// not implementing it for now.
#[derive(Clone, PartialEq, Copy, Debug)] #[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub struct Percentage(pub CSSFloat); pub struct Percentage(pub CSSFloat);
@ -754,7 +745,7 @@ impl Parse for Percentage {
impl ComputedValueAsSpecified for Percentage {} impl ComputedValueAsSpecified for Percentage {}
/// A length or a percentage value. /// A length or a percentage value.
#[derive(Clone, PartialEq, Debug)] #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[allow(missing_docs)] #[allow(missing_docs)]
pub enum LengthOrPercentage { pub enum LengthOrPercentage {
@ -786,16 +777,6 @@ impl From<Percentage> for LengthOrPercentage {
} }
} }
impl HasViewportPercentage for LengthOrPercentage {
fn has_viewport_percentage(&self) -> bool {
match *self {
LengthOrPercentage::Length(ref length) => length.has_viewport_percentage(),
LengthOrPercentage::Calc(ref calc) => calc.has_viewport_percentage(),
_ => false
}
}
}
impl ToCss for LengthOrPercentage { impl ToCss for LengthOrPercentage {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
match *self { match *self {
@ -914,7 +895,7 @@ impl LengthOrPercentage {
} }
/// Either a `<length>`, a `<percentage>`, or the `auto` keyword. /// Either a `<length>`, a `<percentage>`, or the `auto` keyword.
#[derive(Clone, PartialEq, Debug)] #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[allow(missing_docs)] #[allow(missing_docs)]
pub enum LengthOrPercentageOrAuto { pub enum LengthOrPercentageOrAuto {
@ -938,16 +919,6 @@ impl From<Percentage> for LengthOrPercentageOrAuto {
} }
} }
impl HasViewportPercentage for LengthOrPercentageOrAuto {
fn has_viewport_percentage(&self) -> bool {
match *self {
LengthOrPercentageOrAuto::Length(ref length) => length.has_viewport_percentage(),
LengthOrPercentageOrAuto::Calc(ref calc) => calc.has_viewport_percentage(),
_ => false
}
}
}
impl ToCss for LengthOrPercentageOrAuto { impl ToCss for LengthOrPercentageOrAuto {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
match *self { match *self {
@ -1036,7 +1007,7 @@ impl LengthOrPercentageOrAuto {
} }
/// Either a `<length>`, a `<percentage>`, or the `none` keyword. /// Either a `<length>`, a `<percentage>`, or the `none` keyword.
#[derive(Clone, PartialEq, Debug)] #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[allow(missing_docs)] #[allow(missing_docs)]
pub enum LengthOrPercentageOrNone { pub enum LengthOrPercentageOrNone {
@ -1046,16 +1017,6 @@ pub enum LengthOrPercentageOrNone {
None, None,
} }
impl HasViewportPercentage for LengthOrPercentageOrNone {
fn has_viewport_percentage(&self) -> bool {
match *self {
LengthOrPercentageOrNone::Length(ref length) => length.has_viewport_percentage(),
LengthOrPercentageOrNone::Calc(ref calc) => calc.has_viewport_percentage(),
_ => false
}
}
}
impl ToCss for LengthOrPercentageOrNone { impl ToCss for LengthOrPercentageOrNone {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
match *self { match *self {
@ -1133,7 +1094,7 @@ pub type LengthOrAuto = Either<Length, Auto>;
/// Either a `<length>` or a `<percentage>` or the `auto` keyword or the /// Either a `<length>` or a `<percentage>` or the `auto` keyword or the
/// `content` keyword. /// `content` keyword.
#[derive(Clone, PartialEq, Debug)] #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum LengthOrPercentageOrAutoOrContent { pub enum LengthOrPercentageOrAutoOrContent {
/// A `<length>`. /// A `<length>`.
@ -1185,16 +1146,6 @@ impl LengthOrPercentageOrAutoOrContent {
} }
} }
impl HasViewportPercentage for LengthOrPercentageOrAutoOrContent {
fn has_viewport_percentage(&self) -> bool {
match *self {
LengthOrPercentageOrAutoOrContent::Length(ref length) => length.has_viewport_percentage(),
LengthOrPercentageOrAutoOrContent::Calc(ref calc) => calc.has_viewport_percentage(),
_ => false
}
}
}
impl ToCss for LengthOrPercentageOrAutoOrContent { impl ToCss for LengthOrPercentageOrAutoOrContent {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
match *self { match *self {
@ -1227,7 +1178,7 @@ impl LengthOrNumber {
/// A value suitable for a `min-width` or `min-height` property. /// A value suitable for a `min-width` or `min-height` property.
/// Unlike `max-width` or `max-height` properties, a MinLength can be /// Unlike `max-width` or `max-height` properties, a MinLength can be
/// `auto`, and cannot be `none`. /// `auto`, and cannot be `none`.
#[derive(Debug, Clone, PartialEq)] #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[allow(missing_docs)] #[allow(missing_docs)]
pub enum MinLength { pub enum MinLength {
@ -1236,15 +1187,6 @@ pub enum MinLength {
ExtremumLength(ExtremumLength), ExtremumLength(ExtremumLength),
} }
impl HasViewportPercentage for MinLength {
fn has_viewport_percentage(&self) -> bool {
match *self {
MinLength::LengthOrPercentage(ref lop) => lop.has_viewport_percentage(),
_ => false
}
}
}
impl ToCss for MinLength { impl ToCss for MinLength {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
match *self { match *self {
@ -1277,7 +1219,7 @@ impl MinLength {
} }
/// A value suitable for a `max-width` or `max-height` property. /// A value suitable for a `max-width` or `max-height` property.
#[derive(Debug, Clone, PartialEq)] #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[allow(missing_docs)] #[allow(missing_docs)]
pub enum MaxLength { pub enum MaxLength {
@ -1286,14 +1228,6 @@ pub enum MaxLength {
ExtremumLength(ExtremumLength), ExtremumLength(ExtremumLength),
} }
impl HasViewportPercentage for MaxLength {
fn has_viewport_percentage(&self) -> bool {
match *self {
MaxLength::LengthOrPercentage(ref lop) => lop.has_viewport_percentage(),
_ => false
}
}
}
impl ToCss for MaxLength { impl ToCss for MaxLength {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -21,7 +21,7 @@ use std::fmt;
use std::io::Write; use std::io::Write;
use style_traits::ToCss; use style_traits::ToCss;
use style_traits::values::specified::AllowedNumericType; use style_traits::values::specified::AllowedNumericType;
use super::{Auto, CSSFloat, CSSInteger, HasViewportPercentage, Either, None_}; use super::{Auto, CSSFloat, CSSInteger, Either, None_};
use super::computed::{self, Context}; use super::computed::{self, Context};
use super::computed::{Shadow as ComputedShadow, ToComputedValue}; use super::computed::{Shadow as ComputedShadow, ToComputedValue};
use super::generics::BorderRadiusSize as GenericBorderRadiusSize; use super::generics::BorderRadiusSize as GenericBorderRadiusSize;
@ -76,8 +76,6 @@ impl ComputedValueAsSpecified for SpecifiedUrl {}
no_viewport_percentage!(SpecifiedUrl); no_viewport_percentage!(SpecifiedUrl);
} }
no_viewport_percentage!(i32); // For PropertyDeclaration::Order
#[derive(Clone, PartialEq, Debug)] #[derive(Clone, PartialEq, Debug)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[allow(missing_docs)] #[allow(missing_docs)]
@ -289,7 +287,7 @@ impl Parse for BorderRadiusSize {
} }
} }
#[derive(Clone, PartialEq, Copy, Debug)] #[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))]
/// An angle consisting of a value and a unit. /// An angle consisting of a value and a unit.
/// ///
@ -455,7 +453,7 @@ pub fn parse_border_width(context: &ParserContext, input: &mut Parser) -> Result
}) })
} }
#[derive(Clone, PartialEq, Debug)] #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[allow(missing_docs)] #[allow(missing_docs)]
pub enum BorderWidth { pub enum BorderWidth {
@ -507,15 +505,6 @@ impl ToCss for BorderWidth {
} }
} }
impl HasViewportPercentage for BorderWidth {
fn has_viewport_percentage(&self) -> bool {
match *self {
BorderWidth::Thin | BorderWidth::Medium | BorderWidth::Thick => false,
BorderWidth::Width(ref length) => length.has_viewport_percentage()
}
}
}
impl ToComputedValue for BorderWidth { impl ToComputedValue for BorderWidth {
type ComputedValue = Au; type ComputedValue = Au;
@ -950,7 +939,7 @@ pub type TrackList = GenericTrackList<TrackSizeOrRepeat>;
/// `<track-list> | none` /// `<track-list> | none`
pub type TrackListOrNone = Either<TrackList, None_>; pub type TrackListOrNone = Either<TrackList, None_>;
#[derive(Debug, Clone, PartialEq)] #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[allow(missing_docs)] #[allow(missing_docs)]
pub struct Shadow { pub struct Shadow {
@ -962,15 +951,6 @@ pub struct Shadow {
pub inset: bool, pub inset: bool,
} }
impl HasViewportPercentage for Shadow {
fn has_viewport_percentage(&self) -> bool {
self.offset_x.has_viewport_percentage() ||
self.offset_y.has_viewport_percentage() ||
self.blur_radius.has_viewport_percentage() ||
self.spread_radius.has_viewport_percentage()
}
}
impl ToComputedValue for Shadow { impl ToComputedValue for Shadow {
type ComputedValue = ComputedShadow; type ComputedValue = ComputedShadow;
@ -1230,16 +1210,7 @@ impl LengthOrPercentageOrNumber {
} }
} }
impl HasViewportPercentage for ClipRect { #[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
fn has_viewport_percentage(&self) -> bool {
self.top.as_ref().map_or(false, |x| x.has_viewport_percentage()) ||
self.right.as_ref().map_or(false, |x| x.has_viewport_percentage()) ||
self.bottom.as_ref().map_or(false, |x| x.has_viewport_percentage()) ||
self.left.as_ref().map_or(false, |x| x.has_viewport_percentage())
}
}
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
/// rect(<top>, <left>, <bottom>, <right>) used by clip and image-region /// rect(<top>, <left>, <bottom>, <right>) used by clip and image-region
pub struct ClipRect { pub struct ClipRect {

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -0,0 +1,15 @@
[package]
name = "style_derive"
version = "0.0.1"
authors = ["The Servo Project Developers"]
license = "MPL-2.0"
publish = false
[lib]
path = "lib.rs"
proc-macro = true
[dependencies]
quote = "0.3"
syn = "0.11"
synstructure = "0.5.2"

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -0,0 +1,56 @@
/* 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 quote;
use syn;
use synstructure;
pub fn derive(input: syn::DeriveInput) -> quote::Tokens {
let name = &input.ident;
let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();
let mut where_clause = where_clause.clone();
for param in &input.generics.ty_params {
where_clause.predicates.push(where_predicate(syn::Ty::Path(None, param.ident.clone().into())))
}
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,
};
let mut expr = quote!(::style_traits::HasViewportPercentage::has_viewport_percentage(#first));
for binding in rest {
where_clause.predicates.push(where_predicate(binding.field.ty.clone()));
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
}
}
}
}
}
fn where_predicate(ty: syn::Ty) -> syn::WherePredicate {
syn::WherePredicate::BoundPredicate(syn::WhereBoundPredicate {
bound_lifetimes: vec![],
bounded_ty: ty,
bounds: vec![syn::TyParamBound::Trait(
syn::PolyTraitRef {
bound_lifetimes: vec![],
trait_ref: syn::parse_path("::style_traits::HasViewportPercentage").unwrap(),
},
syn::TraitBoundModifier::None
)],
})
}

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -0,0 +1,18 @@
/* 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/. */
extern crate proc_macro;
#[macro_use] extern crate quote;
extern crate syn;
extern crate synstructure;
use proc_macro::TokenStream;
mod has_viewport_percentage;
#[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()
}

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -63,6 +63,8 @@ pub enum CSSPixel {}
pub mod cursor; pub mod cursor;
#[macro_use] #[macro_use]
pub mod values; pub mod values;
#[macro_use]
pub mod viewport; pub mod viewport;
pub use values::{ToCss, OneOrMoreCommaSeparated}; pub use values::{ToCss, OneOrMoreCommaSeparated};
pub use viewport::HasViewportPercentage;

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -20,6 +20,48 @@ define_css_keyword_enum!(Orientation:
"portrait" => Portrait, "portrait" => Portrait,
"landscape" => Landscape); "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> HasViewportPercentage for Box<T> {
#[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> HasViewportPercentage for Vec<T> {
#[inline]
fn has_viewport_percentage(&self) -> bool {
self.iter().any(T::has_viewport_percentage)
}
}
/// A set of viewport descriptors: /// A set of viewport descriptors:
/// ///

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -5,7 +5,6 @@
use app_units::Au; use app_units::Au;
use style::attr::{AttrValue, LengthOrPercentageOrAuto, parse_length}; use style::attr::{AttrValue, LengthOrPercentageOrAuto, parse_length};
use style::values::computed::CalcLengthOrPercentage; use style::values::computed::CalcLengthOrPercentage;
use style_traits::values::specified::AllowedLengthType;
#[test] #[test]
fn test_length_calc() { fn test_length_calc() {

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -6,7 +6,7 @@
fn smoke_restyle_hints() { fn smoke_restyle_hints() {
use cssparser::Parser; use cssparser::Parser;
use selectors::parser::SelectorList; use selectors::parser::SelectorList;
use style::restyle_hints::{DependencySet, RESTYLE_LATER_SIBLINGS}; use style::restyle_hints::DependencySet;
use style::selector_parser::SelectorParser; use style::selector_parser::SelectorParser;
use style::stylesheets::{Origin, Namespaces}; use style::stylesheets::{Origin, Namespaces};
let namespaces = Namespaces::default(); let namespaces = Namespaces::default();

ΠŸΡ€ΠΎΡΠΌΠΎΡ‚Ρ€Π΅Ρ‚ΡŒ Ρ„Π°ΠΉΠ»

@ -212,7 +212,7 @@ fn test_insert() {
#[test] #[test]
fn test_get_universal_rules() { fn test_get_universal_rules() {
thread_state::initialize(thread_state::LAYOUT); thread_state::initialize(thread_state::LAYOUT);
let (map, shared_lock) = get_mock_map(&["*|*", "#foo > *|*", "*|* > *|*", ".klass", "#id"]); let (map, _shared_lock) = get_mock_map(&["*|*", "#foo > *|*", "*|* > *|*", ".klass", "#id"]);
let decls = map.get_universal_rules(CascadeLevel::UserNormal); let decls = map.get_universal_rules(CascadeLevel::UserNormal);