summaryrefslogtreecommitdiffstats
path: root/webkit/glue/webaccessibility.cc
diff options
context:
space:
mode:
authordmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-08 19:26:24 +0000
committerdmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-08 19:26:24 +0000
commit8368e3c097978a1424e13786efceead3ffc6c385 (patch)
tree388a0a7d01f15a992a097ec92bad7727f17a9f92 /webkit/glue/webaccessibility.cc
parentf74252d3754d1d58b6f97cb3cd89b47d151cd88d (diff)
downloadchromium_src-8368e3c097978a1424e13786efceead3ffc6c385.zip
chromium_src-8368e3c097978a1424e13786efceead3ffc6c385.tar.gz
chromium_src-8368e3c097978a1424e13786efceead3ffc6c385.tar.bz2
Browser accessibility improvements so that screen readers can access more
complicated webpages without problems. First, WebAccessibility now works around a "multiple inheritance problem" in WebCore::AccessibilityObject where the same node appears as a child of multiple parents. For example, a table cell appears as a child of both a row and a column. This is solved by having each WebAccessibility parent check whether the child lists itself as an ancestor. If not, it notes the child's id only in a separate vector, so each child appears fully only once. Second, BrowserAccessibility now has internal reference counting, which allows BrowserAccessibilityManager to update any subtree while maximally reusing as many objects as possible. This fixes many screen reader interaction problems! All of this new functionality is tested with new cross-platform tests. BUG=67192 BUG=67620 TEST=Adds new unit tests and a browser test. Review URL: http://codereview.chromium.org/6625042 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77316 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webaccessibility.cc')
-rw-r--r--webkit/glue/webaccessibility.cc30
1 files changed, 22 insertions, 8 deletions
diff --git a/webkit/glue/webaccessibility.cc b/webkit/glue/webaccessibility.cc
index f6df3b2..48cc339 100644
--- a/webkit/glue/webaccessibility.cc
+++ b/webkit/glue/webaccessibility.cc
@@ -380,12 +380,6 @@ void WebAccessibility::Init(const WebKit::WebAccessibilityObject& src,
// Add the source object to the cache and store its id.
id = cache->addOrGetId(src);
- if (role == WebAccessibility::ROLE_EDITABLE_TEXT ||
- role == WebAccessibility::ROLE_TEXTAREA ||
- role == WebAccessibility::ROLE_TEXT_FIELD) {
- include_children = false;
- }
-
if (include_children) {
// Recursively create children.
int child_count = src.childCount();
@@ -393,13 +387,33 @@ void WebAccessibility::Init(const WebKit::WebAccessibilityObject& src,
WebAccessibilityObject child = src.childAt(i);
// The child may be invalid due to issues in webkit accessibility code.
- // Don't add children are invalid thus preventing a crash.
+ // Don't add children that are invalid thus preventing a crash.
// https://bugs.webkit.org/show_bug.cgi?id=44149
// TODO(ctguil): We may want to remove this check as webkit stabilizes.
- if (child.isValid())
+ if (!child.isValid())
+ continue;
+
+ // Some nodes appear in the tree in more than one place: for example,
+ // a cell in a table appears as a child of both a row and a column.
+ // Only recursively add child nodes that have this node as one of its
+ // ancestors. For child nodes that are actually parented to something
+ // else, store only the ID.
+ if (IsAncestorOf(src, child)) {
children.push_back(WebAccessibility(child, cache, include_children));
+ } else {
+ indirect_child_ids.push_back(cache->addOrGetId(child));
+ }
}
}
}
+bool WebAccessibility::IsAncestorOf(
+ const WebKit::WebAccessibilityObject& ancestor,
+ const WebKit::WebAccessibilityObject& child) {
+ WebKit::WebAccessibilityObject parent = child.parentObject();
+ while (!parent.isNull() && !parent.equals(ancestor))
+ parent = parent.parentObject();
+ return parent.equals(ancestor);
+}
+
} // namespace webkit_glue