OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MediaQueryParser_h | 5 #ifndef MediaQueryParser_h |
6 #define MediaQueryParser_h | 6 #define MediaQueryParser_h |
7 | 7 |
8 #include "core/css/CSSParserValues.h" | 8 #include "core/css/CSSParserValues.h" |
9 #include "core/css/MediaList.h" | 9 #include "core/css/MediaList.h" |
10 #include "core/css/MediaQuery.h" | 10 #include "core/css/MediaQuery.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 inline bool currentMediaQueryChanged() const | 39 inline bool currentMediaQueryChanged() const |
40 { | 40 { |
41 return (m_restrictor != MediaQuery::None || m_mediaTypeSet || m_expressi
ons->size() > 0); | 41 return (m_restrictor != MediaQuery::None || m_mediaTypeSet || m_expressi
ons->size() > 0); |
42 } | 42 } |
43 | 43 |
44 inline void setRestrictor(MediaQuery::Restrictor restrictor) { m_restrictor
= restrictor; } | 44 inline void setRestrictor(MediaQuery::Restrictor restrictor) { m_restrictor
= restrictor; } |
45 | 45 |
46 inline void setMediaFeature(const String& str) { m_mediaFeature = str; } | 46 inline void setMediaFeature(const String& str) { m_mediaFeature = str; } |
47 }; | 47 }; |
48 | 48 |
49 typedef Vector<MediaQueryToken> TokenList; | |
50 typedef TokenList::iterator TokenIterator; | |
51 | |
52 class MediaQueryParser { | 49 class MediaQueryParser { |
53 STACK_ALLOCATED(); | 50 STACK_ALLOCATED(); |
54 public: | 51 public: |
55 static PassRefPtrWillBeRawPtr<MediaQuerySet> parseMediaQuerySet(const String
&); | 52 static PassRefPtrWillBeRawPtr<MediaQuerySet> parseMediaQuerySet(const String
&); |
56 static PassRefPtrWillBeRawPtr<MediaQuerySet> parseMediaCondition(TokenIterat
or, TokenIterator endToken); | 53 static PassRefPtrWillBeRawPtr<MediaQuerySet> parseMediaCondition(MediaQueryT
okenIterator, MediaQueryTokenIterator endToken); |
57 | 54 |
58 private: | 55 private: |
59 enum ParserType { | 56 enum ParserType { |
60 MediaQuerySetParser, | 57 MediaQuerySetParser, |
61 MediaConditionParser, | 58 MediaConditionParser, |
62 }; | 59 }; |
63 | 60 |
64 MediaQueryParser(ParserType); | 61 MediaQueryParser(ParserType); |
65 virtual ~MediaQueryParser(); | 62 virtual ~MediaQueryParser(); |
66 | 63 |
67 PassRefPtrWillBeRawPtr<MediaQuerySet> parseImpl(TokenIterator, TokenIterator
endToken); | 64 PassRefPtrWillBeRawPtr<MediaQuerySet> parseImpl(MediaQueryTokenIterator, Med
iaQueryTokenIterator endToken); |
68 | 65 |
69 void processToken(const MediaQueryToken&); | 66 void processToken(const MediaQueryToken&); |
70 | 67 |
71 void readRestrictor(MediaQueryTokenType, const MediaQueryToken&); | 68 void readRestrictor(MediaQueryTokenType, const MediaQueryToken&); |
72 void readMediaType(MediaQueryTokenType, const MediaQueryToken&); | 69 void readMediaType(MediaQueryTokenType, const MediaQueryToken&); |
73 void readAnd(MediaQueryTokenType, const MediaQueryToken&); | 70 void readAnd(MediaQueryTokenType, const MediaQueryToken&); |
74 void readFeatureStart(MediaQueryTokenType, const MediaQueryToken&); | 71 void readFeatureStart(MediaQueryTokenType, const MediaQueryToken&); |
75 void readFeature(MediaQueryTokenType, const MediaQueryToken&); | 72 void readFeature(MediaQueryTokenType, const MediaQueryToken&); |
76 void readFeatureColon(MediaQueryTokenType, const MediaQueryToken&); | 73 void readFeatureColon(MediaQueryTokenType, const MediaQueryToken&); |
77 void readFeatureValue(MediaQueryTokenType, const MediaQueryToken&); | 74 void readFeatureValue(MediaQueryTokenType, const MediaQueryToken&); |
(...skipping 23 matching lines...) Expand all Loading... |
101 const static State ReadFeatureEnd; | 98 const static State ReadFeatureEnd; |
102 const static State SkipUntilComma; | 99 const static State SkipUntilComma; |
103 const static State SkipUntilBlockEnd; | 100 const static State SkipUntilBlockEnd; |
104 const static State Done; | 101 const static State Done; |
105 | 102 |
106 }; | 103 }; |
107 | 104 |
108 } // namespace WebCore | 105 } // namespace WebCore |
109 | 106 |
110 #endif // MediaQueryParser_h | 107 #endif // MediaQueryParser_h |
OLD | NEW |