aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/style/properties/gecko.mako.rs2
-rw-r--r--components/style/properties/helpers.mako.rs11
-rw-r--r--components/style/properties/longhand/box.mako.rs66
-rw-r--r--components/style/values/computed/mod.rs2
-rw-r--r--components/style/values/specified/mod.rs47
5 files changed, 62 insertions, 66 deletions
diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs
index a44956b9f04..bbd94e1ca29 100644
--- a/components/style/properties/gecko.mako.rs
+++ b/components/style/properties/gecko.mako.rs
@@ -893,7 +893,7 @@ fn static_assert() {
#[allow(non_snake_case)]
pub fn set__moz_binding(&mut self, v: longhands::_moz_binding::computed_value::T) {
- use properties::longhands::_moz_binding::SpecifiedValue as BindingValue;
+ use properties::longhands::_moz_binding::computed_value::T as BindingValue;
match v {
BindingValue::None => debug_assert!(self.gecko.mBinding.mRawPtr.is_null()),
BindingValue::Url(ref url, ref extra_data) => {
diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs
index 4dea502a5d5..b34175bcebe 100644
--- a/components/style/properties/helpers.mako.rs
+++ b/components/style/properties/helpers.mako.rs
@@ -16,19 +16,24 @@
</%call>
</%def>
-<%def name="predefined_type(name, type, initial_value, parse_method='parse', **kwargs)">
+<%def name="predefined_type(name, type, initial_value, parse_method='parse', needs_context=False, **kwargs)">
<%call expr="longhand(name, predefined_type=type, **kwargs)">
#[allow(unused_imports)]
use app_units::Au;
use cssparser::{Color as CSSParserColor, RGBA};
- pub type SpecifiedValue = specified::${type};
+ pub use values::specified::${type} as SpecifiedValue;
pub mod computed_value {
pub use values::computed::${type} as T;
}
#[inline] pub fn get_initial_value() -> computed_value::T { ${initial_value} }
- #[inline] pub fn parse(_context: &ParserContext, input: &mut Parser)
+ #[allow(unused_variables)]
+ #[inline] pub fn parse(context: &ParserContext, input: &mut Parser)
-> Result<SpecifiedValue, ()> {
+ % if needs_context:
+ specified::${type}::${parse_method}(context, input)
+ % else:
specified::${type}::${parse_method}(input)
+ % endif
}
</%call>
</%def>
diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs
index 45e64f88f7c..067c37e6251 100644
--- a/components/style/properties/longhand/box.mako.rs
+++ b/components/style/properties/longhand/box.mako.rs
@@ -920,64 +920,8 @@ ${helpers.single_keyword("-moz-appearance",
animatable=False)}
// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-binding
-<%helpers:longhand name="-moz-binding" products="gecko" animatable="False" disable_when_testing="True">
- use cssparser::{CssStringWriter, ToCss};
- use gecko_bindings::sugar::refptr::{GeckoArcPrincipal, GeckoArcURI};
- use std::fmt::{self, Write};
- use url::Url;
- use values::specified::UrlExtraData;
- use values::computed::ComputedValueAsSpecified;
- use values::NoViewportPercentage;
-
- #[derive(PartialEq, Clone, Debug)]
- #[cfg_attr(feature = "servo", derive(HeapSizeOf))]
- pub enum SpecifiedValue {
- Url(Url, UrlExtraData),
- None,
- }
-
- impl ComputedValueAsSpecified for SpecifiedValue {}
- impl NoViewportPercentage for SpecifiedValue {}
-
- impl ToCss for SpecifiedValue {
- fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
- use values::LocalToCss;
- match *self {
- SpecifiedValue::Url(ref url, _) => {
- url.to_css(dest)
- }
- SpecifiedValue::None => {
- try!(dest.write_str("none"));
- Ok(())
- }
- }
- }
- }
-
- pub mod computed_value {
- pub type T = super::SpecifiedValue;
- }
-
- #[inline] pub fn get_initial_value() -> SpecifiedValue {
- SpecifiedValue::None
- }
-
- pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
- if input.try(|input| input.expect_ident_matching("none")).is_ok() {
- return Ok(SpecifiedValue::None);
- }
-
- let url = context.parse_url(&*try!(input.expect_url()));
- match UrlExtraData::make_from(context) {
- Some(extra_data) => {
- Ok(SpecifiedValue::Url(url, extra_data))
- },
- _ => {
- // FIXME(heycam) should ensure we always have a principal, etc., when parsing
- // style attributes and re-parsing due to CSS Variables.
- println!("stylo: skipping -moz-binding declaration without ParserContextExtraData");
- Err(())
- },
- }
- }
-</%helpers:longhand>
+${helpers.predefined_type("-moz-binding", "UrlOrNone", "computed_value::T::None",
+ needs_context=True,
+ products="gecko",
+ animatable="False",
+ disable_when_testing="True")}
diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs
index 90a1462d834..42abdf5b933 100644
--- a/components/style/values/computed/mod.rs
+++ b/components/style/values/computed/mod.rs
@@ -13,7 +13,7 @@ use super::LocalToCss;
pub use cssparser::Color as CSSColor;
pub use self::image::{EndingShape as GradientShape, Gradient, GradientKind, Image};
pub use self::image::{LengthOrKeyword, LengthOrPercentageOrKeyword};
-pub use super::specified::{Angle, BorderStyle, Time, UrlExtraData};
+pub use super::specified::{Angle, BorderStyle, Time, UrlExtraData, UrlOrNone};
pub mod basic_shape;
pub mod image;
diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs
index f8a456d2076..436dc65d7d9 100644
--- a/components/style/values/specified/mod.rs
+++ b/components/style/values/specified/mod.rs
@@ -18,6 +18,7 @@ use std::ops::Mul;
use style_traits::values::specified::AllowedNumericType;
use super::{CSSFloat, FONT_MEDIUM_PX, HasViewportPercentage, LocalToCss, NoViewportPercentage};
use super::computed::{self, ComputedValueAsSpecified, Context, ToComputedValue};
+use url::Url;
pub use self::image::{AngleOrCorner, ColorStop, EndingShape as GradientEndingShape, Gradient};
pub use self::image::{GradientKind, HorizontalDirection, Image, LengthOrKeyword, LengthOrPercentageOrKeyword};
@@ -1452,3 +1453,49 @@ impl ToCss for Opacity {
self.0.to_css(dest)
}
}
+
+#[derive(PartialEq, Clone, Debug)]
+#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
+pub enum UrlOrNone {
+ Url(Url, UrlExtraData),
+ None,
+}
+
+impl ComputedValueAsSpecified for UrlOrNone {}
+impl NoViewportPercentage for UrlOrNone {}
+
+impl ToCss for UrlOrNone {
+ fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
+ use values::LocalToCss;
+ match *self {
+ UrlOrNone::Url(ref url, _) => {
+ url.to_css(dest)
+ }
+ UrlOrNone::None => {
+ try!(dest.write_str("none"));
+ Ok(())
+ }
+ }
+ }
+}
+
+impl UrlOrNone {
+ pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<UrlOrNone, ()> {
+ if input.try(|input| input.expect_ident_matching("none")).is_ok() {
+ return Ok(UrlOrNone::None);
+ }
+
+ let url = context.parse_url(&*try!(input.expect_url()));
+ match UrlExtraData::make_from(context) {
+ Some(extra_data) => {
+ Ok(UrlOrNone::Url(url, extra_data))
+ },
+ _ => {
+ // FIXME(heycam) should ensure we always have a principal, etc., when parsing
+ // style attributes and re-parsing due to CSS Variables.
+ println!("stylo: skipping UrlOrNone declaration without ParserContextExtraData");
+ Err(())
+ },
+ }
+ }
+}