From 3b0840d18744f1d1e3ef76008c322c361a9d51e4 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Thu, 9 Feb 2017 17:43:52 -0800 Subject: [PATCH] stylo: Add stroke-width property MozReview-Commit-ID: 4QKKzJ1DVYP --- .../style/properties/longhand/inherited_svg.mako.rs | 10 ++++++++++ components/style/values/computed/length.rs | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/components/style/properties/longhand/inherited_svg.mako.rs b/components/style/properties/longhand/inherited_svg.mako.rs index 7ac8feb2d1a..98112efbba0 100644 --- a/components/style/properties/longhand/inherited_svg.mako.rs +++ b/components/style/properties/longhand/inherited_svg.mako.rs @@ -65,6 +65,16 @@ ${helpers.predefined_type( boxed=True, spec="https://www.w3.org/TR/SVG2/painting.html#SpecifyingStrokePaint")} +${helpers.predefined_type( + "stroke-width", "LengthOrPercentage", + "computed::LengthOrPercentage::one()", + "parse_non_negative", + 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", products="gecko", animatable=False, spec="https://www.w3.org/TR/SVG11/painting.html#StrokeLinecapProperty")} diff --git a/components/style/values/computed/length.rs b/components/style/values/computed/length.rs index 74c9fd6287f..492bbfb4bc0 100644 --- a/components/style/values/computed/length.rs +++ b/components/style/values/computed/length.rs @@ -4,7 +4,7 @@ //! `` computed values, and related ones. -use app_units::Au; +use app_units::{Au, AU_PER_PX}; use ordered_float::NotNaN; use std::fmt; use style_traits::ToCss; @@ -195,6 +195,12 @@ impl LengthOrPercentage { LengthOrPercentage::Length(Au(0)) } + #[inline] + /// 1px length value for SVG defaults + pub fn one() -> LengthOrPercentage { + LengthOrPercentage::Length(Au(AU_PER_PX)) + } + /// Returns true if the computed value is absolute 0 or 0%. /// /// (Returns false for calc() values, even if ones that may resolve to zero.)