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 |
49 class MediaQueryParser { | 52 class MediaQueryParser { |
50 STACK_ALLOCATED(); | 53 STACK_ALLOCATED(); |
51 public: | 54 public: |
52 typedef Vector<MediaQueryToken>::iterator TokenIterator; | |
53 | |
54 static PassRefPtrWillBeRawPtr<MediaQuerySet> parseMediaQuerySet(const String
&); | 55 static PassRefPtrWillBeRawPtr<MediaQuerySet> parseMediaQuerySet(const String
&); |
55 static PassRefPtrWillBeRawPtr<MediaQuerySet> parseMediaCondition(TokenIterat
or, TokenIterator endToken); | 56 static PassRefPtrWillBeRawPtr<MediaQuerySet> parseMediaCondition(TokenIterat
or, TokenIterator endToken); |
56 | 57 |
57 private: | 58 private: |
58 enum ParserType { | 59 enum ParserType { |
59 MediaQuerySetParser, | 60 MediaQuerySetParser, |
60 MediaConditionParser, | 61 MediaConditionParser, |
61 }; | 62 }; |
62 | 63 |
63 MediaQueryParser(ParserType); | 64 MediaQueryParser(ParserType); |
(...skipping 14 matching lines...) Expand all Loading... |
78 void skipUntilComma(MediaQueryTokenType, const MediaQueryToken&); | 79 void skipUntilComma(MediaQueryTokenType, const MediaQueryToken&); |
79 void skipUntilBlockEnd(MediaQueryTokenType, const MediaQueryToken&); | 80 void skipUntilBlockEnd(MediaQueryTokenType, const MediaQueryToken&); |
80 void done(MediaQueryTokenType, const MediaQueryToken&); | 81 void done(MediaQueryTokenType, const MediaQueryToken&); |
81 | 82 |
82 typedef void (MediaQueryParser::*State)(MediaQueryTokenType, const MediaQuer
yToken&); | 83 typedef void (MediaQueryParser::*State)(MediaQueryTokenType, const MediaQuer
yToken&); |
83 | 84 |
84 void setStateAndRestrict(State, MediaQuery::Restrictor); | 85 void setStateAndRestrict(State, MediaQuery::Restrictor); |
85 void handleBlocks(const MediaQueryToken&); | 86 void handleBlocks(const MediaQueryToken&); |
86 | 87 |
87 State m_state; | 88 State m_state; |
| 89 ParserType m_parserType; |
88 MediaQueryData m_mediaQueryData; | 90 MediaQueryData m_mediaQueryData; |
89 RefPtrWillBeMember<MediaQuerySet> m_querySet; | 91 RefPtrWillBeMember<MediaQuerySet> m_querySet; |
90 MediaQueryBlockWatcher m_blockWatcher; | 92 MediaQueryBlockWatcher m_blockWatcher; |
91 | 93 |
92 const static State ReadRestrictor; | 94 const static State ReadRestrictor; |
93 const static State ReadMediaType; | 95 const static State ReadMediaType; |
94 const static State ReadAnd; | 96 const static State ReadAnd; |
95 const static State ReadFeatureStart; | 97 const static State ReadFeatureStart; |
96 const static State ReadFeature; | 98 const static State ReadFeature; |
97 const static State ReadFeatureColon; | 99 const static State ReadFeatureColon; |
98 const static State ReadFeatureValue; | 100 const static State ReadFeatureValue; |
99 const static State ReadFeatureEnd; | 101 const static State ReadFeatureEnd; |
100 const static State SkipUntilComma; | 102 const static State SkipUntilComma; |
101 const static State SkipUntilBlockEnd; | 103 const static State SkipUntilBlockEnd; |
102 const static State Done; | 104 const static State Done; |
103 | 105 |
104 }; | 106 }; |
105 | 107 |
106 } // namespace WebCore | 108 } // namespace WebCore |
107 | 109 |
108 #endif // MediaQueryParser_h | 110 #endif // MediaQueryParser_h |
OLD | NEW |