AX: Make AXIsolatedTree compile again
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 12 Oct 2019 07:57:07 +0000 (07:57 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 12 Oct 2019 07:57:07 +0000 (07:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=202702
<rdar://problem/56084968>

Reviewed by Joanmarie Diggs.

Source/WebCore:

Fix compilation and runtime issues when building with ACCESSIBILITY_ISOLATED_TREE.

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored const):
* accessibility/isolatedtree/AXIsolatedTree.cpp:
(WebCore::AXIsolatedTree::treePageCache):
(WebCore::AXIsolatedTree::nodeForID const):
    - Remove release assert here because the initial request that comes through happens on the main thread.
      We need to handle that case specific case.
(WebCore::AXIsolatedTree::applyPendingChanges):
(WebCore::AXIsolatedTree::initializePageTreeForID): Deleted.
(WebCore::AXIsolatedTree::setInitialRequestInProgress): Deleted.
* accessibility/isolatedtree/AXIsolatedTree.h:
* accessibility/isolatedtree/AXIsolatedTreeNode.cpp:
(WebCore::AXIsolatedTreeNode::rectAttributeValue const):
* accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
(convertToNSArray):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper childrenVectorArray]):

Source/WebKit:

* WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.mm:
(-[WKAccessibilityWebPageObjectBase isolatedTreeRootObject]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251045 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/accessibility/AXObjectCache.cpp
Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp
Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h
Source/WebCore/accessibility/isolatedtree/AXIsolatedTreeNode.cpp
Source/WebCore/accessibility/isolatedtree/AXIsolatedTreeNode.h
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
Source/WebKit/ChangeLog
Source/WebKit/Configurations/BaseTarget.xcconfig
Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.mm

index 8855bfa..629efb5 100644 (file)
@@ -1,3 +1,31 @@
+2019-10-12  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Make AXIsolatedTree compile again
+        https://bugs.webkit.org/show_bug.cgi?id=202702
+        <rdar://problem/56084968>
+
+        Reviewed by Joanmarie Diggs.
+
+        Fix compilation and runtime issues when building with ACCESSIBILITY_ISOLATED_TREE.
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored const):
+        * accessibility/isolatedtree/AXIsolatedTree.cpp:
+        (WebCore::AXIsolatedTree::treePageCache):
+        (WebCore::AXIsolatedTree::nodeForID const):
+            - Remove release assert here because the initial request that comes through happens on the main thread.
+              We need to handle that case specific case.
+        (WebCore::AXIsolatedTree::applyPendingChanges):
+        (WebCore::AXIsolatedTree::initializePageTreeForID): Deleted.
+        (WebCore::AXIsolatedTree::setInitialRequestInProgress): Deleted.
+        * accessibility/isolatedtree/AXIsolatedTree.h:
+        * accessibility/isolatedtree/AXIsolatedTreeNode.cpp:
+        (WebCore::AXIsolatedTreeNode::rectAttributeValue const):
+        * accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
+        (convertToNSArray):
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper childrenVectorArray]):
+
 2019-10-11  Ryosuke Niwa  <rniwa@webkit.org>
 
         Windows build fix attempt after r251043.
index e0bbda2..aae4d86 100644 (file)
@@ -730,8 +730,10 @@ void AXObjectCache::remove(AXID axID)
 
     m_idsInUse.remove(axID);
 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
-    if (auto pageID = m_document.pageID())
-        AXIsolatedTree::treeForPageID(*pageID)->removeNode(axID);
+    if (auto pageID = m_document.pageID()) {
+        if (auto tree = AXIsolatedTree::treeForPageID(*pageID))
+            tree->removeNode(axID);
+    }
 #endif
 
     ASSERT(m_objects.size() >= m_idsInUse.size());
@@ -2946,6 +2948,7 @@ Ref<AXIsolatedTreeNode> AXObjectCache::createIsolatedAccessibilityTreeHierarchy(
     auto isolatedTreeNode = AXIsolatedTreeNode::create(object);
     nodeChanges.append(isolatedTreeNode.copyRef());
 
+    isolatedTreeNode->setTreeIdentifier(tree.treeIdentifier());
     isolatedTreeNode->setParent(parentID);
     associateIsolatedTreeNode(object, isolatedTreeNode, tree.treeIdentifier());
 
index 0e7d542..586adf0 100644 (file)
@@ -42,9 +42,9 @@ static unsigned newTreeID()
     return ++s_currentTreeID;
 }
 
-HashMap<uint64_t, Ref<AXIsolatedTree>>& AXIsolatedTree::treePageCache()
+HashMap<PageIdentifier, Ref<AXIsolatedTree>>& AXIsolatedTree::treePageCache()
 {
-    static NeverDestroyed<HashMap<uint64_t, Ref<AXIsolatedTree>>> map;
+    static NeverDestroyed<HashMap<PageIdentifier, Ref<AXIsolatedTree>>> map;
     return map;
 }
 
@@ -67,16 +67,6 @@ Ref<AXIsolatedTree> AXIsolatedTree::create()
     return adoptRef(*new AXIsolatedTree());
 }
 
-Ref<AXIsolatedTree> AXIsolatedTree::initializePageTreeForID(PageIdentifier pageID, AXObjectCache& cache)
-{
-    RELEASE_ASSERT(isMainThread());
-    auto tree = cache->generateIsolatedAccessibilityTree();
-    tree->setInitialRequestI\ 1nProgress(true);
-    tree->applyPendingChanges();
-    tree->setInitialRequestInProgress(false);
-    return tree;
-}
-
 RefPtr<AXIsolatedTreeNode> AXIsolatedTree::nodeInTreeForID(AXIsolatedTreeID treeID, AXID axID)
 {
     return treeForID(treeID)->nodeForID(axID);
@@ -109,7 +99,6 @@ RefPtr<AXIsolatedTree> AXIsolatedTree::treeForPageID(PageIdentifier pageID)
 
 RefPtr<AXIsolatedTreeNode> AXIsolatedTree::nodeForID(AXID axID) const
 {
-    RELEASE_ASSERT(!isMainThread() || initialRequest);
     if (!axID)
         return nullptr;
     return m_readerThreadNodeMap.get(axID);
@@ -150,14 +139,9 @@ void AXIsolatedTree::appendNodeChanges(Vector<Ref<AXIsolatedTreeNode>>& log)
         m_pendingAppends.append(node.copyRef());
 }
 
-void AXIsolatedTree::setInitialRequestInProgress(bool initialRequestInProgress)
-{
-    m_initialRequestInProgress = initialRequestInProgress;
-}
-
 void AXIsolatedTree::applyPendingChanges()
 {
-    RELEASE_ASSERT(!isMainThread() || initialRequest);
+    RELEASE_ASSERT(!isMainThread());
     LockHolder locker { m_changeLogLock };
     Vector<Ref<AXIsolatedTreeNode>> appendCopy;
     std::swap(appendCopy, m_pendingAppends);
@@ -169,10 +153,8 @@ void AXIsolatedTree::applyPendingChanges()
     m_rootNodeID = m_pendingRootNodeID;
     m_focusedNodeID = m_pendingFocusedNodeID;
     
-    for (auto& item : appendCopy) {
-        item->setTreeIdentifier(m_treeID);
+    for (auto& item : appendCopy)
         m_readerThreadNodeMap.add(item->identifier(), WTFMove(item));
-    }
 
     for (auto item : removeCopy)
         m_readerThreadNodeMap.remove(item);
index 6eec264..6abd783 100644 (file)
@@ -37,15 +37,14 @@ namespace WebCore {
 
 class Page;
 
-class AXIsolatedTree : public ThreadSafeRefCounted<AXIsolatedTree>, public CanMakeWeakPtr<AXIsolatedTree> {
+class AXIsolatedTree : public ThreadSafeRefCounted<AXIsolatedTree> {
     WTF_MAKE_NONCOPYABLE(AXIsolatedTree); WTF_MAKE_FAST_ALLOCATED;
 
 public:
     static Ref<AXIsolatedTree> create();
     virtual ~AXIsolatedTree();
 
-    static Ref<AXIsolatedTree> createTreeForPageID(PageIdentifier);
-    WEBCORE_EXPORT static Ref<AXIsolatedTree> initializePageTreeForID(PageIdentifier, AXObjectCache&);
+    WEBCORE_EXPORT static Ref<AXIsolatedTree> createTreeForPageID(PageIdentifier);
     WEBCORE_EXPORT static RefPtr<AXIsolatedTree> treeForPageID(PageIdentifier);
     WEBCORE_EXPORT static RefPtr<AXIsolatedTree> treeForID(AXIsolatedTreeID);
 
@@ -64,7 +63,6 @@ public:
     // Call on AX thread
     WEBCORE_EXPORT void applyPendingChanges();
 
-    WEBCORE_EXPORT void setInitialRequestInProgress(bool);
     AXIsolatedTreeID treeIdentifier() const { return m_treeID; }
 
 private:
@@ -86,7 +84,6 @@ private:
     AXIsolatedTreeID m_treeID;
     AXID m_rootNodeID { InvalidAXID };
     AXID m_focusedNodeID { InvalidAXID };
-    bool m_initialRequestInProgress;
 };
 
 } // namespace WebCore
index e2ef412..d8dbb9f 100644 (file)
@@ -95,7 +95,7 @@ void AXIsolatedTreeNode::setTreeIdentifier(AXIsolatedTreeID treeIdentifier)
 {
     m_treeIdentifier = treeIdentifier;
     if (auto tree = AXIsolatedTree::treeForID(m_treeIdentifier))
-        m_cachedTree = makeWeakPtr(tree.get());
+        m_cachedTree = tree;
 }
 
 AccessibilityObjectInterface* AXIsolatedTreeNode::focusedUIElement() const
@@ -132,7 +132,7 @@ FloatRect AXIsolatedTreeNode::rectAttributeValue(AXPropertyName propertyName) co
 {
     auto value = m_attributeMap.get(propertyName);
     return WTF::switchOn(value,
-        [&zeroRect] (Optional<FloatRect> typedValue) {
+        [&] (Optional<FloatRect> typedValue) {
             if (!typedValue)
                 return FloatRect { };
             return typedValue.value();
index 4374535..934d63f 100644 (file)
@@ -45,7 +45,7 @@ namespace WebCore {
 class AXIsolatedTree;
 class AccessibilityObject;
 
-class AXIsolatedTreeNode final : public AccessibilityObjectInterface, public ThreadSafeRefCounted<AXIsolatedTreeNode>, public CanMakeWeakPtr<AXIsolatedTreeNode> {
+class AXIsolatedTreeNode final : public AccessibilityObjectInterface, public ThreadSafeRefCounted<AXIsolatedTreeNode> {
 
 public:
     enum class AXPropertyName : uint8_t {
@@ -131,7 +131,7 @@ private:
     AXID m_identifier;
     bool m_initialized { false };
     AXIsolatedTreeID m_treeIdentifier;
-    WeakPtr<AXIsolatedTree> m_cachedTree;
+    RefPtr<AXIsolatedTree> m_cachedTree;
     Vector<AXID> m_children;
 
 #if PLATFORM(COCOA)
index b53b4ae..daf34f1 100644 (file)
@@ -280,7 +280,7 @@ NSArray *convertToNSArray(const Vector<RefPtr<WebCore::AXIsolatedTreeNode>>& chi
 {
     NSMutableArray *result = [[NSMutableArray alloc] initWithCapacity:children.size()];
     for (auto& child : children)
-        addChildToArray(*child, result)
+        addChildToArray(*child, result);
     return [result autorelease];
 }
 #endif
index cb222b4..0150fca 100644 (file)
@@ -2023,7 +2023,7 @@ static void WebTransformCGPathToNSBezierPath(void* info, const CGPathElement *el
         children.reserveInitialCapacity(nodeChildren.size());
         auto tree = treeNode->tree();
         for (auto childID : nodeChildren)
-            children.uncheckedAppend(tree->nodeForID(child));
+            children.uncheckedAppend(tree->nodeForID(childID));
         return convertToNSArray(children);
     }
 #endif
index f12aee0..1d34944 100644 (file)
@@ -1,3 +1,14 @@
+2019-10-12  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Make AXIsolatedTree compile again
+        https://bugs.webkit.org/show_bug.cgi?id=202702
+        <rdar://problem/56084968>
+
+        Reviewed by Joanmarie Diggs.
+
+        * WebProcess/WebPage/mac/WKAccessibilityWebPageObjectBase.mm:
+        (-[WKAccessibilityWebPageObjectBase isolatedTreeRootObject]):
+
 2019-10-11  Rob Buis  <rbuis@igalia.com>
 
         Cleanup RuntimeEnabledFeatures includes
index 6f28f77..60da40c 100644 (file)
@@ -33,7 +33,7 @@ FRAMEWORK_SEARCH_PATHS_base = "$(UMBRELLA_FRAMEWORKS_DIR)"
 FRAMEWORK_SEARCH_PATHS = $(FRAMEWORK_SEARCH_PATHS_base);
 FRAMEWORK_SEARCH_PATHS[sdk=iphone*] = $(FRAMEWORK_SEARCH_PATHS_base) $(WK_PRIVATE_FRAMEWORKS_DIR);
 
-SYSTEM_FRAMEWORK_SEARCH_PATHS = $(inherited) $(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks $(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks;
+SYSTEM_FRAMEWORK_SEARCH_PATHS = $(inherited) $(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks $(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks $(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks/ApplicationServices.framework/Versions/A/Frameworks;
 
 GCC_PREFIX_HEADER = WebKit2Prefix.h;
 GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) $(FEATURE_DEFINES) $(WK_CORE_PREDICTION_DEFINES) U_HIDE_DEPRECATED_API U_DISABLE_RENAMING=1 U_SHOW_CPLUSPLUS_API=0 FRAMEWORK_NAME=WebKit;
index 4273db5..d0d5657 100644 (file)
@@ -26,6 +26,7 @@
 #import "config.h"
 #import "WKAccessibilityWebPageObjectBase.h"
 
+#import "AccessibilityPrivSPI.h"
 #import "WebFrame.h"
 #import "WebPage.h"
 #import "WKArray.h"
@@ -96,7 +97,7 @@
 {
     if (isMainThread()) {
         if (auto cache = [self axObjectCache]) {
-            auto tree = AXIsolatedTree::initializeTreeForPageId(m_pageID, *cache);
+            auto tree = cache->generateIsolatedAccessibilityTree();
 
             // Now that we have created our tree, initialize the secondary thread,
             // so future requests come in on the other thread.
                 return rootNode->wrapper();
         }
     } else {
-        auto tree = AXIsolatedTree::treeForPageID(m_pageID);
+        auto tree = WebCore::AXIsolatedTree::treeForPageID(m_pageID);
         tree->applyPendingChanges();
         if (auto rootNode = tree->rootNode())
             return rootNode->wrapper();