Title: [288419] trunk/Source/WebCore
Revision
288419
Author
[email protected]
Date
2022-01-23 08:50:20 -0800 (Sun, 23 Jan 2022)

Log Message

AX: Refactor near-duplicate AXObjectCache::updateIsolatedTree implementations
https://bugs.webkit.org/show_bug.cgi?id=235481

Reviewed by Chris Fleizach.

AXObjectCache::updateIsolatedTree(AXCoreObject&, AXNotification) and
AXObjectCache::updateIsolatedTree(const Vector<std::pair<RefPtr<AXCoreObject>, AXNotification>>&)
duplicate a lot of code, and make it possible to forget to add new
notification handling in one place or the other. This patch refactors
this by making the single-object versions of this method defer to the
multiple-object version by wrapping the single change in a Vector.

No tests added because there is no behavior change.

* accessibility/AXObjectCache.cpp:
(WebCore::appendIfNotContainsMatching):
Moved this function above updateIsolatedTree methods. No other change.
(WebCore::AXObjectCache::updateIsolatedTree):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (288418 => 288419)


--- trunk/Source/WebCore/ChangeLog	2022-01-23 16:25:32 UTC (rev 288418)
+++ trunk/Source/WebCore/ChangeLog	2022-01-23 16:50:20 UTC (rev 288419)
@@ -1,3 +1,24 @@
+2022-01-23  Tyler Wilcock  <[email protected]>
+
+        AX: Refactor near-duplicate AXObjectCache::updateIsolatedTree implementations
+        https://bugs.webkit.org/show_bug.cgi?id=235481
+
+        Reviewed by Chris Fleizach.
+
+        AXObjectCache::updateIsolatedTree(AXCoreObject&, AXNotification) and
+        AXObjectCache::updateIsolatedTree(const Vector<std::pair<RefPtr<AXCoreObject>, AXNotification>>&)
+        duplicate a lot of code, and make it possible to forget to add new
+        notification handling in one place or the other. This patch refactors
+        this by making the single-object versions of this method defer to the
+        multiple-object version by wrapping the single change in a Vector.
+
+        No tests added because there is no behavior change.
+
+        * accessibility/AXObjectCache.cpp:
+        (WebCore::appendIfNotContainsMatching):
+        Moved this function above updateIsolatedTree methods. No other change.
+        (WebCore::AXObjectCache::updateIsolatedTree):
+
 2022-01-23  Alan Bujtas  <[email protected]>
 
         [LFC][IFC] LineLayout::contentLogicalHeight should always return the logical height

Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (288418 => 288419)


--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2022-01-23 16:25:32 UTC (rev 288418)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp	2022-01-23 16:50:20 UTC (rev 288419)
@@ -3276,55 +3276,14 @@
 }
     
 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
-void AXObjectCache::updateIsolatedTree(AXCoreObject& object, AXNotification notification)
+// FIXME: should be added to WTF::Vector.
+template<typename T, typename F>
+static bool appendIfNotContainsMatching(Vector<T>& vector, const T& value, F matches)
 {
-    AXTRACE("AXObjectCache::updateIsolatedTree");
-    AXLOG(std::make_pair(&object, notification));
-    AXLOG(*this);
-
-    if (!m_pageID || !object.objectID().isValid()) {
-        AXLOG("No pageID or objectID");
-        return;
-    }
-
-    auto tree = AXIsolatedTree::treeForPageID(*m_pageID);
-    if (!tree) {
-        AXLOG("No isolated tree for m_pageID.");
-        return;
-    }
-
-    switch (notification) {
-    case AXAriaRoleChanged:
-        tree->updateNode(object);
-        break;
-    case AXCheckedStateChanged:
-        tree->updateNodeProperty(object, AXPropertyName::IsChecked);
-        break;
-    case AXDisabledStateChanged:
-        tree->updateNodeProperty(object, AXPropertyName::CanSetFocusAttribute);
-        break;
-    case AXSortDirectionChanged:
-        tree->updateNodeProperty(object, AXPropertyName::SortDirection);
-        break;
-    case AXIdAttributeChanged:
-        tree->updateNodeProperty(object, AXPropertyName::IdentifierAttribute);
-        break;
-    case AXActiveDescendantChanged:
-    case AXSelectedChildrenChanged:
-    case AXValueChanged:
-        tree->updateNode(object);
-        break;
-    case AXChildrenChanged:
-    case AXLanguageChanged:
-    case AXRowCountChanged:
-    case AXRowCollapsed:
-    case AXRowExpanded:
-    case AXExpandedChanged:
-        tree->updateChildren(object);
-        break;
-    default:
-        break;
-    }
+    if (vector.findMatching(matches) != notFound)
+        return false;
+    vector.append(value);
+    return true;
 }
 
 void AXObjectCache::updateIsolatedTree(AXCoreObject* object, AXNotification notification)
@@ -3333,14 +3292,9 @@
         updateIsolatedTree(*object, notification);
 }
 
-// FIXME: should be added to WTF::Vector.
-template<typename T, typename F>
-static bool appendIfNotContainsMatching(Vector<T>& vector, const T& value, F matches)
+void AXObjectCache::updateIsolatedTree(AXCoreObject& object, AXNotification notification)
 {
-    if (vector.findMatching(matches) != notFound)
-        return false;
-    vector.append(value);
-    return true;
+    updateIsolatedTree({ std::make_pair(&object, notification) });
 }
 
 void AXObjectCache::updateIsolatedTree(const Vector<std::pair<RefPtr<AXCoreObject>, AXNotification>>& notifications)
@@ -3368,9 +3322,6 @@
             continue;
 
         switch (notification.second) {
-        case AXAriaRoleChanged:
-            tree->updateNode(*notification.first);
-            break;
         case AXCheckedStateChanged:
             tree->updateNodeProperty(*notification.first, AXPropertyName::IsChecked);
             break;
@@ -3384,6 +3335,7 @@
             tree->updateNodeProperty(*notification.first, AXPropertyName::IdentifierAttribute);
             break;
         case AXActiveDescendantChanged:
+        case AXAriaRoleChanged:
         case AXSelectedChildrenChanged:
         case AXValueChanged: {
             bool needsUpdate = appendIfNotContainsMatching(filteredNotifications, notification, [&notification] (const std::pair<RefPtr<AXCoreObject>, AXNotification>& note) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to