Bug 1325487 - Improve SVGContentUtils::ComputeNormalizedHypotenuse and use it more r=dholbert

This commit is contained in:
Robert Longson 2016-12-23 17:28:13 +00:00
parent 7173b111bb
commit 89c77adf8e
2 changed files with 5 additions and 4 deletions

View File

@ -21,6 +21,7 @@
#include "nsIFrame.h"
#include "nsIScriptError.h"
#include "nsLayoutUtils.h"
#include "nsMathUtils.h"
#include "SVGAnimationElement.h"
#include "SVGAnimatedPreserveAspectRatio.h"
#include "nsContentUtils.h"
@ -509,7 +510,7 @@ SVGContentUtils::RectilinearGetStrokeBounds(const Rect& aRect,
double
SVGContentUtils::ComputeNormalizedHypotenuse(double aWidth, double aHeight)
{
return sqrt((aWidth*aWidth + aHeight*aHeight)/2);
return NS_hypot(aWidth, aHeight) / M_SQRT2;
}
float

View File

@ -13,7 +13,6 @@
#include "mozilla/gfx/PathHelpers.h"
#include "nsCSSRendering.h"
#include "nsIFrame.h"
#include "nsMathUtils.h"
#include "nsRenderingContext.h"
#include "nsRuleNode.h"
#include "nsSVGElement.h"
@ -154,8 +153,9 @@ nsCSSClipPathInstance::CreateClipPathCircle(DrawTarget* aDrawTarget,
} else {
// We resolve percent <shape-radius> value for circle() as defined here:
// https://drafts.csswg.org/css-shapes/#funcdef-circle
const double sqrt2 = std::sqrt(2.0);
double referenceLength = NS_hypot(aRefBox.width, aRefBox.height) / sqrt2;
double referenceLength =
SVGContentUtils::ComputeNormalizedHypotenuse(aRefBox.width,
aRefBox.height);
r = nsRuleNode::ComputeCoordPercentCalc(coords[0],
NSToCoordRound(referenceLength));
}