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 19 matching lines...) Expand all Loading... |
30 #include "config.h" | 30 #include "config.h" |
31 #include "core/css/MediaQueryEvaluator.h" | 31 #include "core/css/MediaQueryEvaluator.h" |
32 | 32 |
33 #include "core/CSSValueKeywords.h" | 33 #include "core/CSSValueKeywords.h" |
34 #include "core/MediaFeatureNames.h" | 34 #include "core/MediaFeatureNames.h" |
35 #include "core/MediaFeatures.h" | 35 #include "core/MediaFeatures.h" |
36 #include "core/MediaTypeNames.h" | 36 #include "core/MediaTypeNames.h" |
37 #include "core/css/CSSHelper.h" | 37 #include "core/css/CSSHelper.h" |
38 #include "core/css/CSSPrimitiveValue.h" | 38 #include "core/css/CSSPrimitiveValue.h" |
39 #include "core/css/CSSToLengthConversionData.h" | 39 #include "core/css/CSSToLengthConversionData.h" |
| 40 #include "core/css/DisplayModeProperties.h" |
40 #include "core/css/MediaList.h" | 41 #include "core/css/MediaList.h" |
41 #include "core/css/MediaQuery.h" | 42 #include "core/css/MediaQuery.h" |
42 #include "core/css/MediaValuesDynamic.h" | 43 #include "core/css/MediaValuesDynamic.h" |
43 #include "core/css/PointerProperties.h" | 44 #include "core/css/PointerProperties.h" |
44 #include "core/css/resolver/MediaQueryResult.h" | 45 #include "core/css/resolver/MediaQueryResult.h" |
45 #include "core/dom/NodeRenderStyle.h" | 46 #include "core/dom/NodeRenderStyle.h" |
46 #include "core/frame/FrameHost.h" | 47 #include "core/frame/FrameHost.h" |
47 #include "core/frame/FrameView.h" | 48 #include "core/frame/FrameView.h" |
48 #include "core/frame/LocalFrame.h" | 49 #include "core/frame/LocalFrame.h" |
49 #include "core/frame/Settings.h" | 50 #include "core/frame/Settings.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 if (value.isValid()) { | 214 if (value.isValid()) { |
214 float number; | 215 float number; |
215 return numberValue(value, number) && compareValue(0, static_cast<int
>(number), op); | 216 return numberValue(value, number) && compareValue(0, static_cast<int
>(number), op); |
216 } | 217 } |
217 return false; | 218 return false; |
218 } | 219 } |
219 | 220 |
220 return colorMediaFeatureEval(value, op, mediaValues); | 221 return colorMediaFeatureEval(value, op, mediaValues); |
221 } | 222 } |
222 | 223 |
| 224 static bool displayModeMediaFeatureEval(const MediaQueryExpValue& value, MediaFe
aturePrefix, const MediaValues& mediaValues) |
| 225 { |
| 226 if (!value.isID) |
| 227 return false; |
| 228 |
| 229 DisplayMode mode = mediaValues.displayMode(); |
| 230 switch (value.id) { |
| 231 case CSSValueFullscreen: |
| 232 return mode == DisplayModeFullscreen; |
| 233 case CSSValueStandalone: |
| 234 return mode == DisplayModeStandalone; |
| 235 case CSSValueMinimalUi: |
| 236 return mode == DisplayModeMinimalUi; |
| 237 case CSSValueBrowser: |
| 238 return mode == DisplayModeBrowser; |
| 239 default: |
| 240 ASSERT_NOT_REACHED(); |
| 241 return false; |
| 242 } |
| 243 } |
| 244 |
223 static bool orientationMediaFeatureEval(const MediaQueryExpValue& value, MediaFe
aturePrefix, const MediaValues& mediaValues) | 245 static bool orientationMediaFeatureEval(const MediaQueryExpValue& value, MediaFe
aturePrefix, const MediaValues& mediaValues) |
224 { | 246 { |
225 int width = mediaValues.viewportWidth(); | 247 int width = mediaValues.viewportWidth(); |
226 int height = mediaValues.viewportHeight(); | 248 int height = mediaValues.viewportHeight(); |
227 | 249 |
228 if (value.isID) { | 250 if (value.isID) { |
229 if (width > height) // Square viewport is portrait. | 251 if (width > height) // Square viewport is portrait. |
230 return CSSValueLandscape == value.id; | 252 return CSSValueLandscape == value.id; |
231 return CSSValuePortrait == value.id; | 253 return CSSValuePortrait == value.id; |
232 } | 254 } |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 // Call the media feature evaluation function. Assume no prefix and let | 662 // Call the media feature evaluation function. Assume no prefix and let |
641 // trampoline functions override the prefix if prefix is used. | 663 // trampoline functions override the prefix if prefix is used. |
642 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); | 664 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); |
643 if (func) | 665 if (func) |
644 return func(expr->expValue(), NoPrefix, *m_mediaValues); | 666 return func(expr->expValue(), NoPrefix, *m_mediaValues); |
645 | 667 |
646 return false; | 668 return false; |
647 } | 669 } |
648 | 670 |
649 } // namespace | 671 } // namespace |
OLD | NEW |