Bug 1294966 - Part 2. Return correct width/height of bbox of an svg element even if the size of it is empty.
MozReview-Commit-ID: JnycqLvgu6D
--- a/dom/svg/SVGImageElement.cpp
+++ b/dom/svg/SVGImageElement.cpp
@@ -248,17 +248,19 @@ SVGImageElement::GetGeometryBounds(Rect*
const Matrix* aToNonScalingStrokeSpace)
{
Rect rect;
GetAnimatedLengthValues(&rect.x, &rect.y, &rect.width,
&rect.height, nullptr);
if (rect.IsEmpty()) {
// Rendering of the element disabled
- rect.SetEmpty(); // Make sure width/height are zero and not negative
+ // Make sure width/height are not negative
+ rect.x = rect.x >= 0 ? rect.x : 0;
+ rect.y = rect.y >= 0 ? rect.y : 0;
}
*aBounds = aToBoundsSpace.TransformBounds(rect);
return true;
}
already_AddRefed<Path>
SVGImageElement::BuildPath(PathBuilder* aBuilder)
--- a/dom/svg/SVGRectElement.cpp
+++ b/dom/svg/SVGRectElement.cpp
@@ -119,17 +119,19 @@ SVGRectElement::GetGeometryBounds(Rect*
{
Rect rect;
Float rx, ry;
GetAnimatedLengthValues(&rect.x, &rect.y, &rect.width,
&rect.height, &rx, &ry, nullptr);
if (rect.IsEmpty()) {
// Rendering of the element disabled
- rect.SetEmpty(); // Make sure width/height are zero and not negative
+ // Make sure width/height are not negative
+ rect.x = rect.x >= 0 ? rect.x : 0;
+ rect.y = rect.y >= 0 ? rect.y : 0;
// We still want the x/y position from 'rect'
*aBounds = aToBoundsSpace.TransformBounds(rect);
return true;
}
if (!aToBoundsSpace.IsRectilinear()) {
// We can't ignore the radii in this case if we want tight bounds
rx = std::max(rx, 0.0f);