From 18aeb0e661445201b72923ce20216bc52033b2a3 Mon Sep 17 00:00:00 2001 From: Joshua Hoffman Date: Tue, 8 Oct 2024 07:23:07 -0700 Subject: [PATCH] AX: Move accessibilityThreadTextApisEnabled to DeprecatedGlobalSettings https://bugs.webkit.org/show_bug.cgi?id=281031 rdar://137469268 Reviewed by Tyler Wilcock. `accessibilityThreadTextApis` tracks global state. Currently, we store this in the Document's settings, but we can't guarantee the value is the same across different documents. Instead, let's move it to `DeprecatedGlobalSettings`, and store/access it on the secondary thread using the existing `gAccessibiltiyThreadTextApisEnabled` atomic bool. This patch also includes a drive-by build fix for the new `nextUnignoredSiblingOrParent` when `ENABLE_AX_THREAD_TEXT_APIS` is enabled. These calls were missing the `shouldUpdateChildren` parameter, which should be true to match the previous behavior. * Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml: * Source/WebCore/accessibility/AXCoreObject.cpp: (WebCore::AXCoreObject::nextUnignoredSiblingOrParent const): * Source/WebCore/accessibility/AXCoreObject.h: * Source/WebCore/accessibility/AXObjectCache.cpp: (WebCore::AXObjectCache::AXObjectCache): * Source/WebCore/page/DeprecatedGlobalSettings.h: (WebCore::DeprecatedGlobalSettings::setAccessibilityThreadTextApisEnabled): (WebCore::DeprecatedGlobalSettings::accessibilityThreadTextApisEnabled): Canonical link: https://commits.webkit.org/284827@main --- .../WTF/Scripts/Preferences/UnifiedWebPreferences.yaml | 2 ++ Source/WebCore/accessibility/AXCoreObject.cpp | 4 ++-- Source/WebCore/accessibility/AXCoreObject.h | 2 +- Source/WebCore/accessibility/AXObjectCache.cpp | 3 ++- Source/WebCore/page/DeprecatedGlobalSettings.h | 9 +++++++++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml b/Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml index e2424c894dd40..bc0cb85117db7 100644 --- a/Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml +++ b/Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml @@ -188,6 +188,8 @@ AccessibilityThreadTextApisEnabled: status: embedder humanReadableName: "Off Main-Thread Accessibility Text APIs" humanReadableDescription: "Serve accessibility text APIs off the main-thread" + webcoreBinding: DeprecatedGlobalSettings + condition: ENABLE(AX_THREAD_TEXT_APIS) defaultValue: WebKitLegacy: default: false diff --git a/Source/WebCore/accessibility/AXCoreObject.cpp b/Source/WebCore/accessibility/AXCoreObject.cpp index 8e4f3402b8b83..ab5f22c0b6774 100644 --- a/Source/WebCore/accessibility/AXCoreObject.cpp +++ b/Source/WebCore/accessibility/AXCoreObject.cpp @@ -209,10 +209,10 @@ AXCoreObject* AXCoreObject::nextUnignoredSibling(bool updateChildrenIfNeeded, AX return indexOfThis + 1 < siblings.size() ? siblings[indexOfThis + 1].get() : nullptr; } -AXCoreObject* AXCoreObject::nextUnignoredSiblingOrParent(bool updateChildrenIfNeeded) const +AXCoreObject* AXCoreObject::nextUnignoredSiblingOrParent() const { RefPtr parent = parentObjectUnignored(); - if (auto* nextSibling = nextUnignoredSibling(updateChildrenIfNeeded, parent.get())) + if (auto* nextSibling = nextUnignoredSibling(/* updateChildrenIfNeeded */ true, parent.get())) return nextSibling; return parent.get(); } diff --git a/Source/WebCore/accessibility/AXCoreObject.h b/Source/WebCore/accessibility/AXCoreObject.h index 1703a3b2fb794..95f733f5de4d3 100644 --- a/Source/WebCore/accessibility/AXCoreObject.h +++ b/Source/WebCore/accessibility/AXCoreObject.h @@ -1217,7 +1217,7 @@ class AXCoreObject : public ThreadSafeRefCountedAndCanMakeThreadSafeWeakPtrisMainFrame()) - gAccessibilityThreadTextApisEnabled = document.settings().accessibilityThreadTextApisEnabled(); + gAccessibilityThreadTextApisEnabled = DeprecatedGlobalSettings::accessibilityThreadTextApisEnabled(); #endif // If loading completed before the cache was created, loading progress will have been reset to zero. diff --git a/Source/WebCore/page/DeprecatedGlobalSettings.h b/Source/WebCore/page/DeprecatedGlobalSettings.h index 378cc84b3c96b..858a18d1aa0d9 100644 --- a/Source/WebCore/page/DeprecatedGlobalSettings.h +++ b/Source/WebCore/page/DeprecatedGlobalSettings.h @@ -108,6 +108,11 @@ class DeprecatedGlobalSettings { static bool isAccessibilityIsolatedTreeEnabled() { return shared().m_accessibilityIsolatedTree; } #endif +#if ENABLE(AX_THREAD_TEXT_APIS) + static void setAccessibilityThreadTextApisEnabled(bool isEnabled) { shared().m_accessibilityThreadTextApis = isEnabled; } + static bool accessibilityThreadTextApisEnabled() { return shared().m_accessibilityThreadTextApis; } +#endif + static void setArePDFImagesEnabled(bool isEnabled) { shared().m_arePDFImagesEnabled = isEnabled; } static bool arePDFImagesEnabled() { return shared().m_arePDFImagesEnabled; } @@ -186,6 +191,10 @@ class DeprecatedGlobalSettings { bool m_accessibilityIsolatedTree { false }; #endif +#if ENABLE(AX_THREAD_TEXT_APIS) + bool m_accessibilityThreadTextApis { false }; +#endif + bool m_arePDFImagesEnabled { true }; #if ENABLE(MEDIA_SOURCE)