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

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. 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))
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 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 if (m_context.mode != UASheetMode && m_useCounter) 1212 if (m_context.mode != UASheetMode && m_useCounter)
1213 m_useCounter->count(propertyID); 1213 m_useCounter->count(propertyID);
1214 1214
1215 setStyleSheet(contextStyleSheet); 1215 setStyleSheet(contextStyleSheet);
1216 1216
1217 setupParser("@-internal-value ", string, ""); 1217 setupParser("@-internal-value ", string, "");
1218 1218
1219 m_id = propertyID; 1219 m_id = propertyID;
1220 m_important = important; 1220 m_important = important;
1221 1221
1222 cssyyparse(this); 1222 {
1223 StyleDeclarationScope scope(this, declaration);
1224 cssyyparse(this);
1225 }
1223 1226
1224 m_rule = 0; 1227 m_rule = 0;
1225 m_id = CSSPropertyInvalid; 1228 m_id = CSSPropertyInvalid;
1226 1229
1227 bool ok = false; 1230 bool ok = false;
1228 if (m_hasFontFaceOnlyValues) 1231 if (m_hasFontFaceOnlyValues)
1229 deleteFontFaceOnlyValues(); 1232 deleteFontFaceOnlyValues();
1230 if (!m_parsedProperties.isEmpty()) { 1233 if (!m_parsedProperties.isEmpty()) {
1231 ok = true; 1234 ok = true;
1232 declaration->addParsedProperties(m_parsedProperties); 1235 declaration->addParsedProperties(m_parsedProperties);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 setStyleSheet(contextStyleSheet); 1330 setStyleSheet(contextStyleSheet);
1328 1331
1329 m_sourceDataHandler = sourceDataHandler; 1332 m_sourceDataHandler = sourceDataHandler;
1330 1333
1331 setupParser("@-internal-decls ", string, ""); 1334 setupParser("@-internal-decls ", string, "");
1332 if (m_sourceDataHandler) { 1335 if (m_sourceDataHandler) {
1333 m_sourceDataHandler->startRuleHeader(CSSRuleSourceData::STYLE_RULE, 0); 1336 m_sourceDataHandler->startRuleHeader(CSSRuleSourceData::STYLE_RULE, 0);
1334 m_sourceDataHandler->endRuleHeader(1); 1337 m_sourceDataHandler->endRuleHeader(1);
1335 m_sourceDataHandler->startRuleBody(0); 1338 m_sourceDataHandler->startRuleBody(0);
1336 } 1339 }
1337 cssyyparse(this); 1340
1341 {
1342 StyleDeclarationScope scope(this, declaration);
1343 cssyyparse(this);
1344 }
1345
1338 m_rule = 0; 1346 m_rule = 0;
1339 1347
1340 bool ok = false; 1348 bool ok = false;
1341 if (m_hasFontFaceOnlyValues) 1349 if (m_hasFontFaceOnlyValues)
1342 deleteFontFaceOnlyValues(); 1350 deleteFontFaceOnlyValues();
1343 if (!m_parsedProperties.isEmpty()) { 1351 if (!m_parsedProperties.isEmpty()) {
1344 ok = true; 1352 ok = true;
1345 declaration->addParsedProperties(m_parsedProperties); 1353 declaration->addParsedProperties(m_parsedProperties);
1346 clearProperties(); 1354 clearProperties();
1347 } 1355 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1394 size_t unusedEntries = m_parsedProperties.size(); 1402 size_t unusedEntries = m_parsedProperties.size();
1395 Vector<CSSProperty, 256> results(unusedEntries); 1403 Vector<CSSProperty, 256> results(unusedEntries);
1396 1404
1397 // Important properties have higher priority, so add them first. Duplicate d efinitions can then be ignored when found. 1405 // Important properties have higher priority, so add them first. Duplicate d efinitions can then be ignored when found.
1398 HashSet<AtomicString> seenVariables; 1406 HashSet<AtomicString> seenVariables;
1399 filterProperties(true, m_parsedProperties, results, unusedEntries, seenPrope rties, seenVariables); 1407 filterProperties(true, m_parsedProperties, results, unusedEntries, seenPrope rties, seenVariables);
1400 filterProperties(false, m_parsedProperties, results, unusedEntries, seenProp erties, seenVariables); 1408 filterProperties(false, m_parsedProperties, results, unusedEntries, seenProp erties, seenVariables);
1401 if (unusedEntries) 1409 if (unusedEntries)
1402 results.remove(0, unusedEntries); 1410 results.remove(0, unusedEntries);
1403 1411
1404 return ImmutableStylePropertySet::create(results.data(), results.size(), m_c ontext.mode); 1412 CSSParserMode mode = inViewport() ? ViewportMode : m_context.mode;
1413
1414 return ImmutableStylePropertySet::create(results.data(), results.size(), mod e);
1405 } 1415 }
1406 1416
1407 void CSSParser::addPropertyWithPrefixingVariant(CSSPropertyID propId, PassRefPtr <CSSValue> value, bool important, bool implicit) 1417 void CSSParser::addPropertyWithPrefixingVariant(CSSPropertyID propId, PassRefPtr <CSSValue> value, bool important, bool implicit)
1408 { 1418 {
1409 RefPtr<CSSValue> val = value.get(); 1419 RefPtr<CSSValue> val = value.get();
1410 addProperty(propId, value, important, implicit); 1420 addProperty(propId, value, important, implicit);
1411 1421
1412 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(propId); 1422 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(propId);
1413 if (prefixingVariant == propId) 1423 if (prefixingVariant == propId)
1414 return; 1424 return;
(...skipping 10576 matching lines...) Expand 10 before | Expand all | Expand 10 after
11991 { 12001 {
11992 // The tokenizer checks for the construct of an+b. 12002 // The tokenizer checks for the construct of an+b.
11993 // However, since the {ident} rule precedes the {nth} rule, some of those 12003 // However, since the {ident} rule precedes the {nth} rule, some of those
11994 // tokens are identified as string literal. Furthermore we need to accept 12004 // tokens are identified as string literal. Furthermore we need to accept
11995 // "odd" and "even" which does not match to an+b. 12005 // "odd" and "even" which does not match to an+b.
11996 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") 12006 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even")
11997 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); 12007 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n");
11998 } 12008 }
11999 12009
12000 } 12010 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698