OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <cmath> | 5 #include <cmath> |
6 | 6 |
7 #include "content/public/common/page_zoom.h" | 7 #include "content/public/common/page_zoom.h" |
8 | 8 |
9 namespace content { | 9 namespace content { |
10 | 10 |
11 const double kMinimumZoomFactor = 0.25; | 11 const double kMinimumZoomFactor = 0.25; |
12 const double kMaximumZoomFactor = 5.0; | 12 const double kMaximumZoomFactor = 5.0; |
| 13 const double kEpsilon = 0.001; |
13 | 14 |
14 bool ZoomValuesEqual(double value_a, double value_b) { | 15 bool ZoomValuesEqual(double value_a, double value_b) { |
15 // Epsilon value for comparing two floating-point zoom values. We don't use | 16 return (std::fabs(value_a - value_b) <= kEpsilon); |
16 // std::numeric_limits<> because it is too precise for zoom values. Zoom | |
17 // values lose precision due to factor/level conversions. A value of 0.001 | |
18 // is precise enough for zoom value comparisons. | |
19 const double epsilon = 0.001; | |
20 | |
21 return (std::fabs(value_a - value_b) <= epsilon); | |
22 } | 17 } |
23 | 18 |
24 } // namespace content | 19 } // namespace content |
25 | |
OLD | NEW |