Remove code for compilers that did not support NSDMI for aggregates
[WebKit-https.git] / Source / WebCore / style / AttributeChangeInvalidation.cpp
index 16bd776..be8e5bf 100644 (file)
@@ -46,60 +46,54 @@ void AttributeChangeInvalidation::invalidateStyle(const QualifiedName& attribute
 
     bool isHTML = m_element.isHTMLElement();
 
-    bool mayAffectStyle = false;
+    bool shouldInvalidateCurrent = false;
     bool mayAffectStyleInShadowTree = false;
 
+    auto attributeNameForLookups = attributeName.localName().convertToASCIILowercase();
+
     traverseRuleFeatures(m_element, [&] (const RuleFeatureSet& features, bool mayAffectShadowTree) {
-        if (!mayBeAffectedByAttributeChange(features, isHTML, attributeName))
-            return;
-        mayAffectStyle = true;
-        if (mayAffectShadowTree)
+        if (mayAffectShadowTree && mayBeAffectedByAttributeChange(features, isHTML, attributeName))
             mayAffectStyleInShadowTree = true;
+        if (features.attributesAffectingHost.contains(attributeNameForLookups))
+            shouldInvalidateCurrent = true;
+        else if (features.contentAttributeNamesInRules.contains(attributeNameForLookups))
+            shouldInvalidateCurrent = true;
     });
 
-    if (!mayAffectStyle)
-        return;
-
-    if (!isHTML) {
-        m_element.invalidateStyleForSubtree();
-        return;
-    }
-
     if (mayAffectStyleInShadowTree) {
         // FIXME: More fine-grained invalidation.
         m_element.invalidateStyleForSubtree();
-        return;
     }
 
-    m_element.invalidateStyle();
-
-    if (!childrenOfType<Element>(m_element).first())
-        return;
+    if (shouldInvalidateCurrent)
+        m_element.invalidateStyle();
 
     auto& ruleSets = m_element.styleResolver().ruleSets();
-    auto* attributeRules = ruleSets.ancestorAttributeRulesForHTML(attributeName.localName());
-    if (!attributeRules)
-        return;
 
-    // Check if descendants may be affected by this attribute change.
-    for (auto* selector : attributeRules->attributeSelectors) {
-        bool oldMatches = oldValue.isNull() ? false : SelectorChecker::attributeSelectorMatches(m_element, attributeName, oldValue, *selector);
-        bool newMatches = newValue.isNull() ? false : SelectorChecker::attributeSelectorMatches(m_element, attributeName, newValue, *selector);
+    auto* invalidationRuleSets = ruleSets.attributeInvalidationRuleSets(attributeNameForLookups);
+    if (!invalidationRuleSets)
+        return;
 
-        if (oldMatches != newMatches) {
-            m_descendantInvalidationRuleSet = attributeRules->ruleSet.get();
-            return;
+    for (auto& invalidationRuleSet : *invalidationRuleSets) {
+        for (auto* selector : invalidationRuleSet.invalidationSelectors) {
+            bool oldMatches = !oldValue.isNull() && SelectorChecker::attributeSelectorMatches(m_element, attributeName, oldValue, *selector);
+            bool newMatches = !newValue.isNull() && SelectorChecker::attributeSelectorMatches(m_element, attributeName, newValue, *selector);
+            if (oldMatches != newMatches) {
+                m_invalidationRuleSets.append(&invalidationRuleSet);
+                break;
+            }
         }
     }
 }
 
-void AttributeChangeInvalidation::invalidateDescendants()
+void AttributeChangeInvalidation::invalidateStyleWithRuleSets()
 {
-    if (!m_descendantInvalidationRuleSet)
-        return;
-    Invalidator invalidator(*m_descendantInvalidationRuleSet);
-    invalidator.invalidateStyle(m_element);
+    for (auto* invalidationRuleSet : m_invalidationRuleSets) {
+        Invalidator invalidator(*invalidationRuleSet->ruleSet);
+        invalidator.invalidateStyleWithMatchElement(m_element, invalidationRuleSet->matchElement);
+    }
 }
 
+
 }
 }