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/CSSCustomIdentValue.h" | 12 #include "core/css/CSSCustomIdentValue.h" |
13 #include "core/css/CSSFontFaceSrcValue.h" | 13 #include "core/css/CSSFontFaceSrcValue.h" |
14 #include "core/css/CSSFontFamilyValue.h" | |
15 #include "core/css/CSSFunctionValue.h" | 14 #include "core/css/CSSFunctionValue.h" |
16 #include "core/css/CSSGridAutoRepeatValue.h" | 15 #include "core/css/CSSGridAutoRepeatValue.h" |
17 #include "core/css/CSSGridLineNamesValue.h" | 16 #include "core/css/CSSGridLineNamesValue.h" |
18 #include "core/css/CSSGridTemplateAreasValue.h" | 17 #include "core/css/CSSGridTemplateAreasValue.h" |
19 #include "core/css/CSSIdentifierValue.h" | 18 #include "core/css/CSSIdentifierValue.h" |
20 #include "core/css/CSSInheritedValue.h" | 19 #include "core/css/CSSInheritedValue.h" |
21 #include "core/css/CSSInitialValue.h" | 20 #include "core/css/CSSInitialValue.h" |
22 #include "core/css/CSSPendingSubstitutionValue.h" | 21 #include "core/css/CSSPendingSubstitutionValue.h" |
23 #include "core/css/CSSPrimitiveValueMappings.h" | 22 #include "core/css/CSSPrimitiveValueMappings.h" |
24 #include "core/css/CSSReflectValue.h" | 23 #include "core/css/CSSReflectValue.h" |
25 #include "core/css/CSSShadowValue.h" | 24 #include "core/css/CSSShadowValue.h" |
26 #include "core/css/CSSStringValue.h" | 25 #include "core/css/CSSStringValue.h" |
27 #include "core/css/CSSTimingFunctionValue.h" | 26 #include "core/css/CSSTimingFunctionValue.h" |
28 #include "core/css/CSSURIValue.h" | 27 #include "core/css/CSSURIValue.h" |
29 #include "core/css/CSSUnicodeRangeValue.h" | 28 #include "core/css/CSSUnicodeRangeValue.h" |
30 #include "core/css/CSSUnsetValue.h" | 29 #include "core/css/CSSUnsetValue.h" |
31 #include "core/css/CSSValuePair.h" | 30 #include "core/css/CSSValuePair.h" |
32 #include "core/css/CSSVariableReferenceValue.h" | 31 #include "core/css/CSSVariableReferenceValue.h" |
33 #include "core/css/HashTools.h" | 32 #include "core/css/HashTools.h" |
34 #include "core/css/parser/CSSParserFastPaths.h" | 33 #include "core/css/parser/CSSParserFastPaths.h" |
35 #include "core/css/parser/CSSParserIdioms.h" | 34 #include "core/css/parser/CSSParserIdioms.h" |
36 #include "core/css/parser/CSSParserLocalContext.h" | 35 #include "core/css/parser/CSSParserLocalContext.h" |
37 #include "core/css/parser/CSSPropertyParserHelpers.h" | 36 #include "core/css/parser/CSSPropertyParserHelpers.h" |
38 #include "core/css/parser/CSSVariableParser.h" | 37 #include "core/css/parser/CSSVariableParser.h" |
39 #include "core/css/parser/FontVariantLigaturesParser.h" | |
40 #include "core/css/parser/FontVariantNumericParser.h" | |
41 #include "core/css/properties/CSSPropertyAPIOffsetAnchor.h" | 38 #include "core/css/properties/CSSPropertyAPIOffsetAnchor.h" |
42 #include "core/css/properties/CSSPropertyAPIOffsetPosition.h" | 39 #include "core/css/properties/CSSPropertyAPIOffsetPosition.h" |
43 #include "core/css/properties/CSSPropertyAlignmentUtils.h" | 40 #include "core/css/properties/CSSPropertyAlignmentUtils.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" |
50 #include "core/css/properties/CSSPropertyMarginUtils.h" | 47 #include "core/css/properties/CSSPropertyMarginUtils.h" |
(...skipping 13 matching lines...) Expand all Loading... | |
64 const CSSParserContext* context, | 61 const CSSParserContext* context, |
65 HeapVector<CSSProperty, 256>* parsed_properties) | 62 HeapVector<CSSProperty, 256>* parsed_properties) |
66 : range_(range), context_(context), parsed_properties_(parsed_properties) { | 63 : range_(range), context_(context), parsed_properties_(parsed_properties) { |
67 range_.ConsumeWhitespace(); | 64 range_.ConsumeWhitespace(); |
68 } | 65 } |
69 | 66 |
70 void CSSPropertyParser::AddParsedProperty(CSSPropertyID resolved_property, | 67 void CSSPropertyParser::AddParsedProperty(CSSPropertyID resolved_property, |
71 CSSPropertyID current_shorthand, | 68 CSSPropertyID current_shorthand, |
72 const CSSValue& value, | 69 const CSSValue& value, |
73 bool important, | 70 bool important, |
74 bool implicit) { | 71 bool implicit) { |
Bugs Nash
2017/06/19 23:30:12
just for documentation I want to note that this bo
Jia
2017/06/20 01:05:51
Done.
| |
75 AddProperty(resolved_property, current_shorthand, value, important, implicit, | 72 AddProperty(resolved_property, current_shorthand, value, important, |
76 *parsed_properties_); | 73 implicit ? kImplicit : kNotImplicit, *parsed_properties_); |
77 } | 74 } |
78 | 75 |
79 void CSSPropertyParser::AddExpandedPropertyForValue(CSSPropertyID property, | 76 void CSSPropertyParser::AddExpandedPropertyForValue(CSSPropertyID property, |
80 const CSSValue& value, | 77 const CSSValue& value, |
81 bool important) { | 78 bool important) { |
82 const StylePropertyShorthand& shorthand = shorthandForProperty(property); | 79 const StylePropertyShorthand& shorthand = shorthandForProperty(property); |
83 unsigned shorthand_length = shorthand.length(); | 80 unsigned shorthand_length = shorthand.length(); |
84 DCHECK(shorthand_length); | 81 DCHECK(shorthand_length); |
85 const CSSPropertyID* longhands = shorthand.properties(); | 82 const CSSPropertyID* longhands = shorthand.properties(); |
86 for (unsigned i = 0; i < shorthand_length; ++i) | 83 for (unsigned i = 0; i < shorthand_length; ++i) |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
271 if (!CSSPropertyMetadata::IsProperty(unresolved_property)) | 268 if (!CSSPropertyMetadata::IsProperty(unresolved_property)) |
272 return false; | 269 return false; |
273 AddParsedProperty(property, CSSPropertyInvalid, *value, important); | 270 AddParsedProperty(property, CSSPropertyInvalid, *value, important); |
274 } else { | 271 } else { |
275 AddExpandedPropertyForValue(property, *value, important); | 272 AddExpandedPropertyForValue(property, *value, important); |
276 } | 273 } |
277 range_ = range_copy; | 274 range_ = range_copy; |
278 return true; | 275 return true; |
279 } | 276 } |
280 | 277 |
281 static CSSIdentifierValue* ConsumeFontVariantCSS21(CSSParserTokenRange& range) { | |
282 return ConsumeIdent<CSSValueNormal, CSSValueSmallCaps>(range); | |
283 } | |
284 | |
285 static CSSValue* ConsumeFontVariantList(CSSParserTokenRange& range) { | 278 static CSSValue* ConsumeFontVariantList(CSSParserTokenRange& range) { |
286 CSSValueList* values = CSSValueList::CreateCommaSeparated(); | 279 CSSValueList* values = CSSValueList::CreateCommaSeparated(); |
287 do { | 280 do { |
288 if (range.Peek().Id() == CSSValueAll) { | 281 if (range.Peek().Id() == CSSValueAll) { |
289 // FIXME: CSSPropertyParser::ParseFontVariant() implements | 282 // FIXME: CSSPropertyParser::ParseFontVariant() implements |
290 // the old css3 draft: | 283 // the old css3 draft: |
291 // http://www.w3.org/TR/2002/WD-css3-webfonts-20020802/#font-variant | 284 // http://www.w3.org/TR/2002/WD-css3-webfonts-20020802/#font-variant |
292 // 'all' is only allowed in @font-face and with no other values. | 285 // 'all' is only allowed in @font-face and with no other values. |
293 if (values->length()) | 286 if (values->length()) |
294 return nullptr; | 287 return nullptr; |
295 return ConsumeIdent(range); | 288 return ConsumeIdent(range); |
296 } | 289 } |
297 CSSIdentifierValue* font_variant = ConsumeFontVariantCSS21(range); | 290 CSSIdentifierValue* font_variant = |
291 CSSPropertyFontUtils::ConsumeFontVariantCSS21(range); | |
298 if (font_variant) | 292 if (font_variant) |
299 values->Append(*font_variant); | 293 values->Append(*font_variant); |
300 } while (ConsumeCommaIncludingWhitespace(range)); | 294 } while (ConsumeCommaIncludingWhitespace(range)); |
301 | 295 |
302 if (values->length()) | 296 if (values->length()) |
303 return values; | 297 return values; |
304 | 298 |
305 return nullptr; | 299 return nullptr; |
306 } | 300 } |
307 | 301 |
(...skipping 1512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1820 break; | 1814 break; |
1821 } | 1815 } |
1822 | 1816 |
1823 if (!parsed_value || !range_.AtEnd()) | 1817 if (!parsed_value || !range_.AtEnd()) |
1824 return false; | 1818 return false; |
1825 | 1819 |
1826 AddParsedProperty(prop_id, CSSPropertyInvalid, *parsed_value, false); | 1820 AddParsedProperty(prop_id, CSSPropertyInvalid, *parsed_value, false); |
1827 return true; | 1821 return true; |
1828 } | 1822 } |
1829 | 1823 |
1830 bool CSSPropertyParser::ConsumeSystemFont(bool important) { | |
1831 CSSValueID system_font_id = range_.ConsumeIncludingWhitespace().Id(); | |
1832 DCHECK_GE(system_font_id, CSSValueCaption); | |
1833 DCHECK_LE(system_font_id, CSSValueStatusBar); | |
1834 if (!range_.AtEnd()) | |
1835 return false; | |
1836 | |
1837 FontStyle font_style = kFontStyleNormal; | |
1838 FontWeight font_weight = kFontWeightNormal; | |
1839 float font_size = 0; | |
1840 AtomicString font_family; | |
1841 LayoutTheme::GetTheme().SystemFont(system_font_id, font_style, font_weight, | |
1842 font_size, font_family); | |
1843 | |
1844 AddParsedProperty(CSSPropertyFontStyle, CSSPropertyFont, | |
1845 *CSSIdentifierValue::Create(font_style == kFontStyleItalic | |
1846 ? CSSValueItalic | |
1847 : CSSValueNormal), | |
1848 important); | |
1849 AddParsedProperty(CSSPropertyFontWeight, CSSPropertyFont, | |
1850 *CSSIdentifierValue::Create(font_weight), important); | |
1851 AddParsedProperty(CSSPropertyFontSize, CSSPropertyFont, | |
1852 *CSSPrimitiveValue::Create( | |
1853 font_size, CSSPrimitiveValue::UnitType::kPixels), | |
1854 important); | |
1855 CSSValueList* font_family_list = CSSValueList::CreateCommaSeparated(); | |
1856 font_family_list->Append(*CSSFontFamilyValue::Create(font_family)); | |
1857 AddParsedProperty(CSSPropertyFontFamily, CSSPropertyFont, *font_family_list, | |
1858 important); | |
1859 | |
1860 AddParsedProperty(CSSPropertyFontStretch, CSSPropertyFont, | |
1861 *CSSIdentifierValue::Create(CSSValueNormal), important); | |
1862 AddParsedProperty(CSSPropertyFontVariantCaps, CSSPropertyFont, | |
1863 *CSSIdentifierValue::Create(CSSValueNormal), important); | |
1864 AddParsedProperty(CSSPropertyFontVariantLigatures, CSSPropertyFont, | |
1865 *CSSIdentifierValue::Create(CSSValueNormal), important); | |
1866 AddParsedProperty(CSSPropertyFontVariantNumeric, CSSPropertyFont, | |
1867 *CSSIdentifierValue::Create(CSSValueNormal), important); | |
1868 AddParsedProperty(CSSPropertyLineHeight, CSSPropertyFont, | |
1869 *CSSIdentifierValue::Create(CSSValueNormal), important); | |
1870 return true; | |
1871 } | |
1872 | |
1873 bool CSSPropertyParser::ConsumeFont(bool important) { | |
1874 // Let's check if there is an inherit or initial somewhere in the shorthand. | |
1875 CSSParserTokenRange range = range_; | |
1876 while (!range.AtEnd()) { | |
1877 CSSValueID id = range.ConsumeIncludingWhitespace().Id(); | |
1878 if (id == CSSValueInherit || id == CSSValueInitial) | |
1879 return false; | |
1880 } | |
1881 // Optional font-style, font-variant, font-stretch and font-weight. | |
1882 CSSIdentifierValue* font_style = nullptr; | |
1883 CSSIdentifierValue* font_variant_caps = nullptr; | |
1884 CSSIdentifierValue* font_weight = nullptr; | |
1885 CSSIdentifierValue* font_stretch = nullptr; | |
1886 while (!range_.AtEnd()) { | |
1887 CSSValueID id = range_.Peek().Id(); | |
1888 if (!font_style && CSSParserFastPaths::IsValidKeywordPropertyAndValue( | |
1889 CSSPropertyFontStyle, id, context_->Mode())) { | |
1890 font_style = ConsumeIdent(range_); | |
1891 continue; | |
1892 } | |
1893 if (!font_variant_caps && | |
1894 (id == CSSValueNormal || id == CSSValueSmallCaps)) { | |
1895 // Font variant in the shorthand is particular, it only accepts normal or | |
1896 // small-caps. | |
1897 // See https://drafts.csswg.org/css-fonts/#propdef-font | |
1898 font_variant_caps = ConsumeFontVariantCSS21(range_); | |
1899 if (font_variant_caps) | |
1900 continue; | |
1901 } | |
1902 if (!font_weight) { | |
1903 font_weight = CSSPropertyFontUtils::ConsumeFontWeight(range_); | |
1904 if (font_weight) | |
1905 continue; | |
1906 } | |
1907 if (!font_stretch && CSSParserFastPaths::IsValidKeywordPropertyAndValue( | |
1908 CSSPropertyFontStretch, id, context_->Mode())) | |
1909 font_stretch = ConsumeIdent(range_); | |
1910 else | |
1911 break; | |
1912 } | |
1913 | |
1914 if (range_.AtEnd()) | |
1915 return false; | |
1916 | |
1917 AddParsedProperty( | |
1918 CSSPropertyFontStyle, CSSPropertyFont, | |
1919 font_style ? *font_style : *CSSIdentifierValue::Create(CSSValueNormal), | |
1920 important); | |
1921 AddParsedProperty(CSSPropertyFontVariantCaps, CSSPropertyFont, | |
1922 font_variant_caps | |
1923 ? *font_variant_caps | |
1924 : *CSSIdentifierValue::Create(CSSValueNormal), | |
1925 important); | |
1926 AddParsedProperty(CSSPropertyFontVariantLigatures, CSSPropertyFont, | |
1927 *CSSIdentifierValue::Create(CSSValueNormal), important); | |
1928 AddParsedProperty(CSSPropertyFontVariantNumeric, CSSPropertyFont, | |
1929 *CSSIdentifierValue::Create(CSSValueNormal), important); | |
1930 | |
1931 AddParsedProperty( | |
1932 CSSPropertyFontWeight, CSSPropertyFont, | |
1933 font_weight ? *font_weight : *CSSIdentifierValue::Create(CSSValueNormal), | |
1934 important); | |
1935 AddParsedProperty(CSSPropertyFontStretch, CSSPropertyFont, | |
1936 font_stretch ? *font_stretch | |
1937 : *CSSIdentifierValue::Create(CSSValueNormal), | |
1938 important); | |
1939 | |
1940 // Now a font size _must_ come. | |
1941 CSSValue* font_size = | |
1942 CSSPropertyFontUtils::ConsumeFontSize(range_, context_->Mode()); | |
1943 if (!font_size || range_.AtEnd()) | |
1944 return false; | |
1945 | |
1946 AddParsedProperty(CSSPropertyFontSize, CSSPropertyFont, *font_size, | |
1947 important); | |
1948 | |
1949 if (ConsumeSlashIncludingWhitespace(range_)) { | |
1950 CSSValue* line_height = | |
1951 CSSPropertyFontUtils::ConsumeLineHeight(range_, context_->Mode()); | |
1952 if (!line_height) | |
1953 return false; | |
1954 AddParsedProperty(CSSPropertyLineHeight, CSSPropertyFont, *line_height, | |
1955 important); | |
1956 } else { | |
1957 AddParsedProperty(CSSPropertyLineHeight, CSSPropertyFont, | |
1958 *CSSIdentifierValue::Create(CSSValueNormal), important); | |
1959 } | |
1960 | |
1961 // Font family must come now. | |
1962 CSSValue* parsed_family_value = | |
1963 CSSPropertyFontUtils::ConsumeFontFamily(range_); | |
1964 if (!parsed_family_value) | |
1965 return false; | |
1966 | |
1967 AddParsedProperty(CSSPropertyFontFamily, CSSPropertyFont, | |
1968 *parsed_family_value, important); | |
1969 | |
1970 // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20110324/#font-prop requires | |
1971 // that "font-stretch", "font-size-adjust", and "font-kerning" be reset to | |
1972 // their initial values but we don't seem to support them at the moment. They | |
1973 // should also be added here once implemented. | |
1974 return range_.AtEnd(); | |
1975 } | |
1976 | |
1977 bool CSSPropertyParser::ConsumeFontVariantShorthand(bool important) { | |
1978 if (IdentMatches<CSSValueNormal, CSSValueNone>(range_.Peek().Id())) { | |
1979 AddParsedProperty(CSSPropertyFontVariantLigatures, CSSPropertyFontVariant, | |
1980 *ConsumeIdent(range_), important); | |
1981 AddParsedProperty(CSSPropertyFontVariantCaps, CSSPropertyFontVariant, | |
1982 *CSSIdentifierValue::Create(CSSValueNormal), important); | |
1983 return range_.AtEnd(); | |
1984 } | |
1985 | |
1986 CSSIdentifierValue* caps_value = nullptr; | |
1987 FontVariantLigaturesParser ligatures_parser; | |
1988 FontVariantNumericParser numeric_parser; | |
1989 do { | |
1990 FontVariantLigaturesParser::ParseResult ligatures_parse_result = | |
1991 ligatures_parser.ConsumeLigature(range_); | |
1992 FontVariantNumericParser::ParseResult numeric_parse_result = | |
1993 numeric_parser.ConsumeNumeric(range_); | |
1994 if (ligatures_parse_result == | |
1995 FontVariantLigaturesParser::ParseResult::kConsumedValue || | |
1996 numeric_parse_result == | |
1997 FontVariantNumericParser::ParseResult::kConsumedValue) | |
1998 continue; | |
1999 | |
2000 if (ligatures_parse_result == | |
2001 FontVariantLigaturesParser::ParseResult::kDisallowedValue || | |
2002 numeric_parse_result == | |
2003 FontVariantNumericParser::ParseResult::kDisallowedValue) | |
2004 return false; | |
2005 | |
2006 CSSValueID id = range_.Peek().Id(); | |
2007 switch (id) { | |
2008 case CSSValueSmallCaps: | |
2009 case CSSValueAllSmallCaps: | |
2010 case CSSValuePetiteCaps: | |
2011 case CSSValueAllPetiteCaps: | |
2012 case CSSValueUnicase: | |
2013 case CSSValueTitlingCaps: | |
2014 // Only one caps value permitted in font-variant grammar. | |
2015 if (caps_value) | |
2016 return false; | |
2017 caps_value = ConsumeIdent(range_); | |
2018 break; | |
2019 default: | |
2020 return false; | |
2021 } | |
2022 } while (!range_.AtEnd()); | |
2023 | |
2024 AddParsedProperty(CSSPropertyFontVariantLigatures, CSSPropertyFontVariant, | |
2025 *ligatures_parser.FinalizeValue(), important); | |
2026 AddParsedProperty(CSSPropertyFontVariantNumeric, CSSPropertyFontVariant, | |
2027 *numeric_parser.FinalizeValue(), important); | |
2028 AddParsedProperty( | |
2029 CSSPropertyFontVariantCaps, CSSPropertyFontVariant, | |
2030 caps_value ? *caps_value : *CSSIdentifierValue::Create(CSSValueNormal), | |
2031 important); | |
2032 return true; | |
2033 } | |
2034 | |
2035 bool CSSPropertyParser::ConsumeBorderSpacing(bool important) { | 1824 bool CSSPropertyParser::ConsumeBorderSpacing(bool important) { |
2036 CSSValue* horizontal_spacing = ConsumeLength( | 1825 CSSValue* horizontal_spacing = ConsumeLength( |
2037 range_, context_->Mode(), kValueRangeNonNegative, UnitlessQuirk::kAllow); | 1826 range_, context_->Mode(), kValueRangeNonNegative, UnitlessQuirk::kAllow); |
2038 if (!horizontal_spacing) | 1827 if (!horizontal_spacing) |
2039 return false; | 1828 return false; |
2040 CSSValue* vertical_spacing = horizontal_spacing; | 1829 CSSValue* vertical_spacing = horizontal_spacing; |
2041 if (!range_.AtEnd()) { | 1830 if (!range_.AtEnd()) { |
2042 vertical_spacing = | 1831 vertical_spacing = |
2043 ConsumeLength(range_, context_->Mode(), kValueRangeNonNegative, | 1832 ConsumeLength(range_, context_->Mode(), kValueRangeNonNegative, |
2044 UnitlessQuirk::kAllow); | 1833 UnitlessQuirk::kAllow); |
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3060 const CSSPropertyDescriptor& css_property_desc = | 2849 const CSSPropertyDescriptor& css_property_desc = |
3061 CSSPropertyDescriptor::Get(property); | 2850 CSSPropertyDescriptor::Get(property); |
3062 if (css_property_desc.parseShorthand) { | 2851 if (css_property_desc.parseShorthand) { |
3063 return css_property_desc.parseShorthand( | 2852 return css_property_desc.parseShorthand( |
3064 important, range_, *context_, | 2853 important, range_, *context_, |
3065 CSSParserLocalContext(isPropertyAlias(unresolved_property)), | 2854 CSSParserLocalContext(isPropertyAlias(unresolved_property)), |
3066 *parsed_properties_); | 2855 *parsed_properties_); |
3067 } | 2856 } |
3068 | 2857 |
3069 switch (property) { | 2858 switch (property) { |
3070 case CSSPropertyOverflow: { | |
3071 CSSValueID id = range_.ConsumeIncludingWhitespace().Id(); | |
3072 if (!CSSParserFastPaths::IsValidKeywordPropertyAndValue( | |
3073 CSSPropertyOverflowY, id, context_->Mode())) | |
3074 return false; | |
3075 if (!range_.AtEnd()) | |
3076 return false; | |
3077 CSSValue* overflow_y_value = CSSIdentifierValue::Create(id); | |
3078 | |
3079 CSSValue* overflow_x_value = nullptr; | |
3080 | |
3081 // FIXME: -webkit-paged-x or -webkit-paged-y only apply to overflow-y. | |
3082 // If | |
3083 // this value has been set using the shorthand, then for now overflow-x | |
3084 // will default to auto, but once we implement pagination controls, it | |
3085 // should default to hidden. If the overflow-y value is anything but | |
3086 // paged-x or paged-y, then overflow-x and overflow-y should have the | |
3087 // same | |
3088 // value. | |
3089 if (id == CSSValueWebkitPagedX || id == CSSValueWebkitPagedY) | |
3090 overflow_x_value = CSSIdentifierValue::Create(CSSValueAuto); | |
3091 else | |
3092 overflow_x_value = overflow_y_value; | |
3093 AddParsedProperty(CSSPropertyOverflowX, CSSPropertyOverflow, | |
3094 *overflow_x_value, important); | |
3095 AddParsedProperty(CSSPropertyOverflowY, CSSPropertyOverflow, | |
3096 *overflow_y_value, important); | |
3097 return true; | |
3098 } | |
3099 case CSSPropertyFont: { | |
3100 const CSSParserToken& token = range_.Peek(); | |
3101 if (token.Id() >= CSSValueCaption && token.Id() <= CSSValueStatusBar) | |
3102 return ConsumeSystemFont(important); | |
3103 return ConsumeFont(important); | |
3104 } | |
3105 case CSSPropertyFontVariant: | |
3106 return ConsumeFontVariantShorthand(important); | |
3107 case CSSPropertyBorderSpacing: | 2859 case CSSPropertyBorderSpacing: |
3108 return ConsumeBorderSpacing(important); | 2860 return ConsumeBorderSpacing(important); |
3109 case CSSPropertyColumns: | 2861 case CSSPropertyColumns: |
3110 return ConsumeColumns(important); | 2862 return ConsumeColumns(important); |
3111 case CSSPropertyAnimation: | 2863 case CSSPropertyAnimation: |
3112 return ConsumeAnimationShorthand( | 2864 return ConsumeAnimationShorthand( |
3113 animationShorthandForParsing(), | 2865 animationShorthandForParsing(), |
3114 unresolved_property == CSSPropertyAliasWebkitAnimation, important); | 2866 unresolved_property == CSSPropertyAliasWebkitAnimation, important); |
3115 case CSSPropertyTransition: | 2867 case CSSPropertyTransition: |
3116 return ConsumeAnimationShorthand(transitionShorthandForParsing(), false, | 2868 return ConsumeAnimationShorthand(transitionShorthandForParsing(), false, |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3266 case CSSPropertyScrollSnapMarginBlock: | 3018 case CSSPropertyScrollSnapMarginBlock: |
3267 return Consume2Values(scrollSnapMarginBlockShorthand(), important); | 3019 return Consume2Values(scrollSnapMarginBlockShorthand(), important); |
3268 case CSSPropertyScrollSnapMarginInline: | 3020 case CSSPropertyScrollSnapMarginInline: |
3269 return Consume2Values(scrollSnapMarginInlineShorthand(), important); | 3021 return Consume2Values(scrollSnapMarginInlineShorthand(), important); |
3270 default: | 3022 default: |
3271 return false; | 3023 return false; |
3272 } | 3024 } |
3273 } | 3025 } |
3274 | 3026 |
3275 } // namespace blink | 3027 } // namespace blink |
OLD | NEW |