Changeset 235458 in webkit
- Timestamp:
- Aug 28, 2018 10:31:57 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r235457 r235458 1 2018-08-28 Ryosuke Niwa <rniwa@webkit.org> 2 3 Changes to slot children should trigger slotchange 4 https://bugs.webkit.org/show_bug.cgi?id=169718 5 <rdar://problem/43317496> 6 7 Reviewed by Darin Adler. 8 9 Added a W3C style testharness.js test for firing slotchange event for the fallback content change 10 since web-platform-tests/shadow-dom/slotchange.html doesn't have adequate set of tests. 11 12 Chrome and Firefox pass all test cases. WebKit used to fail all test cases before this patch. 13 14 * fast/shadow-dom/slotchange-in-fallback-expected.txt: Added. 15 * fast/shadow-dom/slotchange-in-fallback.html: Added. 16 1 17 2018-08-28 Don Olmstead <don.olmstead@sony.com> 2 18 -
trunk/LayoutTests/imported/w3c/ChangeLog
r235426 r235458 1 2018-08-28 Ryosuke Niwa <rniwa@webkit.org> 2 3 Changes to slot children should trigger slotchange 4 https://bugs.webkit.org/show_bug.cgi?id=169718 5 <rdar://problem/43317496> 6 7 Reviewed by Darin Adler. 8 9 Rebaselined the test now that relevant test cases pass. 10 11 * web-platform-tests/shadow-dom/slotchange-expected.txt: 12 1 13 2018-08-28 Aditya Keerthi <akeerthi@apple.com> 2 14 -
trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/slotchange-expected.txt
r206463 r235458 11 11 PASS slotchange event: Add a fallback content. 12 12 PASS slotchange event: Remove a fallback content. 13 TIMEOUT slotchange event: Add a fallback content to nested slots. Test timed out 14 TIMEOUT slotchange event: Remove a fallback content from nested slots. Test timed out 13 PASS slotchange event: Add a fallback content to nested slots. 14 PASS slotchange event: Remove a fallback content from nested slots. 15 15 TIMEOUT slotchange event: Insert a slot before an existing slot. Test timed out 16 16 TIMEOUT slotchange event: Remove a preceding slot. Test timed out -
trunk/Source/WebCore/ChangeLog
r235457 r235458 1 2018-08-28 Ryosuke Niwa <rniwa@webkit.org> 2 3 Changes to slot children should trigger slotchange 4 https://bugs.webkit.org/show_bug.cgi?id=169718 5 <rdar://problem/43317496> 6 7 Reviewed by Darin Adler. 8 9 Fix the bug that slotchange event is not fired when a slot's fallback content is updated now that slotchange event 10 is more formally specified. 11 12 This particular behavior corresponds to step 7.5. of the concept *to insert a node* where it says: 13 "[I]f parent’s root is a shadow root, and parent is a slot whose assigned nodes is the empty list, then run signal 14 a slot change for parent." 15 16 See https://dom.spec.whatwg.org/#concept-node-insert 17 18 Tests: fast/shadow-dom/slotchange-in-fallback.html 19 imported/w3c/web-platform-tests/shadow-dom/slotchange.html 20 21 * dom/Element.cpp: 22 (WebCore::Element::childrenChanged): Updated the comment. 23 * dom/ShadowRoot.cpp: 24 (WebCore::ShadowRoot::addSlotElementByName): Added an assertion. 25 (WebCore::ShadowRoot::slotFallbackDidChange): Added. 26 * dom/ShadowRoot.h: 27 * dom/SlotAssignment.cpp: 28 (WebCore::SlotAssignment::slotFallbackDidChange): Added. When the assigned nodes is empty, we enqueue a slotchange. 29 Because assignedNodesForSlot invokes assignSlots, this can be O(n) but we don't expect mutating slot's fallback 30 contents and shadow host's children in turn to be a common scenario so this shouldn't be an issue in practice. 31 * dom/SlotAssignment.h: 32 * html/HTMLSlotElement.cpp: 33 (WebCore::HTMLSlotElement::insertedIntoAncestor): Be explicit about auto* being used here. 34 (WebCore::HTMLSlotElement::childrenChanged): Added. Invokes slotFallbackDidChange whenver child node is muated. 35 * html/HTMLSlotElement.h: 36 1 37 2018-08-28 Don Olmstead <don.olmstead@sony.com> 2 38 -
trunk/Source/WebCore/dom/Element.cpp
r235331 r235458 2179 2179 case ElementInserted: 2180 2180 case ElementRemoved: 2181 // For elements, we notify shadowRoot in Element::insertedInto and Element::removedFrom.2181 // For elements, we notify shadowRoot in Element::insertedIntoAncestor and Element::removedFromAncestor. 2182 2182 break; 2183 2183 case AllChildrenRemoved: -
trunk/Source/WebCore/dom/ShadowRoot.cpp
r229694 r235458 184 184 void ShadowRoot::addSlotElementByName(const AtomicString& name, HTMLSlotElement& slot) 185 185 { 186 ASSERT(&slot.rootNode() == this); 186 187 if (!m_slotAssignment) 187 188 m_slotAssignment = std::make_unique<SlotAssignment>(); … … 193 194 { 194 195 return m_slotAssignment->removeSlotElementByName(name, slot, *this); 196 } 197 198 void ShadowRoot::slotFallbackDidChange(HTMLSlotElement& slot) 199 { 200 ASSERT(&slot.rootNode() == this); 201 return m_slotAssignment->slotFallbackDidChange(slot, *this); 195 202 } 196 203 -
trunk/Source/WebCore/dom/ShadowRoot.h
r229694 r235458 75 75 void addSlotElementByName(const AtomicString&, HTMLSlotElement&); 76 76 void removeSlotElementByName(const AtomicString&, HTMLSlotElement&); 77 void slotFallbackDidChange(HTMLSlotElement&); 77 78 78 79 void didRemoveAllChildrenOfShadowHost(); … … 108 109 109 110 std::unique_ptr<Style::Scope> m_styleScope; 110 111 111 std::unique_ptr<SlotAssignment> m_slotAssignment; 112 112 }; -
trunk/Source/WebCore/dom/SlotAssignment.cpp
r223728 r235458 124 124 } 125 125 126 void SlotAssignment::slotFallbackDidChange(HTMLSlotElement& slotElement, ShadowRoot& shadowRoot) 127 { 128 if (shadowRoot.mode() == ShadowRootMode::UserAgent) 129 return; 130 131 bool usesFallbackContent = !assignedNodesForSlot(slotElement, shadowRoot); 132 if (usesFallbackContent) 133 slotElement.enqueueSlotChangeEvent(); 134 } 135 126 136 void SlotAssignment::didChangeSlot(const AtomicString& slotAttrValue, ShadowRoot& shadowRoot) 127 137 { -
trunk/Source/WebCore/dom/SlotAssignment.h
r219237 r235458 52 52 void addSlotElementByName(const AtomicString&, HTMLSlotElement&, ShadowRoot&); 53 53 void removeSlotElementByName(const AtomicString&, HTMLSlotElement&, ShadowRoot&); 54 void slotFallbackDidChange(HTMLSlotElement&, ShadowRoot&); 54 55 55 56 void didChangeSlot(const AtomicString&, ShadowRoot&); -
trunk/Source/WebCore/html/HTMLSlotElement.cpp
r234995 r235458 58 58 59 59 if (insertionType.treeScopeChanged && isInShadowTree()) { 60 if (auto shadowRoot = containingShadowRoot())60 if (auto* shadowRoot = containingShadowRoot()) 61 61 shadowRoot->addSlotElementByName(attributeWithoutSynchronization(nameAttr), *this); 62 62 } … … 74 74 75 75 HTMLElement::removedFromAncestor(removalType, oldParentOfRemovedTree); 76 } 77 78 void HTMLSlotElement::childrenChanged(const ChildChange& childChange) 79 { 80 HTMLElement::childrenChanged(childChange); 81 82 if (isInShadowTree()) { 83 if (auto* shadowRoot = containingShadowRoot()) 84 shadowRoot->slotFallbackDidChange(*this); 85 } 76 86 } 77 87 -
trunk/Source/WebCore/html/HTMLSlotElement.h
r229694 r235458 52 52 InsertedIntoAncestorResult insertedIntoAncestor(InsertionType, ContainerNode&) final; 53 53 void removedFromAncestor(RemovalType, ContainerNode&) final; 54 void childrenChanged(const ChildChange&) final; 54 55 void attributeChanged(const QualifiedName&, const AtomicString& oldValue, const AtomicString& newValue, AttributeModificationReason) final; 55 56
Note: See TracChangeset
for help on using the changeset viewer.