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

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

Issue 1192983003: CSS Custom Properties (Variables) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: ToTed Created 5 years, 4 months 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: Source/core/css/resolver/StyleBuilderCustom.cpp
diff --git a/Source/core/css/resolver/StyleBuilderCustom.cpp b/Source/core/css/resolver/StyleBuilderCustom.cpp
index ff629ab79e437a58c16a05f4d9d724c6861f07c9..b746dfcaba3ff7720991a3a9e3e9e8e8264092bd 100644
--- a/Source/core/css/resolver/StyleBuilderCustom.cpp
+++ b/Source/core/css/resolver/StyleBuilderCustom.cpp
@@ -44,6 +44,7 @@
#include "core/StylePropertyShorthand.h"
#include "core/css/BasicShapeFunctions.h"
#include "core/css/CSSCursorImageValue.h"
+#include "core/css/CSSCustomVariableValue.h"
#include "core/css/CSSGradientValue.h"
#include "core/css/CSSGridTemplateAreasValue.h"
#include "core/css/CSSHelper.h"
@@ -56,6 +57,10 @@
#include "core/css/Pair.h"
#include "core/css/StylePropertySet.h"
#include "core/css/StyleRule.h"
+#include "core/css/parser/CSSParser.h"
Timothy Loh 2015/08/25 09:21:11 parser includes not needed here?
+#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"
@@ -106,6 +111,11 @@ static inline bool isValidVisitedLinkProperty(CSSPropertyID id)
void StyleBuilder::applyProperty(CSSPropertyID id, StyleResolverState& state, CSSValue* value)
{
+ if (RuntimeEnabledFeatures::cssVariablesEnabled() && id != CSSPropertyVariable && value->isPrimitiveValue() && toCSSPrimitiveValue(value)->isVariableReference()) {
+ 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();
@@ -799,6 +809,35 @@ void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextOrientation(StyleReso
state.setTextOrientation(*toCSSPrimitiveValue(value));
}
+void StyleBuilderFunctions::applyValueCSSPropertyVariable(StyleResolverState& state, CSSValue* value)
+{
+ CSSCustomVariableValue* varVal = toCSSCustomVariableValue(value);
+ switch (varVal->id()) {
+ case CSSValueInitial:
+ state.style()->removeVariable(varVal->name());
+ break;
+
+ case CSSValueUnset:
Timothy Loh 2015/08/25 09:21:11 Shouldn't unset and inherit do the same thing?
+ state.style()->removeVariable(varVal->name());
+ // Intentional fallthrough.
+ case CSSValueInherit: {
+ 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();

Powered by Google App Engine
This is Rietveld 408576698