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
--- 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();
}