Index: third_party/WebKit/Source/core/css/resolver/CSSVariableResolver.cpp |
diff --git a/third_party/WebKit/Source/core/css/resolver/CSSVariableResolver.cpp b/third_party/WebKit/Source/core/css/resolver/CSSVariableResolver.cpp |
index 4f998d6c5b74ced729373a54c10632d34b981cde..83da0ea80213589c627483c7d2ce796098fb2edb 100644 |
--- a/third_party/WebKit/Source/core/css/resolver/CSSVariableResolver.cpp |
+++ b/third_party/WebKit/Source/core/css/resolver/CSSVariableResolver.cpp |
@@ -8,7 +8,9 @@ |
#include "core/CSSValueKeywords.h" |
#include "core/StyleBuilderFunctions.h" |
#include "core/StylePropertyShorthand.h" |
+#include "core/css/CSSPendingSubstitutionValue.h" |
#include "core/css/CSSUnsetValue.h" |
+#include "core/css/CSSValuePool.h" |
#include "core/css/CSSVariableData.h" |
#include "core/css/CSSVariableReferenceValue.h" |
#include "core/css/parser/CSSParserToken.h" |
@@ -143,36 +145,59 @@ CSSValue* CSSVariableResolver::resolveVariableReferences(StyleVariableData* styl |
return result; |
} |
-void CSSVariableResolver::resolveAndApplyVariableReferences(StyleResolverState& state, CSSPropertyID id, const CSSVariableReferenceValue& value) |
+const CSSValue* CSSVariableResolver::resolveVariableReferences(StyleResolverState& state, CSSPropertyID id, const CSSVariableReferenceValue& value) |
{ |
+ // Longhand variable references follow this path. |
Timothy Loh
2016/06/22 00:06:12
Longhand -> Non-shorthand
Andy Mutton
2016/06/24 04:53:26
Done.
|
CSSVariableResolver resolver(state.style()->variables()); |
Vector<CSSParserToken> tokens; |
if (resolver.resolveTokenRange(value.variableDataValue()->tokens(), tokens)) { |
CSSParserContext context(HTMLStandardMode, 0); |
- HeapVector<CSSProperty, 256> parsedProperties; |
+ CSSValue* value = CSSPropertyParser::parseSingleValue(id, CSSParserTokenRange(tokens), context); |
+ if (value) { |
Timothy Loh
2016/06/22 00:06:11
Braces { } are not required in Blink for single-li
Andy Mutton
2016/06/24 04:53:26
I prefer keeping, but I also don't really care abo
|
+ return value; |
+ } |
+ } |
+ |
+ return CSSUnsetValue::create(); |
+} |
- // TODO: Non-shorthands should just call CSSPropertyParser::parseSingleValue |
- if (CSSPropertyParser::parseValue(id, false, CSSParserTokenRange(tokens), context, parsedProperties, StyleRule::RuleType::Style)) { |
- unsigned parsedPropertiesCount = parsedProperties.size(); |
- for (unsigned i = 0; i < parsedPropertiesCount; ++i) |
- StyleBuilder::applyProperty(parsedProperties[i].id(), state, *parsedProperties[i].value()); |
- return; |
+const CSSValue* CSSVariableResolver::resolvePendingSubstitutions(StyleResolverState& state, CSSPropertyID id, const CSSPendingSubstitutionValue& pendingValue) |
+{ |
+ // Longhands from shorthand references follow this path. |
+ const CSSValue* value = state.cssValueForLonghandPropertyId(id); |
+ if (!value) { |
+ // Property cache is unset. Let's fill it. |
+ CSSVariableReferenceValue* shorthandValue = pendingValue.shorthandValue(); |
+ CSSPropertyID shorthandPropertyId = pendingValue.shorthandPropertyId(); |
+ |
+ CSSVariableResolver resolver(state.style()->variables()); |
+ |
+ Vector<CSSParserToken> tokens; |
+ if (resolver.resolveTokenRange(shorthandValue->variableDataValue()->tokens(), tokens)) { |
+ CSSParserContext context(HTMLStandardMode, 0); |
+ |
+ HeapVector<CSSProperty, 256> parsedProperties; |
+ |
+ if (CSSPropertyParser::parseValue(shorthandPropertyId, false, CSSParserTokenRange(tokens), context, parsedProperties, StyleRule::RuleType::Style)) { |
+ unsigned parsedPropertiesCount = parsedProperties.size(); |
+ for (unsigned i = 0; i < parsedPropertiesCount; ++i) { |
+ state.setCssValueForLonghandPropertyId(parsedProperties[i].id(), parsedProperties[i].value()); |
+ } |
+ } |
} |
+ value = state.cssValueForLonghandPropertyId(id); |
} |
- CSSUnsetValue* unset = CSSUnsetValue::create(); |
- if (isShorthandProperty(id)) { |
- StylePropertyShorthand shorthand = shorthandForProperty(id); |
- for (unsigned i = 0; i < shorthand.length(); i++) |
- StyleBuilder::applyProperty(shorthand.properties()[i], state, *unset); |
- return; |
+ if (value) { |
+ return value; |
} |
- StyleBuilder::applyProperty(id, state, *unset); |
+ return CSSUnsetValue::create(); |
} |
+ |
void CSSVariableResolver::resolveVariableDefinitions(StyleVariableData* variables) |
{ |
if (!variables) |