OLD | NEW |
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 #include "core/style/StyleVariableData.h" | 5 #include "core/style/StyleVariableData.h" |
6 | 6 |
7 #include "core/style/DataEquivalency.h" | 7 #include "core/style/DataEquivalency.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 return true; | 30 return true; |
31 } | 31 } |
32 | 32 |
33 StyleVariableData::StyleVariableData(StyleVariableData& other) | 33 StyleVariableData::StyleVariableData(StyleVariableData& other) |
34 { | 34 { |
35 if (!other.m_root) { | 35 if (!other.m_root) { |
36 m_root = &other; | 36 m_root = &other; |
37 } else { | 37 } else { |
38 m_data = other.m_data; | 38 m_data = other.m_data; |
| 39 m_registeredData = other.m_registeredData; |
39 m_root = other.m_root; | 40 m_root = other.m_root; |
40 } | 41 } |
41 } | 42 } |
42 | 43 |
43 CSSVariableData* StyleVariableData::getVariable(const AtomicString& name) const | 44 CSSVariableData* StyleVariableData::getVariable(const AtomicString& name) const |
44 { | 45 { |
45 auto result = m_data.find(name); | 46 auto result = m_data.find(name); |
46 if (result == m_data.end() && m_root) | 47 if (result == m_data.end() && m_root) |
47 return m_root->getVariable(name); | 48 return m_root->getVariable(name); |
48 if (result == m_data.end()) | 49 if (result == m_data.end()) |
49 return nullptr; | 50 return nullptr; |
50 return result->value.get(); | 51 return result->value.get(); |
51 } | 52 } |
52 | 53 |
| 54 void StyleVariableData::setRegisteredInheritedProperty(const AtomicString& name,
const CSSValue* parsedValue) |
| 55 { |
| 56 m_registeredData.set(name, const_cast<CSSValue*>(parsedValue)); |
| 57 } |
| 58 |
| 59 void StyleVariableData::removeVariable(const AtomicString& name) |
| 60 { |
| 61 m_data.set(name, nullptr); |
| 62 auto iterator = m_registeredData.find(name); |
| 63 if (iterator != m_registeredData.end()) |
| 64 iterator->value = nullptr; |
| 65 } |
| 66 |
53 std::unique_ptr<HashMap<AtomicString, RefPtr<CSSVariableData>>> StyleVariableDat
a::getVariables() const | 67 std::unique_ptr<HashMap<AtomicString, RefPtr<CSSVariableData>>> StyleVariableDat
a::getVariables() const |
54 { | 68 { |
55 std::unique_ptr<HashMap<AtomicString, RefPtr<CSSVariableData>>> result; | 69 std::unique_ptr<HashMap<AtomicString, RefPtr<CSSVariableData>>> result; |
56 if (m_root) { | 70 if (m_root) { |
57 result.reset(new HashMap<AtomicString, RefPtr<CSSVariableData>>(m_root->
m_data)); | 71 result.reset(new HashMap<AtomicString, RefPtr<CSSVariableData>>(m_root->
m_data)); |
58 for (auto it = m_data.begin(); it != m_data.end(); ++it) | 72 for (auto it = m_data.begin(); it != m_data.end(); ++it) |
59 result->set(it->key, it->value); | 73 result->set(it->key, it->value); |
60 } else { | 74 } else { |
61 result.reset(new HashMap<AtomicString, RefPtr<CSSVariableData>>(m_data))
; | 75 result.reset(new HashMap<AtomicString, RefPtr<CSSVariableData>>(m_data))
; |
62 } | 76 } |
63 return result; | 77 return result; |
64 } | 78 } |
65 | 79 |
66 } // namespace blink | 80 } // namespace blink |
OLD | NEW |