<hr> should expose AXRole/AXSubrole, etc
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Mar 2014 17:08:00 +0000 (17:08 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Mar 2014 17:08:00 +0000 (17:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=109015

Reviewed by Mario Sanchez Prada.

Source/WebCore:

Expose the <hr> element to Mac and iOS through the accessibility interface.

Test: platform/mac/accessibility/hr-element.html

* English.lproj/Localizable.strings:
* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::isEnabled):
* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::computedRoleString):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored):
* accessibility/atk/AccessibilityObjectAtk.cpp:
(WebCore::AccessibilityObject::accessibilityPlatformIncludesObject):
* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper determineIsAccessibilityElement]):
(-[WebAccessibilityObjectWrapper accessibilityLabel]):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(createAccessibilityRoleMap):
(-[WebAccessibilityObjectWrapper subrole]):
(-[WebAccessibilityObjectWrapper roleDescription]):
* platform/LocalizedStrings.cpp:
(WebCore::AXHorizontalRuleDescriptionText):
* platform/LocalizedStrings.h:

LayoutTests:

* accessibility/lists.html:
    - An errant <hr> element was in this test which changed results
* accessibility/roles-computedRoleString-expected.txt:
* accessibility/roles-exposed.html:
* platform/gtk/accessibility/roles-exposed-expected.txt: Added.
* platform/mac/accessibility/hr-element-expected.txt: Added.
* platform/mac/accessibility/hr-element.html: Added.
* platform/mac/accessibility/lists-expected.txt:
* platform/mac/accessibility/roles-exposed-expected.txt:

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

18 files changed:
LayoutTests/ChangeLog
LayoutTests/accessibility/lists.html
LayoutTests/accessibility/roles-computedRoleString-expected.txt
LayoutTests/accessibility/roles-exposed.html
LayoutTests/platform/mac/accessibility/hr-element-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/hr-element.html [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/lists-expected.txt
LayoutTests/platform/mac/accessibility/roles-exposed-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/English.lproj/Localizable.strings
Source/WebCore/accessibility/AccessibilityNodeObject.cpp
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/accessibility/atk/AccessibilityObjectAtk.cpp
Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
Source/WebCore/platform/LocalizedStrings.cpp
Source/WebCore/platform/LocalizedStrings.h

index ab5eb5e..df86393 100644 (file)
@@ -1,3 +1,20 @@
+2014-03-24  Chris Fleizach  <cfleizach@apple.com>
+
+        <hr> should expose AXRole/AXSubrole, etc
+        https://bugs.webkit.org/show_bug.cgi?id=109015
+
+        Reviewed by Mario Sanchez Prada.
+
+        * accessibility/lists.html:
+            - An errant <hr> element was in this test which changed results
+        * accessibility/roles-computedRoleString-expected.txt:
+        * accessibility/roles-exposed.html:
+        * platform/gtk/accessibility/roles-exposed-expected.txt: Added.
+        * platform/mac/accessibility/hr-element-expected.txt: Added.
+        * platform/mac/accessibility/hr-element.html: Added.
+        * platform/mac/accessibility/lists-expected.txt:
+        * platform/mac/accessibility/roles-exposed-expected.txt:
+
 2014-03-24  Antti Koivisto  <antti@apple.com>
 
         Invalidate sibling text node style when needed instead of attaching synchronously
index 72ab3d1..1c8951d 100644 (file)
@@ -25,7 +25,7 @@
       <dd>meaning 2</dd>
     </dl>
 
-    <BR><BR><BR><hr><BR>
+    <BR><BR><BR><BR>
     <div id="result"></div>    
 
     <script>
index d65616f..d7216a8 100644 (file)
@@ -19,6 +19,7 @@ PASS: h3 -> heading.
 PASS: h4 -> heading. 
 PASS: h5 -> heading. 
 PASS: h5 -> heading. 
+PASS: hr -> separator. 
 PASS: img[alt='X'] -> img. 
 PASS: input[type='button'] -> button. 
 PASS: input[type='checkbox'] -> checkbox. 
index de6100b..a0d9091 100644 (file)
@@ -50,7 +50,7 @@
 <h4 data-platform="atk,mac" data-role="AXHeading" data-subrole="" data-roledescription="heading" class="ex">X</h4>
 <h5 data-platform="atk,mac" data-role="AXHeading" data-subrole="" data-roledescription="heading" class="ex">X</h5>
 <h6 data-platform="atk,mac" data-role="AXHeading" data-subrole="" data-roledescription="heading" class="ex">X</h6>
-<!-- http://webkit.org/b/109015 --><hr data-platform="atk,mac" data-role="" data-role-atk="AXSeparator" data-subrole="" data-roledescription="" class="ex">
+<hr data-platform="atk,mac" data-role-mac="AXSplitter" data-role-atk="AXSeparator" data-subrole="AXContentSeparator" data-roledescription="separator" class="ex">
 <!-- skipped <html> -->
 <!-- [ATK] Skipped: not focusable --><i data-platform="mac" data-role="" data-subrole="" data-roledescription="" class="ex">X</i>
 <!-- skipped <iframe> -->
diff --git a/LayoutTests/platform/mac/accessibility/hr-element-expected.txt b/LayoutTests/platform/mac/accessibility/hr-element-expected.txt
new file mode 100644 (file)
index 0000000..91019e4
--- /dev/null
@@ -0,0 +1,30 @@
+This tests that the 'hr' element is accessible on the Mac.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+hr1 role: AXRole: AXSplitter
+hr1 subrole: AXSubrole: AXContentSeparator
+hr1 roleDescription: AXRoleDescription: separator
+hr1 description: AXDescription: 
+hr1 is value settable: false
+hr1 is enabled: false
+
+hr2 role: AXRole: AXSplitter
+hr2 subrole: AXSubrole: AXContentSeparator
+hr2 roleDescription: AXRoleDescription: separator
+hr2 description: AXDescription: 
+hr2 is value settable: false
+hr2 is enabled: false
+
+hr3 role: AXRole: AXSplitter
+hr3 subrole: AXSubrole: AXContentSeparator
+hr3 roleDescription: AXRoleDescription: separator
+hr3 description: AXDescription: RULER
+hr3 is value settable: false
+hr3 is enabled: false
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/mac/accessibility/hr-element.html b/LayoutTests/platform/mac/accessibility/hr-element.html
new file mode 100644 (file)
index 0000000..58adfda
--- /dev/null
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../../resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+
+<div id="content">
+<hr id="hr1" onclick="test();">
+
+<hr id="hr2">
+
+<hr id="hr3" aria-label="RULER" tabindex="0">
+</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that the 'hr' element is accessible on the Mac.");
+
+    if (window.accessibilityController) {
+
+        for (var k = 1; k <= 3; k++) {
+           var hr = accessibilityController.accessibleElementById("hr" + k);
+           debug("hr" + k + " role: " + hr.role);
+           debug("hr" + k + " subrole: " + hr.subrole);
+           debug("hr" + k + " roleDescription: " + hr.roleDescription);
+           debug("hr" + k + " description: " + hr.description);
+           debug("hr" + k + " is value settable: " + hr.isAttributeSettable('AXValue'));
+           debug("hr" + k + " is enabled: " + hr.isEnabled + "\n");
+        }
+        document.getElementById("content").style.visibility = "none";
+    }
+
+</script>
+
+<script src="../../../resources/js-test-post.js"></script>
+</body>
+</html>
index 56f27d5..a3f9cea 100644 (file)
@@ -110,35 +110,7 @@ AXRoleDescription: group
 AXChildren: <array of size 0>
 AXHelp: 
 AXParent: <AXGroup>
-AXSize: NSSize: {784, 54}
-AXTitle: 
-AXDescription: 
-AXValue: 
-AXFocused: 0
-AXEnabled: 1
-AXWindow: <AXGroup>
-AXSelectedTextMarkerRange: (null)
-AXStartTextMarker: <AXGroup>
-AXEndTextMarker: <AXGroup>
-AXVisited: 0
-AXLinkedUIElements: (null)
-AXSelected: 0
-AXBlockQuoteLevel: 0
-AXTopLevelUIElement: <AXGroup>
-AXLanguage: 
-AXDOMIdentifier: 
-AXDOMClassList: <array of size 0>
-AXTitleUIElement: (null)
-AXElementBusy: 0
-
-------------
-AXRole: AXGroup
-AXSubrole: (null)
-AXRoleDescription: group
-AXChildren: <array of size 0>
-AXHelp: 
-AXParent: <AXGroup>
-AXSize: NSSize: {784, 18}
+AXSize: NSSize: {784, 72}
 AXTitle: 
 AXDescription: 
 AXValue: 
index 109bda5..e4e66c7 100644 (file)
@@ -170,9 +170,9 @@ PASS: h6
       AXRoleDescription: heading
       
 PASS: hr
-      AXRole: 
-      AXSubrole: 
-      AXRoleDescription: 
+      AXRole: AXSplitter
+      AXSubrole: AXContentSeparator
+      AXRoleDescription: separator
       
 PASS: i
       AXRole: 
index 563e3c7..56b2b15 100644 (file)
@@ -1,3 +1,34 @@
+2014-03-24  Chris Fleizach  <cfleizach@apple.com>
+
+        <hr> should expose AXRole/AXSubrole, etc
+        https://bugs.webkit.org/show_bug.cgi?id=109015
+
+        Reviewed by Mario Sanchez Prada.
+
+        Expose the <hr> element to Mac and iOS through the accessibility interface.
+
+        Test: platform/mac/accessibility/hr-element.html
+
+        * English.lproj/Localizable.strings:
+        * accessibility/AccessibilityNodeObject.cpp:
+        (WebCore::AccessibilityNodeObject::isEnabled):
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::computedRoleString):
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored):
+        * accessibility/atk/AccessibilityObjectAtk.cpp:
+        (WebCore::AccessibilityObject::accessibilityPlatformIncludesObject):
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (-[WebAccessibilityObjectWrapper determineIsAccessibilityElement]):
+        (-[WebAccessibilityObjectWrapper accessibilityLabel]):
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (createAccessibilityRoleMap):
+        (-[WebAccessibilityObjectWrapper subrole]):
+        (-[WebAccessibilityObjectWrapper roleDescription]):
+        * platform/LocalizedStrings.cpp:
+        (WebCore::AXHorizontalRuleDescriptionText):
+        * platform/LocalizedStrings.h:
+
 2014-03-24  Antti Koivisto  <antti@apple.com>
 
         Invalidate sibling text node style when needed instead of attaching synchronously
 
         * platform/ios/WebSafeGCActivityCallbackIOS.h:
 
-=======
 2014-03-19  Antti Koivisto  <antti@apple.com>
 
         Crash with long selector list
index 727b38c..b77a42c 100644 (file)
 /* Verb stating the action that will occur when a radio button is clicked, as used by accessibility */
 "select" = "select";
 
+/* accessibility role description for a horizontal rule [<hr>] */
+"separator" = "separator";
+
 /* HTTP result code string */
 "server error" = "server error";
 
index 352bf41..5224aa7 100644 (file)
@@ -640,7 +640,10 @@ bool AccessibilityNodeObject::isEnabled() const
         if (equalIgnoringCase(disabledStatus, "false"))
             break;
     }
-
+    
+    if (roleValue() == HorizontalRuleRole)
+        return false;
+    
     Node* node = this->node();
     if (!node || !node->isElementNode())
         return true;
index be9ee36..df9e7b8 100644 (file)
@@ -1749,7 +1749,11 @@ AccessibilityRole AccessibilityObject::ariaRoleToWebCoreRole(const String& value
 String AccessibilityObject::computedRoleString() const
 {
     // FIXME: Need a few special cases that aren't in the RoleMap: option, etc. http://webkit.org/b/128296
-    return reverseAriaRoleMap().get(roleValue());
+    AccessibilityRole role = roleValue();
+    if (role == HorizontalRuleRole)
+        role = SplitterRole;
+    
+    return reverseAriaRoleMap().get(role);
 }
 
 bool AccessibilityObject::hasHighlighting() const
index 5397d17..de1f961 100644 (file)
@@ -1252,7 +1252,10 @@ bool AccessibilityRenderObject::computeAccessibilityIsIgnored() const
     
     if (ariaRoleAttribute() != UnknownRole)
         return false;
-
+    
+    if (roleValue() == HorizontalRuleRole)
+        return false;
+    
     // don't ignore labels, because they serve as TitleUIElements
     Node* node = m_renderer->node();
     if (node && isHTMLLabelElement(node))
index 56f84dc..1d16ec1 100644 (file)
@@ -42,9 +42,6 @@ AccessibilityObjectInclusion AccessibilityObject::accessibilityPlatformIncludesO
         return DefaultBehavior;
 
     AccessibilityRole role = roleValue();
-    if (role == HorizontalRuleRole)
-        return IncludeObject;
-
     // We expose the slider as a whole but not its value indicator.
     if (role == SliderThumbRole)
         return IgnoreObject;
index 7ffbb44..58cd3f8 100644 (file)
@@ -44,6 +44,7 @@
 #import "HTMLNames.h"
 #import "IntRect.h"
 #import "IntSize.h"
+#import "LocalizedStrings.h"
 #import "Page.h"
 #import "Range.h"
 #import "RenderView.h"
@@ -620,6 +621,7 @@ static AccessibilityObjectWrapper* AccessibilityUnignoredAncestor(AccessibilityO
         case ListBoxOptionRole:
         case TabRole:
         case DocumentMathRole:
+        case HorizontalRuleRole:
             return true;
         case StaticTextRole:
         {
@@ -750,9 +752,11 @@ static void appendStringToResult(NSMutableString *result, NSString *string)
     NSString *axTitle = [self accessibilityTitle];
     NSString *axDescription = [self accessibilityDescription];
     NSString *landmarkDescription = [self ariaLandmarkRoleDescription];
-
+    
     NSMutableString *result = [NSMutableString string];
-
+    if (m_object->roleValue() == HorizontalRuleRole)
+        appendStringToResult(result, AXHorizontalRuleDescriptionText());
+        
     appendStringToResult(result, axTitle);
     appendStringToResult(result, axDescription);
     if ([self stringValueShouldBeUsedInLabel]) {
index 93bdb1d..8a5ba51 100644 (file)
@@ -116,6 +116,10 @@ using namespace HTMLNames;
 #define NSAccessibilityDescriptionListSubrole @"AXDescriptionList"
 #endif
 
+#ifndef NSAccessibilityContentSeparatorSubrole
+#define NSAccessibilityContentSeparatorSubrole @"AXContentSeparator"
+#endif
+
 // Miscellaneous
 #ifndef NSAccessibilityBlockQuoteLevelAttribute
 #define NSAccessibilityBlockQuoteLevelAttribute @"AXBlockQuoteLevel"
@@ -1916,7 +1920,8 @@ static const AccessibilityRoleMap& createAccessibilityRoleMap()
         { LegendRole, NSAccessibilityGroupRole },
         { MathElementRole, NSAccessibilityGroupRole },
         { AudioRole, NSAccessibilityGroupRole },
-        { VideoRole, NSAccessibilityGroupRole }
+        { VideoRole, NSAccessibilityGroupRole },
+        { HorizontalRuleRole, NSAccessibilitySplitterRole }
     };
     AccessibilityRoleMap& roleMap = *new AccessibilityRoleMap;
     
@@ -1962,6 +1967,9 @@ static NSString* roleValueToNSString(AccessibilityRole value)
         }
     }
     
+    if (m_object->roleValue() == HorizontalRuleRole)
+        return NSAccessibilityContentSeparatorSubrole;
+    
     if (m_object->isSpinButtonPart()) {
         if (toAccessibilitySpinButtonPart(m_object)->isIncrementor())
             return NSAccessibilityIncrementArrowSubrole;
@@ -2155,6 +2163,9 @@ static NSString* roleValueToNSString(AccessibilityRole value)
             return AXDescriptionListText();
     }
     
+    if (m_object->roleValue() == HorizontalRuleRole)
+        return AXHorizontalRuleDescriptionText();
+    
     // AppKit also returns AXTab for the role description for a tab item.
     if (m_object->isTabItem())
         return NSAccessibilityRoleDescription(@"AXTab", nil);
index 33a5cf9..e0ca536 100644 (file)
@@ -700,6 +700,12 @@ String AXARIAContentGroupText(const String& ariaType)
         return WEB_UI_STRING("math", "An ARIA accessibility group that contains mathematical symbols.");
     return String();
 }
+
+String AXHorizontalRuleDescriptionText()
+{
+    return WEB_UI_STRING("separator", "accessibility role description for a horizontal rule [<hr>]");
+}
+    
 #endif // PLATFORM(COCOA)
 
 String missingPluginText()
index 0d47b36..40b4dce 100644 (file)
@@ -181,6 +181,7 @@ namespace WebCore {
 #endif
 #if PLATFORM(COCOA)
     String AXARIAContentGroupText(const String& ariaType);
+    String AXHorizontalRuleDescriptionText();
 #endif
 
     String missingPluginText();