Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 524 // not represent a double. | 524 // not represent a double. |
| 525 bool ok; | 525 bool ok; |
| 526 number = charactersToDouble(characters, length, &ok); | 526 number = charactersToDouble(characters, length, &ok); |
| 527 return ok; | 527 return ok; |
| 528 } | 528 } |
| 529 | 529 |
| 530 static bool parseSimpleLengthValue(MutableStylePropertySet* declaration, CSSProp ertyID propertyId, const String& string, bool important, CSSParserMode cssParser Mode) | 530 static bool parseSimpleLengthValue(MutableStylePropertySet* declaration, CSSProp ertyID propertyId, const String& string, bool important, CSSParserMode cssParser Mode) |
| 531 { | 531 { |
| 532 ASSERT(!string.isEmpty()); | 532 ASSERT(!string.isEmpty()); |
| 533 bool acceptsNegativeNumbers; | 533 bool acceptsNegativeNumbers; |
| 534 if (!isSimpleLengthPropertyID(propertyId, acceptsNegativeNumbers)) | 534 if (cssParserMode == ViewportMode || !isSimpleLengthPropertyID(propertyId, a cceptsNegativeNumbers)) |
| 535 return false; | 535 return false; |
| 536 | 536 |
| 537 unsigned length = string.length(); | 537 unsigned length = string.length(); |
| 538 double number; | 538 double number; |
| 539 CSSPrimitiveValue::UnitTypes unit = CSSPrimitiveValue::CSS_NUMBER; | 539 CSSPrimitiveValue::UnitTypes unit = CSSPrimitiveValue::CSS_NUMBER; |
| 540 | 540 |
| 541 if (string.is8Bit()) { | 541 if (string.is8Bit()) { |
| 542 if (!parseSimpleLength(string.characters8(), length, unit, number)) | 542 if (!parseSimpleLength(string.characters8(), length, unit, number)) |
| 543 return false; | 543 return false; |
| 544 } else { | 544 } else { |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1189 if (m_useCounter) | 1189 if (m_useCounter) |
| 1190 m_useCounter->count(propertyID); | 1190 m_useCounter->count(propertyID); |
| 1191 | 1191 |
| 1192 setStyleSheet(contextStyleSheet); | 1192 setStyleSheet(contextStyleSheet); |
| 1193 | 1193 |
| 1194 setupParser("@-internal-value ", string, ""); | 1194 setupParser("@-internal-value ", string, ""); |
| 1195 | 1195 |
| 1196 m_id = propertyID; | 1196 m_id = propertyID; |
| 1197 m_important = important; | 1197 m_important = important; |
| 1198 | 1198 |
| 1199 if (declaration->cssParserMode() == ViewportMode) | |
| 1200 markViewportRuleBodyStart(); | |
|
eseidel
2013/09/10 16:33:58
Bleh. Do we need a helper function around cssyypa
rune
2013/09/12 13:05:01
Did an RAII.
| |
| 1201 | |
| 1199 cssyyparse(this); | 1202 cssyyparse(this); |
| 1200 | 1203 |
| 1204 if (declaration->cssParserMode() == ViewportMode) | |
| 1205 markViewportRuleBodyEnd(); | |
| 1206 | |
| 1201 m_rule = 0; | 1207 m_rule = 0; |
| 1202 m_id = CSSPropertyInvalid; | 1208 m_id = CSSPropertyInvalid; |
| 1203 | 1209 |
| 1204 bool ok = false; | 1210 bool ok = false; |
| 1205 if (m_hasFontFaceOnlyValues) | 1211 if (m_hasFontFaceOnlyValues) |
| 1206 deleteFontFaceOnlyValues(); | 1212 deleteFontFaceOnlyValues(); |
| 1207 if (!m_parsedProperties.isEmpty()) { | 1213 if (!m_parsedProperties.isEmpty()) { |
| 1208 ok = true; | 1214 ok = true; |
| 1209 declaration->addParsedProperties(m_parsedProperties); | 1215 declaration->addParsedProperties(m_parsedProperties); |
| 1210 clearProperties(); | 1216 clearProperties(); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1304 setStyleSheet(contextStyleSheet); | 1310 setStyleSheet(contextStyleSheet); |
| 1305 | 1311 |
| 1306 m_sourceDataHandler = sourceDataHandler; | 1312 m_sourceDataHandler = sourceDataHandler; |
| 1307 | 1313 |
| 1308 setupParser("@-internal-decls ", string, ""); | 1314 setupParser("@-internal-decls ", string, ""); |
| 1309 if (m_sourceDataHandler) { | 1315 if (m_sourceDataHandler) { |
| 1310 m_sourceDataHandler->startRuleHeader(CSSRuleSourceData::STYLE_RULE, 0); | 1316 m_sourceDataHandler->startRuleHeader(CSSRuleSourceData::STYLE_RULE, 0); |
| 1311 m_sourceDataHandler->endRuleHeader(1); | 1317 m_sourceDataHandler->endRuleHeader(1); |
| 1312 m_sourceDataHandler->startRuleBody(0); | 1318 m_sourceDataHandler->startRuleBody(0); |
| 1313 } | 1319 } |
| 1320 | |
| 1321 if (declaration->cssParserMode() == ViewportMode) | |
| 1322 markViewportRuleBodyStart(); | |
| 1323 | |
| 1314 cssyyparse(this); | 1324 cssyyparse(this); |
| 1325 | |
| 1326 if (declaration->cssParserMode() == ViewportMode) | |
| 1327 markViewportRuleBodyEnd(); | |
| 1328 | |
| 1315 m_rule = 0; | 1329 m_rule = 0; |
| 1316 | 1330 |
| 1317 bool ok = false; | 1331 bool ok = false; |
| 1318 if (m_hasFontFaceOnlyValues) | 1332 if (m_hasFontFaceOnlyValues) |
| 1319 deleteFontFaceOnlyValues(); | 1333 deleteFontFaceOnlyValues(); |
| 1320 if (!m_parsedProperties.isEmpty()) { | 1334 if (!m_parsedProperties.isEmpty()) { |
| 1321 ok = true; | 1335 ok = true; |
| 1322 declaration->addParsedProperties(m_parsedProperties); | 1336 declaration->addParsedProperties(m_parsedProperties); |
| 1323 clearProperties(); | 1337 clearProperties(); |
| 1324 } | 1338 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1371 size_t unusedEntries = m_parsedProperties.size(); | 1385 size_t unusedEntries = m_parsedProperties.size(); |
| 1372 Vector<CSSProperty, 256> results(unusedEntries); | 1386 Vector<CSSProperty, 256> results(unusedEntries); |
| 1373 | 1387 |
| 1374 // Important properties have higher priority, so add them first. Duplicate d efinitions can then be ignored when found. | 1388 // Important properties have higher priority, so add them first. Duplicate d efinitions can then be ignored when found. |
| 1375 HashSet<AtomicString> seenVariables; | 1389 HashSet<AtomicString> seenVariables; |
| 1376 filterProperties(true, m_parsedProperties, results, unusedEntries, seenPrope rties, seenVariables); | 1390 filterProperties(true, m_parsedProperties, results, unusedEntries, seenPrope rties, seenVariables); |
| 1377 filterProperties(false, m_parsedProperties, results, unusedEntries, seenProp erties, seenVariables); | 1391 filterProperties(false, m_parsedProperties, results, unusedEntries, seenProp erties, seenVariables); |
| 1378 if (unusedEntries) | 1392 if (unusedEntries) |
| 1379 results.remove(0, unusedEntries); | 1393 results.remove(0, unusedEntries); |
| 1380 | 1394 |
| 1381 return ImmutableStylePropertySet::create(results.data(), results.size(), m_c ontext.mode); | 1395 CSSParserMode mode = inViewport() ? ViewportMode : m_context.mode; |
| 1396 | |
| 1397 return ImmutableStylePropertySet::create(results.data(), results.size(), mod e); | |
| 1382 } | 1398 } |
| 1383 | 1399 |
| 1384 void CSSParser::addPropertyWithPrefixingVariant(CSSPropertyID propId, PassRefPtr <CSSValue> value, bool important, bool implicit) | 1400 void CSSParser::addPropertyWithPrefixingVariant(CSSPropertyID propId, PassRefPtr <CSSValue> value, bool important, bool implicit) |
| 1385 { | 1401 { |
| 1386 RefPtr<CSSValue> val = value.get(); | 1402 RefPtr<CSSValue> val = value.get(); |
| 1387 addProperty(propId, value, important, implicit); | 1403 addProperty(propId, value, important, implicit); |
| 1388 | 1404 |
| 1389 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(propId); | 1405 CSSPropertyID prefixingVariant = prefixingVariantForPropertyId(propId); |
| 1390 if (prefixingVariant == propId) | 1406 if (prefixingVariant == propId) |
| 1391 return; | 1407 return; |
| (...skipping 10528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11920 { | 11936 { |
| 11921 // The tokenizer checks for the construct of an+b. | 11937 // The tokenizer checks for the construct of an+b. |
| 11922 // However, since the {ident} rule precedes the {nth} rule, some of those | 11938 // However, since the {ident} rule precedes the {nth} rule, some of those |
| 11923 // tokens are identified as string literal. Furthermore we need to accept | 11939 // tokens are identified as string literal. Furthermore we need to accept |
| 11924 // "odd" and "even" which does not match to an+b. | 11940 // "odd" and "even" which does not match to an+b. |
| 11925 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") | 11941 return equalIgnoringCase(token, "odd") || equalIgnoringCase(token, "even") |
| 11926 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); | 11942 || equalIgnoringCase(token, "n") || equalIgnoringCase(token, "-n"); |
| 11927 } | 11943 } |
| 11928 | 11944 |
| 11929 } | 11945 } |
| OLD | NEW |