diff --git a/servo/components/style/properties/gecko.mako.rs b/servo/components/style/properties/gecko.mako.rs index bd11e777a5a3..86a1bbc9e5f7 100644 --- a/servo/components/style/properties/gecko.mako.rs +++ b/servo/components/style/properties/gecko.mako.rs @@ -1819,7 +1819,8 @@ fn static_assert() { <%self:impl_trait style_struct_name="InheritedText" - skip_longhands="text-align text-emphasis-style text-shadow line-height letter-spacing word-spacing"> + skip_longhands="text-align text-emphasis-style text-shadow line-height letter-spacing word-spacing + -webkit-text-stroke-width"> <% text_align_keyword = Keyword("text-align", "start end left right center justify -moz-center -moz-left " + "-moz-right match-parent") %> @@ -1966,6 +1967,13 @@ fn static_assert() { self.gecko.mTextEmphasisStyle = other.gecko.mTextEmphasisStyle; } + #[allow(non_snake_case)] + pub fn set__webkit_text_stroke_width(&mut self, v: longhands::_webkit_text_stroke_width::computed_value::T) { + self.gecko.mWebkitTextStrokeWidth.set_value(CoordDataValue::Coord(v.0)); + } + + <%call expr="impl_coord_copy('_webkit_text_stroke_width', 'mWebkitTextStrokeWidth')"> + <%self:impl_trait style_struct_name="Text" diff --git a/servo/components/style/properties/longhand/inherited_text.mako.rs b/servo/components/style/properties/longhand/inherited_text.mako.rs index 7ac54b042226..f08764ab2307 100644 --- a/servo/components/style/properties/longhand/inherited_text.mako.rs +++ b/servo/components/style/properties/longhand/inherited_text.mako.rs @@ -996,6 +996,48 @@ ${helpers.predefined_type("text-emphasis-color", "CSSColor", products="gecko",animatable=True, complex_color=True, need_clone=True)} +// CSS Compatibility +// https://compat.spec.whatwg.org/#the-webkit-text-fill-color +${helpers.predefined_type( + "-webkit-text-fill-color", "CSSColor", + "CSSParserColor::CurrentColor", + products="gecko", animatable=True, + complex_color=True, need_clone=True)} + +// CSS Compatibility +// https://compat.spec.whatwg.org/#the-webkit-text-stroke-color +${helpers.predefined_type( + "-webkit-text-stroke-color", "CSSColor", + "CSSParserColor::CurrentColor", + products="gecko", animatable=True, + complex_color=True, need_clone=True)} + +// CSS Compatibility +// https://compat.spec.whatwg.org/#the-webkit-text-stroke-width +<%helpers:longhand products="gecko" name="-webkit-text-stroke-width" animatable="False"> + use app_units::Au; + use std::fmt; + use style_traits::ToCss; + use values::HasViewportPercentage; + use values::specified::BorderWidth; + + pub type SpecifiedValue = BorderWidth; + + #[inline] + pub fn parse(_context: &ParserContext, input: &mut Parser) + -> Result { + BorderWidth::parse(input) + } + + pub mod computed_value { + use app_units::Au; + pub type T = Au; + } + #[inline] pub fn get_initial_value() -> computed_value::T { + Au::from_px(0) + } + + // TODO(pcwalton): `full-width` ${helpers.single_keyword("text-transform", "none capitalize uppercase lowercase", diff --git a/servo/components/style/properties/shorthand/inherited_text.mako.rs b/servo/components/style/properties/shorthand/inherited_text.mako.rs index 570c41e5e307..ba2c49423bde 100644 --- a/servo/components/style/properties/shorthand/inherited_text.mako.rs +++ b/servo/components/style/properties/shorthand/inherited_text.mako.rs @@ -78,3 +78,58 @@ } } + +// CSS Compatibility +// https://compat.spec.whatwg.org/#the-webkit-text-stroke +<%helpers:shorthand name="-webkit-text-stroke" + sub_properties="-webkit-text-stroke-color + -webkit-text-stroke-width" + products="gecko"> + use cssparser::Color as CSSParserColor; + use properties::longhands::{_webkit_text_stroke_color, _webkit_text_stroke_width}; + use values::specified::CSSColor; + + pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result { + use values::specified::{BorderWidth, Length}; + use app_units::Au; + + let (mut color, mut width, mut any) = (None, None, false); + % for value in "color width".split(): + if ${value}.is_none() { + if let Ok(value) = input.try(|input| _webkit_text_stroke_${value}::parse(context, input)) { + ${value} = Some(value); + any = true; + } + } + % endfor + + if !any { + return Err(()); + } + + Ok(Longhands { + _webkit_text_stroke_color: color.or(Some(CSSColor { parsed: CSSParserColor::CurrentColor, + authored: None })), + _webkit_text_stroke_width: width.or(Some(BorderWidth::from_length(Length::Absolute(Au::from_px(0))))), + }) + } + + impl<'a> LonghandsToSerialize<'a> { + fn to_css_declared(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { + let mut style_present = false; + if let DeclaredValue::Value(ref width) = *self._webkit_text_stroke_width { + style_present = true; + try!(width.to_css(dest)); + } + + if let DeclaredValue::Value(ref color) = *self._webkit_text_stroke_color { + if style_present { + try!(write!(dest, " ")); + } + try!(color.to_css(dest)); + } + + Ok(()) + } + } +