| 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/StyleInheritedVariables.h" | 5 #include "core/style/StyleInheritedVariables.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 |
| 11 bool StyleInheritedVariables::operator==( | 11 bool StyleInheritedVariables::operator==( |
| 12 const StyleInheritedVariables& other) const { | 12 const StyleInheritedVariables& other) const { |
| 13 // It's technically possible for divergent roots to be value-equal, | 13 // It's technically possible for divergent roots to be value-equal, |
| 14 // but unlikely. This equality operator is used for optimization purposes | 14 // but unlikely. This equality operator is used for optimization purposes |
| 15 // so it's OK to be occasionally wrong. | 15 // so it's OK to be occasionally wrong. |
| 16 // TODO(shanestephens): Rename this to something that indicates it may not | 16 // TODO(shanestephens): Rename this to something that indicates it may not |
| 17 // always return equality. | 17 // always return equality. |
| 18 if (m_root != other.m_root) | 18 if (m_root != other.m_root) |
| 19 return false; | 19 return false; |
| 20 | 20 |
| 21 if (m_data.size() != other.m_data.size()) | 21 if (m_data.size() != other.m_data.size()) |
| 22 return false; | 22 return false; |
| 23 | 23 |
| 24 for (const auto& iter : m_data) { | 24 for (const auto& iter : m_data) { |
| 25 RefPtr<CSSVariableData> otherData = other.m_data.get(iter.key); | 25 RefPtr<CSSVariableData> otherData = other.m_data.at(iter.key); |
| 26 if (!dataEquivalent(iter.value, otherData)) | 26 if (!dataEquivalent(iter.value, otherData)) |
| 27 return false; | 27 return false; |
| 28 } | 28 } |
| 29 | 29 |
| 30 return true; | 30 return true; |
| 31 } | 31 } |
| 32 | 32 |
| 33 StyleInheritedVariables::StyleInheritedVariables( | 33 StyleInheritedVariables::StyleInheritedVariables( |
| 34 StyleInheritedVariables& other) { | 34 StyleInheritedVariables& other) { |
| 35 if (!other.m_root) { | 35 if (!other.m_root) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 new HashMap<AtomicString, RefPtr<CSSVariableData>>(m_root->m_data)); | 82 new HashMap<AtomicString, RefPtr<CSSVariableData>>(m_root->m_data)); |
| 83 for (auto it = m_data.begin(); it != m_data.end(); ++it) | 83 for (auto it = m_data.begin(); it != m_data.end(); ++it) |
| 84 result->set(it->key, it->value); | 84 result->set(it->key, it->value); |
| 85 } else { | 85 } else { |
| 86 result.reset(new HashMap<AtomicString, RefPtr<CSSVariableData>>(m_data)); | 86 result.reset(new HashMap<AtomicString, RefPtr<CSSVariableData>>(m_data)); |
| 87 } | 87 } |
| 88 return result; | 88 return result; |
| 89 } | 89 } |
| 90 | 90 |
| 91 } // namespace blink | 91 } // namespace blink |
| OLD | NEW |