AX: ARIA combo boxes are not returning the right value for selected text range
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Jan 2016 18:11:51 +0000 (18:11 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Jan 2016 18:11:51 +0000 (18:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=153260

Reviewed by Darin Adler.

Source/WebCore:

Just because an element has an ARIA role doesn't mean we should always use the selected text range of the whole document.
If the element is also a text based ARIA control, we can still use the element's inner text range to return the right value.

Test: accessibility/selected-text-range-aria-elements.html

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::selectedTextRange):

LayoutTests:

* accessibility/selected-text-range-aria-elements-expected.txt: Added.
* accessibility/selected-text-range-aria-elements.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/accessibility/selected-text-range-aria-elements-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/selected-text-range-aria-elements.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityRenderObject.cpp

index 3f02c4d..099326f 100644 (file)
@@ -1,3 +1,13 @@
+2016-01-22  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: ARIA combo boxes are not returning the right value for selected text range
+        https://bugs.webkit.org/show_bug.cgi?id=153260
+
+        Reviewed by Darin Adler.
+
+        * accessibility/selected-text-range-aria-elements-expected.txt: Added.
+        * accessibility/selected-text-range-aria-elements.html: Added.
+
 2016-01-21  Dave Hyatt  <hyatt@apple.com>
 
         Elements with overflow and border-radius don't show in multicolumn properly.
diff --git a/LayoutTests/accessibility/selected-text-range-aria-elements-expected.txt b/LayoutTests/accessibility/selected-text-range-aria-elements-expected.txt
new file mode 100644 (file)
index 0000000..1163136
--- /dev/null
@@ -0,0 +1,11 @@
+
+This test makes sure that a native text control with a text-like ARIA value returns selectedTextRange
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Text range: {4, 2}
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/selected-text-range-aria-elements.html b/LayoutTests/accessibility/selected-text-range-aria-elements.html
new file mode 100644 (file)
index 0000000..66dbd92
--- /dev/null
@@ -0,0 +1,29 @@
+<html>
+<html>
+<head>
+<script src="../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+
+    <input id="combo" type="text" role="combobox" value="Hello World"> 
+    
+    <p id="description"></p>
+    <div id="console"></div>
+     
+    <script>
+        var node = document.getElementById("combo");
+        node.focus();
+        node.setSelectionRange(4, 6); 
+
+        if (window.accessibilityController) {
+            description("This test makes sure that a native text control with a text-like ARIA value returns selectedTextRange");
+
+            var element = accessibilityController.accessibleElementById("combo");
+            debug("Text range: " + element.selectedTextRange);
+        }
+    </script>
+
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
index d2a3502..6327538 100644 (file)
@@ -1,3 +1,18 @@
+2016-01-22  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: ARIA combo boxes are not returning the right value for selected text range
+        https://bugs.webkit.org/show_bug.cgi?id=153260
+
+        Reviewed by Darin Adler.
+
+        Just because an element has an ARIA role doesn't mean we should always use the selected text range of the whole document.
+        If the element is also a text based ARIA control, we can still use the element's inner text range to return the right value.
+
+        Test: accessibility/selected-text-range-aria-elements.html
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::selectedTextRange):
+
 2016-01-22  Chris Dumez  <cdumez@apple.com>
 
         Unreviewed iOS build fix after r195452.
index 787ff34..c2389bd 100644 (file)
@@ -1493,7 +1493,8 @@ PlainTextRange AccessibilityRenderObject::selectedTextRange() const
         return PlainTextRange();
     
     AccessibilityRole ariaRole = ariaRoleAttribute();
-    if (isNativeTextControl() && ariaRole == UnknownRole) {
+    // Use the text control native range if it's a native object and it has no ARIA role (or has a text based ARIA role).
+    if (isNativeTextControl() && (ariaRole == UnknownRole || isARIATextControl())) {
         HTMLTextFormControlElement& textControl = downcast<RenderTextControl>(*m_renderer).textFormControlElement();
         return PlainTextRange(textControl.selectionStart(), textControl.selectionEnd() - textControl.selectionStart());
     }