Skip to content

Commit

Permalink
style: Make the empty svg path valid.
Browse files Browse the repository at this point in the history
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: w3c/fxtf-drafts#392.
Now we serialize `path("")` as `path("")` for offset-path and clip-path.

Differential Revision: https://phabricator.services.mozilla.com/D60771
  • Loading branch information
BorisChiou authored and emilio committed Feb 12, 2020
1 parent 3991ab9 commit 9aed1de
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions components/style/values/specified/svg_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 9aed1de

Please sign in to comment.