Title: [141560] trunk
Revision
141560
Author
cfleiz...@apple.com
Date
2013-02-01 01:32:54 -0800 (Fri, 01 Feb 2013)

Log Message

AX: when aria-activedescendant is used with a ComboBox role, focus should not be changed
https://bugs.webkit.org/show_bug.cgi?id=108596

Reviewed by Ryosuke Niwa.

Source/WebCore: 

Normally, an aria-activedescendant change causes a focus change to be triggered.
However, when used in conjunction with a combo box, this causes problems for screen readers.
Namely, the user expects focus to remain in the text field so that the user can keep typing. 
If focus moves to an item in the combobox list, it is not possible to keep typing.

The solution is to not trigger a focus change in this case and instead use a selected children change notification.

Test: platform/mac/accessibility/combobox-activedescendant-notifications.html

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::shouldNotifyActiveDescendant):
(WebCore::AccessibilityRenderObject::shouldFocusActiveDescendant):
(WebCore::AccessibilityRenderObject::handleActiveDescendantChanged):
* accessibility/AccessibilityRenderObject.h:
(AccessibilityRenderObject):
* accessibility/mac/AXObjectCacheMac.mm:
(WebCore::AXObjectCache::postPlatformNotification):

LayoutTests: 

* platform/mac/accessibility/combobox-activedescendant-notifications-expected.txt: Added.
* platform/mac/accessibility/combobox-activedescendant-notifications.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (141559 => 141560)


--- trunk/LayoutTests/ChangeLog	2013-02-01 09:17:02 UTC (rev 141559)
+++ trunk/LayoutTests/ChangeLog	2013-02-01 09:32:54 UTC (rev 141560)
@@ -1,5 +1,15 @@
 2013-02-01  Chris Fleizach  <cfleiz...@apple.com>
 
+        AX: when aria-activedescendant is used with a ComboBox role, focus should not be changed
+        https://bugs.webkit.org/show_bug.cgi?id=108596
+
+        Reviewed by Ryosuke Niwa.
+
+        * platform/mac/accessibility/combobox-activedescendant-notifications-expected.txt: Added.
+        * platform/mac/accessibility/combobox-activedescendant-notifications.html: Added.
+
+2013-02-01  Chris Fleizach  <cfleiz...@apple.com>
+
         [Mac] REGRESSION(r140974): accessibility/lists.html fails on Lion
         https://bugs.webkit.org/show_bug.cgi?id=108291
 

Added: trunk/LayoutTests/platform/mac/accessibility/combobox-activedescendant-notifications-expected.txt (0 => 141560)


--- trunk/LayoutTests/platform/mac/accessibility/combobox-activedescendant-notifications-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/accessibility/combobox-activedescendant-notifications-expected.txt	2013-02-01 09:32:54 UTC (rev 141560)
@@ -0,0 +1,12 @@
+This test makes sure that an ARIA active descendant change does not change focus, because focus should remain in the textfield portion of the combo box.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+The ComboBox should start out as the focused element.
+PASS combo.isEqual(accessibilityController.focusedElement) is true
+
+The ComboBox should still be the focused element even after the aria-activedescendant was changed.
+PASS combo.isEqual(accessibilityController.focusedElement) is true
+Received notification: AXSelectedChildrenChanged
+

Added: trunk/LayoutTests/platform/mac/accessibility/combobox-activedescendant-notifications.html (0 => 141560)


--- trunk/LayoutTests/platform/mac/accessibility/combobox-activedescendant-notifications.html	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/accessibility/combobox-activedescendant-notifications.html	2013-02-01 09:32:54 UTC (rev 141560)
@@ -0,0 +1,50 @@
+<!DOCTYPE HTML PUBLIC>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+
+<div id="content">
+<input type="text" role="combobox" id="combo" aria-owns="list">
+<ul id="list" role="listbox">
+<li tabindex="0" role="option" id="item1">item1</li>
+</ul>
+</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+    description("This test makes sure that an ARIA active descendant change does not change focus, because focus should remain in the textfield portion of the combo box.");
+
+    if (window.testRunner && window.accessibilityController) {
+        jsTestIsAsync = true;
+        testRunner.waitUntilDone();
+
+        document.getElementById("combo").focus();
+        var combo = accessibilityController.accessibleElementById("combo");
+        debug("The ComboBox should start out as the focused element.");
+        shouldBeTrue("combo.isEqual(accessibilityController.focusedElement)");
+
+        // When the active descendant changes, we should receive a selected children changed notification.
+        combo.addNotificationListener(function(notification) {
+           debug("Received notification: " + notification); 
+           if (notification == "AXSelectedChildrenChanged") {
+                combo.removeNotificationListener();
+                window.testRunner.notifyDone();
+           }
+        });
+
+        // After the descendant changes, the combo box should still be the focused object.
+        document.getElementById("combo").setAttribute("aria-activedescendant", "item1");
+        debug("\nThe ComboBox should still be the focused element even after the aria-activedescendant was changed.");
+        shouldBeTrue("combo.isEqual(accessibilityController.focusedElement)");
+        document.getElementById("content").style.visibility = 'hidden';
+    }
+
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (141559 => 141560)


--- trunk/Source/WebCore/ChangeLog	2013-02-01 09:17:02 UTC (rev 141559)
+++ trunk/Source/WebCore/ChangeLog	2013-02-01 09:32:54 UTC (rev 141560)
@@ -1,5 +1,30 @@
 2013-02-01  Chris Fleizach  <cfleiz...@apple.com>
 
+        AX: when aria-activedescendant is used with a ComboBox role, focus should not be changed
+        https://bugs.webkit.org/show_bug.cgi?id=108596
+
+        Reviewed by Ryosuke Niwa.
+
+        Normally, an aria-activedescendant change causes a focus change to be triggered.
+        However, when used in conjunction with a combo box, this causes problems for screen readers.
+        Namely, the user expects focus to remain in the text field so that the user can keep typing. 
+        If focus moves to an item in the combobox list, it is not possible to keep typing.
+
+        The solution is to not trigger a focus change in this case and instead use a selected children change notification.
+
+        Test: platform/mac/accessibility/combobox-activedescendant-notifications.html
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::shouldNotifyActiveDescendant):
+        (WebCore::AccessibilityRenderObject::shouldFocusActiveDescendant):
+        (WebCore::AccessibilityRenderObject::handleActiveDescendantChanged):
+        * accessibility/AccessibilityRenderObject.h:
+        (AccessibilityRenderObject):
+        * accessibility/mac/AXObjectCacheMac.mm:
+        (WebCore::AXObjectCache::postPlatformNotification):
+
+2013-02-01  Chris Fleizach  <cfleiz...@apple.com>
+
         [Mac] REGRESSION(r140974): accessibility/lists.html fails on Lion=
         https://bugs.webkit.org/show_bug.cgi?id=108291
 

Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (141559 => 141560)


--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2013-02-01 09:17:02 UTC (rev 141559)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2013-02-01 09:32:54 UTC (rev 141560)
@@ -2226,11 +2226,20 @@
     return result;
 }
 
+bool AccessibilityRenderObject::shouldNotifyActiveDescendant() const
+{
+    // We want to notify that the combo box has changed its active descendant,
+    // but we do not want to change the focus, because focus should remain with the combo box.
+    if (isComboBox())
+        return true;
+    
+    return shouldFocusActiveDescendant();
+}
+
 bool AccessibilityRenderObject::shouldFocusActiveDescendant() const
 {
     switch (ariaRoleAttribute()) {
     case GroupRole:
-    case ComboBoxRole:
     case ListBoxRole:
     case MenuRole:
     case MenuBarRole:
@@ -2323,7 +2332,7 @@
         return; 
     AccessibilityRenderObject* activedescendant = static_cast<AccessibilityRenderObject*>(activeDescendant());
     
-    if (activedescendant && shouldFocusActiveDescendant())
+    if (activedescendant && shouldNotifyActiveDescendant())
         doc->axObjectCache()->postNotification(m_renderer, AXObjectCache::AXActiveDescendantChanged, true);
 }
 

Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h (141559 => 141560)


--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h	2013-02-01 09:17:02 UTC (rev 141559)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h	2013-02-01 09:32:54 UTC (rev 141560)
@@ -173,6 +173,7 @@
     virtual void visibleChildren(AccessibilityChildrenVector&);
     virtual void tabChildren(AccessibilityChildrenVector&);
     virtual bool shouldFocusActiveDescendant() const;
+    bool shouldNotifyActiveDescendant() const;
     virtual AccessibilityObject* activeDescendant() const;
     virtual void handleActiveDescendantChanged();
     virtual void handleAriaExpandedChanged();

Modified: trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm (141559 => 141560)


--- trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm	2013-02-01 09:17:02 UTC (rev 141559)
+++ trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm	2013-02-01 09:32:54 UTC (rev 141560)
@@ -67,6 +67,12 @@
             // An active descendant change for trees means a selected rows change.
             if (obj->isTree())
                 macNotification = NSAccessibilitySelectedRowsChangedNotification;
+            
+            // When a combobox uses active descendant, it means the selected item in its associated
+            // list has changed. In these cases we should use selected children changed, because
+            // we don't want the focus to change away from the combobox where the user is typing.
+            else if (obj->isComboBox())
+                macNotification = NSAccessibilitySelectedChildrenChangedNotification;
             else
                 macNotification = NSAccessibilityFocusedUIElementChangedNotification;                
             break;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to