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 "core/StylePropertyShorthand.h" | 7 #include "core/StylePropertyShorthand.h" |
8 #include "core/css/CSSBasicShapeValues.h" | 8 #include "core/css/CSSBasicShapeValues.h" |
9 #include "core/css/CSSBorderImage.h" | 9 #include "core/css/CSSBorderImage.h" |
10 #include "core/css/CSSContentDistributionValue.h" | 10 #include "core/css/CSSContentDistributionValue.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 namespace blink { | 48 namespace blink { |
49 | 49 |
50 using namespace CSSPropertyParserHelpers; | 50 using namespace CSSPropertyParserHelpers; |
51 | 51 |
52 CSSPropertyParser::CSSPropertyParser(const CSSParserTokenRange& range, | 52 CSSPropertyParser::CSSPropertyParser(const CSSParserTokenRange& range, |
53 const CSSParserContext& context, HeapVector<CSSProperty, 256>* parsedPropert
ies) | 53 const CSSParserContext& context, HeapVector<CSSProperty, 256>* parsedPropert
ies) |
54 : m_range(range) | 54 : m_range(range) |
55 , m_context(context) | 55 , m_context(context) |
56 , m_parsedProperties(parsedProperties) | 56 , m_parsedProperties(parsedProperties) |
57 , m_inParseShorthand(0) | |
58 , m_currentShorthand(CSSPropertyInvalid) | |
59 { | 57 { |
60 m_range.consumeWhitespace(); | 58 m_range.consumeWhitespace(); |
61 } | 59 } |
62 | 60 |
63 void CSSPropertyParser::addProperty(CSSPropertyID property, CSSValue* value, boo
l important, bool implicit) | 61 void CSSPropertyParser::addProperty(CSSPropertyID property, CSSPropertyID curren
tShorthand, CSSValue* value, bool important, bool implicit) |
64 { | 62 { |
65 ASSERT(!isPropertyAlias(property)); | 63 ASSERT(!isPropertyAlias(property)); |
66 | 64 |
67 int shorthandIndex = 0; | 65 int shorthandIndex = 0; |
68 bool setFromShorthand = false; | 66 bool setFromShorthand = false; |
69 | 67 |
70 if (m_currentShorthand) { | 68 if (currentShorthand) { |
71 Vector<StylePropertyShorthand, 4> shorthands; | 69 Vector<StylePropertyShorthand, 4> shorthands; |
72 getMatchingShorthandsForLonghand(property, &shorthands); | 70 getMatchingShorthandsForLonghand(property, &shorthands); |
73 setFromShorthand = true; | 71 setFromShorthand = true; |
74 if (shorthands.size() > 1) | 72 if (shorthands.size() > 1) |
75 shorthandIndex = indexOfShorthandForLonghand(m_currentShorthand, sho
rthands); | 73 shorthandIndex = indexOfShorthandForLonghand(currentShorthand, short
hands); |
76 } | 74 } |
77 | 75 |
78 m_parsedProperties->append(CSSProperty(property, value, important, setFromSh
orthand, shorthandIndex, implicit)); | 76 m_parsedProperties->append(CSSProperty(property, value, important, setFromSh
orthand, shorthandIndex, implicit)); |
79 } | 77 } |
80 | 78 |
81 void CSSPropertyParser::addExpandedPropertyForValue(CSSPropertyID property, CSSV
alue* value, bool important) | 79 void CSSPropertyParser::addExpandedPropertyForValue(CSSPropertyID property, CSSV
alue* value, bool important) |
82 { | 80 { |
83 const StylePropertyShorthand& shorthand = shorthandForProperty(property); | 81 const StylePropertyShorthand& shorthand = shorthandForProperty(property); |
84 unsigned shorthandLength = shorthand.length(); | 82 unsigned shorthandLength = shorthand.length(); |
85 if (!shorthandLength) { | 83 ASSERT(shorthandLength); |
86 addProperty(property, value, important); | |
87 return; | |
88 } | |
89 | |
90 ShorthandScope scope(this, property); | |
91 const CSSPropertyID* longhands = shorthand.properties(); | 84 const CSSPropertyID* longhands = shorthand.properties(); |
92 for (unsigned i = 0; i < shorthandLength; ++i) | 85 for (unsigned i = 0; i < shorthandLength; ++i) |
93 addProperty(longhands[i], value, important); | 86 addProperty(longhands[i], property, value, important); |
94 } | 87 } |
95 | 88 |
96 static bool hasInvalidNumericValues(const CSSParserTokenRange& range) | 89 static bool hasInvalidNumericValues(const CSSParserTokenRange& range) |
97 { | 90 { |
98 for (const CSSParserToken& token : range) { | 91 for (const CSSParserToken& token : range) { |
99 CSSParserTokenType type = token.type(); | 92 CSSParserTokenType type = token.type(); |
100 if ((type == NumberToken || type == DimensionToken || type == Percentage
Token) | 93 if ((type == NumberToken || type == DimensionToken || type == Percentage
Token) |
101 && !CSSPropertyParser::isValidNumericValue(token.numericValue())) | 94 && !CSSPropertyParser::isValidNumericValue(token.numericValue())) |
102 return true; | 95 return true; |
103 } | 96 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 154 |
162 CSSParserTokenRange originalRange = m_range; | 155 CSSParserTokenRange originalRange = m_range; |
163 CSSPropertyID propertyId = resolveCSSPropertyID(unresolvedProperty); | 156 CSSPropertyID propertyId = resolveCSSPropertyID(unresolvedProperty); |
164 | 157 |
165 if (isShorthandProperty(propertyId)) { | 158 if (isShorthandProperty(propertyId)) { |
166 if (parseShorthand(unresolvedProperty, important)) | 159 if (parseShorthand(unresolvedProperty, important)) |
167 return true; | 160 return true; |
168 } else { | 161 } else { |
169 if (CSSValue* parsedValue = parseSingleValue(unresolvedProperty)) { | 162 if (CSSValue* parsedValue = parseSingleValue(unresolvedProperty)) { |
170 if (m_range.atEnd()) { | 163 if (m_range.atEnd()) { |
171 addProperty(propertyId, parsedValue, important); | 164 addProperty(propertyId, CSSPropertyInvalid, parsedValue, importa
nt); |
172 return true; | 165 return true; |
173 } | 166 } |
174 } | 167 } |
175 } | 168 } |
176 | 169 |
177 if (RuntimeEnabledFeatures::cssVariablesEnabled() && CSSVariableParser::cont
ainsValidVariableReferences(originalRange)) { | 170 if (RuntimeEnabledFeatures::cssVariablesEnabled() && CSSVariableParser::cont
ainsValidVariableReferences(originalRange)) { |
178 // We don't expand the shorthand here because crazypants. | 171 // We don't expand the shorthand here because crazypants. |
179 CSSVariableReferenceValue* variable = CSSVariableReferenceValue::create(
CSSVariableData::create(originalRange)); | 172 CSSVariableReferenceValue* variable = CSSVariableReferenceValue::create(
CSSVariableData::create(originalRange)); |
180 addProperty(propertyId, variable, important); | 173 addProperty(propertyId, CSSPropertyInvalid, variable, important); |
181 return true; | 174 return true; |
182 } | 175 } |
183 | 176 |
184 return false; | 177 return false; |
185 } | 178 } |
186 | 179 |
187 bool CSSPropertyParser::isColorKeyword(CSSValueID id) | 180 bool CSSPropertyParser::isColorKeyword(CSSValueID id) |
188 { | 181 { |
189 // Named colors and color keywords: | 182 // Named colors and color keywords: |
190 // | 183 // |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 CSSValue* value = nullptr; | 296 CSSValue* value = nullptr; |
304 if (id == CSSValueInitial) | 297 if (id == CSSValueInitial) |
305 value = cssValuePool().createExplicitInitialValue(); | 298 value = cssValuePool().createExplicitInitialValue(); |
306 else if (id == CSSValueInherit) | 299 else if (id == CSSValueInherit) |
307 value = cssValuePool().createInheritedValue(); | 300 value = cssValuePool().createInheritedValue(); |
308 else if (id == CSSValueUnset) | 301 else if (id == CSSValueUnset) |
309 value = cssValuePool().createUnsetValue(); | 302 value = cssValuePool().createUnsetValue(); |
310 else | 303 else |
311 return false; | 304 return false; |
312 | 305 |
313 addExpandedPropertyForValue(resolveCSSPropertyID(unresolvedProperty), value,
important); | 306 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); |
| 307 const StylePropertyShorthand& shorthand = shorthandForProperty(property); |
| 308 if (!shorthand.length()) |
| 309 addProperty(property, CSSPropertyInvalid, value, important); |
| 310 else |
| 311 addExpandedPropertyForValue(property, value, important); |
314 m_range = rangeCopy; | 312 m_range = rangeCopy; |
315 return true; | 313 return true; |
316 } | 314 } |
317 | 315 |
318 static CSSValueList* consumeTransformOrigin(CSSParserTokenRange& range, CSSParse
rMode cssParserMode, UnitlessQuirk unitless) | 316 static CSSValueList* consumeTransformOrigin(CSSParserTokenRange& range, CSSParse
rMode cssParserMode, UnitlessQuirk unitless) |
319 { | 317 { |
320 CSSValue* resultX = nullptr; | 318 CSSValue* resultX = nullptr; |
321 CSSValue* resultY = nullptr; | 319 CSSValue* resultY = nullptr; |
322 if (consumeOneOrTwoValuedPosition(range, cssParserMode, unitless, resultX, r
esultY)) { | 320 if (consumeOneOrTwoValuedPosition(range, cssParserMode, unitless, resultX, r
esultY)) { |
323 CSSValueList* list = CSSValueList::createSpaceSeparated(); | 321 CSSValueList* list = CSSValueList::createSpaceSeparated(); |
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1212 parsedLonghand[i] = false; | 1210 parsedLonghand[i] = false; |
1213 } | 1211 } |
1214 } while (consumeCommaIncludingWhitespace(m_range)); | 1212 } while (consumeCommaIncludingWhitespace(m_range)); |
1215 | 1213 |
1216 for (size_t i = 0; i < longhandCount; ++i) { | 1214 for (size_t i = 0; i < longhandCount; ++i) { |
1217 if (!isValidAnimationPropertyList(shorthand.properties()[i], *longhands[
i])) | 1215 if (!isValidAnimationPropertyList(shorthand.properties()[i], *longhands[
i])) |
1218 return false; | 1216 return false; |
1219 } | 1217 } |
1220 | 1218 |
1221 for (size_t i = 0; i < longhandCount; ++i) | 1219 for (size_t i = 0; i < longhandCount; ++i) |
1222 addProperty(shorthand.properties()[i], longhands[i], important); | 1220 addProperty(shorthand.properties()[i], shorthand.id(), longhands[i], imp
ortant); |
1223 | 1221 |
1224 return m_range.atEnd(); | 1222 return m_range.atEnd(); |
1225 } | 1223 } |
1226 | 1224 |
1227 static CSSValue* consumeZIndex(CSSParserTokenRange& range) | 1225 static CSSValue* consumeZIndex(CSSParserTokenRange& range) |
1228 { | 1226 { |
1229 if (range.peek().id() == CSSValueAuto) | 1227 if (range.peek().id() == CSSValueAuto) |
1230 return consumeIdent(range); | 1228 return consumeIdent(range); |
1231 return consumeInteger(range); | 1229 return consumeInteger(range); |
1232 } | 1230 } |
(...skipping 2185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3418 return nullptr; | 3416 return nullptr; |
3419 ++rowCount; | 3417 ++rowCount; |
3420 } | 3418 } |
3421 | 3419 |
3422 if (rowCount == 0) | 3420 if (rowCount == 0) |
3423 return nullptr; | 3421 return nullptr; |
3424 ASSERT(columnCount); | 3422 ASSERT(columnCount); |
3425 return CSSGridTemplateAreasValue::create(gridAreaMap, rowCount, columnCount)
; | 3423 return CSSGridTemplateAreasValue::create(gridAreaMap, rowCount, columnCount)
; |
3426 } | 3424 } |
3427 | 3425 |
3428 CSSValue* CSSPropertyParser::parseSingleValue(CSSPropertyID unresolvedProperty) | 3426 CSSValue* CSSPropertyParser::parseSingleValue(CSSPropertyID unresolvedProperty,
CSSPropertyID currentShorthand) |
3429 { | 3427 { |
3430 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); | 3428 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); |
3431 if (CSSParserFastPaths::isKeywordPropertyID(property)) { | 3429 if (CSSParserFastPaths::isKeywordPropertyID(property)) { |
3432 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_rang
e.peek().id(), m_context.mode())) | 3430 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(property, m_rang
e.peek().id(), m_context.mode())) |
3433 return nullptr; | 3431 return nullptr; |
3434 return consumeIdent(m_range); | 3432 return consumeIdent(m_range); |
3435 } | 3433 } |
3436 switch (property) { | 3434 switch (property) { |
3437 case CSSPropertyWillChange: | 3435 case CSSPropertyWillChange: |
3438 return consumeWillChange(m_range); | 3436 return consumeWillChange(m_range); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3594 case CSSPropertyWebkitBorderStartWidth: | 3592 case CSSPropertyWebkitBorderStartWidth: |
3595 case CSSPropertyWebkitBorderEndWidth: | 3593 case CSSPropertyWebkitBorderEndWidth: |
3596 case CSSPropertyWebkitBorderBeforeWidth: | 3594 case CSSPropertyWebkitBorderBeforeWidth: |
3597 case CSSPropertyWebkitBorderAfterWidth: | 3595 case CSSPropertyWebkitBorderAfterWidth: |
3598 return consumeBorderWidth(m_range, m_context.mode(), UnitlessQuirk::Forb
id); | 3596 return consumeBorderWidth(m_range, m_context.mode(), UnitlessQuirk::Forb
id); |
3599 case CSSPropertyBorderBottomColor: | 3597 case CSSPropertyBorderBottomColor: |
3600 case CSSPropertyBorderLeftColor: | 3598 case CSSPropertyBorderLeftColor: |
3601 case CSSPropertyBorderRightColor: | 3599 case CSSPropertyBorderRightColor: |
3602 case CSSPropertyBorderTopColor: { | 3600 case CSSPropertyBorderTopColor: { |
3603 bool allowQuirkyColors = inQuirksMode() | 3601 bool allowQuirkyColors = inQuirksMode() |
3604 && (m_currentShorthand == CSSPropertyInvalid || m_currentShorthand =
= CSSPropertyBorderColor); | 3602 && (currentShorthand == CSSPropertyInvalid || currentShorthand == CS
SPropertyBorderColor); |
3605 return consumeColor(m_range, m_context.mode(), allowQuirkyColors); | 3603 return consumeColor(m_range, m_context.mode(), allowQuirkyColors); |
3606 } | 3604 } |
3607 case CSSPropertyBorderBottomWidth: | 3605 case CSSPropertyBorderBottomWidth: |
3608 case CSSPropertyBorderLeftWidth: | 3606 case CSSPropertyBorderLeftWidth: |
3609 case CSSPropertyBorderRightWidth: | 3607 case CSSPropertyBorderRightWidth: |
3610 case CSSPropertyBorderTopWidth: { | 3608 case CSSPropertyBorderTopWidth: { |
3611 bool allowQuirkyLengths = inQuirksMode() | 3609 bool allowQuirkyLengths = inQuirksMode() |
3612 && (m_currentShorthand == CSSPropertyInvalid || m_currentShorthand =
= CSSPropertyBorderWidth); | 3610 && (currentShorthand == CSSPropertyInvalid || currentShorthand == CS
SPropertyBorderWidth); |
3613 UnitlessQuirk unitless = allowQuirkyLengths ? UnitlessQuirk::Allow : Uni
tlessQuirk::Forbid; | 3611 UnitlessQuirk unitless = allowQuirkyLengths ? UnitlessQuirk::Allow : Uni
tlessQuirk::Forbid; |
3614 return consumeBorderWidth(m_range, m_context.mode(), unitless); | 3612 return consumeBorderWidth(m_range, m_context.mode(), unitless); |
3615 } | 3613 } |
3616 case CSSPropertyZIndex: | 3614 case CSSPropertyZIndex: |
3617 return consumeZIndex(m_range); | 3615 return consumeZIndex(m_range); |
3618 case CSSPropertyTextShadow: // CSS2 property, dropped in CSS2.1, back in CSS
3, so treat as CSS3 | 3616 case CSSPropertyTextShadow: // CSS2 property, dropped in CSS2.1, back in CSS
3, so treat as CSS3 |
3619 case CSSPropertyBoxShadow: | 3617 case CSSPropertyBoxShadow: |
3620 return consumeShadow(m_range, m_context.mode(), property == CSSPropertyB
oxShadow); | 3618 return consumeShadow(m_range, m_context.mode(), property == CSSPropertyB
oxShadow); |
3621 case CSSPropertyWebkitFilter: | 3619 case CSSPropertyWebkitFilter: |
3622 case CSSPropertyBackdropFilter: | 3620 case CSSPropertyBackdropFilter: |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3924 case CSSPropertyFontFeatureSettings: | 3922 case CSSPropertyFontFeatureSettings: |
3925 parsedValue = consumeFontFeatureSettings(m_range); | 3923 parsedValue = consumeFontFeatureSettings(m_range); |
3926 break; | 3924 break; |
3927 default: | 3925 default: |
3928 break; | 3926 break; |
3929 } | 3927 } |
3930 | 3928 |
3931 if (!parsedValue || !m_range.atEnd()) | 3929 if (!parsedValue || !m_range.atEnd()) |
3932 return false; | 3930 return false; |
3933 | 3931 |
3934 addProperty(propId, parsedValue, false); | 3932 addProperty(propId, CSSPropertyInvalid, parsedValue, false); |
3935 return true; | 3933 return true; |
3936 } | 3934 } |
3937 | 3935 |
3938 bool CSSPropertyParser::consumeSystemFont(bool important) | 3936 bool CSSPropertyParser::consumeSystemFont(bool important) |
3939 { | 3937 { |
3940 CSSValueID systemFontID = m_range.consumeIncludingWhitespace().id(); | 3938 CSSValueID systemFontID = m_range.consumeIncludingWhitespace().id(); |
3941 ASSERT(systemFontID >= CSSValueCaption && systemFontID <= CSSValueStatusBar)
; | 3939 ASSERT(systemFontID >= CSSValueCaption && systemFontID <= CSSValueStatusBar)
; |
3942 if (!m_range.atEnd()) | 3940 if (!m_range.atEnd()) |
3943 return false; | 3941 return false; |
3944 | 3942 |
3945 FontStyle fontStyle = FontStyleNormal; | 3943 FontStyle fontStyle = FontStyleNormal; |
3946 FontWeight fontWeight = FontWeightNormal; | 3944 FontWeight fontWeight = FontWeightNormal; |
3947 float fontSize = 0; | 3945 float fontSize = 0; |
3948 AtomicString fontFamily; | 3946 AtomicString fontFamily; |
3949 LayoutTheme::theme().systemFont(systemFontID, fontStyle, fontWeight, fontSiz
e, fontFamily); | 3947 LayoutTheme::theme().systemFont(systemFontID, fontStyle, fontWeight, fontSiz
e, fontFamily); |
3950 | 3948 |
3951 addProperty(CSSPropertyFontStyle, cssValuePool().createIdentifierValue(fontS
tyle == FontStyleItalic ? CSSValueItalic : CSSValueNormal), important); | 3949 addProperty(CSSPropertyFontStyle, CSSPropertyFont, cssValuePool().createIden
tifierValue(fontStyle == FontStyleItalic ? CSSValueItalic : CSSValueNormal), imp
ortant); |
3952 addProperty(CSSPropertyFontWeight, cssValuePool().createValue(fontWeight), i
mportant); | 3950 addProperty(CSSPropertyFontWeight, CSSPropertyFont, cssValuePool().createVal
ue(fontWeight), important); |
3953 addProperty(CSSPropertyFontSize, cssValuePool().createValue(fontSize, CSSPri
mitiveValue::UnitType::Pixels), important); | 3951 addProperty(CSSPropertyFontSize, CSSPropertyFont, cssValuePool().createValue
(fontSize, CSSPrimitiveValue::UnitType::Pixels), important); |
3954 CSSValueList* fontFamilyList = CSSValueList::createCommaSeparated(); | 3952 CSSValueList* fontFamilyList = CSSValueList::createCommaSeparated(); |
3955 fontFamilyList->append(cssValuePool().createFontFamilyValue(fontFamily)); | 3953 fontFamilyList->append(cssValuePool().createFontFamilyValue(fontFamily)); |
3956 addProperty(CSSPropertyFontFamily, fontFamilyList, important); | 3954 addProperty(CSSPropertyFontFamily, CSSPropertyFont, fontFamilyList, importan
t); |
3957 | 3955 |
3958 addProperty(CSSPropertyFontStretch, cssValuePool().createIdentifierValue(CSS
ValueNormal), important); | 3956 addProperty(CSSPropertyFontStretch, CSSPropertyFont, cssValuePool().createId
entifierValue(CSSValueNormal), important); |
3959 addProperty(CSSPropertyFontVariant, cssValuePool().createIdentifierValue(CSS
ValueNormal), important); | 3957 addProperty(CSSPropertyFontVariant, CSSPropertyFont, cssValuePool().createId
entifierValue(CSSValueNormal), important); |
3960 addProperty(CSSPropertyLineHeight, cssValuePool().createIdentifierValue(CSSV
alueNormal), important); | 3958 addProperty(CSSPropertyLineHeight, CSSPropertyFont, cssValuePool().createIde
ntifierValue(CSSValueNormal), important); |
3961 return true; | 3959 return true; |
3962 } | 3960 } |
3963 | 3961 |
3964 bool CSSPropertyParser::consumeFont(bool important) | 3962 bool CSSPropertyParser::consumeFont(bool important) |
3965 { | 3963 { |
3966 // Let's check if there is an inherit or initial somewhere in the shorthand. | 3964 // Let's check if there is an inherit or initial somewhere in the shorthand. |
3967 CSSParserTokenRange range = m_range; | 3965 CSSParserTokenRange range = m_range; |
3968 while (!range.atEnd()) { | 3966 while (!range.atEnd()) { |
3969 CSSValueID id = range.consumeIncludingWhitespace().id(); | 3967 CSSValueID id = range.consumeIncludingWhitespace().id(); |
3970 if (id == CSSValueInherit || id == CSSValueInitial) | 3968 if (id == CSSValueInherit || id == CSSValueInitial) |
(...skipping 24 matching lines...) Expand all Loading... |
3995 } | 3993 } |
3996 if (!fontStretch && CSSParserFastPaths::isValidKeywordPropertyAndValue(C
SSPropertyFontStretch, id, m_context.mode())) | 3994 if (!fontStretch && CSSParserFastPaths::isValidKeywordPropertyAndValue(C
SSPropertyFontStretch, id, m_context.mode())) |
3997 fontStretch = consumeIdent(m_range); | 3995 fontStretch = consumeIdent(m_range); |
3998 else | 3996 else |
3999 break; | 3997 break; |
4000 } | 3998 } |
4001 | 3999 |
4002 if (m_range.atEnd()) | 4000 if (m_range.atEnd()) |
4003 return false; | 4001 return false; |
4004 | 4002 |
4005 addProperty(CSSPropertyFontStyle, fontStyle ? fontStyle : cssValuePool().cre
ateIdentifierValue(CSSValueNormal), important); | 4003 addProperty(CSSPropertyFontStyle, CSSPropertyFont, fontStyle ? fontStyle : c
ssValuePool().createIdentifierValue(CSSValueNormal), important); |
4006 addProperty(CSSPropertyFontVariant, fontVariant ? fontVariant : cssValuePool
().createIdentifierValue(CSSValueNormal), important); | 4004 addProperty(CSSPropertyFontVariant, CSSPropertyFont, fontVariant ? fontVaria
nt : cssValuePool().createIdentifierValue(CSSValueNormal), important); |
4007 addProperty(CSSPropertyFontWeight, fontWeight ? fontWeight : cssValuePool().
createIdentifierValue(CSSValueNormal), important); | 4005 addProperty(CSSPropertyFontWeight, CSSPropertyFont, fontWeight ? fontWeight
: cssValuePool().createIdentifierValue(CSSValueNormal), important); |
4008 addProperty(CSSPropertyFontStretch, fontStretch ? fontStretch : cssValuePool
().createIdentifierValue(CSSValueNormal), important); | 4006 addProperty(CSSPropertyFontStretch, CSSPropertyFont, fontStretch ? fontStret
ch : cssValuePool().createIdentifierValue(CSSValueNormal), important); |
4009 | 4007 |
4010 // Now a font size _must_ come. | 4008 // Now a font size _must_ come. |
4011 CSSValue* fontSize = consumeFontSize(m_range, m_context.mode()); | 4009 CSSValue* fontSize = consumeFontSize(m_range, m_context.mode()); |
4012 if (!fontSize || m_range.atEnd()) | 4010 if (!fontSize || m_range.atEnd()) |
4013 return false; | 4011 return false; |
4014 | 4012 |
4015 addProperty(CSSPropertyFontSize, fontSize, important); | 4013 addProperty(CSSPropertyFontSize, CSSPropertyFont, fontSize, important); |
4016 | 4014 |
4017 if (consumeSlashIncludingWhitespace(m_range)) { | 4015 if (consumeSlashIncludingWhitespace(m_range)) { |
4018 CSSPrimitiveValue* lineHeight = consumeLineHeight(m_range, m_context.mod
e()); | 4016 CSSPrimitiveValue* lineHeight = consumeLineHeight(m_range, m_context.mod
e()); |
4019 if (!lineHeight) | 4017 if (!lineHeight) |
4020 return false; | 4018 return false; |
4021 addProperty(CSSPropertyLineHeight, lineHeight, important); | 4019 addProperty(CSSPropertyLineHeight, CSSPropertyFont, lineHeight, importan
t); |
4022 } else { | 4020 } else { |
4023 addProperty(CSSPropertyLineHeight, cssValuePool().createIdentifierValue(
CSSValueNormal), important); | 4021 addProperty(CSSPropertyLineHeight, CSSPropertyFont, cssValuePool().creat
eIdentifierValue(CSSValueNormal), important); |
4024 } | 4022 } |
4025 | 4023 |
4026 // Font family must come now. | 4024 // Font family must come now. |
4027 CSSValue* parsedFamilyValue = consumeFontFamily(m_range); | 4025 CSSValue* parsedFamilyValue = consumeFontFamily(m_range); |
4028 if (!parsedFamilyValue) | 4026 if (!parsedFamilyValue) |
4029 return false; | 4027 return false; |
4030 | 4028 |
4031 addProperty(CSSPropertyFontFamily, parsedFamilyValue, important); | 4029 addProperty(CSSPropertyFontFamily, CSSPropertyFont, parsedFamilyValue, impor
tant); |
4032 | 4030 |
4033 // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20110324/#font-prop requir
es that | 4031 // FIXME: http://www.w3.org/TR/2011/WD-css3-fonts-20110324/#font-prop requir
es that |
4034 // "font-stretch", "font-size-adjust", and "font-kerning" be reset to their
initial values | 4032 // "font-stretch", "font-size-adjust", and "font-kerning" be reset to their
initial values |
4035 // but we don't seem to support them at the moment. They should also be adde
d here once implemented. | 4033 // but we don't seem to support them at the moment. They should also be adde
d here once implemented. |
4036 return m_range.atEnd(); | 4034 return m_range.atEnd(); |
4037 } | 4035 } |
4038 | 4036 |
4039 bool CSSPropertyParser::consumeBorderSpacing(bool important) | 4037 bool CSSPropertyParser::consumeBorderSpacing(bool important) |
4040 { | 4038 { |
4041 CSSValue* horizontalSpacing = consumeLength(m_range, m_context.mode(), Value
RangeNonNegative, UnitlessQuirk::Allow); | 4039 CSSValue* horizontalSpacing = consumeLength(m_range, m_context.mode(), Value
RangeNonNegative, UnitlessQuirk::Allow); |
4042 if (!horizontalSpacing) | 4040 if (!horizontalSpacing) |
4043 return false; | 4041 return false; |
4044 CSSValue* verticalSpacing = horizontalSpacing; | 4042 CSSValue* verticalSpacing = horizontalSpacing; |
4045 if (!m_range.atEnd()) | 4043 if (!m_range.atEnd()) |
4046 verticalSpacing = consumeLength(m_range, m_context.mode(), ValueRangeNon
Negative, UnitlessQuirk::Allow); | 4044 verticalSpacing = consumeLength(m_range, m_context.mode(), ValueRangeNon
Negative, UnitlessQuirk::Allow); |
4047 if (!verticalSpacing || !m_range.atEnd()) | 4045 if (!verticalSpacing || !m_range.atEnd()) |
4048 return false; | 4046 return false; |
4049 addProperty(CSSPropertyWebkitBorderHorizontalSpacing, horizontalSpacing, imp
ortant); | 4047 addProperty(CSSPropertyWebkitBorderHorizontalSpacing, CSSPropertyBorderSpaci
ng, horizontalSpacing, important); |
4050 addProperty(CSSPropertyWebkitBorderVerticalSpacing, verticalSpacing, importa
nt); | 4048 addProperty(CSSPropertyWebkitBorderVerticalSpacing, CSSPropertyBorderSpacing
, verticalSpacing, important); |
4051 return true; | 4049 return true; |
4052 } | 4050 } |
4053 | 4051 |
4054 static CSSValue* consumeSingleViewportDescriptor(CSSParserTokenRange& range, CSS
PropertyID propId, CSSParserMode cssParserMode) | 4052 static CSSValue* consumeSingleViewportDescriptor(CSSParserTokenRange& range, CSS
PropertyID propId, CSSParserMode cssParserMode) |
4055 { | 4053 { |
4056 CSSValueID id = range.peek().id(); | 4054 CSSValueID id = range.peek().id(); |
4057 switch (propId) { | 4055 switch (propId) { |
4058 case CSSPropertyMinWidth: | 4056 case CSSPropertyMinWidth: |
4059 case CSSPropertyMaxWidth: | 4057 case CSSPropertyMaxWidth: |
4060 case CSSPropertyMinHeight: | 4058 case CSSPropertyMinHeight: |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4092 switch (propId) { | 4090 switch (propId) { |
4093 case CSSPropertyWidth: { | 4091 case CSSPropertyWidth: { |
4094 CSSValue* minWidth = consumeSingleViewportDescriptor(m_range, CSSPropert
yMinWidth, m_context.mode()); | 4092 CSSValue* minWidth = consumeSingleViewportDescriptor(m_range, CSSPropert
yMinWidth, m_context.mode()); |
4095 if (!minWidth) | 4093 if (!minWidth) |
4096 return false; | 4094 return false; |
4097 CSSValue* maxWidth = minWidth; | 4095 CSSValue* maxWidth = minWidth; |
4098 if (!m_range.atEnd()) | 4096 if (!m_range.atEnd()) |
4099 maxWidth = consumeSingleViewportDescriptor(m_range, CSSPropertyMaxWi
dth, m_context.mode()); | 4097 maxWidth = consumeSingleViewportDescriptor(m_range, CSSPropertyMaxWi
dth, m_context.mode()); |
4100 if (!maxWidth || !m_range.atEnd()) | 4098 if (!maxWidth || !m_range.atEnd()) |
4101 return false; | 4099 return false; |
4102 addProperty(CSSPropertyMinWidth, minWidth, important); | 4100 addProperty(CSSPropertyMinWidth, CSSPropertyInvalid, minWidth, important
); |
4103 addProperty(CSSPropertyMaxWidth, maxWidth, important); | 4101 addProperty(CSSPropertyMaxWidth, CSSPropertyInvalid, maxWidth, important
); |
4104 return true; | 4102 return true; |
4105 } | 4103 } |
4106 case CSSPropertyHeight: { | 4104 case CSSPropertyHeight: { |
4107 CSSValue* minHeight = consumeSingleViewportDescriptor(m_range, CSSProper
tyMinHeight, m_context.mode()); | 4105 CSSValue* minHeight = consumeSingleViewportDescriptor(m_range, CSSProper
tyMinHeight, m_context.mode()); |
4108 if (!minHeight) | 4106 if (!minHeight) |
4109 return false; | 4107 return false; |
4110 CSSValue* maxHeight = minHeight; | 4108 CSSValue* maxHeight = minHeight; |
4111 if (!m_range.atEnd()) | 4109 if (!m_range.atEnd()) |
4112 maxHeight = consumeSingleViewportDescriptor(m_range, CSSPropertyMaxH
eight, m_context.mode()); | 4110 maxHeight = consumeSingleViewportDescriptor(m_range, CSSPropertyMaxH
eight, m_context.mode()); |
4113 if (!maxHeight || !m_range.atEnd()) | 4111 if (!maxHeight || !m_range.atEnd()) |
4114 return false; | 4112 return false; |
4115 addProperty(CSSPropertyMinHeight, minHeight, important); | 4113 addProperty(CSSPropertyMinHeight, CSSPropertyInvalid, minHeight, importa
nt); |
4116 addProperty(CSSPropertyMaxHeight, maxHeight, important); | 4114 addProperty(CSSPropertyMaxHeight, CSSPropertyInvalid, maxHeight, importa
nt); |
4117 return true; | 4115 return true; |
4118 } | 4116 } |
4119 case CSSPropertyMinWidth: | 4117 case CSSPropertyMinWidth: |
4120 case CSSPropertyMaxWidth: | 4118 case CSSPropertyMaxWidth: |
4121 case CSSPropertyMinHeight: | 4119 case CSSPropertyMinHeight: |
4122 case CSSPropertyMaxHeight: | 4120 case CSSPropertyMaxHeight: |
4123 case CSSPropertyMinZoom: | 4121 case CSSPropertyMinZoom: |
4124 case CSSPropertyMaxZoom: | 4122 case CSSPropertyMaxZoom: |
4125 case CSSPropertyZoom: | 4123 case CSSPropertyZoom: |
4126 case CSSPropertyUserZoom: | 4124 case CSSPropertyUserZoom: |
4127 case CSSPropertyOrientation: { | 4125 case CSSPropertyOrientation: { |
4128 CSSValue* parsedValue = consumeSingleViewportDescriptor(m_range, propId,
m_context.mode()); | 4126 CSSValue* parsedValue = consumeSingleViewportDescriptor(m_range, propId,
m_context.mode()); |
4129 if (!parsedValue || !m_range.atEnd()) | 4127 if (!parsedValue || !m_range.atEnd()) |
4130 return false; | 4128 return false; |
4131 addProperty(propId, parsedValue, important); | 4129 addProperty(propId, CSSPropertyInvalid, parsedValue, important); |
4132 return true; | 4130 return true; |
4133 } | 4131 } |
4134 default: | 4132 default: |
4135 return false; | 4133 return false; |
4136 } | 4134 } |
4137 } | 4135 } |
4138 | 4136 |
4139 static bool consumeColumnWidthOrCount(CSSParserTokenRange& range, CSSValue*& col
umnWidth, CSSValue*& columnCount) | 4137 static bool consumeColumnWidthOrCount(CSSParserTokenRange& range, CSSValue*& col
umnWidth, CSSValue*& columnCount) |
4140 { | 4138 { |
4141 if (range.peek().id() == CSSValueAuto) { | 4139 if (range.peek().id() == CSSValueAuto) { |
(...skipping 16 matching lines...) Expand all Loading... |
4158 CSSValue* columnCount = nullptr; | 4156 CSSValue* columnCount = nullptr; |
4159 if (!consumeColumnWidthOrCount(m_range, columnWidth, columnCount)) | 4157 if (!consumeColumnWidthOrCount(m_range, columnWidth, columnCount)) |
4160 return false; | 4158 return false; |
4161 consumeColumnWidthOrCount(m_range, columnWidth, columnCount); | 4159 consumeColumnWidthOrCount(m_range, columnWidth, columnCount); |
4162 if (!m_range.atEnd()) | 4160 if (!m_range.atEnd()) |
4163 return false; | 4161 return false; |
4164 if (!columnWidth) | 4162 if (!columnWidth) |
4165 columnWidth = cssValuePool().createIdentifierValue(CSSValueAuto); | 4163 columnWidth = cssValuePool().createIdentifierValue(CSSValueAuto); |
4166 if (!columnCount) | 4164 if (!columnCount) |
4167 columnCount = cssValuePool().createIdentifierValue(CSSValueAuto); | 4165 columnCount = cssValuePool().createIdentifierValue(CSSValueAuto); |
4168 addProperty(CSSPropertyColumnWidth, columnWidth, important); | 4166 addProperty(CSSPropertyColumnWidth, CSSPropertyInvalid, columnWidth, importa
nt); |
4169 addProperty(CSSPropertyColumnCount, columnCount, important); | 4167 addProperty(CSSPropertyColumnCount, CSSPropertyInvalid, columnCount, importa
nt); |
4170 return true; | 4168 return true; |
4171 } | 4169 } |
4172 | 4170 |
4173 bool CSSPropertyParser::consumeShorthandGreedily(const StylePropertyShorthand& s
horthand, bool important) | 4171 bool CSSPropertyParser::consumeShorthandGreedily(const StylePropertyShorthand& s
horthand, bool important) |
4174 { | 4172 { |
4175 ASSERT(shorthand.length() <= 6); // Existing shorthands have at most 6 longh
ands. | 4173 ASSERT(shorthand.length() <= 6); // Existing shorthands have at most 6 longh
ands. |
4176 CSSValue* longhands[6] = { nullptr, nullptr, nullptr, nullptr, nullptr, null
ptr }; | 4174 CSSValue* longhands[6] = { nullptr, nullptr, nullptr, nullptr, nullptr, null
ptr }; |
4177 const CSSPropertyID* shorthandProperties = shorthand.properties(); | 4175 const CSSPropertyID* shorthandProperties = shorthand.properties(); |
4178 do { | 4176 do { |
4179 bool foundLonghand = false; | 4177 bool foundLonghand = false; |
4180 for (size_t i = 0; !foundLonghand && i < shorthand.length(); ++i) { | 4178 for (size_t i = 0; !foundLonghand && i < shorthand.length(); ++i) { |
4181 if (longhands[i]) | 4179 if (longhands[i]) |
4182 continue; | 4180 continue; |
4183 longhands[i] = parseSingleValue(shorthandProperties[i]); | 4181 longhands[i] = parseSingleValue(shorthandProperties[i], shorthand.id
()); |
4184 if (longhands[i]) | 4182 if (longhands[i]) |
4185 foundLonghand = true; | 4183 foundLonghand = true; |
4186 } | 4184 } |
4187 if (!foundLonghand) | 4185 if (!foundLonghand) |
4188 return false; | 4186 return false; |
4189 } while (!m_range.atEnd()); | 4187 } while (!m_range.atEnd()); |
4190 | 4188 |
4191 for (size_t i = 0; i < shorthand.length(); ++i) { | 4189 for (size_t i = 0; i < shorthand.length(); ++i) { |
4192 if (longhands[i]) | 4190 if (longhands[i]) |
4193 addProperty(shorthandProperties[i], longhands[i], important); | 4191 addProperty(shorthandProperties[i], shorthand.id(), longhands[i], im
portant); |
4194 else | 4192 else |
4195 addProperty(shorthandProperties[i], cssValuePool().createImplicitIni
tialValue(), important); | 4193 addProperty(shorthandProperties[i], shorthand.id(), cssValuePool().c
reateImplicitInitialValue(), important); |
4196 } | 4194 } |
4197 return true; | 4195 return true; |
4198 } | 4196 } |
4199 | 4197 |
4200 bool CSSPropertyParser::consumeFlex(bool important) | 4198 bool CSSPropertyParser::consumeFlex(bool important) |
4201 { | 4199 { |
4202 static const double unsetValue = -1; | 4200 static const double unsetValue = -1; |
4203 double flexGrow = unsetValue; | 4201 double flexGrow = unsetValue; |
4204 double flexShrink = unsetValue; | 4202 double flexShrink = unsetValue; |
4205 CSSPrimitiveValue* flexBasis = nullptr; | 4203 CSSPrimitiveValue* flexBasis = nullptr; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4238 if (flexGrow == unsetValue) | 4236 if (flexGrow == unsetValue) |
4239 flexGrow = 1; | 4237 flexGrow = 1; |
4240 if (flexShrink == unsetValue) | 4238 if (flexShrink == unsetValue) |
4241 flexShrink = 1; | 4239 flexShrink = 1; |
4242 if (!flexBasis) | 4240 if (!flexBasis) |
4243 flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::UnitTyp
e::Percentage); | 4241 flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::UnitTyp
e::Percentage); |
4244 } | 4242 } |
4245 | 4243 |
4246 if (!m_range.atEnd()) | 4244 if (!m_range.atEnd()) |
4247 return false; | 4245 return false; |
4248 addProperty(CSSPropertyFlexGrow, cssValuePool().createValue(clampTo<float>(f
lexGrow), CSSPrimitiveValue::UnitType::Number), important); | 4246 addProperty(CSSPropertyFlexGrow, CSSPropertyFlex, cssValuePool().createValue
(clampTo<float>(flexGrow), CSSPrimitiveValue::UnitType::Number), important); |
4249 addProperty(CSSPropertyFlexShrink, cssValuePool().createValue(clampTo<float>
(flexShrink), CSSPrimitiveValue::UnitType::Number), important); | 4247 addProperty(CSSPropertyFlexShrink, CSSPropertyFlex, cssValuePool().createVal
ue(clampTo<float>(flexShrink), CSSPrimitiveValue::UnitType::Number), important); |
4250 addProperty(CSSPropertyFlexBasis, flexBasis, important); | 4248 addProperty(CSSPropertyFlexBasis, CSSPropertyFlex, flexBasis, important); |
4251 return true; | 4249 return true; |
4252 } | 4250 } |
4253 | 4251 |
4254 bool CSSPropertyParser::consumeBorder(bool important) | 4252 bool CSSPropertyParser::consumeBorder(bool important) |
4255 { | 4253 { |
4256 CSSValue* width = nullptr; | 4254 CSSValue* width = nullptr; |
4257 CSSValue* style = nullptr; | 4255 CSSValue* style = nullptr; |
4258 CSSValue* color = nullptr; | 4256 CSSValue* color = nullptr; |
4259 | 4257 |
4260 while (!width || !style || !color) { | 4258 while (!width || !style || !color) { |
4261 if (!width) { | 4259 if (!width) { |
4262 width = consumeLineWidth(m_range, m_context.mode(), UnitlessQuirk::F
orbid); | 4260 width = consumeLineWidth(m_range, m_context.mode(), UnitlessQuirk::F
orbid); |
4263 if (width) | 4261 if (width) |
4264 continue; | 4262 continue; |
4265 } | 4263 } |
4266 if (!style) { | 4264 if (!style) { |
4267 style = parseSingleValue(CSSPropertyBorderLeftStyle); | 4265 style = parseSingleValue(CSSPropertyBorderLeftStyle, CSSPropertyBord
er); |
4268 if (style) | 4266 if (style) |
4269 continue; | 4267 continue; |
4270 } | 4268 } |
4271 if (!color) { | 4269 if (!color) { |
4272 color = consumeColor(m_range, m_context.mode()); | 4270 color = consumeColor(m_range, m_context.mode()); |
4273 if (color) | 4271 if (color) |
4274 continue; | 4272 continue; |
4275 } | 4273 } |
4276 break; | 4274 break; |
4277 } | 4275 } |
(...skipping 13 matching lines...) Expand all Loading... |
4291 addExpandedPropertyForValue(CSSPropertyBorderColor, color, important); | 4289 addExpandedPropertyForValue(CSSPropertyBorderColor, color, important); |
4292 addExpandedPropertyForValue(CSSPropertyBorderImage, cssValuePool().createImp
licitInitialValue(), important); | 4290 addExpandedPropertyForValue(CSSPropertyBorderImage, cssValuePool().createImp
licitInitialValue(), important); |
4293 | 4291 |
4294 return m_range.atEnd(); | 4292 return m_range.atEnd(); |
4295 } | 4293 } |
4296 | 4294 |
4297 bool CSSPropertyParser::consume4Values(const StylePropertyShorthand& shorthand,
bool important) | 4295 bool CSSPropertyParser::consume4Values(const StylePropertyShorthand& shorthand,
bool important) |
4298 { | 4296 { |
4299 ASSERT(shorthand.length() == 4); | 4297 ASSERT(shorthand.length() == 4); |
4300 const CSSPropertyID* longhands = shorthand.properties(); | 4298 const CSSPropertyID* longhands = shorthand.properties(); |
4301 CSSValue* top = parseSingleValue(longhands[0]); | 4299 CSSValue* top = parseSingleValue(longhands[0], shorthand.id()); |
4302 if (!top) | 4300 if (!top) |
4303 return false; | 4301 return false; |
4304 | 4302 |
4305 CSSValue* right = parseSingleValue(longhands[1]); | 4303 CSSValue* right = parseSingleValue(longhands[1], shorthand.id()); |
4306 CSSValue* bottom = nullptr; | 4304 CSSValue* bottom = nullptr; |
4307 CSSValue* left = nullptr; | 4305 CSSValue* left = nullptr; |
4308 if (right) { | 4306 if (right) { |
4309 bottom = parseSingleValue(longhands[2]); | 4307 bottom = parseSingleValue(longhands[2], shorthand.id()); |
4310 if (bottom) | 4308 if (bottom) |
4311 left = parseSingleValue(longhands[3]); | 4309 left = parseSingleValue(longhands[3], shorthand.id()); |
4312 } | 4310 } |
4313 | 4311 |
4314 if (!right) | 4312 if (!right) |
4315 right = top; | 4313 right = top; |
4316 if (!bottom) | 4314 if (!bottom) |
4317 bottom = top; | 4315 bottom = top; |
4318 if (!left) | 4316 if (!left) |
4319 left = right; | 4317 left = right; |
4320 | 4318 |
4321 addProperty(longhands[0], top, important); | 4319 addProperty(longhands[0], shorthand.id(), top, important); |
4322 addProperty(longhands[1], right, important); | 4320 addProperty(longhands[1], shorthand.id(), right, important); |
4323 addProperty(longhands[2], bottom, important); | 4321 addProperty(longhands[2], shorthand.id(), bottom, important); |
4324 addProperty(longhands[3], left, important); | 4322 addProperty(longhands[3], shorthand.id(), left, important); |
4325 | 4323 |
4326 return m_range.atEnd(); | 4324 return m_range.atEnd(); |
4327 } | 4325 } |
4328 | 4326 |
4329 bool CSSPropertyParser::consumeBorderImage(CSSPropertyID property, bool importan
t) | 4327 bool CSSPropertyParser::consumeBorderImage(CSSPropertyID property, bool importan
t) |
4330 { | 4328 { |
4331 CSSValue* source = nullptr; | 4329 CSSValue* source = nullptr; |
4332 CSSValue* slice = nullptr; | 4330 CSSValue* slice = nullptr; |
4333 CSSValue* width = nullptr; | 4331 CSSValue* width = nullptr; |
4334 CSSValue* outset = nullptr; | 4332 CSSValue* outset = nullptr; |
4335 CSSValue* repeat = nullptr; | 4333 CSSValue* repeat = nullptr; |
4336 if (consumeBorderImageComponents(property, m_range, m_context, source, slice
, width, outset, repeat)) { | 4334 if (consumeBorderImageComponents(property, m_range, m_context, source, slice
, width, outset, repeat)) { |
4337 switch (property) { | 4335 switch (property) { |
4338 case CSSPropertyWebkitMaskBoxImage: | 4336 case CSSPropertyWebkitMaskBoxImage: |
4339 addProperty(CSSPropertyWebkitMaskBoxImageSource, source ? source : c
ssValuePool().createImplicitInitialValue(), important); | 4337 addProperty(CSSPropertyWebkitMaskBoxImageSource, CSSPropertyWebkitMa
skBoxImage, source ? source : cssValuePool().createImplicitInitialValue(), impor
tant); |
4340 addProperty(CSSPropertyWebkitMaskBoxImageSlice, slice ? slice : cssV
aluePool().createImplicitInitialValue(), important); | 4338 addProperty(CSSPropertyWebkitMaskBoxImageSlice, CSSPropertyWebkitMas
kBoxImage, slice ? slice : cssValuePool().createImplicitInitialValue(), importan
t); |
4341 addProperty(CSSPropertyWebkitMaskBoxImageWidth, width ? width : cssV
aluePool().createImplicitInitialValue(), important); | 4339 addProperty(CSSPropertyWebkitMaskBoxImageWidth, CSSPropertyWebkitMas
kBoxImage, width ? width : cssValuePool().createImplicitInitialValue(), importan
t); |
4342 addProperty(CSSPropertyWebkitMaskBoxImageOutset, outset ? outset : c
ssValuePool().createImplicitInitialValue(), important); | 4340 addProperty(CSSPropertyWebkitMaskBoxImageOutset, CSSPropertyWebkitMa
skBoxImage, outset ? outset : cssValuePool().createImplicitInitialValue(), impor
tant); |
4343 addProperty(CSSPropertyWebkitMaskBoxImageRepeat, repeat ? repeat : c
ssValuePool().createImplicitInitialValue(), important); | 4341 addProperty(CSSPropertyWebkitMaskBoxImageRepeat, CSSPropertyWebkitMa
skBoxImage, repeat ? repeat : cssValuePool().createImplicitInitialValue(), impor
tant); |
4344 return true; | 4342 return true; |
4345 case CSSPropertyBorderImage: | 4343 case CSSPropertyBorderImage: |
4346 addProperty(CSSPropertyBorderImageSource, source ? source : cssValue
Pool().createImplicitInitialValue(), important); | 4344 addProperty(CSSPropertyBorderImageSource, CSSPropertyBorderImage, so
urce ? source : cssValuePool().createImplicitInitialValue(), important); |
4347 addProperty(CSSPropertyBorderImageSlice, slice ? slice : cssValuePoo
l().createImplicitInitialValue(), important); | 4345 addProperty(CSSPropertyBorderImageSlice, CSSPropertyBorderImage, sli
ce ? slice : cssValuePool().createImplicitInitialValue(), important); |
4348 addProperty(CSSPropertyBorderImageWidth, width ? width : cssValuePoo
l().createImplicitInitialValue(), important); | 4346 addProperty(CSSPropertyBorderImageWidth, CSSPropertyBorderImage, wid
th ? width : cssValuePool().createImplicitInitialValue(), important); |
4349 addProperty(CSSPropertyBorderImageOutset, outset ? outset : cssValue
Pool().createImplicitInitialValue(), important); | 4347 addProperty(CSSPropertyBorderImageOutset, CSSPropertyBorderImage, ou
tset ? outset : cssValuePool().createImplicitInitialValue(), important); |
4350 addProperty(CSSPropertyBorderImageRepeat, repeat ? repeat : cssValue
Pool().createImplicitInitialValue(), important); | 4348 addProperty(CSSPropertyBorderImageRepeat, CSSPropertyBorderImage, re
peat ? repeat : cssValuePool().createImplicitInitialValue(), important); |
4351 return true; | 4349 return true; |
4352 default: | 4350 default: |
4353 ASSERT_NOT_REACHED(); | 4351 ASSERT_NOT_REACHED(); |
4354 return false; | 4352 return false; |
4355 } | 4353 } |
4356 } | 4354 } |
4357 return false; | 4355 return false; |
4358 } | 4356 } |
4359 | 4357 |
4360 static inline CSSValueID mapFromPageBreakBetween(CSSValueID value) | 4358 static inline CSSValueID mapFromPageBreakBetween(CSSValueID value) |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4416 case CSSPropertyWebkitColumnBreakInside: | 4414 case CSSPropertyWebkitColumnBreakInside: |
4417 value = mapFromColumnOrPageBreakInside(value); | 4415 value = mapFromColumnOrPageBreakInside(value); |
4418 break; | 4416 break; |
4419 default: | 4417 default: |
4420 ASSERT_NOT_REACHED(); | 4418 ASSERT_NOT_REACHED(); |
4421 } | 4419 } |
4422 if (value == CSSValueInvalid) | 4420 if (value == CSSValueInvalid) |
4423 return false; | 4421 return false; |
4424 | 4422 |
4425 CSSPropertyID genericBreakProperty = mapFromLegacyBreakProperty(property); | 4423 CSSPropertyID genericBreakProperty = mapFromLegacyBreakProperty(property); |
4426 addProperty(genericBreakProperty, cssValuePool().createIdentifierValue(value
), important); | 4424 addProperty(genericBreakProperty, property, cssValuePool().createIdentifierV
alue(value), important); |
4427 return true; | 4425 return true; |
4428 } | 4426 } |
4429 | 4427 |
4430 static bool consumeBackgroundPosition(CSSParserTokenRange& range, const CSSParse
rContext& context, UnitlessQuirk unitless, CSSValue*& resultX, CSSValue*& result
Y) | 4428 static bool consumeBackgroundPosition(CSSParserTokenRange& range, const CSSParse
rContext& context, UnitlessQuirk unitless, CSSValue*& resultX, CSSValue*& result
Y) |
4431 { | 4429 { |
4432 do { | 4430 do { |
4433 CSSValue* positionX = nullptr; | 4431 CSSValue* positionX = nullptr; |
4434 CSSValue* positionY = nullptr; | 4432 CSSValue* positionY = nullptr; |
4435 if (!consumePosition(range, context.mode(), unitless, positionX, positio
nY)) | 4433 if (!consumePosition(range, context.mode(), unitless, positionX, positio
nY)) |
4436 return false; | 4434 return false; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4551 addBackgroundValue(longhands[i], cssValuePool().createImplicitIn
itialValue()); | 4549 addBackgroundValue(longhands[i], cssValuePool().createImplicitIn
itialValue()); |
4552 } | 4550 } |
4553 } while (consumeCommaIncludingWhitespace(m_range)); | 4551 } while (consumeCommaIncludingWhitespace(m_range)); |
4554 if (!m_range.atEnd()) | 4552 if (!m_range.atEnd()) |
4555 return false; | 4553 return false; |
4556 | 4554 |
4557 for (size_t i = 0; i < longhandCount; ++i) { | 4555 for (size_t i = 0; i < longhandCount; ++i) { |
4558 CSSPropertyID property = shorthand.properties()[i]; | 4556 CSSPropertyID property = shorthand.properties()[i]; |
4559 if (property == CSSPropertyBackgroundSize && longhands[i] && m_context.u
seLegacyBackgroundSizeShorthandBehavior()) | 4557 if (property == CSSPropertyBackgroundSize && longhands[i] && m_context.u
seLegacyBackgroundSizeShorthandBehavior()) |
4560 continue; | 4558 continue; |
4561 addProperty(property, longhands[i], important, implicit); | 4559 addProperty(property, shorthand.id(), longhands[i], important, implicit)
; |
4562 } | 4560 } |
4563 return true; | 4561 return true; |
4564 } | 4562 } |
4565 | 4563 |
4566 bool CSSPropertyParser::consumeGridItemPositionShorthand(CSSPropertyID shorthand
Id, bool important) | 4564 bool CSSPropertyParser::consumeGridItemPositionShorthand(CSSPropertyID shorthand
Id, bool important) |
4567 { | 4565 { |
4568 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 4566 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
4569 const StylePropertyShorthand& shorthand = shorthandForProperty(shorthandId); | 4567 const StylePropertyShorthand& shorthand = shorthandForProperty(shorthandId); |
4570 ASSERT(shorthand.length() == 2); | 4568 ASSERT(shorthand.length() == 2); |
4571 CSSValue* startValue = consumeGridLine(m_range); | 4569 CSSValue* startValue = consumeGridLine(m_range); |
4572 if (!startValue) | 4570 if (!startValue) |
4573 return false; | 4571 return false; |
4574 | 4572 |
4575 CSSValue* endValue = nullptr; | 4573 CSSValue* endValue = nullptr; |
4576 if (consumeSlashIncludingWhitespace(m_range)) { | 4574 if (consumeSlashIncludingWhitespace(m_range)) { |
4577 endValue = consumeGridLine(m_range); | 4575 endValue = consumeGridLine(m_range); |
4578 if (!endValue) | 4576 if (!endValue) |
4579 return false; | 4577 return false; |
4580 } else { | 4578 } else { |
4581 endValue = startValue->isCustomIdentValue() ? startValue : cssValuePool(
).createIdentifierValue(CSSValueAuto); | 4579 endValue = startValue->isCustomIdentValue() ? startValue : cssValuePool(
).createIdentifierValue(CSSValueAuto); |
4582 } | 4580 } |
4583 if (!m_range.atEnd()) | 4581 if (!m_range.atEnd()) |
4584 return false; | 4582 return false; |
4585 addProperty(shorthand.properties()[0], startValue, important); | 4583 addProperty(shorthand.properties()[0], shorthandId, startValue, important); |
4586 addProperty(shorthand.properties()[1], endValue, important); | 4584 addProperty(shorthand.properties()[1], shorthandId, endValue, important); |
4587 return true; | 4585 return true; |
4588 } | 4586 } |
4589 | 4587 |
4590 bool CSSPropertyParser::consumeGridAreaShorthand(bool important) | 4588 bool CSSPropertyParser::consumeGridAreaShorthand(bool important) |
4591 { | 4589 { |
4592 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 4590 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
4593 ASSERT(gridAreaShorthand().length() == 4); | 4591 ASSERT(gridAreaShorthand().length() == 4); |
4594 CSSValue* rowStartValue = consumeGridLine(m_range); | 4592 CSSValue* rowStartValue = consumeGridLine(m_range); |
4595 if (!rowStartValue) | 4593 if (!rowStartValue) |
4596 return false; | 4594 return false; |
(...skipping 17 matching lines...) Expand all Loading... |
4614 } | 4612 } |
4615 if (!m_range.atEnd()) | 4613 if (!m_range.atEnd()) |
4616 return false; | 4614 return false; |
4617 if (!columnStartValue) | 4615 if (!columnStartValue) |
4618 columnStartValue = rowStartValue->isCustomIdentValue() ? rowStartValue :
cssValuePool().createIdentifierValue(CSSValueAuto); | 4616 columnStartValue = rowStartValue->isCustomIdentValue() ? rowStartValue :
cssValuePool().createIdentifierValue(CSSValueAuto); |
4619 if (!rowEndValue) | 4617 if (!rowEndValue) |
4620 rowEndValue = rowStartValue->isCustomIdentValue() ? rowStartValue : cssV
aluePool().createIdentifierValue(CSSValueAuto); | 4618 rowEndValue = rowStartValue->isCustomIdentValue() ? rowStartValue : cssV
aluePool().createIdentifierValue(CSSValueAuto); |
4621 if (!columnEndValue) | 4619 if (!columnEndValue) |
4622 columnEndValue = columnStartValue->isCustomIdentValue() ? columnStartVal
ue : cssValuePool().createIdentifierValue(CSSValueAuto); | 4620 columnEndValue = columnStartValue->isCustomIdentValue() ? columnStartVal
ue : cssValuePool().createIdentifierValue(CSSValueAuto); |
4623 | 4621 |
4624 addProperty(CSSPropertyGridRowStart, rowStartValue, important); | 4622 addProperty(CSSPropertyGridRowStart, CSSPropertyGridArea, rowStartValue, imp
ortant); |
4625 addProperty(CSSPropertyGridColumnStart, columnStartValue, important); | 4623 addProperty(CSSPropertyGridColumnStart, CSSPropertyGridArea, columnStartValu
e, important); |
4626 addProperty(CSSPropertyGridRowEnd, rowEndValue, important); | 4624 addProperty(CSSPropertyGridRowEnd, CSSPropertyGridArea, rowEndValue, importa
nt); |
4627 addProperty(CSSPropertyGridColumnEnd, columnEndValue, important); | 4625 addProperty(CSSPropertyGridColumnEnd, CSSPropertyGridArea, columnEndValue, i
mportant); |
4628 return true; | 4626 return true; |
4629 } | 4627 } |
4630 | 4628 |
4631 bool CSSPropertyParser::consumeGridTemplateRowsAndAreasAndColumns(bool important
) | 4629 bool CSSPropertyParser::consumeGridTemplateRowsAndAreasAndColumns(CSSPropertyID
shorthandId, bool important) |
4632 { | 4630 { |
4633 NamedGridAreaMap gridAreaMap; | 4631 NamedGridAreaMap gridAreaMap; |
4634 size_t rowCount = 0; | 4632 size_t rowCount = 0; |
4635 size_t columnCount = 0; | 4633 size_t columnCount = 0; |
4636 CSSValueList* templateRows = CSSValueList::createSpaceSeparated(); | 4634 CSSValueList* templateRows = CSSValueList::createSpaceSeparated(); |
4637 | 4635 |
4638 // Persists between loop iterations so we can use the same value for | 4636 // Persists between loop iterations so we can use the same value for |
4639 // consecutive <line-names> values | 4637 // consecutive <line-names> values |
4640 CSSGridLineNamesValue* lineNames = nullptr; | 4638 CSSGridLineNamesValue* lineNames = nullptr; |
4641 | 4639 |
(...skipping 24 matching lines...) Expand all Loading... |
4666 CSSValue* columnsValue = nullptr; | 4664 CSSValue* columnsValue = nullptr; |
4667 if (!m_range.atEnd()) { | 4665 if (!m_range.atEnd()) { |
4668 if (!consumeSlashIncludingWhitespace(m_range)) | 4666 if (!consumeSlashIncludingWhitespace(m_range)) |
4669 return false; | 4667 return false; |
4670 columnsValue = consumeGridTrackList(m_range, m_context.mode()); | 4668 columnsValue = consumeGridTrackList(m_range, m_context.mode()); |
4671 if (!columnsValue || !m_range.atEnd()) | 4669 if (!columnsValue || !m_range.atEnd()) |
4672 return false; | 4670 return false; |
4673 } else { | 4671 } else { |
4674 columnsValue = cssValuePool().createIdentifierValue(CSSValueNone); | 4672 columnsValue = cssValuePool().createIdentifierValue(CSSValueNone); |
4675 } | 4673 } |
4676 addProperty(CSSPropertyGridTemplateRows, templateRows, important); | 4674 addProperty(CSSPropertyGridTemplateRows, shorthandId, templateRows, importan
t); |
4677 addProperty(CSSPropertyGridTemplateColumns, columnsValue, important); | 4675 addProperty(CSSPropertyGridTemplateColumns, shorthandId, columnsValue, impor
tant); |
4678 addProperty(CSSPropertyGridTemplateAreas, CSSGridTemplateAreasValue::create(
gridAreaMap, rowCount, columnCount), important); | 4676 addProperty(CSSPropertyGridTemplateAreas, shorthandId, CSSGridTemplateAreasV
alue::create(gridAreaMap, rowCount, columnCount), important); |
4679 return true; | 4677 return true; |
4680 } | 4678 } |
4681 | 4679 |
4682 bool CSSPropertyParser::consumeGridTemplateShorthand(bool important) | 4680 bool CSSPropertyParser::consumeGridTemplateShorthand(CSSPropertyID shorthandId,
bool important) |
4683 { | 4681 { |
4684 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 4682 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
4685 ASSERT(gridTemplateShorthand().length() == 3); | 4683 ASSERT(gridTemplateShorthand().length() == 3); |
4686 | 4684 |
4687 CSSParserTokenRange rangeCopy = m_range; | 4685 CSSParserTokenRange rangeCopy = m_range; |
4688 CSSValue* rowsValue = consumeIdent<CSSValueNone>(m_range); | 4686 CSSValue* rowsValue = consumeIdent<CSSValueNone>(m_range); |
4689 | 4687 |
4690 // 1- 'none' case. | 4688 // 1- 'none' case. |
4691 if (rowsValue && m_range.atEnd()) { | 4689 if (rowsValue && m_range.atEnd()) { |
4692 addProperty(CSSPropertyGridTemplateRows, cssValuePool().createIdentifier
Value(CSSValueNone), important); | 4690 addProperty(CSSPropertyGridTemplateRows, shorthandId, cssValuePool().cre
ateIdentifierValue(CSSValueNone), important); |
4693 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createIdentif
ierValue(CSSValueNone), important); | 4691 addProperty(CSSPropertyGridTemplateColumns, shorthandId, cssValuePool().
createIdentifierValue(CSSValueNone), important); |
4694 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdentifie
rValue(CSSValueNone), important); | 4692 addProperty(CSSPropertyGridTemplateAreas, shorthandId, cssValuePool().cr
eateIdentifierValue(CSSValueNone), important); |
4695 return true; | 4693 return true; |
4696 } | 4694 } |
4697 | 4695 |
4698 // 2- <grid-template-rows> / <grid-template-columns> | 4696 // 2- <grid-template-rows> / <grid-template-columns> |
4699 if (!rowsValue) | 4697 if (!rowsValue) |
4700 rowsValue = consumeGridTrackList(m_range, m_context.mode()); | 4698 rowsValue = consumeGridTrackList(m_range, m_context.mode()); |
4701 | 4699 |
4702 if (rowsValue) { | 4700 if (rowsValue) { |
4703 if (!consumeSlashIncludingWhitespace(m_range)) | 4701 if (!consumeSlashIncludingWhitespace(m_range)) |
4704 return false; | 4702 return false; |
4705 CSSValue* columnsValue = consumeGridTemplatesRowsOrColumns(m_range, m_co
ntext.mode()); | 4703 CSSValue* columnsValue = consumeGridTemplatesRowsOrColumns(m_range, m_co
ntext.mode()); |
4706 if (!columnsValue || !m_range.atEnd()) | 4704 if (!columnsValue || !m_range.atEnd()) |
4707 return false; | 4705 return false; |
4708 | 4706 |
4709 addProperty(CSSPropertyGridTemplateRows, rowsValue, important); | 4707 addProperty(CSSPropertyGridTemplateRows, shorthandId, rowsValue, importa
nt); |
4710 addProperty(CSSPropertyGridTemplateColumns, columnsValue, important); | 4708 addProperty(CSSPropertyGridTemplateColumns, shorthandId, columnsValue, i
mportant); |
4711 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createIdentifie
rValue(CSSValueNone), important); | 4709 addProperty(CSSPropertyGridTemplateAreas, shorthandId, cssValuePool().cr
eateIdentifierValue(CSSValueNone), important); |
4712 return true; | 4710 return true; |
4713 } | 4711 } |
4714 | 4712 |
4715 // 3- [ <line-names>? <string> <track-size>? <line-names>? ]+ [ / <track-lis
t> ]? | 4713 // 3- [ <line-names>? <string> <track-size>? <line-names>? ]+ [ / <track-lis
t> ]? |
4716 m_range = rangeCopy; | 4714 m_range = rangeCopy; |
4717 return consumeGridTemplateRowsAndAreasAndColumns(important); | 4715 return consumeGridTemplateRowsAndAreasAndColumns(shorthandId, important); |
4718 } | 4716 } |
4719 | 4717 |
4720 bool CSSPropertyParser::consumeGridShorthand(bool important) | 4718 bool CSSPropertyParser::consumeGridShorthand(bool important) |
4721 { | 4719 { |
4722 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); | 4720 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); |
4723 ASSERT(shorthandForProperty(CSSPropertyGrid).length() == 8); | 4721 ASSERT(shorthandForProperty(CSSPropertyGrid).length() == 8); |
4724 | 4722 |
4725 CSSParserTokenRange rangeCopy = m_range; | 4723 CSSParserTokenRange rangeCopy = m_range; |
4726 | 4724 |
4727 // 1- <grid-template> | 4725 // 1- <grid-template> |
4728 if (consumeGridTemplateShorthand(important)) { | 4726 if (consumeGridTemplateShorthand(CSSPropertyGrid, important)) { |
4729 // It can only be specified the explicit or the implicit grid properties
in a single grid declaration. | 4727 // It can only be specified the explicit or the implicit grid properties
in a single grid declaration. |
4730 // The sub-properties not specified are set to their initial value, as n
ormal for shorthands. | 4728 // The sub-properties not specified are set to their initial value, as n
ormal for shorthands. |
4731 addProperty(CSSPropertyGridAutoFlow, cssValuePool().createImplicitInitia
lValue(), important); | 4729 addProperty(CSSPropertyGridAutoFlow, CSSPropertyGrid, cssValuePool().cre
ateImplicitInitialValue(), important); |
4732 addProperty(CSSPropertyGridAutoColumns, cssValuePool().createImplicitIni
tialValue(), important); | 4730 addProperty(CSSPropertyGridAutoColumns, CSSPropertyGrid, cssValuePool().
createImplicitInitialValue(), important); |
4733 addProperty(CSSPropertyGridAutoRows, cssValuePool().createImplicitInitia
lValue(), important); | 4731 addProperty(CSSPropertyGridAutoRows, CSSPropertyGrid, cssValuePool().cre
ateImplicitInitialValue(), important); |
4734 addProperty(CSSPropertyGridColumnGap, cssValuePool().createImplicitIniti
alValue(), important); | 4732 addProperty(CSSPropertyGridColumnGap, CSSPropertyGrid, cssValuePool().cr
eateImplicitInitialValue(), important); |
4735 addProperty(CSSPropertyGridRowGap, cssValuePool().createImplicitInitialV
alue(), important); | 4733 addProperty(CSSPropertyGridRowGap, CSSPropertyGrid, cssValuePool().creat
eImplicitInitialValue(), important); |
4736 return true; | 4734 return true; |
4737 } | 4735 } |
4738 | 4736 |
4739 m_range = rangeCopy; | 4737 m_range = rangeCopy; |
4740 | 4738 |
4741 // 2- <grid-auto-flow> [ <grid-auto-rows> [ / <grid-auto-columns> ]? ] | 4739 // 2- <grid-auto-flow> [ <grid-auto-rows> [ / <grid-auto-columns> ]? ] |
4742 CSSValueList* gridAutoFlow = consumeGridAutoFlow(m_range); | 4740 CSSValueList* gridAutoFlow = consumeGridAutoFlow(m_range); |
4743 if (!gridAutoFlow) | 4741 if (!gridAutoFlow) |
4744 return false; | 4742 return false; |
4745 | 4743 |
(...skipping 16 matching lines...) Expand all Loading... |
4762 autoColumnsValue = cssValuePool().createImplicitInitialValue(); | 4760 autoColumnsValue = cssValuePool().createImplicitInitialValue(); |
4763 autoRowsValue = cssValuePool().createImplicitInitialValue(); | 4761 autoRowsValue = cssValuePool().createImplicitInitialValue(); |
4764 } | 4762 } |
4765 | 4763 |
4766 // if <grid-auto-columns> value is omitted, it is set to the value specified
for grid-auto-rows. | 4764 // if <grid-auto-columns> value is omitted, it is set to the value specified
for grid-auto-rows. |
4767 if (!autoColumnsValue) | 4765 if (!autoColumnsValue) |
4768 autoColumnsValue = autoRowsValue; | 4766 autoColumnsValue = autoRowsValue; |
4769 | 4767 |
4770 // It can only be specified the explicit or the implicit grid properties in
a single grid declaration. | 4768 // It can only be specified the explicit or the implicit grid properties in
a single grid declaration. |
4771 // The sub-properties not specified are set to their initial value, as norma
l for shorthands. | 4769 // The sub-properties not specified are set to their initial value, as norma
l for shorthands. |
4772 addProperty(CSSPropertyGridTemplateColumns, cssValuePool().createImplicitIni
tialValue(), important); | 4770 addProperty(CSSPropertyGridTemplateColumns, CSSPropertyGrid, cssValuePool().
createImplicitInitialValue(), important); |
4773 addProperty(CSSPropertyGridTemplateRows, cssValuePool().createImplicitInitia
lValue(), important); | 4771 addProperty(CSSPropertyGridTemplateRows, CSSPropertyGrid, cssValuePool().cre
ateImplicitInitialValue(), important); |
4774 addProperty(CSSPropertyGridTemplateAreas, cssValuePool().createImplicitIniti
alValue(), important); | 4772 addProperty(CSSPropertyGridTemplateAreas, CSSPropertyGrid, cssValuePool().cr
eateImplicitInitialValue(), important); |
4775 addProperty(CSSPropertyGridAutoFlow, gridAutoFlow, important); | 4773 addProperty(CSSPropertyGridAutoFlow, CSSPropertyGrid, gridAutoFlow, importan
t); |
4776 addProperty(CSSPropertyGridAutoColumns, autoColumnsValue, important); | 4774 addProperty(CSSPropertyGridAutoColumns, CSSPropertyGrid, autoColumnsValue, i
mportant); |
4777 addProperty(CSSPropertyGridAutoRows, autoRowsValue, important); | 4775 addProperty(CSSPropertyGridAutoRows, CSSPropertyGrid, autoRowsValue, importa
nt); |
4778 addProperty(CSSPropertyGridColumnGap, cssValuePool().createImplicitInitialVa
lue(), important); | 4776 addProperty(CSSPropertyGridColumnGap, CSSPropertyGrid, cssValuePool().create
ImplicitInitialValue(), important); |
4779 addProperty(CSSPropertyGridRowGap, cssValuePool().createImplicitInitialValue
(), important); | 4777 addProperty(CSSPropertyGridRowGap, CSSPropertyGrid, cssValuePool().createImp
licitInitialValue(), important); |
4780 | |
4781 return true; | 4778 return true; |
4782 } | 4779 } |
4783 | 4780 |
4784 bool CSSPropertyParser::parseShorthand(CSSPropertyID unresolvedProperty, bool im
portant) | 4781 bool CSSPropertyParser::parseShorthand(CSSPropertyID unresolvedProperty, bool im
portant) |
4785 { | 4782 { |
4786 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); | 4783 CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); |
4787 | 4784 |
4788 CSSPropertyID oldShorthand = m_currentShorthand; | |
4789 // TODO(rob.buis): Remove this when the legacy property parser is gone | |
4790 m_currentShorthand = property; | |
4791 switch (property) { | 4785 switch (property) { |
4792 case CSSPropertyWebkitMarginCollapse: { | 4786 case CSSPropertyWebkitMarginCollapse: { |
4793 CSSValueID id = m_range.consumeIncludingWhitespace().id(); | 4787 CSSValueID id = m_range.consumeIncludingWhitespace().id(); |
4794 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyWebki
tMarginBeforeCollapse, id, m_context.mode())) | 4788 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyWebki
tMarginBeforeCollapse, id, m_context.mode())) |
4795 return false; | 4789 return false; |
4796 CSSValue* beforeCollapse = cssValuePool().createIdentifierValue(id); | 4790 CSSValue* beforeCollapse = cssValuePool().createIdentifierValue(id); |
4797 addProperty(CSSPropertyWebkitMarginBeforeCollapse, beforeCollapse, impor
tant); | 4791 addProperty(CSSPropertyWebkitMarginBeforeCollapse, CSSPropertyWebkitMarg
inCollapse, beforeCollapse, important); |
4798 if (m_range.atEnd()) { | 4792 if (m_range.atEnd()) { |
4799 addProperty(CSSPropertyWebkitMarginAfterCollapse, beforeCollapse, im
portant); | 4793 addProperty(CSSPropertyWebkitMarginAfterCollapse, CSSPropertyWebkitM
arginCollapse, beforeCollapse, important); |
4800 return true; | 4794 return true; |
4801 } | 4795 } |
4802 id = m_range.consumeIncludingWhitespace().id(); | 4796 id = m_range.consumeIncludingWhitespace().id(); |
4803 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyWebki
tMarginAfterCollapse, id, m_context.mode())) | 4797 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyWebki
tMarginAfterCollapse, id, m_context.mode())) |
4804 return false; | 4798 return false; |
4805 addProperty(CSSPropertyWebkitMarginAfterCollapse, cssValuePool().createI
dentifierValue(id), important); | 4799 addProperty(CSSPropertyWebkitMarginAfterCollapse, CSSPropertyWebkitMargi
nCollapse, cssValuePool().createIdentifierValue(id), important); |
4806 return true; | 4800 return true; |
4807 } | 4801 } |
4808 case CSSPropertyOverflow: { | 4802 case CSSPropertyOverflow: { |
4809 CSSValueID id = m_range.consumeIncludingWhitespace().id(); | 4803 CSSValueID id = m_range.consumeIncludingWhitespace().id(); |
4810 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyOverf
lowY, id, m_context.mode())) | 4804 if (!CSSParserFastPaths::isValidKeywordPropertyAndValue(CSSPropertyOverf
lowY, id, m_context.mode())) |
4811 return false; | 4805 return false; |
4812 if (!m_range.atEnd()) | 4806 if (!m_range.atEnd()) |
4813 return false; | 4807 return false; |
4814 CSSValue* overflowYValue = cssValuePool().createIdentifierValue(id); | 4808 CSSValue* overflowYValue = cssValuePool().createIdentifierValue(id); |
4815 | 4809 |
4816 CSSValue* overflowXValue = nullptr; | 4810 CSSValue* overflowXValue = nullptr; |
4817 | 4811 |
4818 // FIXME: -webkit-paged-x or -webkit-paged-y only apply to overflow-y. I
f this value has been | 4812 // FIXME: -webkit-paged-x or -webkit-paged-y only apply to overflow-y. I
f this value has been |
4819 // set using the shorthand, then for now overflow-x will default to auto
, but once we implement | 4813 // set using the shorthand, then for now overflow-x will default to auto
, but once we implement |
4820 // pagination controls, it should default to hidden. If the overflow-y v
alue is anything but | 4814 // pagination controls, it should default to hidden. If the overflow-y v
alue is anything but |
4821 // paged-x or paged-y, then overflow-x and overflow-y should have the sa
me value. | 4815 // paged-x or paged-y, then overflow-x and overflow-y should have the sa
me value. |
4822 if (id == CSSValueWebkitPagedX || id == CSSValueWebkitPagedY) | 4816 if (id == CSSValueWebkitPagedX || id == CSSValueWebkitPagedY) |
4823 overflowXValue = cssValuePool().createIdentifierValue(CSSValueAuto); | 4817 overflowXValue = cssValuePool().createIdentifierValue(CSSValueAuto); |
4824 else | 4818 else |
4825 overflowXValue = overflowYValue; | 4819 overflowXValue = overflowYValue; |
4826 addProperty(CSSPropertyOverflowX, overflowXValue, important); | 4820 addProperty(CSSPropertyOverflowX, CSSPropertyOverflow, overflowXValue, i
mportant); |
4827 addProperty(CSSPropertyOverflowY, overflowYValue, important); | 4821 addProperty(CSSPropertyOverflowY, CSSPropertyOverflow, overflowYValue, i
mportant); |
4828 return true; | 4822 return true; |
4829 } | 4823 } |
4830 case CSSPropertyFont: { | 4824 case CSSPropertyFont: { |
4831 const CSSParserToken& token = m_range.peek(); | 4825 const CSSParserToken& token = m_range.peek(); |
4832 if (token.id() >= CSSValueCaption && token.id() <= CSSValueStatusBar) | 4826 if (token.id() >= CSSValueCaption && token.id() <= CSSValueStatusBar) |
4833 return consumeSystemFont(important); | 4827 return consumeSystemFont(important); |
4834 return consumeFont(important); | 4828 return consumeFont(important); |
4835 } | 4829 } |
4836 case CSSPropertyBorderSpacing: | 4830 case CSSPropertyBorderSpacing: |
4837 return consumeBorderSpacing(important); | 4831 return consumeBorderSpacing(important); |
4838 case CSSPropertyColumns: { | 4832 case CSSPropertyColumns: |
4839 // TODO(rwlbuis): investigate if this shorthand hack can be removed. | |
4840 m_currentShorthand = oldShorthand; | |
4841 return consumeColumns(important); | 4833 return consumeColumns(important); |
4842 } | |
4843 case CSSPropertyAnimation: | 4834 case CSSPropertyAnimation: |
4844 return consumeAnimationShorthand(animationShorthandForParsing(), unresol
vedProperty == CSSPropertyAliasWebkitAnimation, important); | 4835 return consumeAnimationShorthand(animationShorthandForParsing(), unresol
vedProperty == CSSPropertyAliasWebkitAnimation, important); |
4845 case CSSPropertyTransition: | 4836 case CSSPropertyTransition: |
4846 return consumeAnimationShorthand(transitionShorthandForParsing(), false,
important); | 4837 return consumeAnimationShorthand(transitionShorthandForParsing(), false,
important); |
4847 case CSSPropertyTextDecoration: | 4838 case CSSPropertyTextDecoration: |
4848 ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled()); | 4839 ASSERT(RuntimeEnabledFeatures::css3TextDecorationsEnabled()); |
4849 return consumeShorthandGreedily(textDecorationShorthand(), important); | 4840 return consumeShorthandGreedily(textDecorationShorthand(), important); |
4850 case CSSPropertyMargin: | 4841 case CSSPropertyMargin: |
4851 return consume4Values(marginShorthand(), important); | 4842 return consume4Values(marginShorthand(), important); |
4852 case CSSPropertyPadding: | 4843 case CSSPropertyPadding: |
(...skipping 11 matching lines...) Expand all Loading... |
4864 case CSSPropertyWebkitBorderBefore: | 4855 case CSSPropertyWebkitBorderBefore: |
4865 return consumeShorthandGreedily(webkitBorderBeforeShorthand(), important
); | 4856 return consumeShorthandGreedily(webkitBorderBeforeShorthand(), important
); |
4866 case CSSPropertyWebkitBorderAfter: | 4857 case CSSPropertyWebkitBorderAfter: |
4867 return consumeShorthandGreedily(webkitBorderAfterShorthand(), important)
; | 4858 return consumeShorthandGreedily(webkitBorderAfterShorthand(), important)
; |
4868 case CSSPropertyWebkitTextStroke: | 4859 case CSSPropertyWebkitTextStroke: |
4869 return consumeShorthandGreedily(webkitTextStrokeShorthand(), important); | 4860 return consumeShorthandGreedily(webkitTextStrokeShorthand(), important); |
4870 case CSSPropertyMarker: { | 4861 case CSSPropertyMarker: { |
4871 CSSValue* marker = parseSingleValue(CSSPropertyMarkerStart); | 4862 CSSValue* marker = parseSingleValue(CSSPropertyMarkerStart); |
4872 if (!marker || !m_range.atEnd()) | 4863 if (!marker || !m_range.atEnd()) |
4873 return false; | 4864 return false; |
4874 addProperty(CSSPropertyMarkerStart, marker, important); | 4865 addProperty(CSSPropertyMarkerStart, CSSPropertyMarker, marker, important
); |
4875 addProperty(CSSPropertyMarkerMid, marker, important); | 4866 addProperty(CSSPropertyMarkerMid, CSSPropertyMarker, marker, important); |
4876 addProperty(CSSPropertyMarkerEnd, marker, important); | 4867 addProperty(CSSPropertyMarkerEnd, CSSPropertyMarker, marker, important); |
4877 return true; | 4868 return true; |
4878 } | 4869 } |
4879 case CSSPropertyFlex: | 4870 case CSSPropertyFlex: |
4880 return consumeFlex(important); | 4871 return consumeFlex(important); |
4881 case CSSPropertyFlexFlow: | 4872 case CSSPropertyFlexFlow: |
4882 return consumeShorthandGreedily(flexFlowShorthand(), important); | 4873 return consumeShorthandGreedily(flexFlowShorthand(), important); |
4883 case CSSPropertyColumnRule: | 4874 case CSSPropertyColumnRule: |
4884 return consumeShorthandGreedily(columnRuleShorthand(), important); | 4875 return consumeShorthandGreedily(columnRuleShorthand(), important); |
4885 case CSSPropertyListStyle: | 4876 case CSSPropertyListStyle: |
4886 return consumeShorthandGreedily(listStyleShorthand(), important); | 4877 return consumeShorthandGreedily(listStyleShorthand(), important); |
4887 case CSSPropertyBorderRadius: { | 4878 case CSSPropertyBorderRadius: { |
4888 CSSPrimitiveValue* horizontalRadii[4] = { 0 }; | 4879 CSSPrimitiveValue* horizontalRadii[4] = { 0 }; |
4889 CSSPrimitiveValue* verticalRadii[4] = { 0 }; | 4880 CSSPrimitiveValue* verticalRadii[4] = { 0 }; |
4890 if (!consumeRadii(horizontalRadii, verticalRadii, m_range, m_context.mod
e(), unresolvedProperty == CSSPropertyAliasWebkitBorderRadius)) | 4881 if (!consumeRadii(horizontalRadii, verticalRadii, m_range, m_context.mod
e(), unresolvedProperty == CSSPropertyAliasWebkitBorderRadius)) |
4891 return false; | 4882 return false; |
4892 addProperty(CSSPropertyBorderTopLeftRadius, CSSValuePair::create(horizon
talRadii[0], verticalRadii[0], CSSValuePair::DropIdenticalValues), important); | 4883 addProperty(CSSPropertyBorderTopLeftRadius, CSSPropertyBorderRadius, CSS
ValuePair::create(horizontalRadii[0], verticalRadii[0], CSSValuePair::DropIdenti
calValues), important); |
4893 addProperty(CSSPropertyBorderTopRightRadius, CSSValuePair::create(horizo
ntalRadii[1], verticalRadii[1], CSSValuePair::DropIdenticalValues), important); | 4884 addProperty(CSSPropertyBorderTopRightRadius, CSSPropertyBorderRadius, CS
SValuePair::create(horizontalRadii[1], verticalRadii[1], CSSValuePair::DropIdent
icalValues), important); |
4894 addProperty(CSSPropertyBorderBottomRightRadius, CSSValuePair::create(hor
izontalRadii[2], verticalRadii[2], CSSValuePair::DropIdenticalValues), important
); | 4885 addProperty(CSSPropertyBorderBottomRightRadius, CSSPropertyBorderRadius,
CSSValuePair::create(horizontalRadii[2], verticalRadii[2], CSSValuePair::DropId
enticalValues), important); |
4895 addProperty(CSSPropertyBorderBottomLeftRadius, CSSValuePair::create(hori
zontalRadii[3], verticalRadii[3], CSSValuePair::DropIdenticalValues), important)
; | 4886 addProperty(CSSPropertyBorderBottomLeftRadius, CSSPropertyBorderRadius,
CSSValuePair::create(horizontalRadii[3], verticalRadii[3], CSSValuePair::DropIde
nticalValues), important); |
4896 return true; | 4887 return true; |
4897 } | 4888 } |
4898 case CSSPropertyBorderColor: | 4889 case CSSPropertyBorderColor: |
4899 return consume4Values(borderColorShorthand(), important); | 4890 return consume4Values(borderColorShorthand(), important); |
4900 case CSSPropertyBorderStyle: | 4891 case CSSPropertyBorderStyle: |
4901 return consume4Values(borderStyleShorthand(), important); | 4892 return consume4Values(borderStyleShorthand(), important); |
4902 case CSSPropertyBorderWidth: | 4893 case CSSPropertyBorderWidth: |
4903 return consume4Values(borderWidthShorthand(), important); | 4894 return consume4Values(borderWidthShorthand(), important); |
4904 case CSSPropertyBorderTop: | 4895 case CSSPropertyBorderTop: |
4905 return consumeShorthandGreedily(borderTopShorthand(), important); | 4896 return consumeShorthandGreedily(borderTopShorthand(), important); |
(...skipping 14 matching lines...) Expand all Loading... |
4920 case CSSPropertyWebkitColumnBreakAfter: | 4911 case CSSPropertyWebkitColumnBreakAfter: |
4921 case CSSPropertyWebkitColumnBreakBefore: | 4912 case CSSPropertyWebkitColumnBreakBefore: |
4922 case CSSPropertyWebkitColumnBreakInside: | 4913 case CSSPropertyWebkitColumnBreakInside: |
4923 return consumeLegacyBreakProperty(property, important); | 4914 return consumeLegacyBreakProperty(property, important); |
4924 case CSSPropertyWebkitMaskPosition: | 4915 case CSSPropertyWebkitMaskPosition: |
4925 case CSSPropertyBackgroundPosition: { | 4916 case CSSPropertyBackgroundPosition: { |
4926 CSSValue* resultX = nullptr; | 4917 CSSValue* resultX = nullptr; |
4927 CSSValue* resultY = nullptr; | 4918 CSSValue* resultY = nullptr; |
4928 if (!consumeBackgroundPosition(m_range, m_context, UnitlessQuirk::Allow,
resultX, resultY) || !m_range.atEnd()) | 4919 if (!consumeBackgroundPosition(m_range, m_context, UnitlessQuirk::Allow,
resultX, resultY) || !m_range.atEnd()) |
4929 return false; | 4920 return false; |
4930 addProperty(property == CSSPropertyBackgroundPosition ? CSSPropertyBackg
roundPositionX : CSSPropertyWebkitMaskPositionX, resultX, important); | 4921 addProperty(property == CSSPropertyBackgroundPosition ? CSSPropertyBackg
roundPositionX : CSSPropertyWebkitMaskPositionX, property, resultX, important); |
4931 addProperty(property == CSSPropertyBackgroundPosition ? CSSPropertyBackg
roundPositionY : CSSPropertyWebkitMaskPositionY, resultY, important); | 4922 addProperty(property == CSSPropertyBackgroundPosition ? CSSPropertyBackg
roundPositionY : CSSPropertyWebkitMaskPositionY, property, resultY, important); |
4932 return true; | 4923 return true; |
4933 } | 4924 } |
4934 case CSSPropertyBackgroundRepeat: | 4925 case CSSPropertyBackgroundRepeat: |
4935 case CSSPropertyWebkitMaskRepeat: { | 4926 case CSSPropertyWebkitMaskRepeat: { |
4936 CSSValue* resultX = nullptr; | 4927 CSSValue* resultX = nullptr; |
4937 CSSValue* resultY = nullptr; | 4928 CSSValue* resultY = nullptr; |
4938 bool implicit = false; | 4929 bool implicit = false; |
4939 if (!consumeRepeatStyle(m_range, resultX, resultY, implicit) || !m_range
.atEnd()) | 4930 if (!consumeRepeatStyle(m_range, resultX, resultY, implicit) || !m_range
.atEnd()) |
4940 return false; | 4931 return false; |
4941 addProperty(property == CSSPropertyBackgroundRepeat ? CSSPropertyBackgro
undRepeatX : CSSPropertyWebkitMaskRepeatX, resultX, important, implicit); | 4932 addProperty(property == CSSPropertyBackgroundRepeat ? CSSPropertyBackgro
undRepeatX : CSSPropertyWebkitMaskRepeatX, property, resultX, important, implici
t); |
4942 addProperty(property == CSSPropertyBackgroundRepeat ? CSSPropertyBackgro
undRepeatY : CSSPropertyWebkitMaskRepeatY, resultY, important, implicit); | 4933 addProperty(property == CSSPropertyBackgroundRepeat ? CSSPropertyBackgro
undRepeatY : CSSPropertyWebkitMaskRepeatY, property, resultY, important, implici
t); |
4943 return true; | 4934 return true; |
4944 } | 4935 } |
4945 case CSSPropertyBackground: | 4936 case CSSPropertyBackground: |
4946 return consumeBackgroundShorthand(backgroundShorthand(), important); | 4937 return consumeBackgroundShorthand(backgroundShorthand(), important); |
4947 case CSSPropertyWebkitMask: | 4938 case CSSPropertyWebkitMask: |
4948 return consumeBackgroundShorthand(webkitMaskShorthand(), important); | 4939 return consumeBackgroundShorthand(webkitMaskShorthand(), important); |
4949 case CSSPropertyGridGap: { | 4940 case CSSPropertyGridGap: { |
4950 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled() && shorthandForPro
perty(CSSPropertyGridGap).length() == 2); | 4941 ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled() && shorthandForPro
perty(CSSPropertyGridGap).length() == 2); |
4951 CSSValue* rowGap = consumeLength(m_range, m_context.mode(), ValueRangeNo
nNegative); | 4942 CSSValue* rowGap = consumeLength(m_range, m_context.mode(), ValueRangeNo
nNegative); |
4952 CSSValue* columnGap = consumeLength(m_range, m_context.mode(), ValueRang
eNonNegative); | 4943 CSSValue* columnGap = consumeLength(m_range, m_context.mode(), ValueRang
eNonNegative); |
4953 if (!rowGap || !m_range.atEnd()) | 4944 if (!rowGap || !m_range.atEnd()) |
4954 return false; | 4945 return false; |
4955 if (!columnGap) | 4946 if (!columnGap) |
4956 columnGap = rowGap; | 4947 columnGap = rowGap; |
4957 addProperty(CSSPropertyGridRowGap, rowGap, important); | 4948 addProperty(CSSPropertyGridRowGap, CSSPropertyGridGap, rowGap, important
); |
4958 addProperty(CSSPropertyGridColumnGap, columnGap, important); | 4949 addProperty(CSSPropertyGridColumnGap, CSSPropertyGridGap, columnGap, imp
ortant); |
4959 return true; | 4950 return true; |
4960 } | 4951 } |
4961 case CSSPropertyGridColumn: | 4952 case CSSPropertyGridColumn: |
4962 case CSSPropertyGridRow: | 4953 case CSSPropertyGridRow: |
4963 return consumeGridItemPositionShorthand(property, important); | 4954 return consumeGridItemPositionShorthand(property, important); |
4964 case CSSPropertyGridArea: | 4955 case CSSPropertyGridArea: |
4965 return consumeGridAreaShorthand(important); | 4956 return consumeGridAreaShorthand(important); |
4966 case CSSPropertyGridTemplate: | 4957 case CSSPropertyGridTemplate: |
4967 return consumeGridTemplateShorthand(important); | 4958 return consumeGridTemplateShorthand(CSSPropertyGridTemplate, important); |
4968 case CSSPropertyGrid: | 4959 case CSSPropertyGrid: |
4969 return consumeGridShorthand(important); | 4960 return consumeGridShorthand(important); |
4970 default: | 4961 default: |
4971 m_currentShorthand = oldShorthand; | |
4972 return false; | 4962 return false; |
4973 } | 4963 } |
4974 } | 4964 } |
4975 | 4965 |
4976 } // namespace blink | 4966 } // namespace blink |
OLD | NEW |