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 30 matching lines...) Expand all Loading... |
41 } | 41 } |
42 | 42 |
43 inline void setRestrictor(MediaQuery::Restrictor restrictor) { m_restrictor
= restrictor; } | 43 inline void setRestrictor(MediaQuery::Restrictor restrictor) { m_restrictor
= restrictor; } |
44 | 44 |
45 inline void setMediaFeature(const String& str) { m_mediaFeature = str; } | 45 inline void setMediaFeature(const String& str) { m_mediaFeature = str; } |
46 }; | 46 }; |
47 | 47 |
48 class MediaQueryParser { | 48 class MediaQueryParser { |
49 STACK_ALLOCATED(); | 49 STACK_ALLOCATED(); |
50 public: | 50 public: |
51 static PassRefPtrWillBeRawPtr<MediaQuerySet> parse(const String&); | 51 typedef Vector<MediaQueryToken>::iterator TokenIterator; |
| 52 |
| 53 static PassRefPtrWillBeRawPtr<MediaQuerySet> parseMediaQuerySet(const String
&); |
| 54 static PassRefPtrWillBeRawPtr<MediaQuerySet> parseMediaCondition(TokenIterat
or, TokenIterator endToken); |
52 | 55 |
53 private: | 56 private: |
54 MediaQueryParser(const String&); | 57 enum ParserType { |
55 virtual ~MediaQueryParser() { }; | 58 MediaQuerySetParser, |
| 59 MediaConditionParser, |
| 60 }; |
56 | 61 |
57 PassRefPtrWillBeRawPtr<MediaQuerySet> parseImpl(); | 62 MediaQueryParser(ParserType); |
| 63 virtual ~MediaQueryParser(); |
58 | 64 |
59 typedef Vector<MediaQueryToken>::iterator TokenIterator; | 65 PassRefPtrWillBeRawPtr<MediaQuerySet> parseImpl(TokenIterator, TokenIterator
endToken); |
60 | 66 |
61 enum BlockType { | 67 enum BlockType { |
62 ParenthesisBlock, | 68 ParenthesisBlock, |
63 BracketsBlock, | 69 BracketsBlock, |
64 BracesBlock | 70 BracesBlock |
65 }; | 71 }; |
66 | 72 |
67 enum StateChange { | 73 enum StateChange { |
68 ModifyState, | 74 ModifyState, |
69 DoNotModifyState | 75 DoNotModifyState |
(...skipping 21 matching lines...) Expand all Loading... |
91 void done(MediaQueryTokenType, TokenIterator&); | 97 void done(MediaQueryTokenType, TokenIterator&); |
92 | 98 |
93 typedef void (MediaQueryParser::*State)(MediaQueryTokenType, TokenIterator&)
; | 99 typedef void (MediaQueryParser::*State)(MediaQueryTokenType, TokenIterator&)
; |
94 | 100 |
95 void setStateAndRestrict(State, MediaQuery::Restrictor); | 101 void setStateAndRestrict(State, MediaQuery::Restrictor); |
96 bool observeBlock(BlockParameters&, MediaQueryTokenType); | 102 bool observeBlock(BlockParameters&, MediaQueryTokenType); |
97 void observeBlocks(MediaQueryTokenType); | 103 void observeBlocks(MediaQueryTokenType); |
98 static void popIfBlockMatches(Vector<MediaQueryParser::BlockType>& blockStac
k, BlockType); | 104 static void popIfBlockMatches(Vector<MediaQueryParser::BlockType>& blockStac
k, BlockType); |
99 | 105 |
100 State m_state; | 106 State m_state; |
101 Vector<MediaQueryToken> m_tokens; | |
102 MediaQueryData m_mediaQueryData; | 107 MediaQueryData m_mediaQueryData; |
103 RefPtrWillBeMember<MediaQuerySet> m_querySet; | 108 RefPtrWillBeMember<MediaQuerySet> m_querySet; |
104 Vector<BlockType> m_blockStack; | 109 Vector<BlockType> m_blockStack; |
105 | 110 |
106 const static State ReadRestrictor; | 111 const static State ReadRestrictor; |
107 const static State ReadMediaType; | 112 const static State ReadMediaType; |
108 const static State ReadAnd; | 113 const static State ReadAnd; |
109 const static State ReadFeatureStart; | 114 const static State ReadFeatureStart; |
110 const static State ReadFeature; | 115 const static State ReadFeature; |
111 const static State ReadFeatureColon; | 116 const static State ReadFeatureColon; |
112 const static State ReadFeatureValue; | 117 const static State ReadFeatureValue; |
113 const static State ReadFeatureEnd; | 118 const static State ReadFeatureEnd; |
114 const static State SkipUntilComma; | 119 const static State SkipUntilComma; |
115 const static State SkipUntilBlockEnd; | 120 const static State SkipUntilBlockEnd; |
116 const static State Done; | 121 const static State Done; |
117 | 122 |
118 }; | 123 }; |
119 | 124 |
120 } // namespace WebCore | 125 } // namespace WebCore |
121 | 126 |
122 #endif // MediaQueryParser_h | 127 #endif // MediaQueryParser_h |
OLD | NEW |