Bug 1294966 - Part 1. Return correct x/y of bbox of an svg element even if the size of it is empty.
MozReview-Commit-ID: KZxGKOjAnTS
--- a/layout/svg/nsSVGUtils.cpp
+++ b/layout/svg/nsSVGUtils.cpp
@@ -1102,22 +1102,16 @@ nsSVGUtils::GetBBox(nsIFrame* aFrame, ui
bool onlyCurrentFrame = aFlags & eIncludeOnlyCurrentFrameForNonSVGElement;
return nsSVGIntegrationUtils::GetSVGBBoxForNonSVGFrame(
aFrame,
/* aUnionContinuations = */ !onlyCurrentFrame);
}
MOZ_ASSERT(svg);
- nsIContent* content = aFrame->GetContent();
- if (content->IsSVGElement() &&
- !static_cast<const nsSVGElement*>(content)->HasValidDimensions()) {
- return gfxRect();
- }
-
// Clean out flags which have no effects on returning bbox from now, so that
// we can cache and reuse ObjectBoundingBoxProperty() in the code below.
aFlags &= ~eIncludeOnlyCurrentFrameForNonSVGElement;
aFlags &= ~eUseFrameBoundsForOuterSVG;
if (!aFrame->IsSVGUseFrame()) {
aFlags &= ~eUseUserSpaceOfUseElement;
}
@@ -1132,16 +1126,17 @@ nsSVGUtils::GetBBox(nsIFrame* aFrame, ui
gfxMatrix matrix;
if (aToBoundsSpace) {
matrix = *aToBoundsSpace;
}
if (aFrame->IsSVGForeignObjectFrame() ||
aFlags & nsSVGUtils::eUseUserSpaceOfUseElement) {
+ nsIContent* content = aFrame->GetContent();
// The spec says getBBox "Returns the tight bounding box in *current user
// space*". So we should really be doing this for all elements, but that
// needs investigation to check that we won't break too much content.
// NOTE: When changing this to apply to other frame types, make sure to
// also update nsSVGUtils::FrameSpaceInCSSPxToUserSpaceOffset.
MOZ_ASSERT(content->IsSVGElement(), "bad cast");
nsSVGElement *element = static_cast<nsSVGElement*>(content);
matrix = element->PrependLocalTransformsTo(matrix, eChildToUserSpace);