Changeset 208616 in webkit
- Timestamp:
- Nov 11, 2016 3:08:34 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r208613 r208616 1 2016-11-11 Antti Koivisto <antti@apple.com> 2 3 Updating class name doesn't update the slotted content's style 4 https://bugs.webkit.org/show_bug.cgi?id=164577 5 <rdar://problem/29205873> 6 7 Reviewed by Ryosuke Niwa. 8 9 * fast/shadow-dom/css-scoping-slotted-invalidation-expected.html: Added. 10 * fast/shadow-dom/css-scoping-slotted-invalidation.html: Added. 11 1 12 2016-11-11 Chris Dumez <cdumez@apple.com> 2 13 -
trunk/Source/WebCore/ChangeLog
r208615 r208616 1 2016-11-11 Antti Koivisto <antti@apple.com> 2 3 Updating class name doesn't update the slotted content's style 4 https://bugs.webkit.org/show_bug.cgi?id=164577 5 <rdar://problem/29205873> 6 7 Reviewed by Ryosuke Niwa. 8 9 Test: fast/shadow-dom/css-scoping-slotted-invalidation.html 10 11 Teach style invalidation code for attribute/class/id mutations about slotted rules. 12 13 * dom/ShadowRoot.cpp: 14 (WebCore::assignedShadowRootsIfSlotted): 15 16 Helper to find all assigned shadow roots (there may be more than one if slots are assigned to slots). 17 18 * dom/ShadowRoot.h: 19 * style/AttributeChangeInvalidation.cpp: 20 (WebCore::Style::mayBeAffectedByAttributeChange): 21 (WebCore::Style::mayBeAffectedByHostRules): 22 (WebCore::Style::mayBeAffectedBySlottedRules): 23 (WebCore::Style::AttributeChangeInvalidation::invalidateStyle): 24 (WebCore::Style::mayBeAffectedByHostStyle): Deleted. 25 * style/ClassChangeInvalidation.cpp: 26 (WebCore::Style::mayBeAffectedByHostRules): 27 (WebCore::Style::mayBeAffectedBySlottedRules): 28 (WebCore::Style::ClassChangeInvalidation::invalidateStyle): 29 (WebCore::Style::mayBeAffectedByHostStyle): Deleted. 30 * style/ClassChangeInvalidation.h: 31 * style/IdChangeInvalidation.cpp: 32 (WebCore::Style::mayBeAffectedByHostRules): 33 (WebCore::Style::mayBeAffectedBySlottedRules): 34 (WebCore::Style::IdChangeInvalidation::invalidateStyle): 35 (WebCore::Style::mayBeAffectedByHostStyle): Deleted. 36 * style/StyleSharingResolver.cpp: 37 (WebCore::Style::SharingResolver::canShareStyleWithElement): 38 39 Fix a bug in style sharing where we were checking wrong element for host rules. 40 Tested by the included test too (the last empty div). 41 1 42 2016-11-11 Dave Hyatt <hyatt@apple.com> 2 43 -
trunk/Source/WebCore/dom/ShadowRoot.cpp
r208378 r208616 32 32 #include "ElementTraversal.h" 33 33 #include "ExceptionCode.h" 34 #include "HTMLSlotElement.h" 34 35 #include "RenderElement.h" 35 36 #include "RuntimeEnabledFeatures.h" … … 184 185 } 185 186 187 Vector<ShadowRoot*> assignedShadowRootsIfSlotted(const Node& node) 188 { 189 Vector<ShadowRoot*> result; 190 for (auto* slot = node.assignedSlot(); slot; slot = slot->assignedSlot()) { 191 ASSERT(slot->containingShadowRoot()); 192 result.append(slot->containingShadowRoot()); 193 } 194 return result; 195 } 186 196 187 197 } -
trunk/Source/WebCore/dom/ShadowRoot.h
r208118 r208616 134 134 } 135 135 136 Vector<ShadowRoot*> assignedShadowRootsIfSlotted(const Node&); 137 136 138 } // namespace WebCore 137 139 -
trunk/Source/WebCore/style/AttributeChangeInvalidation.cpp
r207458 r208616 37 37 namespace Style { 38 38 39 static bool mayBeAffectedBy HostStyle(ShadowRoot& shadowRoot, bool isHTML, const QualifiedName& attributeName)39 static bool mayBeAffectedByAttributeChange(DocumentRuleSets& ruleSets, bool isHTML, const QualifiedName& attributeName) 40 40 { 41 auto& shadowRuleSets = shadowRoot.styleScope().resolver().ruleSets(); 41 auto& nameSet = isHTML ? ruleSets.features().attributeCanonicalLocalNamesInRules : ruleSets.features().attributeLocalNamesInRules; 42 return nameSet.contains(attributeName.localName().impl()); 43 } 44 45 static bool mayBeAffectedByHostRules(const Element& element, const QualifiedName& attributeName) 46 { 47 auto* shadowRoot = element.shadowRoot(); 48 if (!shadowRoot) 49 return false; 50 auto& shadowRuleSets = shadowRoot->styleScope().resolver().ruleSets(); 42 51 if (shadowRuleSets.authorStyle().hostPseudoClassRules().isEmpty()) 43 52 return false; 44 53 45 auto& nameSet = isHTML ? shadowRuleSets.features().attributeCanonicalLocalNamesInRules : shadowRuleSets.features().attributeLocalNamesInRules; 46 return nameSet.contains(attributeName.localName().impl()); 54 return mayBeAffectedByAttributeChange(shadowRuleSets, element.isHTMLElement(), attributeName); 55 } 56 57 static bool mayBeAffectedBySlottedRules(const Element& element, const QualifiedName& attributeName) 58 { 59 for (auto* shadowRoot : assignedShadowRootsIfSlotted(element)) { 60 auto& ruleSets = shadowRoot->styleScope().resolver().ruleSets(); 61 if (ruleSets.authorStyle().slottedPseudoElementRules().isEmpty()) 62 continue; 63 if (mayBeAffectedByAttributeChange(ruleSets, element.isHTMLElement(), attributeName)) 64 return true; 65 } 66 return false; 47 67 } 48 68 … … 55 75 bool isHTML = m_element.isHTMLElement(); 56 76 57 auto& nameSet = isHTML ? ruleSets.features().attributeCanonicalLocalNamesInRules : ruleSets.features().attributeLocalNamesInRules; 58 bool mayAffectStyle = nameSet.contains(attributeName.localName().impl()); 59 60 auto* shadowRoot = m_element.shadowRoot(); 61 if (!mayAffectStyle && shadowRoot && mayBeAffectedByHostStyle(*shadowRoot, isHTML, attributeName)) 62 mayAffectStyle = true; 77 bool mayAffectStyle = mayBeAffectedByAttributeChange(ruleSets, isHTML, attributeName) 78 || mayBeAffectedByHostRules(m_element, attributeName) 79 || mayBeAffectedBySlottedRules(m_element, attributeName); 63 80 64 81 if (!mayAffectStyle) -
trunk/Source/WebCore/style/ClassChangeInvalidation.cpp
r207458 r208616 87 87 } 88 88 89 static bool mayBeAffectedByHost Style(ShadowRoot&shadowRoot, AtomicStringImpl* changedClass)89 static bool mayBeAffectedByHostRules(ShadowRoot* shadowRoot, AtomicStringImpl* changedClass) 90 90 { 91 auto& shadowRuleSets = shadowRoot.styleScope().resolver().ruleSets(); 91 if (!shadowRoot) 92 return false; 93 auto& shadowRuleSets = shadowRoot->styleScope().resolver().ruleSets(); 92 94 if (shadowRuleSets.authorStyle().hostPseudoClassRules().isEmpty()) 93 95 return false; 94 96 return shadowRuleSets.features().classesInRules.contains(changedClass); 97 } 98 99 static bool mayBeAffectedBySlottedRules(const Vector<ShadowRoot*>& assignedShadowRoots, AtomicStringImpl* changedClass) 100 { 101 for (auto& assignedShadowRoot : assignedShadowRoots) { 102 auto& ruleSets = assignedShadowRoot->styleScope().resolver().ruleSets(); 103 if (ruleSets.authorStyle().slottedPseudoElementRules().isEmpty()) 104 continue; 105 if (ruleSets.features().classesInRules.contains(changedClass)) 106 return true; 107 } 108 return false; 95 109 } 96 110 … … 101 115 auto& ruleSets = m_element.styleResolver().ruleSets(); 102 116 auto* shadowRoot = m_element.shadowRoot(); 117 auto assignedShadowRoots = assignedShadowRootsIfSlotted(m_element); 103 118 104 119 ClassChangeVector changedClassesAffectingStyle; 105 120 for (auto* changedClass : changedClasses) { 106 bool mayAffectStyle = ruleSets.features().classesInRules.contains(changedClass); 107 108 if (!mayAffectStyle && shadowRoot && mayBeAffectedByHostStyle(*shadowRoot, changedClass)) 109 mayAffectStyle = true; 110 121 bool mayAffectStyle = ruleSets.features().classesInRules.contains(changedClass) 122 || mayBeAffectedByHostRules(shadowRoot, changedClass) 123 || mayBeAffectedBySlottedRules(assignedShadowRoots, changedClass); 111 124 if (mayAffectStyle) 112 125 changedClassesAffectingStyle.append(changedClass); -
trunk/Source/WebCore/style/ClassChangeInvalidation.h
r202167 r208616 70 70 invalidateDescendantStyle(); 71 71 } 72 72 73 73 } 74 74 } -
trunk/Source/WebCore/style/IdChangeInvalidation.cpp
r207458 r208616 36 36 namespace Style { 37 37 38 static bool mayBeAffectedByHost Style(ShadowRoot& shadowRoot, const AtomicString& changedId)38 static bool mayBeAffectedByHostRules(const Element& element, const AtomicString& changedId) 39 39 { 40 auto& shadowRuleSets = shadowRoot.styleScope().resolver().ruleSets(); 40 auto* shadowRoot = element.shadowRoot(); 41 if (!shadowRoot) 42 return false; 43 auto& shadowRuleSets = shadowRoot->styleScope().resolver().ruleSets(); 41 44 if (shadowRuleSets.authorStyle().hostPseudoClassRules().isEmpty()) 42 45 return false; 46 return shadowRuleSets.features().idsInRules.contains(changedId.impl()); 47 } 43 48 44 return shadowRuleSets.features().idsInRules.contains(changedId.impl()); 49 static bool mayBeAffectedBySlottedRules(const Element& element, const AtomicString& changedId) 50 { 51 for (auto* shadowRoot : assignedShadowRootsIfSlotted(element)) { 52 auto& ruleSets = shadowRoot->styleScope().resolver().ruleSets(); 53 if (ruleSets.authorStyle().slottedPseudoElementRules().isEmpty()) 54 continue; 55 if (ruleSets.features().idsInRules.contains(changedId.impl())) 56 return true; 57 } 58 return false; 45 59 } 46 60 … … 52 66 auto& ruleSets = m_element.styleResolver().ruleSets(); 53 67 54 bool mayAffectStyle = ruleSets.features().idsInRules.contains(changedId.impl()); 55 56 auto* shadowRoot = m_element.shadowRoot(); 57 if (!mayAffectStyle && shadowRoot && mayBeAffectedByHostStyle(*shadowRoot, changedId)) 58 mayAffectStyle = true; 68 bool mayAffectStyle = ruleSets.features().idsInRules.contains(changedId.impl()) 69 || mayBeAffectedByHostRules(m_element, changedId) 70 || mayBeAffectedBySlottedRules(m_element, changedId); 59 71 60 72 if (!mayAffectStyle) -
trunk/Source/WebCore/style/StyleSharingResolver.cpp
r206951 r208616 289 289 return false; 290 290 291 if ( element.shadowRoot() && !element.shadowRoot()->styleScope().resolver().ruleSets().authorStyle().hostPseudoClassRules().isEmpty())291 if (candidateElement.shadowRoot() && !candidateElement.shadowRoot()->styleScope().resolver().ruleSets().authorStyle().hostPseudoClassRules().isEmpty()) 292 292 return false; 293 293
Note: See TracChangeset
for help on using the changeset viewer.