Chromium Code Reviews| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 static PassRefPtrWillBeRawPtr<MediaQuerySet> parse(const String&); | 51 static PassRefPtrWillBeRawPtr<MediaQuerySet> parse(const String&); |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 MediaQueryParser(const String&); | 54 MediaQueryParser(const String&); |
| 55 virtual ~MediaQueryParser() { }; | 55 virtual ~MediaQueryParser() { }; |
| 56 | 56 |
| 57 PassRefPtrWillBeRawPtr<MediaQuerySet> parseImpl(); | 57 PassRefPtrWillBeRawPtr<MediaQuerySet> parseImpl(); |
| 58 | 58 |
| 59 typedef Vector<MediaQueryToken>::iterator TokenIterator; | 59 typedef Vector<MediaQueryToken>::iterator TokenIterator; |
| 60 | 60 |
| 61 enum BlockType { | |
| 62 ParenthesisBlock, | |
| 63 BracketsBlock, | |
| 64 BracesBlock | |
| 65 }; | |
| 66 | |
| 67 enum StateChange { | |
| 68 ModifyState, | |
| 69 DoNotModifyState | |
| 70 }; | |
| 71 | |
| 72 struct BlockParameters { | |
| 73 MediaQueryTokenType lefttoken; | |
|
eseidel
2014/04/01 21:15:08
leftToken?
| |
| 74 MediaQueryTokenType righttoken; | |
| 75 BlockType blockType; | |
| 76 StateChange stateChange; | |
| 77 }; | |
| 78 | |
| 61 void processToken(TokenIterator&); | 79 void processToken(TokenIterator&); |
| 62 | 80 |
| 63 void readRestrictor(MediaQueryTokenType, TokenIterator&); | 81 void readRestrictor(MediaQueryTokenType, TokenIterator&); |
| 64 void readMediaType(MediaQueryTokenType, TokenIterator&); | 82 void readMediaType(MediaQueryTokenType, TokenIterator&); |
| 65 void readAnd(MediaQueryTokenType, TokenIterator&); | 83 void readAnd(MediaQueryTokenType, TokenIterator&); |
| 66 void readFeatureStart(MediaQueryTokenType, TokenIterator&); | 84 void readFeatureStart(MediaQueryTokenType, TokenIterator&); |
| 67 void readFeature(MediaQueryTokenType, TokenIterator&); | 85 void readFeature(MediaQueryTokenType, TokenIterator&); |
| 68 void readFeatureColon(MediaQueryTokenType, TokenIterator&); | 86 void readFeatureColon(MediaQueryTokenType, TokenIterator&); |
| 69 void readFeatureValue(MediaQueryTokenType, TokenIterator&); | 87 void readFeatureValue(MediaQueryTokenType, TokenIterator&); |
| 70 void readFeatureEnd(MediaQueryTokenType, TokenIterator&); | 88 void readFeatureEnd(MediaQueryTokenType, TokenIterator&); |
| 71 void skipUntilComma(MediaQueryTokenType, TokenIterator&); | 89 void skipUntilComma(MediaQueryTokenType, TokenIterator&); |
| 72 void skipUntilParenthesis(MediaQueryTokenType, TokenIterator&); | 90 void skipUntilBlockEnd(MediaQueryTokenType, TokenIterator&); |
| 73 void done(MediaQueryTokenType, TokenIterator&); | 91 void done(MediaQueryTokenType, TokenIterator&); |
| 74 | 92 |
| 75 typedef void (MediaQueryParser::*State)(MediaQueryTokenType, TokenIterator&) ; | 93 typedef void (MediaQueryParser::*State)(MediaQueryTokenType, TokenIterator&) ; |
| 76 | 94 |
| 77 void setStateAndRestrict(State, MediaQuery::Restrictor); | 95 void setStateAndRestrict(State, MediaQuery::Restrictor); |
| 96 bool observeBlock(BlockParameters&, MediaQueryTokenType); | |
| 97 void observeBlocks(MediaQueryTokenType); | |
| 98 static void popIfBlockMatches(Vector<MediaQueryParser::BlockType>& blockStac k, BlockType); | |
| 78 | 99 |
| 79 State m_state; | 100 State m_state; |
| 80 Vector<MediaQueryToken> m_tokens; | 101 Vector<MediaQueryToken> m_tokens; |
| 81 MediaQueryData m_mediaQueryData; | 102 MediaQueryData m_mediaQueryData; |
| 82 RefPtrWillBeMember<MediaQuerySet> m_querySet; | 103 RefPtrWillBeMember<MediaQuerySet> m_querySet; |
| 104 Vector<BlockType> m_blockStack; | |
| 83 | 105 |
| 84 const static State ReadRestrictor; | 106 const static State ReadRestrictor; |
| 85 const static State ReadMediaType; | 107 const static State ReadMediaType; |
| 86 const static State ReadAnd; | 108 const static State ReadAnd; |
| 87 const static State ReadFeatureStart; | 109 const static State ReadFeatureStart; |
| 88 const static State ReadFeature; | 110 const static State ReadFeature; |
| 89 const static State ReadFeatureColon; | 111 const static State ReadFeatureColon; |
| 90 const static State ReadFeatureValue; | 112 const static State ReadFeatureValue; |
| 91 const static State ReadFeatureEnd; | 113 const static State ReadFeatureEnd; |
| 92 const static State SkipUntilComma; | 114 const static State SkipUntilComma; |
| 93 const static State SkipUntilParenthesis; | 115 const static State SkipUntilBlockEnd; |
| 94 const static State Done; | 116 const static State Done; |
| 95 | 117 |
| 96 }; | 118 }; |
| 97 | 119 |
| 98 } // namespace WebCore | 120 } // namespace WebCore |
| 99 | 121 |
| 100 #endif // MediaQueryParser_h | 122 #endif // MediaQueryParser_h |
| OLD | NEW |