Bug 537623 - Part 1. Remove extra translation for <use> element in nsSVGUtils. draft
authorcku <cku@mozilla.com>
Tue, 17 Jan 2017 17:06:16 +0800
changeset 462406 da629ba4464534a89718db1cd5b9705261ae4a4d
parent 461121 8eaf154b385bbe0ff06155294ccf7962aa2d3324
child 462407 61a8008da3351207d517291c571234553f0f49ab
child 462409 626602168e24d539d0588658b3e7200e50539fbd
push id41736
push userbmo:cku@mozilla.com
push dateTue, 17 Jan 2017 09:41:03 +0000
bugs537623
milestone53.0a1
Bug 537623 - Part 1. Remove extra translation for <use> element in nsSVGUtils. 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();
 }