mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-20 23:19:44 +00:00
LibWeb/SVG: Parse comma-separated SVG viewBox
From the SVG spec The value of the ‘viewBox’ attribute is a list of four numbers <min-x>, <min-y>, <width> and <height>, separated by whitespace and/or a comma... Currently try_parse_view_box will fail to parse the attribute if the values are separated by commas. This change replaces try_parse_view_box with a more correct implementation. It will reside in the AttributeParser.cpp. This new implementation correctly handles comma-separated viewBox values, and is also more robust against invalid inputs. Additionally, it adds a new test case to ensure viewBox values with various syntax are parsed correctly and invalid values are rejected.
This commit is contained in:
parent
c3aa8f0c8d
commit
21ff66c6cb
Notes:
github-actions[bot]
2025-08-30 13:50:27 +00:00
Author: https://github.com/erik-kz
Commit: 21ff66c6cb
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6018
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/kalenikaliaksandr ✅
12 changed files with 104 additions and 91 deletions
|
@ -28,7 +28,7 @@ void SVGFitToViewBox::attribute_changed(DOM::Element& element, FlyString const&
|
|||
if (!value.has_value()) {
|
||||
m_view_box_for_bindings->set_nulled(true);
|
||||
} else {
|
||||
m_view_box = try_parse_view_box(value.value_or(String {}));
|
||||
m_view_box = AttributeParser::parse_viewbox(value.value_or(String {}));
|
||||
m_view_box_for_bindings->set_nulled(!m_view_box.has_value());
|
||||
if (m_view_box.has_value()) {
|
||||
m_view_box_for_bindings->set_base_val(Gfx::DoubleRect { m_view_box->min_x, m_view_box->min_y, m_view_box->width, m_view_box->height });
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue