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 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/css/parser/MediaQueryParser.h" | 6 #include "core/css/parser/MediaQueryParser.h" |
| 7 | 7 |
| 8 #include "MediaTypeNames.h" | 8 #include "MediaTypeNames.h" |
| 9 #include "core/css/parser/CSSPropertyParser.h" | 9 #include "core/css/parser/CSSPropertyParser.h" |
| 10 #include "core/css/parser/MediaQueryTokenizer.h" | 10 #include "core/css/parser/MediaQueryTokenizer.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 } else if (type == DelimiterToken && token->delimiter() == '/') { | 135 } else if (type == DelimiterToken && token->delimiter() == '/') { |
| 136 m_mediaQueryData.addParserValue(type, *token); | 136 m_mediaQueryData.addParserValue(type, *token); |
| 137 m_state = ReadFeatureValue; | 137 m_state = ReadFeatureValue; |
| 138 } else { | 138 } else { |
| 139 m_state = SkipUntilBlockEnd; | 139 m_state = SkipUntilBlockEnd; |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 | 142 |
| 143 void MediaQueryParser::skipUntilComma(MediaQueryTokenType type, TokenIterator& t oken) | 143 void MediaQueryParser::skipUntilComma(MediaQueryTokenType type, TokenIterator& t oken) |
| 144 { | 144 { |
| 145 if (type == CommaToken || type == EOFToken) { | 145 if ((type == CommaToken && m_blockStack.isEmpty()) || type == EOFToken) { |
| 146 m_state = ReadRestrictor; | 146 m_state = ReadRestrictor; |
| 147 m_mediaQueryData.clear(); | 147 m_mediaQueryData.clear(); |
| 148 m_querySet->addMediaQuery(MediaQuery::createNotAll()); | 148 m_querySet->addMediaQuery(MediaQuery::createNotAll()); |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 | 151 |
| 152 void MediaQueryParser::skipUntilBlockEnd(MediaQueryTokenType type, TokenIterator & token) | 152 void MediaQueryParser::skipUntilBlockEnd(MediaQueryTokenType type, TokenIterator & token) |
| 153 { | 153 { |
| 154 if (m_blockStack.isEmpty()) | 154 if (m_blockStack.isEmpty()) |
| 155 m_state = SkipUntilComma; | 155 m_state = SkipUntilComma; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 172 } else if (type == parameters.rightToken) { | 172 } else if (type == parameters.rightToken) { |
| 173 popIfBlockMatches(m_blockStack, parameters.blockType); | 173 popIfBlockMatches(m_blockStack, parameters.blockType); |
| 174 } else { | 174 } else { |
| 175 return false; | 175 return false; |
| 176 } | 176 } |
| 177 return true; | 177 return true; |
| 178 } | 178 } |
| 179 | 179 |
| 180 void MediaQueryParser::observeBlocks(MediaQueryTokenType type) | 180 void MediaQueryParser::observeBlocks(MediaQueryTokenType type) |
| 181 { | 181 { |
| 182 const unsigned blockParametersNumber = 3; | 182 const unsigned blockParametersNumber = 4; |
|
rune
2014/04/02 12:48:31
We normally use enums like:
enum { BlockParam
| |
| 183 BlockParameters blockParameterSet[blockParametersNumber] = { | 183 BlockParameters blockParameterSet[blockParametersNumber] = { |
| 184 { LeftParenthesisToken, RightParenthesisToken, ParenthesisBlock, DoNotMo difyState }, | 184 { LeftParenthesisToken, RightParenthesisToken, ParenthesisBlock, DoNotMo difyState }, |
| 185 { FunctionToken, RightParenthesisToken, ParenthesisBlock, ModifyState }, | |
| 185 { LeftBracketToken, RightBracketToken, BracketsBlock, ModifyState }, | 186 { LeftBracketToken, RightBracketToken, BracketsBlock, ModifyState }, |
| 186 { LeftBraceToken, RightBraceToken, BracesBlock, ModifyState } | 187 { LeftBraceToken, RightBraceToken, BracesBlock, ModifyState } |
| 187 }; | 188 }; |
| 188 | 189 |
| 189 for (unsigned i = 0; i < blockParametersNumber; ++i) { | 190 for (unsigned i = 0; i < blockParametersNumber; ++i) { |
| 190 if (observeBlock(blockParameterSet[i], type)) | 191 if (observeBlock(blockParameterSet[i], type)) |
| 191 break; | 192 break; |
| 192 } | 193 } |
| 193 } | 194 } |
| 194 | 195 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 271 m_valueList.addValue(value); | 272 m_valueList.addValue(value); |
| 272 } | 273 } |
| 273 | 274 |
| 274 void MediaQueryData::setMediaType(const String& mediaType) | 275 void MediaQueryData::setMediaType(const String& mediaType) |
| 275 { | 276 { |
| 276 m_mediaType = mediaType; | 277 m_mediaType = mediaType; |
| 277 m_mediaTypeSet = true; | 278 m_mediaTypeSet = true; |
| 278 } | 279 } |
| 279 | 280 |
| 280 } // namespace WebCore | 281 } // namespace WebCore |
| OLD | NEW |