AX: Nodes are reporting that focus can be set when they really can't
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Dec 2011 01:08:55 +0000 (01:08 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Dec 2011 01:08:55 +0000 (01:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=72791

Reviewed by Beth Dakin.

Source/WebCore:

Whether focus can be set on a node shouldn't rely only on the role.
It should depend on whether the node supports focus.

Test: platform/mac/accessibility/supports-focus-setting.html

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

Tools:

* DumpRenderTree/mac/AccessibilityUIElementMac.mm:
(AccessibilityUIElement::isFocusable):
* WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl:
* WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
(WTR::AccessibilityUIElement::isFocusable):

LayoutTests:

* platform/mac/accessibility/supports-focus-setting-expected.txt: Added.
* platform/mac/accessibility/supports-focus-setting.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/platform/mac/accessibility/supports-focus-setting-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/supports-focus-setting.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Tools/ChangeLog
Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm
Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl
Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm

index 09c395ad9a1d0cd67851735a784b3d560c201092..79dd1d43dc9a846a72cb585222e88094ff603870 100644 (file)
@@ -1,3 +1,13 @@
+2011-11-30  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Nodes are reporting that focus can be set when they really can't
+        https://bugs.webkit.org/show_bug.cgi?id=72791
+
+        Reviewed by Beth Dakin.
+
+        * platform/mac/accessibility/supports-focus-setting-expected.txt: Added.
+        * platform/mac/accessibility/supports-focus-setting.html: Added.
+
 2011-11-30  Chris Fleizach  <cfleizach@apple.com>
 
         WebKit does not send mouse down/up/click events to ARIA tabs
diff --git a/LayoutTests/platform/mac/accessibility/supports-focus-setting-expected.txt b/LayoutTests/platform/mac/accessibility/supports-focus-setting-expected.txt
new file mode 100644 (file)
index 0000000..6724b33
--- /dev/null
@@ -0,0 +1,15 @@
+focusable link non focusable link focusable link non focusable button focusable button
+This tests whether focus can be set is reported correctly based on whether the node can accept focus.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS group.childAtIndex(0).isFocusable is true
+PASS group.childAtIndex(1).isFocusable is false
+PASS group.childAtIndex(2).isFocusable is true
+PASS group.childAtIndex(3).isFocusable is false
+PASS group.childAtIndex(4).isFocusable is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/mac/accessibility/supports-focus-setting.html b/LayoutTests/platform/mac/accessibility/supports-focus-setting.html
new file mode 100644 (file)
index 0000000..c089c9b
--- /dev/null
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../../fast/js/resources/js-test-style.css">
+<script>
+var successfullyParsed = false;
+</script>
+<script src="../../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+
+<a href="#">focusable link</a>
+<a>non focusable link</a>
+<a role="link" tabindex="0">focusable link</a>
+<span role="button">non focusable button</span>
+<span tabindex="0" role="button">focusable button</span>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests whether focus can be set is reported correctly based on whether the node can accept focus.");
+
+    if (window.accessibilityController) {
+
+        document.getElementById("body").focus();
+        var group = accessibilityController.focusedElement.childAtIndex(0);
+        shouldBe("group.childAtIndex(0).isFocusable", "true");
+        shouldBe("group.childAtIndex(1).isFocusable", "false");
+        shouldBe("group.childAtIndex(2).isFocusable", "true");
+        shouldBe("group.childAtIndex(3).isFocusable", "false");
+        shouldBe("group.childAtIndex(4).isFocusable", "true");
+    }
+
+    successfullyParsed = true;
+</script>
+
+<script src="../../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index 5303517eed51caa194b72f0e19f2a85063dac371..8a63e974d5473c0128908a5b4b800c20b61905dd 100644 (file)
@@ -1,3 +1,18 @@
+2011-11-30  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Nodes are reporting that focus can be set when they really can't
+        https://bugs.webkit.org/show_bug.cgi?id=72791
+
+        Reviewed by Beth Dakin.
+
+        Whether focus can be set on a node shouldn't rely only on the role.
+        It should depend on whether the node supports focus.
+
+        Test: platform/mac/accessibility/supports-focus-setting.html
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::canSetFocusAttribute):
+
 2011-11-30  Chris Fleizach  <cfleizach@apple.com>
 
         WebKit does not send mouse down/up/click events to ARIA tabs
index 951986542e66fcdbc3bc8febb58b0de31acbd74a..f148f0e79dabe9e35a3296994355f285ac9f526e 100644 (file)
@@ -3335,32 +3335,18 @@ bool AccessibilityRenderObject::ariaRoleHasPresentationalChildren() const
 
 bool AccessibilityRenderObject::canSetFocusAttribute() const
 {
-    ASSERT(m_renderer);
-    Node* node = m_renderer->node();
+    Node* node = this->node();
 
     // NOTE: It would be more accurate to ask the document whether setFocusedNode() would
     // do anything.  For example, setFocusedNode() will do nothing if the current focused
     // node will not relinquish the focus.
-    if (!node || !node->isElementNode())
+    if (!node)
         return false;
 
-    if (!static_cast<Element*>(node)->isEnabledFormControl())
+    if (node->isElementNode() && !static_cast<Element*>(node)->isEnabledFormControl())
         return false;
 
-    switch (roleValue()) {
-    case WebCoreLinkRole:
-    case ImageMapLinkRole:
-    case TextFieldRole:
-    case TextAreaRole:
-    case ButtonRole:
-    case PopUpButtonRole:
-    case CheckBoxRole:
-    case RadioButtonRole:
-    case SliderRole:
-        return true;
-    default:
-        return node->supportsFocus();
-    }
+    return node->supportsFocus();
 }
     
 bool AccessibilityRenderObject::canSetExpandedAttribute() const
index de68348c9a5c38e29a99fac91dd94c84287508be..0d02b6029385ebb37ec642146ef388fbb04894be 100644 (file)
@@ -1,3 +1,16 @@
+2011-11-30  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Nodes are reporting that focus can be set when they really can't
+        https://bugs.webkit.org/show_bug.cgi?id=72791
+
+        Reviewed by Beth Dakin.
+
+        * DumpRenderTree/mac/AccessibilityUIElementMac.mm:
+        (AccessibilityUIElement::isFocusable):
+        * WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl:
+        * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
+        (WTR::AccessibilityUIElement::isFocusable):
+
 2011-11-30  Alejandro G. Castro  <alex@igalia.com>
 
         Moved myself to the reviewers list.
index 7d69382355706f37252c173b060ba8388b3e26e0..27b10dc0a0543efabe169e2599398f7c74756065 100644 (file)
@@ -1246,8 +1246,12 @@ void AccessibilityUIElement::removeNotificationListener()
 
 bool AccessibilityUIElement::isFocusable() const
 {
-    // FIXME: implement
-    return false;
+    bool result = false;
+    BEGIN_AX_OBJC_EXCEPTIONS
+    result = [m_element accessibilityIsAttributeSettable:NSAccessibilityFocusedAttribute];
+    END_AX_OBJC_EXCEPTIONS
+    
+    return result;
 }
 
 bool AccessibilityUIElement::isSelectable() const
index 46051e88fa0376ec4de89e8c52e36e0b398720ce..919353c71026ab3743c20f08ffb43a87bce46fae 100644 (file)
@@ -68,6 +68,7 @@ module WTR {
         readonly attribute boolean isEnabled;
         readonly attribute boolean isRequired;
         readonly attribute boolean isFocused;
+        readonly attribute boolean isFocusable;
         readonly attribute boolean isSelected;
         readonly attribute boolean isMultiSelectable;
         readonly attribute boolean isExpanded;
index d222d368e5b93821a9cac67d4c785bee3413e448..4d9d99dcb369987a8c94d3e2389df92360bde64e 100644 (file)
@@ -1263,8 +1263,12 @@ bool AccessibilityUIElement::removeNotificationListener()
 
 bool AccessibilityUIElement::isFocusable() const
 {
-    // FIXME: implement
-    return false;
+    bool result = false;
+    BEGIN_AX_OBJC_EXCEPTIONS
+    result = [m_element accessibilityIsAttributeSettable:NSAccessibilityFocusedAttribute];
+    END_AX_OBJC_EXCEPTIONS
+    
+    return result;
 }
 
 bool AccessibilityUIElement::isSelectable() const