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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
228 // Acording to spec, if the device does not use a color lookup table, the | 228 // Acording to spec, if the device does not use a color lookup table, the |
229 // value is zero. | 229 // value is zero. |
230 float number; | 230 float number; |
231 return NumberValue(value, number) && | 231 return NumberValue(value, number) && |
232 CompareValue(0, static_cast<int>(number), op); | 232 CompareValue(0, static_cast<int>(number), op); |
233 } | 233 } |
234 | 234 |
235 static bool MonochromeMediaFeatureEval(const MediaQueryExpValue& value, | 235 static bool MonochromeMediaFeatureEval(const MediaQueryExpValue& value, |
236 MediaFeaturePrefix op, | 236 MediaFeaturePrefix op, |
237 const MediaValues& media_values) { | 237 const MediaValues& media_values) { |
238 if (!media_values.MonochromeBitsPerComponent()) { | 238 float number; |
rune
2017/05/04 20:52:37
Nit: I think I'd put this declaration inside the i
| |
239 if (value.IsValid()) { | 239 int bits_per_component = media_values.MonochromeBitsPerComponent(); |
240 float number; | 240 if (value.IsValid()) { |
241 return NumberValue(value, number) && | 241 return NumberValue(value, number) && |
242 CompareValue(0, static_cast<int>(number), op); | 242 CompareValue(bits_per_component, static_cast<int>(number), op); |
243 } | |
244 return false; | |
245 } | 243 } |
246 | 244 return bits_per_component != 0; |
247 return ColorMediaFeatureEval(value, op, media_values); | |
248 } | 245 } |
249 | 246 |
250 static bool DisplayModeMediaFeatureEval(const MediaQueryExpValue& value, | 247 static bool DisplayModeMediaFeatureEval(const MediaQueryExpValue& value, |
251 MediaFeaturePrefix, | 248 MediaFeaturePrefix, |
252 const MediaValues& media_values) { | 249 const MediaValues& media_values) { |
253 // isValid() is false if there is no parameter. Without parameter we should | 250 // isValid() is false if there is no parameter. Without parameter we should |
254 // return true to indicate that displayModeMediaFeature is enabled in the | 251 // return true to indicate that displayModeMediaFeature is enabled in the |
255 // browser. | 252 // browser. |
256 if (!value.IsValid()) | 253 if (!value.IsValid()) |
257 return true; | 254 return true; |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
814 // Call the media feature evaluation function. Assume no prefix and let | 811 // Call the media feature evaluation function. Assume no prefix and let |
815 // trampoline functions override the prefix if prefix is used. | 812 // trampoline functions override the prefix if prefix is used. |
816 EvalFunc func = g_function_map->at(expr.MediaFeature().Impl()); | 813 EvalFunc func = g_function_map->at(expr.MediaFeature().Impl()); |
817 if (func) | 814 if (func) |
818 return func(expr.ExpValue(), kNoPrefix, *media_values_); | 815 return func(expr.ExpValue(), kNoPrefix, *media_values_); |
819 | 816 |
820 return false; | 817 return false; |
821 } | 818 } |
822 | 819 |
823 } // namespace blink | 820 } // namespace blink |
OLD | NEW |