Bug 619967 - Resolve percentage filter primitive attributes correctly. r=roc
authorRobert Longson <longsonr@gmail.com>
Mon, 09 Jan 2012 13:18:53 +1100
changeset 85252 1848f311b78616be3519f18496d71f5eb7a84402
parent 85251 20ae82960dc3e9608065eac60bc3e5294dde39b2
child 85253 6239ab8b23193f7972a567c4253a89f1cd94f064
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs619967
milestone12.0a1
Bug 619967 - Resolve percentage filter primitive attributes correctly. r=roc
layout/svg/base/src/nsSVGFilterInstance.cpp
--- a/layout/svg/base/src/nsSVGFilterInstance.cpp
+++ b/layout/svg/base/src/nsSVGFilterInstance.cpp
@@ -38,21 +38,16 @@
 #include "nsSVGUtils.h"
 #include "nsIDOMSVGUnitTypes.h"
 #include "gfxPlatform.h"
 #include "nsSVGFilterPaintCallback.h"
 #include "nsSVGFilterElement.h"
 #include "nsLayoutUtils.h"
 #include "gfxUtils.h"
 
-static double Square(double aX)
-{
-  return aX*aX;
-}
-
 float
 nsSVGFilterInstance::GetPrimitiveNumber(PRUint8 aCtxType, float aValue) const
 {
   nsSVGLength2 val;
   val.Init(aCtxType, 0xff, aValue,
            nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER);
 
   float value;
@@ -64,19 +59,19 @@ nsSVGFilterInstance::GetPrimitiveNumber(
 
   switch (aCtxType) {
   case nsSVGUtils::X:
     return value * mFilterSpaceSize.width / mFilterRect.Width();
   case nsSVGUtils::Y:
     return value * mFilterSpaceSize.height / mFilterRect.Height();
   case nsSVGUtils::XY:
   default:
-    return value *
-      sqrt(Square(mFilterSpaceSize.width) + Square(mFilterSpaceSize.height)) /
-      sqrt(Square(mFilterRect.Width()) + Square(mFilterRect.Height()));
+    return value * nsSVGUtils::ComputeNormalizedHypotenuse(
+                     mFilterSpaceSize.width / mFilterRect.Width(),
+                     mFilterSpaceSize.height / mFilterRect.Height());
   }
 }
 
 void
 nsSVGFilterInstance::ConvertLocation(float aValues[3]) const
 {
   nsSVGLength2 val[4];
   val[0].Init(nsSVGUtils::X, 0xff, aValues[0],