| 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/resolver/CSSVariableResolver.h" | 5 #include "core/css/resolver/CSSVariableResolver.h" |
| 6 | 6 |
| 7 #include "core/CSSPropertyNames.h" | 7 #include "core/CSSPropertyNames.h" |
| 8 #include "core/CSSValueKeywords.h" | 8 #include "core/CSSValueKeywords.h" |
| 9 #include "core/StyleBuilderFunctions.h" | 9 #include "core/StyleBuilderFunctions.h" |
| 10 #include "core/StylePropertyShorthand.h" | 10 #include "core/StylePropertyShorthand.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 ASSERT(!isShorthandProperty(id)); | 106 ASSERT(!isShorthandProperty(id)); |
| 107 | 107 |
| 108 CSSVariableResolver resolver(styleVariableData); | 108 CSSVariableResolver resolver(styleVariableData); |
| 109 Vector<CSSParserToken> tokens; | 109 Vector<CSSParserToken> tokens; |
| 110 if (!resolver.resolveTokenRange(value.variableDataValue()->tokens(), tokens)
) | 110 if (!resolver.resolveTokenRange(value.variableDataValue()->tokens(), tokens)
) |
| 111 return cssValuePool().createUnsetValue(); | 111 return cssValuePool().createUnsetValue(); |
| 112 | 112 |
| 113 CSSParserContext context(HTMLStandardMode, nullptr); | 113 CSSParserContext context(HTMLStandardMode, nullptr); |
| 114 WillBeHeapVector<CSSProperty, 256> parsedProperties; | 114 WillBeHeapVector<CSSProperty, 256> parsedProperties; |
| 115 // TODO(timloh): This should be CSSParser::parseSingleValue and not need a v
ector. | 115 // TODO(timloh): This should be CSSParser::parseSingleValue and not need a v
ector. |
| 116 if (!CSSPropertyParser::parseValue(id, false, CSSParserTokenRange(tokens), c
ontext, parsedProperties, StyleRule::Type::Style)) | 116 if (!CSSPropertyParser::parseValue(id, false, CSSParserTokenRange(tokens), c
ontext, parsedProperties, StyleRule::RuleType::Style)) |
| 117 return cssValuePool().createUnsetValue(); | 117 return cssValuePool().createUnsetValue(); |
| 118 ASSERT(parsedProperties.size() == 1); | 118 ASSERT(parsedProperties.size() == 1); |
| 119 return parsedProperties[0].value(); | 119 return parsedProperties[0].value(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void CSSVariableResolver::resolveAndApplyVariableReferences(StyleResolverState&
state, CSSPropertyID id, const CSSVariableReferenceValue& value) | 122 void CSSVariableResolver::resolveAndApplyVariableReferences(StyleResolverState&
state, CSSPropertyID id, const CSSVariableReferenceValue& value) |
| 123 { | 123 { |
| 124 CSSVariableResolver resolver(state.style()->variables()); | 124 CSSVariableResolver resolver(state.style()->variables()); |
| 125 | 125 |
| 126 Vector<CSSParserToken> tokens; | 126 Vector<CSSParserToken> tokens; |
| 127 if (resolver.resolveTokenRange(value.variableDataValue()->tokens(), tokens))
{ | 127 if (resolver.resolveTokenRange(value.variableDataValue()->tokens(), tokens))
{ |
| 128 CSSParserContext context(HTMLStandardMode, 0); | 128 CSSParserContext context(HTMLStandardMode, 0); |
| 129 | 129 |
| 130 WillBeHeapVector<CSSProperty, 256> parsedProperties; | 130 WillBeHeapVector<CSSProperty, 256> parsedProperties; |
| 131 | 131 |
| 132 if (CSSPropertyParser::parseValue(id, false, CSSParserTokenRange(tokens)
, context, parsedProperties, StyleRule::Type::Style)) { | 132 if (CSSPropertyParser::parseValue(id, false, CSSParserTokenRange(tokens)
, context, parsedProperties, StyleRule::RuleType::Style)) { |
| 133 unsigned parsedPropertiesCount = parsedProperties.size(); | 133 unsigned parsedPropertiesCount = parsedProperties.size(); |
| 134 for (unsigned i = 0; i < parsedPropertiesCount; ++i) | 134 for (unsigned i = 0; i < parsedPropertiesCount; ++i) |
| 135 StyleBuilder::applyProperty(parsedProperties[i].id(), state, par
sedProperties[i].value()); | 135 StyleBuilder::applyProperty(parsedProperties[i].id(), state, par
sedProperties[i].value()); |
| 136 return; | 136 return; |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 | 139 |
| 140 RefPtrWillBeRawPtr<CSSUnsetValue> unset = cssValuePool().createUnsetValue(); | 140 RefPtrWillBeRawPtr<CSSUnsetValue> unset = cssValuePool().createUnsetValue(); |
| 141 if (isShorthandProperty(id)) { | 141 if (isShorthandProperty(id)) { |
| 142 StylePropertyShorthand shorthand = shorthandForProperty(id); | 142 StylePropertyShorthand shorthand = shorthandForProperty(id); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 159 variable.value = resolver.resolveCustomProperty(variable.key, *varia
ble.value); | 159 variable.value = resolver.resolveCustomProperty(variable.key, *varia
ble.value); |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 | 162 |
| 163 CSSVariableResolver::CSSVariableResolver(StyleVariableData* styleVariableData) | 163 CSSVariableResolver::CSSVariableResolver(StyleVariableData* styleVariableData) |
| 164 : m_styleVariableData(styleVariableData) | 164 : m_styleVariableData(styleVariableData) |
| 165 { | 165 { |
| 166 } | 166 } |
| 167 | 167 |
| 168 } // namespace blink | 168 } // namespace blink |
| OLD | NEW |