Skip to content

Commit

Permalink
AX: Remove AXObjectCache::usedOnAXThread().
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=256552
<rdar://problem/109118496>

Reviewed by Darin Adler.

This was used to run ITM as a cache on the main thread as opposed to on the AX thread. It was useful in the early stage of the ITM project, but no longer used. Now if ITM is on, it will use the secondary AX thread. So this patch removes this unused code path and simplifies the code.

* Source/WebCore/accessibility/AXObjectCache.h:
* Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp:
(WebCore::AXIsolatedTree::AXIsolatedTree):
(WebCore::AXIsolatedTree::objectForID const):
(WebCore::AXIsolatedTree::applyPendingChanges):
* Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h:
* Source/WebCore/accessibility/mac/AXObjectCacheMac.mm:
(WebCore::AXObjectCache::initializeSecondaryAXThread):
(WebCore::AXObjectCache::usedOnAXThread): Deleted.
* Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp:
(WKAccessibilityCanUseSecondaryAXThread): Deleted.
* Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePagePrivate.h:
* Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.cpp:
(WTR::AccessibilityController::executeOnAXThreadAndWait):
(WTR::AccessibilityController::executeOnAXThread):
* Tools/WebKitTestRunner/InjectedBundle/AccessibilityController.h:
* Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityControllerMac.mm:
(WTR::AccessibilityController::updateIsolatedTreeMode):

Canonical link: https://commits.webkit.org/266660@main
  • Loading branch information
AndresGonzalezApple committed Aug 7, 2023
1 parent 41847fe commit 3e01a64
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 58 deletions.
1 change: 0 additions & 1 deletion Source/WebCore/accessibility/AXObjectCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@ class AXObjectCache : public CanMakeWeakPtr<AXObjectCache>, public CanMakeChecke
void scheduleObjectRegionsUpdate(bool scheduleImmediately = false) { m_geometryManager->scheduleObjectRegionsUpdate(scheduleImmediately); }
void willUpdateObjectRegions() { m_geometryManager->willUpdateObjectRegions(); }
WEBCORE_EXPORT static bool isIsolatedTreeEnabled();
WEBCORE_EXPORT static bool usedOnAXThread();
private:
static bool clientSupportsIsolatedTree();
static bool isTestClient();
Expand Down
16 changes: 8 additions & 8 deletions Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ AXIsolatedTree::AXIsolatedTree(AXObjectCache& axObjectCache)
, m_axObjectCache(&axObjectCache)
, m_pageActivityState(axObjectCache.pageActivityState())
, m_geometryManager(axObjectCache.m_geometryManager.ptr())
, m_usedOnAXThread(axObjectCache.usedOnAXThread())
{
AXTRACE("AXIsolatedTree::AXIsolatedTree"_s);
ASSERT(isMainThread());
Expand Down Expand Up @@ -171,11 +170,11 @@ RefPtr<AXIsolatedTree> AXIsolatedTree::treeForPageID(PageIdentifier pageID)

RefPtr<AXIsolatedObject> AXIsolatedTree::objectForID(const AXID axID) const
{
// In isolated tree mode 2, only access m_readerThreadNodeMap on the AX thread.
ASSERT(m_usedOnAXThread ? !isMainThread() : isMainThread());
if (m_usedOnAXThread && isMainThread())
// In isolated tree mode, only access m_readerThreadNodeMap on the AX thread.
if (isMainThread()) {
ASSERT_NOT_REACHED();
return nullptr;

}
return axID.isValid() ? m_readerThreadNodeMap.get(axID) : nullptr;
}

Expand Down Expand Up @@ -904,10 +903,11 @@ void AXIsolatedTree::applyPendingChanges()
{
AXTRACE("AXIsolatedTree::applyPendingChanges"_s);

// In isolated tree mode 2, only apply pending changes on the AX thread.
ASSERT(m_usedOnAXThread ? !isMainThread() : isMainThread());
if (m_usedOnAXThread && isMainThread())
// In isolated tree mode, only apply pending changes on the AX thread.
if (isMainThread()) {
ASSERT_NOT_REACHED();
return;
}

Locker locker { m_changeLogLock };

Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ class AXIsolatedTree : public ThreadSafeRefCountedAndCanMakeThreadSafeWeakPtr<AX
WeakPtr<AXObjectCache> m_axObjectCache;
OptionSet<ActivityState> m_pageActivityState;
RefPtr<AXGeometryManager> m_geometryManager;
bool m_usedOnAXThread { true };

// Stores the parent ID and children IDS for a given IsolatedObject.
struct ParentChildrenIDs {
Expand Down
7 changes: 0 additions & 7 deletions Source/WebCore/accessibility/mac/AXObjectCacheMac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -720,13 +720,6 @@ static bool isTestAXClientType(AXClientType client)
if (_AXSIsolatedTreeModeFunctionIsAvailable() && _AXSIsolatedTreeMode_Soft() == AXSIsolatedTreeModeSecondaryThread)
_AXUIElementUseSecondaryAXThread(true);
}

bool AXObjectCache::usedOnAXThread()
{
ASSERT(isIsolatedTreeEnabled());
return _AXSIsolatedTreeModeFunctionIsAvailable()
&& _AXSIsolatedTreeMode_Soft() == AXSIsolatedTreeModeSecondaryThread;
}
#endif // ENABLE(ACCESSIBILITY_ISOLATED_TREE)

bool AXObjectCache::shouldSpellCheck()
Expand Down
31 changes: 0 additions & 31 deletions Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,37 +308,6 @@ void* WKAccessibilityFocusedUIElement()
#endif
}

bool WKAccessibilityCanUseSecondaryAXThread(WKBundlePageRef pageRef)
{
#if ENABLE(ACCESSIBILITY) && ENABLE(ACCESSIBILITY_ISOLATED_TREE)
if (!pageRef)
return false;

WebCore::Page* page = WebKit::toImpl(pageRef)->corePage();
if (!page)
return false;

auto* localMainFrame = dynamicDowncast<WebCore::LocalFrame>(page->mainFrame());
if (!localMainFrame)
return false;

auto& core = *localMainFrame;
if (!core.document())
return false;

WebCore::AXObjectCache::enableAccessibility();

auto* axObjectCache = core.document()->axObjectCache();
if (!axObjectCache)
return false;

return axObjectCache->usedOnAXThread();
#else
UNUSED_PARAM(pageRef);
return false;
#endif
}

void WKAccessibilitySetForceDeferredSpellChecking(bool shouldForce)
{
WebCore::AXObjectCache::setForceDeferredSpellChecking(shouldForce);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ WK_EXPORT bool WKBundlePageCanShowMIMEType(WKBundlePageRef, WKStringRef mimeType
WK_EXPORT void* WKAccessibilityRootObject(WKBundlePageRef);
WK_EXPORT void* WKAccessibilityFocusedObject(WKBundlePageRef);
WK_EXPORT void* WKAccessibilityFocusedUIElement();
WK_EXPORT bool WKAccessibilityCanUseSecondaryAXThread(WKBundlePageRef);
WK_EXPORT void WKAccessibilityTestingInjectPreference(WKBundlePageRef, WKStringRef domain, WKStringRef key, WKStringRef encodedValue);

WK_EXPORT void WKAccessibilitySetForceDeferredSpellChecking(bool);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Ref<AccessibilityUIElement> AccessibilityController::rootElement()
void AccessibilityController::executeOnAXThreadAndWait(Function<void()>&& function)
{
#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
if (m_useMockAXThread) {
if (m_accessibilityIsolatedTreeMode) {
std::atomic<bool> complete = false;
AXThread::dispatch([&function, &complete] {
function();
Expand All @@ -128,7 +128,7 @@ void AccessibilityController::executeOnAXThreadAndWait(Function<void()>&& functi
void AccessibilityController::executeOnAXThread(Function<void()>&& function)
{
#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
if (m_useMockAXThread) {
if (m_accessibilityIsolatedTreeMode) {
AXThread::dispatch([function = WTFMove(function)] {
function();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,8 @@ class AccessibilityController : public JSWrappable {

#if PLATFORM(COCOA)
void spinMainRunLoop() const;
// _AXUIElementUseSecondaryAXThread and _AXUIElementRequestServicedBySecondaryAXThread
// do not work for WebKitTestRunner since this is calling directly into
// WebCore/accessibility via JavaScript without going through HIServices.
// Thus to simulate the behavior of HIServices, AccessibilityController is spawning a secondary thread to service the JavaScript requests.
bool m_useMockAXThread { false };
#endif

bool m_accessibilityIsolatedTreeMode { false };
#endif
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,9 @@ static id findAccessibleObjectById(id obj, NSString *idAttribute)
#if ENABLE(ACCESSIBILITY_ISOLATED_TREE)
void AccessibilityController::updateIsolatedTreeMode()
{
// Override to set identifier to VoiceOver so that requests are handled in isolated mode.
// Override the client identifier to be kAXClientTypeWebKitTesting which is treated the same as the VoiceOver identifier, and thus requests are handled in isolated tree mode.
_AXSetClientIdentificationOverride(m_accessibilityIsolatedTreeMode ? (AXClientType)kAXClientTypeWebKitTesting : kAXClientTypeNoActiveRequestFound);
_AXSSetIsolatedTreeMode(m_accessibilityIsolatedTreeMode ? AXSIsolatedTreeModeSecondaryThread : AXSIsolatedTreeModeOff);
m_useMockAXThread = WKAccessibilityCanUseSecondaryAXThread(InjectedBundle::singleton().page()->page());
}
#endif

Expand Down

0 comments on commit 3e01a64

Please sign in to comment.