Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Unified Diff: third_party/WebKit/Source/core/css/resolver/StyleBuilderCustom.cpp

Issue 1192983003: CSS Custom Properties (Variables) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Use m_unit Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 5943b343d79f52940f4134609269175f0e8107ab..e9e56d3b274778cc4e1ebf1803823c3491e7e38d 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();
@@ -813,6 +821,34 @@ void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextOrientation(StyleReso
state.setTextOrientation(toCSSPrimitiveValue(value)->convertTo<TextOrientation>());
}
+void StyleBuilderFunctions::applyValueCSSPropertyVariable(StyleResolverState& state, CSSValue* value)
+{
+ CSSCustomPropertyDeclaration* declaration = toCSSCustomPropertyDeclaration(value);
+ switch (declaration->id()) {
+ case CSSValueInitial:
+ state.style()->removeVariable(declaration->name());
+ break;
+
+ case CSSValueUnset:
+ case CSSValueInherit: {
+ state.style()->removeVariable(declaration->name());
+ StyleVariableData* parentVariables = state.parentStyle()->variables();
+ if (!parentVariables)
+ return;
+ CSSVariableData* value = parentVariables->getVariable(declaration->name());
+ if (!value)
+ return;
+ state.style()->setVariable(declaration->name(), value);
+ break;
+ }
+ case CSSValueInternalVariableValue:
+ state.style()->setVariable(declaration->name(), declaration->value());
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+}
+
void StyleBuilderFunctions::applyInheritCSSPropertyBaselineShift(StyleResolverState& state)
{
const SVGComputedStyle& parentSvgStyle = state.parentStyle()->svgStyle();

Powered by Google App Engine
This is Rietveld 408576698