mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Make stroke-dasharray accept context-value.
This commit is contained in:
parent
aa80859a71
commit
7827ca6bb5
8 changed files with 143 additions and 23 deletions
|
@ -6,7 +6,7 @@
|
|||
|
||||
use cssparser::Parser;
|
||||
use parser::{Parse, ParserContext};
|
||||
use style_traits::{ParseError, StyleParseError};
|
||||
use style_traits::{CommaWithSpace, ParseError, Separator, StyleParseError};
|
||||
use values::generics::svg as generic;
|
||||
use values::specified::LengthOrPercentageOrNumber;
|
||||
use values::specified::color::RGBAColor;
|
||||
|
@ -69,3 +69,21 @@ impl From<LengthOrPercentageOrNumber> for SVGLength {
|
|||
generic::SVGLength::Length(length)
|
||||
}
|
||||
}
|
||||
|
||||
/// [ <length> | <percentage> | <number> ]# | context-value
|
||||
pub type SVGStrokeDashArray = generic::SVGStrokeDashArray<LengthOrPercentageOrNumber>;
|
||||
|
||||
impl Parse for SVGStrokeDashArray {
|
||||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<Self, ParseError<'i>> {
|
||||
if let Ok(values) = input.try(|i| CommaWithSpace::parse(i, |i| {
|
||||
LengthOrPercentageOrNumber::parse_non_negative(context, i)
|
||||
})) {
|
||||
Ok(generic::SVGStrokeDashArray::Values(values))
|
||||
} else if let Ok(_) = input.try(|i| i.expect_ident_matching("none")) {
|
||||
Ok(generic::SVGStrokeDashArray::Values(vec![]))
|
||||
} else {
|
||||
parse_context_value(input, generic::SVGStrokeDashArray::ContextValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue