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

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

Issue 2366313006: CSS Properties and Values API: Support non-inherited custom properties (Closed)
Patch Set: use de morgan's law Created 4 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 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 StyleInheritedVariables_h
6 #define StyleVariableData_h 6 #define StyleInheritedVariables_h
7 7
8 #include "core/css/CSSValue.h" 8 #include "core/css/CSSValue.h"
9 #include "core/css/CSSVariableData.h" 9 #include "core/css/CSSVariableData.h"
10 #include "wtf/Forward.h" 10 #include "wtf/Forward.h"
11 #include "wtf/HashMap.h" 11 #include "wtf/HashMap.h"
12 #include "wtf/RefCounted.h" 12 #include "wtf/RefCounted.h"
13 #include "wtf/text/AtomicStringHash.h" 13 #include "wtf/text/AtomicStringHash.h"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 class StyleVariableData : public RefCounted<StyleVariableData> { 17 class StyleInheritedVariables : public RefCounted<StyleInheritedVariables> {
18 public: 18 public:
19 static PassRefPtr<StyleVariableData> create() { return adoptRef(new StyleVar iableData()); } 19 static PassRefPtr<StyleInheritedVariables> create() { return adoptRef(new St yleInheritedVariables()); }
20 20
21 PassRefPtr<StyleVariableData> copy() { return adoptRef(new StyleVariableData (*this)); } 21 PassRefPtr<StyleInheritedVariables> copy() { return adoptRef(new StyleInheri tedVariables(*this)); }
22 22
23 bool operator==(const StyleVariableData& other) const; 23 bool operator==(const StyleInheritedVariables& other) const;
24 bool operator!=(const StyleVariableData& other) const { return !(*this == ot her); } 24 bool operator!=(const StyleInheritedVariables& other) const { return !(*this == other); }
25 25
26 void setVariable(const AtomicString& name, PassRefPtr<CSSVariableData> value ) { m_data.set(name, std::move(value)); } 26 void setVariable(const AtomicString& name, PassRefPtr<CSSVariableData> value ) { m_data.set(name, std::move(value)); }
27 CSSVariableData* getVariable(const AtomicString& name) const; 27 CSSVariableData* getVariable(const AtomicString& name) const;
28 void removeVariable(const AtomicString&); 28 void removeVariable(const AtomicString&);
29 29
30 void setRegisteredInheritedProperty(const AtomicString&, const CSSValue*); 30 void setRegisteredVariable(const AtomicString&, const CSSValue*);
31 CSSValue* registeredInheritedProperty(const AtomicString& name) const { retu rn m_registeredData.get(name); } 31 CSSValue* registeredVariable(const AtomicString&) const;
32 32
33 // 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
34 // cycles or referencing invalid variables without using a fallback. 34 // cycles or referencing invalid variables without using a fallback.
35 // 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.
36 std::unique_ptr<HashMap<AtomicString, RefPtr<CSSVariableData>>> getVariables () const; 36 std::unique_ptr<HashMap<AtomicString, RefPtr<CSSVariableData>>> getVariables () const;
37 private: 37 private:
38 StyleVariableData() 38 StyleInheritedVariables()
39 : m_root(nullptr) 39 : m_root(nullptr)
40 { } 40 { }
41 StyleVariableData(StyleVariableData& other); 41 StyleInheritedVariables(StyleInheritedVariables& other);
42 42
43 friend class CSSVariableResolver; 43 friend class CSSVariableResolver;
44 44
45 HashMap<AtomicString, RefPtr<CSSVariableData>> m_data; 45 HashMap<AtomicString, RefPtr<CSSVariableData>> m_data;
46 HashMap<AtomicString, Persistent<CSSValue>> m_registeredData; 46 HashMap<AtomicString, Persistent<CSSValue>> m_registeredData;
47 RefPtr<StyleVariableData> m_root; 47 RefPtr<StyleInheritedVariables> m_root;
48 }; 48 };
49 49
50 } // namespace blink 50 } // namespace blink
51 51
52 #endif // StyleVariableData_h 52 #endif // StyleInheritedVariables_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698