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

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

Issue 22917005: New parser mode for CSSOM @viewport descriptors. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: More comments added. Created 7 years, 3 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/CSSParser.h ('k') | Source/core/css/CSSParserMode.h » ('j') | 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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 // not represent a double. 536 // not represent a double.
537 bool ok; 537 bool ok;
538 number = charactersToDouble(characters, length, &ok); 538 number = charactersToDouble(characters, length, &ok);
539 return ok; 539 return ok;
540 } 540 }
541 541
542 static bool parseSimpleLengthValue(MutableStylePropertySet* declaration, CSSProp ertyID propertyId, const String& string, bool important, CSSParserMode cssParser Mode) 542 static bool parseSimpleLengthValue(MutableStylePropertySet* declaration, CSSProp ertyID propertyId, const String& string, bool important, CSSParserMode cssParser Mode)
543 { 543 {
544 ASSERT(!string.isEmpty()); 544 ASSERT(!string.isEmpty());
545 bool acceptsNegativeNumbers; 545 bool acceptsNegativeNumbers;
546 if (!isSimpleLengthPropertyID(propertyId, acceptsNegativeNumbers)) 546 // In ViewportMode, width and height are shorthands, not simple length value s.
547 if (cssParserMode == ViewportMode || !isSimpleLengthPropertyID(propertyId, a cceptsNegativeNumbers))
547 return false; 548 return false;
548 549
549 unsigned length = string.length(); 550 unsigned length = string.length();
550 double number; 551 double number;
551 CSSPrimitiveValue::UnitTypes unit = CSSPrimitiveValue::CSS_NUMBER; 552 CSSPrimitiveValue::UnitTypes unit = CSSPrimitiveValue::CSS_NUMBER;
552 553
553 if (string.is8Bit()) { 554 if (string.is8Bit()) {
554 if (!parseSimpleLength(string.characters8(), length, unit, number)) 555 if (!parseSimpleLength(string.characters8(), length, unit, number))
555 return false; 556 return false;
556 } else { 557 } else {
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 if (m_context.mode != UASheetMode && m_useCounter) 1213 if (m_context.mode != UASheetMode && m_useCounter)
1213 m_useCounter->count(propertyID); 1214 m_useCounter->count(propertyID);
1214 1215
1215 setStyleSheet(contextStyleSheet); 1216 setStyleSheet(contextStyleSheet);
1216 1217
1217 setupParser("@-internal-value ", string, ""); 1218 setupParser("@-internal-value ", string, "");
1218 1219
1219 m_id = propertyID; 1220 m_id = propertyID;
1220 m_important = important; 1221 m_important = important;
1221 1222
1222 cssyyparse(this); 1223 {
1224 StyleDeclarationScope scope(this, declaration);
1225 cssyyparse(this);
1226 }
1223 1227
1224 m_rule = 0; 1228 m_rule = 0;
1225 m_id = CSSPropertyInvalid; 1229 m_id = CSSPropertyInvalid;
1226 1230
1227 bool ok = false; 1231 bool ok = false;
1228 if (m_hasFontFaceOnlyValues) 1232 if (m_hasFontFaceOnlyValues)
1229 deleteFontFaceOnlyValues(); 1233 deleteFontFaceOnlyValues();
1230 if (!m_parsedProperties.isEmpty()) { 1234 if (!m_parsedProperties.isEmpty()) {
1231 ok = true; 1235 ok = true;
1232 declaration->addParsedProperties(m_parsedProperties); 1236 declaration->addParsedProperties(m_parsedProperties);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 setStyleSheet(contextStyleSheet); 1331 setStyleSheet(contextStyleSheet);
1328 1332
1329 m_sourceDataHandler = sourceDataHandler; 1333 m_sourceDataHandler = sourceDataHandler;
1330 1334
1331 setupParser("@-internal-decls ", string, ""); 1335 setupParser("@-internal-decls ", string, "");
1332 if (m_sourceDataHandler) { 1336 if (m_sourceDataHandler) {
1333 m_sourceDataHandler->startRuleHeader(CSSRuleSourceData::STYLE_RULE, 0); 1337 m_sourceDataHandler->startRuleHeader(CSSRuleSourceData::STYLE_RULE, 0);
1334 m_sourceDataHandler->endRuleHeader(1); 1338 m_sourceDataHandler->endRuleHeader(1);
1335 m_sourceDataHandler->startRuleBody(0); 1339 m_sourceDataHandler->startRuleBody(0);
1336 } 1340 }
1337 cssyyparse(this); 1341
1342 {
1343 StyleDeclarationScope scope(this, declaration);
1344 cssyyparse(this);
1345 }
1346
1338 m_rule = 0; 1347 m_rule = 0;
1339 1348
1340 bool ok = false; 1349 bool ok = false;
1341 if (m_hasFontFaceOnlyValues) 1350 if (m_hasFontFaceOnlyValues)
1342 deleteFontFaceOnlyValues(); 1351 deleteFontFaceOnlyValues();
1343 if (!m_parsedProperties.isEmpty()) { 1352 if (!m_parsedProperties.isEmpty()) {
1344 ok = true; 1353 ok = true;
1345 declaration->addParsedProperties(m_parsedProperties); 1354 declaration->addParsedProperties(m_parsedProperties);
1346 clearProperties(); 1355 clearProperties();
1347 } 1356 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1394 size_t unusedEntries = m_parsedProperties.size(); 1403 size_t unusedEntries = m_parsedProperties.size();
1395 Vector<CSSProperty, 256> results(unusedEntries); 1404 Vector<CSSProperty, 256> results(unusedEntries);
1396 1405
1397 // Important properties have higher priority, so add them first. Duplicate d efinitions can then be ignored when found. 1406 // Important properties have higher priority, so add them first. Duplicate d efinitions can then be ignored when found.
1398 HashSet<AtomicString> seenVariables; 1407 HashSet<AtomicString> seenVariables;
1399 filterProperties(true, m_parsedProperties, results, unusedEntries, seenPrope rties, seenVariables); 1408 filterProperties(true, m_parsedProperties, results, unusedEntries, seenPrope rties, seenVariables);
1400 filterProperties(false, m_parsedProperties, results, unusedEntries, seenProp erties, seenVariables); 1409 filterProperties(false, m_parsedProperties, results, unusedEntries, seenProp erties, seenVariables);
1401 if (unusedEntries) 1410 if (unusedEntries)
1402 results.remove(0, unusedEntries); 1411 results.remove(0, unusedEntries);
1403 1412
1404 return ImmutableStylePropertySet::create(results.data(), results.size(), m_c ontext.mode); 1413 CSSParserMode mode = inViewport() ? ViewportMode : m_context.mode;
1414
1415 return ImmutableStylePropertySet::create(results.data(), results.size(), mod e);
1405 } 1416 }
1406 1417
1407 void CSSParser::addPropertyWithPrefixingVariant(CSSPropertyID propId, PassRefPtr <CSSValue> value, bool important, bool implicit) 1418 void CSSParser::addPropertyWithPrefixingVariant(CSSPropertyID propId, PassRefPtr <CSSValue> value, bool important, bool implicit)
1408 { 1419 {
1409 RefPtr<CSSValue> val = value.get(); 1420 RefPtr<CSSValue> val = value.get();
1410 addProperty(propId, value, important, implicit); 1421 addProperty(propId, value, important, implicit);
1411 1422
1412 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(propId); 1423 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(propId);
1413 if (prefixingVariant == propId) 1424 if (prefixingVariant == propId)
1414 return; 1425 return;
(...skipping 10576 matching lines...) Expand 10 before | Expand all | Expand 10 after
11991 { 12002 {
11992 // The tokenizer checks for the construct of an+b. 12003 // The tokenizer checks for the construct of an+b.
11993 // However, since the {ident} rule precedes the {nth} rule, some of those 12004 // However, since the {ident} rule precedes the {nth} rule, some of those
11994 // tokens are identified as string literal. Furthermore we need to accept 12005 // tokens are identified as string literal. Furthermore we need to accept
11995 // "odd" and "even" which does not match to an+b. 12006 // "odd" and "even" which does not match to an+b.
11996 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 12007 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
11997 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 12008 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
11998 } 12009 }
11999 12010
12000 } 12011 }
OLDNEW
« no previous file with comments | « Source/core/css/CSSParser.h ('k') | Source/core/css/CSSParserMode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698