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

Unified Diff: third_party/WebKit/Source/core/dom/StyleEngine.cpp

Issue 1514733002: Avoid unnecessary invalidation scheduling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed unnecessary isMaster check Created 5 years 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 | « third_party/WebKit/Source/core/dom/StyleEngine.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/StyleEngine.cpp
diff --git a/third_party/WebKit/Source/core/dom/StyleEngine.cpp b/third_party/WebKit/Source/core/dom/StyleEngine.cpp
index d5d9941d1cae10ee2b6c1a26c426a48a399dd7cf..0f96af7c6b35cb1692395d10486be2ac66327dfa 100644
--- a/third_party/WebKit/Source/core/dom/StyleEngine.cpp
+++ b/third_party/WebKit/Source/core/dom/StyleEngine.cpp
@@ -627,9 +627,21 @@ void StyleEngine::platformColorsChanged()
document().setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::PlatformColorChange));
}
+bool StyleEngine::shouldSkipInvalidationFor(const Element& element) const
+{
+ if (!resolver())
+ return true;
+ if (!element.inActiveDocument())
+ return true;
+ if (!element.parentNode())
+ return true;
+ return element.parentNode()->styleChangeType() >= SubtreeStyleChange;
+}
+
void StyleEngine::classChangedForElement(const SpaceSplitString& changedClasses, Element& element)
{
- ASSERT(isMaster());
+ if (shouldSkipInvalidationFor(element))
+ return;
InvalidationLists invalidationLists;
unsigned changedSize = changedClasses.size();
RuleFeatureSet& ruleFeatureSet = ensureResolver().ensureUpdatedRuleFeatureSet();
@@ -640,7 +652,9 @@ void StyleEngine::classChangedForElement(const SpaceSplitString& changedClasses,
void StyleEngine::classChangedForElement(const SpaceSplitString& oldClasses, const SpaceSplitString& newClasses, Element& element)
{
- ASSERT(isMaster());
+ if (shouldSkipInvalidationFor(element))
+ return;
+
if (!oldClasses.size()) {
classChangedForElement(newClasses, element);
return;
@@ -681,7 +695,9 @@ void StyleEngine::classChangedForElement(const SpaceSplitString& oldClasses, con
void StyleEngine::attributeChangedForElement(const QualifiedName& attributeName, Element& element)
{
- ASSERT(isMaster());
+ if (shouldSkipInvalidationFor(element))
+ return;
+
InvalidationLists invalidationLists;
ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsForAttribute(invalidationLists, element, attributeName);
m_styleInvalidator.scheduleInvalidationSetsForElement(invalidationLists, element);
@@ -689,7 +705,9 @@ void StyleEngine::attributeChangedForElement(const QualifiedName& attributeName,
void StyleEngine::idChangedForElement(const AtomicString& oldId, const AtomicString& newId, Element& element)
{
- ASSERT(isMaster());
+ if (shouldSkipInvalidationFor(element))
+ return;
+
InvalidationLists invalidationLists;
RuleFeatureSet& ruleFeatureSet = ensureResolver().ensureUpdatedRuleFeatureSet();
if (!oldId.isEmpty())
@@ -701,7 +719,9 @@ void StyleEngine::idChangedForElement(const AtomicString& oldId, const AtomicStr
void StyleEngine::pseudoStateChangedForElement(CSSSelector::PseudoType pseudoType, Element& element)
{
- ASSERT(isMaster());
+ if (shouldSkipInvalidationFor(element))
+ return;
+
InvalidationLists invalidationLists;
ensureResolver().ensureUpdatedRuleFeatureSet().collectInvalidationSetsForPseudoClass(invalidationLists, element, pseudoType);
m_styleInvalidator.scheduleInvalidationSetsForElement(invalidationLists, element);
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleEngine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698