Implementation of AccessibilitySupport AXSIsolatedTreeMode.
authorandresg_22@apple.com <andresg_22@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Mar 2020 02:06:27 +0000 (02:06 +0000)
committerandresg_22@apple.com <andresg_22@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 7 Mar 2020 02:06:27 +0000 (02:06 +0000)
https://bugs.webkit.org/show_bug.cgi?id=208691

Reviewed by Chris Fleizach.

Source/WebCore:

Support for the AccessibilitySupport AXIsolatedTreMode accessibility setting.

* accessibility/AXObjectCache.cpp:
(WebCore::AXObjectCache::isolatedTreeFocusedObject):
(WebCore::AXObjectCache::focusedUIElementForPage):
(WebCore::AXObjectCache::isIsolatedTreeEnabled):
(WebCore::AXObjectCache::rootObject):
(WebCore::AXObjectCache::isolatedTreeRootObject):
(WebCore::AXObjectCache::canUseSecondaryAXThread):
* accessibility/AXObjectCache.h:
* accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
(-[WebAccessibilityObjectWrapperBase detach]):
(-[WebAccessibilityObjectWrapperBase axBackingObject]):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper additionalAccessibilityAttributeNames]):

Source/WebCore/PAL:

* pal/spi/cocoa/AccessibilitySupportSPI.h:
Added constants and prototypes used in AXIsolatedTreeMode support.

Source/WebKit:

* WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm:
(-[WKAccessibilityWebPageObject accessibilityHitTest:]):
Honors AXIsolatedTreeMode setting.

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

12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/PAL/ChangeLog
Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj
Source/WebCore/PAL/pal/PlatformMac.cmake
Source/WebCore/PAL/pal/spi/cocoa/AccessibilitySupportSPI.h [new file with mode: 0644]
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/accessibility/AXObjectCache.cpp
Source/WebCore/accessibility/AXObjectCache.h
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm

index 5dc656f..e625fd0 100644 (file)
@@ -1,3 +1,26 @@
+2020-03-06  Andres Gonzalez  <andresg_22@apple.com>
+
+        Implementation of AccessibilitySupport AXSIsolatedTreeMode.
+        https://bugs.webkit.org/show_bug.cgi?id=208691
+
+        Reviewed by Chris Fleizach.
+
+        Support for the AccessibilitySupport AXIsolatedTreMode accessibility setting.
+
+        * accessibility/AXObjectCache.cpp:
+        (WebCore::AXObjectCache::isolatedTreeFocusedObject):
+        (WebCore::AXObjectCache::focusedUIElementForPage):
+        (WebCore::AXObjectCache::isIsolatedTreeEnabled):
+        (WebCore::AXObjectCache::rootObject):
+        (WebCore::AXObjectCache::isolatedTreeRootObject):
+        (WebCore::AXObjectCache::canUseSecondaryAXThread):
+        * accessibility/AXObjectCache.h:
+        * accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
+        (-[WebAccessibilityObjectWrapperBase detach]):
+        (-[WebAccessibilityObjectWrapperBase axBackingObject]):
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper additionalAccessibilityAttributeNames]):
+
 2020-03-06  Simon Fraser  <simon.fraser@apple.com>
 
         Hit-test CALayers on the scrolling thread for async frame/overflow scrolling
index 35105f4..bcd015b 100644 (file)
@@ -1,3 +1,13 @@
+2020-03-06  Andres Gonzalez  <andresg_22@apple.com>
+
+        Implementation of AccessibilitySupport AXSIsolatedTreeMode.
+        https://bugs.webkit.org/show_bug.cgi?id=208691
+
+        Reviewed by Chris Fleizach.
+
+        * pal/spi/cocoa/AccessibilitySupportSPI.h:
+        Added constants and prototypes used in AXIsolatedTreeMode support.
+
 2020-03-06  Peng Liu  <peng.liu6@apple.com>
 
         Use the feature flags mechanism to give default feature preference values
index 83fc5f4..183bf24 100644 (file)
                A3AB6E631F3D217F009C14B1 /* SystemSleepListenerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SystemSleepListenerMac.mm; sourceTree = "<group>"; };
                A3C66CDA1F462D6A009E6EE9 /* SessionID.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SessionID.cpp; sourceTree = "<group>"; };
                A3C66CDB1F462D6A009E6EE9 /* SessionID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SessionID.h; sourceTree = "<group>"; };
+               C037494124127CCB00D9A36E /* AccessibilitySupportSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AccessibilitySupportSPI.h; sourceTree = "<group>"; };
                C15CBB3223F34A1200300CC7 /* NSUserDefaultsSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSUserDefaultsSPI.h; sourceTree = "<group>"; };
                C2147A4A1EFD0AA600056FA5 /* CopyPALHeaders.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = CopyPALHeaders.xcconfig; sourceTree = "<group>"; };
                CDACB35E23873E480018D7CE /* MediaToolboxSoftLink.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = MediaToolboxSoftLink.cpp; sourceTree = "<group>"; };
                0C2DA1201F3BE9E700DBC317 /* cocoa */ = {
                        isa = PBXGroup;
                        children = (
+                               C037494124127CCB00D9A36E /* AccessibilitySupportSPI.h */,
                                576CA9D522B854AB0030143C /* AppSSOSPI.h */,
                                2D02E93B2056FAA700A13797 /* AudioToolboxSPI.h */,
                                572A107722B456F500F410C8 /* AuthKitSPI.h */,
index d24aae2..80e8735 100644 (file)
@@ -20,6 +20,7 @@ list(APPEND PAL_PUBLIC_HEADERS
     spi/cg/CoreGraphicsSPI.h
     spi/cg/ImageIOSPI.h
 
+    spi/cocoa/AccessibilitySupportSPI.h
     spi/cocoa/AppSSOSPI.h
     spi/cocoa/AuthKitSPI.h
     spi/cocoa/AVKitSPI.h
diff --git a/Source/WebCore/PAL/pal/spi/cocoa/AccessibilitySupportSPI.h b/Source/WebCore/PAL/pal/spi/cocoa/AccessibilitySupportSPI.h
new file mode 100644 (file)
index 0000000..a0fbe28
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2020 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if HAVE(ACCESSIBILITY_SUPPORT)
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#include <AccessibilitySupport.h>
+
+#else
+
+WTF_EXTERN_C_BEGIN
+
+#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+typedef CF_ENUM(int32_t, AXSIsolatedTreeMode)
+{
+    AXSIsolatedTreeModeOff = 0,
+    AXSIsolatedTreeModeMainThread,
+    AXSIsolatedTreeModeSecondaryThread,
+};
+
+AXSIsolatedTreeMode _AXSIsolatedTreeMode(void);
+#endif // ENABLE(ACCESSIBILITY_ISOLATED_TREE)
+
+WTF_EXTERN_C_END
+
+#endif // USE(APPLE_INTERNAL_SDK)
+
+#endif // HAVE(ACCESSIBILITY_SUPPORT)
index 7d2dde6..62bc069 100644 (file)
                C0C054CB1118C8E400CE2636 /* CodeGenerator.pm in Headers */ = {isa = PBXBuildFile; fileRef = 93F8B3050A300FE100F61AB8 /* CodeGenerator.pm */; settings = {ATTRIBUTES = (Private, ); }; };
                C0C054CC1118C8E400CE2636 /* generate-bindings.pl in Headers */ = {isa = PBXBuildFile; fileRef = 93F8B3070A300FEA00F61AB8 /* generate-bindings.pl */; settings = {ATTRIBUTES = (Private, ); }; };
                C0C054CD1118C8E400CE2636 /* IDLParser.pm in Headers */ = {isa = PBXBuildFile; fileRef = 14813BF309EDF88E00F757E1 /* IDLParser.pm */; settings = {ATTRIBUTES = (Private, ); }; };
+               C0E2F3272412BF29009C73EC /* libAccessibility.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = C0E2F3252412BF29009C73EC /* libAccessibility.tbd */; };
                C0F2A44113869AAB0066C534 /* preprocessor.pm in Headers */ = {isa = PBXBuildFile; fileRef = C0F2A43F13869A280066C534 /* preprocessor.pm */; settings = {ATTRIBUTES = (Private, ); }; };
                C105DA640F3AA6B8001DD44F /* TextEncodingDetector.h in Headers */ = {isa = PBXBuildFile; fileRef = C105DA630F3AA6B8001DD44F /* TextEncodingDetector.h */; };
                C11A9ECE21403A5C00CFB20A /* SwitchingGPUClient.h in Headers */ = {isa = PBXBuildFile; fileRef = C11A9ECD21403A5C00CFB20A /* SwitchingGPUClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
                BEF29EEA1715DD0900C4B4C9 /* VideoTrackPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VideoTrackPrivate.h; sourceTree = "<group>"; };
                C046E1AB1208A9FE00BA2CF7 /* LocalizedStrings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LocalizedStrings.cpp; sourceTree = "<group>"; };
                C078376023DF253E00C9C5C8 /* AXIsolatedObjectMac.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = AXIsolatedObjectMac.mm; path = mac/AXIsolatedObjectMac.mm; sourceTree = "<group>"; };
+               C0E2F3252412BF29009C73EC /* libAccessibility.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libAccessibility.tbd; path = usr/lib/libAccessibility.tbd; sourceTree = SDKROOT; };
                C0F2A43F13869A280066C534 /* preprocessor.pm */ = {isa = PBXFileReference; lastKnownFileType = text.script.perl; name = preprocessor.pm; path = scripts/preprocessor.pm; sourceTree = "<group>"; };
                C105DA610F3AA68F001DD44F /* TextEncodingDetectorICU.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextEncodingDetectorICU.cpp; sourceTree = "<group>"; };
                C105DA630F3AA6B8001DD44F /* TextEncodingDetector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextEncodingDetector.h; sourceTree = "<group>"; };
                                FD2DBF1312B048A300ED98C6 /* AudioToolbox.framework in Frameworks */,
                                1AB33DA512551E320024457A /* IOKit.framework in Frameworks */,
                                93F19B1608245E59001E9ABC /* JavaScriptCore.framework in Frameworks */,
+                               C0E2F3272412BF29009C73EC /* libAccessibility.tbd in Frameworks */,
                                1C022F0022CFED68006DF01B /* libcompression.tbd in Frameworks */,
                                93F19B1708245E59001E9ABC /* libicucore.dylib in Frameworks */,
                                1CFAE3230A6D6A3F0032593D /* libobjc.dylib in Frameworks */,
                                A15E6BF01E212A6A0080AF34 /* Foundation.framework */,
                                1AB33DA412551E320024457A /* IOKit.framework */,
                                F8216299029F4FB501000131 /* JavaScriptCore.framework */,
+                               C0E2F3252412BF29009C73EC /* libAccessibility.tbd */,
                                1C8D26D022C09CDE00D125F3 /* libcompression.tbd */,
                                93F1D31A0558CC5C00821BC0 /* libicucore.dylib */,
                                1CFAE3220A6D6A3F0032593D /* libobjc.dylib */,
index 7aeb9e3..2e08330 100644 (file)
 #include "TextIterator.h"
 
 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE) && PLATFORM(MAC)
+#include <pal/spi/cocoa/AccessibilitySupportSPI.h>
 #include <pal/spi/mac/HIServicesSPI.h>
 #endif
 
@@ -392,7 +393,8 @@ AXCoreObject* AXObjectCache::isolatedTreeFocusedObject(Document& document)
         tree = generateIsolatedTree(*pageID, document);
         // Now that we have created our tree, initialize the secondary thread,
         // so future requests come in on the other thread.
-        _AXUIElementUseSecondaryAXThread(true);
+        if (_AXSIsolatedTreeMode() == AXSIsolatedTreeModeSecondaryThread)
+            _AXUIElementUseSecondaryAXThread(true);
     }
 
     if (tree)
@@ -430,7 +432,7 @@ AXCoreObject* AXObjectCache::focusedUIElementForPage(const Page* page)
     focusedDocument->updateStyleIfNeeded();
 
 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
-    if (clientSupportsIsolatedTree())
+    if (isIsolatedTreeEnabled())
         return isolatedTreeFocusedObject(*focusedDocument);
 #endif
 
@@ -726,6 +728,11 @@ bool AXObjectCache::clientSupportsIsolatedTree()
     return type == kAXClientTypeVoiceOver
         || type == kAXClientTypeUnknown;
 }
+
+bool AXObjectCache::isIsolatedTreeEnabled()
+{
+    return _AXSIsolatedTreeMode() != AXSIsolatedTreeModeOff && clientSupportsIsolatedTree();
+}
 #endif
 
 AXCoreObject* AXObjectCache::rootObject()
@@ -734,7 +741,7 @@ AXCoreObject* AXObjectCache::rootObject()
         return nullptr;
 
 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
-    if (clientSupportsIsolatedTree())
+    if (isIsolatedTreeEnabled())
         return isolatedTreeRootObject();
 #endif
 
@@ -755,7 +762,8 @@ AXCoreObject* AXObjectCache::isolatedTreeRootObject()
 
         // Now that we have created our tree, initialize the secondary thread,
         // so future requests come in on the other thread.
-        _AXUIElementUseSecondaryAXThread(true);
+        if (_AXSIsolatedTreeMode() == AXSIsolatedTreeModeSecondaryThread)
+            _AXUIElementUseSecondaryAXThread(true);
     }
 
     if (tree)
@@ -776,7 +784,7 @@ bool AXObjectCache::canUseSecondaryAXThread()
     // _AXUIElementRequestServicedBySecondaryAXThread returns false for
     // LayoutTests, but we still want to run LayoutTests using isolated tree on
     // a secondary thread to simulate the actual execution.
-    return clientSupportsIsolatedTree();
+    return _AXSIsolatedTreeMode() == AXSIsolatedTreeModeSecondaryThread && clientSupportsIsolatedTree();
 #else
     return false;
 #endif
index 2987eae..76de890 100644 (file)
@@ -352,8 +352,9 @@ public:
     RefPtr<Range> rangeMatchesTextNearRange(RefPtr<Range>, const String&);
 
 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
-    WEBCORE_EXPORT static bool clientSupportsIsolatedTree();
+    WEBCORE_EXPORT static bool isIsolatedTreeEnabled();
 private:
+    static bool clientSupportsIsolatedTree();
     AXCoreObject* isolatedTreeRootObject();
     static AXCoreObject* isolatedTreeFocusedObject(Document&);
     void setIsolatedTreeFocusedObject(Node*);
index 8ce8a0e..1ae6aa9 100644 (file)
@@ -327,7 +327,7 @@ NSArray *convertToNSArray(const WebCore::AXCoreObject::AccessibilityChildrenVect
     _identifier = InvalidAXID;
 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
     if (!isMainThread()) {
-        ASSERT(AXObjectCache::clientSupportsIsolatedTree());
+        ASSERT(AXObjectCache::isIsolatedTreeEnabled());
         [self detachIsolatedObject];
         return;
     }
@@ -366,7 +366,7 @@ NSArray *convertToNSArray(const WebCore::AXCoreObject::AccessibilityChildrenVect
 {
 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
     if (!isMainThread()) {
-        ASSERT(AXObjectCache::clientSupportsIsolatedTree());
+        ASSERT(AXObjectCache::isIsolatedTreeEnabled());
         return m_isolatedObject;
     }
 #endif
index 153e98e..edd3023 100644 (file)
@@ -1477,7 +1477,7 @@ ALLOW_DEPRECATED_IMPLEMENTATIONS_END
         [additional addObject:NSAccessibilityExpandedTextValueAttribute];
 
 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
-    if (_AXUIElementRequestServicedBySecondaryAXThread() && AXObjectCache::clientSupportsIsolatedTree())
+    if (AXObjectCache::isIsolatedTreeEnabled() && _AXUIElementRequestServicedBySecondaryAXThread())
         [additional addObject:NSAccessibilityRelativeFrameAttribute];
 #endif
     
index 9c1f397..58ea193 100644 (file)
@@ -1,3 +1,14 @@
+2020-03-06  Andres Gonzalez  <andresg_22@apple.com>
+
+        Implementation of AccessibilitySupport AXSIsolatedTreeMode.
+        https://bugs.webkit.org/show_bug.cgi?id=208691
+
+        Reviewed by Chris Fleizach.
+
+        * WebProcess/WebPage/mac/WKAccessibilityWebPageObjectMac.mm:
+        (-[WKAccessibilityWebPageObject accessibilityHitTest:]):
+        Honors AXIsolatedTreeMode setting.
+
 2020-03-06  Simon Fraser  <simon.fraser@apple.com>
 
         Hit-test CALayers on the scrolling thread for async frame/overflow scrolling
index 4ec3e45..e8c0bcf 100644 (file)
@@ -253,8 +253,7 @@ ALLOW_DEPRECATED_DECLARATIONS_BEGIN
 
         // Isolated tree frames have the offset encoded into them so we don't need to undo here.
 #if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
-        bool queryingIsolatedTree = WebCore::AXObjectCache::clientSupportsIsolatedTree() && _AXUIElementRequestServicedBySecondaryAXThread();
-        applyContentOffset = !queryingIsolatedTree;
+        applyContentOffset = !WebCore::AXObjectCache::isIsolatedTreeEnabled() || !_AXUIElementRequestServicedBySecondaryAXThread();
 #endif
         if (auto pluginView = WebKit::WebPage::pluginViewForFrame(protectedSelf->m_page->mainFrame()))
             applyContentOffset = !pluginView->plugin()->pluginHandlesContentOffsetForAccessibilityHitTest();