diff options
author | Andreas Kling <kling@serenityos.org> | 2023-04-17 12:34:00 +0200 |
---|---|---|
committer | Jelle Raaijmakers <jelle@gmta.nl> | 2023-04-17 14:18:45 +0200 |
commit | 7f79208759f7b788cde8aeeeec4ff0cdb34171db (patch) | |
tree | 1e619dc02415b827692a7cc973d1690413f0a247 /Userland/Libraries/LibWeb/SVG | |
parent | 8d0985ef012188d20212b1532450dc1cd19008d7 (diff) | |
download | serenity-7f79208759f7b788cde8aeeeec4ff0cdb34171db.zip |
LibWeb: Support implicit lineto commands after moveto in SVG paths
Per SVG2, any coordinate pairs following a moveto command should be
treated as implicit lineto commands with the same absoluteness as the
moveto command.
Diffstat (limited to 'Userland/Libraries/LibWeb/SVG')
-rw-r--r-- | Userland/Libraries/LibWeb/SVG/AttributeParser.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/SVG/AttributeParser.cpp b/Userland/Libraries/LibWeb/SVG/AttributeParser.cpp index 644f2843a5..64ccd31c44 100644 --- a/Userland/Libraries/LibWeb/SVG/AttributeParser.cpp +++ b/Userland/Libraries/LibWeb/SVG/AttributeParser.cpp @@ -130,12 +130,19 @@ void AttributeParser::parse_drawto() } } +// https://www.w3.org/TR/SVG2/paths.html#PathDataMovetoCommands void AttributeParser::parse_moveto() { bool absolute = consume() == 'M'; parse_whitespace(); - for (auto& pair : parse_coordinate_pair_sequence()) - m_instructions.append({ PathInstructionType::Move, absolute, pair }); + + bool is_first = true; + for (auto& pair : parse_coordinate_pair_sequence()) { + // NOTE: "M 1 2 3 4" is equivalent to "M 1 2 L 3 4". + auto type = is_first ? PathInstructionType::Move : PathInstructionType::Line; + m_instructions.append({ type, absolute, pair }); + is_first = false; + } } void AttributeParser::parse_closepath() |