OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef StyleVariableData_h | |
6 #define StyleVariableData_h | |
7 | |
8 #include "core/css/CSSValue.h" | |
9 #include "core/css/CSSVariableData.h" | |
10 #include "wtf/Forward.h" | |
11 #include "wtf/HashMap.h" | |
12 #include "wtf/RefCounted.h" | |
13 #include "wtf/text/AtomicStringHash.h" | |
14 | |
15 namespace blink { | |
16 | |
17 class StyleVariableData : public RefCounted<StyleVariableData> { | |
18 public: | |
19 static PassRefPtr<StyleVariableData> create() { return adoptRef(new StyleVar
iableData()); } | |
20 | |
21 PassRefPtr<StyleVariableData> copy() { return adoptRef(new StyleVariableData
(*this)); } | |
22 | |
23 bool operator==(const StyleVariableData& other) const; | |
24 bool operator!=(const StyleVariableData& other) const { return !(*this == ot
her); } | |
25 | |
26 void setVariable(const AtomicString& name, PassRefPtr<CSSVariableData> value
) { m_data.set(name, std::move(value)); } | |
27 CSSVariableData* getVariable(const AtomicString& name) const; | |
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); } | |
32 | |
33 // This map will contain null pointers if variables are invalid due to | |
34 // cycles or referencing invalid variables without using a fallback. | |
35 // Note that this method is slow as a new map is constructed. | |
36 std::unique_ptr<HashMap<AtomicString, RefPtr<CSSVariableData>>> getVariables
() const; | |
37 private: | |
38 StyleVariableData() | |
39 : m_root(nullptr) | |
40 { } | |
41 StyleVariableData(StyleVariableData& other); | |
42 | |
43 friend class CSSVariableResolver; | |
44 | |
45 HashMap<AtomicString, RefPtr<CSSVariableData>> m_data; | |
46 HashMap<AtomicString, Persistent<CSSValue>> m_registeredData; | |
47 RefPtr<StyleVariableData> m_root; | |
48 }; | |
49 | |
50 } // namespace blink | |
51 | |
52 #endif // StyleVariableData_h | |
OLD | NEW |