summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Danner <danner.simon@gmail.com>2020-09-07 20:50:31 +0200
committerAndreas Kling <kling@serenityos.org>2020-09-08 13:57:18 +0200
commit772fcba814493d7843af327590fec11c1ab2f0b1 (patch)
tree8c7d94af0b374f9d3c6d58621fbf20edf8134b79
parent6e61532e06495c18852d66eee1d7ba8f959a9c04 (diff)
downloadserenity-772fcba814493d7843af327590fec11c1ab2f0b1.zip
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.
-rw-r--r--Libraries/LibWeb/SVG/SVGPathElement.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/Libraries/LibWeb/SVG/SVGPathElement.cpp b/Libraries/LibWeb/SVG/SVGPathElement.cpp
index c1a67834ed..a797d05909 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;
}