mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 17:55:07 +02:00
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.
36 lines
1.6 KiB
HTML
36 lines
1.6 KiB
HTML
<!DOCTYPE html>
|
|
<script src="../include.js"></script>
|
|
<svg xmlns="http://www.w3.org/2000/svg" style="display: none" id="svg-element"></svg>
|
|
<script>
|
|
test(() => {
|
|
const svgElement = document.getElementById("svg-element");
|
|
svgElement.setAttribute("viewBox", "0,1,2,3");
|
|
println(svgElement.viewBox.baseVal.x);
|
|
println(svgElement.viewBox.baseVal.y);
|
|
println(svgElement.viewBox.baseVal.width);
|
|
println(svgElement.viewBox.baseVal.height);
|
|
svgElement.setAttribute("viewBox", " 4 , 5 , 6 , 7 ");
|
|
println(svgElement.viewBox.baseVal.x);
|
|
println(svgElement.viewBox.baseVal.y);
|
|
println(svgElement.viewBox.baseVal.width);
|
|
println(svgElement.viewBox.baseVal.height);
|
|
svgElement.setAttribute("viewBox", "8 9,10 11");
|
|
println(svgElement.viewBox.baseVal.x);
|
|
println(svgElement.viewBox.baseVal.y);
|
|
println(svgElement.viewBox.baseVal.width);
|
|
println(svgElement.viewBox.baseVal.height);
|
|
svgElement.setAttribute("viewBox", "");
|
|
println(svgElement.viewBox.baseVal);
|
|
svgElement.setAttribute("viewBox", " , , , ");
|
|
println(svgElement.viewBox.baseVal);
|
|
svgElement.setAttribute("viewBox", "12");
|
|
println(svgElement.viewBox.baseVal);
|
|
svgElement.setAttribute("viewBox", "13,");
|
|
println(svgElement.viewBox.baseVal);
|
|
svgElement.setAttribute("viewBox", ",14");
|
|
println(svgElement.viewBox.baseVal);
|
|
svgElement.setAttribute("viewBox", "15,16,17,18,");
|
|
println(svgElement.viewBox.baseVal);
|
|
});
|
|
</script>
|