From fabfe94b89a130e47100e238f4fd2e3a2bb8706f Mon Sep 17 00:00:00 2001 From: "cfleizach@apple.com" Date: Mon, 3 Oct 2011 19:01:28 +0000 Subject: [PATCH] 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. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96524 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 10 ++++ .../html-section-elements-expected.txt | 29 ++++++++++ .../mac/accessibility/html-section-elements.html | 61 ++++++++++++++++++++++ Source/WebCore/ChangeLog | 23 ++++++++ .../accessibility/AccessibilityRenderObject.cpp | 31 +++++++++++ .../accessibility/AccessibilityRenderObject.h | 1 + 6 files changed, 155 insertions(+) create mode 100644 LayoutTests/platform/mac/accessibility/html-section-elements-expected.txt create mode 100644 LayoutTests/platform/mac/accessibility/html-section-elements.html diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index e7868e9..01d01b6 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,5 +1,15 @@ 2011-10-03 Chris Fleizach + 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 + 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 diff --git a/LayoutTests/platform/mac/accessibility/html-section-elements-expected.txt b/LayoutTests/platform/mac/accessibility/html-section-elements-expected.txt new file mode 100644 index 0000000..51f6a59 --- /dev/null +++ b/LayoutTests/platform/mac/accessibility/html-section-elements-expected.txt @@ -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 + diff --git a/LayoutTests/platform/mac/accessibility/html-section-elements.html b/LayoutTests/platform/mac/accessibility/html-section-elements.html new file mode 100644 index 0000000..8a3fce5 --- /dev/null +++ b/LayoutTests/platform/mac/accessibility/html-section-elements.html @@ -0,0 +1,61 @@ + + + + + + + + + +
header
+
footer
+
section
+
article
+ + + +
+
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
+
+ +

+
+ + + + + + diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 7f3cb1d..9c5ea26 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,5 +1,28 @@ 2011-10-03 Chris Fleizach + 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 + 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 diff --git a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp b/Source/WebCore/accessibility/AccessibilityRenderObject.cpp index 29232b0..024da7d 100644 --- a/Source/WebCore/accessibility/AccessibilityRenderObject.cpp +++ b/Source/WebCore/accessibility/AccessibilityRenderObject.cpp @@ -3094,6 +3094,15 @@ void AccessibilityRenderObject::updateAccessibilityRole() 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 @@ AccessibilityRole AccessibilityRenderObject::determineAccessibilityRole() 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; diff --git a/Source/WebCore/accessibility/AccessibilityRenderObject.h b/Source/WebCore/accessibility/AccessibilityRenderObject.h index 6a20706..45e02f6 100644 --- a/Source/WebCore/accessibility/AccessibilityRenderObject.h +++ b/Source/WebCore/accessibility/AccessibilityRenderObject.h @@ -299,6 +299,7 @@ private: AccessibilityObject* accessibilityParentForImageMap(HTMLMapElement*) const; bool renderObjectIsObservable(RenderObject*) const; RenderObject* renderParentObject() const; + bool isDescendantOfElementType(const QualifiedName& tagName) const; void ariaSelectedRows(AccessibilityChildrenVector&); -- 2.7.4