Commit b4237149 authored by Isha Bobra's avatar Isha Bobra Committed by Commit Bot

Android Accessibility: Avoiding incorrect marking of elements as clickable

For the elements where a click listener is present in its ancestry chain,
a default action verb "click-ancestor" is used. So for android this CL makes sure
that such elements are not marked as clickable.

Bug: 645167
Change-Id: I0ce047e8bf619bb6eaa3c77bc4bec4d2d999e203
Reviewed-on: https://chromium-review.googlesource.com/804202
Commit-Queue: Isha Bobra <ibobra@google.com>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarNektarios Paisios <nektar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#523210}
parent 8c36df7c
...@@ -174,9 +174,15 @@ bool BrowserAccessibilityAndroid::IsChecked() const { ...@@ -174,9 +174,15 @@ bool BrowserAccessibilityAndroid::IsChecked() const {
} }
bool BrowserAccessibilityAndroid::IsClickable() const { bool BrowserAccessibilityAndroid::IsClickable() const {
// If it has a custom default action verb, it's definitely clickable. // If it has a custom default action verb except for
if (HasIntAttribute(ui::AX_ATTR_DEFAULT_ACTION_VERB)) // AX_DEFAULT_ACTION_VERB_CLICK_ANCESTOR, it's definitely clickable.
// AX_DEFAULT_ACTION_VERB_CLICK_ANCESTOR is used when an element with a click
// listener is present in its ancestry chain.
if (HasIntAttribute(ui::AX_ATTR_DEFAULT_ACTION_VERB) &&
(GetIntAttribute(ui::AX_ATTR_DEFAULT_ACTION_VERB) !=
ui::AX_DEFAULT_ACTION_VERB_CLICK_ANCESTOR)) {
return true; return true;
}
// Otherwise return true if it's focusable, but skip web areas and iframes. // Otherwise return true if it's focusable, but skip web areas and iframes.
if (IsIframe() || (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA)) if (IsIframe() || (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA))
......
...@@ -325,6 +325,11 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityAIsInteresting) { ...@@ -325,6 +325,11 @@ IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest, AccessibilityAIsInteresting) {
RunHtmlTest(FILE_PATH_LITERAL("isInteresting.html")); RunHtmlTest(FILE_PATH_LITERAL("isInteresting.html"));
} }
IN_PROC_BROWSER_TEST_F(DumpAccessibilityTreeTest,
AccessibilityClickableAncestor) {
RunHtmlTest(FILE_PATH_LITERAL("clickable-ancestor.html"));
}
#if defined(THREAD_SANITIZER) #if defined(THREAD_SANITIZER)
// See (crbug.com/708759). // See (crbug.com/708759).
#define MAYBE_AccessibilityAomBusy DISABLED_AccessibilityAomBusy #define MAYBE_AccessibilityAomBusy DISABLED_AccessibilityAomBusy
......
android.webkit.WebView focusable focused scrollable name='Checking nodes marked as clickable'
++android.view.View name='Generic div'
++android.view.View role_description='heading 1' heading name='Heading'
++android.widget.Button role_description='button' clickable focusable name='Button'
++android.view.View clickable
++++android.view.View name='Paragraph with click handler on parent and should be not marked as clickable'
\ No newline at end of file
<!doctype html>
<html>
<head>
<title>Checking nodes marked as clickable</title>
</head>
<body>
<div>Generic div</div>
<h1>Heading</h1>
<button>Button</button>
<div onclick="alert('success');" role="group">
<p>Paragraph with click handler on parent and should be not marked as clickable</p>
</div>
</body>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment