Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(543)

Side by Side Diff: Source/core/dom/shadow/SelectRuleFeatureSet.cpp

Issue 143873016: Implement style invalidation tree walk for targeted style recalc upon class change. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/shadow/SelectRuleFeatureSet.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/dom/shadow/SelectRuleFeatureSet.h" 32 #include "core/dom/shadow/SelectRuleFeatureSet.h"
33 33
34 #include "core/css/CSSSelector.h" 34 #include "core/css/CSSSelector.h"
35 35
36 #include "wtf/BitVector.h"
37
36 namespace WebCore { 38 namespace WebCore {
37 39
38 SelectRuleFeatureSet::SelectRuleFeatureSet() 40 SelectRuleFeatureSet::SelectRuleFeatureSet()
39 : m_featureFlags(0) 41 : m_featureFlags(0)
40 { 42 {
41 } 43 }
42 44
43 void SelectRuleFeatureSet::add(const SelectRuleFeatureSet& featureSet) 45 void SelectRuleFeatureSet::add(const SelectRuleFeatureSet& featureSet)
44 { 46 {
45 m_cssRuleFeatureSet.add(featureSet.m_cssRuleFeatureSet); 47 m_cssRuleFeatureSet.add(featureSet.m_cssRuleFeatureSet);
(...skipping 30 matching lines...) Expand all
76 setSelectRuleFeature(AffectedSelectorTarget); 78 setSelectRuleFeature(AffectedSelectorTarget);
77 break; 79 break;
78 case CSSSelector::PseudoVisited: 80 case CSSSelector::PseudoVisited:
79 setSelectRuleFeature(AffectedSelectorVisited); 81 setSelectRuleFeature(AffectedSelectorVisited);
80 break; 82 break;
81 default: 83 default:
82 break; 84 break;
83 } 85 }
84 } 86 }
85 87
88 bool SelectRuleFeatureSet::checkSelectorsForClassChange(const SpaceSplitString& changedClasses) const
89 {
90 unsigned changedSize = changedClasses.size();
91 for (unsigned i = 0; i < changedSize; ++i) {
92 if (hasSelectorForClass(changedClasses[i]))
93 return true;
94 }
95 return false;
96 }
97
98 bool SelectRuleFeatureSet::checkSelectorsForClassChange(const SpaceSplitString& oldClasses, const SpaceSplitString& newClasses) const
99 {
100 if (!oldClasses.size())
101 return checkSelectorsForClassChange(newClasses);
102
103 // Class vectors tend to be very short. This is faster than using a hash tab le.
104 BitVector remainingClassBits;
105 remainingClassBits.ensureSize(oldClasses.size());
106
107 for (unsigned i = 0; i < newClasses.size(); ++i) {
108 bool found = false;
109 for (unsigned j = 0; j < oldClasses.size(); ++j) {
110 if (newClasses[i] == oldClasses[j]) {
111 // Mark each class that is still in the newClasses so we can ski p doing
112 // an n^2 search below when looking for removals. We can't break from
113 // this loop early since a class can appear more than once.
114 remainingClassBits.quickSet(j);
115 found = true;
116 }
117 }
118 // Class was added.
119 if (!found) {
120 if (hasSelectorForClass(newClasses[i]))
121 return true;
122 }
123 }
124
125 for (unsigned i = 0; i < oldClasses.size(); ++i) {
126 if (remainingClassBits.quickGet(i))
127 continue;
128
129 // Class was removed.
130 if (hasSelectorForClass(oldClasses[i]))
131 return true;
132 }
133 return false;
134 }
135
86 } 136 }
87 137
OLDNEW
« no previous file with comments | « Source/core/dom/shadow/SelectRuleFeatureSet.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698