AX: Support aria-posinset/setsize
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Mar 2013 01:47:47 +0000 (01:47 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Mar 2013 01:47:47 +0000 (01:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=109725

Reviewed by Tim Horton.

Source/WebCore:

Expose aria-setsize and aria-posinset through accessibility.
Right now only the Mac platform exposes them.

Test: platform/mac/accessibility/aria-setsize-posinset.html

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::supportsARIASetSize):
(WebCore):
(WebCore::AccessibilityObject::supportsARIAPosInset):
(WebCore::AccessibilityObject::ariaSetSize):
(WebCore::AccessibilityObject::ariaPosInset):
* accessibility/AccessibilityObject.h:
(AccessibilityObject):
* accessibility/mac/WebAccessibilityObjectWrapper.mm:
(-[WebAccessibilityObjectWrapper additionalAccessibilityAttributeNames]):
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
* html/HTMLAttributeNames.in:

LayoutTests:

* platform/mac/accessibility/aria-setsize-posinset-expected.txt: Added.
* platform/mac/accessibility/aria-setsize-posinset.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/platform/mac/accessibility/aria-setsize-posinset-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/aria-setsize-posinset.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
Source/WebCore/html/HTMLAttributeNames.in

index b6167ce..d2d7b79 100644 (file)
@@ -1,3 +1,13 @@
+2013-03-05  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Support aria-posinset/setsize
+        https://bugs.webkit.org/show_bug.cgi?id=109725
+
+        Reviewed by Tim Horton.
+
+        * platform/mac/accessibility/aria-setsize-posinset-expected.txt: Added.
+        * platform/mac/accessibility/aria-setsize-posinset.html: Added.
+
 2013-03-05  Emil A Eklund  <eae@chromium.org>
 
         Unreviewed apple rebaselines for r144837.
diff --git a/LayoutTests/platform/mac/accessibility/aria-setsize-posinset-expected.txt b/LayoutTests/platform/mac/accessibility/aria-setsize-posinset-expected.txt
new file mode 100644 (file)
index 0000000..d8c39a0
--- /dev/null
@@ -0,0 +1,18 @@
+This tests verifies that aria-posinset and aria-setsize are exposed to accessibility correctly.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Verify that the first item in the list exposes setsize and posinset attributes.
+PASS list.childAtIndex(0).isAttributeSupported('AXARIASetSize') is true
+PASS list.childAtIndex(0).isAttributeSupported('AXARIAPosInSet') is true
+Verify that the first item in the list returns the correct value for setsize and posinset.
+PASS list.childAtIndex(0).numberAttributeValue('AXARIASetSize') is 100
+PASS list.childAtIndex(0).numberAttributeValue('AXARIAPosInSet') is 3
+Verify that the second item in the list does not support setsize and posinset.
+PASS list.childAtIndex(1).isAttributeSupported('AXARIASetSize') is false
+PASS list.childAtIndex(1).isAttributeSupported('AXARIAPosInSet') is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/mac/accessibility/aria-setsize-posinset.html b/LayoutTests/platform/mac/accessibility/aria-setsize-posinset.html
new file mode 100644 (file)
index 0000000..249f543
--- /dev/null
@@ -0,0 +1,43 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+
+<ul id="list">
+<li aria-setsize="100" aria-posinset="3">3</li>
+<li>4</li>
+</ul>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests verifies that aria-posinset and aria-setsize are exposed to accessibility correctly.");
+
+    if (window.accessibilityController) {
+
+          var list = accessibilityController.accessibleElementById("list");
+
+          debug("Verify that the first item in the list exposes setsize and posinset attributes.");
+          shouldBeTrue("list.childAtIndex(0).isAttributeSupported('AXARIASetSize')");
+          shouldBeTrue("list.childAtIndex(0).isAttributeSupported('AXARIAPosInSet')");
+
+          debug("Verify that the first item in the list returns the correct value for setsize and posinset.");
+          shouldBe("list.childAtIndex(0).numberAttributeValue('AXARIASetSize')", "100");
+          shouldBe("list.childAtIndex(0).numberAttributeValue('AXARIAPosInSet')", "3");
+
+          debug("Verify that the second item in the list does not support setsize and posinset.");
+          shouldBeFalse("list.childAtIndex(1).isAttributeSupported('AXARIASetSize')");
+          shouldBeFalse("list.childAtIndex(1).isAttributeSupported('AXARIAPosInSet')");
+
+          document.getElementById("list").style.visibility = 'hidden';
+    }
+
+</script>
+
+<script src="../../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index 6c3fbc9..a905d2f 100644 (file)
@@ -1,3 +1,29 @@
+2013-03-05  Chris Fleizach  <cfleizach@apple.com>
+        AX: Support aria-posinset/setsize
+        https://bugs.webkit.org/show_bug.cgi?id=109725
+
+        Reviewed by Tim Horton.
+
+        Expose aria-setsize and aria-posinset through accessibility.
+        Right now only the Mac platform exposes them.
+
+        Test: platform/mac/accessibility/aria-setsize-posinset.html
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::supportsARIASetSize):
+        (WebCore):
+        (WebCore::AccessibilityObject::supportsARIAPosInset):
+        (WebCore::AccessibilityObject::ariaSetSize):
+        (WebCore::AccessibilityObject::ariaPosInset):
+        * accessibility/AccessibilityObject.h:
+        (AccessibilityObject):
+        * accessibility/mac/WebAccessibilityObjectWrapper.mm:
+        (-[WebAccessibilityObjectWrapper additionalAccessibilityAttributeNames]):
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
+        * html/HTMLAttributeNames.in:
+
+
 2013-03-05  Peter Nelson  <peter@peterdn.com>
 
         [WinCairo] Support for cookies is incomplete
index be8c4ae..441cc3e 100644 (file)
@@ -1586,6 +1586,26 @@ bool AccessibilityObject::supportsRangeValue() const
         || isSpinButton();
 }
     
+bool AccessibilityObject::supportsARIASetSize() const
+{
+    return hasAttribute(aria_setsizeAttr);
+}
+
+bool AccessibilityObject::supportsARIAPosInSet() const
+{
+    return hasAttribute(aria_posinsetAttr);
+}
+    
+int AccessibilityObject::ariaSetSize() const
+{
+    return getAttribute(aria_setsizeAttr).toInt();
+}
+
+int AccessibilityObject::ariaPosInSet() const
+{
+    return getAttribute(aria_posinsetAttr).toInt();
+}
+    
 bool AccessibilityObject::supportsARIAExpanded() const
 {
     return !getAttribute(aria_expandedAttr).isEmpty();
index 0089cf1..0e0bcfa 100644 (file)
@@ -514,6 +514,11 @@ public:
     AccessibilitySortDirection sortDirection() const;
     virtual bool canvasHasFallbackContent() const { return false; }
     bool supportsRangeValue() const;
+
+    bool supportsARIASetSize() const;
+    bool supportsARIAPosInSet() const;
+    int ariaSetSize() const;
+    int ariaPosInSet() const;
     
     // ARIA drag and drop
     virtual bool supportsARIADropping() const { return false; }
index 6b04f24..6c3b143 100644 (file)
@@ -164,6 +164,14 @@ using namespace std;
 #define NSAccessibilityARIABusyAttribute @"AXARIABusy"
 #endif
 
+#ifndef NSAccessibilityARIAPosInSetAttribute
+#define NSAccessibilityARIAPosInSetAttribute @"AXARIAPosInSet"
+#endif
+
+#ifndef NSAccessibilityARIASetSizeAttribute
+#define NSAccessibilityARIASetSizeAttribute @"AXARIASetSize"
+#endif
+
 #ifndef NSAccessibilityLoadingProgressAttribute
 #define NSAccessibilityLoadingProgressAttribute @"AXLoadingProgress"
 #endif
@@ -971,6 +979,11 @@ static id textMarkerRangeFromVisiblePositions(AXObjectCache *cache, VisiblePosit
         [additional addObject:NSAccessibilityARIARelevantAttribute];
     }
     
+    if (m_object->supportsARIASetSize())
+        [additional addObject:NSAccessibilityARIASetSizeAttribute];
+    if (m_object->supportsARIAPosInSet())
+        [additional addObject:NSAccessibilityARIAPosInSetAttribute];
+    
     if (m_object->sortDirection() != SortDirectionNone)
         [additional addObject:NSAccessibilitySortDirectionAttribute];
     
@@ -2577,6 +2590,11 @@ static NSString* roleValueToNSString(AccessibilityRole value)
         return convertToNSArray(ariaOwns);
     }
     
+    if ([attributeName isEqualToString:NSAccessibilityARIAPosInSetAttribute])
+        return [NSNumber numberWithInt:m_object->ariaPosInSet()];
+    if ([attributeName isEqualToString:NSAccessibilityARIASetSizeAttribute])
+        return [NSNumber numberWithInt:m_object->ariaSetSize()];
+    
     if ([attributeName isEqualToString:NSAccessibilityGrabbedAttribute])
         return [NSNumber numberWithBool:m_object->isARIAGrabbed()];
     
index 7146ec4..154c033 100644 (file)
@@ -37,11 +37,13 @@ aria-multiline
 aria-multiselectable
 aria-orientation
 aria-owns
+aria-posinset
 aria-pressed
 aria-readonly
 aria-relevant
 aria-required
 aria-selected
+aria-setsize
 aria-sort
 aria-valuemax
 aria-valuemin