From 9aed1de6a5279c79e4cf217693009775365e4a26 Mon Sep 17 00:00:00 2001 From: Boris Chiou Date: Fri, 24 Jan 2020 18:59:03 +0000 Subject: [PATCH] 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 --- components/style/values/specified/svg_path.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/components/style/values/specified/svg_path.rs b/components/style/values/specified/svg_path.rs index b5461bb37fc..288f396b73c 100644 --- a/components/style/values/specified/svg_path.rs +++ b/components/style/values/specified/svg_path.rs @@ -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> { 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);