aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManish Goregaokar <manishearth@gmail.com>2017-02-17 15:36:38 -0800
committerManish Goregaokar <manishsmail@gmail.com>2017-02-18 04:08:41 -0800
commit66a28a4f5aec9375aa8c8e92533b14ada1a69b38 (patch)
treea470d1493671ad1c23cd590de431ad51bf0c1dcd
parent895fcb222be6c3263c90781836db318c4e1c9af8 (diff)
downloadservo-66a28a4f5aec9375aa8c8e92533b14ada1a69b38.tar.gz
servo-66a28a4f5aec9375aa8c8e92533b14ada1a69b38.zip
stylo: Support `marker` shorthand; update boxing
MozReview-Commit-ID: 7B6h4IDZD67
-rw-r--r--components/style/properties/longhand/inherited_svg.mako.rs16
-rw-r--r--components/style/properties/shorthand/inherited_svg.mako.rs36
2 files changed, 44 insertions, 8 deletions
diff --git a/components/style/properties/longhand/inherited_svg.mako.rs b/components/style/properties/longhand/inherited_svg.mako.rs
index be6721d0906..ffba35e83f3 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 00000000000..24d6e37890c
--- /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<Longhands, ()> {
+ 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<W>(&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(())
+ }
+ }
+</%helpers:shorthand>