Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: Source/core/css/parser/MediaQueryParser.cpp

Issue 221693004: Unit test both MQ parsers. Fix MQ parser block handling bugs (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed a couple of errors related to block handling. Added tests Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/css/MediaQuerySetTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « Source/core/css/MediaQuerySetTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698