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/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 bool ruleSetsChanged = !changedRuleSets.isEmpty(); |
|
sashab
2017/01/25 02:45:00
Hmm, is this the same logic as before? This is way
meade_UTC10
2017/01/25 05:14:40
I don't think that'd have the same behaviour, Sash
rune
2017/01/25 08:57:34
The isEmpty check must be done before the for-loop
rune
2017/01/25 08:57:34
Those are two different tests. The test here is th
| |
| 42 return changedRuleSets.isEmpty() ? NoActiveSheetsChanged | |
| 43 : ActiveSheetsChanged; | |
| 44 } | |
| 45 | |
| 46 // Sheets added at the end. | |
| 47 for (; index < newStyleSheetCount; index++) { | 42 for (; index < newStyleSheetCount; index++) { |
| 48 if (newStyleSheets[index].second) | 43 if (newStyleSheets[index].second) |
| 49 changedRuleSets.add(newStyleSheets[index].second); | 44 changedRuleSets.add(newStyleSheets[index].second); |
| 50 } | 45 } |
| 51 return changedRuleSets.isEmpty() ? NoActiveSheetsChanged | 46 if (ruleSetsChanged) |
| 52 : ActiveSheetsAppended; | 47 return ActiveSheetsChanged; |
| 48 if (changedRuleSets.isEmpty()) | |
| 49 return NoActiveSheetsChanged; | |
| 50 return ActiveSheetsAppended; | |
| 53 } | 51 } |
| 54 | 52 |
| 55 if (index == newStyleSheetCount) { | 53 if (index == newStyleSheetCount) { |
| 56 // Sheets removed from the end. | 54 // Sheets removed from the end. |
| 57 for (; index < oldStyleSheetCount; index++) { | 55 for (; index < oldStyleSheetCount; index++) { |
| 58 if (oldStyleSheets[index].second) | 56 if (oldStyleSheets[index].second) |
| 59 changedRuleSets.add(oldStyleSheets[index].second); | 57 changedRuleSets.add(oldStyleSheets[index].second); |
| 60 } | 58 } |
| 61 return changedRuleSets.isEmpty() ? NoActiveSheetsChanged | 59 return changedRuleSets.isEmpty() ? NoActiveSheetsChanged |
| 62 : ActiveSheetsChanged; | 60 : ActiveSheetsChanged; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 if (sheet1.second) | 98 if (sheet1.second) |
| 101 changedRuleSets.add(sheet1.second); | 99 changedRuleSets.add(sheet1.second); |
| 102 if (sheet2.second) | 100 if (sheet2.second) |
| 103 changedRuleSets.add(sheet2.second); | 101 changedRuleSets.add(sheet2.second); |
| 104 } | 102 } |
| 105 return changedRuleSets.isEmpty() ? NoActiveSheetsChanged | 103 return changedRuleSets.isEmpty() ? NoActiveSheetsChanged |
| 106 : ActiveSheetsChanged; | 104 : ActiveSheetsChanged; |
| 107 } | 105 } |
| 108 | 106 |
| 109 } // namespace blink | 107 } // namespace blink |
| OLD | NEW |