Bug 1294966 - Part 1. Return correct x/y of bbox of an svg element even if the size of it is empty. draft
authorcku <cku@mozilla.com>
Wed, 06 Sep 2017 17:37:43 +0800
changeset 659968 10fa430bc0c572a0ce793f1b57ab07bd028741c7
parent 659384 f64e2b4dcf5eec0b4ad456c149680a67b7c26dc4
child 659969 bb3ebeaca177a99edc820fe20b59c12f20514fa3
child 660002 b1c7a279ad5a27bab34127e993d947aab7260944
push id78251
push userbmo:cku@mozilla.com
push dateWed, 06 Sep 2017 12:28:54 +0000
bugs1294966
milestone57.0a1
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
layout/svg/nsSVGUtils.cpp
--- 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);