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

Unified Diff: third_party/WebKit/Source/core/style/StyleVariableData.h

Issue 1192983003: CSS Custom Properties (Variables) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Whoops, the forward declaration just needed to be moved. Created 5 years, 2 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
Index: third_party/WebKit/Source/core/style/StyleVariableData.h
diff --git a/third_party/WebKit/Source/core/style/StyleVariableData.h b/third_party/WebKit/Source/core/style/StyleVariableData.h
new file mode 100644
index 0000000000000000000000000000000000000000..b2b3d052cc0206f771fc64b50157fe0ee4d584cb
--- /dev/null
+++ b/third_party/WebKit/Source/core/style/StyleVariableData.h
@@ -0,0 +1,34 @@
+#ifndef StyleVariableData_h
+#define StyleVariableData_h
+
+#include "core/css/CSSVariableData.h"
+#include "wtf/Forward.h"
+#include "wtf/HashMap.h"
+#include "wtf/RefCounted.h"
+#include "wtf/text/AtomicStringHash.h"
+
+namespace blink {
+
+class StyleVariableData : public RefCounted<StyleVariableData> {
+public:
+ static PassRefPtr<StyleVariableData> create() { return adoptRef(new StyleVariableData()); }
+ PassRefPtr<StyleVariableData> copy() const { return adoptRef(new StyleVariableData(*this)); }
+
+ bool operator==(const StyleVariableData& other) const { return other.m_data == m_data; }
+ bool operator!=(const StyleVariableData& other) const { return !(*this == other); }
+
+ void setVariable(const AtomicString& name, PassRefPtr<CSSVariableData> value) { m_data.set(name, value); }
+ CSSVariableData* getVariable(const AtomicString& name) const { return m_data.get(name); }
+ void removeVariable(const AtomicString& name) { return m_data.remove(name); }
+private:
+ explicit StyleVariableData() : RefCounted<StyleVariableData>() { }
Timothy Loh 2015/10/15 03:43:48 Not sure if you need to define either of these con
leviw_travelin_and_unemployed 2015/10/20 21:56:53 It's actually necessary for the copy constructor.
Timothy Loh 2015/10/28 05:12:41 But we can write m_data(other.m_data), right?
+ StyleVariableData(const StyleVariableData& other) : RefCounted<StyleVariableData>(), m_data(HashMap<AtomicString, RefPtr<CSSVariableData>>(other.m_data)) { }
+
+ friend class CSSVariableResolver;
+
+ HashMap<AtomicString, RefPtr<CSSVariableData>> m_data;
+};
+
+} // namespace blink
+
+#endif // StyleVariableData_h

Powered by Google App Engine
This is Rietveld 408576698