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

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

Issue 1560693002: Avoid unnecessary invalidation scheduling. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile fix Created 4 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 | « 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 a030df253ecb34484ec6e858e9b12261c1d88218..374e9e8655a53160a95564ae23faff06207e5448 100644
--- a/third_party/WebKit/Source/core/dom/StyleEngine.cpp
+++ b/third_party/WebKit/Source/core/dom/StyleEngine.cpp
@@ -626,9 +626,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();
@@ -639,7 +651,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;
@@ -680,7 +694,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);
@@ -688,7 +704,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())
@@ -700,7 +718,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