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

Unified Diff: Source/core/css/CSSValue.h

Issue 1225553002: CSSValue Immediates: Make CSSPrimitiveValue a container (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cssvalue_patch_1
Patch Set: Rebase 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
« no previous file with comments | « Source/core/css/CSSShadowValue.cpp ('k') | Source/core/css/CSSValueObject.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/CSSValue.h
diff --git a/Source/core/css/CSSValue.h b/Source/core/css/CSSValue.h
index 609dcbc85afcae15a768dc5b5debdca568aa6112..ac7df50a004ea2b8914057e1cfcd39f5a06dba76 100644
--- a/Source/core/css/CSSValue.h
+++ b/Source/core/css/CSSValue.h
@@ -22,6 +22,7 @@
#define CSSValue_h
#include "core/CoreExport.h"
+#include "core/css/CSSPrimitiveValue.h"
#include "core/css/CSSValueObject.h"
#include "platform/heap/Handle.h"
#include "wtf/RefCounted.h"
@@ -67,6 +68,13 @@ public:
ref();
}
+ // Implicit conversion from CSSPrimitiveValue.
+ CSSValue(CSSPrimitiveValue cssPrimitiveValue)
+ : m_data(static_cast<CSSValueObject*>(cssPrimitiveValue.get()))
+ {
+ ref();
+ }
+
~CSSValue()
{
deref();
@@ -221,12 +229,19 @@ public:
ref();
}
+ // Implicit conversion from CSSPrimitiveValue.
+ NullableCSSValue(CSSPrimitiveValue cssPrimitiveValue)
+ : m_data(static_cast<CSSValueObject*>(cssPrimitiveValue.get()))
+ {
+ ref();
+ }
+
~NullableCSSValue()
{
deref();
};
- operator bool() const
+ explicit operator bool() const
{
return m_data;
}
@@ -239,12 +254,12 @@ public:
return *this;
}
- bool operator==(const NullableCSSValue& rhs)
+ bool operator==(const NullableCSSValue& rhs) const
{
return m_data ? rhs.m_data && m_data->equals(*rhs.m_data) : !bool(rhs.m_data);
}
- bool operator!=(const NullableCSSValue& rhs)
+ bool operator!=(const NullableCSSValue& rhs) const
{
return !(*this == rhs);
}
@@ -348,6 +363,13 @@ inline bool compareCSSValueVector(const WillBeHeapVector<CSSValue, inlineCapacit
return static_cast<thisType*>(value.get()); \
}
+// Returns by value on purpose.
+inline CSSPrimitiveValue toCSSPrimitiveValue(const CSSValue& value)
+{
+ ASSERT_WITH_SECURITY_IMPLICATION(value.isPrimitiveValue());
+ return CSSPrimitiveValue(static_cast<CSSPrimitiveValue::CSSLargePrimitiveValue*>(value.get()));
+}
+
} // namespace blink
WTF_ALLOW_CLEAR_UNUSED_SLOTS_WITH_MEM_FUNCTIONS(blink::CSSValue);
« no previous file with comments | « Source/core/css/CSSShadowValue.cpp ('k') | Source/core/css/CSSValueObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698