Bug 1395439 - Clean out useless flags to reuse cache FillGeometry in nsSVGUtils::GetBBox. r=longsonr+218550
authorcku <cku@mozilla.com>
Thu, 31 Aug 2017 12:21:39 +0800
changeset 378150 aa111604eaa34be601b91b32aa077939b4252c28
parent 378149 b18cad4e3274cb2a6b92eb95779f099b79c4fd5d
child 378151 de726c1fbb1e85aad4ed2f3f3d91366024818739
push id94412
push userarchaeopteryx@coole-files.de
push dateFri, 01 Sep 2017 08:46:09 +0000
treeherdermozilla-inbound@d56571d7f1be [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslongsonr
bugs1395439, 218550
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1395439 - Clean out useless flags to reuse cache FillGeometry in nsSVGUtils::GetBBox. r=longsonr+218550 In nsSVGUtils::GetBBox, we cache fill-gemorty's bbox in ObjectBoundingBoxProperty of the given frame[1] so that we can just return the cache value without recomputing bbox. Some new added flags, such as eUseFrameBoundsForOuterSVG, prevent storing and reusing this cache value. This patch is trying to make this cache mechanism work again. [1] https://hg.mozilla.org/mozilla-central/file/ef585ac7c476/layout/svg/nsSVGUtils.cpp#l1119 MozReview-Commit-ID: 8vWDzFi8qCw
layout/svg/nsSVGUtils.cpp
--- a/layout/svg/nsSVGUtils.cpp
+++ b/layout/svg/nsSVGUtils.cpp
@@ -1108,33 +1108,40 @@ nsSVGUtils::GetBBox(nsIFrame* aFrame, ui
   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;
+  }
+
   if (aFlags == eBBoxIncludeFillGeometry &&
       // We only cache bbox in element's own user space
       !aToBoundsSpace) {
     gfxRect* prop = aFrame->GetProperty(ObjectBoundingBoxProperty());
     if (prop) {
       return *prop;
     }
   }
 
   gfxMatrix matrix;
   if (aToBoundsSpace) {
     matrix = *aToBoundsSpace;
   }
 
   if (aFrame->IsSVGForeignObjectFrame() ||
-      (aFrame->IsSVGUseFrame() &&
-       (aFlags & nsSVGUtils::eUseUserSpaceOfUseElement))) {
+      aFlags & nsSVGUtils::eUseUserSpaceOfUseElement) {
     // 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);