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

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

Issue 2310823002: Skeleton implementation of CSS Properties and Values API (Closed)
Patch Set: custom properties :D 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 #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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 CSSVariableData* StyleVariableData::getVariable(const AtomicString& name) const 43 CSSVariableData* StyleVariableData::getVariable(const AtomicString& name) const
44 { 44 {
45 auto result = m_data.find(name); 45 auto result = m_data.find(name);
46 if (result == m_data.end() && m_root) 46 if (result == m_data.end() && m_root)
47 return m_root->getVariable(name); 47 return m_root->getVariable(name);
48 if (result == m_data.end()) 48 if (result == m_data.end())
49 return nullptr; 49 return nullptr;
50 return result->value.get(); 50 return result->value.get();
51 } 51 }
52 52
53 void StyleVariableData::setRegisteredInheritedProperty(const AtomicString& name, const CSSValue* parsedValue)
54 {
55 m_registeredData.set(name, const_cast<CSSValue*>(parsedValue));
56 }
57
58 void StyleVariableData::removeVariable(const AtomicString& name)
59 {
60 m_data.set(name, nullptr);
61 auto iterator = m_registeredData.find(name);
62 if (iterator != m_registeredData.end())
63 iterator->value = nullptr;
64 }
65
53 std::unique_ptr<HashMap<AtomicString, RefPtr<CSSVariableData>>> StyleVariableDat a::getVariables() const 66 std::unique_ptr<HashMap<AtomicString, RefPtr<CSSVariableData>>> StyleVariableDat a::getVariables() const
54 { 67 {
55 std::unique_ptr<HashMap<AtomicString, RefPtr<CSSVariableData>>> result; 68 std::unique_ptr<HashMap<AtomicString, RefPtr<CSSVariableData>>> result;
56 if (m_root) { 69 if (m_root) {
57 result.reset(new HashMap<AtomicString, RefPtr<CSSVariableData>>(m_root-> m_data)); 70 result.reset(new HashMap<AtomicString, RefPtr<CSSVariableData>>(m_root-> m_data));
58 for (auto it = m_data.begin(); it != m_data.end(); ++it) 71 for (auto it = m_data.begin(); it != m_data.end(); ++it)
59 result->set(it->key, it->value); 72 result->set(it->key, it->value);
60 } else { 73 } else {
61 result.reset(new HashMap<AtomicString, RefPtr<CSSVariableData>>(m_data)) ; 74 result.reset(new HashMap<AtomicString, RefPtr<CSSVariableData>>(m_data)) ;
62 } 75 }
63 return result; 76 return result;
64 } 77 }
65 78
66 } // namespace blink 79 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698