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); |
(...skipping 20 matching lines...) Expand all Loading... |
1498 if (list->hasValue(ident.get())) | 1500 if (list->hasValue(ident.get())) |
1499 return nullptr; | 1501 return nullptr; |
1500 list->append(ident.release()); | 1502 list->append(ident.release()); |
1501 } | 1503 } |
1502 | 1504 |
1503 if (!list->length()) | 1505 if (!list->length()) |
1504 return nullptr; | 1506 return nullptr; |
1505 return list.release(); | 1507 return list.release(); |
1506 } | 1508 } |
1507 | 1509 |
| 1510 static PassRefPtrWillBeRawPtr<CSSValue> consumeMotionPath(CSSParserTokenRange& r
ange) |
| 1511 { |
| 1512 CSSValueID id = range.peek().id(); |
| 1513 if (id == CSSValueNone) |
| 1514 return consumeIdent(range); |
| 1515 |
| 1516 // FIXME: Add support for <url>, <basic-shape>, <geometry-box>. |
| 1517 if (range.peek().functionId() != CSSValuePath) |
| 1518 return nullptr; |
| 1519 |
| 1520 // FIXME: Add support for <fill-rule>. |
| 1521 CSSParserTokenRange functionRange = range; |
| 1522 CSSParserTokenRange functionArgs = consumeFunction(functionRange); |
| 1523 |
| 1524 if (functionArgs.peek().type() != StringToken) |
| 1525 return nullptr; |
| 1526 String pathString = functionArgs.consumeIncludingWhitespace().value(); |
| 1527 Path path; |
| 1528 if (!buildPathFromString(pathString, path) || !functionArgs.atEnd()) |
| 1529 return nullptr; |
| 1530 |
| 1531 range = functionRange; |
| 1532 return CSSPathValue::create(pathString); |
| 1533 } |
| 1534 |
| 1535 static PassRefPtrWillBeRawPtr<CSSValue> consumeMotionRotation(CSSParserTokenRang
e& range, CSSParserMode cssParserMode) |
| 1536 { |
| 1537 RefPtrWillBeRawPtr<CSSValue> angle = consumeAngle(range, cssParserMode); |
| 1538 RefPtrWillBeRawPtr<CSSValue> keyword = consumeIdent<CSSValueAuto, CSSValueRe
verse>(range); |
| 1539 if (!angle && !keyword) |
| 1540 return nullptr; |
| 1541 |
| 1542 if (!angle) |
| 1543 angle = consumeAngle(range, cssParserMode); |
| 1544 |
| 1545 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; |
| 1546 if (keyword) |
| 1547 list->append(keyword.release()); |
| 1548 if (angle) |
| 1549 list->append(angle.release()); |
| 1550 return list.release(); |
| 1551 } |
| 1552 |
1508 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty
ID unresolvedProperty) | 1553 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty
ID unresolvedProperty) |
1509 { | 1554 { |
1510 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); | 1555 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); |
1511 m_range.consumeWhitespace(); | 1556 m_range.consumeWhitespace(); |
1512 switch (property) { | 1557 switch (property) { |
1513 case CSSPropertyWillChange: | 1558 case CSSPropertyWillChange: |
1514 return consumeWillChange(m_range); | 1559 return consumeWillChange(m_range); |
1515 case CSSPropertyPage: | 1560 case CSSPropertyPage: |
1516 return consumePage(m_range); | 1561 return consumePage(m_range); |
1517 case CSSPropertyQuotes: | 1562 case CSSPropertyQuotes: |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1614 return consumeZIndex(m_range); | 1659 return consumeZIndex(m_range); |
1615 case CSSPropertyTextShadow: // CSS2 property, dropped in CSS2.1, back in CSS
3, so treat as CSS3 | 1660 case CSSPropertyTextShadow: // CSS2 property, dropped in CSS2.1, back in CSS
3, so treat as CSS3 |
1616 case CSSPropertyBoxShadow: | 1661 case CSSPropertyBoxShadow: |
1617 return consumeShadow(m_range, m_context, property == CSSPropertyBoxShado
w); | 1662 return consumeShadow(m_range, m_context, property == CSSPropertyBoxShado
w); |
1618 case CSSPropertyWebkitFilter: | 1663 case CSSPropertyWebkitFilter: |
1619 case CSSPropertyBackdropFilter: | 1664 case CSSPropertyBackdropFilter: |
1620 return consumeFilter(m_range, m_context); | 1665 return consumeFilter(m_range, m_context); |
1621 case CSSPropertyWebkitTextDecorationsInEffect: | 1666 case CSSPropertyWebkitTextDecorationsInEffect: |
1622 case CSSPropertyTextDecorationLine: | 1667 case CSSPropertyTextDecorationLine: |
1623 return consumeTextDecorationLine(m_range); | 1668 return consumeTextDecorationLine(m_range); |
| 1669 case CSSPropertyMotionPath: |
| 1670 ASSERT(RuntimeEnabledFeatures::cssMotionPathEnabled()); |
| 1671 return consumeMotionPath(m_range); |
| 1672 case CSSPropertyMotionOffset: |
| 1673 ASSERT(RuntimeEnabledFeatures::cssMotionPathEnabled()); |
| 1674 return consumeLengthOrPercent(m_range, m_context.mode(), ValueRangeAll); |
| 1675 case CSSPropertyMotionRotation: |
| 1676 ASSERT(RuntimeEnabledFeatures::cssMotionPathEnabled()); |
| 1677 return consumeMotionRotation(m_range, m_context.mode()); |
1624 default: | 1678 default: |
1625 return nullptr; | 1679 return nullptr; |
1626 } | 1680 } |
1627 } | 1681 } |
1628 | 1682 |
1629 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse
rTokenRange& range) | 1683 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse
rTokenRange& range) |
1630 { | 1684 { |
1631 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated
(); | 1685 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated
(); |
1632 | 1686 |
1633 do { | 1687 do { |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2085 // Fall through 'text-decoration-line' parsing if CSS 3 Text Decoration | 2139 // Fall through 'text-decoration-line' parsing if CSS 3 Text Decoration |
2086 // is disabled to match CSS 2.1 rules for parsing 'text-decoration'. | 2140 // is disabled to match CSS 2.1 rules for parsing 'text-decoration'. |
2087 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) | 2141 if (RuntimeEnabledFeatures::css3TextDecorationsEnabled()) |
2088 return consumeShorthandGreedily(textDecorationShorthand(), important
); | 2142 return consumeShorthandGreedily(textDecorationShorthand(), important
); |
2089 RefPtrWillBeRawPtr<CSSValue> textDecoration = consumeTextDecorationLine(
m_range); | 2143 RefPtrWillBeRawPtr<CSSValue> textDecoration = consumeTextDecorationLine(
m_range); |
2090 if (!textDecoration || !m_range.atEnd()) | 2144 if (!textDecoration || !m_range.atEnd()) |
2091 return false; | 2145 return false; |
2092 addProperty(CSSPropertyTextDecoration, textDecoration.release(), importa
nt); | 2146 addProperty(CSSPropertyTextDecoration, textDecoration.release(), importa
nt); |
2093 return true; | 2147 return true; |
2094 } | 2148 } |
| 2149 case CSSPropertyMotion: |
| 2150 ASSERT(RuntimeEnabledFeatures::cssMotionPathEnabled()); |
| 2151 return consumeShorthandGreedily(motionShorthand(), important); |
2095 default: | 2152 default: |
2096 m_currentShorthand = oldShorthand; | 2153 m_currentShorthand = oldShorthand; |
2097 return false; | 2154 return false; |
2098 } | 2155 } |
2099 } | 2156 } |
2100 | 2157 |
2101 } // namespace blink | 2158 } // namespace blink |
OLD | NEW |