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 15 matching lines...) Expand all Loading... |
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 */ | 28 */ |
29 | 29 |
30 #include "config.h" | 30 #include "config.h" |
31 #include "core/css/MediaQueryEvaluator.h" | 31 #include "core/css/MediaQueryEvaluator.h" |
32 | 32 |
33 #include "CSSValueKeywords.h" | 33 #include "CSSValueKeywords.h" |
34 #include "MediaFeatureNames.h" | 34 #include "MediaFeatureNames.h" |
35 #include "MediaFeatures.h" | 35 #include "MediaFeatures.h" |
| 36 #include "MediaTypeNames.h" |
36 #include "core/css/CSSAspectRatioValue.h" | 37 #include "core/css/CSSAspectRatioValue.h" |
37 #include "core/css/CSSHelper.h" | 38 #include "core/css/CSSHelper.h" |
38 #include "core/css/CSSPrimitiveValue.h" | 39 #include "core/css/CSSPrimitiveValue.h" |
39 #include "core/css/CSSToLengthConversionData.h" | 40 #include "core/css/CSSToLengthConversionData.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/resolver/MediaQueryResult.h" | 43 #include "core/css/resolver/MediaQueryResult.h" |
43 #include "core/dom/NodeRenderStyle.h" | 44 #include "core/dom/NodeRenderStyle.h" |
44 #include "core/frame/FrameHost.h" | 45 #include "core/frame/FrameHost.h" |
45 #include "core/frame/FrameView.h" | 46 #include "core/frame/FrameView.h" |
(...skipping 17 matching lines...) Expand all Loading... |
63 typedef HashMap<StringImpl*, EvalFunc> FunctionMap; | 64 typedef HashMap<StringImpl*, EvalFunc> FunctionMap; |
64 static FunctionMap* gFunctionMap; | 65 static FunctionMap* gFunctionMap; |
65 | 66 |
66 MediaQueryEvaluator::MediaQueryEvaluator(bool mediaFeatureResult) | 67 MediaQueryEvaluator::MediaQueryEvaluator(bool mediaFeatureResult) |
67 : m_frame(0) | 68 : m_frame(0) |
68 , m_style(nullptr) | 69 , m_style(nullptr) |
69 , m_expResult(mediaFeatureResult) | 70 , m_expResult(mediaFeatureResult) |
70 { | 71 { |
71 } | 72 } |
72 | 73 |
73 MediaQueryEvaluator::MediaQueryEvaluator(const AtomicString& acceptedMediaType,
bool mediaFeatureResult) | 74 MediaQueryEvaluator::MediaQueryEvaluator(const String& acceptedMediaType, bool m
ediaFeatureResult) |
74 : m_mediaType(acceptedMediaType) | 75 : m_mediaType(acceptedMediaType) |
75 , m_frame(0) | 76 , m_frame(0) |
76 , m_style(nullptr) | 77 , m_style(nullptr) |
77 , m_expResult(mediaFeatureResult) | 78 , m_expResult(mediaFeatureResult) |
78 { | 79 { |
79 } | 80 } |
80 | 81 |
81 MediaQueryEvaluator::MediaQueryEvaluator(const char* acceptedMediaType, bool med
iaFeatureResult) | 82 MediaQueryEvaluator::MediaQueryEvaluator(const char* acceptedMediaType, bool med
iaFeatureResult) |
82 : m_mediaType(acceptedMediaType) | 83 : m_mediaType(acceptedMediaType) |
83 , m_frame(0) | 84 , m_frame(0) |
84 , m_style(nullptr) | 85 , m_style(nullptr) |
85 , m_expResult(mediaFeatureResult) | 86 , m_expResult(mediaFeatureResult) |
86 { | 87 { |
87 } | 88 } |
88 | 89 |
89 MediaQueryEvaluator::MediaQueryEvaluator(const AtomicString& acceptedMediaType,
LocalFrame* frame, RenderStyle* style) | 90 MediaQueryEvaluator::MediaQueryEvaluator(const String& acceptedMediaType, LocalF
rame* frame, RenderStyle* style) |
90 : m_mediaType(acceptedMediaType) | 91 : m_mediaType(acceptedMediaType) |
91 , m_frame(frame) | 92 , m_frame(frame) |
92 , m_style(style) | 93 , m_style(style) |
93 , m_expResult(false) // Doesn't matter when we have m_frame and m_style. | 94 , m_expResult(false) // Doesn't matter when we have m_frame and m_style. |
94 { | 95 { |
95 } | 96 } |
96 | 97 |
97 MediaQueryEvaluator::~MediaQueryEvaluator() | 98 MediaQueryEvaluator::~MediaQueryEvaluator() |
98 { | 99 { |
99 } | 100 } |
100 | 101 |
101 bool MediaQueryEvaluator::mediaTypeMatch(const AtomicString& mediaTypeToMatch) c
onst | 102 bool MediaQueryEvaluator::mediaTypeMatch(const String& mediaTypeToMatch) const |
102 { | 103 { |
103 return mediaTypeToMatch.isEmpty() | 104 return mediaTypeToMatch.isEmpty() |
104 || equalIgnoringCase(mediaTypeToMatch, "all") | 105 || equalIgnoringCase(mediaTypeToMatch, MediaTypeNames::all) |
105 || equalIgnoringCase(mediaTypeToMatch, m_mediaType); | 106 || equalIgnoringCase(mediaTypeToMatch, m_mediaType); |
106 } | 107 } |
107 | 108 |
108 bool MediaQueryEvaluator::mediaTypeMatchSpecific(const char* mediaTypeToMatch) c
onst | 109 bool MediaQueryEvaluator::mediaTypeMatchSpecific(const char* mediaTypeToMatch) c
onst |
109 { | 110 { |
110 // Like mediaTypeMatch, but without the special cases for "" and "all". | 111 // Like mediaTypeMatch, but without the special cases for "" and "all". |
111 ASSERT(mediaTypeToMatch); | 112 ASSERT(mediaTypeToMatch); |
112 ASSERT(mediaTypeToMatch[0] != '\0'); | 113 ASSERT(mediaTypeToMatch[0] != '\0'); |
113 ASSERT(!equalIgnoringCase(mediaTypeToMatch, AtomicString("all"))); | 114 ASSERT(!equalIgnoringCase(mediaTypeToMatch, MediaTypeNames::all)); |
114 return equalIgnoringCase(mediaTypeToMatch, m_mediaType); | 115 return equalIgnoringCase(mediaTypeToMatch, m_mediaType); |
115 } | 116 } |
116 | 117 |
117 static bool applyRestrictor(MediaQuery::Restrictor r, bool value) | 118 static bool applyRestrictor(MediaQuery::Restrictor r, bool value) |
118 { | 119 { |
119 return r == MediaQuery::Not ? !value : value; | 120 return r == MediaQuery::Not ? !value : value; |
120 } | 121 } |
121 | 122 |
122 bool MediaQueryEvaluator::eval(const MediaQuerySet* querySet, MediaQueryResultLi
st* viewportDependentMediaQueryResults) const | 123 bool MediaQueryEvaluator::eval(const MediaQuerySet* querySet, MediaQueryResultLi
st* viewportDependentMediaQueryResults) const |
123 { | 124 { |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 // Call the media feature evaluation function. Assume no prefix and let | 692 // Call the media feature evaluation function. Assume no prefix and let |
692 // trampoline functions override the prefix if prefix is used. | 693 // trampoline functions override the prefix if prefix is used. |
693 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); | 694 EvalFunc func = gFunctionMap->get(expr->mediaFeature().impl()); |
694 if (func) | 695 if (func) |
695 return func(expr->value(), m_style.get(), m_frame, NoPrefix); | 696 return func(expr->value(), m_style.get(), m_frame, NoPrefix); |
696 | 697 |
697 return false; | 698 return false; |
698 } | 699 } |
699 | 700 |
700 } // namespace | 701 } // namespace |
OLD | NEW |