| 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" |
| (...skipping 1498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1509 if (!list->length()) | 1509 if (!list->length()) |
| 1510 return nullptr; | 1510 return nullptr; |
| 1511 return list.release(); | 1511 return list.release(); |
| 1512 } | 1512 } |
| 1513 | 1513 |
| 1514 static PassRefPtrWillBeRawPtr<CSSValue> consumeMotionPath(CSSParserTokenRange& r
ange) | 1514 static PassRefPtrWillBeRawPtr<CSSValue> consumeMotionPath(CSSParserTokenRange& r
ange) |
| 1515 { | 1515 { |
| 1516 CSSValueID id = range.peek().id(); | 1516 CSSValueID id = range.peek().id(); |
| 1517 if (id == CSSValueNone) | 1517 if (id == CSSValueNone) |
| 1518 return consumeIdent(range); | 1518 return consumeIdent(range); |
| 1519 | |
| 1520 // FIXME: Add support for <url>, <basic-shape>, <geometry-box>. | 1519 // FIXME: Add support for <url>, <basic-shape>, <geometry-box>. |
| 1521 if (range.peek().functionId() != CSSValuePath) | 1520 if (range.peek().functionId() != CSSValuePath) |
| 1522 return nullptr; | 1521 return nullptr; |
| 1523 | 1522 |
| 1524 // FIXME: Add support for <fill-rule>. | 1523 // FIXME: Add support for <fill-rule>. |
| 1525 CSSParserTokenRange functionRange = range; | 1524 CSSParserTokenRange functionRange = range; |
| 1526 CSSParserTokenRange functionArgs = consumeFunction(functionRange); | 1525 CSSParserTokenRange functionArgs = consumeFunction(functionRange); |
| 1527 | 1526 |
| 1528 if (functionArgs.peek().type() != StringToken) | 1527 if (functionArgs.peek().type() != StringToken) |
| 1529 return nullptr; | 1528 return nullptr; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1547 angle = consumeAngle(range, cssParserMode); | 1546 angle = consumeAngle(range, cssParserMode); |
| 1548 | 1547 |
| 1549 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; | 1548 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSpaceSeparated()
; |
| 1550 if (keyword) | 1549 if (keyword) |
| 1551 list->append(keyword.release()); | 1550 list->append(keyword.release()); |
| 1552 if (angle) | 1551 if (angle) |
| 1553 list->append(angle.release()); | 1552 list->append(angle.release()); |
| 1554 return list.release(); | 1553 return list.release(); |
| 1555 } | 1554 } |
| 1556 | 1555 |
| 1556 static PassRefPtrWillBeRawPtr<CSSValue> consumeTextEmphasisStyle(CSSParserTokenR
ange& range) |
| 1557 { |
| 1558 CSSValueID id = range.peek().id(); |
| 1559 if (id == CSSValueNone) |
| 1560 return consumeIdent(range); |
| 1561 |
| 1562 if (RefPtrWillBeRawPtr<CSSValue> textEmphasisStyle = consumeString(range)) |
| 1563 return textEmphasisStyle.release(); |
| 1564 |
| 1565 RefPtrWillBeRawPtr<CSSPrimitiveValue> fill = consumeIdent<CSSValueFilled, CS
SValueOpen>(range); |
| 1566 RefPtrWillBeRawPtr<CSSPrimitiveValue> shape = consumeIdent<CSSValueDot, CSSV
alueCircle, CSSValueDoubleCircle, CSSValueTriangle, CSSValueSesame>(range); |
| 1567 if (!fill) |
| 1568 fill = consumeIdent<CSSValueFilled, CSSValueOpen>(range); |
| 1569 if (fill && shape) { |
| 1570 RefPtrWillBeRawPtr<CSSValueList> parsedValues = CSSValueList::createSpac
eSeparated(); |
| 1571 parsedValues->append(fill.release()); |
| 1572 parsedValues->append(shape.release()); |
| 1573 return parsedValues.release(); |
| 1574 } |
| 1575 if (fill) |
| 1576 return fill.release(); |
| 1577 if (shape) |
| 1578 return shape.release(); |
| 1579 return nullptr; |
| 1580 } |
| 1581 |
| 1557 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty
ID unresolvedProperty) | 1582 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty
ID unresolvedProperty) |
| 1558 { | 1583 { |
| 1559 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); | 1584 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); |
| 1560 m_range.consumeWhitespace(); | 1585 m_range.consumeWhitespace(); |
| 1561 switch (property) { | 1586 switch (property) { |
| 1562 case CSSPropertyWillChange: | 1587 case CSSPropertyWillChange: |
| 1563 return consumeWillChange(m_range); | 1588 return consumeWillChange(m_range); |
| 1564 case CSSPropertyPage: | 1589 case CSSPropertyPage: |
| 1565 return consumePage(m_range); | 1590 return consumePage(m_range); |
| 1566 case CSSPropertyQuotes: | 1591 case CSSPropertyQuotes: |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1649 case CSSPropertyTransitionTimingFunction: | 1674 case CSSPropertyTransitionTimingFunction: |
| 1650 return consumeAnimationPropertyList(property, m_range, m_context, unreso
lvedProperty == CSSPropertyAliasWebkitAnimationName); | 1675 return consumeAnimationPropertyList(property, m_range, m_context, unreso
lvedProperty == CSSPropertyAliasWebkitAnimationName); |
| 1651 case CSSPropertyOrphans: | 1676 case CSSPropertyOrphans: |
| 1652 case CSSPropertyWidows: | 1677 case CSSPropertyWidows: |
| 1653 return consumeWidowsOrOrphans(m_range); | 1678 return consumeWidowsOrOrphans(m_range); |
| 1654 case CSSPropertyTextDecorationColor: | 1679 case CSSPropertyTextDecorationColor: |
| 1655 ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled()); | 1680 ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled()); |
| 1656 return consumeColor(m_range, m_context); | 1681 return consumeColor(m_range, m_context); |
| 1657 case CSSPropertyWebkitTextFillColor: | 1682 case CSSPropertyWebkitTextFillColor: |
| 1658 case CSSPropertyWebkitTapHighlightColor: | 1683 case CSSPropertyWebkitTapHighlightColor: |
| 1684 case CSSPropertyWebkitTextEmphasisColor: |
| 1659 return consumeColor(m_range, m_context); | 1685 return consumeColor(m_range, m_context); |
| 1660 case CSSPropertyColor: | 1686 case CSSPropertyColor: |
| 1661 return consumeColor(m_range, m_context, inQuirksMode()); | 1687 return consumeColor(m_range, m_context, inQuirksMode()); |
| 1662 case CSSPropertyZIndex: | 1688 case CSSPropertyZIndex: |
| 1663 return consumeZIndex(m_range); | 1689 return consumeZIndex(m_range); |
| 1664 case CSSPropertyTextShadow: // CSS2 property, dropped in CSS2.1, back in CSS
3, so treat as CSS3 | 1690 case CSSPropertyTextShadow: // CSS2 property, dropped in CSS2.1, back in CSS
3, so treat as CSS3 |
| 1665 case CSSPropertyBoxShadow: | 1691 case CSSPropertyBoxShadow: |
| 1666 return consumeShadow(m_range, m_context, property == CSSPropertyBoxShado
w); | 1692 return consumeShadow(m_range, m_context, property == CSSPropertyBoxShado
w); |
| 1667 case CSSPropertyWebkitFilter: | 1693 case CSSPropertyWebkitFilter: |
| 1668 case CSSPropertyBackdropFilter: | 1694 case CSSPropertyBackdropFilter: |
| 1669 return consumeFilter(m_range, m_context); | 1695 return consumeFilter(m_range, m_context); |
| 1670 case CSSPropertyWebkitTextDecorationsInEffect: | 1696 case CSSPropertyWebkitTextDecorationsInEffect: |
| 1671 case CSSPropertyTextDecorationLine: | 1697 case CSSPropertyTextDecorationLine: |
| 1672 return consumeTextDecorationLine(m_range); | 1698 return consumeTextDecorationLine(m_range); |
| 1673 case CSSPropertyMotionPath: | 1699 case CSSPropertyMotionPath: |
| 1674 ASSERT(RuntimeEnabledFeatures::cssMotionPathEnabled()); | 1700 ASSERT(RuntimeEnabledFeatures::cssMotionPathEnabled()); |
| 1675 return consumeMotionPath(m_range); | 1701 return consumeMotionPath(m_range); |
| 1676 case CSSPropertyMotionOffset: | 1702 case CSSPropertyMotionOffset: |
| 1677 ASSERT(RuntimeEnabledFeatures::cssMotionPathEnabled()); | 1703 ASSERT(RuntimeEnabledFeatures::cssMotionPathEnabled()); |
| 1678 return consumeLengthOrPercent(m_range, m_context.mode(), ValueRangeAll); | 1704 return consumeLengthOrPercent(m_range, m_context.mode(), ValueRangeAll); |
| 1679 case CSSPropertyMotionRotation: | 1705 case CSSPropertyMotionRotation: |
| 1680 ASSERT(RuntimeEnabledFeatures::cssMotionPathEnabled()); | 1706 ASSERT(RuntimeEnabledFeatures::cssMotionPathEnabled()); |
| 1681 return consumeMotionRotation(m_range, m_context.mode()); | 1707 return consumeMotionRotation(m_range, m_context.mode()); |
| 1708 case CSSPropertyWebkitTextEmphasisStyle: |
| 1709 return consumeTextEmphasisStyle(m_range); |
| 1682 default: | 1710 default: |
| 1683 return nullptr; | 1711 return nullptr; |
| 1684 } | 1712 } |
| 1685 } | 1713 } |
| 1686 | 1714 |
| 1687 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse
rTokenRange& range) | 1715 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse
rTokenRange& range) |
| 1688 { | 1716 { |
| 1689 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated
(); | 1717 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated
(); |
| 1690 | 1718 |
| 1691 do { | 1719 do { |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2148 m_currentShorthand = oldShorthand; | 2176 m_currentShorthand = oldShorthand; |
| 2149 RefPtrWillBeRawPtr<CSSValue> textDecoration = consumeTextDecorationLine(
m_range); | 2177 RefPtrWillBeRawPtr<CSSValue> textDecoration = consumeTextDecorationLine(
m_range); |
| 2150 if (!textDecoration || !m_range.atEnd()) | 2178 if (!textDecoration || !m_range.atEnd()) |
| 2151 return false; | 2179 return false; |
| 2152 addProperty(CSSPropertyTextDecoration, textDecoration.release(), importa
nt); | 2180 addProperty(CSSPropertyTextDecoration, textDecoration.release(), importa
nt); |
| 2153 return true; | 2181 return true; |
| 2154 } | 2182 } |
| 2155 case CSSPropertyMotion: | 2183 case CSSPropertyMotion: |
| 2156 ASSERT(RuntimeEnabledFeatures::cssMotionPathEnabled()); | 2184 ASSERT(RuntimeEnabledFeatures::cssMotionPathEnabled()); |
| 2157 return consumeShorthandGreedily(motionShorthand(), important); | 2185 return consumeShorthandGreedily(motionShorthand(), important); |
| 2186 case CSSPropertyWebkitTextEmphasis: |
| 2187 return consumeShorthandGreedily(webkitTextEmphasisShorthand(), important
); |
| 2158 default: | 2188 default: |
| 2159 m_currentShorthand = oldShorthand; | 2189 m_currentShorthand = oldShorthand; |
| 2160 return false; | 2190 return false; |
| 2161 } | 2191 } |
| 2162 } | 2192 } |
| 2163 | 2193 |
| 2164 } // namespace blink | 2194 } // namespace blink |
| OLD | NEW |