Chromium Code Reviews| Index: third_party/WebKit/Source/core/css/MediaQueryEvaluator.cpp |
| diff --git a/third_party/WebKit/Source/core/css/MediaQueryEvaluator.cpp b/third_party/WebKit/Source/core/css/MediaQueryEvaluator.cpp |
| index 92f06db9a7cd19e5f68faa2f22a832b5fd6ecfd7..02bbd5f9ae29ae40b45776932f98fc8f329a3c8b 100644 |
| --- a/third_party/WebKit/Source/core/css/MediaQueryEvaluator.cpp |
| +++ b/third_party/WebKit/Source/core/css/MediaQueryEvaluator.cpp |
| @@ -173,6 +173,20 @@ bool compareValue(T a, T b, MediaFeaturePrefix op) |
| return false; |
| } |
| +bool compareDoubleValue(double a, double b, MediaFeaturePrefix op) |
| +{ |
| + const double precision = 0.000001; |
|
rune
2016/04/20 07:04:46
We use std::numeric_limits<T>::epsilon() other pla
Yoav Weiss
2016/04/20 07:26:57
yup
|
| + switch (op) { |
| + case MinPrefix: |
| + return a >= (b - precision); |
| + case MaxPrefix: |
| + return a <= (b + precision); |
| + case NoPrefix: |
| + return abs(a - b) <= precision; |
| + } |
| + return false; |
| +} |
| + |
| static bool compareAspectRatioValue(const MediaQueryExpValue& value, int width, int height, MediaFeaturePrefix op) |
| { |
| if (value.isRatio) |
| @@ -374,7 +388,7 @@ static bool computeLength(const MediaQueryExpValue& value, const MediaValues& me |
| static bool computeLengthAndCompare(const MediaQueryExpValue& value, MediaFeaturePrefix op, const MediaValues& mediaValues, double compareToValue) |
| { |
| double length; |
| - return computeLength(value, mediaValues, length) && compareValue(compareToValue, length, op); |
| + return computeLength(value, mediaValues, length) && compareDoubleValue(compareToValue, length, op); |
| } |
| static bool deviceHeightMediaFeatureEval(const MediaQueryExpValue& value, MediaFeaturePrefix op, const MediaValues& mediaValues) |