Changeset 216761 in webkit
- Timestamp:
- May 12, 2017 5:31:49 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r216760 r216761 1 2017-05-12 Antti Koivisto <antti@apple.com> 2 3 Updating class name of a shadow host does not update the style applied by descendants of :host() 4 https://bugs.webkit.org/show_bug.cgi?id=170762 5 <rdar://problem/31572668> 6 7 Reviewed by Ryosuke Niwa. 8 9 * fast/shadow-dom/css-scoping-host-class-and-attribute-mutation-expected.html: Added. 10 * fast/shadow-dom/css-scoping-host-class-and-attribute-mutation.html: Added. 11 1 12 2017-05-12 Claudio Saavedra <csaavedra@igalia.com> 2 13 -
trunk/Source/WebCore/ChangeLog
r216759 r216761 1 2017-05-12 Antti Koivisto <antti@apple.com> 2 3 Updating class name of a shadow host does not update the style applied by descendants of :host() 4 https://bugs.webkit.org/show_bug.cgi?id=170762 5 <rdar://problem/31572668> 6 7 Reviewed by Ryosuke Niwa. 8 9 We need to invalidate shadow tree style when host classes or attributes change if it may be 10 affected by host rules. 11 12 Test: fast/shadow-dom/css-scoping-host-class-and-attribute-mutation.html 13 14 * css/RuleSet.cpp: 15 (WebCore::isHostSelectorMatchingInShadowTree): 16 (WebCore::RuleSet::addRule): 17 18 Check if we have :host selectors that affect shadow tree. 19 20 * css/RuleSet.h: 21 (WebCore::RuleSet::hasHostPseudoClassRulesMatchingInShadowTree): 22 * style/AttributeChangeInvalidation.cpp: 23 (WebCore::Style::mayBeAffectedByHostRules): 24 (WebCore::Style::AttributeChangeInvalidation::invalidateStyle): 25 26 Invalidate the whole subtree if there is a class change that may affect shadow tree style. 27 28 * style/ClassChangeInvalidation.cpp: 29 (WebCore::Style::mayBeAffectedByHostRules): 30 (WebCore::Style::ClassChangeInvalidation::invalidateStyle): 31 * style/IdChangeInvalidation.cpp: 32 (WebCore::Style::mayBeAffectedByHostRules): 33 (WebCore::Style::IdChangeInvalidation::invalidateStyle): 34 35 Same for classes and ids. 36 This should be refactored at some point to reduce copy-code. 37 1 38 2017-05-12 Carlos Garcia Campos <cgarcia@igalia.com> 2 39 -
trunk/Source/WebCore/css/RuleSet.cpp
r214255 r216761 195 195 } 196 196 197 static bool isHostSelectorMatchingInShadowTree(const CSSSelector& startSelector) 198 { 199 auto* leftmostSelector = &startSelector; 200 bool hasDescendantOrChildRelation = false; 201 while (auto* previous = leftmostSelector->tagHistory()) { 202 hasDescendantOrChildRelation = leftmostSelector->hasDescendantOrChildRelation(); 203 leftmostSelector = previous; 204 } 205 if (!hasDescendantOrChildRelation) 206 return false; 207 208 return leftmostSelector->match() == CSSSelector::PseudoClass && leftmostSelector->pseudoClassType() == CSSSelector::PseudoClassHost; 209 } 210 197 211 void RuleSet::addRule(StyleRule* rule, unsigned selectorIndex, AddRuleFlags addRuleFlags) 198 212 { … … 309 323 return; 310 324 } 325 326 if (!m_hasHostPseudoClassRulesMatchingInShadowTree) 327 m_hasHostPseudoClassRulesMatchingInShadowTree = isHostSelectorMatchingInShadowTree(*ruleData.selector()); 311 328 312 329 if (hostPseudoClassSelector) { -
trunk/Source/WebCore/css/RuleSet.h
r214255 r216761 193 193 194 194 bool hasShadowPseudoElementRules() const; 195 bool hasHostPseudoClassRulesMatchingInShadowTree() const { return m_hasHostPseudoClassRulesMatchingInShadowTree; } 195 196 196 197 private: … … 212 213 Vector<StyleRulePage*> m_pageRules; 213 214 unsigned m_ruleCount { 0 }; 215 bool m_hasHostPseudoClassRulesMatchingInShadowTree { false }; 214 216 bool m_autoShrinkToFitEnabled { true }; 215 217 RuleFeatureSet m_features; -
trunk/Source/WebCore/style/AttributeChangeInvalidation.cpp
r216117 r216761 43 43 } 44 44 45 static bool mayBeAffectedByHostRules(const Element& element, const QualifiedName& attributeName )45 static bool mayBeAffectedByHostRules(const Element& element, const QualifiedName& attributeName, bool& mayAffectShadowTree) 46 46 { 47 // FIXME: More of this code should be shared between Class/Attribute/IdInvalidation. 47 48 auto* shadowRoot = element.shadowRoot(); 48 49 if (!shadowRoot) 49 50 return false; 50 51 auto& shadowRuleSets = shadowRoot->styleScope().resolver().ruleSets(); 51 if (shadowRuleSets.authorStyle().hostPseudoClassRules().isEmpty()) 52 auto& authorStyle = shadowRuleSets.authorStyle(); 53 if (authorStyle.hostPseudoClassRules().isEmpty() && !authorStyle.hasHostPseudoClassRulesMatchingInShadowTree()) 52 54 return false; 53 55 54 return mayBeAffectedByAttributeChange(shadowRuleSets, element.isHTMLElement(), attributeName); 56 if (!mayBeAffectedByAttributeChange(shadowRuleSets, element.isHTMLElement(), attributeName)) 57 return false; 58 59 if (authorStyle.hasHostPseudoClassRulesMatchingInShadowTree()) 60 mayAffectShadowTree = true; 61 return true; 55 62 } 56 63 … … 74 81 auto& ruleSets = m_element.styleResolver().ruleSets(); 75 82 bool isHTML = m_element.isHTMLElement(); 83 bool mayAffectShadowTree = false; 76 84 77 85 bool mayAffectStyle = mayBeAffectedByAttributeChange(ruleSets, isHTML, attributeName) 78 || mayBeAffectedByHostRules(m_element, attributeName )86 || mayBeAffectedByHostRules(m_element, attributeName, mayAffectShadowTree) 79 87 || mayBeAffectedBySlottedRules(m_element, attributeName); 80 88 … … 87 95 } 88 96 89 if (m_element.shadowRoot() && ruleSets.authorStyle().hasShadowPseudoElementRules()) { 97 if (m_element.shadowRoot() && ruleSets.authorStyle().hasShadowPseudoElementRules()) 98 mayAffectShadowTree = true; 99 100 if (mayAffectShadowTree) { 90 101 m_element.invalidateStyleForSubtree(); 91 102 return; -
trunk/Source/WebCore/style/ClassChangeInvalidation.cpp
r216117 r216761 87 87 } 88 88 89 static bool mayBeAffectedByHostRules(ShadowRoot* shadowRoot, AtomicStringImpl* changedClass )89 static bool mayBeAffectedByHostRules(ShadowRoot* shadowRoot, AtomicStringImpl* changedClass, bool& mayAffectShadowTree) 90 90 { 91 // FIXME: More of this code should be shared between Class/Attribute/IdInvalidation. 91 92 if (!shadowRoot) 92 93 return false; 93 94 auto& shadowRuleSets = shadowRoot->styleScope().resolver().ruleSets(); 94 if (shadowRuleSets.authorStyle().hostPseudoClassRules().isEmpty()) 95 auto& authorStyle = shadowRuleSets.authorStyle(); 96 if (authorStyle.hostPseudoClassRules().isEmpty() && !authorStyle.hasHostPseudoClassRulesMatchingInShadowTree()) 95 97 return false; 96 return shadowRuleSets.features().classesInRules.contains(changedClass); 98 99 if (!shadowRuleSets.features().classesInRules.contains(changedClass)) 100 return false; 101 102 if (authorStyle.hasHostPseudoClassRulesMatchingInShadowTree()) 103 mayAffectShadowTree = true; 104 return true; 97 105 } 98 106 … … 112 120 { 113 121 auto changedClasses = computeClassChange(oldClasses, newClasses); 122 bool mayAffectShadowTree = false; 114 123 115 124 auto& ruleSets = m_element.styleResolver().ruleSets(); … … 120 129 for (auto* changedClass : changedClasses) { 121 130 bool mayAffectStyle = ruleSets.features().classesInRules.contains(changedClass) 122 || mayBeAffectedByHostRules(shadowRoot, changedClass )131 || mayBeAffectedByHostRules(shadowRoot, changedClass, mayAffectShadowTree) 123 132 || mayBeAffectedBySlottedRules(assignedShadowRoots, changedClass); 124 133 if (mayAffectStyle) … … 129 138 return; 130 139 131 if (shadowRoot && ruleSets.authorStyle().hasShadowPseudoElementRules()) { 140 if (shadowRoot && ruleSets.authorStyle().hasShadowPseudoElementRules()) 141 mayAffectShadowTree = true; 142 143 if (mayAffectShadowTree) { 144 // FIXME: We should do fine-grained invalidation for shadow tree. 132 145 m_element.invalidateStyleForSubtree(); 133 146 return; -
trunk/Source/WebCore/style/IdChangeInvalidation.cpp
r214255 r216761 36 36 namespace Style { 37 37 38 static bool mayBeAffectedByHostRules(const Element& element, const AtomicString& changedId )38 static bool mayBeAffectedByHostRules(const Element& element, const AtomicString& changedId, bool& mayAffectShadowTree) 39 39 { 40 40 auto* shadowRoot = element.shadowRoot(); … … 42 42 return false; 43 43 auto& shadowRuleSets = shadowRoot->styleScope().resolver().ruleSets(); 44 if (shadowRuleSets.authorStyle().hostPseudoClassRules().isEmpty()) 44 auto& authorStyle = shadowRuleSets.authorStyle(); 45 if (authorStyle.hostPseudoClassRules().isEmpty() && !authorStyle.hasHostPseudoClassRulesMatchingInShadowTree()) 45 46 return false; 46 return shadowRuleSets.features().idsInRules.contains(changedId); 47 48 if (!shadowRuleSets.features().idsInRules.contains(changedId)) 49 return false; 50 51 if (authorStyle.hasHostPseudoClassRulesMatchingInShadowTree()) 52 mayAffectShadowTree = true; 53 return true; 47 54 } 48 55 … … 65 72 66 73 auto& ruleSets = m_element.styleResolver().ruleSets(); 74 bool mayAffectShadowTree = false; 67 75 68 76 bool mayAffectStyle = ruleSets.features().idsInRules.contains(changedId) 69 || mayBeAffectedByHostRules(m_element, changedId )77 || mayBeAffectedByHostRules(m_element, changedId, mayAffectShadowTree) 70 78 || mayBeAffectedBySlottedRules(m_element, changedId); 71 79 … … 73 81 return; 74 82 75 if (m_element.shadowRoot() && ruleSets.authorStyle().hasShadowPseudoElementRules()) { 83 if (m_element.shadowRoot() && ruleSets.authorStyle().hasShadowPseudoElementRules()) 84 mayAffectShadowTree = true; 85 86 if (mayAffectShadowTree) { 76 87 m_element.invalidateStyleForSubtree(); 77 88 return;
Note: See TracChangeset
for help on using the changeset viewer.