| 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 "core/css/parser/MediaQueryParser.h" | 5 #include "core/css/parser/MediaQueryParser.h" |
| 6 | 6 |
| 7 #include "core/MediaTypeNames.h" | 7 #include "core/MediaTypeNames.h" |
| 8 #include "core/css/parser/CSSPropertyParser.h" | 8 #include "core/css/parser/CSSPropertyParser.h" |
| 9 #include "core/css/parser/CSSTokenizer.h" | 9 #include "core/css/parser/CSSTokenizer.h" |
| 10 #include "wtf/Vector.h" | 10 #include "wtf/Vector.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 , m_querySet(MediaQuerySet::create()) | 44 , m_querySet(MediaQuerySet::create()) |
| 45 { | 45 { |
| 46 if (parserType == MediaQuerySetParser) | 46 if (parserType == MediaQuerySetParser) |
| 47 m_state = &MediaQueryParser::readRestrictor; | 47 m_state = &MediaQueryParser::readRestrictor; |
| 48 else // MediaConditionParser | 48 else // MediaConditionParser |
| 49 m_state = &MediaQueryParser::readMediaNot; | 49 m_state = &MediaQueryParser::readMediaNot; |
| 50 } | 50 } |
| 51 | 51 |
| 52 MediaQueryParser::~MediaQueryParser() { } | 52 MediaQueryParser::~MediaQueryParser() { } |
| 53 | 53 |
| 54 void MediaQueryParser::setStateAndRestrict(State state, MediaQuery::Restrictor r
estrictor) | 54 void MediaQueryParser::setStateAndRestrict(State state, MediaQuery::RestrictorTy
pe restrictor) |
| 55 { | 55 { |
| 56 m_mediaQueryData.setRestrictor(restrictor); | 56 m_mediaQueryData.setRestrictor(restrictor); |
| 57 m_state = state; | 57 m_state = state; |
| 58 } | 58 } |
| 59 | 59 |
| 60 // State machine member functions start here | 60 // State machine member functions start here |
| 61 void MediaQueryParser::readRestrictor(CSSParserTokenType type, const CSSParserTo
ken& token) | 61 void MediaQueryParser::readRestrictor(CSSParserTokenType type, const CSSParserTo
ken& token) |
| 62 { | 62 { |
| 63 readMediaType(type, token); | 63 readMediaType(type, token); |
| 64 } | 64 } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 { | 181 { |
| 182 if ((type == CommaToken && !m_blockWatcher.blockLevel()) || type == EOFToken
) { | 182 if ((type == CommaToken && !m_blockWatcher.blockLevel()) || type == EOFToken
) { |
| 183 m_state = ReadRestrictor; | 183 m_state = ReadRestrictor; |
| 184 m_mediaQueryData.clear(); | 184 m_mediaQueryData.clear(); |
| 185 m_querySet->addMediaQuery(MediaQuery::createNotAll()); | 185 m_querySet->addMediaQuery(MediaQuery::createNotAll()); |
| 186 } | 186 } |
| 187 } | 187 } |
| 188 | 188 |
| 189 void MediaQueryParser::skipUntilBlockEnd(CSSParserTokenType type, const CSSParse
rToken& token) | 189 void MediaQueryParser::skipUntilBlockEnd(CSSParserTokenType type, const CSSParse
rToken& token) |
| 190 { | 190 { |
| 191 if (token.blockType() == CSSParserToken::BlockEnd && !m_blockWatcher.blockLe
vel()) | 191 if (token.getBlockType() == CSSParserToken::BlockEnd && !m_blockWatcher.bloc
kLevel()) |
| 192 m_state = SkipUntilComma; | 192 m_state = SkipUntilComma; |
| 193 } | 193 } |
| 194 | 194 |
| 195 void MediaQueryParser::done(CSSParserTokenType type, const CSSParserToken& token
) { } | 195 void MediaQueryParser::done(CSSParserTokenType type, const CSSParserToken& token
) { } |
| 196 | 196 |
| 197 void MediaQueryParser::handleBlocks(const CSSParserToken& token) | 197 void MediaQueryParser::handleBlocks(const CSSParserToken& token) |
| 198 { | 198 { |
| 199 if (token.blockType() == CSSParserToken::BlockStart | 199 if (token.getBlockType() == CSSParserToken::BlockStart |
| 200 && (token.type() != LeftParenthesisToken || m_blockWatcher.blockLevel())
) | 200 && (token.type() != LeftParenthesisToken || m_blockWatcher.blockLevel())
) |
| 201 m_state = SkipUntilBlockEnd; | 201 m_state = SkipUntilBlockEnd; |
| 202 } | 202 } |
| 203 | 203 |
| 204 void MediaQueryParser::processToken(const CSSParserToken& token) | 204 void MediaQueryParser::processToken(const CSSParserToken& token) |
| 205 { | 205 { |
| 206 CSSParserTokenType type = token.type(); | 206 CSSParserTokenType type = token.type(); |
| 207 | 207 |
| 208 handleBlocks(token); | 208 handleBlocks(token); |
| 209 m_blockWatcher.handleToken(token); | 209 m_blockWatcher.handleToken(token); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 return false; | 275 return false; |
| 276 } | 276 } |
| 277 | 277 |
| 278 void MediaQueryData::setMediaType(const String& mediaType) | 278 void MediaQueryData::setMediaType(const String& mediaType) |
| 279 { | 279 { |
| 280 m_mediaType = mediaType; | 280 m_mediaType = mediaType; |
| 281 m_mediaTypeSet = true; | 281 m_mediaTypeSet = true; |
| 282 } | 282 } |
| 283 | 283 |
| 284 } // namespace blink | 284 } // namespace blink |
| OLD | NEW |