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

Side by Side Diff: Source/core/css/CSSParser.cpp

Issue 14620012: Improved parse error handling for CSSMQ. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@query-selector-performance
Patch Set: Created 7 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2003 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> 6 * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. 8 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved.
9 * Copyright (C) 2012 Intel Corporation. All rights reserved. 9 * Copyright (C) 2012 Intel Corporation. All rights reserved.
10 * 10 *
(...skipping 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 } 1415 }
1416 1416
1417 PassOwnPtr<MediaQuery> CSSParser::parseMediaQuery(const String& string) 1417 PassOwnPtr<MediaQuery> CSSParser::parseMediaQuery(const String& string)
1418 { 1418 {
1419 if (string.isEmpty()) 1419 if (string.isEmpty())
1420 return nullptr; 1420 return nullptr;
1421 1421
1422 ASSERT(!m_mediaQuery); 1422 ASSERT(!m_mediaQuery);
1423 1423
1424 // can't use { because tokenizer state switches from mediaquery to initial s tate when it sees { token. 1424 // can't use { because tokenizer state switches from mediaquery to initial s tate when it sees { token.
1425 // instead insert one " " (which is WHITESPACE in CSSGrammar.y) 1425 // instead insert one " " (which is caught by maybe_space in CSSGrammar.y)
1426 setupParser("@-webkit-mediaquery ", string, "} "); 1426 setupParser("@-webkit-mediaquery ", string, "");
1427 cssyyparse(this); 1427 cssyyparse(this);
1428 1428
1429 return m_mediaQuery.release(); 1429 return m_mediaQuery.release();
1430 } 1430 }
1431 1431
1432 static inline void filterProperties(bool important, const CSSParser::ParsedPrope rtyVector& input, Vector<CSSProperty, 256>& output, size_t& unusedEntries, BitAr ray<numCSSProperties>& seenProperties, HashSet<AtomicString>& seenVariables) 1432 static inline void filterProperties(bool important, const CSSParser::ParsedPrope rtyVector& input, Vector<CSSProperty, 256>& output, size_t& unusedEntries, BitAr ray<numCSSProperties>& seenProperties, HashSet<AtomicString>& seenVariables)
1433 { 1433 {
1434 // Add properties in reverse order so that highest priority definitions are reached first. Duplicate definitions can then be ignored when found. 1434 // Add properties in reverse order so that highest priority definitions are reached first. Duplicate definitions can then be ignored when found.
1435 for (int i = input.size() - 1; i >= 0; --i) { 1435 for (int i = input.size() - 1; i >= 0; --i) {
1436 const CSSProperty& property = input[i]; 1436 const CSSProperty& property = input[i];
(...skipping 8901 matching lines...) Expand 10 before | Expand all | Expand 10 after
10338 m_token = IDENT; 10338 m_token = IDENT;
10339 10339
10340 if (UNLIKELY(*currentCharacter<SrcCharacterType>() == '(')) { 10340 if (UNLIKELY(*currentCharacter<SrcCharacterType>() == '(')) {
10341 if (m_parsingMode == SupportsMode && !hasEscape) { 10341 if (m_parsingMode == SupportsMode && !hasEscape) {
10342 detectSupportsToken<SrcCharacterType>(result - tokenStart<SrcCha racterType>()); 10342 detectSupportsToken<SrcCharacterType>(result - tokenStart<SrcCha racterType>());
10343 if (m_token != IDENT) 10343 if (m_token != IDENT)
10344 break; 10344 break;
10345 } 10345 }
10346 10346
10347 m_token = FUNCTION; 10347 m_token = FUNCTION;
10348 bool shouldSkipParenthesis = true; 10348 if (!hasEscape)
10349 if (!hasEscape) { 10349 detectFunctionTypeToken<SrcCharacterType>(result - tokenStart<Sr cCharacterType>());
10350 bool detected = detectFunctionTypeToken<SrcCharacterType>(result - tokenStart<SrcCharacterType>()); 10350 ++currentCharacter<SrcCharacterType>();
10351 if (!detected && m_parsingMode == MediaQueryMode) { 10351 ++result;
10352 // ... and(max-width: 480px) ... looks like a function, but in fact it is not, 10352 ++yylval->string.m_length;
10353 // so run more detection code in the MediaQueryMode.
10354 detectMediaQueryToken<SrcCharacterType>(result - tokenStart< SrcCharacterType>());
10355 shouldSkipParenthesis = false;
10356 }
10357 }
10358
10359 if (LIKELY(shouldSkipParenthesis)) {
10360 ++currentCharacter<SrcCharacterType>();
10361 ++result;
10362 ++yylval->string.m_length;
10363 }
10364 10353
10365 if (token() == URI) { 10354 if (token() == URI) {
10366 m_token = FUNCTION; 10355 m_token = FUNCTION;
10367 // Check whether it is really an URI. 10356 // Check whether it is really an URI.
10368 if (yylval->string.is8Bit()) 10357 if (yylval->string.is8Bit())
10369 parseURI<LChar>(yylval->string); 10358 parseURI<LChar>(yylval->string);
10370 else 10359 else
10371 parseURI<UChar>(yylval->string); 10360 parseURI<UChar>(yylval->string);
10372 } 10361 }
10373 } else if (UNLIKELY(m_parsingMode != NormalMode) && !hasEscape) { 10362 } else if (UNLIKELY(m_parsingMode != NormalMode) && !hasEscape) {
(...skipping 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after
11698 { 11687 {
11699 // The tokenizer checks for the construct of an+b. 11688 // The tokenizer checks for the construct of an+b.
11700 // However, since the {ident} rule precedes the {nth} rule, some of those 11689 // However, since the {ident} rule precedes the {nth} rule, some of those
11701 // tokens are identified as string literal. Furthermore we need to accept 11690 // tokens are identified as string literal. Furthermore we need to accept
11702 // "odd" and "even" which does not match to an+b. 11691 // "odd" and "even" which does not match to an+b.
11703 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 11692 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
11704 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 11693 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
11705 } 11694 }
11706 11695
11707 } 11696 }
OLDNEW
« LayoutTests/fast/media/media-descriptor-syntax-01.html ('K') | « Source/core/css/CSSGrammar.y.in ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698