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 "core/css/parser/CSSPropertyParser.h" | 5 #include "core/css/parser/CSSPropertyParser.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include "core/StylePropertyShorthand.h" | 8 #include "core/StylePropertyShorthand.h" |
9 #include "core/css/CSSBasicShapeValues.h" | 9 #include "core/css/CSSBasicShapeValues.h" |
10 #include "core/css/CSSContentDistributionValue.h" | 10 #include "core/css/CSSContentDistributionValue.h" |
11 #include "core/css/CSSCursorImageValue.h" | 11 #include "core/css/CSSCursorImageValue.h" |
12 #include "core/css/CSSFontFaceSrcValue.h" | 12 #include "core/css/CSSFontFaceSrcValue.h" |
13 #include "core/css/CSSFontFamilyValue.h" | |
14 #include "core/css/CSSFunctionValue.h" | 13 #include "core/css/CSSFunctionValue.h" |
15 #include "core/css/CSSGridAutoRepeatValue.h" | 14 #include "core/css/CSSGridAutoRepeatValue.h" |
16 #include "core/css/CSSGridLineNamesValue.h" | 15 #include "core/css/CSSGridLineNamesValue.h" |
17 #include "core/css/CSSGridTemplateAreasValue.h" | 16 #include "core/css/CSSGridTemplateAreasValue.h" |
18 #include "core/css/CSSIdentifierValue.h" | 17 #include "core/css/CSSIdentifierValue.h" |
19 #include "core/css/CSSInheritedValue.h" | 18 #include "core/css/CSSInheritedValue.h" |
20 #include "core/css/CSSInitialValue.h" | 19 #include "core/css/CSSInitialValue.h" |
21 #include "core/css/CSSPendingSubstitutionValue.h" | 20 #include "core/css/CSSPendingSubstitutionValue.h" |
22 #include "core/css/CSSPrimitiveValueMappings.h" | 21 #include "core/css/CSSPrimitiveValueMappings.h" |
23 #include "core/css/CSSReflectValue.h" | 22 #include "core/css/CSSReflectValue.h" |
24 #include "core/css/CSSShadowValue.h" | 23 #include "core/css/CSSShadowValue.h" |
25 #include "core/css/CSSStringValue.h" | 24 #include "core/css/CSSStringValue.h" |
26 #include "core/css/CSSTimingFunctionValue.h" | 25 #include "core/css/CSSTimingFunctionValue.h" |
27 #include "core/css/CSSURIValue.h" | 26 #include "core/css/CSSURIValue.h" |
28 #include "core/css/CSSUnicodeRangeValue.h" | 27 #include "core/css/CSSUnicodeRangeValue.h" |
29 #include "core/css/CSSUnsetValue.h" | 28 #include "core/css/CSSUnsetValue.h" |
30 #include "core/css/CSSValuePair.h" | 29 #include "core/css/CSSValuePair.h" |
31 #include "core/css/CSSVariableReferenceValue.h" | 30 #include "core/css/CSSVariableReferenceValue.h" |
32 #include "core/css/HashTools.h" | 31 #include "core/css/HashTools.h" |
33 #include "core/css/parser/CSSParserFastPaths.h" | 32 #include "core/css/parser/CSSParserFastPaths.h" |
34 #include "core/css/parser/CSSParserIdioms.h" | 33 #include "core/css/parser/CSSParserIdioms.h" |
35 #include "core/css/parser/CSSParserLocalContext.h" | 34 #include "core/css/parser/CSSParserLocalContext.h" |
36 #include "core/css/parser/CSSPropertyParserHelpers.h" | 35 #include "core/css/parser/CSSPropertyParserHelpers.h" |
37 #include "core/css/parser/CSSVariableParser.h" | 36 #include "core/css/parser/CSSVariableParser.h" |
38 #include "core/css/parser/FontVariantLigaturesParser.h" | |
39 #include "core/css/parser/FontVariantNumericParser.h" | |
40 #include "core/css/properties/CSSPropertyAPIOffsetAnchor.h" | 37 #include "core/css/properties/CSSPropertyAPIOffsetAnchor.h" |
41 #include "core/css/properties/CSSPropertyAPIOffsetPosition.h" | 38 #include "core/css/properties/CSSPropertyAPIOffsetPosition.h" |
42 #include "core/css/properties/CSSPropertyAlignmentUtils.h" | 39 #include "core/css/properties/CSSPropertyAlignmentUtils.h" |
43 #include "core/css/properties/CSSPropertyAnimationIterationCountUtils.h" | 40 #include "core/css/properties/CSSPropertyAnimationIterationCountUtils.h" |
44 #include "core/css/properties/CSSPropertyAnimationNameUtils.h" | 41 #include "core/css/properties/CSSPropertyAnimationNameUtils.h" |
45 #include "core/css/properties/CSSPropertyBorderImageUtils.h" | 42 #include "core/css/properties/CSSPropertyBorderImageUtils.h" |
46 #include "core/css/properties/CSSPropertyColumnUtils.h" | 43 #include "core/css/properties/CSSPropertyColumnUtils.h" |
47 #include "core/css/properties/CSSPropertyDescriptor.h" | 44 #include "core/css/properties/CSSPropertyDescriptor.h" |
48 #include "core/css/properties/CSSPropertyFontUtils.h" | 45 #include "core/css/properties/CSSPropertyFontUtils.h" |
49 #include "core/css/properties/CSSPropertyLengthUtils.h" | 46 #include "core/css/properties/CSSPropertyLengthUtils.h" |
(...skipping 13 matching lines...) Expand all Loading... |
63 class CSSCustomIdentValue; | 60 class CSSCustomIdentValue; |
64 | 61 |
65 CSSPropertyParser::CSSPropertyParser( | 62 CSSPropertyParser::CSSPropertyParser( |
66 const CSSParserTokenRange& range, | 63 const CSSParserTokenRange& range, |
67 const CSSParserContext* context, | 64 const CSSParserContext* context, |
68 HeapVector<CSSProperty, 256>* parsed_properties) | 65 HeapVector<CSSProperty, 256>* parsed_properties) |
69 : range_(range), context_(context), parsed_properties_(parsed_properties) { | 66 : range_(range), context_(context), parsed_properties_(parsed_properties) { |
70 range_.ConsumeWhitespace(); | 67 range_.ConsumeWhitespace(); |
71 } | 68 } |
72 | 69 |
| 70 // AddProperty takes implicit as an enum, below we're using a bool because |
| 71 // AddParsedProperty will be removed after we finish implemenation of property |
| 72 // APIs. |
73 void CSSPropertyParser::AddParsedProperty(CSSPropertyID resolved_property, | 73 void CSSPropertyParser::AddParsedProperty(CSSPropertyID resolved_property, |
74 CSSPropertyID current_shorthand, | 74 CSSPropertyID current_shorthand, |
75 const CSSValue& value, | 75 const CSSValue& value, |
76 bool important, | 76 bool important, |
77 bool implicit) { | 77 bool implicit) { |
78 AddProperty(resolved_property, current_shorthand, value, important, implicit, | 78 AddProperty(resolved_property, current_shorthand, value, important, |
| 79 implicit ? IsImplicitProperty::kImplicit |
| 80 : IsImplicitProperty::kNotImplicit, |
79 *parsed_properties_); | 81 *parsed_properties_); |
80 } | 82 } |
81 | 83 |
82 void CSSPropertyParser::AddExpandedPropertyForValue(CSSPropertyID property, | 84 void CSSPropertyParser::AddExpandedPropertyForValue(CSSPropertyID property, |
83 const CSSValue& value, | 85 const CSSValue& value, |
84 bool important) { | 86 bool important) { |
85 const StylePropertyShorthand& shorthand = shorthandForProperty(property); | 87 const StylePropertyShorthand& shorthand = shorthandForProperty(property); |
86 unsigned shorthand_length = shorthand.length(); | 88 unsigned shorthand_length = shorthand.length(); |
87 DCHECK(shorthand_length); | 89 DCHECK(shorthand_length); |
88 const CSSPropertyID* longhands = shorthand.properties(); | 90 const CSSPropertyID* longhands = shorthand.properties(); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 if (!CSSPropertyMetadata::IsProperty(unresolved_property)) | 276 if (!CSSPropertyMetadata::IsProperty(unresolved_property)) |
275 return false; | 277 return false; |
276 AddParsedProperty(property, CSSPropertyInvalid, *value, important); | 278 AddParsedProperty(property, CSSPropertyInvalid, *value, important); |
277 } else { | 279 } else { |
278 AddExpandedPropertyForValue(property, *value, important); | 280 AddExpandedPropertyForValue(property, *value, important); |
279 } | 281 } |
280 range_ = range_copy; | 282 range_ = range_copy; |
281 return true; | 283 return true; |
282 } | 284 } |
283 | 285 |
284 static CSSIdentifierValue* ConsumeFontVariantCSS21(CSSParserTokenRange& range) { | |
285 return ConsumeIdent<CSSValueNormal, CSSValueSmallCaps>(range); | |
286 } | |
287 | |
288 static CSSValue* ConsumeFontVariantList(CSSParserTokenRange& range) { | 286 static CSSValue* ConsumeFontVariantList(CSSParserTokenRange& range) { |
289 CSSValueList* values = CSSValueList::CreateCommaSeparated(); | 287 CSSValueList* values = CSSValueList::CreateCommaSeparated(); |
290 do { | 288 do { |
291 if (range.Peek().Id() == CSSValueAll) { | 289 if (range.Peek().Id() == CSSValueAll) { |
292 // FIXME: CSSPropertyParser::ParseFontVariant() implements | 290 // FIXME: CSSPropertyParser::ParseFontVariant() implements |
293 // the old css3 draft: | 291 // the old css3 draft: |
294 // http://www.w3.org/TR/2002/WD-css3-webfonts-20020802/#font-variant | 292 // http://www.w3.org/TR/2002/WD-css3-webfonts-20020802/#font-variant |
295 // 'all' is only allowed in @font-face and with no other values. | 293 // 'all' is only allowed in @font-face and with no other values. |
296 if (values->length()) | 294 if (values->length()) |
297 return nullptr; | 295 return nullptr; |
298 return ConsumeIdent(range); | 296 return ConsumeIdent(range); |
299 } | 297 } |
300 CSSIdentifierValue* font_variant = ConsumeFontVariantCSS21(range); | 298 CSSIdentifierValue* font_variant = |
| 299 CSSPropertyFontUtils::ConsumeFontVariantCSS21(range); |
301 if (font_variant) | 300 if (font_variant) |
302 values->Append(*font_variant); | 301 values->Append(*font_variant); |
303 } while (ConsumeCommaIncludingWhitespace(range)); | 302 } while (ConsumeCommaIncludingWhitespace(range)); |
304 | 303 |
305 if (values->length()) | 304 if (values->length()) |
306 return values; | 305 return values; |
307 | 306 |
308 return nullptr; | 307 return nullptr; |
309 } | 308 } |
310 | 309 |
(...skipping 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1795 break; | 1794 break; |
1796 } | 1795 } |
1797 | 1796 |
1798 if (!parsed_value || !range_.AtEnd()) | 1797 if (!parsed_value || !range_.AtEnd()) |
1799 return false; | 1798 return false; |
1800 | 1799 |
1801 AddParsedProperty(prop_id, CSSPropertyInvalid, *parsed_value, false); | 1800 AddParsedProperty(prop_id, CSSPropertyInvalid, *parsed_value, false); |
1802 return true; | 1801 return true; |
1803 } | 1802 } |
1804 | 1803 |
1805 bool CSSPropertyParser::ConsumeSystemFont(bool important) { | |
1806 CSSValueID system_font_id = range_.ConsumeIncludingWhitespace().Id(); | |
1807 DCHECK_GE(system_font_id, CSSValueCaption); | |
1808 DCHECK_LE(system_font_id, CSSValueStatusBar); | |
1809 if (!range_.AtEnd()) | |
1810 return false; | |
1811 | |
1812 FontStyle font_style = kFontStyleNormal; | |
1813 FontWeight font_weight = kFontWeightNormal; | |
1814 float font_size = 0; | |
1815 AtomicString font_family; | |
1816 LayoutTheme::GetTheme().SystemFont(system_font_id, font_style, font_weight, | |
1817 font_size, font_family); | |
1818 | |
1819 AddParsedProperty(CSSPropertyFontStyle, CSSPropertyFont, | |
1820 *CSSIdentifierValue::Create(font_style == kFontStyleItalic | |
1821 ? CSSValueItalic | |
1822 : CSSValueNormal), | |
1823 important); | |
1824 AddParsedProperty(CSSPropertyFontWeight, CSSPropertyFont, | |
1825 *CSSIdentifierValue::Create(font_weight), important); | |
1826 AddParsedProperty(CSSPropertyFontSize, CSSPropertyFont, | |
1827 *CSSPrimitiveValue::Create( | |
1828 font_size, CSSPrimitiveValue::UnitType::kPixels), | |
1829 important); | |
1830 CSSValueList* font_family_list = CSSValueList::CreateCommaSeparated(); | |
1831 font_family_list->Append(*CSSFontFamilyValue::Create(font_family)); | |
1832 AddParsedProperty(CSSPropertyFontFamily, CSSPropertyFont, *font_family_list, | |
1833 important); | |
1834 | |
1835 AddParsedProperty(CSSPropertyFontStretch, CSSPropertyFont, | |
1836 *CSSIdentifierValue::Create(CSSValueNormal), important); | |
1837 AddParsedProperty(CSSPropertyFontVariantCaps, CSSPropertyFont, | |
1838 *CSSIdentifierValue::Create(CSSValueNormal), important); | |
1839 AddParsedProperty(CSSPropertyFontVariantLigatures, CSSPropertyFont, | |
1840 *CSSIdentifierValue::Create(CSSValueNormal), important); | |
1841 AddParsedProperty(CSSPropertyFontVariantNumeric, CSSPropertyFont, | |
1842 *CSSIdentifierValue::Create(CSSValueNormal), important); | |
1843 AddParsedProperty(CSSPropertyLineHeight, CSSPropertyFont, | |
1844 *CSSIdentifierValue::Create(CSSValueNormal), important); | |
1845 return true; | |
1846 } | |
1847 | |
1848 bool CSSPropertyParser::ConsumeFont(bool important) { | |
1849 // Let's check if there is an inherit or initial somewhere in the shorthand. | |
1850 CSSParserTokenRange range = range_; | |
1851 while (!range.AtEnd()) { | |
1852 CSSValueID id = range.ConsumeIncludingWhitespace().Id(); | |
1853 if (id == CSSValueInherit || id == CSSValueInitial) | |
1854 return false; | |
1855 } | |
1856 // Optional font-style, font-variant, font-stretch and font-weight. | |
1857 CSSIdentifierValue* font_style = nullptr; | |
1858 CSSIdentifierValue* font_variant_caps = nullptr; | |
1859 CSSIdentifierValue* font_weight = nullptr; | |
1860 CSSIdentifierValue* font_stretch = nullptr; | |
1861 while (!range_.AtEnd()) { | |
1862 CSSValueID id = range_.Peek().Id(); | |
1863 if (!font_style && CSSParserFastPaths::IsValidKeywordPropertyAndValue( | |
1864 CSSPropertyFontStyle, id, context_->Mode())) { | |
1865 font_style = ConsumeIdent(range_); | |
1866 continue; | |
1867 } | |
1868 if (!font_variant_caps && | |
1869 (id == CSSValueNormal || id == CSSValueSmallCaps)) { | |
1870 // Font variant in the shorthand is particular, it only accepts normal or | |
1871 // small-caps. | |
1872 // See https://drafts.csswg.org/css-fonts/#propdef-font | |
1873 font_variant_caps = ConsumeFontVariantCSS21(range_); | |
1874 if (font_variant_caps) | |
1875 continue; | |
1876 } | |
1877 if (!font_weight) { | |
1878 font_weight = CSSPropertyFontUtils::ConsumeFontWeight(range_); | |
1879 if (font_weight) | |
1880 continue; | |
1881 } | |
1882 if (!font_stretch && CSSParserFastPaths::IsValidKeywordPropertyAndValue( | |
1883 CSSPropertyFontStretch, id, context_->Mode())) | |
1884 font_stretch = ConsumeIdent(range_); | |
1885 else | |
1886 break; | |
1887 } | |
1888 | |
1889 if (range_.AtEnd()) | |
1890 return false; | |
1891 | |
1892 AddParsedProperty( | |
1893 CSSPropertyFontStyle, CSSPropertyFont, | |
1894 font_style ? *font_style : *CSSIdentifierValue::Create(CSSValueNormal), | |
1895 important); | |
1896 AddParsedProperty(CSSPropertyFontVariantCaps, CSSPropertyFont, | |
1897 font_variant_caps | |
1898 ? *font_variant_caps | |
1899 : *CSSIdentifierValue::Create(CSSValueNormal), | |
1900 important); | |
1901 AddParsedProperty(CSSPropertyFontVariantLigatures, CSSPropertyFont, | |
1902 *CSSIdentifierValue::Create(CSSValueNormal), important); | |
1903 AddParsedProperty(CSSPropertyFontVariantNumeric, CSSPropertyFont, | |
1904 *CSSIdentifierValue::Create(CSSValueNormal), important); | |
1905 | |
1906 AddParsedProperty( | |
1907 CSSPropertyFontWeight, CSSPropertyFont, | |
1908 font_weight ? *font_weight : *CSSIdentifierValue::Create(CSSValueNormal), | |
1909 important); | |
1910 AddParsedProperty(CSSPropertyFontStretch, CSSPropertyFont, | |
1911 font_stretch ? *font_stretch | |
1912 : *CSSIdentifierValue::Create(CSSValueNormal), | |
1913 important); | |
1914 | |
1915 // Now a font size _must_ come. | |
1916 CSSValue* font_size = | |
1917 CSSPropertyFontUtils::ConsumeFontSize(range_, context_->Mode()); | |
1918 if (!font_size || range_.AtEnd()) | |
1919 return false; | |
1920 | |
1921 AddParsedProperty(CSSPropertyFontSize, CSSPropertyFont, *font_size, | |
1922 important); | |
1923 | |
1924 if (ConsumeSlashIncludingWhitespace(range_)) { | |
1925 CSSValue* line_height = | |
1926 CSSPropertyFontUtils::ConsumeLineHeight(range_, context_->Mode()); | |
1927 if (!line_height) | |
1928 return false; | |
1929 AddParsedProperty(CSSPropertyLineHeight, CSSPropertyFont, *line_height, | |
1930 important); | |
1931 } else { | |
1932 AddParsedProperty(CSSPropertyLineHeight, CSSPropertyFont, | |
1933 *CSSIdentifierValue::Create(CSSValueNormal), important); | |
1934 } | |
1935 | |
1936 // Font family must come now. | |
1937 CSSValue* parsed_family_value = | |
1938 CSSPropertyFontUtils::ConsumeFontFamily(range_); | |
1939 if (!parsed_family_value) | |
1940 return false; | |
1941 | |
1942 AddParsedProperty(CSSPropertyFontFamily, CSSPropertyFont, | |
1943 *parsed_family_value, important); | |
1944 | |
1945 // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20110324/#font-prop requires | |
1946 // that "font-stretch", "font-size-adjust", and "font-kerning" be reset to | |
1947 // their initial values but we don't seem to support them at the moment. They | |
1948 // should also be added here once implemented. | |
1949 return range_.AtEnd(); | |
1950 } | |
1951 | |
1952 bool CSSPropertyParser::ConsumeFontVariantShorthand(bool important) { | |
1953 if (IdentMatches<CSSValueNormal, CSSValueNone>(range_.Peek().Id())) { | |
1954 AddParsedProperty(CSSPropertyFontVariantLigatures, CSSPropertyFontVariant, | |
1955 *ConsumeIdent(range_), important); | |
1956 AddParsedProperty(CSSPropertyFontVariantCaps, CSSPropertyFontVariant, | |
1957 *CSSIdentifierValue::Create(CSSValueNormal), important); | |
1958 return range_.AtEnd(); | |
1959 } | |
1960 | |
1961 CSSIdentifierValue* caps_value = nullptr; | |
1962 FontVariantLigaturesParser ligatures_parser; | |
1963 FontVariantNumericParser numeric_parser; | |
1964 do { | |
1965 FontVariantLigaturesParser::ParseResult ligatures_parse_result = | |
1966 ligatures_parser.ConsumeLigature(range_); | |
1967 FontVariantNumericParser::ParseResult numeric_parse_result = | |
1968 numeric_parser.ConsumeNumeric(range_); | |
1969 if (ligatures_parse_result == | |
1970 FontVariantLigaturesParser::ParseResult::kConsumedValue || | |
1971 numeric_parse_result == | |
1972 FontVariantNumericParser::ParseResult::kConsumedValue) | |
1973 continue; | |
1974 | |
1975 if (ligatures_parse_result == | |
1976 FontVariantLigaturesParser::ParseResult::kDisallowedValue || | |
1977 numeric_parse_result == | |
1978 FontVariantNumericParser::ParseResult::kDisallowedValue) | |
1979 return false; | |
1980 | |
1981 CSSValueID id = range_.Peek().Id(); | |
1982 switch (id) { | |
1983 case CSSValueSmallCaps: | |
1984 case CSSValueAllSmallCaps: | |
1985 case CSSValuePetiteCaps: | |
1986 case CSSValueAllPetiteCaps: | |
1987 case CSSValueUnicase: | |
1988 case CSSValueTitlingCaps: | |
1989 // Only one caps value permitted in font-variant grammar. | |
1990 if (caps_value) | |
1991 return false; | |
1992 caps_value = ConsumeIdent(range_); | |
1993 break; | |
1994 default: | |
1995 return false; | |
1996 } | |
1997 } while (!range_.AtEnd()); | |
1998 | |
1999 AddParsedProperty(CSSPropertyFontVariantLigatures, CSSPropertyFontVariant, | |
2000 *ligatures_parser.FinalizeValue(), important); | |
2001 AddParsedProperty(CSSPropertyFontVariantNumeric, CSSPropertyFontVariant, | |
2002 *numeric_parser.FinalizeValue(), important); | |
2003 AddParsedProperty( | |
2004 CSSPropertyFontVariantCaps, CSSPropertyFontVariant, | |
2005 caps_value ? *caps_value : *CSSIdentifierValue::Create(CSSValueNormal), | |
2006 important); | |
2007 return true; | |
2008 } | |
2009 | |
2010 bool CSSPropertyParser::ConsumeBorderSpacing(bool important) { | 1804 bool CSSPropertyParser::ConsumeBorderSpacing(bool important) { |
2011 CSSValue* horizontal_spacing = ConsumeLength( | 1805 CSSValue* horizontal_spacing = ConsumeLength( |
2012 range_, context_->Mode(), kValueRangeNonNegative, UnitlessQuirk::kAllow); | 1806 range_, context_->Mode(), kValueRangeNonNegative, UnitlessQuirk::kAllow); |
2013 if (!horizontal_spacing) | 1807 if (!horizontal_spacing) |
2014 return false; | 1808 return false; |
2015 CSSValue* vertical_spacing = horizontal_spacing; | 1809 CSSValue* vertical_spacing = horizontal_spacing; |
2016 if (!range_.AtEnd()) { | 1810 if (!range_.AtEnd()) { |
2017 vertical_spacing = | 1811 vertical_spacing = |
2018 ConsumeLength(range_, context_->Mode(), kValueRangeNonNegative, | 1812 ConsumeLength(range_, context_->Mode(), kValueRangeNonNegative, |
2019 UnitlessQuirk::kAllow); | 1813 UnitlessQuirk::kAllow); |
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3035 const CSSPropertyDescriptor& css_property_desc = | 2829 const CSSPropertyDescriptor& css_property_desc = |
3036 CSSPropertyDescriptor::Get(property); | 2830 CSSPropertyDescriptor::Get(property); |
3037 if (css_property_desc.parseShorthand) { | 2831 if (css_property_desc.parseShorthand) { |
3038 return css_property_desc.parseShorthand( | 2832 return css_property_desc.parseShorthand( |
3039 important, range_, *context_, | 2833 important, range_, *context_, |
3040 CSSParserLocalContext(isPropertyAlias(unresolved_property)), | 2834 CSSParserLocalContext(isPropertyAlias(unresolved_property)), |
3041 *parsed_properties_); | 2835 *parsed_properties_); |
3042 } | 2836 } |
3043 | 2837 |
3044 switch (property) { | 2838 switch (property) { |
3045 case CSSPropertyOverflow: { | |
3046 CSSValueID id = range_.ConsumeIncludingWhitespace().Id(); | |
3047 if (!CSSParserFastPaths::IsValidKeywordPropertyAndValue( | |
3048 CSSPropertyOverflowY, id, context_->Mode())) | |
3049 return false; | |
3050 if (!range_.AtEnd()) | |
3051 return false; | |
3052 CSSValue* overflow_y_value = CSSIdentifierValue::Create(id); | |
3053 | |
3054 CSSValue* overflow_x_value = nullptr; | |
3055 | |
3056 // FIXME: -webkit-paged-x or -webkit-paged-y only apply to overflow-y. | |
3057 // If | |
3058 // this value has been set using the shorthand, then for now overflow-x | |
3059 // will default to auto, but once we implement pagination controls, it | |
3060 // should default to hidden. If the overflow-y value is anything but | |
3061 // paged-x or paged-y, then overflow-x and overflow-y should have the | |
3062 // same | |
3063 // value. | |
3064 if (id == CSSValueWebkitPagedX || id == CSSValueWebkitPagedY) | |
3065 overflow_x_value = CSSIdentifierValue::Create(CSSValueAuto); | |
3066 else | |
3067 overflow_x_value = overflow_y_value; | |
3068 AddParsedProperty(CSSPropertyOverflowX, CSSPropertyOverflow, | |
3069 *overflow_x_value, important); | |
3070 AddParsedProperty(CSSPropertyOverflowY, CSSPropertyOverflow, | |
3071 *overflow_y_value, important); | |
3072 return true; | |
3073 } | |
3074 case CSSPropertyFont: { | |
3075 const CSSParserToken& token = range_.Peek(); | |
3076 if (token.Id() >= CSSValueCaption && token.Id() <= CSSValueStatusBar) | |
3077 return ConsumeSystemFont(important); | |
3078 return ConsumeFont(important); | |
3079 } | |
3080 case CSSPropertyFontVariant: | |
3081 return ConsumeFontVariantShorthand(important); | |
3082 case CSSPropertyBorderSpacing: | 2839 case CSSPropertyBorderSpacing: |
3083 return ConsumeBorderSpacing(important); | 2840 return ConsumeBorderSpacing(important); |
3084 case CSSPropertyColumns: | 2841 case CSSPropertyColumns: |
3085 return ConsumeColumns(important); | 2842 return ConsumeColumns(important); |
3086 case CSSPropertyAnimation: | 2843 case CSSPropertyAnimation: |
3087 return ConsumeAnimationShorthand( | 2844 return ConsumeAnimationShorthand( |
3088 animationShorthandForParsing(), | 2845 animationShorthandForParsing(), |
3089 unresolved_property == CSSPropertyAliasWebkitAnimation, important); | 2846 unresolved_property == CSSPropertyAliasWebkitAnimation, important); |
3090 case CSSPropertyTransition: | 2847 case CSSPropertyTransition: |
3091 return ConsumeAnimationShorthand(transitionShorthandForParsing(), false, | 2848 return ConsumeAnimationShorthand(transitionShorthandForParsing(), false, |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3241 case CSSPropertyScrollSnapMarginBlock: | 2998 case CSSPropertyScrollSnapMarginBlock: |
3242 return Consume2Values(scrollSnapMarginBlockShorthand(), important); | 2999 return Consume2Values(scrollSnapMarginBlockShorthand(), important); |
3243 case CSSPropertyScrollSnapMarginInline: | 3000 case CSSPropertyScrollSnapMarginInline: |
3244 return Consume2Values(scrollSnapMarginInlineShorthand(), important); | 3001 return Consume2Values(scrollSnapMarginInlineShorthand(), important); |
3245 default: | 3002 default: |
3246 return false; | 3003 return false; |
3247 } | 3004 } |
3248 } | 3005 } |
3249 | 3006 |
3250 } // namespace blink | 3007 } // namespace blink |
OLD | NEW |