AX: no accessibility support for details element
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Jun 2015 18:39:20 +0000 (18:39 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Jun 2015 18:39:20 +0000 (18:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=131111

Reviewed by Darin Adler.

Source/WebCore:

Add accessibility support for Mac for details element by:
   1) Returning new subroles for <details> and <summary>
   2) Exposing isExpanded property for <details> element.

Test: platform/mac/accessibility/details-summary.html

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::supportsARIAPressed):
(WebCore::AccessibilityObject::supportsExpanded):
(WebCore::AccessibilityObject::isExpanded):
(WebCore::AccessibilityObject::supportsARIAExpanded): Deleted.
* accessibility/AccessibilityObject.h:
(WebCore::AccessibilityObject::canvasHasFallbackContent):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored):
(WebCore::AccessibilityRenderObject::determineAccessibilityRole):
* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper accessibilitySupportsARIAExpanded]):
(-[WebAccessibilityObjectWrapper accessibilityIsExpanded]):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper additionalAccessibilityAttributeNames]):
(createAccessibilityRoleMap):
(-[WebAccessibilityObjectWrapper subrole]):
* html/HTMLDetailsElement.h:
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::buildObjectForAccessibilityProperties):

LayoutTests:

* platform/mac/accessibility/details-summary-expected.txt: Added.
* platform/mac/accessibility/details-summary.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/platform/mac/accessibility/details-summary-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/details-summary.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
Source/WebCore/html/HTMLDetailsElement.h
Source/WebCore/inspector/InspectorDOMAgent.cpp

index c6f1eac..d176ce4 100644 (file)
@@ -1,3 +1,13 @@
+2015-06-15  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: no accessibility support for details element
+        https://bugs.webkit.org/show_bug.cgi?id=131111
+
+        Reviewed by Darin Adler.
+
+        * platform/mac/accessibility/details-summary-expected.txt: Added.
+        * platform/mac/accessibility/details-summary.html: Added.
+
 2015-06-13  Chris Fleizach  <cfleizach@apple.com>
 
         AX: WebKit exposes all Ruby Text as Unknown (Japanese EPUB accessibility blocker)
diff --git a/LayoutTests/platform/mac/accessibility/details-summary-expected.txt b/LayoutTests/platform/mac/accessibility/details-summary-expected.txt
new file mode 100644 (file)
index 0000000..9af177f
--- /dev/null
@@ -0,0 +1,20 @@
+Some open info
+Details about the open topic.
+
+Some open info
+This tests some basic attributes about the details element.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS details1.role is 'AXRole: AXGroup'
+PASS details1.subrole is 'AXSubrole: AXDetails'
+PASS details1.isExpanded is true
+PASS details1.childAtIndex(0).role is 'AXRole: AXGroup'
+PASS details1.childAtIndex(0).subrole is 'AXSubrole: AXSummary'
+PASS details2.subrole is 'AXSubrole: AXDetails'
+PASS details2.isExpanded is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/mac/accessibility/details-summary.html b/LayoutTests/platform/mac/accessibility/details-summary.html
new file mode 100644 (file)
index 0000000..44dd166
--- /dev/null
@@ -0,0 +1,43 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+
+<details open id="details1">
+  <summary>Some open info</summary>
+  <p>Details about the open topic.</p>
+</details>
+
+<details id="details2">
+  <summary>Some open info</summary>
+  <p>Details about the open topic.</p>
+</details>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests some basic attributes about the details element.");
+
+    if (window.accessibilityController) {
+
+        var details1 = accessibilityController.accessibleElementById("details1");
+        shouldBe("details1.role", "'AXRole: AXGroup'");
+        shouldBe("details1.subrole", "'AXSubrole: AXDetails'");
+        shouldBeTrue("details1.isExpanded");
+        shouldBe("details1.childAtIndex(0).role", "'AXRole: AXGroup'");
+        shouldBe("details1.childAtIndex(0).subrole", "'AXSubrole: AXSummary'");
+
+        var details2 = accessibilityController.accessibleElementById("details2");
+        shouldBe("details2.subrole", "'AXSubrole: AXDetails'");
+        shouldBeFalse("details2.isExpanded");
+    }
+
+</script>
+
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
index dc548a4..aab0266 100644 (file)
@@ -1,3 +1,37 @@
+2015-06-15  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: no accessibility support for details element
+        https://bugs.webkit.org/show_bug.cgi?id=131111
+
+        Reviewed by Darin Adler.
+
+        Add accessibility support for Mac for details element by:
+           1) Returning new subroles for <details> and <summary>
+           2) Exposing isExpanded property for <details> element.
+
+        Test: platform/mac/accessibility/details-summary.html
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::supportsARIAPressed):
+        (WebCore::AccessibilityObject::supportsExpanded):
+        (WebCore::AccessibilityObject::isExpanded):
+        (WebCore::AccessibilityObject::supportsARIAExpanded): Deleted.
+        * accessibility/AccessibilityObject.h:
+        (WebCore::AccessibilityObject::canvasHasFallbackContent):
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored):
+        (WebCore::AccessibilityRenderObject::determineAccessibilityRole):
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (-[WebAccessibilityObjectWrapper accessibilitySupportsARIAExpanded]):
+        (-[WebAccessibilityObjectWrapper accessibilityIsExpanded]):
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper additionalAccessibilityAttributeNames]):
+        (createAccessibilityRoleMap):
+        (-[WebAccessibilityObjectWrapper subrole]):
+        * html/HTMLDetailsElement.h:
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::buildObjectForAccessibilityProperties):
+
 2015-06-15  Alex Christensen  <achristensen@webkit.org>
 
         [Content Extensions] Limit number of rules.
index 023e895..293557d 100644 (file)
@@ -41,6 +41,7 @@
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "FrameSelection.h"
+#include "HTMLDetailsElement.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "HTMLParserIdioms.h"
@@ -2219,7 +2220,7 @@ bool AccessibilityObject::supportsARIAPressed() const
     return equalIgnoringCase(expanded, "true") || equalIgnoringCase(expanded, "false");
 }
     
-bool AccessibilityObject::supportsARIAExpanded() const
+bool AccessibilityObject::supportsExpanded() const
 {
     // Undefined values should not result in this attribute being exposed to ATs according to ARIA.
     const AtomicString& expanded = getAttribute(aria_expandedAttr);
@@ -2228,6 +2229,7 @@ bool AccessibilityObject::supportsARIAExpanded() const
     switch (roleValue()) {
     case ComboBoxRole:
     case DisclosureTriangleRole:
+    case DetailsRole:
         return true;
     default:
         return false;
@@ -2239,6 +2241,9 @@ bool AccessibilityObject::isExpanded() const
     if (equalIgnoringCase(getAttribute(aria_expandedAttr), "true"))
         return true;
     
+    if (is<HTMLDetailsElement>(node()))
+        return downcast<HTMLDetailsElement>(node())->isOpen();
+    
     return false;  
 }
 
index 330d88a..6cbd1a0 100644 (file)
@@ -118,6 +118,7 @@ enum AccessibilityRole {
     DescriptionListRole,
     DescriptionListTermRole,
     DescriptionListDetailRole,
+    DetailsRole,
     DirectoryRole,
     DisclosureTriangleRole,
     DivRole,
@@ -195,6 +196,7 @@ enum AccessibilityRole {
     SplitGroupRole,
     SplitterRole,
     StaticTextRole,
+    SummaryRole,
     SwitchRole,
     SystemWideRole,
     SVGRootRole,
@@ -612,7 +614,7 @@ public:
     bool ariaIsMultiline() const;
     String invalidStatus() const;
     bool supportsARIAPressed() const;
-    bool supportsARIAExpanded() const;
+    bool supportsExpanded() const;
     bool supportsChecked() const;
     AccessibilitySortDirection sortDirection() const;
     virtual bool canvasHasFallbackContent() const { return false; }
index e4474e9..9b5f024 100644 (file)
@@ -1256,6 +1256,7 @@ bool AccessibilityRenderObject::computeAccessibilityIsIgnored() const
     case AudioRole:
     case DescriptionListTermRole:
     case DescriptionListDetailRole:
+    case DetailsRole:
     case DocumentArticleRole:
     case DocumentRegionRole:
     case ListItemRole:
@@ -2651,6 +2652,11 @@ AccessibilityRole AccessibilityRenderObject::determineAccessibilityRole()
     if (node && node->hasTagName(preTag))
         return PreRole;
 
+    if (is<HTMLDetailsElement>(node))
+        return DetailsRole;
+    if (is<HTMLSummaryElement>(node))
+        return SummaryRole;
+
 #if ENABLE(VIDEO)
     if (is<HTMLVideoElement>(node))
         return VideoRole;
index 429ff18..8fc27e7 100644 (file)
@@ -2326,7 +2326,7 @@ static void AXAttributedStringAppendText(NSMutableAttributedString* attrString,
     if (![self _prepareAccessibilityCall])
         return NO;
     
-    return m_object->supportsARIAExpanded();
+    return m_object->supportsExpanded();
 }
 
 - (BOOL)accessibilityIsExpanded
index ff297cd..ae62876 100644 (file)
@@ -1214,7 +1214,7 @@ static id textMarkerRangeFromVisiblePositions(AXObjectCache *cache, const Visibl
     if (m_object->isToggleButton())
         [additional addObject:NSAccessibilityValueAttribute];
     
-    if (m_object->supportsARIAExpanded())
+    if (m_object->supportsExpanded())
         [additional addObject:NSAccessibilityExpandedAttribute];
     
     if (m_object->isScrollbar())
@@ -1985,6 +1985,8 @@ static const AccessibilityRoleMap& createAccessibilityRoleMap()
         { RubyInlineRole, NSAccessibilityGroupRole },
         { RubyRunRole, NSAccessibilityGroupRole },
         { RubyTextRole, NSAccessibilityGroupRole },
+        { DetailsRole, NSAccessibilityGroupRole },
+        { SummaryRole, NSAccessibilityGroupRole },
     };
     AccessibilityRoleMap& roleMap = *new AccessibilityRoleMap;
     
@@ -2161,6 +2163,10 @@ static NSString* roleValueToNSString(AccessibilityRole value)
         return @"AXVideo";
     if (role == AudioRole)
         return @"AXAudio";
+    if (role == DetailsRole)
+        return @"AXDetails";
+    if (role == SummaryRole)
+        return @"AXSummary";
     
     if (m_object->isMediaTimeline())
         return NSAccessibilityTimelineSubrole;
index 18d2655..4f594e1 100644 (file)
@@ -31,7 +31,8 @@ public:
     void toggleOpen();
 
     const Element* findMainSummary() const;
-
+    bool isOpen() const { return m_isOpen; }
+    
 private:
     HTMLDetailsElement(const QualifiedName&, Document&);
 
index 25e9ea1..c874715 100644 (file)
@@ -1510,7 +1510,7 @@ RefPtr<Inspector::Protocol::DOM::AccessibilityProperties> InspectorDOMAgent::bui
             disabled = !axObject->isEnabled(); 
             exists = true;
             
-            supportsExpanded = axObject->supportsARIAExpanded();
+            supportsExpanded = axObject->supportsExpanded();
             if (supportsExpanded)
                 expanded = axObject->isExpanded();