AX: Add remote search support for keyboard focusable element search type
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Mar 2019 04:01:47 +0000 (04:01 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Mar 2019 04:01:47 +0000 (04:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195336

Patch by Eric Liang <ericliang@apple.com> on 2019-03-05
Reviewed by Chris Fleizach.

Source/WebCore:

Added AXKeyboardFocusable search key to return default keyboard-focusable elements for accessibility.

Test: accessibility/mac/search-predicate-keyboard-focusable.html

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::isAccessibilityObjectSearchMatchAtIndex):
(WebCore::AccessibilityObject::isKeyboardFocusable const):
* accessibility/AccessibilityObject.h:
* accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
(createAccessibilitySearchKeyMap):

LayoutTests:

Added test that verifies search with AXKeyboardFocusableSearchKey returns the default keyboard-focusable elements.

* accessibility/mac/search-predicate-keyboard-focusable-expected.txt: Added.
* accessibility/mac/search-predicate-keyboard-focusable.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242528 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/accessibility/mac/search-predicate-keyboard-focusable-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/mac/search-predicate-keyboard-focusable.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperBase.mm

index c680aba..b606c4e 100644 (file)
@@ -1,3 +1,15 @@
+2019-03-05  Eric Liang  <ericliang@apple.com>
+
+        AX: Add remote search support for keyboard focusable element search type
+        https://bugs.webkit.org/show_bug.cgi?id=195336
+
+        Reviewed by Chris Fleizach.
+
+        Added test that verifies search with AXKeyboardFocusableSearchKey returns the default keyboard-focusable elements.
+
+        * accessibility/mac/search-predicate-keyboard-focusable-expected.txt: Added.
+        * accessibility/mac/search-predicate-keyboard-focusable.html: Added.
+
 2019-03-05  Daniel Bates  <dabates@apple.com>
 
         [iOS] Should not scroll when checkbox, radio, submit, reset, or button is spacebar activated
diff --git a/LayoutTests/accessibility/mac/search-predicate-keyboard-focusable-expected.txt b/LayoutTests/accessibility/mac/search-predicate-keyboard-focusable-expected.txt
new file mode 100644 (file)
index 0000000..15ef0de
--- /dev/null
@@ -0,0 +1,33 @@
+first blockquote level 1
+
+ checkbox
+
+first heading level 1
+
+link
+list item
+radio button
+first table heading level 1
+tree item
+test button 1
+test button 2
+This tests AXKeyboardFocusableSearchKey gives the default focusable elements.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS resultElement.role is 'AXRole: AXTextField'
+PASS resultElement.role is 'AXRole: AXCheckBox'
+PASS resultElement.role is 'AXRole: AXButton'
+PASS resultElement.title is 'AXTitle: Submit'
+PASS resultElement.role is 'AXRole: AXComboBox'
+PASS resultElement.role is 'AXRole: AXLink'
+PASS resultElement.role is 'AXRole: AXButton'
+PASS resultElement.title is 'AXTitle: test button 1'
+PASS resultElement.role is 'AXRole: AXButton'
+PASS resultElement.title is 'AXTitle: test button 2'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/mac/search-predicate-keyboard-focusable.html b/LayoutTests/accessibility/mac/search-predicate-keyboard-focusable.html
new file mode 100644 (file)
index 0000000..447215a
--- /dev/null
@@ -0,0 +1,73 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+<div id="content">
+<blockquote id="start">first blockquote level 1</blockquote>
+<form>
+<input type="text" /><br />
+<input type="checkbox" value="Checkbox" /> checkbox<br />
+<input type="submit" value="Submit" />
+<input type="text" role="combobox">
+</form>
+<img id="image" src="resources/cake.png" alt="Test">
+<h1>first heading level 1</h1>
+<a href="#image">link</a>
+<ol><li>list item</li></ol>
+<ul role="radiogroup"><li role="radio">radio button</li></ul>
+<table>
+<thead><tr><td>first table heading level 1</td></tr></thead>
+</table>
+<ul role="tree"><li role="treeitem">tree item</li></ul>
+
+<div id="group" style="overflow: scroll; width:100px; height:100px;">
+    <button id="button">test button 1</button><BR>
+</div>
+<button id="button">test button 2</button>
+
+<p id="description"></p>
+<div id="console"></div>
+
+</div>
+<script>
+    description("This tests AXKeyboardFocusableSearchKey gives the default focusable elements.");
+
+    if (window.accessibilityController) {
+        document.getElementById("body").focus();
+        var containerElement = accessibilityController.focusedElement;
+        var resultElement = accessibilityController.accessibleElementById("start");
+
+        resultElement = containerElement.uiElementForSearchPredicate(resultElement, true, "AXKeyboardFocusableSearchKey", "", false);
+        shouldBe("resultElement.role", "'AXRole: AXTextField'");
+
+        resultElement = containerElement.uiElementForSearchPredicate(resultElement, true, "AXKeyboardFocusableSearchKey", "", false);
+        shouldBe("resultElement.role", "'AXRole: AXCheckBox'");
+
+        resultElement = containerElement.uiElementForSearchPredicate(resultElement, true, "AXKeyboardFocusableSearchKey", "", false);
+        shouldBe("resultElement.role", "'AXRole: AXButton'");
+        shouldBe("resultElement.title", "'AXTitle: Submit'");
+
+        resultElement = containerElement.uiElementForSearchPredicate(resultElement, true, "AXKeyboardFocusableSearchKey", "", false);
+        shouldBe("resultElement.role", "'AXRole: AXComboBox'");
+
+        resultElement = containerElement.uiElementForSearchPredicate(resultElement, true, "AXKeyboardFocusableSearchKey", "", false);
+        shouldBe("resultElement.role", "'AXRole: AXLink'");
+
+        resultElement = containerElement.uiElementForSearchPredicate(resultElement, true, "AXKeyboardFocusableSearchKey", "", false);
+        shouldBe("resultElement.role", "'AXRole: AXButton'");
+        shouldBe("resultElement.title", "'AXTitle: test button 1'");
+
+        resultElement = containerElement.uiElementForSearchPredicate(resultElement, true, "AXKeyboardFocusableSearchKey", "", false);
+        shouldBe("resultElement.role", "'AXRole: AXButton'");
+        shouldBe("resultElement.title", "'AXTitle: test button 2'");
+    } else {
+        testFailed("Could not load accessibility controller");
+    }
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
index 9e1f220..c1690e7 100644 (file)
@@ -1,3 +1,21 @@
+2019-03-05  Eric Liang  <ericliang@apple.com>
+
+        AX: Add remote search support for keyboard focusable element search type
+        https://bugs.webkit.org/show_bug.cgi?id=195336
+
+        Reviewed by Chris Fleizach.
+
+        Added AXKeyboardFocusable search key to return default keyboard-focusable elements for accessibility.
+
+        Test: accessibility/mac/search-predicate-keyboard-focusable.html
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::isAccessibilityObjectSearchMatchAtIndex):
+        (WebCore::AccessibilityObject::isKeyboardFocusable const):
+        * accessibility/AccessibilityObject.h:
+        * accessibility/mac/WebAccessibilityObjectWrapperBase.mm:
+        (createAccessibilitySearchKeyMap):
+
 2019-03-05  Don Olmstead  <don.olmstead@sony.com>
 
         [WinCairo] Enable CSS Typed OM
index 3266078..32feea6 100644 (file)
@@ -195,6 +195,9 @@ bool AccessibilityObject::isAccessibilityObjectSearchMatchAtIndex(AccessibilityO
     case AccessibilitySearchKey::Highlighted:
         return axObject->hasHighlighting();
             
+    case AccessibilitySearchKey::KeyboardFocusable:
+        return axObject->isKeyboardFocusable();
+        
     case AccessibilitySearchKey::ItalicFont:
         return axObject->hasItalicFont();
         
@@ -3493,6 +3496,13 @@ bool AccessibilityObject::isFigureElement() const
     return node && node->hasTagName(figureTag);
 }
 
+bool AccessibilityObject::isKeyboardFocusable() const
+{
+    if (auto element = this->element())
+        return element->isFocusable();
+    return false;
+}
+
 bool AccessibilityObject::isOutput() const
 {
     Node* node = this->node();
index 780f67f..18a098f 100644 (file)
@@ -215,6 +215,7 @@ enum class AccessibilitySearchKey {
     Heading,
     Highlighted,
     ItalicFont,
+    KeyboardFocusable,
     Landmark,
     Link,
     List,
@@ -441,6 +442,7 @@ public:
     bool isSubscriptStyleGroup() const;
     bool isSuperscriptStyleGroup() const;
     bool isFigureElement() const;
+    bool isKeyboardFocusable() const;
     bool isSummary() const { return roleValue() == AccessibilityRole::Summary; }
     bool isOutput() const;
     
index f0dd328..af8f8a0 100644 (file)
@@ -166,6 +166,10 @@ using namespace HTMLNames;
 #define NSAccessibilityHighlightedSearchKey @"AXHighlightedSearchKey"
 #endif
 
+#ifndef NSAccessibilityKeyboardFocusableSearchKey
+#define NSAccessibilityKeyboardFocusableSearchKey @"AXKeyboardFocusableSearchKey"
+#endif
+
 #ifndef NSAccessibilityItalicFontSearchKey
 #define NSAccessibilityItalicFontSearchKey @"AXItalicFontSearchKey"
 #endif
@@ -695,6 +699,7 @@ static AccessibilitySearchKeyMap* createAccessibilitySearchKeyMap()
         { NSAccessibilityHeadingSameLevelSearchKey, AccessibilitySearchKey::HeadingSameLevel },
         { NSAccessibilityHeadingSearchKey, AccessibilitySearchKey::Heading },
         { NSAccessibilityHighlightedSearchKey, AccessibilitySearchKey::Highlighted },
+        { NSAccessibilityKeyboardFocusableSearchKey, AccessibilitySearchKey::KeyboardFocusable },
         { NSAccessibilityItalicFontSearchKey, AccessibilitySearchKey::ItalicFont },
         { NSAccessibilityLandmarkSearchKey, AccessibilitySearchKey::Landmark },
         { NSAccessibilityLinkSearchKey, AccessibilitySearchKey::Link },