Run LayoutTests/accessibility/mac/primary-screen-height.html on secondary accessibili...
authorandresg_22@apple.com <andresg_22@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 23 Nov 2019 16:16:33 +0000 (16:16 +0000)
committerandresg_22@apple.com <andresg_22@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 23 Nov 2019 16:16:33 +0000 (16:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=204391

Reviewed by Chris Fleizach.

Source/WebCore:

LayoutTests/accessibility/mac/primary-screen-height.html tests this
change when isolated tree is enabled.

Use ASSERT(!isMainThread()) instead of HIServices call to detect
whether not running in the secondary thread during LayoutTests.

* accessibility/isolatedtree/AXIsolatedTreeNode.cpp:
(WebCore::AXIsolatedObject::children):
(WebCore::AXIsolatedObject::updateBackingStore):

Tools:

Added AccessibilityController::execute to execute any
AccessibilityUIElement call into AccessibilityObjectWrapper on the
secondary accessibility thread.

* WebKitTestRunner/InjectedBundle/AccessibilityController.cpp:
(WTR::AccessibilityController::rootElement): leftover from previous review.
(WTR::AccessibilityController::execute): added this to execute any AccessibilityUIElement method on the appropriate thread.
* WebKitTestRunner/InjectedBundle/AccessibilityController.h:
* WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
(WTR::AccessibilityUIElement::getChildrenWithRange): Runs on secondary thread.
(WTR::AccessibilityUIElement::numberAttributeValue): Runs on secondary thread.

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

Source/WebCore/ChangeLog
Source/WebCore/accessibility/isolatedtree/AXIsolatedTreeNode.cpp
Tools/ChangeLog
Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.cpp
Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.h
Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm

index dec3daa..a66107f 100644 (file)
@@ -1,3 +1,20 @@
+2019-11-23  Andres Gonzalez  <andresg_22@apple.com>
+
+        Run LayoutTests/accessibility/mac/primary-screen-height.html on secondary accessibility thread.
+        https://bugs.webkit.org/show_bug.cgi?id=204391
+
+        Reviewed by Chris Fleizach.
+
+        LayoutTests/accessibility/mac/primary-screen-height.html tests this
+        change when isolated tree is enabled.
+
+        Use ASSERT(!isMainThread()) instead of HIServices call to detect
+        whether not running in the secondary thread during LayoutTests.
+
+        * accessibility/isolatedtree/AXIsolatedTreeNode.cpp:
+        (WebCore::AXIsolatedObject::children):
+        (WebCore::AXIsolatedObject::updateBackingStore):
+
 2019-11-23  Zalan Bujtas  <zalan@apple.com>
 
         [LFC][IFC] Remove unnecessary Line::hasContent() calls in LineLayout::placeInlineItem
index a8b3d1a..8704f94 100644 (file)
@@ -30,8 +30,6 @@
 
 #include "AccessibilityObject.h"
 
-extern "C" bool _AXUIElementRequestServicedBySecondaryAXThread(void);
-
 namespace WebCore {
 
 AXIsolatedObject::AXIsolatedObject(AXCoreObject& object)
@@ -171,7 +169,8 @@ void AXIsolatedObject::setTreeIdentifier(AXIsolatedTreeID treeIdentifier)
 
 const AXCoreObject::AccessibilityChildrenVector& AXIsolatedObject::children(bool)
 {
-    if (_AXUIElementRequestServicedBySecondaryAXThread()) {
+    ASSERT(!isMainThread());
+    if (!isMainThread()) {
         m_children.clear();
         m_children.reserveInitialCapacity(m_childrenIDs.size());
         auto tree = this->tree();
@@ -279,8 +278,8 @@ int AXIsolatedObject::intAttributeValue(AXPropertyName propertyName) const
 
 void AXIsolatedObject::updateBackingStore()
 {
-    if (_AXUIElementRequestServicedBySecondaryAXThread()) {
-        RELEASE_ASSERT(!isMainThread());
+    ASSERT(!isMainThread());
+    if (!isMainThread()) {
         if (auto tree = this->tree())
             tree->applyPendingChanges();
     }
index 280cb50..d0347bb 100644 (file)
@@ -1,3 +1,22 @@
+2019-11-23  Andres Gonzalez  <andresg_22@apple.com>
+
+        Run LayoutTests/accessibility/mac/primary-screen-height.html on secondary accessibility thread.
+        https://bugs.webkit.org/show_bug.cgi?id=204391
+
+        Reviewed by Chris Fleizach.
+
+        Added AccessibilityController::execute to execute any
+        AccessibilityUIElement call into AccessibilityObjectWrapper on the
+        secondary accessibility thread.
+
+        * WebKitTestRunner/InjectedBundle/AccessibilityController.cpp:
+        (WTR::AccessibilityController::rootElement): leftover from previous review.
+        (WTR::AccessibilityController::execute): added this to execute any AccessibilityUIElement method on the appropriate thread.
+        * WebKitTestRunner/InjectedBundle/AccessibilityController.h:
+        * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
+        (WTR::AccessibilityUIElement::getChildrenWithRange): Runs on secondary thread.
+        (WTR::AccessibilityUIElement::numberAttributeValue): Runs on secondary thread.
+
 2019-11-22  Per Arne Vollan  <pvollan@apple.com>
 
         Set 64-bit as default architecture on Windows
index 236bcab..160a2e0 100644 (file)
@@ -88,10 +88,9 @@ Ref<AccessibilityUIElement> AccessibilityController::rootElement()
     } else {
         root = static_cast<PlatformUIElement>(WKAccessibilityRootObject(page));
 
-        if (WKAccessibilityCanUseSecondaryAXThread(page)) {
-            // Set m_useAXThread to true for next request.
+        // Set m_useAXThread to true for next request.
+        if (WKAccessibilityCanUseSecondaryAXThread(page))
             m_useAXThread = true;
-        }
     }
 
     return AccessibilityUIElement::create(root);
@@ -104,6 +103,19 @@ Ref<AccessibilityUIElement> AccessibilityController::focusedElement()
     
     return AccessibilityUIElement::create(static_cast<PlatformUIElement>(root));    
 }
+
+void AccessibilityController::execute(Function<void()>&& function)
+{
+    if (m_useAXThread) {
+        AXThread::dispatch([&function, this] {
+            function();
+            m_semaphore.signal();
+        });
+
+        m_semaphore.wait();
+    } else
+        function();
+}
 #endif
 
 RefPtr<AccessibilityUIElement> AccessibilityController::elementAtPoint(int x, int y)
index 4f61ebd..f8df3c8 100644 (file)
@@ -62,6 +62,10 @@ public:
     RefPtr<AccessibilityUIElement> elementAtPoint(int x, int y);
     RefPtr<AccessibilityUIElement> accessibleElementById(JSStringRef idAttribute);
 
+#if PLATFORM(COCOA)
+    void execute(Function<void()>&&);
+#endif
+
     bool addNotificationListener(JSValueRef functionCallback);
     bool removeNotificationListener();
 
index 0abad26..c569f68 100644 (file)
@@ -370,8 +370,11 @@ void AccessibilityUIElement::getChildren(Vector<RefPtr<AccessibilityUIElement> >
 void AccessibilityUIElement::getChildrenWithRange(Vector<RefPtr<AccessibilityUIElement> >& elementVector, unsigned location, unsigned length)
 {
     BEGIN_AX_OBJC_EXCEPTIONS
-    NSArray* children = [m_element accessibilityArrayAttributeValues:NSAccessibilityChildrenAttribute index:location maxCount:length];
-    elementVector = convertNSArrayToVector<RefPtr<AccessibilityUIElement>>(children);
+    auto accessibilityController = InjectedBundle::singleton().accessibilityController();
+    accessibilityController->execute([&elementVector, location, length, this] {
+        NSArray* children = [m_element accessibilityArrayAttributeValues:NSAccessibilityChildrenAttribute index:location maxCount:length];
+        elementVector = convertNSArrayToVector<RefPtr<AccessibilityUIElement>>(children);
+    });
     END_AX_OBJC_EXCEPTIONS
 }
 
@@ -634,11 +637,17 @@ JSRetainPtr<JSStringRef> AccessibilityUIElement::stringAttributeValue(JSStringRe
 double AccessibilityUIElement::numberAttributeValue(JSStringRef attribute)
 {
     BEGIN_AX_OBJC_EXCEPTIONS
-    id value = [m_element accessibilityAttributeValue:[NSString stringWithJSStringRef:attribute]];
+    id value;
+
+    auto accessibilityController = InjectedBundle::singleton().accessibilityController();
+    accessibilityController->execute([&attribute, &value, this] {
+        value = [m_element accessibilityAttributeValue:[NSString stringWithJSStringRef:attribute]];
+    });
+
     if ([value isKindOfClass:[NSNumber class]])
         return [value doubleValue];
     END_AX_OBJC_EXCEPTIONS
-    
+
     return 0;
 }