ARIA: support a way to create a static text object
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Dec 2009 02:04:50 +0000 (02:04 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Dec 2009 02:04:50 +0000 (02:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=32030

Reviewed by David Kilzer.

WebCore:

Test: accessibility/aria-text-role.html

* accessibility/AccessibilityObject.cpp:
(WebCore::createARIARoleMap):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::stringValue):
(WebCore::AccessibilityRenderObject::isDescendantOfBarrenParent):
(WebCore::AccessibilityRenderObject::accessibilityIsIgnored):
(WebCore::AccessibilityRenderObject::text):
* accessibility/AccessibilityRenderObject.h:

LayoutTests:

* accessibility/aria-text-role-expected.txt: Added.
* accessibility/aria-text-role.html: Added.
* platform/gtk/Skipped:
* platform/win/Skipped:

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

LayoutTests/ChangeLog
LayoutTests/accessibility/aria-text-role-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/aria-text-role.html [new file with mode: 0644]
LayoutTests/platform/gtk/Skipped
LayoutTests/platform/win/Skipped
WebCore/ChangeLog
WebCore/accessibility/AccessibilityObject.cpp
WebCore/accessibility/AccessibilityRenderObject.cpp
WebCore/accessibility/AccessibilityRenderObject.h

index 18d8bd9..4257e91 100644 (file)
@@ -1,3 +1,15 @@
+2009-12-01  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by David Kilzer.
+
+        ARIA: support a way to create a static text object
+        https://bugs.webkit.org/show_bug.cgi?id=32030
+
+        * accessibility/aria-text-role-expected.txt: Added.
+        * accessibility/aria-text-role.html: Added.
+        * platform/gtk/Skipped:
+        * platform/win/Skipped:
+
 2009-12-01  Nikolas Zimmermann  <nzimmermann@rim.com>
 
         Reviewed by Simon Fraser.
diff --git a/LayoutTests/accessibility/aria-text-role-expected.txt b/LayoutTests/accessibility/aria-text-role-expected.txt
new file mode 100644 (file)
index 0000000..1144a84
--- /dev/null
@@ -0,0 +1,13 @@
+hello world this is a test more test
+This tests that you can set an ARIA text role and that it will not have children through hit testing
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS textrole.role is 'AXRole: AXStaticText'
+PASS textrole.stringValue is 'AXValue: all at once'
+PASS textrole.elementAtPoint(x, y).isEqual(textrole) is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/aria-text-role.html b/LayoutTests/accessibility/aria-text-role.html
new file mode 100644 (file)
index 0000000..61906d3
--- /dev/null
@@ -0,0 +1,43 @@
+<!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">
+
+<div id="textrole" tabindex=0 role="text" aria-label="all at once">
+<b>hello world</b>
+<i>this is a test</i>
+<a href="#">more test</a>
+</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that you can set an ARIA text role and that it will not have children through hit testing");
+
+    if (window.accessibilityController) {
+
+        document.getElementById("textrole").focus();
+        var textrole = accessibilityController.focusedElement;
+        shouldBe("textrole.role", "'AXRole: AXStaticText'");
+        shouldBe("textrole.stringValue", "'AXValue: all at once'");
+
+        // now check the hit-testing
+        var x = textrole.clickPointX;
+        var y = textrole.clickPointY;
+        shouldBe("textrole.elementAtPoint(x, y).isEqual(textrole)", "true");
+    }
+
+    successfullyParsed = true;
+</script>
+
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index 949f26f..b5f0ad3 100644 (file)
@@ -54,6 +54,7 @@ accessibility/aria-labelledby-stay-within.html
 accessibility/aria-link-supports-press.html
 accessibility/aria-readonly.html
 accessibility/aria-tab-roles.html
+accessibility/aria-text-role.html
 accessibility/aria-used-on-image-maps.html
 accessibility/button-press-action.html
 accessibility/canvas.html
index 3d485a1..0360a52 100644 (file)
@@ -372,6 +372,7 @@ accessibility/aria-readonly.html
 accessibility/aria-roles.html
 accessibility/aria-tables.html
 accessibility/aria-tab-roles.html
+accessibility/aria-text-role.html
 accessibility/aria-used-on-image-maps.html
 accessibility/button-press-action.html
 accessibility/canvas.html
index 857483c..bf01a2a 100644 (file)
@@ -1,3 +1,21 @@
+2009-12-01  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by David Kilzer.
+
+        ARIA: support a way to create a static text object
+        https://bugs.webkit.org/show_bug.cgi?id=32030
+
+        Test: accessibility/aria-text-role.html
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::createARIARoleMap):
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::stringValue):
+        (WebCore::AccessibilityRenderObject::isDescendantOfBarrenParent):
+        (WebCore::AccessibilityRenderObject::accessibilityIsIgnored):
+        (WebCore::AccessibilityRenderObject::text):
+        * accessibility/AccessibilityRenderObject.h:
+
 2009-12-01  Oliver Hunt  <oliver@apple.com>
 
         Reviewed by Maciej Stachowiak.
index a4f3400..a066f50 100644 (file)
@@ -905,6 +905,7 @@ static ARIARoleMap* createARIARoleMap()
         { "tab", TabRole },
         { "tablist", TabListRole },
         { "tabpanel", TabPanelRole },
+        { "text", StaticTextRole },
         { "textbox", TextAreaRole },
         { "timer", ApplicationTimerRole },
         { "toolbar", ToolbarRole },
index 41f155f..cc58e38 100644 (file)
@@ -860,6 +860,9 @@ String AccessibilityRenderObject::stringValue() const
     if (!m_renderer || isPasswordField())
         return String();
     
+    if (ariaRoleAttribute() == StaticTextRole)
+        return text();
+        
     if (m_renderer->isText())
         return textUnderElement();
     
@@ -1357,6 +1360,16 @@ bool AccessibilityRenderObject::ariaIsHidden() const
     return false;
 }
 
+bool AccessibilityRenderObject::isDescendantOfBarrenParent() const
+{
+    for (AccessibilityObject* object = parentObject(); object; object = object->parentObject()) {
+        if (!object->canHaveChildren())
+            return true;
+    }
+    
+    return false;
+}
+    
 bool AccessibilityRenderObject::accessibilityIsIgnored() const
 {
     // Is the platform interested in this object?
@@ -1377,6 +1390,10 @@ bool AccessibilityRenderObject::accessibilityIsIgnored() const
     if (isPresentationalChildOfAriaRole())
         return true;
         
+    // If this element is within a parent that cannot have children, it should not be exposed.
+    if (isDescendantOfBarrenParent())
+        return true;    
+    
     if (roleValue() == IgnoredRole)
         return true;
     
@@ -1489,6 +1506,10 @@ int AccessibilityRenderObject::layoutCount() const
 
 String AccessibilityRenderObject::text() const
 {
+    // If this is a user defined static text, use the accessible name computation.
+    if (ariaRoleAttribute() == StaticTextRole)
+        return accessibilityDescription();
+    
     if (!isTextControl() || isPasswordField())
         return String();
     
index 859aee1..27cd49e 100644 (file)
@@ -256,6 +256,7 @@ private:
     void ariaListboxSelectedChildren(AccessibilityChildrenVector&);
     void ariaListboxVisibleChildren(AccessibilityChildrenVector&);
     bool ariaIsHidden() const;
+    bool isDescendantOfBarrenParent() const;
     bool hasTextAlternative() const;
     String positionalDescriptionForMSAA() const;