| Index: Source/core/css/CSSValue.h
|
| diff --git a/Source/core/css/CSSValue.h b/Source/core/css/CSSValue.h
|
| index b9d3b052e55182e2427b6a6f048856802d2d3724..cd3942687dc4f5101f584d4b03b8ec13b3f2f209 100644
|
| --- a/Source/core/css/CSSValue.h
|
| +++ b/Source/core/css/CSSValue.h
|
| @@ -65,30 +65,48 @@ public:
|
| }
|
| #endif
|
|
|
| - CSSValue(const CSSValue& cssValue)
|
| + CSSValue(CSSValue const& cssValue)
|
| : m_data(cssValue.m_data)
|
| {
|
| ref();
|
| }
|
|
|
| +
|
| + CSSValue(CSSValue&& cssValue)
|
| + : m_data(cssValue.m_data)
|
| + {
|
| + cssValue.m_data.clear();
|
| + }
|
| +
|
| +
|
| // Implicit conversion from CSSPrimitiveValue.
|
| CSSValue(const CSSPrimitiveValue& cssPrimitiveValue)
|
| - : m_data(static_cast<CSSValueObject*>(cssPrimitiveValue.get()))
|
| + : m_data(reinterpret_cast<CSSValueObject*>(cssPrimitiveValue.get()))
|
| {
|
| ref();
|
| }
|
|
|
| ~CSSValue()
|
| {
|
| - deref();
|
| + // Could be null, because of move operations.
|
| + if (m_data)
|
| + deref();
|
| }
|
|
|
| + /*
|
| CSSValue& operator=(const CSSValue& rhs)
|
| {
|
| rhs.ref();
|
| deref();
|
| m_data = rhs.m_data;
|
| return *this;
|
| + }*/
|
| +
|
| + CSSValue& operator=(CSSValue&& rhs)
|
| + {
|
| + m_data = rhs.m_data.get();
|
| + rhs.m_data = nullptr;
|
| + return *this;
|
| }
|
|
|
| bool operator==(const CSSValue& other) const
|
| @@ -177,25 +195,25 @@ private:
|
| CSSValue() = delete; // compile-time guard
|
| CSSValue(std::nullptr_t) = delete; // compile-time guard
|
|
|
| - void ref() const
|
| + inline void ref() const
|
| {
|
| #if !ENABLE(OILPAN)
|
| - if (m_data && isObject())
|
| + if (isObject())
|
| m_data->ref();
|
| #endif
|
| }
|
|
|
| - void deref() const
|
| + inline void deref() const
|
| {
|
| #if !ENABLE(OILPAN)
|
| - if (m_data && isObject())
|
| + if (isObject())
|
| m_data->deref();
|
| #endif
|
| }
|
|
|
| bool isObject() const
|
| {
|
| - return !(*reinterpret_cast<const uintptr_t*>(&m_data) & 1);
|
| + return !(reinterpret_cast<const uintptr_t>(m_data.get()) & 1);
|
| }
|
|
|
| RawPtrWillBeMember<CSSValueObject> m_data;
|
| @@ -252,6 +270,18 @@ public:
|
| ref();
|
| }
|
|
|
| + NullableCSSValue(CSSValue&& cssValue)
|
| + : m_data(cssValue.m_data)
|
| + {
|
| + cssValue.m_data.clear();
|
| + }
|
| +
|
| + NullableCSSValue(NullableCSSValue&& cssValue)
|
| + : m_data(cssValue.m_data)
|
| + {
|
| + cssValue.m_data.clear();
|
| + }
|
| +
|
| // Implicit conversion from CSSPrimitiveValue.
|
| NullableCSSValue(const CSSPrimitiveValue& cssPrimitiveValue)
|
| : m_data(static_cast<CSSValueObject*>(cssPrimitiveValue.get()))
|
| @@ -269,7 +299,7 @@ public:
|
| return m_data;
|
| }
|
|
|
| - NullableCSSValue& operator=(const NullableCSSValue& rhs)
|
| + NullableCSSValue& operator=(NullableCSSValue const& rhs)
|
| {
|
| rhs.ref();
|
| deref();
|
| @@ -277,6 +307,13 @@ public:
|
| return *this;
|
| }
|
|
|
| + NullableCSSValue& operator=(NullableCSSValue&& rhs)
|
| + {
|
| + m_data = rhs.m_data.get();
|
| + rhs.m_data = nullptr;
|
| + return *this;
|
| + }
|
| +
|
| bool operator==(const NullableCSSValue& rhs) const
|
| {
|
| if (m_data == rhs.m_data)
|
| @@ -291,25 +328,12 @@ public:
|
| return !(*this == rhs);
|
| }
|
|
|
| - CSSValue& operator*()
|
| - {
|
| - ASSERT(m_data);
|
| - // reinterpret_casts used to avoid ref-churn.
|
| - return *reinterpret_cast<CSSValue*>(this);
|
| - }
|
| -
|
| const CSSValue& operator*() const
|
| {
|
| ASSERT(m_data);
|
| return *reinterpret_cast<const CSSValue*>(this);
|
| }
|
|
|
| - CSSValue* operator->()
|
| - {
|
| - ASSERT(m_data);
|
| - return reinterpret_cast<CSSValue*>(this);
|
| - }
|
| -
|
| const CSSValue* operator->() const
|
| {
|
| ASSERT(m_data);
|
| @@ -354,7 +378,7 @@ private:
|
|
|
| bool isObject() const
|
| {
|
| - return !(*reinterpret_cast<const uintptr_t*>(&m_data) & 1);
|
| + return !(reinterpret_cast<const uintptr_t>(m_data.get()) & 1);
|
| }
|
|
|
| RawPtrWillBeMember<CSSValueObject> m_data;
|
| @@ -389,6 +413,18 @@ inline bool compareCSSValueVector(const WillBeHeapVector<CSSValue, inlineCapacit
|
| ASSERT_WITH_SECURITY_IMPLICATION(value.predicate); \
|
| return *static_cast<thisType*>(value.get()); \
|
| } \
|
| + inline thisType& to##thisType(CSSValue&& value) \
|
| + { \
|
| + ASSERT_WITH_SECURITY_IMPLICATION(value.predicate); \
|
| + return *static_cast<thisType*>(value.get()); \
|
| + } \
|
| + inline thisType* to##thisType(NullableCSSValue&& value) \
|
| + { \
|
| + if (!value) \
|
| + return nullptr; \
|
| + ASSERT_WITH_SECURITY_IMPLICATION(value->predicate); \
|
| + return static_cast<thisType*>(value.get()); \
|
| + } \
|
| inline thisType* to##thisType(const NullableCSSValue& value) \
|
| { \
|
| if (!value) \
|
| @@ -397,19 +433,17 @@ inline bool compareCSSValueVector(const WillBeHeapVector<CSSValue, inlineCapacit
|
| return static_cast<thisType*>(value.get()); \
|
| }
|
|
|
| -// Returns by value on purpose.
|
| inline const CSSPrimitiveValue& toCSSPrimitiveValue(const CSSValue& value)
|
| {
|
| ASSERT_WITH_SECURITY_IMPLICATION(value.isPrimitiveValue());
|
| return *reinterpret_cast<const CSSPrimitiveValue*>(&value);
|
| }
|
| -/*
|
| -inline CSSPrimitiveValue& toCSSPrimitiveValue(const CSSValue& value)
|
| +
|
| +inline const CSSPrimitiveValue& toCSSPrimitiveValue(CSSValue&& value)
|
| {
|
| ASSERT_WITH_SECURITY_IMPLICATION(value.isPrimitiveValue());
|
| - return *const_cast<CSSPrimitiveValue*>(reinterpret_cast<const CSSPrimitiveValue*>(&value));
|
| + return *reinterpret_cast<const CSSPrimitiveValue*>(&value);
|
| }
|
| -*/
|
|
|
| } // namespace blink
|
|
|
|
|