Skip to content

Commit

Permalink
stylo: Support marker shorthand; update boxing
Browse files Browse the repository at this point in the history
MozReview-Commit-ID: 7B6h4IDZD67
  • Loading branch information
Manishearth committed Feb 18, 2017
1 parent 895fcb2 commit 66a28a4
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 8 deletions.
16 changes: 8 additions & 8 deletions components/style/properties/longhand/inherited_svg.mako.rs
Expand Up @@ -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",
Expand Down Expand Up @@ -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")}

Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down
36 changes: 36 additions & 0 deletions 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>

0 comments on commit 66a28a4

Please sign in to comment.