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

Unified Diff: Source/core/css/CSSCalculationValue.cpp

Issue 1192983003: CSS Custom Properties (Variables) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: with missing files Created 5 years, 6 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/CSSCalculationValue.cpp
diff --git a/Source/core/css/CSSCalculationValue.cpp b/Source/core/css/CSSCalculationValue.cpp
index 998fba4d322d019fc2069e1f42690de038ab1169..9208235947c97b683929a7090e7c37d741855d20 100644
--- a/Source/core/css/CSSCalculationValue.cpp
+++ b/Source/core/css/CSSCalculationValue.cpp
@@ -32,6 +32,7 @@
#include "core/css/CSSCalculationValue.h"
#include "core/css/CSSPrimitiveValueMappings.h"
+#include "core/css/parser/CSSPropertyParser.h"
#include "core/css/resolver/StyleResolver.h"
#include "wtf/MathExtras.h"
#include "wtf/OwnPtr.h"
@@ -80,6 +81,8 @@ static CalculationCategory unitCategory(CSSPrimitiveValue::UnitType type)
case CSSPrimitiveValue::CSS_HZ:
case CSSPrimitiveValue::CSS_KHZ:
return CalcFrequency;
+ case CSSPrimitiveValue::CSS_VARIABLE_REFERENCE:
+ return CalcVariable;
default:
return CalcOther;
}
@@ -135,6 +138,7 @@ static bool hasDoubleValue(CSSPrimitiveValue::UnitType type)
case CSSPrimitiveValue::CSS_PROPERTY_ID:
case CSSPrimitiveValue::CSS_VALUE_ID:
case CSSPrimitiveValue::CSS_QEM:
+ case CSSPrimitiveValue::CSS_VARIABLE_REFERENCE:
return false;
};
ASSERT_NOT_REACHED();
@@ -243,6 +247,7 @@ public:
case CalcPercentLength:
case CalcPercentNumber:
case CalcTime:
+ case CalcVariable:
case CalcOther:
ASSERT_NOT_REACHED();
break;
@@ -308,6 +313,9 @@ static CalculationCategory determineCategory(const CSSCalcExpressionNode& leftSi
if (leftCategory == CalcOther || rightCategory == CalcOther)
return CalcOther;
+ if (leftCategory == CalcVariable || rightCategory == CalcVariable)
+ return CalcVariable;
+
switch (op) {
case CalcAdd:
case CalcSubtract:
@@ -529,6 +537,8 @@ public:
return CSSPrimitiveValue::CSS_MS;
case CalcFrequency:
return CSSPrimitiveValue::CSS_HZ;
+ case CalcVariable:
+ return CSSPrimitiveValue::CSS_VARIABLE_REFERENCE;
case CalcPercentLength:
case CalcPercentNumber:
case CalcOther:
@@ -635,10 +645,21 @@ private:
bool parseValue(CSSParserValueList* tokens, unsigned* index, Value* result)
{
CSSParserValue* parserValue = tokens->valueAt(*index);
- if (parserValue->unit >= CSSParserValue::Operator)
- return false;
+
+ if (parserValue->unit >= CSSParserValue::Operator) {
+ // We still have to check for variables, which are parser values
+ if (!RuntimeEnabledFeatures::cssVariablesEnabled() || !CSSPropertyParser::isVariableReference(parserValue))
+ return false;
+
+ result->value = CSSCalcPrimitiveValue::create(
+ CSSPrimitiveValue::create(parserValue->function->args->valueAt(0)->string, CSSPrimitiveValue::CSS_VARIABLE_REFERENCE), parserValue->isInt);
+ ++*index;
+
+ return true;
+ }
CSSPrimitiveValue::UnitType type = static_cast<CSSPrimitiveValue::UnitType>(parserValue->unit);
+
if (unitCategory(type) == CalcOther)
return false;

Powered by Google App Engine
This is Rietveld 408576698