diff --git a/layout/svg/base/src/nsSVGOuterSVGFrame.cpp b/layout/svg/base/src/nsSVGOuterSVGFrame.cpp index 03c11bc1d28..38fb931f93f 100644 --- a/layout/svg/base/src/nsSVGOuterSVGFrame.cpp +++ b/layout/svg/base/src/nsSVGOuterSVGFrame.cpp @@ -54,6 +54,7 @@ #include "nsPIDOMWindow.h" #include "nsIObjectLoadingContent.h" #include "nsIInterfaceRequestorUtils.h" +#include "nsSVGMatrix.h" #if defined(DEBUG) && defined(SVG_DEBUG_PRINTING) #include "nsIDeviceContext.h" @@ -713,15 +714,21 @@ already_AddRefed nsSVGOuterSVGFrame::GetCanvasTM() { if (!mCanvasTM) { - nsCOMPtr vb2vp; nsSVGSVGElement *svgElement = static_cast(mContent); - svgElement->GetViewboxToViewportTransform(getter_AddRefs(vb2vp)); - // Scale the transform from CSS pixel space to device pixel space float devPxPerCSSPx = 1 / PresContext()->AppUnitsToFloatCSSPixels( PresContext()->AppUnitsPerDevPixel()); - vb2vp->Scale(devPxPerCSSPx, getter_AddRefs(mCanvasTM)); + nsCOMPtr devPxToCSSPxMatrix; + NS_NewSVGMatrix(getter_AddRefs(devPxToCSSPxMatrix), + devPxPerCSSPx, 0.0f, + 0.0f, devPxPerCSSPx); + + nsCOMPtr viewBoxMatrix; + svgElement->GetViewboxToViewportTransform(getter_AddRefs(viewBoxMatrix)); + + // PRE-multiply px conversion! + devPxToCSSPxMatrix->Multiply(viewBoxMatrix, getter_AddRefs(mCanvasTM)); // our content is the document element so we must premultiply the values // of its currentScale and currentTranslate properties