Title: [96524] trunk
Revision
96524
Author
[email protected]
Date
2011-10-03 12:01:28 -0700 (Mon, 03 Oct 2011)

Log Message

AX: support role mapping for HTML5 section elements
https://bugs.webkit.org/show_bug.cgi?id=69150

Source/WebCore: 

We need to map these HTML5 elements to appropriate ARIA roles. That mapping is:
  article -> Document article
  nav -> Landmark navigation
  aside -> Landmark complementary
  section -> Document region
  address -> Landmark content info
  header -> Landmark banner (unless it's in an article or section)
  footer -> Landmark content info (unless it's in an article or section)

Reviewed by Darin Adler.

Test: platform/mac/accessibility/html-section-elements.html

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::isDescendantOfElementType):
(WebCore::AccessibilityRenderObject::determineAccessibilityRole):
* accessibility/AccessibilityRenderObject.h:

LayoutTests: 

Reviewed by Darin Adler.

* platform/mac/accessibility/html-section-elements-expected.txt: Added.
* platform/mac/accessibility/html-section-elements.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (96523 => 96524)


--- trunk/LayoutTests/ChangeLog	2011-10-03 18:55:46 UTC (rev 96523)
+++ trunk/LayoutTests/ChangeLog	2011-10-03 19:01:28 UTC (rev 96524)
@@ -1,5 +1,15 @@
 2011-10-03  Chris Fleizach  <[email protected]>
 
+        AX: support role mapping for HTML5 section elements
+        https://bugs.webkit.org/show_bug.cgi?id=69150
+
+        Reviewed by Darin Adler.
+
+        * platform/mac/accessibility/html-section-elements-expected.txt: Added.
+        * platform/mac/accessibility/html-section-elements.html: Added.
+
+2011-10-03  Chris Fleizach  <[email protected]>
+
         AX: click point for AXHeadings often returns point on empty space (results in wrong context menu)
         https://bugs.webkit.org/show_bug.cgi?id=69262
 

Added: trunk/LayoutTests/platform/mac/accessibility/html-section-elements-expected.txt (0 => 96524)


--- trunk/LayoutTests/platform/mac/accessibility/html-section-elements-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/accessibility/html-section-elements-expected.txt	2011-10-03 19:01:28 UTC (rev 96524)
@@ -0,0 +1,29 @@
+header
+footer
+section
+article
+nav
+aside
+Should be IGNORED because it's inside an article, so it should not be a landmark
+Should be IGNORED because it's inside an article, so it should not be a landmark
+Should be IGNORED because it's inside a section, so it should not be a landmark
+Should be IGNORED because it's inside a section, so it should not be a landmark
+This tests that the HTML5 section elements map to the correct AX roles.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS body.childAtIndex(0).subrole is 'AXSubrole: AXLandmarkBanner'
+PASS body.childAtIndex(1).subrole is 'AXSubrole: AXLandmarkContentInfo'
+PASS body.childAtIndex(2).subrole is 'AXSubrole: AXDocumentRegion'
+PASS body.childAtIndex(3).subrole is 'AXSubrole: AXDocumentArticle'
+PASS body.childAtIndex(4).subrole is 'AXSubrole: AXLandmarkNavigation'
+PASS body.childAtIndex(5).subrole is 'AXSubrole: AXLandmarkComplementary'
+PASS body.childAtIndex(6).childAtIndex(0).subrole is 'AXSubrole: '
+PASS body.childAtIndex(6).childAtIndex(1).subrole is 'AXSubrole: '
+PASS body.childAtIndex(7).childAtIndex(0).subrole is 'AXSubrole: '
+PASS body.childAtIndex(7).childAtIndex(1).subrole is 'AXSubrole: '
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/platform/mac/accessibility/html-section-elements.html (0 => 96524)


--- trunk/LayoutTests/platform/mac/accessibility/html-section-elements.html	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/accessibility/html-section-elements.html	2011-10-03 19:01:28 UTC (rev 96524)
@@ -0,0 +1,61 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script>
+var successfullyParsed = false;
+</script>
+<script src=""
+</head>
+<body id="body">
+
+<header>header</header>
+<footer>footer</footer>
+<section>section</section>
+<article>article</article>
+<nav>nav</nav>
+<aside>aside</aside>
+
+<article>
+<header>Should be IGNORED because it's inside an article, so it should not be a landmark</header>
+<footer>Should be IGNORED because it's inside an article, so it should not be a landmark</footer>
+</article>
+
+<section>
+<header>Should be IGNORED because it's inside a section, so it should not be a landmark</header>
+<footer>Should be IGNORED because it's inside a section, so it should not be a landmark</footer>
+</section>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that the HTML5 section elements map to the correct AX roles.");
+
+    if (window.accessibilityController) {
+
+          document.getElementById("body").focus();
+          var body = accessibilityController.focusedElement;
+          shouldBe("body.childAtIndex(0).subrole", "'AXSubrole: AXLandmarkBanner'");
+          shouldBe("body.childAtIndex(1).subrole", "'AXSubrole: AXLandmarkContentInfo'");
+          shouldBe("body.childAtIndex(2).subrole", "'AXSubrole: AXDocumentRegion'");
+          shouldBe("body.childAtIndex(3).subrole", "'AXSubrole: AXDocumentArticle'");
+          shouldBe("body.childAtIndex(4).subrole", "'AXSubrole: AXLandmarkNavigation'");
+          shouldBe("body.childAtIndex(5).subrole", "'AXSubrole: AXLandmarkComplementary'");
+
+          // When a header and footer are inside an article, they should not be landmarks.
+          shouldBe("body.childAtIndex(6).childAtIndex(0).subrole", "'AXSubrole: '");
+          shouldBe("body.childAtIndex(6).childAtIndex(1).subrole", "'AXSubrole: '");
+
+          // When a header and footer are inside a section, they should not be landmarks.
+          shouldBe("body.childAtIndex(7).childAtIndex(0).subrole", "'AXSubrole: '");
+          shouldBe("body.childAtIndex(7).childAtIndex(1).subrole", "'AXSubrole: '");
+    }
+
+    successfullyParsed = true;
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (96523 => 96524)


--- trunk/Source/WebCore/ChangeLog	2011-10-03 18:55:46 UTC (rev 96523)
+++ trunk/Source/WebCore/ChangeLog	2011-10-03 19:01:28 UTC (rev 96524)
@@ -1,5 +1,28 @@
 2011-10-03  Chris Fleizach  <[email protected]>
 
+        AX: support role mapping for HTML5 section elements
+        https://bugs.webkit.org/show_bug.cgi?id=69150
+
+        We need to map these HTML5 elements to appropriate ARIA roles. That mapping is:
+          article -> Document article
+          nav -> Landmark navigation
+          aside -> Landmark complementary
+          section -> Document region
+          address -> Landmark content info
+          header -> Landmark banner (unless it's in an article or section)
+          footer -> Landmark content info (unless it's in an article or section)
+
+        Reviewed by Darin Adler.
+
+        Test: platform/mac/accessibility/html-section-elements.html
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::isDescendantOfElementType):
+        (WebCore::AccessibilityRenderObject::determineAccessibilityRole):
+        * accessibility/AccessibilityRenderObject.h:
+
+2011-10-03  Chris Fleizach  <[email protected]>
+
         AX: click point for AXHeadings often returns point on empty space (results in wrong context menu)
         https://bugs.webkit.org/show_bug.cgi?id=69262
 

Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (96523 => 96524)


--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2011-10-03 18:55:46 UTC (rev 96523)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp	2011-10-03 19:01:28 UTC (rev 96524)
@@ -3094,6 +3094,15 @@
         childrenChanged();
 }
     
+bool AccessibilityRenderObject::isDescendantOfElementType(const QualifiedName& tagName) const
+{
+    for (RenderObject* parent = m_renderer->parent(); parent; parent = parent->parent()) {
+        if (parent->node() && parent->node()->hasTagName(tagName))
+            return true;
+    }
+    return false;
+}
+    
 AccessibilityRole AccessibilityRenderObject::determineAccessibilityRole()
 {
     if (!m_renderer)
@@ -3210,6 +3219,28 @@
         return GroupRole;
 #endif
 
+    if (node && node->hasTagName(articleTag))
+        return DocumentArticleRole;
+
+    if (node && node->hasTagName(navTag))
+        return LandmarkNavigationRole;
+
+    if (node && node->hasTagName(asideTag))
+        return LandmarkComplementaryRole;
+
+    if (node && node->hasTagName(sectionTag))
+        return DocumentRegionRole;
+
+    if (node && node->hasTagName(addressTag))
+        return LandmarkContentInfoRole;
+
+    // There should only be one banner/contentInfo per page. If header/footer are being used within an article or section
+    // then it should not be exposed as whole page's banner/contentInfo
+    if (node && node->hasTagName(headerTag) && !isDescendantOfElementType(articleTag) && !isDescendantOfElementType(sectionTag))
+        return LandmarkBannerRole;
+    if (node && node->hasTagName(footerTag) && !isDescendantOfElementType(articleTag) && !isDescendantOfElementType(sectionTag))
+        return LandmarkContentInfoRole;
+
     if (m_renderer->isBlockFlow())
         return GroupRole;
     

Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h (96523 => 96524)


--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h	2011-10-03 18:55:46 UTC (rev 96523)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.h	2011-10-03 19:01:28 UTC (rev 96524)
@@ -299,6 +299,7 @@
     AccessibilityObject* accessibilityParentForImageMap(HTMLMapElement*) const;
     bool renderObjectIsObservable(RenderObject*) const;
     RenderObject* renderParentObject() const;
+    bool isDescendantOfElementType(const QualifiedName& tagName) const;
     
     void ariaSelectedRows(AccessibilityChildrenVector&);
     
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to