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

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

Issue 2089063005: Schedule sibling invalidation sets for sibling insert/remove. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed minDirectAdjacent optimization. Created 4 years, 6 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: 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 b7cccd69a0808c85471a3698915ce9c4f613368e..3c448bf3591f648c7a25f7b5eaa266a5bda12d0f 100644
--- a/third_party/WebKit/Source/core/dom/StyleEngine.cpp
+++ b/third_party/WebKit/Source/core/dom/StyleEngine.cpp
@@ -37,6 +37,7 @@
#include "core/css/resolver/ScopedStyleResolver.h"
#include "core/dom/DocumentStyleSheetCollector.h"
#include "core/dom/Element.h"
+#include "core/dom/ElementTraversal.h"
#include "core/dom/ProcessingInstruction.h"
#include "core/dom/ShadowTreeStyleSheetCollection.h"
#include "core/dom/StyleChangeReason.h"
@@ -690,6 +691,57 @@ void StyleEngine::pseudoStateChangedForElement(CSSSelector::PseudoType pseudoTyp
m_styleInvalidator.scheduleInvalidationSetsForElement(invalidationLists, element);
}
+void StyleEngine::scheduleSiblingInvalidationsForElement(Element& element, ContainerNode& schedulingParent)
+{
+ InvalidationLists invalidationLists;
+
+ RuleFeatureSet& ruleFeatureSet = ensureResolver().ensureUpdatedRuleFeatureSet();
+
+ if (element.hasID())
+ ruleFeatureSet.collectSiblingInvalidationSetForId(invalidationLists, element, element.idForStyleResolution());
+
+ if (element.hasClass()) {
+ const SpaceSplitString& classNames = element.classNames();
+ for (size_t i = 0; i < classNames.size(); i++)
+ ruleFeatureSet.collectSiblingInvalidationSetForClass(invalidationLists, element, classNames[i]);
+ }
+
+ for (const Attribute& attribute : element.attributes())
+ ruleFeatureSet.collectSiblingInvalidationSetForAttribute(invalidationLists, element, attribute.name());
+
+ ruleFeatureSet.collectUniversalSiblingInvalidationSet(invalidationLists);
+
+ m_styleInvalidator.scheduleSiblingInvalidationsAsDescendants(invalidationLists, schedulingParent);
+}
+
+void StyleEngine::scheduleInvalidationsForInsertedSibling(Element* beforeElement, Element& insertedElement)
+{
+ unsigned affectedSiblings = insertedElement.parentNode()->childrenAffectedByIndirectAdjacentRules() ? UINT_MAX : m_maxDirectAdjacentSelectors;
+
+ ContainerNode* schedulingParent = insertedElement.parentElementOrShadowRoot();
+ if (!schedulingParent)
+ return;
+
+ scheduleSiblingInvalidationsForElement(insertedElement, *schedulingParent);
+
+ for (unsigned i = 0; beforeElement && i < affectedSiblings; i++, beforeElement = ElementTraversal::previousSibling(*beforeElement))
+ scheduleSiblingInvalidationsForElement(*beforeElement, *schedulingParent);
+}
+
+void StyleEngine::scheduleInvalidationsForRemovedSibling(Element* beforeElement, Element& removedElement, Element& afterElement)
+{
+ unsigned affectedSiblings = afterElement.parentNode()->childrenAffectedByIndirectAdjacentRules() ? UINT_MAX : m_maxDirectAdjacentSelectors;
+
+ ContainerNode* schedulingParent = afterElement.parentElementOrShadowRoot();
+ if (!schedulingParent)
+ return;
+
+ scheduleSiblingInvalidationsForElement(removedElement, *schedulingParent);
+
+ for (unsigned i = 1; beforeElement && i < affectedSiblings; i++, beforeElement = ElementTraversal::previousSibling(*beforeElement))
+ scheduleSiblingInvalidationsForElement(*beforeElement, *schedulingParent);
+}
+
void StyleEngine::setStatsEnabled(bool enabled)
{
if (!enabled) {
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleEngine.h ('k') | third_party/WebKit/Source/core/dom/shadow/ShadowRoot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698