Skip to content

Commit

Permalink
AX: Move accessibilityThreadTextApisEnabled to DeprecatedGlobalSettings
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hoffmanjoshua committed Oct 8, 2024
1 parent 1e32109 commit 18aeb0e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/accessibility/AXCoreObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/accessibility/AXCoreObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,7 @@ class AXCoreObject : public ThreadSafeRefCountedAndCanMakeThreadSafeWeakPtr<AXCo
// In some contexts, we may have already computed the unignored parent for `this`, so take that as an optional
// parameter. If nullptr, we will compute it inside the function.
AXCoreObject* nextUnignoredSibling(bool updateChildrenIfNeeded, AXCoreObject* unignoredParent = nullptr) const;
AXCoreObject* nextUnignoredSiblingOrParent(bool updateChildrenIfNeeded) const;
AXCoreObject* nextUnignoredSiblingOrParent() const;
virtual void detachFromParent() = 0;
virtual bool isDetachedFromParent() = 0;

Expand Down
3 changes: 2 additions & 1 deletion Source/WebCore/accessibility/AXObjectCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
#include "AccessibilityTreeItem.h"
#include "CaretRectComputation.h"
#include "CustomElementDefaultARIA.h"
#include "DeprecatedGlobalSettings.h"
#include "Document.h"
#include "Editing.h"
#include "Editor.h"
Expand Down Expand Up @@ -272,7 +273,7 @@ AXObjectCache::AXObjectCache(Document& document)

#if ENABLE(AX_THREAD_TEXT_APIS)
if (auto* frame = document.frame(); frame && frame->isMainFrame())
gAccessibilityThreadTextApisEnabled = document.settings().accessibilityThreadTextApisEnabled();
gAccessibilityThreadTextApisEnabled = DeprecatedGlobalSettings::accessibilityThreadTextApisEnabled();
#endif

// If loading completed before the cache was created, loading progress will have been reset to zero.
Expand Down
9 changes: 9 additions & 0 deletions Source/WebCore/page/DeprecatedGlobalSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 18aeb0e

Please sign in to comment.