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

Unified Diff: Source/core/css/CSSPrimitiveValue.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/CSSPrimitiveValue.cpp
diff --git a/Source/core/css/CSSPrimitiveValue.cpp b/Source/core/css/CSSPrimitiveValue.cpp
index 58513f96ef008040bfe4d41135b4599416277d8b..251008998f5946d6ea74c4706f1df781afb736db 100644
--- a/Source/core/css/CSSPrimitiveValue.cpp
+++ b/Source/core/css/CSSPrimitiveValue.cpp
@@ -26,6 +26,7 @@
#include "core/css/CSSHelper.h"
#include "core/css/CSSMarkup.h"
#include "core/css/CSSToLengthConversionData.h"
+#include "core/css/CSSVariableData.h"
#include "core/css/Counter.h"
#include "core/css/Pair.h"
#include "core/css/Rect.h"
@@ -245,6 +246,15 @@ CSSPrimitiveValue::CSSPrimitiveValue(const String& str, UnitType type)
m_value.string->ref();
}
+CSSPrimitiveValue::CSSPrimitiveValue(CSSVariableData* variableData)
+ : CSSValue(PrimitiveClass)
+{
+ init(UnitType::VariableReference);
+ m_value.variableData = variableData;
+ ASSERT(m_value.variableData);
+ m_value.variableData->ref();
+}
alancutter (OOO until 2018) 2015/08/25 01:59:08 This should be done in an init(PassRefPtrWillBeRaw
+
CSSPrimitiveValue::CSSPrimitiveValue(const LengthSize& lengthSize, const ComputedStyle& style)
: CSSValue(PrimitiveClass)
{
@@ -439,6 +449,11 @@ void CSSPrimitiveValue::cleanup()
m_value.shape->deref();
#endif
break;
+ case UnitType::VariableReference:
+#if !ENABLE(OILPAN)
+ m_value.variableData->deref();
+#endif
+ break;
case UnitType::Number:
case UnitType::Integer:
case UnitType::Percentage:
@@ -928,6 +943,7 @@ const char* CSSPrimitiveValue::unitTypeToString(UnitType type)
case UnitType::CalcPercentageWithNumber:
case UnitType::CalcPercentageWithLength:
case UnitType::QuirkyEms:
+ case UnitType::VariableReference:
break;
};
ASSERT_NOT_REACHED();
@@ -1048,6 +1064,15 @@ String CSSPrimitiveValue::customCSSText() const
case UnitType::Shape:
text = m_value.shape->cssText();
break;
+ case UnitType::VariableReference: {
+ StringBuilder result;
+ result.appendLiteral("var(");
Timothy Loh 2015/08/25 09:21:09 Shouldn't this just return (..).serialize(), inste
+ CSSParserTokenRange range = m_value.variableData->tokenRange();
+ result.append(range.serialize());
+ result.appendLiteral(")");
+ text = result.toString();
+ break;
+ }
case UnitType::CalcPercentageWithNumber:
case UnitType::CalcPercentageWithLength:
case UnitType::QuirkyEms:
@@ -1120,6 +1145,8 @@ bool CSSPrimitiveValue::equals(const CSSPrimitiveValue& other) const
return m_value.calc && other.m_value.calc && m_value.calc->equals(*other.m_value.calc);
case UnitType::Shape:
return m_value.shape && other.m_value.shape && m_value.shape->equals(*other.m_value.shape);
+ case UnitType::VariableReference:
+ return m_value.variableData == other.m_value.variableData;
case UnitType::Integer:
case UnitType::Chs:
case UnitType::CalcPercentageWithNumber:

Powered by Google App Engine
This is Rietveld 408576698