Bug 1374233 - Part 9: Add NonNegativeLengthOrPercentageOrNumber for stroke-{width|dasharry}.

Also add SVGWidth which use NonNegativeSVGLengthOrPercentage
as the LengthType for stroke-width.

MozReview-Commit-ID: 8gD0fVe2eAe
This commit is contained in:
Boris Chiou 2017-07-21 16:59:28 +08:00
parent b37f270c65
commit bd0a098ef1
9 changed files with 64 additions and 46 deletions

View file

@ -7,6 +7,7 @@
use app_units::Au;
use values::{Either, RGBA};
use values::computed::{LengthOrPercentageOrNumber, Opacity};
use values::computed::{NonNegativeAu, NonNegativeLengthOrPercentageOrNumber};
use values::generics::svg as generic;
/// Computed SVG Paint value
@ -43,8 +44,17 @@ impl From<Au> for SVGLength {
}
}
/// An non-negative wrapper of SVGLength.
pub type SVGWidth = generic::SVGLength<NonNegativeLengthOrPercentageOrNumber>;
impl From<NonNegativeAu> for SVGWidth {
fn from(length: NonNegativeAu) -> Self {
generic::SVGLength::Length(Either::Second(length.into()))
}
}
/// [ <length> | <percentage> | <number> ]# | context-value
pub type SVGStrokeDashArray = generic::SVGStrokeDashArray<LengthOrPercentageOrNumber>;
pub type SVGStrokeDashArray = generic::SVGStrokeDashArray<NonNegativeLengthOrPercentageOrNumber>;
impl Default for SVGStrokeDashArray {
fn default() -> Self {