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

Side by Side Diff: third_party/WebKit/Source/core/style/StyleVariableData.h

Issue 2310823002: Skeleton implementation of CSS Properties and Values API (Closed)
Patch Set: fix stylevardata copy ctor Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef StyleVariableData_h 5 #ifndef StyleVariableData_h
6 #define StyleVariableData_h 6 #define StyleVariableData_h
7 7
8 #include "core/css/CSSValue.h"
8 #include "core/css/CSSVariableData.h" 9 #include "core/css/CSSVariableData.h"
9 #include "wtf/Forward.h" 10 #include "wtf/Forward.h"
10 #include "wtf/HashMap.h" 11 #include "wtf/HashMap.h"
11 #include "wtf/RefCounted.h" 12 #include "wtf/RefCounted.h"
12 #include "wtf/text/AtomicStringHash.h" 13 #include "wtf/text/AtomicStringHash.h"
13 14
14 namespace blink { 15 namespace blink {
15 16
16 class StyleVariableData : public RefCounted<StyleVariableData> { 17 class StyleVariableData : public RefCounted<StyleVariableData> {
17 public: 18 public:
18 static PassRefPtr<StyleVariableData> create() { return adoptRef(new StyleVar iableData()); } 19 static PassRefPtr<StyleVariableData> create() { return adoptRef(new StyleVar iableData()); }
19 20
20 PassRefPtr<StyleVariableData> copy() { return adoptRef(new StyleVariableData (*this)); } 21 PassRefPtr<StyleVariableData> copy() { return adoptRef(new StyleVariableData (*this)); }
21 22
22 bool operator==(const StyleVariableData& other) const; 23 bool operator==(const StyleVariableData& other) const;
23 bool operator!=(const StyleVariableData& other) const { return !(*this == ot her); } 24 bool operator!=(const StyleVariableData& other) const { return !(*this == ot her); }
24 25
25 void setVariable(const AtomicString& name, PassRefPtr<CSSVariableData> value ) { m_data.set(name, value); } 26 void setVariable(const AtomicString& name, PassRefPtr<CSSVariableData> value ) { m_data.set(name, value); }
26 CSSVariableData* getVariable(const AtomicString& name) const; 27 CSSVariableData* getVariable(const AtomicString& name) const;
27 void removeVariable(const AtomicString& name) { return setVariable(name, nul lptr); } 28 void removeVariable(const AtomicString&);
29
30 void setRegisteredInheritedProperty(const AtomicString&, const CSSValue*);
31 CSSValue* registeredInheritedProperty(const AtomicString& name) const { retu rn m_registeredData.get(name); }
28 32
29 // This map will contain null pointers if variables are invalid due to 33 // This map will contain null pointers if variables are invalid due to
30 // cycles or referencing invalid variables without using a fallback. 34 // cycles or referencing invalid variables without using a fallback.
31 // Note that this method is slow as a new map is constructed. 35 // Note that this method is slow as a new map is constructed.
32 std::unique_ptr<HashMap<AtomicString, RefPtr<CSSVariableData>>> getVariables () const; 36 std::unique_ptr<HashMap<AtomicString, RefPtr<CSSVariableData>>> getVariables () const;
33 private: 37 private:
34 StyleVariableData() 38 StyleVariableData()
35 : m_root(nullptr) 39 : m_root(nullptr)
36 { } 40 { }
37 StyleVariableData(StyleVariableData& other); 41 StyleVariableData(StyleVariableData& other);
38 42
39 friend class CSSVariableResolver; 43 friend class CSSVariableResolver;
40 44
41 HashMap<AtomicString, RefPtr<CSSVariableData>> m_data; 45 HashMap<AtomicString, RefPtr<CSSVariableData>> m_data;
46 HashMap<AtomicString, Persistent<CSSValue>> m_registeredData;
42 RefPtr<StyleVariableData> m_root; 47 RefPtr<StyleVariableData> m_root;
43 }; 48 };
44 49
45 } // namespace blink 50 } // namespace blink
46 51
47 #endif // StyleVariableData_h 52 #endif // StyleVariableData_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/style/ComputedStyle.cpp ('k') | third_party/WebKit/Source/core/style/StyleVariableData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698