| 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 20 matching lines...) Expand all Loading... |
| 31 if (newStyleSheets[index].second == oldStyleSheets[index].second) | 31 if (newStyleSheets[index].second == oldStyleSheets[index].second) |
| 32 continue; | 32 continue; |
| 33 | 33 |
| 34 if (newStyleSheets[index].second) | 34 if (newStyleSheets[index].second) |
| 35 changedRuleSets.add(newStyleSheets[index].second); | 35 changedRuleSets.add(newStyleSheets[index].second); |
| 36 if (oldStyleSheets[index].second) | 36 if (oldStyleSheets[index].second) |
| 37 changedRuleSets.add(oldStyleSheets[index].second); | 37 changedRuleSets.add(oldStyleSheets[index].second); |
| 38 } | 38 } |
| 39 | 39 |
| 40 if (index == oldStyleSheetCount) { | 40 if (index == oldStyleSheetCount) { |
| 41 if (index == newStyleSheetCount) { | 41 // The old stylesheet vector is a prefix of the new vector in terms of |
| 42 return changedRuleSets.isEmpty() ? NoActiveSheetsChanged | 42 // StyleSheets. If none of the RuleSets changed, we only need to add the new |
| 43 : ActiveSheetsChanged; | 43 // sheets to the ScopedStyleResolver (ActiveSheetsAppended). |
| 44 } | 44 bool ruleSetsChangedInCommonPrefix = !changedRuleSets.isEmpty(); |
| 45 | |
| 46 // Sheets added at the end. | |
| 47 for (; index < newStyleSheetCount; index++) { | 45 for (; index < newStyleSheetCount; index++) { |
| 48 if (newStyleSheets[index].second) | 46 if (newStyleSheets[index].second) |
| 49 changedRuleSets.add(newStyleSheets[index].second); | 47 changedRuleSets.add(newStyleSheets[index].second); |
| 50 } | 48 } |
| 51 return changedRuleSets.isEmpty() ? NoActiveSheetsChanged | 49 if (ruleSetsChangedInCommonPrefix) |
| 52 : ActiveSheetsAppended; | 50 return ActiveSheetsChanged; |
| 51 if (changedRuleSets.isEmpty()) |
| 52 return NoActiveSheetsChanged; |
| 53 return ActiveSheetsAppended; |
| 53 } | 54 } |
| 54 | 55 |
| 55 if (index == newStyleSheetCount) { | 56 if (index == newStyleSheetCount) { |
| 56 // Sheets removed from the end. | 57 // Sheets removed from the end. |
| 57 for (; index < oldStyleSheetCount; index++) { | 58 for (; index < oldStyleSheetCount; index++) { |
| 58 if (oldStyleSheets[index].second) | 59 if (oldStyleSheets[index].second) |
| 59 changedRuleSets.add(oldStyleSheets[index].second); | 60 changedRuleSets.add(oldStyleSheets[index].second); |
| 60 } | 61 } |
| 61 return changedRuleSets.isEmpty() ? NoActiveSheetsChanged | 62 return changedRuleSets.isEmpty() ? NoActiveSheetsChanged |
| 62 : ActiveSheetsChanged; | 63 : ActiveSheetsChanged; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 if (sheet1.second) | 101 if (sheet1.second) |
| 101 changedRuleSets.add(sheet1.second); | 102 changedRuleSets.add(sheet1.second); |
| 102 if (sheet2.second) | 103 if (sheet2.second) |
| 103 changedRuleSets.add(sheet2.second); | 104 changedRuleSets.add(sheet2.second); |
| 104 } | 105 } |
| 105 return changedRuleSets.isEmpty() ? NoActiveSheetsChanged | 106 return changedRuleSets.isEmpty() ? NoActiveSheetsChanged |
| 106 : ActiveSheetsChanged; | 107 : ActiveSheetsChanged; |
| 107 } | 108 } |
| 108 | 109 |
| 109 } // namespace blink | 110 } // namespace blink |
| OLD | NEW |