AX: when an element uses role="text" but no aria-label, it should default to textUnde...
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Jul 2010 19:47:56 +0000 (19:47 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Jul 2010 19:47:56 +0000 (19:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=41780

Reviewed by Beth Dakin.

WebCore:

Test: platform/mac/accessibility/static-text-role-uses-text-under-element.html

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::stringValue):
   Fallback to textUnderElement() if text() does not return any explicitly set text.
(WebCore::AccessibilityRenderObject::accessibilityIsIgnored):
   Remove erroneous check to ignore text elements that didn't have a explicit text value.

LayoutTests:

* platform/mac/accessibility/static-text-role-uses-text-under-element-expected.txt: Added.
* platform/mac/accessibility/static-text-role-uses-text-under-element.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/platform/mac/accessibility/static-text-role-uses-text-under-element-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/static-text-role-uses-text-under-element.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/accessibility/AccessibilityRenderObject.cpp

index 30fa242..0dde776 100644 (file)
@@ -1,3 +1,13 @@
+2010-07-07  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by Beth Dakin.
+
+        AX: when an element uses role="text" but no aria-label, it should default to textUnderElement()
+        https://bugs.webkit.org/show_bug.cgi?id=41780
+
+        * platform/mac/accessibility/static-text-role-uses-text-under-element-expected.txt: Added.
+        * platform/mac/accessibility/static-text-role-uses-text-under-element.html: Added.
+
 2010-07-07  Alexey Proskuryakov  <ap@apple.com>
 
         Not reviewed, just updating test expectations.
diff --git a/LayoutTests/platform/mac/accessibility/static-text-role-uses-text-under-element-expected.txt b/LayoutTests/platform/mac/accessibility/static-text-role-uses-text-under-element-expected.txt
new file mode 100644 (file)
index 0000000..d0b7c56
--- /dev/null
@@ -0,0 +1,11 @@
+Text 1 Text 2 Text 3
+This tests that if an element uses the 'text' role but does not use an aria-label, it can retrieve the text inside of it.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS text.stringValue is 'AXValue: Text 1 Text 2 Text 3'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/mac/accessibility/static-text-role-uses-text-under-element.html b/LayoutTests/platform/mac/accessibility/static-text-role-uses-text-under-element.html
new file mode 100644 (file)
index 0000000..9eea6f7
--- /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 src="../../../fast/js/resources/js-test-pre.js"></script>
+<script>
+var successfullyParsed = false;
+if (window.layoutTestController)
+   layoutTestController.dumpAsText();
+</script>
+</head>
+<body>
+
+<div role="text" tabindex=0 id='text1'>
+<a href="#name1" id="name1link">Text 1</a>
+<a href="#name2" id="name2link">Text 2</a>
+<span><b><span>Text 3</span></b></span>
+</div>
+
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that if an element uses the 'text' role but does not use an aria-label, it can retrieve the text inside of it.");
+
+    if (window.accessibilityController) {
+        document.getElementById("text1").focus();
+        var text = accessibilityController.focusedElement;
+        shouldBe("text.stringValue", "'AXValue: Text 1 Text 2 Text 3'");
+    }
+
+    successfullyParsed = true;
+</script>
+
+<script src="../../../fast/js/resources/js-test-post.js"></script>
+
+</body>
+</html>
+
index 6167152..0433962 100644 (file)
@@ -1,3 +1,18 @@
+2010-07-07  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by Beth Dakin.
+
+        AX: when an element uses role="text" but no aria-label, it should default to textUnderElement()
+        https://bugs.webkit.org/show_bug.cgi?id=41780
+
+        Test: platform/mac/accessibility/static-text-role-uses-text-under-element.html
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::stringValue):
+           Fallback to textUnderElement() if text() does not return any explicitly set text.
+        (WebCore::AccessibilityRenderObject::accessibilityIsIgnored): 
+           Remove erroneous check to ignore text elements that didn't have a explicit text value.
+
 2010-07-07  Simon Fraser  <simon.fraser@apple.com>
 
         Reviewed by Dan Bernstein.
index 1ef6e09..ea801a2 100644 (file)
@@ -1101,8 +1101,12 @@ String AccessibilityRenderObject::stringValue() const
     if (!m_renderer || isPasswordField())
         return String();
     
-    if (ariaRoleAttribute() == StaticTextRole)
-        return text();
+    if (ariaRoleAttribute() == StaticTextRole) {
+        String staticText = text();
+        if (!staticText.length())
+            staticText = textUnderElement();
+        return staticText;
+    }
         
     if (m_renderer->isText())
         return textUnderElement();
@@ -1754,12 +1758,6 @@ bool AccessibilityRenderObject::accessibilityIsIgnored() const
     if (controlObject && !controlObject->exposesTitleUIElement() && controlObject->isCheckboxOrRadio())
         return true;
         
-    AccessibilityRole ariaRole = ariaRoleAttribute();
-    if (ariaRole == TextAreaRole || ariaRole == StaticTextRole) {
-        String ariaText = text();
-        return ariaText.isNull() || ariaText.isEmpty();
-    }    
-    
     // NOTE: BRs always have text boxes now, so the text box check here can be removed
     if (m_renderer->isText()) {
         // static text beneath MenuItems and MenuButtons are just reported along with the menu item, so it's ignored on an individual level
@@ -1784,7 +1782,7 @@ bool AccessibilityRenderObject::accessibilityIsIgnored() const
     if (isControl())
         return false;
     
-    if (ariaRole != UnknownRole)
+    if (ariaRoleAttribute() != UnknownRole)
         return false;
 
     if (!helpText().isEmpty())