Bug 326092 - [Webapp] Eclipse help system content panel tree component is unusable by people using screen readers
diff --git a/org.eclipse.help.webapp/META-INF/MANIFEST.MF b/org.eclipse.help.webapp/META-INF/MANIFEST.MF
index 6b46f2f..c46a7bd 100644
--- a/org.eclipse.help.webapp/META-INF/MANIFEST.MF
+++ b/org.eclipse.help.webapp/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
Bundle-ManifestVersion: 2
Bundle-Name: %help_webapp_plugin_name
Bundle-SymbolicName: org.eclipse.help.webapp;singleton:=true
-Bundle-Version: 3.3.103.qualifier
+Bundle-Version: 3.3.104.qualifier
Bundle-Activator: org.eclipse.help.internal.webapp.HelpWebappPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/org.eclipse.help.webapp/advanced/helptree.js b/org.eclipse.help.webapp/advanced/helptree.js
index a0b582c..71c9b00 100644
--- a/org.eclipse.help.webapp/advanced/helptree.js
+++ b/org.eclipse.help.webapp/advanced/helptree.js
@@ -15,11 +15,11 @@
var oldActive;
var oldActiveClass;
-// WAI Roles
-var WAI_TREEITEM = "wairole:treeitem";
-var WAI_TREE = "wairole:tree";
-var WAI_GROUP = "wairole:group";
-var WAI_APPLICATION = "wairole:application";
+// WAI-ARIA Roles
+var WAI_TREEITEM = "treeitem";
+var WAI_TREE = "tree";
+var WAI_GROUP = "group";
+var WAI_APPLICATION = "application";
/**
* Returns the currently selected (highlighted) tree node anchor.
@@ -394,24 +394,46 @@
// Accessibility
-var isNamespaceSupport = typeof document.documentElement.setAttributeNS != 'undefined';
+
+// Accessibility roles are now set for all browsers
+var setAccessibilityRoles = true;
function setAccessibilityRole(node, role) {
- if (isNamespaceSupport) {
- node.setAttributeNS("http://www.w3.org/TR/xhtml2", "role", role);
- node.role = role;
+ if (setAccessibilityRoles) {
+ node.setAttribute("role", role);
+ }
+}
+
+function setAccessibilitySetsize( node, setsize )
+{
+ if (setAccessibilityRoles) {
+ node.setAttribute("aria-setsize", setsize);
+ }
+}
+
+function setAccessibilityPosition( node, posinset)
+{
+ if (setAccessibilityRoles) {
+ node.setAttribute("aria-posinset", posinset);
+ }
+}
+
+function setAccessibilityTreeLevel( node,level )
+{
+ if (setAccessibilityRoles) {
+ node.setAttribute("aria-level", level);
}
}
function setWAIExpanded(node, value) {
- if (isNamespaceSupport) {
+ if (setAccessibilityRoles && node.id != "tree_root") {
var valueAsString = value? "true" : "false";
- node.setAttributeNS("http://www.w3.org/2005/07/aaa", "expanded", valueAsString);
+ node.setAttribute("aria-expanded", valueAsString);
}
}
function setRootAccessibility() {
- if (isNamespaceSupport) {
+ if (setAccessibilityRoles) {
var treeItem = document.getElementById("tree_root");
if (treeItem) {
setAccessibilityRole(treeItem, WAI_TREE);
@@ -424,7 +446,7 @@
}
function setWAIExpansionState(treeItem, isExpanded) {
- if (isNamespaceSupport) {
+ if (setAccessibilityRoles) {
var anchor = findAnchor(treeItem);
if (anchor) {
setWAIExpanded(anchor, isExpanded);
diff --git a/org.eclipse.help.webapp/advanced/helptreechildren.js b/org.eclipse.help.webapp/advanced/helptreechildren.js
index 6722d91..3030fa9 100644
--- a/org.eclipse.help.webapp/advanced/helptreechildren.js
+++ b/org.eclipse.help.webapp/advanced/helptreechildren.js
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
+ * Copyright (c) 2006, 2010 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -24,7 +24,7 @@
var treeRoot = document.getElementById("tree_root");
var nodes = tocData.childNodes;
selectedNode = null;
- mergeChildren(treeRoot, nodes);
+ mergeChildren(treeRoot, nodes, 0);
if (selectedNode != null) {
// Focusing on the last child will increase the chance that it is visible
if (!highlightSelectedNode) {
@@ -49,7 +49,7 @@
return errorTags.length > 0;
}
-function mergeChildren(treeItem, nodes) {
+function mergeChildren(treeItem, nodes, level) {
var childContainer;
if (treeItem.id == "tree_root") {
childContainer=treeItem;
@@ -58,10 +58,23 @@
}
var childAdded = false;
var hasPlaceholder = childContainer != null && childContainer.className == "unopened";
+ var childCount = 0;
+ var nodeIndex = 0;
+
+ // Compute total # of nodes for accessibility attributes
+ // nodes.length cannot be used because the list may contain xml elements
+ // which are not nodes
+
+ for (var i = 0; i < nodes.length; i++) {
+ if (nodes[i].tagName == "node") {
+ childCount++;
+ }
+ }
if (nodes) {
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
if (node.tagName == "node") {
+ nodeIndex++;
if (hasPlaceholder) {
// Remove the loading message
treeItem.removeChild(childContainer);
@@ -79,10 +92,10 @@
var href = node.getAttribute("href");
var image = node.getAttribute("image");
var id = node.getAttribute("id");
- var childItem = mergeChild(childContainer, id, title, href, image, isLeaf);
+ var childItem = mergeChild(childContainer, id, title, href, image, isLeaf, nodeIndex, childCount, level + 1);
var isSelected = node.getAttribute("is_selected");
if (!isLeaf) {
- mergeChildren(childItem, node.childNodes);
+ mergeChildren(childItem, node.childNodes, level + 1);
}
if (isSelected) {
selectedNode = childItem;
@@ -106,7 +119,7 @@
}
// Create a child if one with this if does not exist
-function mergeChild(treeItem, id, name, href, image, isLeaf) {
+function mergeChild(treeItem, id, name, href, image, isLeaf, position, setsize, level) {
var children = treeItem.childNodes;
if (children !== null) {
for (var i = 0; i < children.length; i++) {
@@ -158,7 +171,10 @@
anchor.href = href;
}
anchor.title = name;
- setAccessibilityRole(anchor, WAI_TREEITEM);
+ setAccessibilityRole(anchor, WAI_TREEITEM);
+ setAccessibilitySetsize(anchor, setsize);
+ setAccessibilityPosition(anchor, position);
+ setAccessibilityTreeLevel(anchor, level);
if (topicImage) {
anchor.appendChild(topicImage);