mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
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.
This commit is contained in:
parent
8d0985ef01
commit
7f79208759
Notes:
sideshowbarker
2024-07-17 05:01:20 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/7f79208759 Pull-request: https://github.com/SerenityOS/serenity/pull/18411 Reviewed-by: https://github.com/gmta ✅
@ -0,0 +1,7 @@
|
||||
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||
BlockContainer <html> at (0,0) content-size 800x116 children: not-inline
|
||||
BlockContainer <body> at (8,8) content-size 784x100 children: inline
|
||||
line 0 width: 100, height: 100, bottom: 100, baseline: 60
|
||||
frag 0 from SVGSVGBox start: 0, length: 0, rect: [8,8 100x100]
|
||||
SVGSVGBox <svg> at (8,8) content-size 100x100 children: not-inline
|
||||
SVGGeometryBox <path> at (28,28) content-size 60x60 children: not-inline
|
@ -0,0 +1,6 @@
|
||||
<!DOCTYPE html><html><body><svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="100"
|
||||
height="100"
|
||||
viewBox="0 0 10 10"
|
||||
><path d="M 2 2 5 8 8 2 z"></path></svg>
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user