Title: [292223] trunk/Source/WebCore
Revision
292223
Author
andresg...@apple.com
Date
2022-04-01 09:42:06 -0700 (Fri, 01 Apr 2022)

Log Message

Add AXObjectCache::treeData() to retrieve serialized representation of the AX trees.
https://bugs.webkit.org/show_bug.cgi?id=238561
<rdar://problem/91055027>

Reviewed by Chris Fleizach.

Added AXObjectCache::treeData() to retrieve a serialized representation
of both the live and isolated AX trees. The immediate application of
this will be log to file the trees from the browser. Other application
down the road may be to expose a text document-like representation of
the web page for AT clients.

* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::treeData):
* accessibility/AXObjectCache.h:
(WebCore::AXObjectCache::treeData):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (292222 => 292223)


--- trunk/Source/WebCore/ChangeLog	2022-04-01 15:35:55 UTC (rev 292222)
+++ trunk/Source/WebCore/ChangeLog	2022-04-01 16:42:06 UTC (rev 292223)
@@ -1,3 +1,22 @@
+2022-04-01  Andres Gonzalez  <andresg...@apple.com>
+
+        Add AXObjectCache::treeData() to retrieve serialized representation of the AX trees.
+        https://bugs.webkit.org/show_bug.cgi?id=238561
+        <rdar://problem/91055027>
+
+        Reviewed by Chris Fleizach.
+
+        Added AXObjectCache::treeData() to retrieve a serialized representation
+        of both the live and isolated AX trees. The immediate application of
+        this will be log to file the trees from the browser. Other application
+        down the road may be to expose a text document-like representation of
+        the web page for AT clients.
+
+        * accessibility/AXObjectCache.cpp:
+        (WebCore::AXObjectCache::treeData):
+        * accessibility/AXObjectCache.h:
+        (WebCore::AXObjectCache::treeData):
+
 2022-04-01  Tim Nguyen  <n...@apple.com>
 
         [css-logical] Add support for block/inline CSS values for resize property

Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (292222 => 292223)


--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2022-04-01 15:35:55 UTC (rev 292222)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2022-04-01 16:42:06 UTC (rev 292223)
@@ -3546,6 +3546,35 @@
     return root->webAreaObject();
 }
 
+AXTreeData AXObjectCache::treeData()
+{
+    ASSERT(isMainThread());
+
+    AXTreeData data;
+    TextStream stream(TextStream::LineMode::MultipleLine);
+
+    stream << "\nAXObjectTree:\n";
+    if (auto* root = get(document().view())) {
+        constexpr OptionSet<AXStreamOptions> options = { AXStreamOptions::ObjectID, AXStreamOptions::ParentID };
+        streamSubtree(stream, root, options);
+    } else
+        stream << "No root!";
+    data.liveTree = stream.release();
+
+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+    if (isIsolatedTreeEnabled()) {
+        stream << "\nAXIsolatedTree:\n";
+        if (auto tree = getOrCreateIsolatedTree())
+            streamIsolatedSubtreeOnMainThread(stream, *tree, tree->rootNode()->objectID(), { AXStreamOptions::ObjectID, AXStreamOptions::ParentID });
+        else
+            stream << "No isolated tree!";
+        data.isolatedTree = stream.release();
+    }
+#endif
+
+    return data;
+}
+
 AXAttributeCacheEnabler::AXAttributeCacheEnabler(AXObjectCache* cache)
     : m_cache(cache)
 {

Modified: trunk/Source/WebCore/accessibility/AXObjectCache.h (292222 => 292223)


--- trunk/Source/WebCore/accessibility/AXObjectCache.h	2022-04-01 15:35:55 UTC (rev 292222)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.h	2022-04-01 16:42:06 UTC (rev 292223)
@@ -120,6 +120,11 @@
     bool isNull() const { return startIndex.value == -1 || endIndex.value == -1; }
 };
 
+struct AXTreeData {
+    String liveTree;
+    String isolatedTree;
+};
+
 class AccessibilityReplacedText {
 public:
     AccessibilityReplacedText() = default;
@@ -365,6 +370,8 @@
 
     static String notificationPlatformName(AXNotification);
 
+    AXTreeData treeData();
+
 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
     WEBCORE_EXPORT static bool isIsolatedTreeEnabled();
     WEBCORE_EXPORT static bool usedOnAXThread();
@@ -644,12 +651,12 @@
 inline AXTextChange AXObjectCache::textChangeForEditType(AXTextEditType) { return AXTextInserted; }
 inline void AXObjectCache::nodeTextChangePlatformNotification(AccessibilityObject*, AXTextChange, unsigned, const String&) { }
 #endif
+inline AXTreeData AXObjectCache::treeData() { return { }; }
 
 inline AXAttributeCacheEnabler::AXAttributeCacheEnabler(AXObjectCache*) { }
 inline AXAttributeCacheEnabler::~AXAttributeCacheEnabler() { }
+#endif // !ENABLE(ACCESSIBILITY)
 
-#endif
-
 WTF::TextStream& operator<<(WTF::TextStream&, AXObjectCache::AXNotification);
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to