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 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "platform/heap/Handle.h" | 32 #include "platform/heap/Handle.h" |
33 #include "wtf/text/WTFString.h" | 33 #include "wtf/text/WTFString.h" |
34 | 34 |
35 namespace blink { | 35 namespace blink { |
36 class LocalFrame; | 36 class LocalFrame; |
37 class MediaQuery; | 37 class MediaQuery; |
38 class MediaQueryExp; | 38 class MediaQueryExp; |
39 class MediaQueryResult; | 39 class MediaQueryResult; |
40 class MediaQuerySet; | 40 class MediaQuerySet; |
41 class MediaValues; | 41 class MediaValues; |
| 42 class MediaValuesInitialViewport; |
42 | 43 |
43 using MediaQueryResultList = HeapVector<Member<MediaQueryResult>>; | 44 using MediaQueryResultList = HeapVector<Member<MediaQueryResult>>; |
44 | 45 |
45 // Class that evaluates css media queries as defined in | 46 // Class that evaluates css media queries as defined in |
46 // CSS3 Module "Media Queries" (http://www.w3.org/TR/css3-mediaqueries/) | 47 // CSS3 Module "Media Queries" (http://www.w3.org/TR/css3-mediaqueries/) |
47 // Special constructors are needed, if simple media queries are to be | 48 // Special constructors are needed, if simple media queries are to be |
48 // evaluated without knowledge of the medium features. This can happen | 49 // evaluated without knowledge of the medium features. This can happen |
49 // for example when parsing UA stylesheets, if evaluation is done | 50 // for example when parsing UA stylesheets, if evaluation is done |
50 // right after parsing. | 51 // right after parsing. |
51 // | 52 // |
(...skipping 21 matching lines...) Expand all Loading... |
73 MediaQueryEvaluator(const char* acceptedMediaType, | 74 MediaQueryEvaluator(const char* acceptedMediaType, |
74 bool mediaFeatureResult = false); | 75 bool mediaFeatureResult = false); |
75 | 76 |
76 // Creates evaluator which evaluates full media queries. | 77 // Creates evaluator which evaluates full media queries. |
77 explicit MediaQueryEvaluator(LocalFrame*); | 78 explicit MediaQueryEvaluator(LocalFrame*); |
78 | 79 |
79 // Creates evaluator which evaluates in a thread-safe manner a subset of media | 80 // Creates evaluator which evaluates in a thread-safe manner a subset of media |
80 // values. | 81 // values. |
81 explicit MediaQueryEvaluator(const MediaValues&); | 82 explicit MediaQueryEvaluator(const MediaValues&); |
82 | 83 |
| 84 explicit MediaQueryEvaluator(MediaValuesInitialViewport*); |
| 85 |
83 ~MediaQueryEvaluator(); | 86 ~MediaQueryEvaluator(); |
84 | 87 |
85 bool mediaTypeMatch(const String& mediaTypeToMatch) const; | 88 bool mediaTypeMatch(const String& mediaTypeToMatch) const; |
86 | 89 |
87 // Evaluates a list of media queries. | 90 // Evaluates a list of media queries. |
88 bool eval(const MediaQuerySet*, | 91 bool eval(const MediaQuerySet*, |
89 MediaQueryResultList* viewportDependent = 0, | 92 MediaQueryResultList* viewportDependent = nullptr, |
90 MediaQueryResultList* deviceDependent = 0) const; | 93 MediaQueryResultList* deviceDependent = nullptr) const; |
91 | 94 |
92 // Evaluates media query. | 95 // Evaluates media query. |
93 bool eval(const MediaQuery*, | 96 bool eval(const MediaQuery*, |
94 MediaQueryResultList* viewportDependent = 0, | 97 MediaQueryResultList* viewportDependent = nullptr, |
95 MediaQueryResultList* deviceDependent = 0) const; | 98 MediaQueryResultList* deviceDependent = nullptr) const; |
96 | 99 |
97 // Evaluates media query subexpression, ie "and (media-feature: value)" part. | 100 // Evaluates media query subexpression, ie "and (media-feature: value)" part. |
98 bool eval(const MediaQueryExp*) const; | 101 bool eval(const MediaQueryExp*) const; |
99 | 102 |
100 DECLARE_TRACE(); | 103 DECLARE_TRACE(); |
101 | 104 |
102 private: | 105 private: |
103 const String mediaType() const; | 106 const String mediaType() const; |
104 | 107 |
105 String m_mediaType; | 108 String m_mediaType; |
106 bool m_expectedResult; | 109 bool m_expectedResult = false; |
107 Member<MediaValues> m_mediaValues; | 110 Member<MediaValues> m_mediaValues; |
108 }; | 111 }; |
109 | 112 |
110 } // namespace blink | 113 } // namespace blink |
111 #endif | 114 #endif |
OLD | NEW |