Index: Source/core/css/resolver/StyleBuilderCustom.cpp |
diff --git a/Source/core/css/resolver/StyleBuilderCustom.cpp b/Source/core/css/resolver/StyleBuilderCustom.cpp |
index eefd6cc6d4ca7854247e16577902c80b892926b9..7f8a92c801839282923f0e2d10ca387a339aaf28 100644 |
--- a/Source/core/css/resolver/StyleBuilderCustom.cpp |
+++ b/Source/core/css/resolver/StyleBuilderCustom.cpp |
@@ -52,10 +52,16 @@ |
#include "core/css/CSSPathValue.h" |
#include "core/css/CSSPrimitiveValueMappings.h" |
#include "core/css/CSSPropertyMetadata.h" |
+#include "core/css/CSSReflectValue.h" |
+#include "core/css/CSSVariableValue.h" |
#include "core/css/Counter.h" |
#include "core/css/Pair.h" |
#include "core/css/StylePropertySet.h" |
#include "core/css/StyleRule.h" |
+#include "core/css/parser/CSSParser.h" |
+#include "core/css/parser/CSSParserTokenRange.h" |
+#include "core/css/parser/CSSPropertyParser.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" |
@@ -104,8 +110,18 @@ static inline bool isValidVisitedLinkProperty(CSSPropertyID id) |
} // namespace |
+static bool hasVariableReference(CSSValue* value) |
+{ |
+ return value->isPrimitiveValue() && toCSSPrimitiveValue(value)->primitiveType() == CSSPrimitiveValue::CSS_VARIABLE_REFERENCE; |
+} |
+ |
void StyleBuilder::applyProperty(CSSPropertyID id, StyleResolverState& state, CSSValue* value) |
{ |
+ if (RuntimeEnabledFeatures::cssVariablesEnabled() /*&& state.documentUsesCSSVariables()*/ && id != CSSPropertyVariable && hasVariableReference(value)) { |
+ CSSVariableResolver::resolveAndApplyVariableReferences(state, id, toCSSPrimitiveValue(value)); |
+ return; |
+ } |
+ |
ASSERT_WITH_MESSAGE(!isShorthandProperty(id), "Shorthand property id = %d wasn't expanded at parsing time", id); |
bool isInherit = state.parentNode() && value->isInheritedValue(); |
@@ -798,6 +814,47 @@ void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextOrientation(StyleReso |
state.setTextOrientation(*toCSSPrimitiveValue(value)); |
} |
+void StyleBuilderFunctions::applyValueCSSPropertyVariable(StyleResolverState& state, CSSValue* value) |
+{ |
+ CSSVariableValue* varVal = toCSSVariableValue(value); |
+ if (state.style()->variables()) { |
+ switch (varVal->id()) { |
+ case CSSValueInitial: |
+ state.style()->variables()->removeVariable(varVal->name()); |
+ break; |
+ case CSSValueInherit: { |
+ StyleVariableData* parentVariables = state.parentStyle()->variables(); |
+ if (!parentVariables) |
+ return; |
+ CSSVariableData* value = parentVariables->getVariable(varVal->name()); |
+ if (!value) |
+ return; |
+ state.style()->variables()->setVariable(varVal->name(), value); |
+ break; |
+ } |
+ case CSSValueInternalVariableValue: |
+ state.style()->variables()->setVariable(varVal->name(), varVal->value()); |
+ break; |
+ default: |
+ ASSERT_NOT_REACHED(); |
+ } |
+ } else if (varVal->id() == CSSValueInternalVariableValue) { |
+ RefPtr<StyleVariableData> variableData = state.parentStyle()->variables() ? state.parentStyle()->variables()->copy() : StyleVariableData::create(); |
+ variableData->setVariable(varVal->name(), varVal->value()); |
+ state.style()->setVariables(variableData.release()); |
+ } |
+} |
+ |
+void StyleBuilderFunctions::applyInheritCSSPropertyVariable(StyleResolverState& state) |
+{ |
+ ASSERT_NOT_REACHED(); |
+} |
+ |
+void StyleBuilderFunctions::applyInitialCSSPropertyVariable(StyleResolverState& state) |
+{ |
+ ASSERT_NOT_REACHED(); |
+} |
alancutter (OOO until 2018)
2015/06/26 06:56:08
Can we use the regular StyleBuilder machinery for
|
+ |
void StyleBuilderFunctions::applyInheritCSSPropertyBaselineShift(StyleResolverState& state) |
{ |
const SVGComputedStyle& parentSvgStyle = state.parentStyle()->svgStyle(); |