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

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

Issue 1234763007: CSSValue Immediates: Make toCSSPrimitiveValue() return a const reference (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cssvalue_patch_3_tagged_ptrs_finally
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/CSSPrimitiveValueTest.cpp ('k') | no next file » | 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 b2f0a4ef382f1e1c301ec9e2f4a9503e59ef061c..b9d3b052e55182e2427b6a6f048856802d2d3724 100644
--- a/Source/core/css/CSSValue.h
+++ b/Source/core/css/CSSValue.h
@@ -72,7 +72,7 @@ public:
}
// Implicit conversion from CSSPrimitiveValue.
- CSSValue(CSSPrimitiveValue cssPrimitiveValue)
+ CSSValue(const CSSPrimitiveValue& cssPrimitiveValue)
: m_data(static_cast<CSSValueObject*>(cssPrimitiveValue.get()))
{
ref();
@@ -253,7 +253,7 @@ public:
}
// Implicit conversion from CSSPrimitiveValue.
- NullableCSSValue(CSSPrimitiveValue cssPrimitiveValue)
+ NullableCSSValue(const CSSPrimitiveValue& cssPrimitiveValue)
: m_data(static_cast<CSSValueObject*>(cssPrimitiveValue.get()))
{
ref();
@@ -363,6 +363,7 @@ private:
static_assert(sizeof(CSSValue) == sizeof(void*), "CSSValue should be pointer-sized");
static_assert(sizeof(NullableCSSValue) == sizeof(void*), "CSSValue should be pointer-sized");
static_assert(sizeof(CSSValue) == sizeof(NullableCSSValue), "Both CSSValue containers must contain the same data");
+static_assert(sizeof(CSSValue) == sizeof(CSSPrimitiveValue), "Both CSSValue and CSSPrimitiveValue must contain the same data");
template<size_t inlineCapacity>
inline bool compareCSSValueVector(const WillBeHeapVector<CSSValue, inlineCapacity>& firstVector, const WillBeHeapVector<CSSValue, inlineCapacity>& secondVector)
@@ -397,11 +398,18 @@ inline bool compareCSSValueVector(const WillBeHeapVector<CSSValue, inlineCapacit
}
// Returns by value on purpose.
-inline CSSPrimitiveValue toCSSPrimitiveValue(const CSSValue& value)
+inline const CSSPrimitiveValue& toCSSPrimitiveValue(const CSSValue& value)
{
ASSERT_WITH_SECURITY_IMPLICATION(value.isPrimitiveValue());
- return CSSPrimitiveValue(static_cast<CSSPrimitiveValue::CSSLargePrimitiveValue*>(value.get()));
+ return *reinterpret_cast<const CSSPrimitiveValue*>(&value);
}
+/*
+inline CSSPrimitiveValue& toCSSPrimitiveValue(const CSSValue& value)
+{
+ ASSERT_WITH_SECURITY_IMPLICATION(value.isPrimitiveValue());
+ return *const_cast<CSSPrimitiveValue*>(reinterpret_cast<const CSSPrimitiveValue*>(&value));
+}
+*/
} // namespace blink
« no previous file with comments | « Source/core/css/CSSPrimitiveValueTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698