- Revision
- 292086
- Author
- [email protected]
- Date
- 2022-03-29 17:34:26 -0700 (Tue, 29 Mar 2022)
Log Message
AX: Don't detach children in AXIsolatedTree::applyPendingChanges for nodes being updated (removed and added)
https://bugs.webkit.org/show_bug.cgi?id=238460
Reviewed by Chris Fleizach and Andres Gonzalez.
Source/WebCore:
In AXIsolatedTree::updateNode, we perform the update by queuing the node to be
removed, and then queueing it to be added. When performing the removal in
AXIsolatedTree::applyPendingChanges, we call AXCoreObject::detach, which unconditionally
calls AXCoreObject::detachRemoteParts. Specifically, AXIsolatedObject::detachRemoteParts
detaches all the object's children from the itself (by setting their m_parentID to zero).
Then, when we start applying m_pendingAppends, we re-add the object, but never re-attach
the children, resulting in a broken tree.
This patch fixes this by storing the reason (AccessibilityDetachmentType) the node is
being removed in m_pendingNodeRemovals, and not detaching children if the type is
AccessibilityDetachmentType::ElementChanged, as in the case of a node update.
This patch also removes AXIsolatedObject::setParent. It's never called, and
its existence is therefore confusing.
Test: accessibility/search-traversal-after-role-change.html.
This test exercises the behavior in this patch because changing an
object's role triggers AXIsolatedTree::updateNode.
* accessibility/AccessibilityObjectInterface.h:
(WebCore::AXCoreObject::detach):
* accessibility/isolatedtree/AXIsolatedObject.cpp:
(WebCore::AXIsolatedObject::setParent): Deleted.
* accessibility/isolatedtree/AXIsolatedObject.h:
* accessibility/isolatedtree/AXIsolatedTree.cpp:
(WebCore::AXIsolatedTree::updateNode):
(WebCore::AXIsolatedTree::applyPendingChanges):
* accessibility/isolatedtree/AXIsolatedTree.h:
LayoutTests:
* accessibility/search-traversal-after-role-change-expected.txt: Added.
* accessibility/search-traversal-after-role-change.html: Added.
* platform/glib/TestExpectations: Skip new test.
* platform/ios/TestExpectations: Enable new test.
* platform/ios/accessibility/search-traversal-after-role-change-expected.txt: Added.
* platform/win/TestExpectations: Skip new test.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (292085 => 292086)
--- trunk/LayoutTests/ChangeLog 2022-03-30 00:32:17 UTC (rev 292085)
+++ trunk/LayoutTests/ChangeLog 2022-03-30 00:34:26 UTC (rev 292086)
@@ -1,3 +1,17 @@
+2022-03-29 Tyler Wilcock <[email protected]>
+
+ AX: Don't detach children in AXIsolatedTree::applyPendingChanges for nodes being updated (removed and added)
+ https://bugs.webkit.org/show_bug.cgi?id=238460
+
+ Reviewed by Chris Fleizach and Andres Gonzalez.
+
+ * accessibility/search-traversal-after-role-change-expected.txt: Added.
+ * accessibility/search-traversal-after-role-change.html: Added.
+ * platform/glib/TestExpectations: Skip new test.
+ * platform/ios/TestExpectations: Enable new test.
+ * platform/ios/accessibility/search-traversal-after-role-change-expected.txt: Added.
+ * platform/win/TestExpectations: Skip new test.
+
2022-03-29 Devin Rousso <[email protected]>
Web Inspector: Sources: allow Response Local Overrides to map to a file on disk
Added: trunk/LayoutTests/accessibility/search-traversal-after-role-change-expected.txt (0 => 292086)
--- trunk/LayoutTests/accessibility/search-traversal-after-role-change-expected.txt (rev 0)
+++ trunk/LayoutTests/accessibility/search-traversal-after-role-change-expected.txt 2022-03-30 00:34:26 UTC (rev 292086)
@@ -0,0 +1,43 @@
+This test ensures we can traverse through an object's children after its role is changed dynamically.
+
+Performing search traversal with initial page state.
+
+AXRole: AXHeading
+
+AXRole: AXStaticText
+AXValue: Hello world!
+
+AXRole: AXToolbar
+
+AXRole: AXGroup
+
+AXRole: AXButton
+
+AXRole: AXGroup
+
+AXRole: AXStaticText
+AXValue: Lorem ipsum
+
+Performing search traversal after role change.
+
+AXRole: AXHeading
+
+AXRole: AXStaticText
+AXValue: Hello world!
+
+AXRole: AXToolbar
+
+AXRole: AXGroup
+
+AXRole: AXButton
+
+AXRole: AXGroup
+
+AXRole: AXStaticText
+AXValue: Lorem ipsum
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
Added: trunk/LayoutTests/accessibility/search-traversal-after-role-change.html (0 => 292086)
--- trunk/LayoutTests/accessibility/search-traversal-after-role-change.html (rev 0)
+++ trunk/LayoutTests/accessibility/search-traversal-after-role-change.html 2022-03-30 00:34:26 UTC (rev 292086)
@@ -0,0 +1,66 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+<script src=""
+</head>
+<body>
+
+<div id="container" role="group">
+ <h1>Hello world!</h1>
+ <div role="toolbar">
+ <div>
+ <button>Foo</button>
+ </div>
+ </div>
+
+ <div role="article">
+ Lorem ipsum
+ </div>
+</div>
+
+<script>
+ var testOutput = "This test ensures we can traverse through an object's children after its role is changed dynamically.\n";
+
+ function traverse(containerElement) {
+ let searchResult = null;
+ while (true) {
+ searchResult = containerElement.uiElementForSearchPredicate(searchResult, true, "AXAnyTypeSearchKey", "", false);
+ if (!searchResult)
+ break;
+ const role = searchResult.role;
+ testOutput += `\n${role}`;
+ if (role.includes("StaticText")) {
+ let textContent = accessibilityController.platformName === "ios" ? searchResult.description : searchResult.stringValue;
+ testOutput += `\n${textContent}`;
+ }
+ testOutput += "\n";
+ }
+ }
+
+ if (window.accessibilityController) {
+ window.jsTestIsAsync = true;
+ const container = accessibilityController.accessibleElementById("container");
+ testOutput += "\nPerforming search traversal with initial page state.\n";
+ traverse(container);
+
+ document.getElementById("container").role = "main";
+ setTimeout(async function() {
+ await waitFor(() => {
+ if (accessibilityController.platformName === "ios")
+ return container.role && container.role.includes("LandmarkMain");
+
+ return container.subrole && container.subrole.includes("AXLandmarkMain");
+ });
+ testOutput += "\nPerforming search traversal after role change.\n";
+ traverse(container);
+
+ document.getElementById("container").style.visibility = "hidden";
+ debug(testOutput);
+ finishJSTest();
+ }, 0);
+ }
+</script>
+</body>
+</html>
+
Modified: trunk/LayoutTests/platform/glib/TestExpectations (292085 => 292086)
--- trunk/LayoutTests/platform/glib/TestExpectations 2022-03-30 00:32:17 UTC (rev 292085)
+++ trunk/LayoutTests/platform/glib/TestExpectations 2022-03-30 00:34:26 UTC (rev 292086)
@@ -343,6 +343,7 @@
# Missing AccessibilityUIElement::uiElementForSearchPredicate implementation.
accessibility/display-contents-search-traversal.html [ Skip ]
+accessibility/search-traversal-after-role-change.html [ Skip ]
accessibility/table-search-traversal.html [ Skip ]
accessibility/dynamically-changing-iframe-remains-accessible.html [ Skip ]
accessibility/ignore-modals-without-any-content.html [ Skip ]
Modified: trunk/LayoutTests/platform/ios/TestExpectations (292085 => 292086)
--- trunk/LayoutTests/platform/ios/TestExpectations 2022-03-30 00:32:17 UTC (rev 292085)
+++ trunk/LayoutTests/platform/ios/TestExpectations 2022-03-30 00:34:26 UTC (rev 292086)
@@ -2115,6 +2115,7 @@
webkit.org/b/150366 accessibility/aria-table-attributes.html [ Pass ]
accessibility/display-contents-search-traversal.html [ Pass ]
+accessibility/search-traversal-after-role-change.html [ Pass ]
accessibility/table-search-traversal.html [ Pass ]
accessibility/dynamically-changing-iframe-remains-accessible.html [ Pass ]
accessibility/ignore-modals-without-any-content.html [ Pass ]
Added: trunk/LayoutTests/platform/ios/accessibility/search-traversal-after-role-change-expected.txt (0 => 292086)
--- trunk/LayoutTests/platform/ios/accessibility/search-traversal-after-role-change-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/ios/accessibility/search-traversal-after-role-change-expected.txt 2022-03-30 00:34:26 UTC (rev 292086)
@@ -0,0 +1,27 @@
+This test ensures we can traverse through an object's children after its role is changed dynamically.
+
+Performing search traversal with initial page state.
+
+StaticText
+AXLabel: Hello world!
+
+Button
+
+StaticText
+AXLabel: Lorem ipsum
+
+Performing search traversal after role change.
+
+StaticText
+AXLabel: Hello world!
+
+Button
+
+StaticText
+AXLabel: Lorem ipsum
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+
Modified: trunk/LayoutTests/platform/win/TestExpectations (292085 => 292086)
--- trunk/LayoutTests/platform/win/TestExpectations 2022-03-30 00:32:17 UTC (rev 292085)
+++ trunk/LayoutTests/platform/win/TestExpectations 2022-03-30 00:34:26 UTC (rev 292086)
@@ -479,6 +479,7 @@
# Missing AccessibilityUIElement::uiElementForSearchPredicate implementation.
accessibility/display-contents-search-traversal.html [ Skip ]
+accessibility/search-traversal-after-role-change.html [ Skip ]
accessibility/table-search-traversal.html [ Skip ]
accessibility/dynamically-changing-iframe-remains-accessible.html [ Skip ]
accessibility/ignore-modals-without-any-content.html [ Skip ]
Modified: trunk/Source/WebCore/ChangeLog (292085 => 292086)
--- trunk/Source/WebCore/ChangeLog 2022-03-30 00:32:17 UTC (rev 292085)
+++ trunk/Source/WebCore/ChangeLog 2022-03-30 00:34:26 UTC (rev 292086)
@@ -1,5 +1,41 @@
2022-03-29 Tyler Wilcock <[email protected]>
+ AX: Don't detach children in AXIsolatedTree::applyPendingChanges for nodes being updated (removed and added)
+ https://bugs.webkit.org/show_bug.cgi?id=238460
+
+ Reviewed by Chris Fleizach and Andres Gonzalez.
+
+ In AXIsolatedTree::updateNode, we perform the update by queuing the node to be
+ removed, and then queueing it to be added. When performing the removal in
+ AXIsolatedTree::applyPendingChanges, we call AXCoreObject::detach, which unconditionally
+ calls AXCoreObject::detachRemoteParts. Specifically, AXIsolatedObject::detachRemoteParts
+ detaches all the object's children from the itself (by setting their m_parentID to zero).
+ Then, when we start applying m_pendingAppends, we re-add the object, but never re-attach
+ the children, resulting in a broken tree.
+
+ This patch fixes this by storing the reason (AccessibilityDetachmentType) the node is
+ being removed in m_pendingNodeRemovals, and not detaching children if the type is
+ AccessibilityDetachmentType::ElementChanged, as in the case of a node update.
+
+ This patch also removes AXIsolatedObject::setParent. It's never called, and
+ its existence is therefore confusing.
+
+ Test: accessibility/search-traversal-after-role-change.html.
+ This test exercises the behavior in this patch because changing an
+ object's role triggers AXIsolatedTree::updateNode.
+
+ * accessibility/AccessibilityObjectInterface.h:
+ (WebCore::AXCoreObject::detach):
+ * accessibility/isolatedtree/AXIsolatedObject.cpp:
+ (WebCore::AXIsolatedObject::setParent): Deleted.
+ * accessibility/isolatedtree/AXIsolatedObject.h:
+ * accessibility/isolatedtree/AXIsolatedTree.cpp:
+ (WebCore::AXIsolatedTree::updateNode):
+ (WebCore::AXIsolatedTree::applyPendingChanges):
+ * accessibility/isolatedtree/AXIsolatedTree.h:
+
+2022-03-29 Tyler Wilcock <[email protected]>
+
AXIsolatedObject::isAccessibilityObject should not be ASSERT_NOT_REACHED
https://bugs.webkit.org/show_bug.cgi?id=238511
Modified: trunk/Source/WebCore/accessibility/AccessibilityObjectInterface.h (292085 => 292086)
--- trunk/Source/WebCore/accessibility/AccessibilityObjectInterface.h 2022-03-30 00:32:17 UTC (rev 292085)
+++ trunk/Source/WebCore/accessibility/AccessibilityObjectInterface.h 2022-03-30 00:34:26 UTC (rev 292086)
@@ -1569,7 +1569,8 @@
inline void AXCoreObject::detach(AccessibilityDetachmentType detachmentType)
{
detachWrapper(detachmentType);
- detachRemoteParts(detachmentType);
+ if (detachmentType != AccessibilityDetachmentType::ElementChanged)
+ detachRemoteParts(detachmentType);
setObjectID({ });
}
Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp (292085 => 292086)
--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp 2022-03-30 00:32:17 UTC (rev 292085)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.cpp 2022-03-30 00:34:26 UTC (rev 292086)
@@ -485,12 +485,6 @@
m_propertyMap.set(propertyName, value);
}
-void AXIsolatedObject::setParent(AXID parent)
-{
- ASSERT(isMainThread());
- m_parentID = parent;
-}
-
void AXIsolatedObject::detachRemoteParts(AccessibilityDetachmentType)
{
for (const auto& childID : m_childrenIDs) {
Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h (292085 => 292086)
--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h 2022-03-30 00:32:17 UTC (rev 292085)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h 2022-03-30 00:34:26 UTC (rev 292086)
@@ -57,8 +57,6 @@
void attachPlatformWrapper(AccessibilityObjectWrapper*);
bool isDetached() const override;
- void setParent(AXID);
-
private:
void detachRemoteParts(AccessibilityDetachmentType) override;
void detachPlatformWrapper(AccessibilityDetachmentType) override;
Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp (292085 => 292086)
--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp 2022-03-30 00:32:17 UTC (rev 292085)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp 2022-03-30 00:34:26 UTC (rev 292086)
@@ -307,7 +307,7 @@
// Remove the old object and set the new one to be updated on the AX thread.
Locker locker { m_changeLogLock };
- m_pendingNodeRemovals.append(axID);
+ m_pendingNodeRemovals.append({ axID, AccessibilityDetachmentType::ElementChanged });
queueChange(change);
}
@@ -545,11 +545,11 @@
}
while (m_pendingNodeRemovals.size()) {
- auto axID = m_pendingNodeRemovals.takeLast();
- AXLOG(makeString("removing axID ", axID.loggingString()));
- if (auto object = nodeForID(axID)) {
- object->detach(AccessibilityDetachmentType::ElementDestroyed);
- m_readerThreadNodeMap.remove(axID);
+ auto removal = m_pendingNodeRemovals.takeLast();
+ AXLOG(makeString("removing axID ", removal.first.loggingString()));
+ if (auto object = nodeForID(removal.first)) {
+ object->detach(removal.second);
+ m_readerThreadNodeMap.remove(removal.first);
}
}
Modified: trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h (292085 => 292086)
--- trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h 2022-03-30 00:32:17 UTC (rev 292085)
+++ trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h 2022-03-30 00:34:26 UTC (rev 292086)
@@ -411,7 +411,8 @@
RefPtr<AXIsolatedObject> m_rootNode WTF_GUARDED_BY_LOCK(m_changeLogLock);
Vector<NodeChange> m_pendingAppends WTF_GUARDED_BY_LOCK(m_changeLogLock); // Nodes to be added to the tree and platform-wrapped.
Vector<AXPropertyChange> m_pendingPropertyChanges WTF_GUARDED_BY_LOCK(m_changeLogLock);
- Vector<AXID> m_pendingNodeRemovals WTF_GUARDED_BY_LOCK(m_changeLogLock); // Nodes to be removed from the tree.
+ // Nodes to be removed from the tree (and the AccessibilityDetachmentType reason for the removal).
+ Vector<std::pair<AXID, AccessibilityDetachmentType>> m_pendingNodeRemovals WTF_GUARDED_BY_LOCK(m_changeLogLock);
Vector<AXID> m_pendingSubtreeRemovals WTF_GUARDED_BY_LOCK(m_changeLogLock); // Nodes whose subtrees are to be removed from the tree.
Vector<std::pair<AXID, Vector<AXID>>> m_pendingChildrenUpdates WTF_GUARDED_BY_LOCK(m_changeLogLock);
AXID m_pendingFocusedNodeID WTF_GUARDED_BY_LOCK(m_changeLogLock);