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

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

Issue 1192983003: CSS Custom Properties (Variables) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: ToT-ed again... Created 5 years, 5 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 a4eb31adb59c44b655d1fcb7e70f63912d60a1b1..ce2b7b50d2462a4e2ec64a16824afd4c784d9b7d 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"
@@ -248,6 +249,15 @@ CSSPrimitiveValue::CSSPrimitiveValue(const String& str, UnitType type)
m_value.string->ref();
}
+CSSPrimitiveValue::CSSPrimitiveValue(CSSVariableData* variableData)
+ : CSSValue(PrimitiveClass)
+{
+ m_primitiveUnitType = CSSPrimitiveValue::CSS_VARIABLE_REFERENCE;
+ m_value.variableData = variableData;
+ if (m_value.variableData)
Timothy Loh 2015/07/23 08:11:46 Is this ever null (here and in cleanup())?
+ m_value.variableData->ref();
+}
+
CSSPrimitiveValue::CSSPrimitiveValue(const LengthSize& lengthSize, const ComputedStyle& style)
: CSSValue(PrimitiveClass)
{
@@ -397,6 +407,10 @@ void CSSPrimitiveValue::cleanup()
if (m_value.string)
m_value.string->deref();
break;
+ case CSS_VARIABLE_REFERENCE:
+ if (m_value.variableData)
+ m_value.variableData->deref();
+ break;
case CSS_COUNTER:
// We must not call deref() when oilpan is enabled because m_value.counter is traced.
#if !ENABLE(OILPAN)
@@ -820,6 +834,8 @@ String CSSPrimitiveValue::getStringValue() const
return valueName(m_value.valueID);
case CSS_PROPERTY_ID:
return propertyName(m_value.propertyID);
+ case CSS_VARIABLE_REFERENCE:
+ return m_value.variableData->string();
default:
break;
}
@@ -929,6 +945,7 @@ const char* CSSPrimitiveValue::unitTypeToString(UnitType type)
case CSS_CALC_PERCENTAGE_WITH_NUMBER:
case CSS_CALC_PERCENTAGE_WITH_LENGTH:
case CSS_QEM:
+ case CSS_VARIABLE_REFERENCE:
break;
};
ASSERT_NOT_REACHED();
@@ -1049,6 +1066,9 @@ String CSSPrimitiveValue::customCSSText() const
case CSS_SHAPE:
text = m_value.shape->cssText();
break;
+ case CSS_VARIABLE_REFERENCE:
+ text = "var(" + String(m_value.string) + ")";
Timothy Loh 2015/07/23 08:11:46 Looks wrong, we only have m_value.variableData, ri
+ break;
}
ASSERT(!cssTextCache().contains(this));
@@ -1101,6 +1121,7 @@ bool CSSPrimitiveValue::equals(const CSSPrimitiveValue& other) const
case CSS_STRING:
case CSS_URI:
case CSS_ATTR:
+ case CSS_VARIABLE_REFERENCE:
return equal(m_value.string, other.m_value.string);
Timothy Loh 2015/07/23 08:11:46 Like above, isn't m_value.string invalid for CSS_V
case CSS_COUNTER:
return m_value.counter && other.m_value.counter && m_value.counter->equals(*other.m_value.counter);

Powered by Google App Engine
This is Rietveld 408576698