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

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

Issue 15878013: Tokenize "and(" as a FUNCTION in media queries. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 6 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 | « LayoutTests/fast/media/media-query-list-syntax.html ('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 /* 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 10297 matching lines...) Expand 10 before | Expand all | Expand 10 after
10308 m_token = IDENT; 10308 m_token = IDENT;
10309 10309
10310 if (UNLIKELY(*currentCharacter<SrcCharacterType>() == '(')) { 10310 if (UNLIKELY(*currentCharacter<SrcCharacterType>() == '(')) {
10311 if (m_parsingMode == SupportsMode && !hasEscape) { 10311 if (m_parsingMode == SupportsMode && !hasEscape) {
10312 detectSupportsToken<SrcCharacterType>(result - tokenStart<SrcCha racterType>()); 10312 detectSupportsToken<SrcCharacterType>(result - tokenStart<SrcCha racterType>());
10313 if (m_token != IDENT) 10313 if (m_token != IDENT)
10314 break; 10314 break;
10315 } 10315 }
10316 10316
10317 m_token = FUNCTION; 10317 m_token = FUNCTION;
10318 bool shouldSkipParenthesis = true; 10318 if (!hasEscape)
10319 if (!hasEscape) { 10319 detectFunctionTypeToken<SrcCharacterType>(result - tokenStart<Sr cCharacterType>());
10320 bool detected = detectFunctionTypeToken<SrcCharacterType>(result - tokenStart<SrcCharacterType>());
10321 if (!detected && m_parsingMode == MediaQueryMode) {
10322 // ... and(max-width: 480px) ... looks like a function, but in fact it is not,
10323 // so run more detection code in the MediaQueryMode.
10324 detectMediaQueryToken<SrcCharacterType>(result - tokenStart< SrcCharacterType>());
10325 if (m_token == MEDIA_AND)
10326 shouldSkipParenthesis = false;
10327 }
10328 }
10329 10320
10330 if (LIKELY(shouldSkipParenthesis)) { 10321 // Skip parenthesis
10331 ++currentCharacter<SrcCharacterType>(); 10322 ++currentCharacter<SrcCharacterType>();
10332 ++result; 10323 ++result;
10333 ++yylval->string.m_length; 10324 ++yylval->string.m_length;
10334 }
10335 10325
10336 if (token() == URI) { 10326 if (token() == URI) {
10337 m_token = FUNCTION; 10327 m_token = FUNCTION;
10338 // Check whether it is really an URI. 10328 // Check whether it is really an URI.
10339 if (yylval->string.is8Bit()) 10329 if (yylval->string.is8Bit())
10340 parseURI<LChar>(yylval->string); 10330 parseURI<LChar>(yylval->string);
10341 else 10331 else
10342 parseURI<UChar>(yylval->string); 10332 parseURI<UChar>(yylval->string);
10343 } 10333 }
10344 } else if (UNLIKELY(m_parsingMode != NormalMode) && !hasEscape) { 10334 } else if (UNLIKELY(m_parsingMode != NormalMode) && !hasEscape) {
(...skipping 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after
11760 { 11750 {
11761 // The tokenizer checks for the construct of an+b. 11751 // The tokenizer checks for the construct of an+b.
11762 // However, since the {ident} rule precedes the {nth} rule, some of those 11752 // However, since the {ident} rule precedes the {nth} rule, some of those
11763 // tokens are identified as string literal. Furthermore we need to accept 11753 // tokens are identified as string literal. Furthermore we need to accept
11764 // "odd" and "even" which does not match to an+b. 11754 // "odd" and "even" which does not match to an+b.
11765 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 11755 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
11766 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 11756 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
11767 } 11757 }
11768 11758
11769 } 11759 }
OLDNEW
« no previous file with comments | « LayoutTests/fast/media/media-query-list-syntax.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698