Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(725)

Unified Diff: third_party/WebKit/Source/platform/transforms/TransformationMatrix.cpp

Issue 1530723004: Use clampTo instead of chaining std::max(std::min(...)) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Handling that minimumThumbLength > trackLen. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/transforms/TransformationMatrix.cpp
diff --git a/third_party/WebKit/Source/platform/transforms/TransformationMatrix.cpp b/third_party/WebKit/Source/platform/transforms/TransformationMatrix.cpp
index 1cb3bca95d544fd2822e1f629b1884da0badcefd..a491e924d9baa25ce3379b7b593801054fdc9987 100644
--- a/third_party/WebKit/Source/platform/transforms/TransformationMatrix.cpp
+++ b/third_party/WebKit/Source/platform/transforms/TransformationMatrix.cpp
@@ -38,6 +38,9 @@
#include "wtf/Assertions.h"
#include "wtf/MathExtras.h"
+#include <cmath>
+#include <cstdlib>
+
#if CPU(X86_64)
#include <emmintrin.h>
#endif
@@ -597,8 +600,7 @@ static void slerp(double qa[4], const double qb[4], double t)
product = ax * bx + ay * by + az * bz + aw * bw;
- // Clamp product to -1.0 <= product <= 1.0.
- product = std::min(std::max(product, -1.0), 1.0);
+ product = clampTo(product, -1.0, 1.0);
const double epsilon = 1e-5;
if (std::abs(product - 1.0) < epsilon) {
@@ -711,7 +713,7 @@ FloatQuad TransformationMatrix::projectQuad(const FloatQuad& q, bool* clamped) c
static float clampEdgeValue(float f)
{
ASSERT(!std::isnan(f));
- return std::min<float>(std::max<float>(f, (-LayoutUnit::max() / 2).toFloat()), (LayoutUnit::max() / 2).toFloat());
+ return clampTo(f, (-LayoutUnit::max() / 2).toFloat(), (LayoutUnit::max() / 2).toFloat());
}
LayoutRect TransformationMatrix::clampedBoundsOfProjectedQuad(const FloatQuad& q) const

Powered by Google App Engine
This is Rietveld 408576698