OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/css/parser/CSSPropertyParser.h" | 6 #include "core/css/parser/CSSPropertyParser.h" |
7 | 7 |
8 #include "core/StylePropertyShorthand.h" | 8 #include "core/StylePropertyShorthand.h" |
9 #include "core/css/CSSCalculationValue.h" | 9 #include "core/css/CSSCalculationValue.h" |
10 #include "core/css/CSSCustomIdentValue.h" | 10 #include "core/css/CSSCustomIdentValue.h" |
11 #include "core/css/CSSFontFaceSrcValue.h" | 11 #include "core/css/CSSFontFaceSrcValue.h" |
12 #include "core/css/CSSFontFeatureValue.h" | 12 #include "core/css/CSSFontFeatureValue.h" |
13 #include "core/css/CSSFunctionValue.h" | 13 #include "core/css/CSSFunctionValue.h" |
14 #include "core/css/CSSPathValue.h" | |
14 #include "core/css/CSSPrimitiveValueMappings.h" | 15 #include "core/css/CSSPrimitiveValueMappings.h" |
15 #include "core/css/CSSQuadValue.h" | 16 #include "core/css/CSSQuadValue.h" |
16 #include "core/css/CSSSVGDocumentValue.h" | 17 #include "core/css/CSSSVGDocumentValue.h" |
17 #include "core/css/CSSShadowValue.h" | 18 #include "core/css/CSSShadowValue.h" |
18 #include "core/css/CSSStringValue.h" | 19 #include "core/css/CSSStringValue.h" |
19 #include "core/css/CSSTimingFunctionValue.h" | 20 #include "core/css/CSSTimingFunctionValue.h" |
20 #include "core/css/CSSURIValue.h" | 21 #include "core/css/CSSURIValue.h" |
21 #include "core/css/CSSUnicodeRangeValue.h" | 22 #include "core/css/CSSUnicodeRangeValue.h" |
22 #include "core/css/CSSValuePair.h" | 23 #include "core/css/CSSValuePair.h" |
23 #include "core/css/CSSValuePool.h" | 24 #include "core/css/CSSValuePool.h" |
24 #include "core/css/FontFace.h" | 25 #include "core/css/FontFace.h" |
25 #include "core/css/parser/CSSParserFastPaths.h" | 26 #include "core/css/parser/CSSParserFastPaths.h" |
26 #include "core/css/parser/CSSParserValues.h" | 27 #include "core/css/parser/CSSParserValues.h" |
27 #include "core/frame/UseCounter.h" | 28 #include "core/frame/UseCounter.h" |
28 #include "core/layout/LayoutTheme.h" | 29 #include "core/layout/LayoutTheme.h" |
30 #include "core/svg/SVGPathUtilities.h" | |
29 #include "wtf/text/StringBuilder.h" | 31 #include "wtf/text/StringBuilder.h" |
30 | 32 |
31 namespace blink { | 33 namespace blink { |
32 | 34 |
33 CSSPropertyParser::CSSPropertyParser(CSSParserValueList* valueList, const CSSPar serTokenRange& range, | 35 CSSPropertyParser::CSSPropertyParser(CSSParserValueList* valueList, const CSSPar serTokenRange& range, |
34 const CSSParserContext& context, WillBeHeapVector<CSSProperty, 256>& parsedP roperties, | 36 const CSSParserContext& context, WillBeHeapVector<CSSProperty, 256>& parsedP roperties, |
35 StyleRule::Type ruleType) | 37 StyleRule::Type ruleType) |
36 : m_valueList(valueList) | 38 : m_valueList(valueList) |
37 , m_range(range) | 39 , m_range(range) |
38 , m_context(context) | 40 , m_context(context) |
(...skipping 1376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1415 RefPtrWillBeRawPtr<CSSValueList> shadowValueList = CSSValueList::createComma Separated(); | 1417 RefPtrWillBeRawPtr<CSSValueList> shadowValueList = CSSValueList::createComma Separated(); |
1416 do { | 1418 do { |
1417 if (RefPtrWillBeRawPtr<CSSShadowValue> shadowValue = parseSingleShadow(r ange, context, isBoxShadowProperty, isBoxShadowProperty)) | 1419 if (RefPtrWillBeRawPtr<CSSShadowValue> shadowValue = parseSingleShadow(r ange, context, isBoxShadowProperty, isBoxShadowProperty)) |
1418 shadowValueList->append(shadowValue.release()); | 1420 shadowValueList->append(shadowValue.release()); |
1419 else | 1421 else |
1420 return nullptr; | 1422 return nullptr; |
1421 } while (consumeCommaIncludingWhitespace(range)); | 1423 } while (consumeCommaIncludingWhitespace(range)); |
1422 return shadowValueList; | 1424 return shadowValueList; |
1423 } | 1425 } |
1424 | 1426 |
1425 static PassRefPtrWillBeRawPtr<CSSFunctionValue> consumeFilterFunction(CSSParserT okenRange& range, const CSSParserContext& context) | 1427 static PassRefPtrWillBeRawPtr<CSSFunctionValue> consumeFilterFunction(CSSParserT okenRange& range, const CSSParserContext& context) |
1426 { | 1428 { |
1427 CSSValueID filterType = range.peek().functionId(); | 1429 CSSValueID filterType = range.peek().functionId(); |
1428 if (filterType < CSSValueInvert || filterType > CSSValueDropShadow) | 1430 if (filterType < CSSValueInvert || filterType > CSSValueDropShadow) |
1429 return nullptr; | 1431 return nullptr; |
1430 CSSParserTokenRange args = consumeFunction(range); | 1432 CSSParserTokenRange args = consumeFunction(range); |
1431 RefPtrWillBeRawPtr<CSSFunctionValue> filterValue = CSSFunctionValue::create( filterType); | 1433 RefPtrWillBeRawPtr<CSSFunctionValue> filterValue = CSSFunctionValue::create( filterType); |
1432 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; | 1434 RefPtrWillBeRawPtr<CSSValue> parsedValue = nullptr; |
1433 | 1435 |
1434 if (filterType == CSSValueDropShadow) { | 1436 if (filterType == CSSValueDropShadow) { |
1435 parsedValue = parseSingleShadow(args, context, false, false); | 1437 parsedValue = parseSingleShadow(args, context, false, false); |
(...skipping 21 matching lines...) Expand all Loading... | |
1457 return nullptr; | 1459 return nullptr; |
1458 } | 1460 } |
1459 } | 1461 } |
1460 } | 1462 } |
1461 if (!parsedValue || !args.atEnd()) | 1463 if (!parsedValue || !args.atEnd()) |
1462 return nullptr; | 1464 return nullptr; |
1463 filterValue->append(parsedValue.release()); | 1465 filterValue->append(parsedValue.release()); |
1464 return filterValue.release(); | 1466 return filterValue.release(); |
1465 } | 1467 } |
1466 | 1468 |
1467 static PassRefPtrWillBeRawPtr<CSSValue> consumeFilter(CSSParserTokenRange& range , const CSSParserContext& context) | 1469 static PassRefPtrWillBeRawPtr<CSSValue> consumeFilter(CSSParserTokenRange& range , const CSSParserContext& context) |
1468 { | 1470 { |
1469 if (range.peek().id() == CSSValueNone) | 1471 if (range.peek().id() == CSSValueNone) |
1470 return consumeIdent(range); | 1472 return consumeIdent(range); |
1471 | 1473 |
1472 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; | 1474 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; |
1473 do { | 1475 do { |
1474 String url = consumeUrl(range); | 1476 String url = consumeUrl(range); |
1475 RefPtrWillBeRawPtr<CSSFunctionValue> filterValue = nullptr; | 1477 RefPtrWillBeRawPtr<CSSFunctionValue> filterValue = nullptr; |
1476 if (!url.isNull()) { | 1478 if (!url.isNull()) { |
1477 filterValue = CSSFunctionValue::create(CSSValueUrl); | 1479 filterValue = CSSFunctionValue::create(CSSValueUrl); |
1478 filterValue->append(CSSSVGDocumentValue::create(url)); | 1480 filterValue->append(CSSSVGDocumentValue::create(url)); |
1479 } else { | 1481 } else { |
1480 filterValue = consumeFilterFunction(range, context); | 1482 filterValue = consumeFilterFunction(range, context); |
1481 if (!filterValue) | 1483 if (!filterValue) |
1482 return nullptr; | 1484 return nullptr; |
1483 } | 1485 } |
1484 list->append(filterValue.release()); | 1486 list->append(filterValue.release()); |
1485 } while (!range.atEnd()); | 1487 } while (!range.atEnd()); |
1486 | 1488 |
1487 return list.release(); | 1489 return list.release(); |
1488 } | 1490 } |
1489 | 1491 |
1492 static PassRefPtrWillBeRawPtr<CSSValue> consumeMotionPath(CSSParserTokenRange& r ange) | |
1493 { | |
1494 CSSValueID id = range.peek().id(); | |
1495 if (id == CSSValueNone) | |
1496 return consumeIdent(range); | |
1497 | |
1498 // FIXME: Add support for <url>, <basic-shape>, <geometry-box>. | |
1499 if (range.peek().functionId() != CSSValuePath) | |
1500 return nullptr; | |
1501 | |
1502 // FIXME: Add support for <fill-rule>. | |
1503 CSSParserTokenRange functionRange = range; | |
1504 CSSParserTokenRange functionArgs = consumeFunction(functionRange); | |
1505 | |
1506 if (functionArgs.peek().type() != StringToken) | |
1507 return nullptr; | |
1508 String pathString = functionArgs.consumeIncludingWhitespace().value(); | |
1509 Path path; | |
1510 if (!buildPathFromString(pathString, path) || !functionArgs.atEnd()) | |
1511 return nullptr; | |
1512 | |
1513 range = functionRange; | |
1514 return CSSPathValue::create(pathString); | |
1515 } | |
1516 | |
1517 static bool consumeMotionKeywordOrAngle(CSSParserTokenRange& range, CSSParserMod e cssParserMode, RefPtrWillBeRawPtr<CSSValue>& keyword, RefPtrWillBeRawPtr<CSSVa lue>& angle) | |
1518 { | |
1519 CSSValueID id = range.peek().id(); | |
1520 if ((id == CSSValueAuto || id == CSSValueReverse) && !keyword) | |
1521 keyword = consumeIdent(range); | |
1522 else if (!angle) | |
1523 angle = consumeAngle(range, cssParserMode); | |
1524 else | |
1525 return false; | |
Timothy Loh
2015/11/04 04:18:28
btw we'd never actually get here on the first call
| |
1526 return true; | |
1527 } | |
1528 | |
1529 static PassRefPtrWillBeRawPtr<CSSValue> consumeMotionRotation(CSSParserTokenRang e& range, CSSParserMode cssParserMode) | |
1530 { | |
1531 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated() ; | |
Timothy Loh
2015/11/04 04:18:27
let's define this where it's used instead of at th
| |
1532 | |
1533 RefPtrWillBeRawPtr<CSSValue> keyword = nullptr; | |
Timothy Loh
2015/11/04 04:18:27
Another option, WDYT?
RefPtrWillBeRawPtr<CSSValue
| |
1534 RefPtrWillBeRawPtr<CSSValue> angle = nullptr; | |
1535 if (!consumeMotionKeywordOrAngle(range, cssParserMode, keyword, angle)) | |
1536 return nullptr; | |
1537 consumeMotionKeywordOrAngle(range, cssParserMode, keyword, angle); | |
1538 | |
1539 if (keyword) | |
1540 list->append(keyword.release()); | |
1541 if (angle) | |
1542 list->append(angle.release()); | |
1543 return list.release(); | |
1544 } | |
1545 | |
1490 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID unresolvedProperty) | 1546 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ID unresolvedProperty) |
1491 { | 1547 { |
1492 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); | 1548 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); |
1493 m_range.consumeWhitespace(); | 1549 m_range.consumeWhitespace(); |
1494 switch (property) { | 1550 switch (property) { |
1495 case CSSPropertyWillChange: | 1551 case CSSPropertyWillChange: |
1496 return consumeWillChange(m_range); | 1552 return consumeWillChange(m_range); |
1497 case CSSPropertyPage: | 1553 case CSSPropertyPage: |
1498 return consumePage(m_range); | 1554 return consumePage(m_range); |
1499 case CSSPropertyQuotes: | 1555 case CSSPropertyQuotes: |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1590 case CSSPropertyColor: | 1646 case CSSPropertyColor: |
1591 return consumeColor(m_range, m_context, inQuirksMode()); | 1647 return consumeColor(m_range, m_context, inQuirksMode()); |
1592 case CSSPropertyZIndex: | 1648 case CSSPropertyZIndex: |
1593 return consumeZIndex(m_range); | 1649 return consumeZIndex(m_range); |
1594 case CSSPropertyTextShadow: // CSS2 property, dropped in CSS2.1, back in CSS 3, so treat as CSS3 | 1650 case CSSPropertyTextShadow: // CSS2 property, dropped in CSS2.1, back in CSS 3, so treat as CSS3 |
1595 case CSSPropertyBoxShadow: | 1651 case CSSPropertyBoxShadow: |
1596 return consumeShadow(m_range, m_context, property == CSSPropertyBoxShado w); | 1652 return consumeShadow(m_range, m_context, property == CSSPropertyBoxShado w); |
1597 case CSSPropertyWebkitFilter: | 1653 case CSSPropertyWebkitFilter: |
1598 case CSSPropertyBackdropFilter: | 1654 case CSSPropertyBackdropFilter: |
1599 return consumeFilter(m_range, m_context); | 1655 return consumeFilter(m_range, m_context); |
1656 case CSSPropertyMotionPath: | |
1657 ASSERT(RuntimeEnabledFeatures::cssMotionPathEnabled()); | |
1658 return consumeMotionPath(m_range); | |
1659 case CSSPropertyMotionOffset: | |
1660 ASSERT(RuntimeEnabledFeatures::cssMotionPathEnabled()); | |
1661 return consumeLengthOrPercent(m_range, m_context.mode(), ValueRangeAll); | |
1662 case CSSPropertyMotionRotation: | |
1663 ASSERT(RuntimeEnabledFeatures::cssMotionPathEnabled()); | |
1664 return consumeMotionRotation(m_range, m_context.mode()); | |
1600 default: | 1665 default: |
1601 return nullptr; | 1666 return nullptr; |
1602 } | 1667 } |
1603 } | 1668 } |
1604 | 1669 |
1605 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse rTokenRange& range) | 1670 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse rTokenRange& range) |
1606 { | 1671 { |
1607 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated (); | 1672 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated (); |
1608 | 1673 |
1609 do { | 1674 do { |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2016 return consumeBorderSpacing(important); | 2081 return consumeBorderSpacing(important); |
2017 case CSSPropertyWebkitColumns: { | 2082 case CSSPropertyWebkitColumns: { |
2018 // TODO(rwlbuis): investigate if this shorthand hack can be removed. | 2083 // TODO(rwlbuis): investigate if this shorthand hack can be removed. |
2019 m_currentShorthand = oldShorthand; | 2084 m_currentShorthand = oldShorthand; |
2020 return consumeColumns(important); | 2085 return consumeColumns(important); |
2021 } | 2086 } |
2022 case CSSPropertyAnimation: | 2087 case CSSPropertyAnimation: |
2023 return consumeAnimationShorthand(animationShorthandForParsing(), unresol vedProperty == CSSPropertyAliasWebkitAnimation, important); | 2088 return consumeAnimationShorthand(animationShorthandForParsing(), unresol vedProperty == CSSPropertyAliasWebkitAnimation, important); |
2024 case CSSPropertyTransition: | 2089 case CSSPropertyTransition: |
2025 return consumeAnimationShorthand(transitionShorthandForParsing(), false, important); | 2090 return consumeAnimationShorthand(transitionShorthandForParsing(), false, important); |
2091 case CSSPropertyMotion: | |
2092 ASSERT(RuntimeEnabledFeatures::cssMotionPathEnabled()); | |
2093 return consumeShorthandGreedily(motionShorthand(), important); | |
2026 default: | 2094 default: |
2027 m_currentShorthand = oldShorthand; | 2095 m_currentShorthand = oldShorthand; |
2028 return false; | 2096 return false; |
2029 } | 2097 } |
2030 } | 2098 } |
2031 | 2099 |
2032 } // namespace blink | 2100 } // namespace blink |
OLD | NEW |