Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/css/resolver/StyleRuleUsageTracker.h" | 5 #include "core/css/resolver/StyleRuleUsageTracker.h" |
| 6 | 6 |
| 7 #include "core/css/CSSStyleSheet.h" | |
| 7 #include "core/css/StyleRule.h" | 8 #include "core/css/StyleRule.h" |
| 8 | 9 |
| 9 namespace blink { | 10 namespace blink { |
| 10 | 11 |
| 11 bool StyleRuleUsageTracker::contains(StyleRule* rule) const { | 12 StyleRuleUsageTracker::RuleListByStyleSheet StyleRuleUsageTracker::takeDelta() { |
| 12 return m_ruleList.contains(rule); | 13 RuleListByStyleSheet result; |
| 14 result.swap(m_usedRulesDelta); | |
| 15 return result; | |
| 16 } | |
| 17 | |
| 18 void StyleRuleUsageTracker::track(const StyleRule* rule, | |
| 19 const CSSStyleSheet* parentSheet) { | |
| 20 if (!parentSheet) | |
| 21 return; | |
| 22 if (!m_usedRules.insert(rule).isNewEntry) | |
|
pfeldman
2017/03/21 18:04:16
This is not entirely correct due to stylesheetcont
| |
| 23 return; | |
| 24 auto it = m_usedRulesDelta.find(parentSheet); | |
| 25 if (it != m_usedRulesDelta.end()) { | |
| 26 it->value.push_back(rule); | |
| 27 } else { | |
| 28 m_usedRulesDelta.insert(parentSheet, HeapVector<Member<const StyleRule>>()) | |
| 29 .storedValue->value.push_back(rule); | |
| 30 } | |
| 13 } | 31 } |
| 14 | 32 |
| 15 DEFINE_TRACE(StyleRuleUsageTracker) { | 33 DEFINE_TRACE(StyleRuleUsageTracker) { |
| 16 visitor->trace(m_ruleList); | 34 visitor->trace(m_usedRules); |
| 35 visitor->trace(m_usedRulesDelta); | |
| 17 } | 36 } |
| 18 | 37 |
| 19 } // namespace blink | 38 } // namespace blink |
| OLD | NEW |