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/ActiveStyleSheets.h" | 5 #include "core/css/ActiveStyleSheets.h" |
6 | 6 |
7 #include "core/css/CSSStyleSheet.h" | 7 #include "core/css/CSSStyleSheet.h" |
8 #include "core/css/RuleSet.h" | 8 #include "core/css/RuleSet.h" |
9 #include "core/css/resolver/ScopedStyleResolver.h" | 9 #include "core/css/resolver/ScopedStyleResolver.h" |
10 #include "core/dom/ContainerNode.h" | 10 #include "core/dom/ContainerNode.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 if (index == newStyleSheetCount) { | 56 if (index == newStyleSheetCount) { |
57 // Sheets removed from the end. | 57 // Sheets removed from the end. |
58 for (; index < oldStyleSheetCount; index++) { | 58 for (; index < oldStyleSheetCount; index++) { |
59 if (oldStyleSheets[index].second) | 59 if (oldStyleSheets[index].second) |
60 changedRuleSets.insert(oldStyleSheets[index].second); | 60 changedRuleSets.insert(oldStyleSheets[index].second); |
61 } | 61 } |
62 return changedRuleSets.isEmpty() ? NoActiveSheetsChanged | 62 return changedRuleSets.isEmpty() ? NoActiveSheetsChanged |
63 : ActiveSheetsChanged; | 63 : ActiveSheetsChanged; |
64 } | 64 } |
65 | 65 |
66 DCHECK(index < oldStyleSheetCount && index < newStyleSheetCount); | 66 DCHECK_LT(index, oldStyleSheetCount); |
| 67 DCHECK_LT(index, newStyleSheetCount); |
67 | 68 |
68 // Both the new and old active stylesheet vectors have stylesheets following | 69 // Both the new and old active stylesheet vectors have stylesheets following |
69 // the common prefix. Figure out which were added or removed by sorting the | 70 // the common prefix. Figure out which were added or removed by sorting the |
70 // merged vector of old and new sheets. | 71 // merged vector of old and new sheets. |
71 | 72 |
72 ActiveStyleSheetVector mergedSorted; | 73 ActiveStyleSheetVector mergedSorted; |
73 mergedSorted.reserveCapacity(oldStyleSheetCount + newStyleSheetCount - | 74 mergedSorted.reserveCapacity(oldStyleSheetCount + newStyleSheetCount - |
74 2 * index); | 75 2 * index); |
75 mergedSorted.appendRange(oldStyleSheets.begin() + index, | 76 mergedSorted.appendRange(oldStyleSheets.begin() + index, |
76 oldStyleSheets.end()); | 77 oldStyleSheets.end()); |
(...skipping 24 matching lines...) Expand all Loading... |
101 if (sheet1.second) | 102 if (sheet1.second) |
102 changedRuleSets.insert(sheet1.second); | 103 changedRuleSets.insert(sheet1.second); |
103 if (sheet2.second) | 104 if (sheet2.second) |
104 changedRuleSets.insert(sheet2.second); | 105 changedRuleSets.insert(sheet2.second); |
105 } | 106 } |
106 return changedRuleSets.isEmpty() ? NoActiveSheetsChanged | 107 return changedRuleSets.isEmpty() ? NoActiveSheetsChanged |
107 : ActiveSheetsChanged; | 108 : ActiveSheetsChanged; |
108 } | 109 } |
109 | 110 |
110 } // namespace blink | 111 } // namespace blink |
OLD | NEW |