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