style: Make the empty svg path valid.

Per SVG2 spec, the EBNF allows the path data string to be empty.
An empty path data string disables rendering of the path.
Therefore, we should make path('') a valid path string.

The related spec issue: https://github.com/w3c/fxtf-drafts/issues/392.
Now we serialize `path("")` as `path("")` for offset-path and clip-path.

Differential Revision: https://phabricator.services.mozilla.com/D60771
This commit is contained in:
Boris Chiou 2020-01-24 18:59:03 +00:00 committed by Emilio Cobos Álvarez
parent 3991ab9999
commit 9aed1de6a5
No known key found for this signature in database
GPG key ID: E1152D0994E4BF8A

View file

@ -42,7 +42,6 @@ impl SVGPathData {
/// Get the array of PathCommand.
#[inline]
pub fn commands(&self) -> &[PathCommand] {
debug_assert!(!self.0.is_empty());
&self.0
}
@ -92,10 +91,6 @@ impl Parse for SVGPathData {
) -> Result<Self, ParseError<'i>> {
let location = input.current_source_location();
let path_string = input.expect_string()?.as_ref();
if path_string.is_empty() {
// Treat an empty string as invalid, so we will not set it.
return Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError));
}
// Parse the svg path string as multiple sub-paths.
let mut path_parser = PathParser::new(path_string);