AX: Can't activate links with VoiceOver in Safari
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Mar 2013 20:04:22 +0000 (20:04 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Mar 2013 20:04:22 +0000 (20:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=111755

Reviewed by Tim Horton.

Source/WebCore:

VoiceOver is relying on the press action being the first action in the list. We changed
that order inadvertently recently, which confuses VoiceOver.

Test: platform/mac/accessibility/press-action-is-first.html

* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper accessibilityActionNames]):

Tools:

* DumpRenderTree/AccessibilityUIElement.cpp:
(supportedActionsCallback):
(AccessibilityUIElement::getJSClass):
* DumpRenderTree/AccessibilityUIElement.h:
(AccessibilityUIElement):
* DumpRenderTree/mac/AccessibilityUIElementMac.mm:
(AccessibilityUIElement::supportedActions):

LayoutTests:

* platform/mac/accessibility/press-action-is-first-expected.txt: Added.
* platform/mac/accessibility/press-action-is-first.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/platform/mac/accessibility/press-action-is-first-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/press-action-is-first.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
Tools/ChangeLog
Tools/DumpRenderTree/AccessibilityUIElement.cpp
Tools/DumpRenderTree/AccessibilityUIElement.h
Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm

index 1fdef6f..8aa56f9 100644 (file)
@@ -1,3 +1,13 @@
+2013-03-07  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Can't activate links with VoiceOver in Safari
+        https://bugs.webkit.org/show_bug.cgi?id=111755
+
+        Reviewed by Tim Horton.
+
+        * platform/mac/accessibility/press-action-is-first-expected.txt: Added.
+        * platform/mac/accessibility/press-action-is-first.html: Added.
+
 2013-03-07  Rafael Weinstein  <rafaelw@chromium.org>
 
         Unreviewed, rolling out r145083.
diff --git a/LayoutTests/platform/mac/accessibility/press-action-is-first-expected.txt b/LayoutTests/platform/mac/accessibility/press-action-is-first-expected.txt
new file mode 100644 (file)
index 0000000..e7ed04e
--- /dev/null
@@ -0,0 +1,12 @@
+
+This tests that the AXPressAction comes first for activatable items instead of the scroll to visible action. This is needed for screenreaders to operate correctly.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Button supported actions: AXPress,AXShowMenu,AXScrollToVisible
+Link supported actions: AXPress,AXShowMenu,AXScrollToVisible
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/mac/accessibility/press-action-is-first.html b/LayoutTests/platform/mac/accessibility/press-action-is-first.html
new file mode 100644 (file)
index 0000000..a405714
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+
+<div id="group">
+
+<a href="#" id="link1">link1</a><br>
+<button id="button1">button</button>
+
+</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that the AXPressAction comes first for activatable items instead of the scroll to visible action. This is needed for screenreaders to operate correctly.");
+
+    if (window.accessibilityController) {
+
+          var button = accessibilityController.accessibleElementById("button1");
+          debug("Button supported actions: " + button.supportedActions);
+
+          var link = accessibilityController.accessibleElementById("link1");
+          debug("Link supported actions: " + link.supportedActions);
+
+          document.getElementById("group").style.visibility = "hidden";
+    }
+
+</script>
+
+<script src="../../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index cc4f694..b0f4e06 100644 (file)
@@ -1,3 +1,18 @@
+2013-03-07  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Can't activate links with VoiceOver in Safari
+        https://bugs.webkit.org/show_bug.cgi?id=111755
+
+        Reviewed by Tim Horton.
+
+        VoiceOver is relying on the press action being the first action in the list. We changed
+        that order inadvertently recently, which confuses VoiceOver.
+
+        Test: platform/mac/accessibility/press-action-is-first.html
+
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper accessibilityActionNames]):
+
 2013-03-07  Rafael Weinstein  <rafaelw@chromium.org>
 
         Unreviewed, rolling out r145083.
index f4cb1f5..72be421 100644 (file)
@@ -927,7 +927,8 @@ static id textMarkerRangeFromVisiblePositions(AXObjectCache *cache, VisiblePosit
     static NSArray *defaultElementActions = [[NSArray alloc] initWithObjects:NSAccessibilityShowMenuAction, NSAccessibilityScrollToVisibleAction, nil];
 
     // Action elements allow Press.
-    static NSArray *actionElementActions = [[defaultElementActions arrayByAddingObject:NSAccessibilityPressAction] retain];
+    // The order is important to VoiceOver, which expects the 'default' action to be the first action. In this case the default action should be press.
+    static NSArray *actionElementActions = [[NSArray alloc] initWithObjects:NSAccessibilityPressAction, NSAccessibilityShowMenuAction, NSAccessibilityScrollToVisibleAction, nil];
 
     // Menu elements allow Press and Cancel.
     static NSArray *menuElementActions = [[actionElementActions arrayByAddingObject:NSAccessibilityCancelAction] retain];
index 21b2864..76ca515 100644 (file)
@@ -1,3 +1,18 @@
+2013-03-07  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Can't activate links with VoiceOver in Safari
+        https://bugs.webkit.org/show_bug.cgi?id=111755
+
+        Reviewed by Tim Horton.
+
+        * DumpRenderTree/AccessibilityUIElement.cpp:
+        (supportedActionsCallback):
+        (AccessibilityUIElement::getJSClass):
+        * DumpRenderTree/AccessibilityUIElement.h:
+        (AccessibilityUIElement):
+        * DumpRenderTree/mac/AccessibilityUIElementMac.mm:
+        (AccessibilityUIElement::supportedActions):
+
 2013-03-07  Roger Fong  <roger_fong@apple.com>
 
         Windows debug layout tests are crashing like crazy again.
index 4b84bdf..9dfbc6c 100644 (file)
@@ -1060,6 +1060,14 @@ static JSValueRef getIPhoneElementTextLengthCallback(JSContextRef context, JSObj
 
 #endif // PLATFORM(IOS)
 
+#if PLATFORM(MAC) && !PLATFORM(IOS)
+static JSValueRef supportedActionsCallback(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)
+{
+    JSRetainPtr<JSStringRef> valueString(Adopt, toAXElement(thisObject)->supportedActions());
+    return JSValueMakeString(context, valueString.get());
+}
+#endif
+
 // Implementation
 
 // Unsupported methods on various platforms.
@@ -1237,6 +1245,9 @@ JSClassRef AccessibilityUIElement::getJSClass()
         { "iphoneElementTextLength", getIPhoneElementTextLengthCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "stringForSelection", stringForSelectionCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
 #endif // PLATFORM(IOS)
+#if PLATFORM(MAC) && !PLATFORM(IOS)
+        { "supportedActions", supportedActionsCallback, 0, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+#endif
         { 0, 0, 0, 0 }
     };
 
index 3b2d391..794a15d 100644 (file)
@@ -255,6 +255,11 @@ public:
     void assistiveTechnologySimulatedFocus();
 #endif // PLATFORM(IOS)
 
+#if PLATFORM(MAC) && !PLATFORM(IOS)
+    // Returns an ordered list of supported actions for an element.
+    JSStringRef supportedActions();
+#endif
+    
 private:
     static JSClassRef getJSClass();
     PlatformUIElement m_element;
index 6141e8d..63a6bd9 100644 (file)
@@ -1437,6 +1437,16 @@ AccessibilityUIElement AccessibilityUIElement::accessibilityElementForTextMarker
 
 #endif // SUPPORTS_AX_TEXTMARKERS
 
+JSStringRef AccessibilityUIElement::supportedActions()
+{
+    BEGIN_AX_OBJC_EXCEPTIONS
+    NSArray *names = [m_element accessibilityActionNames];
+    return [[names componentsJoinedByString:@","] createJSStringRef];
+    END_AX_OBJC_EXCEPTIONS
+
+    return 0;
+}
+
 void AccessibilityUIElement::scrollToMakeVisible()
 {
     BEGIN_AX_OBJC_EXCEPTIONS