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

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

Issue 19555002: Translate viewport related meta tags into @viewport descriptors as suggested by the CSS Device Adap… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Land patch upload resulted in python error Created 7 years, 5 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 | Annotate | Revision Log
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 2820 matching lines...) Expand 10 before | Expand all | Expand 10 after
2831 case CSSPropertyWebkitUserSelect: 2831 case CSSPropertyWebkitUserSelect:
2832 case CSSPropertyWebkitWrapFlow: 2832 case CSSPropertyWebkitWrapFlow:
2833 case CSSPropertyWebkitWrapThrough: 2833 case CSSPropertyWebkitWrapThrough:
2834 case CSSPropertyWebkitWritingMode: 2834 case CSSPropertyWebkitWritingMode:
2835 case CSSPropertyWhiteSpace: 2835 case CSSPropertyWhiteSpace:
2836 case CSSPropertyWordBreak: 2836 case CSSPropertyWordBreak:
2837 case CSSPropertyWordWrap: 2837 case CSSPropertyWordWrap:
2838 // These properties should be handled before in isValidKeywordPropertyAn dValue(). 2838 // These properties should be handled before in isValidKeywordPropertyAn dValue().
2839 ASSERT_NOT_REACHED(); 2839 ASSERT_NOT_REACHED();
2840 return false; 2840 return false;
2841 // Properties bellow are validated inside parseViewportProperty, because we 2841 // Properties below are validated inside parseViewportProperty, because we
2842 // check for parser state inViewportScope. We need to invalidate if someone 2842 // check for parser state inViewportScope. We need to invalidate if someone
2843 // adds them outside a @viewport rule. 2843 // adds them outside a @viewport rule.
2844 case CSSPropertyMaxZoom: 2844 case CSSPropertyMaxZoom:
2845 case CSSPropertyMinZoom: 2845 case CSSPropertyMinZoom:
2846 case CSSPropertyOrientation: 2846 case CSSPropertyOrientation:
2847 case CSSPropertyUserZoom: 2847 case CSSPropertyUserZoom:
2848 case CSSPropertyInternalPriority:
2848 validPrimitive = false; 2849 validPrimitive = false;
2849 break; 2850 break;
2850 default: 2851 default:
2851 return parseSVGValue(propId, important); 2852 return parseSVGValue(propId, important);
2852 } 2853 }
2853 2854
2854 if (validPrimitive) { 2855 if (validPrimitive) {
2855 parsedValue = parseValidPrimitive(id, value); 2856 parsedValue = parseValidPrimitive(id, value);
2856 m_valueList->next(); 2857 m_valueList->next();
2857 } 2858 }
(...skipping 8538 matching lines...) Expand 10 before | Expand all | Expand 10 after
11396 m_sourceDataHandler->startEndUnknownRule(); 11397 m_sourceDataHandler->startEndUnknownRule();
11397 } 11398 }
11398 11399
11399 unsigned CSSParser::safeUserStringTokenOffset() 11400 unsigned CSSParser::safeUserStringTokenOffset()
11400 { 11401 {
11401 return min(tokenStartOffset(), static_cast<unsigned>(m_length - 1 - m_parsed TextSuffixLength)) - m_parsedTextPrefixLength; 11402 return min(tokenStartOffset(), static_cast<unsigned>(m_length - 1 - m_parsed TextSuffixLength)) - m_parsedTextPrefixLength;
11402 } 11403 }
11403 11404
11404 StyleRuleBase* CSSParser::createViewportRule() 11405 StyleRuleBase* CSSParser::createViewportRule()
11405 { 11406 {
11406 if (!RuntimeEnabledFeatures::cssViewportEnabled())
11407 return 0;
11408
11409 m_allowImportRules = m_allowNamespaceDeclarations = false; 11407 m_allowImportRules = m_allowNamespaceDeclarations = false;
11410 11408
11411 RefPtr<StyleRuleViewport> rule = StyleRuleViewport::create(); 11409 RefPtr<StyleRuleViewport> rule = StyleRuleViewport::create();
11412 11410
11413 rule->setProperties(createStylePropertySet()); 11411 rule->setProperties(createStylePropertySet());
11414 clearProperties(); 11412 clearProperties();
11415 11413
11416 StyleRuleViewport* result = rule.get(); 11414 StyleRuleViewport* result = rule.get();
11417 m_parsedRules.append(rule.release()); 11415 m_parsedRules.append(rule.release());
11418 endRuleBody(); 11416 endRuleBody();
11419 11417
11420 return result; 11418 return result;
11421 } 11419 }
11422 11420
11423 bool CSSParser::parseViewportProperty(CSSPropertyID propId, bool important) 11421 bool CSSParser::parseViewportProperty(CSSPropertyID propId, bool important)
11424 { 11422 {
11425 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled());
11426
11427 CSSParserValue* value = m_valueList->current(); 11423 CSSParserValue* value = m_valueList->current();
11428 if (!value) 11424 if (!value)
11429 return false; 11425 return false;
11430 11426
11431 CSSValueID id = value->id; 11427 CSSValueID id = value->id;
11432 bool validPrimitive = false; 11428 bool validPrimitive = false;
11433 11429
11434 switch (propId) { 11430 switch (propId) {
11431 case CSSPropertyInternalPriority:
11432 if (id == CSSValueAuto)
11433 validPrimitive = true;
11434 else
11435 validPrimitive = (!id && validUnit(value, FNumber | FNonNeg));
11436 break;
11435 case CSSPropertyMinWidth: // auto | extend-to-zoom | <length> | <percentage> 11437 case CSSPropertyMinWidth: // auto | extend-to-zoom | <length> | <percentage>
11436 case CSSPropertyMaxWidth: 11438 case CSSPropertyMaxWidth:
11437 case CSSPropertyMinHeight: 11439 case CSSPropertyMinHeight:
11438 case CSSPropertyMaxHeight: 11440 case CSSPropertyMaxHeight:
11439 if (id == CSSValueAuto || id == CSSValueInternalExtendToZoom) 11441 if (id == CSSValueAuto || id == CSSValueInternalExtendToZoom)
11440 validPrimitive = true; 11442 validPrimitive = true;
11441 else 11443 else
11442 validPrimitive = (!id && validUnit(value, FLength | FPercent | FNonN eg)); 11444 validPrimitive = (!id && validUnit(value, FLength | FPercent | FNonN eg));
11443 break; 11445 break;
11444 case CSSPropertyWidth: // shorthand 11446 case CSSPropertyWidth: // shorthand
(...skipping 30 matching lines...) Expand all
11475 addProperty(propId, parsedValue.release(), important); 11477 addProperty(propId, parsedValue.release(), important);
11476 return true; 11478 return true;
11477 } 11479 }
11478 } 11480 }
11479 11481
11480 return false; 11482 return false;
11481 } 11483 }
11482 11484
11483 bool CSSParser::parseViewportShorthand(CSSPropertyID propId, CSSPropertyID first , CSSPropertyID second, bool important) 11485 bool CSSParser::parseViewportShorthand(CSSPropertyID propId, CSSPropertyID first , CSSPropertyID second, bool important)
11484 { 11486 {
11485 ASSERT(RuntimeEnabledFeatures::cssViewportEnabled());
11486 unsigned numValues = m_valueList->size(); 11487 unsigned numValues = m_valueList->size();
11487 11488
11488 if (numValues > 2) 11489 if (numValues > 2)
11489 return false; 11490 return false;
11490 11491
11491 ShorthandScope scope(this, propId); 11492 ShorthandScope scope(this, propId);
11492 11493
11493 if (!parseViewportProperty(first, important)) 11494 if (!parseViewportProperty(first, important))
11494 return false; 11495 return false;
11495 11496
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
11740 { 11741 {
11741 // The tokenizer checks for the construct of an+b. 11742 // The tokenizer checks for the construct of an+b.
11742 // However, since the {ident} rule precedes the {nth} rule, some of those 11743 // However, since the {ident} rule precedes the {nth} rule, some of those
11743 // tokens are identified as string literal. Furthermore we need to accept 11744 // tokens are identified as string literal. Furthermore we need to accept
11744 // "odd" and "even" which does not match to an+b. 11745 // "odd" and "even" which does not match to an+b.
11745 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 11746 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
11746 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 11747 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
11747 } 11748 }
11748 11749
11749 } 11750 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698