AX: WebKit exposes all Ruby Text as Unknown (Japanese EPUB accessibility blocker)
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 13 Jun 2015 08:29:23 +0000 (08:29 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 13 Jun 2015 08:29:23 +0000 (08:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=141303

Patch by Andres Gonzalez <agonzalez334@nc.rr.com> on 2015-06-13
Reviewed by Chris Fleizach.

Source/WebCore:

Test: accessibility/ruby-hierarchy-roles.html

* accessibility/AccessibilityObject.h:
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored):
(WebCore::AccessibilityRenderObject::determineAccessibilityRole):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(createAccessibilityRoleMap):
(-[WebAccessibilityObjectWrapper subrole]):

LayoutTests:

* accessibility/ruby-hierarchy-roles-expected.txt: Added.
* accessibility/ruby-hierarchy-roles.html: Added.
* platform/mac-mavericks/accessibility/ruby-hierarchy-roles-expected.txt: Added.
* platform/mac/accessibility/ruby-hierarchy-roles-expected.txt: Added.

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

LayoutTests/ChangeLog
LayoutTests/accessibility/ruby-hierarchy-roles-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/ruby-hierarchy-roles.html [new file with mode: 0644]
LayoutTests/platform/mac-mavericks/accessibility/ruby-hierarchy-roles-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/ruby-hierarchy-roles-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/AccessibilityRenderObject.cpp
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm

index 94d6ed9..d7b732d 100644 (file)
@@ -1,3 +1,15 @@
+2015-06-13  Andres Gonzalez  <agonzalez334@nc.rr.com>
+
+        AX: WebKit exposes all Ruby Text as Unknown (Japanese EPUB accessibility blocker)
+        https://bugs.webkit.org/show_bug.cgi?id=141303
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/ruby-hierarchy-roles-expected.txt: Added.
+        * accessibility/ruby-hierarchy-roles.html: Added.
+        * platform/mac-mavericks/accessibility/ruby-hierarchy-roles-expected.txt: Added.
+        * platform/mac/accessibility/ruby-hierarchy-roles-expected.txt: Added.
+
 2015-06-12  Chris Fleizach  <cfleizach@apple.com>
 
         AX:ARIA Toggle buttons aren't properly conveyed on iOS using VoiceOver
diff --git a/LayoutTests/accessibility/ruby-hierarchy-roles-expected.txt b/LayoutTests/accessibility/ruby-hierarchy-roles-expected.txt
new file mode 100644 (file)
index 0000000..5d53862
--- /dev/null
@@ -0,0 +1,9 @@
+This tests that the ruby containers are exposed with the appropriate hierarchy and roles.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+basetext rubytext
diff --git a/LayoutTests/accessibility/ruby-hierarchy-roles.html b/LayoutTests/accessibility/ruby-hierarchy-roles.html
new file mode 100644 (file)
index 0000000..0a3bc42
--- /dev/null
@@ -0,0 +1,79 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+    <head>
+        <script src="../resources/js-test-pre.js"></script>
+    </head>
+    <body>
+        <ruby id="rubyElemId">
+            <rb>basetext</rb>
+            <rp>(</rp>
+            <rt>rubytext</rt>
+            <rp>)</rp>
+        </ruby>
+        
+        <script>
+            if (window.accessibilityController) {
+                description("This tests that the ruby containers are exposed with the appropriate hierarchy and roles.")
+                // At the moment, this is implemented only for OSX.
+                var platform = accessibilityController.platformName;
+                if ("mac" == platform) {
+                    // Expected values for roles and subroles.
+                    var expectedRubyRole = "AXRole: AXGroup"; // all ruby containers have AXGroup role
+                    var expectedRubyInlineSubrole = "AXSubrole: AXRubyInline";
+                    var expectedRubyBlockSubrole = "AXSubrole: AXRubyBlock";
+                    var expectedRubyRunSubrole = "AXSubrole: AXRubyRun";
+                    var expectedRubyTextSubrole = "AXSubrole: AXRubyText";
+                    var expectedRubyBaseSubrole = "AXSubrole: AXRubyBase";
+                    
+                    // Try inline style first, block style second
+                    var rubyElem = document.getElementById("rubyElemId");
+                    shouldBeTrue("rubyElem != null");
+                    rubyElem.style.display = "inline";
+                    checkHierarchyAndRoles(rubyElem);
+                    
+                    rubyElem.style.display = "block";
+                    checkHierarchyAndRoles(rubyElem);
+                    
+                    function checkHierarchyAndRoles(rubyElem) {
+                        axRuby = window.accessibilityController.accessibleElementById("rubyElemId");
+                        shouldBeTrue("axRuby != null");
+                        role = axRuby.role;
+                        subrole = axRuby.subrole;
+                        shouldBe("role", "expectedRubyRole");
+                        if (rubyElem.style.display == "inline") {
+                            shouldBe("subrole", "expectedRubyInlineSubrole");
+                        }
+                        else {
+                            shouldBe("subrole", "expectedRubyBlockSubrole");
+                        }
+                        
+                        // RubyRun
+                        axRubyRun = axRuby.childAtIndex(0);
+                        shouldBeTrue("axRubyRun != null");
+                        role = axRubyRun.role;
+                        subrole = axRubyRun.subrole;
+                        shouldBe("role", "expectedRubyRole");
+                        shouldBe("subrole", "expectedRubyRunSubrole");
+                        
+                        // RubyText
+                        axRubyText = axRubyRun.childAtIndex(0);
+                        shouldBeTrue("axRubyText != null");
+                        role = axRubyText.role;
+                        subrole = axRubyText.subrole;
+                        shouldBe("role", "expectedRubyRole");
+                        shouldBe("subrole", "expectedRubyTextSubrole");
+                        
+                        // RubyBase
+                        axRubyBase = axRubyRun.childAtIndex(1);
+                        shouldBeTrue("axRubyBase != null");
+                        role = axRubyBase.role;
+                        subrole = axRubyBase.subrole;
+                        shouldBe("role", "expectedRubyRole");
+                        shouldBe("subrole", "expectedRubyBaseSubrole");
+                    }
+                }
+            }
+        </script>
+        <script src="../resources/js-test-post.js"></script>
+    </body>
+</html>
diff --git a/LayoutTests/platform/mac-mavericks/accessibility/ruby-hierarchy-roles-expected.txt b/LayoutTests/platform/mac-mavericks/accessibility/ruby-hierarchy-roles-expected.txt
new file mode 100644 (file)
index 0000000..4d355d9
--- /dev/null
@@ -0,0 +1,34 @@
+This tests that the ruby containers are exposed with the appropriate hierarchy and roles.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS rubyElem != null is true
+PASS axRuby != null is true
+PASS role is expectedRubyRole
+PASS subrole is expectedRubyInlineSubrole
+PASS axRubyRun != null is true
+PASS role is expectedRubyRole
+PASS subrole is expectedRubyRunSubrole
+PASS axRubyText != null is true
+PASS role is expectedRubyRole
+PASS subrole is expectedRubyTextSubrole
+PASS axRubyBase != null is true
+PASS role is expectedRubyRole
+PASS subrole is expectedRubyBaseSubrole
+PASS axRuby != null is true
+PASS role is expectedRubyRole
+PASS subrole is expectedRubyBlockSubrole
+PASS axRubyRun != null is true
+PASS role is expectedRubyRole
+PASS subrole is expectedRubyRunSubrole
+PASS axRubyText != null is true
+PASS role is expectedRubyRole
+PASS subrole is expectedRubyTextSubrole
+PASS axRubyBase != null is true
+PASS role is expectedRubyRole
+PASS subrole is expectedRubyBaseSubrole
+PASS successfullyParsed is true
+
+TEST COMPLETE
+basetext rubytext
diff --git a/LayoutTests/platform/mac/accessibility/ruby-hierarchy-roles-expected.txt b/LayoutTests/platform/mac/accessibility/ruby-hierarchy-roles-expected.txt
new file mode 100644 (file)
index 0000000..4d355d9
--- /dev/null
@@ -0,0 +1,34 @@
+This tests that the ruby containers are exposed with the appropriate hierarchy and roles.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS rubyElem != null is true
+PASS axRuby != null is true
+PASS role is expectedRubyRole
+PASS subrole is expectedRubyInlineSubrole
+PASS axRubyRun != null is true
+PASS role is expectedRubyRole
+PASS subrole is expectedRubyRunSubrole
+PASS axRubyText != null is true
+PASS role is expectedRubyRole
+PASS subrole is expectedRubyTextSubrole
+PASS axRubyBase != null is true
+PASS role is expectedRubyRole
+PASS subrole is expectedRubyBaseSubrole
+PASS axRuby != null is true
+PASS role is expectedRubyRole
+PASS subrole is expectedRubyBlockSubrole
+PASS axRubyRun != null is true
+PASS role is expectedRubyRole
+PASS subrole is expectedRubyRunSubrole
+PASS axRubyText != null is true
+PASS role is expectedRubyRole
+PASS subrole is expectedRubyTextSubrole
+PASS axRubyBase != null is true
+PASS role is expectedRubyRole
+PASS subrole is expectedRubyBaseSubrole
+PASS successfullyParsed is true
+
+TEST COMPLETE
+basetext rubytext
index 0095844..d2d1903 100644 (file)
@@ -1,3 +1,20 @@
+2015-06-13  Andres Gonzalez  <agonzalez334@nc.rr.com>
+
+        AX: WebKit exposes all Ruby Text as Unknown (Japanese EPUB accessibility blocker)
+        https://bugs.webkit.org/show_bug.cgi?id=141303
+
+        Reviewed by Chris Fleizach.
+
+        Test: accessibility/ruby-hierarchy-roles.html
+
+        * accessibility/AccessibilityObject.h:
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::computeAccessibilityIsIgnored):
+        (WebCore::AccessibilityRenderObject::determineAccessibilityRole):
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (createAccessibilityRoleMap):
+        (-[WebAccessibilityObjectWrapper subrole]):
+
 2015-06-12  Chris Fleizach  <cfleizach@apple.com>
 
         AX: iOS: after updating control, VoiceOver speaks aria-expanded states reversed (says "collapsed" when "expanded")
index 45d7bc1..330d88a 100644 (file)
@@ -177,6 +177,11 @@ enum AccessibilityRole {
     RadioGroupRole,
     RowHeaderRole,
     RowRole,
+    RubyBaseRole,
+    RubyBlockRole,
+    RubyInlineRole,
+    RubyRunRole,
+    RubyTextRole,
     RulerRole,
     RulerMarkerRole,
     ScrollAreaRole,
index 1e6eca3..e4474e9 100644 (file)
@@ -1382,7 +1382,11 @@ bool AccessibilityRenderObject::computeAccessibilityIsIgnored() const
     if (node && node->hasTagName(dfnTag))
         return false;
     
-    // By default, objects should be ignored so that the AX hierarchy is not 
+    // Make sure that ruby containers are not ignored.
+    if (m_renderer->isRubyRun() || m_renderer->isRubyBlock() || m_renderer->isRubyInline())
+        return false;
+
+    // By default, objects should be ignored so that the AX hierarchy is not
     // filled with unnecessary items.
     return true;
 }
@@ -2575,9 +2579,18 @@ AccessibilityRole AccessibilityRenderObject::determineAccessibilityRole()
     if (node && node->hasTagName(dlTag))
         return DescriptionListRole;
 
-    if (node && (node->hasTagName(rpTag) || node->hasTagName(rtTag)))
-        return AnnotationRole;
-
+    // Check for Ruby elements
+    if (m_renderer->isRubyText())
+        return RubyTextRole;
+    if (m_renderer->isRubyBase())
+        return RubyBaseRole;
+    if (m_renderer->isRubyRun())
+        return RubyRunRole;
+    if (m_renderer->isRubyBlock())
+        return RubyBlockRole;
+    if (m_renderer->isRubyInline())
+        return RubyInlineRole;
+    
     // This return value is what will be used if AccessibilityTableCell determines
     // the cell should not be treated as a cell (e.g. because it is a layout table.
     // In ATK, there is a distinction between generic text block elements and other
index 970ec91..ff297cd 100644 (file)
@@ -120,6 +120,26 @@ using namespace HTMLNames;
 #define NSAccessibilityContentSeparatorSubrole @"AXContentSeparator"
 #endif
 
+#ifndef NSAccessibilityRubyBaseSubRole
+#define NSAccessibilityRubyBaseSubrole @"AXRubyBase"
+#endif
+
+#ifndef NSAccessibilityRubyBlockSubrole
+#define NSAccessibilityRubyBlockSubrole @"AXRubyBlock"
+#endif
+
+#ifndef NSAccessibilityRubyInlineSubrole
+#define NSAccessibilityRubyInlineSubrole @"AXRubyInline"
+#endif
+
+#ifndef NSAccessibilityRubyRunSubrole
+#define NSAccessibilityRubyRunSubrole @"AXRubyRun"
+#endif
+
+#ifndef NSAccessibilityRubyTextSubrole
+#define NSAccessibilityRubyTextSubrole @"AXRubyText"
+#endif
+
 // Miscellaneous
 #ifndef NSAccessibilityBlockQuoteLevelAttribute
 #define NSAccessibilityBlockQuoteLevelAttribute @"AXBlockQuoteLevel"
@@ -1960,6 +1980,11 @@ static const AccessibilityRoleMap& createAccessibilityRoleMap()
         { SwitchRole, NSAccessibilityCheckBoxRole },
         { SearchFieldRole, NSAccessibilityTextFieldRole },
         { PreRole, NSAccessibilityGroupRole },
+        { RubyBaseRole, NSAccessibilityGroupRole },
+        { RubyBlockRole, NSAccessibilityGroupRole },
+        { RubyInlineRole, NSAccessibilityGroupRole },
+        { RubyRunRole, NSAccessibilityGroupRole },
+        { RubyTextRole, NSAccessibilityGroupRole },
     };
     AccessibilityRoleMap& roleMap = *new AccessibilityRoleMap;
     
@@ -2142,6 +2167,22 @@ static NSString* roleValueToNSString(AccessibilityRole value)
 
     if (m_object->isSwitch())
         return NSAccessibilitySwitchSubrole;
+
+    // Ruby subroles
+    switch (role) {
+    case RubyBaseRole:
+        return NSAccessibilityRubyBaseSubrole;
+    case RubyBlockRole:
+        return NSAccessibilityRubyBlockSubrole;
+    case RubyInlineRole:
+        return NSAccessibilityRubyInlineSubrole;
+    case RubyRunRole:
+        return NSAccessibilityRubyRunSubrole;
+    case RubyTextRole:
+        return NSAccessibilityRubyTextSubrole;
+    default:
+        break;
+    }
     
     return nil;
 }