Changeset 288162 in webkit
- Timestamp:
- Jan 18, 2022 4:27:43 PM (6 months ago)
- Location:
- trunk
- Files:
-
- 12 edited
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-label-element/label-attributes.sub-expected.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/dom/Document.cpp (modified) (3 diffs)
-
Source/WebCore/dom/LiveNodeList.h (modified) (2 diffs)
-
Source/WebCore/dom/NameNodeList.h (modified) (1 diff)
-
Source/WebCore/dom/NodeRareData.h (modified) (1 diff)
-
Source/WebCore/html/HTMLCollection.cpp (modified) (1 diff)
-
Source/WebCore/html/HTMLCollection.h (modified) (4 diffs)
-
Source/WebCore/html/LabelsNodeList.h (modified) (1 diff)
-
Source/WebCore/html/RadioNodeList.cpp (modified) (1 diff)
-
Source/WebCore/html/RadioNodeList.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r288143 r288162 1 2022-01-18 Chris Dumez <cdumez@apple.com> 2 3 input.labels doesn't work inside shadow DOM 4 https://bugs.webkit.org/show_bug.cgi?id=235326 5 6 Reviewed by Darin Adler. 7 8 Rebaseline test that now has one extra passing subtest. This subtest was already passing in both 9 Gecko and Blink. 10 11 * web-platform-tests/html/semantics/forms/the-label-element/label-attributes.sub-expected.txt: 12 1 13 2022-01-18 Sam Weinig <weinig@apple.com> 2 14 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-label-element/label-attributes.sub-expected.txt
r267646 r288162 13 13 FAIL A div element which contains labelable element is removed. assert_equals: The number of labels should be 1 after the labelable element is removed but label element is still in the same tree. expected 1 but got 0 14 14 FAIL A labelable element not in a document can label element in the same tree. assert_equals: The number of labels associated with a form control should be the number of label elements for which it is a labeled control. expected 2 but got 0 15 FAIL A labelable element inside the shadow DOM. assert_equals: The form control has an ancestor with no explicit associated label, and it is the first labelable descendant. expected 1 but got 0 15 PASS A labelable element inside the shadow DOM. 16 16 PASS A form control has an implicit label. 17 17 PASS A form control has no label 1. -
trunk/Source/WebCore/ChangeLog
r288159 r288162 1 2022-01-18 Chris Dumez <cdumez@apple.com> 2 3 input.labels doesn't work inside shadow DOM 4 https://bugs.webkit.org/show_bug.cgi?id=235326 5 6 Reviewed by Darin Adler. 7 8 HTMLCollection and LiveNodeList had the concept of "isRootedAtDocument" which meant that 9 we used the document as root when doing the traversal to find Nodes that belong to the 10 list/collection. However, when the list's owner is inside a shadow tree, this didn't 11 work as expected since we would traverse the main document's DOM tree instead of the 12 shadow tree. To address the issue, I now renamed "isRootedAtDocument" to 13 "isRootedAtTreeScope" and updated rootNode() to return the owner's tree scope's root 14 node, instead of the owner's document. 15 16 No new tests, rebaselined existing test. 17 18 * dom/Document.cpp: 19 (WebCore::Document::registerNodeListForInvalidation): 20 (WebCore::Document::registerCollection): 21 (WebCore::Document::unregisterCollection): 22 * dom/LiveNodeList.h: 23 (WebCore::LiveNodeList::rootNode const): 24 * dom/NameNodeList.h: 25 * dom/NodeRareData.h: 26 (WebCore::NodeListsNodeData::adoptDocument): 27 * html/HTMLCollection.cpp: 28 (WebCore::HTMLCollection::rootTypeFromCollectionType): 29 * html/HTMLCollection.h: 30 (WebCore::HTMLCollection::rootNode const): 31 (WebCore::HTMLCollection::isRootedAtTreeScope const): 32 (WebCore::HTMLCollection::isRootedAtDocument const): Deleted. 33 * html/LabelsNodeList.h: 34 * html/RadioNodeList.cpp: 35 (WebCore::RadioNodeList::RadioNodeList): 36 * html/RadioNodeList.h: 37 1 38 2022-01-18 Alan Bujtas <zalan@apple.com> 2 39 -
trunk/Source/WebCore/dom/Document.cpp
r288087 r288162 4835 4835 { 4836 4836 m_nodeListAndCollectionCounts[list.invalidationType()]++; 4837 if (!list.isRootedAt Document())4837 if (!list.isRootedAtTreeScope()) 4838 4838 return; 4839 4839 ASSERT(!list.isRegisteredForInvalidationAtDocument()); … … 4856 4856 { 4857 4857 m_nodeListAndCollectionCounts[collection.invalidationType()]++; 4858 if (collection.isRootedAt Document())4858 if (collection.isRootedAtTreeScope()) 4859 4859 m_collectionsInvalidatedAtDocument.add(&collection); 4860 4860 } … … 4864 4864 ASSERT(m_nodeListAndCollectionCounts[collection.invalidationType()]); 4865 4865 m_nodeListAndCollectionCounts[collection.invalidationType()]--; 4866 if (!collection.isRootedAt Document())4866 if (!collection.isRootedAtTreeScope()) 4867 4867 return; 4868 4868 -
trunk/Source/WebCore/dom/LiveNodeList.h
r257192 r288162 44 44 45 45 virtual bool elementMatches(Element&) const = 0; 46 virtual bool isRootedAt Document() const = 0;46 virtual bool isRootedAtTreeScope() const = 0; 47 47 48 48 NodeListInvalidationType invalidationType() const { return m_invalidationType; } … … 140 140 inline ContainerNode& LiveNodeList::rootNode() const 141 141 { 142 if (isRootedAtDocument() && m_ownerNode->isConnected()) 143 return document(); 144 142 if (isRootedAtTreeScope() && m_ownerNode->isInTreeScope()) 143 return m_ownerNode->treeScope().rootNode(); 145 144 return m_ownerNode; 146 145 } -
trunk/Source/WebCore/dom/NameNodeList.h
r257192 r288162 35 35 36 36 bool elementMatches(Element&) const final; 37 bool isRootedAt Document() const final { return false; }37 bool isRootedAtTreeScope() const final { return false; } 38 38 39 39 private: -
trunk/Source/WebCore/dom/NodeRareData.h
r285478 r288162 199 199 200 200 for (auto& list : m_tagCollectionNSCache.values()) { 201 ASSERT(!list->isRootedAt Document());201 ASSERT(!list->isRootedAtTreeScope()); 202 202 list->invalidateCacheForDocument(oldDocument); 203 203 } -
trunk/Source/WebCore/html/HTMLCollection.cpp
r277908 r288162 49 49 case DocumentAllNamedItems: 50 50 case FormControls: 51 return HTMLCollection::IsRootedAt Document;51 return HTMLCollection::IsRootedAtTreeScope; 52 52 case AllDescendants: 53 53 case ByClass: -
trunk/Source/WebCore/html/HTMLCollection.h
r277908 r288162 76 76 size_t memoryCost() const override; 77 77 78 bool isRootedAt Document() const;78 bool isRootedAtTreeScope() const; 79 79 NodeListInvalidationType invalidationType() const; 80 80 CollectionType type() const; … … 100 100 void invalidateNamedElementCache(Document&) const; 101 101 102 enum RootType { IsRootedAtNode, IsRootedAt Document};102 enum RootType { IsRootedAtNode, IsRootedAtTreeScope }; 103 103 static RootType rootTypeFromCollectionType(CollectionType); 104 104 … … 116 116 inline ContainerNode& HTMLCollection::rootNode() const 117 117 { 118 if (isRootedAtDocument() && ownerNode().isConnected()) 119 return ownerNode().document(); 120 118 if (isRootedAtTreeScope() && ownerNode().isInTreeScope()) 119 return ownerNode().treeScope().rootNode(); 121 120 return ownerNode(); 122 121 } … … 180 179 } 181 180 182 inline bool HTMLCollection::isRootedAt Document() const183 { 184 return m_rootType == IsRootedAt Document;181 inline bool HTMLCollection::isRootedAtTreeScope() const 182 { 183 return m_rootType == IsRootedAtTreeScope; 185 184 } 186 185 -
trunk/Source/WebCore/html/LabelsNodeList.h
r257192 r288162 38 38 39 39 bool elementMatches(Element&) const final; 40 bool isRootedAt Document() const final { return true; }40 bool isRootedAtTreeScope() const final { return true; } 41 41 42 42 private: -
trunk/Source/WebCore/html/RadioNodeList.cpp
r257192 r288162 43 43 : CachedLiveNodeList(rootNode, InvalidateForFormControls) 44 44 , m_name(name) 45 , m_isRootedAt Document(is<HTMLFormElement>(rootNode))45 , m_isRootedAtTreeScope(is<HTMLFormElement>(rootNode)) 46 46 { 47 47 } -
trunk/Source/WebCore/html/RadioNodeList.h
r257192 r288162 43 43 private: 44 44 RadioNodeList(ContainerNode&, const AtomString& name); 45 bool isRootedAt Document() const final { return m_isRootedAtDocument; }45 bool isRootedAtTreeScope() const final { return m_isRootedAtTreeScope; } 46 46 47 47 AtomString m_name; 48 bool m_isRootedAt Document;48 bool m_isRootedAtTreeScope; 49 49 }; 50 50
Note: See TracChangeset
for help on using the changeset viewer.