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 1757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1768 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceS
eparated(); | 1768 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceS
eparated(); |
1769 values->append(CSSURIValue::create(url)); | 1769 values->append(CSSURIValue::create(url)); |
1770 values->append(parsedValue); | 1770 values->append(parsedValue); |
1771 return values.release(); | 1771 return values.release(); |
1772 } | 1772 } |
1773 return CSSURIValue::create(url); | 1773 return CSSURIValue::create(url); |
1774 } | 1774 } |
1775 return consumeColor(range, context); | 1775 return consumeColor(range, context); |
1776 } | 1776 } |
1777 | 1777 |
| 1778 static PassRefPtrWillBeRawPtr<CSSValue> consumePaintOrder(CSSParserTokenRange& r
ange) |
| 1779 { |
| 1780 if (range.peek().id() == CSSValueNormal) |
| 1781 return consumeIdent(range); |
| 1782 |
| 1783 Vector<CSSValueID, 3> paintTypeList; |
| 1784 RefPtrWillBeRawPtr<CSSPrimitiveValue> fill = nullptr; |
| 1785 RefPtrWillBeRawPtr<CSSPrimitiveValue> stroke = nullptr; |
| 1786 RefPtrWillBeRawPtr<CSSPrimitiveValue> markers = nullptr; |
| 1787 do { |
| 1788 CSSValueID id = range.peek().id(); |
| 1789 if (id == CSSValueFill && !fill) |
| 1790 fill = consumeIdent(range); |
| 1791 else if (id == CSSValueStroke && !stroke) |
| 1792 stroke = consumeIdent(range); |
| 1793 else if (id == CSSValueMarkers && !markers) |
| 1794 markers = consumeIdent(range); |
| 1795 else |
| 1796 return nullptr; |
| 1797 paintTypeList.append(id); |
| 1798 } while (!range.atEnd()); |
| 1799 |
| 1800 // After parsing we serialize the paint-order list. Since it is not possible
to |
| 1801 // pop a last list items from CSSValueList without bigger cost, we create th
e |
| 1802 // list after parsing. |
| 1803 CSSValueID firstPaintOrderType = paintTypeList.at(0); |
| 1804 RefPtrWillBeRawPtr<CSSValueList> paintOrderList = CSSValueList::createSpaceS
eparated(); |
| 1805 switch (firstPaintOrderType) { |
| 1806 case CSSValueFill: |
| 1807 case CSSValueStroke: |
| 1808 paintOrderList->append(firstPaintOrderType == CSSValueFill ? fill.releas
e() : stroke.release()); |
| 1809 if (paintTypeList.size() > 1) { |
| 1810 if (paintTypeList.at(1) == CSSValueMarkers) |
| 1811 paintOrderList->append(markers.release()); |
| 1812 } |
| 1813 break; |
| 1814 case CSSValueMarkers: |
| 1815 paintOrderList->append(markers.release()); |
| 1816 if (paintTypeList.size() > 1) { |
| 1817 if (paintTypeList.at(1) == CSSValueStroke) |
| 1818 paintOrderList->append(stroke.release()); |
| 1819 } |
| 1820 break; |
| 1821 default: |
| 1822 ASSERT_NOT_REACHED(); |
| 1823 } |
| 1824 |
| 1825 return paintOrderList.release(); |
| 1826 } |
| 1827 |
1778 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty
ID unresolvedProperty) | 1828 PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty
ID unresolvedProperty) |
1779 { | 1829 { |
1780 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); | 1830 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); |
1781 m_range.consumeWhitespace(); | 1831 m_range.consumeWhitespace(); |
1782 switch (property) { | 1832 switch (property) { |
1783 case CSSPropertyWillChange: | 1833 case CSSPropertyWillChange: |
1784 return consumeWillChange(m_range); | 1834 return consumeWillChange(m_range); |
1785 case CSSPropertyPage: | 1835 case CSSPropertyPage: |
1786 return consumePage(m_range); | 1836 return consumePage(m_range); |
1787 case CSSPropertyQuotes: | 1837 case CSSPropertyQuotes: |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1922 return consumeOutlineColor(m_range, m_context); | 1972 return consumeOutlineColor(m_range, m_context); |
1923 case CSSPropertyOutlineOffset: | 1973 case CSSPropertyOutlineOffset: |
1924 return consumeLength(m_range, m_context.mode(), ValueRangeAll); | 1974 return consumeLength(m_range, m_context.mode(), ValueRangeAll); |
1925 case CSSPropertyOutlineWidth: | 1975 case CSSPropertyOutlineWidth: |
1926 return consumeLineWidth(m_range, m_context.mode()); | 1976 return consumeLineWidth(m_range, m_context.mode()); |
1927 case CSSPropertyTransform: | 1977 case CSSPropertyTransform: |
1928 return consumeTransform(m_range, m_context.mode(), unresolvedProperty ==
CSSPropertyAliasWebkitTransform); | 1978 return consumeTransform(m_range, m_context.mode(), unresolvedProperty ==
CSSPropertyAliasWebkitTransform); |
1929 case CSSPropertyFill: | 1979 case CSSPropertyFill: |
1930 case CSSPropertyStroke: | 1980 case CSSPropertyStroke: |
1931 return consumePaint(m_range, m_context); | 1981 return consumePaint(m_range, m_context); |
| 1982 case CSSPropertyPaintOrder: |
| 1983 return consumePaintOrder(m_range); |
1932 default: | 1984 default: |
1933 return nullptr; | 1985 return nullptr; |
1934 } | 1986 } |
1935 } | 1987 } |
1936 | 1988 |
1937 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse
rTokenRange& range) | 1989 static PassRefPtrWillBeRawPtr<CSSValueList> consumeFontFaceUnicodeRange(CSSParse
rTokenRange& range) |
1938 { | 1990 { |
1939 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated
(); | 1991 RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createCommaSeparated
(); |
1940 | 1992 |
1941 do { | 1993 do { |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2419 return consumeShorthandGreedily(webkitBorderAfterShorthand(), important)
; | 2471 return consumeShorthandGreedily(webkitBorderAfterShorthand(), important)
; |
2420 case CSSPropertyWebkitTextStroke: | 2472 case CSSPropertyWebkitTextStroke: |
2421 return consumeShorthandGreedily(webkitTextStrokeShorthand(), important); | 2473 return consumeShorthandGreedily(webkitTextStrokeShorthand(), important); |
2422 default: | 2474 default: |
2423 m_currentShorthand = oldShorthand; | 2475 m_currentShorthand = oldShorthand; |
2424 return false; | 2476 return false; |
2425 } | 2477 } |
2426 } | 2478 } |
2427 | 2479 |
2428 } // namespace blink | 2480 } // namespace blink |
OLD | NEW |