| 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..d46cef40cd70800e24c917f22e5c8e271559a9e5 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, unsigned minDirectAdjacent)
|
| +{
|
| + InvalidationLists invalidationLists;
|
| +
|
| + RuleFeatureSet& ruleFeatureSet = ensureResolver().ensureUpdatedRuleFeatureSet();
|
| +
|
| + if (element.hasID())
|
| + ruleFeatureSet.collectSiblingInvalidationSetForId(invalidationLists, element, element.idForStyleResolution(), minDirectAdjacent);
|
| +
|
| + if (element.hasClass()) {
|
| + const SpaceSplitString& classNames = element.classNames();
|
| + for (size_t i = 0; i < classNames.size(); i++)
|
| + ruleFeatureSet.collectSiblingInvalidationSetForClass(invalidationLists, element, classNames[i], minDirectAdjacent);
|
| + }
|
| +
|
| + for (const Attribute& attribute : element.attributes())
|
| + ruleFeatureSet.collectSiblingInvalidationSetForAttribute(invalidationLists, element, attribute.name(), minDirectAdjacent);
|
| +
|
| + ruleFeatureSet.collectUniversalSiblingInvalidationSet(invalidationLists, minDirectAdjacent);
|
| +
|
| + 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, 1);
|
| +
|
| + for (unsigned i = 1; beforeElement && i <= affectedSiblings; i++, beforeElement = ElementTraversal::previousSibling(*beforeElement))
|
| + scheduleSiblingInvalidationsForElement(*beforeElement, *schedulingParent, i);
|
| +}
|
| +
|
| +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, 1);
|
| +
|
| + for (unsigned i = 2; beforeElement && i <= affectedSiblings; i++, beforeElement = ElementTraversal::previousSibling(*beforeElement))
|
| + scheduleSiblingInvalidationsForElement(*beforeElement, *schedulingParent, i);
|
| +}
|
| +
|
| void StyleEngine::setStatsEnabled(bool enabled)
|
| {
|
| if (!enabled) {
|
|
|