OLD | NEW |
1 /* | 1 /* |
2 * CSS Media Query Evaluator | 2 * CSS Media Query Evaluator |
3 * | 3 * |
4 * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>. | 4 * Copyright (C) 2006 Kimmo Kinnunen <kimmo.t.kinnunen@nokia.com>. |
5 * Copyright (C) 2013 Apple Inc. All rights reserved. | 5 * Copyright (C) 2013 Apple Inc. All rights reserved. |
6 * Copyright (C) 2013 Intel Corporation. All rights reserved. | 6 * Copyright (C) 2013 Intel Corporation. All rights reserved. |
7 * | 7 * |
8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
10 * are met: | 10 * are met: |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 case kNoPrefix: | 186 case kNoPrefix: |
187 return std::abs(a - b) <= precision; | 187 return std::abs(a - b) <= precision; |
188 } | 188 } |
189 return false; | 189 return false; |
190 } | 190 } |
191 | 191 |
192 static bool CompareAspectRatioValue(const MediaQueryExpValue& value, | 192 static bool CompareAspectRatioValue(const MediaQueryExpValue& value, |
193 int width, | 193 int width, |
194 int height, | 194 int height, |
195 MediaFeaturePrefix op) { | 195 MediaFeaturePrefix op) { |
196 if (value.is_ratio) | 196 if (value.is_ratio) { |
197 return CompareValue(width * static_cast<int>(value.denominator), | 197 return CompareValue(static_cast<double>(width) * value.denominator, |
198 height * static_cast<int>(value.numerator), op); | 198 static_cast<double>(height) * value.numerator, op); |
199 | 199 } |
200 return false; | 200 return false; |
201 } | 201 } |
202 | 202 |
203 static bool NumberValue(const MediaQueryExpValue& value, float& result) { | 203 static bool NumberValue(const MediaQueryExpValue& value, float& result) { |
204 if (value.is_value && value.unit == CSSPrimitiveValue::UnitType::kNumber) { | 204 if (value.is_value && value.unit == CSSPrimitiveValue::UnitType::kNumber) { |
205 result = value.value; | 205 result = value.value; |
206 return true; | 206 return true; |
207 } | 207 } |
208 return false; | 208 return false; |
209 } | 209 } |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 // Call the media feature evaluation function. Assume no prefix and let | 818 // Call the media feature evaluation function. Assume no prefix and let |
819 // trampoline functions override the prefix if prefix is used. | 819 // trampoline functions override the prefix if prefix is used. |
820 EvalFunc func = g_function_map->at(expr->MediaFeature().Impl()); | 820 EvalFunc func = g_function_map->at(expr->MediaFeature().Impl()); |
821 if (func) | 821 if (func) |
822 return func(expr->ExpValue(), kNoPrefix, *media_values_); | 822 return func(expr->ExpValue(), kNoPrefix, *media_values_); |
823 | 823 |
824 return false; | 824 return false; |
825 } | 825 } |
826 | 826 |
827 } // namespace blink | 827 } // namespace blink |
OLD | NEW |