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

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

Issue 1261763005: CSSValue Immediates: Add move operators to CSSValue and NullableCSSValue (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cssvalue_patch_3_tagged_pointers
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 | « no previous file | 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..2102da7f1f21c6eaeac439afb54ae8465e055a6f 100644
--- a/Source/core/css/CSSValue.h
+++ b/Source/core/css/CSSValue.h
@@ -80,7 +80,10 @@ public:
~CSSValue()
{
- deref();
+ // Although m_data can't be null, a move constructor from NullableCSSValue
+ // could make it null for a short time.
+ if (m_data)
+ deref();
}
CSSValue& operator=(const CSSValue& rhs)
@@ -91,6 +94,18 @@ public:
return *this;
}
+ CSSValue& operator=(CSSValue&& rhs)
+ {
+ m_data = rhs.m_data;
+ rhs.m_data.clear();
+ return *this;
+ }
+
+ CSSValue(CSSValue&& rhs)
+ {
+ m_data = rhs.m_data;
+ }
+
bool operator==(const CSSValue& other) const
{
if (m_data == other.m_data)
@@ -269,6 +284,18 @@ public:
return m_data;
}
+ NullableCSSValue(NullableCSSValue&& rhs)
+ {
+ m_data = rhs.m_data;
+ rhs.m_data = nullptr;
+ }
+
+ NullableCSSValue(CSSValue&& rhs)
+ {
+ m_data = rhs.m_data;
+ rhs.m_data = nullptr;
+ }
+
NullableCSSValue& operator=(const NullableCSSValue& rhs)
{
rhs.ref();
@@ -277,6 +304,13 @@ public:
return *this;
}
+ NullableCSSValue& operator=(NullableCSSValue&& rhs)
+ {
+ m_data = rhs.m_data;
+ rhs.m_data.clear();
+ return *this;
+ }
+
bool operator==(const NullableCSSValue& rhs) const
{
if (m_data == rhs.m_data)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698