summaryrefslogtreecommitdiffstats
path: root/cc/animation
diff options
context:
space:
mode:
authorshawnsingh@google.com <shawnsingh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-29 21:42:03 +0000
committershawnsingh@google.com <shawnsingh@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-29 21:42:03 +0000
commit81d20544b54bdc302d06315428b6be7311d7d784 (patch)
treed76bbc26e0b698f0f4ea0eaaab30286152a173fb /cc/animation
parentee38bc4084d0812df5fa0d9a615f8a8193e04ab2 (diff)
downloadchromium_src-81d20544b54bdc302d06315428b6be7311d7d784.zip
chromium_src-81d20544b54bdc302d06315428b6be7311d7d784.tar.gz
chromium_src-81d20544b54bdc302d06315428b6be7311d7d784.tar.bz2
Add PRESUBMIT check to cc to ensure that C++ std::abs is used
This is try #2, previous patch r214144 was reverted in r214149. Before this patch, it is possible to use abs() without the std:: namespace qualifier, which may link to the C standard library implementation of abs(). Thus, someone using abs(float) may get wrong results because C standard version will convert the float to an int. This patch updates the occurrences of of abs() and fabs() in cc/ (though technically none were incorrect, thankfully) and adds a PRESUBMIT to enforce that all uses of abs from now on have an explicit std:: to resolve them correctly. BUG=261900 R=enne@chromium.org Review URL: https://codereview.chromium.org/21061004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214225 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/animation')
-rw-r--r--cc/animation/timing_function.cc5
-rw-r--r--cc/animation/transform_operation.cc2
2 files changed, 4 insertions, 3 deletions
diff --git a/cc/animation/timing_function.cc b/cc/animation/timing_function.cc
index f5a4f9f..65d607f 100644
--- a/cc/animation/timing_function.cc
+++ b/cc/animation/timing_function.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <algorithm>
+#include <cmath>
#include "base/logging.h"
#include "cc/animation/timing_function.h"
@@ -47,14 +48,14 @@ static double bezier_interp(double x1,
double step = 1.0;
for (int i = 0; i < MAX_STEPS; ++i, step *= 0.5) {
const double error = eval_bezier(x1, x2, t) - x;
- if (fabs(error) < BEZIER_EPSILON)
+ if (std::abs(error) < BEZIER_EPSILON)
break;
t += error > 0.0 ? -step : step;
}
// We should have terminated the above loop because we got close to x, not
// because we exceeded MAX_STEPS. Do a DCHECK here to confirm.
- DCHECK_GT(BEZIER_EPSILON, fabs(eval_bezier(x1, x2, t) - x));
+ DCHECK_GT(BEZIER_EPSILON, std::abs(eval_bezier(x1, x2, t) - x));
// Step 2. Return the interpolated y values at the t we computed above.
return eval_bezier(y1, y2, t);
diff --git a/cc/animation/transform_operation.cc b/cc/animation/transform_operation.cc
index 854901d..dacea06 100644
--- a/cc/animation/transform_operation.cc
+++ b/cc/animation/transform_operation.cc
@@ -60,7 +60,7 @@ static bool ShareSameAxis(const TransformOperation* from,
double dot = to->rotate.axis.x * from->rotate.axis.x +
to->rotate.axis.y * from->rotate.axis.y +
to->rotate.axis.z * from->rotate.axis.z;
- double error = std::fabs(1.0 - (dot * dot) / (length_2 * other_length_2));
+ double error = std::abs(1.0 - (dot * dot) / (length_2 * other_length_2));
bool result = error < kAngleEpsilon;
if (result) {
*axis_x = to->rotate.axis.x;