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

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

Issue 1231973006: CSSValue Immediates: Add move operators to CSSValue and NullableCSSValue (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 | « 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 609dcbc85afcae15a768dc5b5debdca568aa6112..28a560cbf2577f6e2fa604c60db5b89e25c0236b 100644
--- a/Source/core/css/CSSValue.h
+++ b/Source/core/css/CSSValue.h
@@ -69,7 +69,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)
@@ -80,6 +83,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
{
return m_data->equals(*other.m_data);
@@ -231,6 +246,12 @@ public:
return m_data;
}
+ NullableCSSValue(NullableCSSValue&& rhs)
+ {
+ m_data = rhs.m_data;
+ rhs.m_data = nullptr;
+ }
+
NullableCSSValue& operator=(const NullableCSSValue& rhs)
{
rhs.ref();
@@ -239,7 +260,14 @@ public:
return *this;
}
- bool operator==(const NullableCSSValue& rhs)
+ NullableCSSValue& operator=(NullableCSSValue&& rhs)
+ {
+ m_data = rhs.m_data;
+ rhs.m_data.clear();
+ return *this;
+ }
+
+ bool operator==(const NullableCSSValue& rhs) const
{
return m_data ? rhs.m_data && m_data->equals(*rhs.m_data) : !bool(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