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

Unified Diff: Source/core/css/RuleFeature.cpp

Issue 1111643003: Move StyleInvalidator to StyleEngine. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Avoid calling ensureUpdatedRuleFeatureSet multiple times Created 5 years, 8 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/css/RuleFeature.h ('k') | Source/core/css/invalidation/StyleInvalidator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/RuleFeature.cpp
diff --git a/Source/core/css/RuleFeature.cpp b/Source/core/css/RuleFeature.cpp
index 3ddaed1b3b90fc916b472b425b00ccb199930bb9..f91e83bd97197eda6db9cd139eabdc7aafabf8b5 100644
--- a/Source/core/css/RuleFeature.cpp
+++ b/Source/core/css/RuleFeature.cpp
@@ -544,100 +544,40 @@ void RuleFeatureSet::clear()
m_classInvalidationSets.clear();
m_attributeInvalidationSets.clear();
m_idInvalidationSets.clear();
- // We cannot clear m_styleInvalidator here, because the style invalidator might not
- // have been evaluated yet. If not yet, in StyleInvalidator, there exists some element
- // who has needsStyleInvlidation but does not have any invalidation list.
- // This makes Blink not to recalc style correctly. crbug.com/344729.
}
-void RuleFeatureSet::scheduleStyleInvalidationForClassChange(const SpaceSplitString& changedClasses, Element& element)
+void RuleFeatureSet::collectInvalidationSetsForClass(InvalidationSetVector& invalidationSets, Element& element, const AtomicString& className) const
{
- unsigned changedSize = changedClasses.size();
- for (unsigned i = 0; i < changedSize; ++i) {
- addClassToInvalidationSet(changedClasses[i], element);
+ if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_classInvalidationSets.get(className)) {
+ TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationSet, classChange, className);
+ invalidationSets.append(invalidationSet);
}
}
-void RuleFeatureSet::scheduleStyleInvalidationForClassChange(const SpaceSplitString& oldClasses, const SpaceSplitString& newClasses, Element& element)
+void RuleFeatureSet::collectInvalidationSetsForId(InvalidationSetVector& invalidationSets, Element& element, const AtomicString& id) const
{
- if (!oldClasses.size()) {
- scheduleStyleInvalidationForClassChange(newClasses, element);
- return;
- }
-
- // 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)
- addClassToInvalidationSet(newClasses[i], element);
- }
-
- for (unsigned i = 0; i < oldClasses.size(); ++i) {
- if (remainingClassBits.quickGet(i))
- continue;
- // Class was removed.
- addClassToInvalidationSet(oldClasses[i], element);
+ if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_idInvalidationSets.get(id)) {
+ TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationSet, idChange, id);
+ invalidationSets.append(invalidationSet);
}
}
-void RuleFeatureSet::scheduleStyleInvalidationForAttributeChange(const QualifiedName& attributeName, Element& element)
+void RuleFeatureSet::collectInvalidationSetsForAttribute(InvalidationSetVector& invalidationSets, Element& element, const QualifiedName& attributeName) const
{
if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_attributeInvalidationSets.get(attributeName.localName())) {
TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationSet, attributeChange, attributeName);
- m_styleInvalidator.scheduleInvalidation(invalidationSet, element);
- }
-}
-
-void RuleFeatureSet::scheduleStyleInvalidationForIdChange(const AtomicString& oldId, const AtomicString& newId, Element& element)
-{
- if (!oldId.isEmpty()) {
- if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_idInvalidationSets.get(oldId)) {
- TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationSet, idChange, oldId);
- m_styleInvalidator.scheduleInvalidation(invalidationSet, element);
- }
- }
- if (!newId.isEmpty()) {
- if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_idInvalidationSets.get(newId)) {
- TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationSet, idChange, newId);
- m_styleInvalidator.scheduleInvalidation(invalidationSet, element);
- }
+ invalidationSets.append(invalidationSet);
}
}
-void RuleFeatureSet::scheduleStyleInvalidationForPseudoChange(CSSSelector::PseudoType pseudo, Element& element)
+void RuleFeatureSet::collectInvalidationSetsForPseudoClass(InvalidationSetVector& invalidationSets, Element& element, CSSSelector::PseudoType pseudo) const
{
if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_pseudoInvalidationSets.get(pseudo)) {
TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationSet, pseudoChange, pseudo);
- m_styleInvalidator.scheduleInvalidation(invalidationSet, element);
+ invalidationSets.append(invalidationSet);
}
}
-inline void RuleFeatureSet::addClassToInvalidationSet(const AtomicString& className, Element& element)
-{
- if (RefPtrWillBeRawPtr<DescendantInvalidationSet> invalidationSet = m_classInvalidationSets.get(className)) {
- TRACE_SCHEDULE_STYLE_INVALIDATION(element, *invalidationSet, classChange, className);
- m_styleInvalidator.scheduleInvalidation(invalidationSet, element);
- }
-}
-
-StyleInvalidator& RuleFeatureSet::styleInvalidator()
-{
- return m_styleInvalidator;
-}
-
DEFINE_TRACE(RuleFeatureSet)
{
#if ENABLE(OILPAN)
@@ -647,7 +587,6 @@ DEFINE_TRACE(RuleFeatureSet)
visitor->trace(m_attributeInvalidationSets);
visitor->trace(m_idInvalidationSets);
visitor->trace(m_pseudoInvalidationSets);
- visitor->trace(m_styleInvalidator);
#endif
}
« no previous file with comments | « Source/core/css/RuleFeature.h ('k') | Source/core/css/invalidation/StyleInvalidator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698