mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #17617 - mantaroh:svg-paint-server, r=hiro,manishearth
Handling of invalid values in svg paint server <!-- Please describe your changes on the following line: --> This is a PR for https://bugzilla.mozilla.org/show_bug.cgi?id=1374161 --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors <!-- Either: --> There are tests for these changes, a test case will be landed in reftests in https://bugzilla.mozilla.org/show_bug.cgi?id=1374161. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17288) <!-- Reviewable:end -->
This commit is contained in:
commit
7323c7745c
2 changed files with 23 additions and 6 deletions
|
@ -323,13 +323,25 @@ impl<ColorType> SVGPaintKind<ColorType> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Parse SVGPaint's fallback.
|
||||
/// fallback is keyword(none) or Color.
|
||||
/// https://svgwg.org/svg2-draft/painting.html#SpecifyingPaint
|
||||
fn parse_fallback<'i, 't, ColorType: Parse>(context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>)
|
||||
-> Option<ColorType> {
|
||||
if input.try(|i| i.expect_ident_matching("none")).is_ok() {
|
||||
None
|
||||
} else {
|
||||
input.try(|i| ColorType::parse(context, i)).ok()
|
||||
}
|
||||
}
|
||||
|
||||
impl<ColorType: Parse> Parse for SVGPaint<ColorType> {
|
||||
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
if let Ok(url) = input.try(|i| SpecifiedUrl::parse(context, i)) {
|
||||
let fallback = input.try(|i| ColorType::parse(context, i));
|
||||
Ok(SVGPaint {
|
||||
kind: SVGPaintKind::PaintServer(url),
|
||||
fallback: fallback.ok(),
|
||||
fallback: parse_fallback(context, input),
|
||||
})
|
||||
} else if let Ok(kind) = input.try(SVGPaintKind::parse_ident) {
|
||||
if let SVGPaintKind::None = kind {
|
||||
|
@ -338,10 +350,9 @@ impl<ColorType: Parse> Parse for SVGPaint<ColorType> {
|
|||
fallback: None,
|
||||
})
|
||||
} else {
|
||||
let fallback = input.try(|i| ColorType::parse(context, i));
|
||||
Ok(SVGPaint {
|
||||
kind: kind,
|
||||
fallback: fallback.ok(),
|
||||
fallback: parse_fallback(context, input),
|
||||
})
|
||||
}
|
||||
} else if let Ok(color) = input.try(|i| ColorType::parse(context, i)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue