WebKit Bugzilla
Attachment 371253 Details for
Bug 198483
: Use std::hypot() where possible
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
WIP
bug-198483-20190604100432.patch (text/plain), 27.50 KB, created by
Zan Dobersek
on 2019-06-04 01:04:33 PDT
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Zan Dobersek
Created:
2019-06-04 01:04:33 PDT
Size:
27.50 KB
patch
obsolete
>Subversion Revision: 246056 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index bf197880ab046e4b5ac6ea5da72bd00f0569cbe9..d86b1c07f3add8ae3a56342c2bcf9d1962d27491 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,63 @@ >+2019-06-04 Zan Dobersek <zdobersek@igalia.com> >+ >+ Use std::hypot() where possible >+ https://bugs.webkit.org/show_bug.cgi?id=198483 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ No new tests (OOPS!). >+ >+ * css/CSSGradientValue.cpp: >+ (WebCore::horizontalEllipseRadius): >+ * platform/audio/FFTFrame.cpp: >+ (WebCore::FFTFrame::print): >+ * platform/graphics/FloatPoint.cpp: >+ (WebCore::FloatPoint::length const): Deleted. >+ * platform/graphics/FloatPoint.h: >+ (WebCore::FloatPoint::length const): >+ * platform/graphics/FloatPoint3D.h: >+ (WebCore::FloatPoint3D::length const): >+ * platform/graphics/FloatSize.cpp: >+ (WebCore::FloatSize::diagonalLength const): Deleted. >+ * platform/graphics/FloatSize.h: >+ (WebCore::FloatSize::diagonalLength const): >+ * platform/graphics/GeometryUtilities.cpp: >+ (WebCore::euclidianDistance): >+ * platform/graphics/GraphicsContext.cpp: >+ (WebCore::GraphicsContext::computeLineBoundsAndAntialiasingModeForText): >+ * platform/graphics/PathTraversalState.cpp: >+ (WebCore::distanceLine): >+ * platform/graphics/cairo/CairoOperations.cpp: >+ (WebCore::Cairo::computeLineBoundsAndAntialiasingModeForText): >+ * platform/graphics/cairo/PathCairo.cpp: >+ (WebCore::Path::addArcTo): >+ * platform/graphics/cg/GraphicsContextCG.cpp: >+ (WebCore::GraphicsContext::roundToDevicePixels): >+ * platform/graphics/filters/FETurbulence.cpp: >+ (WebCore::FETurbulence::initPaint): >+ * platform/graphics/transforms/AffineTransform.cpp: >+ (WebCore::AffineTransform::xScale const): >+ (WebCore::AffineTransform::yScale const): >+ * platform/graphics/transforms/RotateTransformOperation.cpp: >+ (WebCore::RotateTransformOperation::blend): >+ * platform/graphics/transforms/TransformationMatrix.cpp: >+ (WebCore::v3Length): >+ (WebCore::decompose2): >+ (WebCore::TransformationMatrix::rotate3d): >+ * rendering/style/BasicShapes.cpp: >+ (WebCore::BasicShapeCircle::floatValueForRadiusInBox const): >+ * rendering/svg/SVGRenderingContext.cpp: >+ (WebCore::SVGRenderingContext::calculateScreenFontSizeScalingFactor): >+ * svg/SVGAnimateMotionElement.cpp: >+ (WebCore::SVGAnimateMotionElement::calculateDistance): >+ * svg/SVGLengthContext.cpp: >+ (WebCore::SVGLengthContext::valueForLength): >+ (WebCore::SVGLengthContext::convertValueFromUserUnitsToPercentage const): >+ (WebCore::SVGLengthContext::convertValueFromPercentageToUserUnits const): >+ * svg/SVGTransformDistance.cpp: >+ (WebCore::SVGTransformDistance::distance const): >+ * svg/properties/SVGAnimationAdditiveValueFunctionImpl.h: >+ > 2019-06-03 Andy Estes <aestes@apple.com> > > [Apple Pay] Disable script injection when canMakePayment APIs are called and return true >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index ce82571b79aec000b4b25f3f8468b2f98d3a12b6..6404b19bb93effae898ffa1972307d112b3a57f3 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,15 @@ >+2019-06-04 Zan Dobersek <zdobersek@igalia.com> >+ >+ Use std::hypot() where possible >+ https://bugs.webkit.org/show_bug.cgi?id=198483 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * Platform/classifier/ResourceLoadStatisticsClassifier.cpp: >+ (WebKit::vectorLength): >+ * UIProcess/ios/forms/WKFocusedFormControlView.mm: >+ (-[WKFocusedFormControlView scrollOffsetForCrownInputOffset:]): >+ > 2019-06-03 Chris Dumez <cdumez@apple.com> > > [iOS] Do not prevent app suspension for more than 20 seconds after getting backgrounded >diff --git a/Source/WebCore/css/CSSGradientValue.cpp b/Source/WebCore/css/CSSGradientValue.cpp >index f6bf2495b91e0c3a98104bbc55aac75772aec047..686b3d2f88b1f66e6bb02f842bf23a74d53bc1c1 100644 >--- a/Source/WebCore/css/CSSGradientValue.cpp >+++ b/Source/WebCore/css/CSSGradientValue.cpp >@@ -1180,7 +1180,7 @@ static inline float horizontalEllipseRadius(const FloatSize& p, float aspectRati > // x^2/a^2 + y^2/b^2 = 1 > // a/b = aspectRatio, b = a/aspectRatio > // a = sqrt(x^2 + y^2/(1/r^2)) >- return sqrtf(p.width() * p.width() + (p.height() * p.height()) / (1 / (aspectRatio * aspectRatio))); >+ return std::hypot(p.width(), p.height() * aspectRatio); > } > > // FIXME: share code with the linear version >diff --git a/Source/WebCore/platform/audio/FFTFrame.cpp b/Source/WebCore/platform/audio/FFTFrame.cpp >index 4c02b6992b06383b8035737878dbf65a26fb9c31..6cfcb2c449cc259b393b6955536676eaaa8648a2 100644 >--- a/Source/WebCore/platform/audio/FFTFrame.cpp >+++ b/Source/WebCore/platform/audio/FFTFrame.cpp >@@ -259,7 +259,7 @@ void FFTFrame::print() > int n = m_FFTSize / 2; > > for (int i = 1; i < n; i++) { >- double mag = sqrt(realP[i] * realP[i] + imagP[i] * imagP[i]); >+ double mag = std::hypot(realP[i], imagP[i]); > double phase = atan2(realP[i], imagP[i]); > > LOG(WebAudio, "[%d] (%f %f)\n", i, mag, phase); >diff --git a/Source/WebCore/platform/graphics/FloatPoint.cpp b/Source/WebCore/platform/graphics/FloatPoint.cpp >index 3b661aeede51b35a681197db3f630d6a70b00e78..fbab72ad7416af31170f7f28cae9873ba797017e 100644 >--- a/Source/WebCore/platform/graphics/FloatPoint.cpp >+++ b/Source/WebCore/platform/graphics/FloatPoint.cpp >@@ -64,11 +64,6 @@ float FloatPoint::slopeAngleRadians() const > return atan2f(m_y, m_x); > } > >-float FloatPoint::length() const >-{ >- return sqrtf(lengthSquared()); >-} >- > FloatPoint FloatPoint::matrixTransform(const AffineTransform& transform) const > { > double newX, newY; >diff --git a/Source/WebCore/platform/graphics/FloatPoint.h b/Source/WebCore/platform/graphics/FloatPoint.h >index 720453d9f046d79f48a09b81af7000f4de3be025..d040f971d0733c8d04b5a9a16fecf0bbd7c44145 100644 >--- a/Source/WebCore/platform/graphics/FloatPoint.h >+++ b/Source/WebCore/platform/graphics/FloatPoint.h >@@ -146,7 +146,11 @@ public: > } > > float slopeAngleRadians() const; >- float length() const; >+ >+ float length() const >+ { >+ return std::hypot(m_x, m_y); >+ } > > float lengthSquared() const > { >diff --git a/Source/WebCore/platform/graphics/FloatPoint3D.h b/Source/WebCore/platform/graphics/FloatPoint3D.h >index fde468d8125f51dc2c8f0b57d148b7bfc4af429a..51e6e7ebc6b3084319aaed616b3d970b3e344103 100644 >--- a/Source/WebCore/platform/graphics/FloatPoint3D.h >+++ b/Source/WebCore/platform/graphics/FloatPoint3D.h >@@ -119,7 +119,7 @@ public: > } > > float lengthSquared() const { return this->dot(*this); } >- float length() const { return sqrtf(lengthSquared()); } >+ float length() const { return std::hypot(m_x, m_y, m_z); } > > float distanceTo(const FloatPoint3D& a) const; > >diff --git a/Source/WebCore/platform/graphics/FloatSize.cpp b/Source/WebCore/platform/graphics/FloatSize.cpp >index 6c5741d6316d93c587cca260b59fa7df0e59d008..d54024dba1022e13325b693ef4c27603bdde7cc8 100644 >--- a/Source/WebCore/platform/graphics/FloatSize.cpp >+++ b/Source/WebCore/platform/graphics/FloatSize.cpp >@@ -50,11 +50,6 @@ FloatSize FloatSize::constrainedBetween(const FloatSize& min, const FloatSize& m > }; > } > >-float FloatSize::diagonalLength() const >-{ >- return sqrtf(diagonalLengthSquared()); >-} >- > bool FloatSize::isZero() const > { > return fabs(m_width) < std::numeric_limits<float>::epsilon() && fabs(m_height) < std::numeric_limits<float>::epsilon(); >diff --git a/Source/WebCore/platform/graphics/FloatSize.h b/Source/WebCore/platform/graphics/FloatSize.h >index bc6b253078768382953f324696530e2d4fbdd24b..8bad61b6f1b0997f794470c2b8d3098677312a32 100644 >--- a/Source/WebCore/platform/graphics/FloatSize.h >+++ b/Source/WebCore/platform/graphics/FloatSize.h >@@ -123,7 +123,10 @@ public: > m_height < other.m_height ? m_height : other.m_height); > } > >- WEBCORE_EXPORT float diagonalLength() const; >+ float diagonalLength() const >+ { >+ return std::hypot(m_width, m_height); >+ } > > float diagonalLengthSquared() const > { >diff --git a/Source/WebCore/platform/graphics/GeometryUtilities.cpp b/Source/WebCore/platform/graphics/GeometryUtilities.cpp >index 0099cefa0638500140a0c7ed23e16b68ed441346..bad2e81c117aaa0b604c7c5bcfb338229ca669f0 100644 >--- a/Source/WebCore/platform/graphics/GeometryUtilities.cpp >+++ b/Source/WebCore/platform/graphics/GeometryUtilities.cpp >@@ -32,7 +32,7 @@ namespace WebCore { > float euclidianDistance(const FloatPoint& p1, const FloatPoint& p2) > { > FloatSize delta = p1 - p2; >- return sqrt(delta.width() * delta.width() + delta.height() * delta.height()); >+ return std::hypot(delta.width(), delta.height()); > } > > float findSlope(const FloatPoint& p1, const FloatPoint& p2, float& c) >diff --git a/Source/WebCore/platform/graphics/GraphicsContext.cpp b/Source/WebCore/platform/graphics/GraphicsContext.cpp >index 1332c940fd102763df4d08dd26f8caa241cefad5..16f4e14452406e99abd820875dfd24e0ad15db4a 100644 >--- a/Source/WebCore/platform/graphics/GraphicsContext.cpp >+++ b/Source/WebCore/platform/graphics/GraphicsContext.cpp >@@ -1120,7 +1120,7 @@ FloatRect GraphicsContext::computeLineBoundsAndAntialiasingModeForText(const Flo > > AffineTransform transform = getCTM(GraphicsContext::DefinitelyIncludeDeviceScale); > // Just compute scale in x dimension, assuming x and y scales are equal. >- float scale = transform.b() ? sqrtf(transform.a() * transform.a() + transform.b() * transform.b()) : transform.a(); >+ float scale = transform.b() ? std::hypot(transform.a(), transform.b()) : transform.a(); > if (scale < 1.0) { > // This code always draws a line that is at least one-pixel line high, > // which tends to visually overwhelm text at small scales. To counter this >diff --git a/Source/WebCore/platform/graphics/PathTraversalState.cpp b/Source/WebCore/platform/graphics/PathTraversalState.cpp >index 9c5339a2d30fa5c022fb5704379de045e4816110..6fb9d838209810ce36ee88066150a4fd29841005 100644 >--- a/Source/WebCore/platform/graphics/PathTraversalState.cpp >+++ b/Source/WebCore/platform/graphics/PathTraversalState.cpp >@@ -35,9 +35,7 @@ static inline FloatPoint midPoint(const FloatPoint& first, const FloatPoint& sec > > static inline float distanceLine(const FloatPoint& start, const FloatPoint& end) > { >- float dx = end.x() - start.x(); >- float dy = end.y() - start.y(); >- return sqrtf(dx * dx + dy * dy); >+ return std::hypot(end.x() - start.x(), end.y() - start.y()); > } > > struct QuadraticBezier { >diff --git a/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp b/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp >index fba54565a5a9dcb928521a1421bc732ba09ade34..20bd223f78c569dc14e2c2da4a5c89c253c87dac 100644 >--- a/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp >+++ b/Source/WebCore/platform/graphics/cairo/CairoOperations.cpp >@@ -387,7 +387,7 @@ FloatRect computeLineBoundsAndAntialiasingModeForText(PlatformContextCairo& plat > > AffineTransform transform = Cairo::State::getCTM(platformContext); > // Just compute scale in x dimension, assuming x and y scales are equal. >- float scale = transform.b() ? sqrtf(transform.a() * transform.a() + transform.b() * transform.b()) : transform.a(); >+ float scale = transform.b() ? std::hypot(transform.a(), transform.b()) : transform.a(); > if (scale < 1.0) { > // This code always draws a line that is at least one-pixel line high, > // which tends to visually overwhelm text at small scales. To counter this >diff --git a/Source/WebCore/platform/graphics/cairo/PathCairo.cpp b/Source/WebCore/platform/graphics/cairo/PathCairo.cpp >index dc288b35ffa33a46588b0443ed4a347db2e2c1fa..e077afb9d554e98c3e773775a1911268263b690b 100644 >--- a/Source/WebCore/platform/graphics/cairo/PathCairo.cpp >+++ b/Source/WebCore/platform/graphics/cairo/PathCairo.cpp >@@ -242,8 +242,8 @@ void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius) > > FloatPoint p1p0((p0.x() - p1.x()),(p0.y() - p1.y())); > FloatPoint p1p2((p2.x() - p1.x()),(p2.y() - p1.y())); >- float p1p0_length = sqrtf(p1p0.x() * p1p0.x() + p1p0.y() * p1p0.y()); >- float p1p2_length = sqrtf(p1p2.x() * p1p2.x() + p1p2.y() * p1p2.y()); >+ float p1p0_length = std::hypot(p1p0.x(), p1p0.y()); >+ float p1p2_length = std::hypot(p1p2.x(), p1p2.y()); > > double cos_phi = (p1p0.x() * p1p2.x() + p1p0.y() * p1p2.y()) / (p1p0_length * p1p2_length); > // all points on a line logic >@@ -265,7 +265,7 @@ void Path::addArcTo(const FloatPoint& p1, const FloatPoint& p2, float radius) > FloatPoint t_p1p0((p1.x() + factor_p1p0 * p1p0.x()), (p1.y() + factor_p1p0 * p1p0.y())); > > FloatPoint orth_p1p0(p1p0.y(), -p1p0.x()); >- float orth_p1p0_length = sqrt(orth_p1p0.x() * orth_p1p0.x() + orth_p1p0.y() * orth_p1p0.y()); >+ float orth_p1p0_length = std::hypot(orth_p1p0.x(), orth_p1p0.y()); > float factor_ra = radius / orth_p1p0_length; > > // angle between orth_p1p0 and p1p2 to get the right vector orthographic to p1p0 >diff --git a/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp b/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp >index 8adf8014df59621fa049a84772ad4b8425f67881..1bf29b791a9f530046e3a3e53bd29e484d6d32a9 100644 >--- a/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp >+++ b/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp >@@ -1538,8 +1538,8 @@ FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect, RoundingMo > return roundedIntRect(rect); > } > >- float deviceScaleX = sqrtf(deviceMatrix.a * deviceMatrix.a + deviceMatrix.b * deviceMatrix.b); >- float deviceScaleY = sqrtf(deviceMatrix.c * deviceMatrix.c + deviceMatrix.d * deviceMatrix.d); >+ float deviceScaleX = std::hypot(deviceMatrix.a, deviceMatrix.b); >+ float deviceScaleY = std::hypot(deviceMatrix.c, deviceMatrix.d); > > CGPoint deviceOrigin = CGPointMake(rect.x() * deviceScaleX, rect.y() * deviceScaleY); > CGPoint deviceLowerRight = CGPointMake((rect.x() + rect.width()) * deviceScaleX, >diff --git a/Source/WebCore/platform/graphics/filters/FETurbulence.cpp b/Source/WebCore/platform/graphics/filters/FETurbulence.cpp >index 8227879f5786de63505436f1b48017c0add28ef6..6d60cddebb102f52dc3c21aecc2a50db4bf7834b 100644 >--- a/Source/WebCore/platform/graphics/filters/FETurbulence.cpp >+++ b/Source/WebCore/platform/graphics/filters/FETurbulence.cpp >@@ -154,7 +154,7 @@ void FETurbulence::initPaint(PaintingData& paintingData) > gradient[0] = static_cast<float>((paintingData.random() % (2 * s_blockSize)) - s_blockSize) / s_blockSize; > gradient[1] = static_cast<float>((paintingData.random() % (2 * s_blockSize)) - s_blockSize) / s_blockSize; > } while (!gradient[0] && !gradient[1]); >- normalizationFactor = sqrtf(gradient[0] * gradient[0] + gradient[1] * gradient[1]); >+ normalizationFactor = std::hypot(gradient[0], gradient[1]); > gradient[0] /= normalizationFactor; > gradient[1] /= normalizationFactor; > } >diff --git a/Source/WebCore/platform/graphics/transforms/AffineTransform.cpp b/Source/WebCore/platform/graphics/transforms/AffineTransform.cpp >index 34398a3863f9e8c84c9f0f368865372f54c2fc70..3c2cc2afc9ab87f4127bbe32baf6410009aad8a3 100644 >--- a/Source/WebCore/platform/graphics/transforms/AffineTransform.cpp >+++ b/Source/WebCore/platform/graphics/transforms/AffineTransform.cpp >@@ -85,12 +85,12 @@ bool AffineTransform::isIdentity() const > > double AffineTransform::xScale() const > { >- return sqrt(m_transform[0] * m_transform[0] + m_transform[1] * m_transform[1]); >+ return std::hypot(m_transform[0], m_transform[1]); > } > > double AffineTransform::yScale() const > { >- return sqrt(m_transform[2] * m_transform[2] + m_transform[3] * m_transform[3]); >+ return std::hypot(m_transform[2], m_transform[3]); > } > > static double det(const std::array<double, 6>& transform) >diff --git a/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.cpp b/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.cpp >index 7316d33da32e6e3e9070ff430b995c68ae601e94..962e7c104508801080b0b05d70a116abc87ef6d2 100644 >--- a/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.cpp >+++ b/Source/WebCore/platform/graphics/transforms/RotateTransformOperation.cpp >@@ -84,7 +84,7 @@ Ref<TransformOperation> RotateTransformOperation::blend(const TransformOperation > double x = -decomp.quaternionX; > double y = -decomp.quaternionY; > double z = -decomp.quaternionZ; >- double length = sqrt(x * x + y * y + z * z); >+ double length = std::hypot(x, y, z); > double angle = 0; > > if (length > 0.00001) { >diff --git a/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp b/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp >index 394109de2dba62d84515e8e70d9068228aa1dad8..ee30a21bec5ad347a71079e3aee0ec497b583887 100644 >--- a/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp >+++ b/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp >@@ -254,7 +254,7 @@ static void v4MulPointByMatrix(const Vector4 p, const TransformationMatrix::Matr > > static double v3Length(Vector3 a) > { >- return sqrt((a[0] * a[0]) + (a[1] * a[1]) + (a[2] * a[2])); >+ return std::hypot(a[0], a[1], a[2]); > } > > static void v3Scale(Vector3 v, double desiredLength) >@@ -300,8 +300,8 @@ static bool decompose2(const TransformationMatrix::Matrix4& matrix, Transformati > result.translateY = matrix[3][1]; > > // Compute scaling factors. >- result.scaleX = sqrt(row0x * row0x + row0y * row0y); >- result.scaleY = sqrt(row1x * row1x + row1y * row1y); >+ result.scaleX = std::hypot(row0x, row0y); >+ result.scaleY = std::hypot(row1x, row1y); > > // If determinant is negative, one axis was flipped. > double determinant = row0x * row1y - row0y * row1x; >@@ -813,7 +813,7 @@ TransformationMatrix& TransformationMatrix::scale3d(double sx, double sy, double > TransformationMatrix& TransformationMatrix::rotate3d(double x, double y, double z, double angle) > { > // Normalize the axis of rotation >- double length = sqrt(x * x + y * y + z * z); >+ double length = std::hypot(x, y, z); > if (length == 0) { > // A direction vector that cannot be normalized, such as [0, 0, 0], will cause the rotation to not be applied. > return *this; >diff --git a/Source/WebCore/rendering/style/BasicShapes.cpp b/Source/WebCore/rendering/style/BasicShapes.cpp >index 0c98f9166f7e1529703bcdb2c8c83cc80bb7bf24..42707b8340a8dd39bbc56522ea9f8978ece03441 100644 >--- a/Source/WebCore/rendering/style/BasicShapes.cpp >+++ b/Source/WebCore/rendering/style/BasicShapes.cpp >@@ -28,7 +28,6 @@ > */ > > #include "config.h" >- > #include "BasicShapes.h" > > #include "BasicShapeFunctions.h" >@@ -40,7 +39,7 @@ > #include "RenderBox.h" > #include "SVGPathByteStream.h" > #include "SVGPathUtilities.h" >- >+#include <cmath> > #include <wtf/NeverDestroyed.h> > #include <wtf/TinyLRUCache.h> > >@@ -158,7 +157,7 @@ bool BasicShapeCircle::operator==(const BasicShape& other) const > float BasicShapeCircle::floatValueForRadiusInBox(float boxWidth, float boxHeight) const > { > if (m_radius.type() == BasicShapeRadius::Value) >- return floatValueForLength(m_radius.value(), sqrtf((boxWidth * boxWidth + boxHeight * boxHeight) / 2)); >+ return floatValueForLength(m_radius.value(), std::hypot(boxWidth, boxHeight) / M_SQRT2); > > float centerX = floatValueForCenterCoordinate(m_centerX, boxWidth); > float centerY = floatValueForCenterCoordinate(m_centerY, boxHeight); >diff --git a/Source/WebCore/rendering/svg/SVGRenderingContext.cpp b/Source/WebCore/rendering/svg/SVGRenderingContext.cpp >index aa92d634ecef80e9068a81157837028e6c61f3ed..8dc0b4275a3f620eec5599055e65cff68d42b257 100644 >--- a/Source/WebCore/rendering/svg/SVGRenderingContext.cpp >+++ b/Source/WebCore/rendering/svg/SVGRenderingContext.cpp >@@ -201,7 +201,7 @@ static AffineTransform& currentContentTransformation() > float SVGRenderingContext::calculateScreenFontSizeScalingFactor(const RenderObject& renderer) > { > AffineTransform ctm = calculateTransformationToOutermostCoordinateSystem(renderer); >- return narrowPrecisionToFloat(sqrt((pow(ctm.xScale(), 2) + pow(ctm.yScale(), 2)) / 2)); >+ return narrowPrecisionToFloat(std::hypot(ctm.xScale(), ctm.yScale()) / M_SQRT2); > } > > AffineTransform SVGRenderingContext::calculateTransformationToOutermostCoordinateSystem(const RenderObject& renderer) >diff --git a/Source/WebCore/svg/SVGAnimateMotionElement.cpp b/Source/WebCore/svg/SVGAnimateMotionElement.cpp >index 8ec41b7804b653cba9903b1dd324ae92b50631ef..d0030ca839e0d0508b50a26033487481be669054 100644 >--- a/Source/WebCore/svg/SVGAnimateMotionElement.cpp >+++ b/Source/WebCore/svg/SVGAnimateMotionElement.cpp >@@ -282,7 +282,7 @@ Optional<float> SVGAnimateMotionElement::calculateDistance(const String& fromStr > if (!parsePoint(toString, to)) > return { }; > FloatSize diff = to - from; >- return sqrtf(diff.width() * diff.width() + diff.height() * diff.height()); >+ return std::hypot(diff.width(), diff.height()); > } > > void SVGAnimateMotionElement::updateAnimationMode() >diff --git a/Source/WebCore/svg/SVGLengthContext.cpp b/Source/WebCore/svg/SVGLengthContext.cpp >index 08000176bac0fb90fea350ffd62e56ec4bbc129e..aa3ff51923958cd237319f031ea11c734c3f73d1 100644 >--- a/Source/WebCore/svg/SVGLengthContext.cpp >+++ b/Source/WebCore/svg/SVGLengthContext.cpp >@@ -105,7 +105,7 @@ float SVGLengthContext::valueForLength(const Length& length, SVGLengthMode mode) > case LengthModeHeight: > return floatValueForLength(length, viewportSize.height()); > case LengthModeOther: >- return floatValueForLength(length, std::sqrt(viewportSize.diagonalLengthSquared() / 2)); >+ return floatValueForLength(length, viewportSize.diagonalLength() / M_SQRT2); > }; > return 0; > } >@@ -192,7 +192,7 @@ ExceptionOr<float> SVGLengthContext::convertValueFromUserUnitsToPercentage(float > case LengthModeHeight: > return value / viewportSize.height() * 100; > case LengthModeOther: >- return value / (std::sqrt(viewportSize.diagonalLengthSquared() / 2)) * 100; >+ return value / (viewportSize.diagonalLength() / M_SQRT2) * 100; > }; > > ASSERT_NOT_REACHED(); >@@ -211,7 +211,7 @@ ExceptionOr<float> SVGLengthContext::convertValueFromPercentageToUserUnits(float > case LengthModeHeight: > return value * viewportSize.height(); > case LengthModeOther: >- return value * std::sqrt(viewportSize.diagonalLengthSquared() / 2); >+ return value * viewportSize.diagonalLength() / M_SQRT2; > }; > > ASSERT_NOT_REACHED(); >diff --git a/Source/WebCore/svg/SVGTransformDistance.cpp b/Source/WebCore/svg/SVGTransformDistance.cpp >index 3847d53c72ab199154d406dbc3b468c442df488a..15d1160518019c3c014521bfcc7c7e1a851cac9f 100644 >--- a/Source/WebCore/svg/SVGTransformDistance.cpp >+++ b/Source/WebCore/svg/SVGTransformDistance.cpp >@@ -217,11 +217,11 @@ float SVGTransformDistance::distance() const > case SVGTransformValue::SVG_TRANSFORM_UNKNOWN: > return 0; > case SVGTransformValue::SVG_TRANSFORM_ROTATE: >- return sqrtf(m_angle * m_angle + m_cx * m_cx + m_cy * m_cy); >+ return std::hypot(m_angle, m_cx, m_cy); > case SVGTransformValue::SVG_TRANSFORM_SCALE: >- return static_cast<float>(sqrt(m_transform.a() * m_transform.a() + m_transform.d() * m_transform.d())); >+ return static_cast<float>(std::hypot(m_transform.a(), m_transform.d())); > case SVGTransformValue::SVG_TRANSFORM_TRANSLATE: >- return static_cast<float>(sqrt(m_transform.e() * m_transform.e() + m_transform.f() * m_transform.f())); >+ return static_cast<float>(std::hypot(m_transform.e(), m_transform.f())); > case SVGTransformValue::SVG_TRANSFORM_SKEWX: > case SVGTransformValue::SVG_TRANSFORM_SKEWY: > return m_angle; >diff --git a/Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunctionImpl.h b/Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunctionImpl.h >index 28c512a09a749db25bd73dacbbad6d489db7a352..a687c2e1e6cb3ae47c7e62ab521ce4d2fa1b0b0a 100644 >--- a/Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunctionImpl.h >+++ b/Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunctionImpl.h >@@ -101,7 +101,7 @@ public: > float red = fromColor.red() - toColor.red(); > float green = fromColor.green() - toColor.green(); > float blue = fromColor.blue() - toColor.blue(); >- return sqrtf(red * red + green * green + blue * blue); >+ return std::hypot(red, green, blue); > } > > private: >diff --git a/Source/WebKit/Platform/classifier/ResourceLoadStatisticsClassifier.cpp b/Source/WebKit/Platform/classifier/ResourceLoadStatisticsClassifier.cpp >index b4492a4d249fc97dca8aa3d323d35279baf6d7df..dd38cf5a3c33043f088a5b518747b0fd00d91f58 100644 >--- a/Source/WebKit/Platform/classifier/ResourceLoadStatisticsClassifier.cpp >+++ b/Source/WebKit/Platform/classifier/ResourceLoadStatisticsClassifier.cpp >@@ -34,7 +34,7 @@ using namespace WebCore; > > static double vectorLength(unsigned a, unsigned b, unsigned c) > { >- return sqrt(a * a + b * b + c * c); >+ return std::hypot(a, b, c); > } > > static const auto featureVectorLengthThresholdHigh = 3; >diff --git a/Source/WebKit/UIProcess/ios/forms/WKFocusedFormControlView.mm b/Source/WebKit/UIProcess/ios/forms/WKFocusedFormControlView.mm >index d72adab423e58c20062a18c1bef2a6e8e3b3f718..fe742e4c9fef2ea7aad8f69ecd37b76f44a225e2 100644 >--- a/Source/WebKit/UIProcess/ios/forms/WKFocusedFormControlView.mm >+++ b/Source/WebKit/UIProcess/ios/forms/WKFocusedFormControlView.mm >@@ -396,7 +396,7 @@ static NSDictionary *submitActionNameFontAttributes() > } > > if (targetHighlightedFrameDeltaX || targetHighlightedFrameDeltaY) { >- CGFloat distanceToTarget = std::sqrt(targetHighlightedFrameDeltaX * targetHighlightedFrameDeltaX + targetHighlightedFrameDeltaY * targetHighlightedFrameDeltaY); >+ CGFloat distanceToTarget = std::hypot(targetHighlightedFrameDeltaX, targetHighlightedFrameDeltaY) > unitVectorToTarget = CGVector { targetHighlightedFrameDeltaX / distanceToTarget, targetHighlightedFrameDeltaY / distanceToTarget }; > } > >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 5e5022f5378c9a17955026a5e51ddb7bb680a441..b73d66e34c006181997f72f36ffd1a518324731c 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,13 @@ >+2019-06-04 Zan Dobersek <zdobersek@igalia.com> >+ >+ Use std::hypot() where possible >+ https://bugs.webkit.org/show_bug.cgi?id=198483 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestWebKitAPI/mac/DragAndDropSimulatorMac.mm: >+ (-[DragAndDropSimulator initialProgressForMouseDrag]): >+ > 2019-06-03 Andy Estes <aestes@apple.com> > > [Apple Pay] Disable script injection when canMakePayment APIs are called and return true >diff --git a/Tools/TestWebKitAPI/mac/DragAndDropSimulatorMac.mm b/Tools/TestWebKitAPI/mac/DragAndDropSimulatorMac.mm >index 1005ee478b57dffec87f453d4224494413a93f4d..9315a8b1457378e87e69f1a575d2ac8da6a7da47 100644 >--- a/Tools/TestWebKitAPI/mac/DragAndDropSimulatorMac.mm >+++ b/Tools/TestWebKitAPI/mac/DragAndDropSimulatorMac.mm >@@ -150,7 +150,7 @@ static NSImage *defaultExternalDragImage() > > - (double)initialProgressForMouseDrag > { >- double totalDistance = std::sqrt(std::pow(_startLocationInWindow.x - _endLocationInWindow.x, 2) + std::pow(_startLocationInWindow.y - _endLocationInWindow.y, 2)); >+ double totalDistance = std::hypot(_startLocationInWindow.x - _endLocationInWindow.x, _startLocationInWindow.y - _endLocationInWindow.y); > return !totalDistance ? 1 : std::min<double>(1, initialMouseDragDistance / totalDistance); > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198483
:
371188
|
371253
|
371261
|
371274
|
372226
|
379364
|
379442
|
380193
|
389496