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

Unified 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, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/shadow/SelectRuleFeatureSet.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/shadow/SelectRuleFeatureSet.cpp
diff --git a/Source/core/dom/shadow/SelectRuleFeatureSet.cpp b/Source/core/dom/shadow/SelectRuleFeatureSet.cpp
index 02ab9488fc36a42faff5c91c7eaf4845f0efe419..25757e6bc7463c69a3e5cbe978cbf07cabbe35e9 100644
--- a/Source/core/dom/shadow/SelectRuleFeatureSet.cpp
+++ b/Source/core/dom/shadow/SelectRuleFeatureSet.cpp
@@ -33,6 +33,8 @@
#include "core/css/CSSSelector.h"
+#include "wtf/BitVector.h"
+
namespace WebCore {
SelectRuleFeatureSet::SelectRuleFeatureSet()
@@ -83,5 +85,53 @@ void SelectRuleFeatureSet::collectFeaturesFromSelector(const CSSSelector& select
}
}
+bool SelectRuleFeatureSet::checkSelectorsForClassChange(const SpaceSplitString& changedClasses) const
+{
+ unsigned changedSize = changedClasses.size();
+ for (unsigned i = 0; i < changedSize; ++i) {
+ if (hasSelectorForClass(changedClasses[i]))
+ return true;
+ }
+ return false;
+}
+
+bool SelectRuleFeatureSet::checkSelectorsForClassChange(const SpaceSplitString& oldClasses, const SpaceSplitString& newClasses) const
+{
+ if (!oldClasses.size())
+ return checkSelectorsForClassChange(newClasses);
+
+ // Class vectors tend to be very short. This is faster than using a hash table.
+ BitVector remainingClassBits;
+ remainingClassBits.ensureSize(oldClasses.size());
+
+ for (unsigned i = 0; i < newClasses.size(); ++i) {
+ bool found = false;
+ for (unsigned j = 0; j < oldClasses.size(); ++j) {
+ if (newClasses[i] == oldClasses[j]) {
+ // Mark each class that is still in the newClasses so we can skip doing
+ // an n^2 search below when looking for removals. We can't break from
+ // this loop early since a class can appear more than once.
+ remainingClassBits.quickSet(j);
+ found = true;
+ }
+ }
+ // Class was added.
+ if (!found) {
+ if (hasSelectorForClass(newClasses[i]))
+ return true;
+ }
+ }
+
+ for (unsigned i = 0; i < oldClasses.size(); ++i) {
+ if (remainingClassBits.quickGet(i))
+ continue;
+
+ // Class was removed.
+ if (hasSelectorForClass(oldClasses[i]))
+ return true;
+ }
+ return false;
+}
+
}
« 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