From 772fcba814493d7843af327590fec11c1ab2f0b1 Mon Sep 17 00:00:00 2001 From: Simon Danner Date: Mon, 7 Sep 2020 20:50:31 +0200 Subject: [PATCH] LibWeb: SVG: draw commands can also be repeated after a comma Consume comma or whitespace to make it possible to also parse commands that use comma separation. --- Libraries/LibWeb/SVG/SVGPathElement.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Libraries/LibWeb/SVG/SVGPathElement.cpp b/Libraries/LibWeb/SVG/SVGPathElement.cpp index c1a67834eda..a797d05909e 100644 --- a/Libraries/LibWeb/SVG/SVGPathElement.cpp +++ b/Libraries/LibWeb/SVG/SVGPathElement.cpp @@ -150,6 +150,7 @@ void PathDataParser::parse_moveto() void PathDataParser::parse_closepath() { bool absolute = consume() == 'Z'; + parse_whitespace(); m_instructions.append({ PathInstructionType::ClosePath, absolute, {} }); } @@ -182,7 +183,8 @@ void PathDataParser::parse_curveto() while (true) { m_instructions.append({ PathInstructionType::Curve, absolute, parse_coordinate_pair_triplet() }); - parse_whitespace(); + if (match_comma_whitespace()) + parse_comma_whitespace(); if (!match_coordinate()) break; } @@ -195,7 +197,8 @@ void PathDataParser::parse_smooth_curveto() while (true) { m_instructions.append({ PathInstructionType::SmoothCurve, absolute, parse_coordinate_pair_double() }); - parse_whitespace(); + if (match_comma_whitespace()) + parse_comma_whitespace(); if (!match_coordinate()) break; } @@ -208,7 +211,8 @@ void PathDataParser::parse_quadratic_bezier_curveto() while (true) { m_instructions.append({ PathInstructionType::QuadraticBezierCurve, absolute, parse_coordinate_pair_double() }); - parse_whitespace(); + if (match_comma_whitespace()) + parse_comma_whitespace(); if (!match_coordinate()) break; } @@ -221,7 +225,8 @@ void PathDataParser::parse_smooth_quadratic_bezier_curveto() while (true) { m_instructions.append({ PathInstructionType::SmoothQuadraticBezierCurve, absolute, parse_coordinate_pair() }); - parse_whitespace(); + if (match_comma_whitespace()) + parse_comma_whitespace(); if (!match_coordinate()) break; } @@ -234,7 +239,8 @@ void PathDataParser::parse_elliptical_arc() while (true) { m_instructions.append({ PathInstructionType::EllipticalArc, absolute, parse_elliptical_arg_argument() }); - parse_whitespace(); + if (match_comma_whitespace()) + parse_comma_whitespace(); if (!match_coordinate()) break; }