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 ActiveSheetsChange change = |
42 return changedRuleSets.isEmpty() ? NoActiveSheetsChanged | 42 changedRuleSets.isEmpty() ? NoActiveSheetsChanged : ActiveSheetsChanged; |
43 : ActiveSheetsChanged; | |
44 } | |
45 | |
46 // Sheets added at the end. | |
47 for (; index < newStyleSheetCount; index++) { | 43 for (; index < newStyleSheetCount; index++) { |
48 if (newStyleSheets[index].second) | 44 if (newStyleSheets[index].second) |
49 changedRuleSets.add(newStyleSheets[index].second); | 45 changedRuleSets.add(newStyleSheets[index].second); |
50 } | 46 } |
51 return changedRuleSets.isEmpty() ? NoActiveSheetsChanged | 47 if (change == NoActiveSheetsChanged && !changedRuleSets.isEmpty()) |
52 : ActiveSheetsAppended; | 48 change = ActiveSheetsAppended; |
49 return change; | |
sashab
2017/01/23 22:06:33
I'm having trouble comparing these two logic. So t
rune
2017/01/24 01:08:10
Tried with a bool approach now.
| |
53 } | 50 } |
54 | 51 |
55 if (index == newStyleSheetCount) { | 52 if (index == newStyleSheetCount) { |
56 // Sheets removed from the end. | 53 // Sheets removed from the end. |
57 for (; index < oldStyleSheetCount; index++) { | 54 for (; index < oldStyleSheetCount; index++) { |
58 if (oldStyleSheets[index].second) | 55 if (oldStyleSheets[index].second) |
59 changedRuleSets.add(oldStyleSheets[index].second); | 56 changedRuleSets.add(oldStyleSheets[index].second); |
60 } | 57 } |
61 return changedRuleSets.isEmpty() ? NoActiveSheetsChanged | 58 return changedRuleSets.isEmpty() ? NoActiveSheetsChanged |
62 : ActiveSheetsChanged; | 59 : ActiveSheetsChanged; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 if (sheet1.second) | 97 if (sheet1.second) |
101 changedRuleSets.add(sheet1.second); | 98 changedRuleSets.add(sheet1.second); |
102 if (sheet2.second) | 99 if (sheet2.second) |
103 changedRuleSets.add(sheet2.second); | 100 changedRuleSets.add(sheet2.second); |
104 } | 101 } |
105 return changedRuleSets.isEmpty() ? NoActiveSheetsChanged | 102 return changedRuleSets.isEmpty() ? NoActiveSheetsChanged |
106 : ActiveSheetsChanged; | 103 : ActiveSheetsChanged; |
107 } | 104 } |
108 | 105 |
109 } // namespace blink | 106 } // namespace blink |
OLD | NEW |