commit fb0dc04b190c79aa6b9e7376e6308394f7cc8e03
parent f690cf8ee9eafbe9d79eb3e828d9f2b9be83f0a2
Author: longsonr <longsonr@gmail.com>
Date: Thu, 30 Oct 2025 20:29:41 +0000
Bug 1997305 - Return a fill size even when a shape is fill=none r=firefox-svg-reviewers,dholbert
Differential Revision: https://phabricator.services.mozilla.com/D270700
Diffstat:
3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/dom/svg/test/test_bounds.html b/dom/svg/test/test_bounds.html
@@ -34,7 +34,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=463934
<g id="g-6">
<rect x="5" y="5" width="10" height="10"/>
<g>
- <!-- The rect has neither fill, nor stroke so has no bounds. -->
<rect x="20" y="20" width="30" height="30" fill="none"/>
</g>
</g>
@@ -85,8 +84,8 @@ function runTest() {
is(bounds.height, 6, "css-trans-rect getBoundingClientRect().height");
bounds = document.getElementById("g-6").getBoundingClientRect();
- is(bounds.width, 10, "g-6 getBoundingClientRect().width");
- is(bounds.height, 10, "g-6 getBoundingClientRect().height");
+ is(bounds.width, 45, "g-6 getBoundingClientRect().width");
+ is(bounds.height, 45, "g-6 getBoundingClientRect().height");
var doc = $("svg").contentWindow.document;
diff --git a/layout/svg/SVGGeometryFrame.cpp b/layout/svg/SVGGeometryFrame.cpp
@@ -267,8 +267,9 @@ void SVGGeometryFrame::ReflowSVG() {
return;
}
- uint32_t flags = SVGUtils::eBBoxIncludeFill | SVGUtils::eBBoxIncludeStroke |
- SVGUtils::eBBoxIncludeMarkers;
+ uint32_t flags = SVGUtils::eBBoxIncludeFillGeometry |
+ SVGUtils::eBBoxIncludeStroke | SVGUtils::eBBoxIncludeMarkers;
+
// Our "visual" overflow rect needs to be valid for building display lists
// for hit testing, which means that for certain values of 'pointer-events'
// it needs to include the geometry of the fill or stroke even when the fill/
diff --git a/testing/web-platform/tests/svg/geometry/svg-get-bounding-client-rect-in-non-rendered-elements.html b/testing/web-platform/tests/svg/geometry/svg-get-bounding-client-rect-in-non-rendered-elements.html
@@ -25,7 +25,6 @@
<g id="g1">
<rect x="5" y="5" width="10" height="10"/>
<g>
- <!-- This rect has neither fill, nor stroke so has no bounds. -->
<rect x="20" y="20" width="30" height="30" fill="none"/>
</g>
</g>
@@ -48,7 +47,7 @@
assert_equals(rect5.getBoundingClientRect().width, 0, "rect5");
assert_equals(rect6.getBoundingClientRect().width, 10, "rect6");
assert_equals(symbol.getBoundingClientRect().width, 0, "symbol");
- assert_equals(g1.getBoundingClientRect().width, 10, "g1");
+ assert_equals(g1.getBoundingClientRect().width, 45, "g1");
assert_equals(rect1.getBoundingClientRect().height, 0, "rect1");
assert_equals(rect2.getBoundingClientRect().height, 0, "rect2");
@@ -57,6 +56,6 @@
assert_equals(rect5.getBoundingClientRect().height, 0, "rect5");
assert_equals(rect6.getBoundingClientRect().height, 10, "rect6");
assert_equals(symbol.getBoundingClientRect().height, 0, "symbol");
- assert_equals(g1.getBoundingClientRect().height, 10, "g1");
+ assert_equals(g1.getBoundingClientRect().height, 45, "g1");
}, "Get Bounding Client Rect");
</script>