Skip to content

Commit

Permalink
[a11y] Disable the function to enable AX mode through ATK calls
Browse files Browse the repository at this point in the history
This CL disables the function to enable AX mode through ATK calls
since it seems to enable it even when it's not required. After
figuring out what API causes false positives, it will be enabled.

APIs on Linux and enabling AX mode is allowed with the command
line option, '--force-renderer-accessibility'.

(cherry picked from commit 62eefcd)

Bug: 1086506
AX-Relnotes: It disables automatic enabling AX mode on using ATK
Change-Id: I6c0b865349d4f965700bf0ff0639f0508e712de5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2216135
Commit-Queue: Dominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: Dominic Mazzoni <dmazzoni@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#772255}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2218724
Reviewed-by: Srinivas Sista <srinivassista@chromium.org>
Cr-Commit-Position: refs/branch-heads/4157@{#7}
Cr-Branched-From: 21b3ba8-refs/heads/master@{#772010}
  • Loading branch information
jkim-julie authored and Srinivas Sista committed May 27, 2020
1 parent 7115b40 commit b0d536c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
5 changes: 5 additions & 0 deletions ui/accessibility/platform/atk_util_auralinux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "base/memory/singleton.h"
#include "base/no_destructor.h"
#include "ui/accessibility/platform/atk_util_auralinux.h"
#include "ui/accessibility/platform/ax_platform_node.h"
#include "ui/accessibility/platform/ax_platform_node_auralinux.h"

namespace {
Expand Down Expand Up @@ -55,6 +56,10 @@ static KeySnoopFuncMap& GetActiveKeySnoopFunctions() {
static guint AtkUtilAuraLinuxAddKeyEventListener(
AtkKeySnoopFunc key_snoop_function,
gpointer data) {
if (!ui::AXPlatformNode::GetAccessibilityMode().has_mode(
ui::AXMode::kNativeAPIs))
return 0;

static guint current_key_event_listener_id = 0;

current_key_event_listener_id++;
Expand Down
28 changes: 18 additions & 10 deletions ui/accessibility/platform/ax_platform_node_auralinux.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2028,7 +2028,7 @@ const gchar* GetName(AtkObject* atk_object) {
}

const gchar* AtkGetName(AtkObject* atk_object) {
AXPlatformNode::NotifyAddAXModeFlags(kAXModeComplete);
AXPlatformNodeAuraLinux::EnableAXMode();
return GetName(atk_object);
}

Expand All @@ -2045,7 +2045,7 @@ const gchar* GetDescription(AtkObject* atk_object) {
}

const gchar* AtkGetDescription(AtkObject* atk_object) {
AXPlatformNode::NotifyAddAXModeFlags(kAXModeComplete);
AXPlatformNodeAuraLinux::EnableAXMode();
return GetDescription(atk_object);
}

Expand All @@ -2061,7 +2061,7 @@ gint GetNChildren(AtkObject* atk_object) {
}

gint AtkGetNChildren(AtkObject* atk_object) {
AXPlatformNode::NotifyAddAXModeFlags(kAXModeComplete);
AXPlatformNodeAuraLinux::EnableAXMode();
return GetNChildren(atk_object);
}

Expand All @@ -2083,7 +2083,7 @@ AtkObject* RefChild(AtkObject* atk_object, gint index) {
}

AtkObject* AtkRefChild(AtkObject* atk_object, gint index) {
AXPlatformNode::NotifyAddAXModeFlags(kAXModeComplete);
AXPlatformNodeAuraLinux::EnableAXMode();
return RefChild(atk_object, index);
}

Expand All @@ -2099,7 +2099,7 @@ gint GetIndexInParent(AtkObject* atk_object) {
}

gint AtkGetIndexInParent(AtkObject* atk_object) {
AXPlatformNode::NotifyAddAXModeFlags(kAXModeComplete);
AXPlatformNodeAuraLinux::EnableAXMode();
return GetIndexInParent(atk_object);
}

Expand All @@ -2115,7 +2115,7 @@ AtkObject* GetParent(AtkObject* atk_object) {
}

AtkObject* AtkGetParent(AtkObject* atk_object) {
AXPlatformNode::NotifyAddAXModeFlags(kAXModeComplete);
AXPlatformNodeAuraLinux::EnableAXMode();
return GetParent(atk_object);
}

Expand All @@ -2130,7 +2130,7 @@ AtkRelationSet* RefRelationSet(AtkObject* atk_object) {
}

AtkRelationSet* AtkRefRelationSet(AtkObject* atk_object) {
AXPlatformNode::NotifyAddAXModeFlags(kAXModeComplete);
AXPlatformNodeAuraLinux::EnableAXMode();
return RefRelationSet(atk_object);
}

Expand All @@ -2146,7 +2146,7 @@ AtkAttributeSet* GetAttributes(AtkObject* atk_object) {
}

AtkAttributeSet* AtkGetAttributes(AtkObject* atk_object) {
AXPlatformNode::NotifyAddAXModeFlags(kAXModeComplete);
AXPlatformNodeAuraLinux::EnableAXMode();
return GetAttributes(atk_object);
}

Expand All @@ -2161,7 +2161,7 @@ AtkRole GetRole(AtkObject* atk_object) {
}

AtkRole AtkGetRole(AtkObject* atk_object) {
AXPlatformNode::NotifyAddAXModeFlags(kAXModeComplete);
AXPlatformNodeAuraLinux::EnableAXMode();
return GetRole(atk_object);
}

Expand All @@ -2183,7 +2183,7 @@ AtkStateSet* RefStateSet(AtkObject* atk_object) {
}

AtkStateSet* AtkRefStateSet(AtkObject* atk_object) {
AXPlatformNode::NotifyAddAXModeFlags(kAXModeComplete);
AXPlatformNodeAuraLinux::EnableAXMode();
return RefStateSet(atk_object);
}

Expand Down Expand Up @@ -2549,6 +2549,14 @@ void AXPlatformNodeAuraLinux::StaticInitialize() {
AtkUtilAuraLinux::GetInstance()->InitializeAsync();
}

// static
void AXPlatformNodeAuraLinux::EnableAXMode() {
// TODO(https://crbug.com/1086506): After figuring out what API calls are
// giving us false positives, enable it again. For now, don't activate AX
// through ATK calls.
// AXPlatformNode::NotifyAddAXModeFlags(kAXModeComplete);
}

AtkRole AXPlatformNodeAuraLinux::GetAtkRole() const {
switch (GetData().role) {
case ax::mojom::Role::kAlert:
Expand Down
4 changes: 4 additions & 0 deletions ui/accessibility/platform/ax_platform_node_auralinux.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ class AX_EXPORT AXPlatformNodeAuraLinux : public AXPlatformNodeBase {
// Do asynchronous static initialization.
static void StaticInitialize();

// Enables AXMode calling AXPlatformNode::NotifyAddAXModeFlags. It's used
// when ATK APIs are called.
static void EnableAXMode();

// EnsureAtkObjectIsValid will destroy and recreate |atk_object_| if the
// interface mask is different. This partially relies on looking at the tree's
// structure. This must not be called when the tree is unstable e.g. in the
Expand Down

0 comments on commit b0d536c

Please sign in to comment.