From 66a28a4f5aec9375aa8c8e92533b14ada1a69b38 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 17 Feb 2017 15:36:38 -0800 Subject: [PATCH] stylo: Support `marker` shorthand; update boxing MozReview-Commit-ID: 7B6h4IDZD67 --- .../properties/longhand/inherited_svg.mako.rs | 16 ++++----- .../shorthand/inherited_svg.mako.rs | 36 +++++++++++++++++++ 2 files changed, 44 insertions(+), 8 deletions(-) create mode 100644 components/style/properties/shorthand/inherited_svg.mako.rs diff --git a/components/style/properties/longhand/inherited_svg.mako.rs b/components/style/properties/longhand/inherited_svg.mako.rs index be6721d0906c..ffba35e83f3a 100644 --- a/components/style/properties/longhand/inherited_svg.mako.rs +++ b/components/style/properties/longhand/inherited_svg.mako.rs @@ -72,7 +72,6 @@ ${helpers.predefined_type( products="gecko", animatable=True, needs_context=False, - boxed=True, spec="https://www.w3.org/TR/SVG2/painting.html#StrokeWidth")} ${helpers.single_keyword("stroke-linecap", "butt round square", @@ -107,7 +106,6 @@ ${helpers.predefined_type( "parse_numbers_are_pixels", products="gecko", animatable=True, - boxed=True, needs_context=False, spec="https://www.w3.org/TR/SVG2/painting.html#StrokeDashing")} @@ -122,20 +120,17 @@ ${helpers.single_keyword("clip-rule", "nonzero evenodd", ${helpers.predefined_type("marker-start", "UrlOrNone", "Either::Second(None_)", products="gecko", animatable="False", - spec="https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties", - boxed=True)} + spec="https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties")} ${helpers.predefined_type("marker-mid", "UrlOrNone", "Either::Second(None_)", products="gecko", animatable="False", - spec="https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties", - boxed=True)} + spec="https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties")} ${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)", products="gecko", animatable="False", - spec="https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties", - boxed=True)} + spec="https://www.w3.org/TR/SVG2/painting.html#VertexMarkerProperties")} <%helpers:longhand name="paint-order" animatable="False" @@ -171,12 +166,17 @@ ${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)", /// Higher priority values, i.e. the values specified first, /// will be painted first (and may be covered by paintings of lower priority) #[derive(PartialEq, Clone, Copy, Debug)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedValue(pub u8); pub mod computed_value { pub use super::SpecifiedValue as T; } + pub fn get_initial_value() -> SpecifiedValue { + SpecifiedValue(NORMAL) + } + impl SpecifiedValue { pub fn bits_at(&self, pos: u8) -> u8 { (self.0 >> pos * SHIFT) & MASK diff --git a/components/style/properties/shorthand/inherited_svg.mako.rs b/components/style/properties/shorthand/inherited_svg.mako.rs new file mode 100644 index 000000000000..24d6e37890ce --- /dev/null +++ b/components/style/properties/shorthand/inherited_svg.mako.rs @@ -0,0 +1,36 @@ +/* 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/. */ + +<%namespace name="helpers" file="/helpers.mako.rs" /> + +<%helpers:shorthand name="marker" products="gecko" + sub_properties="marker-start marker-end marker-mid" + spec="https://www.w3.org/TR/SVG2/painting.html#MarkerShorthand"> + use values::specified::UrlOrNone; + + pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result { + let url = UrlOrNone::parse(context, input)?; + + Ok(Longhands { + marker_start: url.clone(), + marker_mid: url.clone(), + marker_end: url, + }) + } + + impl<'a> LonghandsToSerialize<'a> { + fn to_css_declared(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { + if let DeclaredValue::Value(ref start) = *self.marker_start { + if let DeclaredValue::Value(ref mid) = *self.marker_mid { + if let DeclaredValue::Value(ref end) = *self.marker_end { + if start == mid && mid == end { + start.to_css(dest)?; + } + } + } + } + Ok(()) + } + } +