Bug 537623 - Part 1. Remove extra translation for <use> element in nsSVGUtils. r=longsonr+218550
authorcku <cku@mozilla.com>
Tue, 17 Jan 2017 17:06:16 +0800
changeset 377062 5db57e49db29a6218aed3ba3bcbbae0ce897bdcf
parent 377061 e85cf51eeaa76cbaa3c13f384e20ff018210b4aa
child 377063 71db159b7fd98359be5f9ffe9ff93d8f29adce50
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslongsonr
bugs537623, 218550
milestone53.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 537623 - Part 1. Remove extra translation for <use> element in nsSVGUtils. r=longsonr+218550 For nsSVGUtils::FrameSpaceInCSSPxToUserSpace: If we give a nsSVGUseFrame to this function, it will return <use>'s x/y as translation vector, which is not necessary. A point (a, b) in frame's coordinate space should keep (a, b) in <use>'s coordinate space with no change. Since we remove extra translation in nsSVGUtils::FrameSpaceInCSSPxToUserSpace, aslo update nsSVGUtils::GetBBox accordingly. MozReview-Commit-ID: BMjSonjoWd2
layout/svg/nsSVGUtils.cpp
--- a/layout/svg/nsSVGUtils.cpp
+++ b/layout/svg/nsSVGUtils.cpp
@@ -1121,18 +1121,17 @@ nsSVGUtils::GetBBox(nsIFrame *aFrame, ui
     if (aFlags == eBBoxIncludeFillGeometry) {
       gfxRect* prop = props.Get(ObjectBoundingBoxProperty());
       if (prop) {
         return *prop;
       }
     }
 
     gfxMatrix matrix;
-    if (aFrame->GetType() == nsGkAtoms::svgForeignObjectFrame ||
-        aFrame->GetType() == nsGkAtoms::svgUseFrame) {
+    if (aFrame->GetType() == nsGkAtoms::svgForeignObjectFrame) {
       // 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);
@@ -1214,18 +1213,17 @@ nsSVGUtils::FrameSpaceInCSSPxToUserSpace
   if (aFrame->IsFrameOfType(nsIFrame::eSVGGeometry) ||
       aFrame->IsSVGText()) {
     return nsLayoutUtils::RectToGfxRect(aFrame->GetRect(),
                                          nsPresContext::AppUnitsPerCSSPixel()).TopLeft();
   }
 
   // For foreignObject frames, nsSVGUtils::GetBBox applies their local
   // transform, so we need to do the same here.
-  if (aFrame->GetType() == nsGkAtoms::svgForeignObjectFrame ||
-      aFrame->GetType() == nsGkAtoms::svgUseFrame) {
+  if (aFrame->GetType() == nsGkAtoms::svgForeignObjectFrame) {
     gfxMatrix transform = static_cast<nsSVGElement*>(aFrame->GetContent())->
         PrependLocalTransformsTo(gfxMatrix(), eChildToUserSpace);
     NS_ASSERTION(!transform.HasNonTranslation(), "we're relying on this being an offset-only transform");
     return transform.GetTranslation();
   }
 
   return gfxPoint();
 }