Chromium Code Reviews| Index: third_party/WebKit/Source/core/css/resolver/StyleBuilderCustom.cpp |
| diff --git a/third_party/WebKit/Source/core/css/resolver/StyleBuilderCustom.cpp b/third_party/WebKit/Source/core/css/resolver/StyleBuilderCustom.cpp |
| index 979f32cc54374af58aecbb0937da78d33518f64f..7aeff7e377ad2748e1aea3551f40796ba1543167 100644 |
| --- a/third_party/WebKit/Source/core/css/resolver/StyleBuilderCustom.cpp |
| +++ b/third_party/WebKit/Source/core/css/resolver/StyleBuilderCustom.cpp |
| @@ -46,6 +46,7 @@ |
| #include "core/css/CSSBasicShapeValues.h" |
| #include "core/css/CSSCounterValue.h" |
| #include "core/css/CSSCursorImageValue.h" |
| +#include "core/css/CSSCustomPropertyDeclaration.h" |
| #include "core/css/CSSFunctionValue.h" |
| #include "core/css/CSSGradientValue.h" |
| #include "core/css/CSSGridTemplateAreasValue.h" |
| @@ -56,8 +57,10 @@ |
| #include "core/css/CSSPropertyMetadata.h" |
| #include "core/css/CSSURIValue.h" |
| #include "core/css/CSSValuePair.h" |
| +#include "core/css/CSSVariableReferenceValue.h" |
| #include "core/css/StylePropertySet.h" |
| #include "core/css/StyleRule.h" |
| +#include "core/css/resolver/CSSVariableResolver.h" |
| #include "core/css/resolver/ElementStyleResources.h" |
| #include "core/css/resolver/FilterOperationResolver.h" |
| #include "core/css/resolver/FontBuilder.h" |
| @@ -108,6 +111,11 @@ static inline bool isValidVisitedLinkProperty(CSSPropertyID id) |
| void StyleBuilder::applyProperty(CSSPropertyID id, StyleResolverState& state, CSSValue* value) |
| { |
| + if (RuntimeEnabledFeatures::cssVariablesEnabled() && id != CSSPropertyVariable && value->isVariableReferenceValue()) { |
| + CSSVariableResolver::resolveAndApplyVariableReferences(state, id, *toCSSVariableReferenceValue(value)); |
| + return; |
| + } |
| + |
| ASSERT_WITH_MESSAGE(!isShorthandProperty(id), "Shorthand property id = %d wasn't expanded at parsing time", id); |
| bool isInherit = state.parentNode() && value->isInheritedValue(); |
| @@ -818,6 +826,34 @@ void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextOrientation(StyleReso |
| state.setTextOrientation(*toCSSPrimitiveValue(value)); |
| } |
| +void StyleBuilderFunctions::applyValueCSSPropertyVariable(StyleResolverState& state, CSSValue* value) |
| +{ |
| + CSSCustomPropertyDeclaration* varVal = toCSSCustomPropertyDeclaration(value); |
|
Timothy Loh
2015/10/15 03:43:48
varVal -> declaration?
|
| + switch (varVal->id()) { |
| + case CSSValueInitial: |
| + state.style()->removeVariable(varVal->name()); |
| + break; |
| + |
| + case CSSValueUnset: |
| + case CSSValueInherit: { |
| + state.style()->removeVariable(varVal->name()); |
| + StyleVariableData* parentVariables = state.parentStyle()->variables(); |
| + if (!parentVariables) |
| + return; |
| + CSSVariableData* value = parentVariables->getVariable(varVal->name()); |
| + if (!value) |
| + return; |
| + state.style()->setVariable(varVal->name(), value); |
| + break; |
| + } |
| + case CSSValueInternalVariableValue: |
| + state.style()->setVariable(varVal->name(), varVal->value()); |
| + break; |
| + default: |
| + ASSERT_NOT_REACHED(); |
| + } |
| +} |
| + |
| void StyleBuilderFunctions::applyInheritCSSPropertyBaselineShift(StyleResolverState& state) |
| { |
| const SVGComputedStyle& parentSvgStyle = state.parentStyle()->svgStyle(); |