Title: [157038] trunk
Revision
157038
Author
cfleiz...@apple.com
Date
2013-10-07 08:10:15 -0700 (Mon, 07 Oct 2013)

Log Message

AX: Facebook wrapped a file upload button in an unfocusable ARIA button, which doesn't work with AXPress.
https://bugs.webkit.org/show_bug.cgi?id=122252

Reviewed by Mario Sanchez Prada.

Source/WebCore:

When an author uses a control-type ARIA role (like button), but then hides a native control-type inside,
AXPress needs to operate on the inside node if possible.

Test: accessibility/axpress-on-aria-button.html

* accessibility/AccessibilityNodeObject.cpp:
(WebCore::isNodeActionElement):
(WebCore::nativeActionElement):
(WebCore::AccessibilityNodeObject::actionElement):

LayoutTests:

* accessibility/axpress-on-aria-button-expected.txt: Added.
* accessibility/axpress-on-aria-button.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (157037 => 157038)


--- trunk/LayoutTests/ChangeLog	2013-10-07 14:51:30 UTC (rev 157037)
+++ trunk/LayoutTests/ChangeLog	2013-10-07 15:10:15 UTC (rev 157038)
@@ -1,3 +1,13 @@
+2013-10-07  Chris Fleizach  <cfleiz...@apple.com>
+
+        AX: Facebook wrapped a file upload button in an unfocusable ARIA button, which doesn't work with AXPress.
+        https://bugs.webkit.org/show_bug.cgi?id=122252
+
+        Reviewed by Mario Sanchez Prada.
+
+        * accessibility/axpress-on-aria-button-expected.txt: Added.
+        * accessibility/axpress-on-aria-button.html: Added.
+
 2013-10-06  Filip Pizlo  <fpi...@apple.com>
 
         ASSERTION FAILED: bitwise_cast<WriteBarrier<Unknown>*>(callFrame) == m_registers in jsc-layout-tests.yaml/js/script-tests/dfg-inline-arguments-capture-throw-exception.js.layout-dfg-eager-no-cjit

Added: trunk/LayoutTests/accessibility/axpress-on-aria-button-expected.txt (0 => 157038)


--- trunk/LayoutTests/accessibility/axpress-on-aria-button-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/accessibility/axpress-on-aria-button-expected.txt	2013-10-07 15:10:15 UTC (rev 157038)
@@ -0,0 +1,18 @@
+Upload
+
+Upload
+
+Upload
+
+This tests that if a non-native action type is exposed as a control, then we will look for descendants to call press() on.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Press performed on fileupload
+Press performed on button
+Press performed on checkbox
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/accessibility/axpress-on-aria-button.html (0 => 157038)


--- trunk/LayoutTests/accessibility/axpress-on-aria-button.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/axpress-on-aria-button.html	2013-10-07 15:10:15 UTC (rev 157038)
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+
+<a id="button1" role="button">
+   <div>Upload</div>
+   <div><input type="file" _onclick_="pressPerformed(this);" title="Choose a file to upload" multiple="1" id="fileupload"></div>
+</a>
+
+<a id="button2" role="button">
+   <div>Upload</div>
+   <div><button _onclick_="pressPerformed(this);" id="button"></div>
+</a>
+
+<a id="button3" role="button">
+   <div>Upload</div>
+   <div><input type="checkbox" _onclick_="pressPerformed(this); finishJSTest();" id="checkbox"></div>
+</a>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+    description("This tests that if a non-native action type is exposed as a control, then we will look for descendants to call press() on.");
+    
+    function pressPerformed(element) {
+        debug("Press performed on " + element.getAttribute("id"));
+    }
+
+    window.jsTestIsAsync = true;
+    if (window.accessibilityController) {
+        for (var k = 1; k <= 3; k++) {
+            var button = accessibilityController.accessibleElementById("button" + k);
+            button.press();
+        }
+    }
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (157037 => 157038)


--- trunk/Source/WebCore/ChangeLog	2013-10-07 14:51:30 UTC (rev 157037)
+++ trunk/Source/WebCore/ChangeLog	2013-10-07 15:10:15 UTC (rev 157038)
@@ -1,3 +1,20 @@
+2013-10-07  Chris Fleizach  <cfleiz...@apple.com>
+
+        AX: Facebook wrapped a file upload button in an unfocusable ARIA button, which doesn't work with AXPress.
+        https://bugs.webkit.org/show_bug.cgi?id=122252
+
+        Reviewed by Mario Sanchez Prada.
+
+        When an author uses a control-type ARIA role (like button), but then hides a native control-type inside,
+        AXPress needs to operate on the inside node if possible.
+
+        Test: accessibility/axpress-on-aria-button.html
+
+        * accessibility/AccessibilityNodeObject.cpp:
+        (WebCore::isNodeActionElement):
+        (WebCore::nativeActionElement):
+        (WebCore::AccessibilityNodeObject::actionElement):
+
 2013-10-07  Zan Dobersek  <zdober...@igalia.com>
 
         Unreviewed debug build fix for ports enabling the <template> element support.

Modified: trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp (157037 => 157038)


--- trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp	2013-10-07 14:51:30 UTC (rev 157037)
+++ trunk/Source/WebCore/accessibility/AccessibilityNodeObject.cpp	2013-10-07 15:10:15 UTC (rev 157038)
@@ -946,31 +946,49 @@
     return 0;
 }
 
+static bool isNodeActionElement(Node* node)
+{
+    if (isHTMLInputElement(node)) {
+        HTMLInputElement* input = toHTMLInputElement(node);
+        if (!input->isDisabledFormControl() && (input->isRadioButton() || input->isCheckbox() || input->isTextButton() || input->isFileUpload() || input->isImageButton()))
+            return true;
+    } else if (node->hasTagName(buttonTag) || node->hasTagName(selectTag))
+        return true;
+
+    return false;
+}
+    
+static Element* nativeActionElement(Node* start)
+{
+    if (!start)
+        return 0;
+    
+    // Do a deep-dive to see if any nodes should be used as the action element.
+    // We have to look at Nodes, since this method should only be called on objects that do not have children (like buttons).
+    // It solves the problem when authors put role="button" on a group and leave the actual button inside the group.
+    
+    for (Node* child = start->firstChild(); child; child = child->nextSibling()) {
+        if (isNodeActionElement(child))
+            return toElement(child);
+
+        if (Element* subChild = nativeActionElement(child))
+            return subChild;
+    }
+    return 0;
+}
+    
 Element* AccessibilityNodeObject::actionElement() const
 {
     Node* node = this->node();
     if (!node)
         return 0;
 
-    if (isHTMLInputElement(node)) {
-        HTMLInputElement* input = toHTMLInputElement(node);
-        if (!input->isDisabledFormControl() && (isCheckboxOrRadio() || input->isTextButton()))
-            return input;
-    } else if (node->hasTagName(buttonTag))
+    if (isNodeActionElement(node))
         return toElement(node);
-
-    if (isFileUploadButton())
-        return toElement(node);
-            
+    
     if (AccessibilityObject::isARIAInput(ariaRoleAttribute()))
         return toElement(node);
 
-    if (isImageButton())
-        return toElement(node);
-    
-    if (node->hasTagName(selectTag))
-        return toElement(node);
-
     switch (roleValue()) {
     case ButtonRole:
     case PopUpButtonRole:
@@ -980,6 +998,9 @@
     case MenuItemCheckboxRole:
     case MenuItemRadioRole:
     case ListItemRole:
+        // Check if the author is hiding the real control element inside the ARIA element.
+        if (Element* nativeElement = nativeActionElement(node))
+            return nativeElement;
         return toElement(node);
     default:
         break;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to