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

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: Fixed review issues and added more tests 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
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 if (cssParserMode == ViewportMode || !isSimpleLengthPropertyID(propertyId, a cceptsNegativeNumbers))
eseidel 2013/09/17 16:28:55 So this whole change is to disallow negative numbe
rune 2013/09/17 20:17:03 No. This is to avoid the simple-length-fast-path f
547 return false; 547 return false;
548 548
549 unsigned length = string.length(); 549 unsigned length = string.length();
550 double number; 550 double number;
551 CSSPrimitiveValue::UnitTypes unit = CSSPrimitiveValue::CSS_NUMBER; 551 CSSPrimitiveValue::UnitTypes unit = CSSPrimitiveValue::CSS_NUMBER;
552 552
553 if (string.is8Bit()) { 553 if (string.is8Bit()) {
554 if (!parseSimpleLength(string.characters8(), length, unit, number)) 554 if (!parseSimpleLength(string.characters8(), length, unit, number))
555 return false; 555 return false;
556 } else { 556 } else {
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 if (m_useCounter) 1211 if (m_useCounter)
1212 m_useCounter->count(propertyID); 1212 m_useCounter->count(propertyID);
1213 1213
1214 setStyleSheet(contextStyleSheet); 1214 setStyleSheet(contextStyleSheet);
1215 1215
1216 setupParser("@-internal-value ", string, ""); 1216 setupParser("@-internal-value ", string, "");
1217 1217
1218 m_id = propertyID; 1218 m_id = propertyID;
1219 m_important = important; 1219 m_important = important;
1220 1220
1221 StyleDeclarationScope scope(this, declaration);
1221 cssyyparse(this); 1222 cssyyparse(this);
eseidel 2013/09/17 16:28:55 I might have wrapped this in a block, depending on
rune 2013/09/17 20:17:03 Will do.
rune 2013/09/17 20:40:41 Done.
1222 1223
1223 m_rule = 0; 1224 m_rule = 0;
1224 m_id = CSSPropertyInvalid; 1225 m_id = CSSPropertyInvalid;
1225 1226
1226 bool ok = false; 1227 bool ok = false;
1227 if (m_hasFontFaceOnlyValues) 1228 if (m_hasFontFaceOnlyValues)
1228 deleteFontFaceOnlyValues(); 1229 deleteFontFaceOnlyValues();
1229 if (!m_parsedProperties.isEmpty()) { 1230 if (!m_parsedProperties.isEmpty()) {
1230 ok = true; 1231 ok = true;
1231 declaration->addParsedProperties(m_parsedProperties); 1232 declaration->addParsedProperties(m_parsedProperties);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 setStyleSheet(contextStyleSheet); 1327 setStyleSheet(contextStyleSheet);
1327 1328
1328 m_sourceDataHandler = sourceDataHandler; 1329 m_sourceDataHandler = sourceDataHandler;
1329 1330
1330 setupParser("@-internal-decls ", string, ""); 1331 setupParser("@-internal-decls ", string, "");
1331 if (m_sourceDataHandler) { 1332 if (m_sourceDataHandler) {
1332 m_sourceDataHandler->startRuleHeader(CSSRuleSourceData::STYLE_RULE, 0); 1333 m_sourceDataHandler->startRuleHeader(CSSRuleSourceData::STYLE_RULE, 0);
1333 m_sourceDataHandler->endRuleHeader(1); 1334 m_sourceDataHandler->endRuleHeader(1);
1334 m_sourceDataHandler->startRuleBody(0); 1335 m_sourceDataHandler->startRuleBody(0);
1335 } 1336 }
1337
1338 StyleDeclarationScope scope(this, declaration);
1336 cssyyparse(this); 1339 cssyyparse(this);
1340
1337 m_rule = 0; 1341 m_rule = 0;
1338 1342
1339 bool ok = false; 1343 bool ok = false;
1340 if (m_hasFontFaceOnlyValues) 1344 if (m_hasFontFaceOnlyValues)
1341 deleteFontFaceOnlyValues(); 1345 deleteFontFaceOnlyValues();
1342 if (!m_parsedProperties.isEmpty()) { 1346 if (!m_parsedProperties.isEmpty()) {
1343 ok = true; 1347 ok = true;
1344 declaration->addParsedProperties(m_parsedProperties); 1348 declaration->addParsedProperties(m_parsedProperties);
1345 clearProperties(); 1349 clearProperties();
1346 } 1350 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1393 size_t unusedEntries = m_parsedProperties.size(); 1397 size_t unusedEntries = m_parsedProperties.size();
1394 Vector<CSSProperty, 256> results(unusedEntries); 1398 Vector<CSSProperty, 256> results(unusedEntries);
1395 1399
1396 // Important properties have higher priority, so add them first. Duplicate d efinitions can then be ignored when found. 1400 // Important properties have higher priority, so add them first. Duplicate d efinitions can then be ignored when found.
1397 HashSet<AtomicString> seenVariables; 1401 HashSet<AtomicString> seenVariables;
1398 filterProperties(true, m_parsedProperties, results, unusedEntries, seenPrope rties, seenVariables); 1402 filterProperties(true, m_parsedProperties, results, unusedEntries, seenPrope rties, seenVariables);
1399 filterProperties(false, m_parsedProperties, results, unusedEntries, seenProp erties, seenVariables); 1403 filterProperties(false, m_parsedProperties, results, unusedEntries, seenProp erties, seenVariables);
1400 if (unusedEntries) 1404 if (unusedEntries)
1401 results.remove(0, unusedEntries); 1405 results.remove(0, unusedEntries);
1402 1406
1403 return ImmutableStylePropertySet::create(results.data(), results.size(), m_c ontext.mode); 1407 CSSParserMode mode = inViewport() ? ViewportMode : m_context.mode;
1408
1409 return ImmutableStylePropertySet::create(results.data(), results.size(), mod e);
1404 } 1410 }
1405 1411
1406 void CSSParser::addPropertyWithPrefixingVariant(CSSPropertyID propId, PassRefPtr <CSSValue> value, bool important, bool implicit) 1412 void CSSParser::addPropertyWithPrefixingVariant(CSSPropertyID propId, PassRefPtr <CSSValue> value, bool important, bool implicit)
1407 { 1413 {
1408 RefPtr<CSSValue> val = value.get(); 1414 RefPtr<CSSValue> val = value.get();
1409 addProperty(propId, value, important, implicit); 1415 addProperty(propId, value, important, implicit);
1410 1416
1411 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(propId); 1417 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(propId);
1412 if (prefixingVariant == propId) 1418 if (prefixingVariant == propId)
1413 return; 1419 return;
(...skipping 10575 matching lines...) Expand 10 before | Expand all | Expand 10 after
11989 { 11995 {
11990 // The tokenizer checks for the construct of an+b. 11996 // The tokenizer checks for the construct of an+b.
11991 // However, since the {ident} rule precedes the {nth} rule, some of those 11997 // However, since the {ident} rule precedes the {nth} rule, some of those
11992 // tokens are identified as string literal. Furthermore we need to accept 11998 // tokens are identified as string literal. Furthermore we need to accept
11993 // "odd" and "even" which does not match to an+b. 11999 // "odd" and "even" which does not match to an+b.
11994 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 12000 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
11995 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 12001 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
11996 } 12002 }
11997 12003
11998 } 12004 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698