AX: Support time@datetime for verbosity clarification of dates, times, and durations
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 May 2017 22:52:36 +0000 (22:52 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 May 2017 22:52:36 +0000 (22:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=171498
<rdar://problem/12985540>

Reviewed by Joanmarie Diggs.

Source/WebCore:

Expose the datetime attribute value.

Test: accessibility/datetime-attribute.html

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::datetimeAttributeValue):
* accessibility/AccessibilityObject.h:
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored):
(WebCore::AccessibilityRenderObject::determineAccessibilityRole):
* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper determineIsAccessibilityElement]):
(-[WebAccessibilityObjectWrapper accessibilityDatetimeValue]):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper additionalAccessibilityAttributeNames]):
(createAccessibilityRoleMap):
(-[WebAccessibilityObjectWrapper subrole]):
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):

LayoutTests:

* accessibility/datetime-attribute.html: Added.
* accessibility/roles-computedRoleString-expected.txt:
* platform/gtk/accessibility/datetime-attribute-expected.txt: Added.
* platform/gtk/accessibility/roles-exposed-expected.txt:
* platform/mac/accessibility/datetime-attribute-expected.txt: Added.
* platform/mac/accessibility/roles-computedRoleString-expected.txt:
* platform/mac/accessibility/roles-exposed-expected.txt:

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

14 files changed:
LayoutTests/ChangeLog
LayoutTests/accessibility/datetime-attribute.html [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/datetime-attribute-expected.txt [new file with mode: 0644]
LayoutTests/platform/gtk/accessibility/roles-exposed-expected.txt
LayoutTests/platform/mac/accessibility/datetime-attribute-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/roles-computedRoleString-expected.txt
LayoutTests/platform/mac/accessibility/roles-exposed-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp
Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm

index d79d717..4d8d512 100644 (file)
@@ -1,3 +1,19 @@
+2017-05-01  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Support time@datetime for verbosity clarification of dates, times, and durations
+        https://bugs.webkit.org/show_bug.cgi?id=171498
+        <rdar://problem/12985540>
+
+        Reviewed by Joanmarie Diggs.
+
+        * accessibility/datetime-attribute.html: Added.
+        * accessibility/roles-computedRoleString-expected.txt:
+        * platform/gtk/accessibility/datetime-attribute-expected.txt: Added.
+        * platform/gtk/accessibility/roles-exposed-expected.txt:
+        * platform/mac/accessibility/datetime-attribute-expected.txt: Added.
+        * platform/mac/accessibility/roles-computedRoleString-expected.txt:
+        * platform/mac/accessibility/roles-exposed-expected.txt:
+
 2017-05-01  Matt Lewis  <jlewis3@apple.com>
 
         Marked fast/mediastream/getUserMedia-webaudio.html as flaky timeout.
diff --git a/LayoutTests/accessibility/datetime-attribute.html b/LayoutTests/accessibility/datetime-attribute.html
new file mode 100644 (file)
index 0000000..7847423
--- /dev/null
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../resources/js-test-pre.js"></script>
+<script src="../resources/accessibility-helper.js"></script>
+</head>
+<body id="body">
+
+<time id="timeElement" datetime="P15H10M">15 hrs, 10 min</time>
+
+<p id="description"></p>
+<div id="console"></div>
+<script>
+    description("This tests that items with aria-selected are reported as selected children of the parent container.");
+
+    if (window.accessibilityController) {
+        var timeElement = accessibilityController.accessibleElementById("timeElement");
+        debug("Time 'role': " + timeElement.role);
+        debug("Time 'subrole': " + timeElement.subrole);
+        debug("Time 'value': " + timeElement.stringAttributeValue('AXDateTimeValue'));
+    }
+</script>
+
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/platform/gtk/accessibility/datetime-attribute-expected.txt b/LayoutTests/platform/gtk/accessibility/datetime-attribute-expected.txt
new file mode 100644 (file)
index 0000000..d9f4c47
--- /dev/null
@@ -0,0 +1,13 @@
+15 hrs, 10 min
+This tests that items with aria-selected are reported as selected children of the parent container.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Time 'role': AXRole: AXStatic
+Time 'subrole': 
+Time 'value': 
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
index 95b8e5b..dc3ecb0 100644 (file)
@@ -431,7 +431,7 @@ textarea
       AXRole: AXTextField
       
 time:not([datetime])
-      AXRole: 
+      AXRole: AXStatic
       
 time[datetime]
       AXRole: AXStatic
diff --git a/LayoutTests/platform/mac/accessibility/datetime-attribute-expected.txt b/LayoutTests/platform/mac/accessibility/datetime-attribute-expected.txt
new file mode 100644 (file)
index 0000000..e9fcdb5
--- /dev/null
@@ -0,0 +1,13 @@
+15 hrs, 10 min
+This tests that items with aria-selected are reported as selected children of the parent container.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Time 'role': AXRole: AXGroup
+Time 'subrole': AXSubrole: AXTimeGroup
+Time 'value': P15H10M
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
index 80b422b..45a8847 100644 (file)
@@ -78,6 +78,7 @@ PASS: td[role="gridcell"] -> gridcell.
 PASS: tr -> row. 
 PASS: td[role="gridcell"] -> gridcell. 
 PASS: textarea -> textbox. 
+PASS: time -> . 
 PASS: ul -> list. 
 PASS: li -> listitem. 
 PASS: var -> . 
index 7624766..c7b2451 100644 (file)
@@ -720,14 +720,14 @@ textarea
       AXRoleDescription: text entry area
       
 time:not([datetime])
-      AXRole: 
-      AXSubrole: 
-      AXRoleDescription: 
+      AXRole: AXGroup
+      AXSubrole: AXTimeGroup
+      AXRoleDescription: group
       
 time[datetime]
-      AXRole: 
-      AXSubrole: 
-      AXRoleDescription: 
+      AXRole: AXGroup
+      AXSubrole: AXTimeGroup
+      AXRoleDescription: group
       
 ul
       AXRole: AXList
index 994c100..9958f93 100644 (file)
@@ -1,3 +1,30 @@
+2017-05-01  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Support time@datetime for verbosity clarification of dates, times, and durations
+        https://bugs.webkit.org/show_bug.cgi?id=171498
+        <rdar://problem/12985540>
+
+        Reviewed by Joanmarie Diggs.
+
+        Expose the datetime attribute value.
+
+        Test: accessibility/datetime-attribute.html
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::datetimeAttributeValue):
+        * accessibility/AccessibilityObject.h:
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored):
+        (WebCore::AccessibilityRenderObject::determineAccessibilityRole):
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (-[WebAccessibilityObjectWrapper determineIsAccessibilityElement]):
+        (-[WebAccessibilityObjectWrapper accessibilityDatetimeValue]):
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper additionalAccessibilityAttributeNames]):
+        (createAccessibilityRoleMap):
+        (-[WebAccessibilityObjectWrapper subrole]):
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
+
 2017-05-01  Joseph Pecoraro  <pecoraro@apple.com>
 
         RejectedPromiseTracker should produce better callstacks and avoid capturing callstacks unless there is a debugger/inspector
index d393e6d..e90c5d9 100644 (file)
@@ -2380,6 +2380,11 @@ bool AccessibilityObject::supportsDatetimeAttribute() const
     return hasTagName(insTag) || hasTagName(delTag) || hasTagName(timeTag);
 }
 
+const AtomicString& AccessibilityObject::datetimeAttributeValue() const
+{
+    return getAttribute(datetimeAttr);
+}
+    
 Element* AccessibilityObject::element() const
 {
     Node* node = this->node();
index 21e9c22..2d1df21 100644 (file)
@@ -217,6 +217,7 @@ enum AccessibilityRole {
     TextAreaRole,
     TextGroupRole,
     TermRole,
+    TimeRole,
     TreeRole,
     TreeGridRole,
     TreeItemRole,
@@ -623,7 +624,8 @@ public:
     bool hasHighlighting() const;
 
     bool supportsDatetimeAttribute() const;
-
+    const AtomicString& datetimeAttributeValue() const;
+    
     virtual bool canSetFocusAttribute() const { return false; }
     virtual bool canSetTextRangeAttributes() const { return false; }
     virtual bool canSetValueAttribute() const { return false; }
index b55f3b5..e4ad98c 100644 (file)
@@ -1260,6 +1260,7 @@ bool AccessibilityRenderObject::computeAccessibilityIsIgnored() const
     case DocumentArticleRole:
     case LandmarkRegionRole:
     case ListItemRole:
+    case TimeRole:
     case VideoRole:
         return false;
     default:
@@ -2796,6 +2797,9 @@ AccessibilityRole AccessibilityRenderObject::determineAccessibilityRole()
     if (node && node->hasTagName(menuTag) && equalLettersIgnoringASCIICase(getAttribute(typeAttr), "toolbar"))
         return ToolbarRole;
     
+    if (node && node->hasTagName(timeTag))
+        return TimeRole;
+    
     // If the element does not have role, but it has ARIA attributes, or accepts tab focus, accessibility should fallback to exposing it as a group.
     if (supportsARIAAttributes() || canSetFocusAttribute())
         return GroupRole;
index 6fd98ae..52bf8c7 100644 (file)
@@ -730,6 +730,7 @@ static AtkRole atkRole(AccessibilityObject* coreObject)
         return ATK_ROLE_STATIC;
     case SVGTextPathRole:
     case SVGTSpanRole:
+    case TimeRole:
         return ATK_ROLE_STATIC;
 #endif
     default:
index 130ffcb..62bd9a5 100644 (file)
@@ -935,6 +935,7 @@ static AccessibilityObjectWrapper* AccessibilityUnignoredAncestor(AccessibilityO
         case TableHeaderContainerRole:
         case TermRole:
         case TextGroupRole:
+        case TimeRole:
         case TreeRole:
         case TreeItemRole:
         case TreeGridRole:
@@ -1276,6 +1277,17 @@ static void appendStringToResult(NSMutableString *result, NSString *string)
     return m_object->blockquoteLevel();
 }
 
+- (NSString *)accessibilityDatetimeValue
+{
+    if (![self _prepareAccessibilityCall])
+        return nil;
+    
+    if (auto parent = AccessibilityObject::matchedParent(*m_object, true, [] (const AccessibilityObject& object) { return object.supportsDatetimeAttribute(); }))
+        return parent->datetimeAttributeValue();
+
+    return nil;
+}
+
 - (NSString *)accessibilityPlaceholderValue
 {
     if (![self _prepareAccessibilityCall])
index 7a566da..f815795 100644 (file)
@@ -188,6 +188,10 @@ using namespace HTMLNames;
 #define NSAccessibilityGrabbedAttribute @"AXGrabbed"
 #endif
 
+#ifndef NSAccessibilityDatetimeValueAttribute
+#define NSAccessibilityDatetimeValueAttribute @"AXDateTimeValue"
+#endif
+
 #ifndef NSAccessibilityDropEffectsAttribute
 #define NSAccessibilityDropEffectsAttribute @"AXDropEffects"
 #endif
@@ -1170,6 +1174,9 @@ static id textMarkerRangeFromVisiblePositions(AXObjectCache* cache, const Visibl
         [additional addObject:NSAccessibilityValueAttribute];
     }
 
+    if (m_object->supportsDatetimeAttribute())
+        [additional addObject:NSAccessibilityDatetimeValueAttribute];
+    
     if (m_object->supportsRequiredAttribute()) {
         [additional addObject:NSAccessibilityRequiredAttribute];
     }
@@ -1934,6 +1941,7 @@ static const AccessibilityRoleMap& createAccessibilityRoleMap()
         { SVGTSpanRole, NSAccessibilityGroupRole },
         { InlineRole, NSAccessibilityGroupRole },
         { MarkRole, NSAccessibilityGroupRole },
+        { TimeRole, NSAccessibilityGroupRole },
         { FeedRole, NSAccessibilityGroupRole },
         { FigureRole, NSAccessibilityGroupRole },
     };
@@ -2132,7 +2140,9 @@ static NSString* roleValueToNSString(AccessibilityRole value)
         return @"AXDetails";
     if (role == SummaryRole)
         return @"AXSummary";
-    
+    if (role == TimeRole)
+        return @"AXTimeGroup";
+
     if (m_object->isMediaTimeline())
         return NSAccessibilityTimelineSubrole;
 
@@ -3042,7 +3052,10 @@ static NSString* roleValueToNSString(AccessibilityRole value)
 
     if ([attributeName isEqualToString:NSAccessibilityHasPopupAttribute])
         return [NSNumber numberWithBool:m_object->ariaHasPopup()];
-    
+
+    if ([attributeName isEqualToString:NSAccessibilityDatetimeValueAttribute])
+        return m_object->datetimeAttributeValue();
+
     // ARIA Live region attributes.
     if ([attributeName isEqualToString:NSAccessibilityARIALiveAttribute])
         return m_object->ariaLiveRegionStatus();