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

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

Issue 170873004: Fix issue in which removing a class does not always invalidate style (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed bug - was not clearing the NeedsStyleInvalidation bit correctly. 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/css/RuleFeature.cpp
diff --git a/Source/core/css/RuleFeature.cpp b/Source/core/css/RuleFeature.cpp
index b52569a0034cea47262ee54d626699f31eaf38c5..1395acf0e6f59aca9dfcef749802b97bc3626a39 100644
--- a/Source/core/css/RuleFeature.cpp
+++ b/Source/core/css/RuleFeature.cpp
@@ -380,24 +380,26 @@ bool RuleFeatureSet::invalidateStyleForClassChangeOnChildren(Element* element, V
bool RuleFeatureSet::invalidateStyleForClassChange(Element* element, Vector<AtomicString>& invalidationClasses, bool foundInvalidationSet)
{
+ bool thisElementNeedsStyleRecalc = false;
int oldSize = invalidationClasses.size();
+
if (element->needsStyleInvalidation()) {
- if (InvalidationList* invalidationList = m_pendingInvalidationMap.get(element)) {
- foundInvalidationSet = true;
- for (InvalidationList::const_iterator it = invalidationList->begin(); it != invalidationList->end(); ++it) {
- if ((*it)->wholeSubtreeInvalid()) {
- element->setNeedsStyleRecalc(SubtreeStyleChange);
- invalidationClasses.remove(oldSize, invalidationClasses.size() - oldSize);
- element->clearChildNeedsStyleInvalidation();
- return true;
- }
- (*it)->getClasses(invalidationClasses);
+ InvalidationList* invalidationList = m_pendingInvalidationMap.get(element);
+ ASSERT(invalidationList);
+ // FIXME: it's really only necessary to clone the render style for this element, not full style recalc.
+ thisElementNeedsStyleRecalc = true;
+ foundInvalidationSet = true;
+ for (InvalidationList::const_iterator it = invalidationList->begin(); it != invalidationList->end(); ++it) {
+ if ((*it)->wholeSubtreeInvalid()) {
+ element->setNeedsStyleRecalc(SubtreeStyleChange);
+ invalidationClasses.remove(oldSize, invalidationClasses.size() - oldSize);
+ element->clearChildNeedsStyleInvalidation();
+ return true;
}
+ (*it)->getClasses(invalidationClasses);
}
}
- bool thisElementNeedsStyleRecalc = false;
-
if (element->hasClass()) {
const SpaceSplitString& classNames = element->classNames();
for (Vector<AtomicString>::const_iterator it = invalidationClasses.begin(); it != invalidationClasses.end(); ++it) {
@@ -413,6 +415,7 @@ bool RuleFeatureSet::invalidateStyleForClassChange(Element* element, Vector<Atom
if (foundInvalidationSet || element->childNeedsStyleInvalidation()) {
bool someChildrenNeedStyleRecalc = invalidateStyleForClassChangeOnChildren(element, invalidationClasses, foundInvalidationSet);
// We only need to possibly recalc style if this node is in the subtree of a node with a DescendantInvalidationSet on it.
+ // FIXME: it's really only necessary to clone the render style for this element, not full style recalc.
if (foundInvalidationSet)
thisElementNeedsStyleRecalc = thisElementNeedsStyleRecalc || someChildrenNeedStyleRecalc;
}
@@ -422,6 +425,8 @@ bool RuleFeatureSet::invalidateStyleForClassChange(Element* element, Vector<Atom
invalidationClasses.remove(oldSize, invalidationClasses.size() - oldSize);
element->clearChildNeedsStyleInvalidation();
+ element->clearNeedsStyleInvalidation();
+
return thisElementNeedsStyleRecalc;
}

Powered by Google App Engine
This is Rietveld 408576698