summaryrefslogtreecommitdiffstats
path: root/content/renderer/renderer_accessibility.cc
diff options
context:
space:
mode:
authordtseng@chromium.org <dtseng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-19 02:46:21 +0000
committerdtseng@chromium.org <dtseng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-19 02:46:21 +0000
commit62405028eba3eab760007a3e736426927f3f3435 (patch)
treee8a378415e4e1ff37f1f58456098683c0b9e6456 /content/renderer/renderer_accessibility.cc
parent913a8885b2b7c6b86626f7bef21be05bb081406a (diff)
downloadchromium_src-62405028eba3eab760007a3e736426927f3f3435.zip
chromium_src-62405028eba3eab760007a3e736426927f3f3435.tar.gz
chromium_src-62405028eba3eab760007a3e736426927f3f3435.tar.bz2
Remedy irratic focus behavior when accessibility clients set focus.
BUG=none TEST=manually on Mac. TBR=tony@chromium.org, avi@chromium.org Review URL: http://codereview.chromium.org/10069003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132928 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer/renderer_accessibility.cc')
-rw-r--r--content/renderer/renderer_accessibility.cc122
1 files changed, 92 insertions, 30 deletions
diff --git a/content/renderer/renderer_accessibility.cc b/content/renderer/renderer_accessibility.cc
index bfb22f1..666b06e 100644
--- a/content/renderer/renderer_accessibility.cc
+++ b/content/renderer/renderer_accessibility.cc
@@ -8,6 +8,7 @@
#include "content/public/common/content_switches.h"
#include "content/renderer/render_view_impl.h"
#include "content/renderer/renderer_accessibility.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityNotification.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObject.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
@@ -74,7 +75,7 @@ bool WebAccessibilityNotificationToAccessibilityNotification(
*type = AccessibilityNotificationSelectedTextChanged;
break;
case WebKit::WebAccessibilityNotificationValueChanged:
- *type = AccessibilityNotificationValueChangedD;
+ *type = AccessibilityNotificationValueChanged;
break;
default:
NOTREACHED();
@@ -134,7 +135,7 @@ void RendererAccessibility::FocusedNodeChanged(const WebNode& node) {
// TODO(dmazzoni): Make WebKit send this notification instead.
PostAccessibilityNotification(
document.accessibilityObject(),
- WebKit::WebAccessibilityNotificationFocusedUIElementChanged);
+ AccessibilityNotificationBlur);
}
}
@@ -161,6 +162,18 @@ void RendererAccessibility::DidFinishLoad(WebKit::WebFrame* frame) {
void RendererAccessibility::PostAccessibilityNotification(
const WebAccessibilityObject& obj,
WebAccessibilityNotification notification) {
+ AccessibilityNotification temp;
+ if (!WebAccessibilityNotificationToAccessibilityNotification(
+ notification, &temp)) {
+ return;
+ }
+
+ PostAccessibilityNotification(obj, temp);
+}
+
+void RendererAccessibility::PostAccessibilityNotification(
+ const WebKit::WebAccessibilityObject& obj,
+ AccessibilityNotification notification) {
if (!WebAccessibilityObject::accessibilityEnabled())
return;
@@ -184,20 +197,15 @@ void RendererAccessibility::PostAccessibilityNotification(
}
// Add the accessibility object to our cache and ensure it's valid.
- Notification acc_notification;
+ AccessibilityHostMsg_NotificationParams acc_notification;
acc_notification.id = obj.axID();
- acc_notification.type = notification;
-
- AccessibilityNotification temp;
- if (!WebAccessibilityNotificationToAccessibilityNotification(
- notification, &temp)) {
- return;
- }
+ acc_notification.notification_type = notification;
// Discard duplicate accessibility notifications.
for (uint32 i = 0; i < pending_notifications_.size(); ++i) {
if (pending_notifications_[i].id == acc_notification.id &&
- pending_notifications_[i].type == acc_notification.type) {
+ pending_notifications_[i].notification_type ==
+ acc_notification.notification_type) {
return;
}
}
@@ -228,16 +236,17 @@ void RendererAccessibility::SendPendingAccessibilityNotifications() {
// Make a copy of the notifications, because it's possible that
// actions inside this loop will cause more notifications to be
// queued up.
- std::vector<Notification> src_notifications = pending_notifications_;
+ std::vector<AccessibilityHostMsg_NotificationParams> src_notifications =
+ pending_notifications_;
pending_notifications_.clear();
// Generate a notification message from each WebKit notification.
std::vector<AccessibilityHostMsg_NotificationParams> notification_msgs;
- // Loop over each WebKit notification and generate a notification message
- // from it.
+ // Loop over each notification and generate an updated notification message.
for (size_t i = 0; i < src_notifications.size(); ++i) {
- Notification& notification = src_notifications[i];
+ AccessibilityHostMsg_NotificationParams& notification =
+ src_notifications[i];
// TODO(dtseng): Come up with a cleaner way of deciding to include children.
int root_id = document.accessibilityObject().axID();
@@ -256,8 +265,8 @@ void RendererAccessibility::SendPendingAccessibilityNotifications() {
obj.axID() != root_id) {
obj = obj.parentObject();
includes_children = true;
- if (notification.type ==
- WebKit::WebAccessibilityNotificationChildrenChanged) {
+ if (notification.notification_type ==
+ AccessibilityNotificationChildrenChanged) {
notification.id = obj.axID();
}
}
@@ -303,11 +312,10 @@ void RendererAccessibility::SendPendingAccessibilityNotifications() {
}
AccessibilityHostMsg_NotificationParams notification_msg;
- BuildAccessibilityTree(obj, includes_children, &notification_msg.acc_tree);
- WebAccessibilityNotificationToAccessibilityNotification(
- notification.type, &notification_msg.notification_type);
+ notification_msg.notification_type = notification.notification_type;
notification_msg.id = notification.id;
notification_msg.includes_children = includes_children;
+ BuildAccessibilityTree(obj, includes_children, &notification_msg.acc_tree);
if (obj.axID() == root_id) {
DCHECK_EQ(notification_msg.acc_tree.role,
WebAccessibility::ROLE_WEB_AREA);
@@ -320,10 +328,11 @@ void RendererAccessibility::SendPendingAccessibilityNotifications() {
#ifndef NDEBUG
if (logging_) {
- LOG(INFO) << "Accessibility update: "
- << notification_msg.acc_tree.DebugString(true,
- routing_id(),
- notification.type);
+ LOG(INFO) << "Accessibility update: \n"
+ << "routing id=" << routing_id()
+ << " notification="
+ << AccessibilityNotificationToString(notification.notification_type)
+ << "\n" << notification_msg.acc_tree.DebugString(true);
}
#endif
}
@@ -549,12 +558,12 @@ void RendererAccessibility::OnSetFocus(int acc_obj_id) {
}
bool RendererAccessibility::ShouldIncludeChildren(
- const RendererAccessibility::Notification& notification) {
- WebKit::WebAccessibilityNotification type = notification.type;
- if (type == WebKit::WebAccessibilityNotificationChildrenChanged ||
- type == WebKit::WebAccessibilityNotificationLoadComplete ||
- type == WebKit::WebAccessibilityNotificationLiveRegionChanged ||
- type == WebKit::WebAccessibilityNotificationSelectedChildrenChanged) {
+ const AccessibilityHostMsg_NotificationParams& notification) {
+ AccessibilityNotification type = notification.notification_type;
+ if (type == AccessibilityNotificationChildrenChanged ||
+ type == AccessibilityNotificationLoadComplete ||
+ type == AccessibilityNotificationLiveRegionChanged ||
+ type == AccessibilityNotificationSelectedChildrenChanged) {
return true;
}
return false;
@@ -620,3 +629,56 @@ void RendererAccessibility::BuildAccessibilityTree(
// Find all editable text nodes and add them as children.
RecursiveAddEditableTextNodesToTree(src, dst);
}
+
+#ifndef NDEBUG
+const std::string RendererAccessibility::AccessibilityNotificationToString(
+ AccessibilityNotification notification) {
+ switch (notification) {
+ case AccessibilityNotificationActiveDescendantChanged:
+ return "active descendant changed";
+ case AccessibilityNotificationBlur:
+ return "blur";
+ case AccessibilityNotificationAlert:
+ return "alert";
+ case AccessibilityNotificationCheckStateChanged:
+ return "check state changed";
+ case AccessibilityNotificationChildrenChanged:
+ return "children changed";
+ case AccessibilityNotificationFocusChanged:
+ return "focus changed";
+ case AccessibilityNotificationLayoutComplete:
+ return "layout complete";
+ case AccessibilityNotificationLiveRegionChanged:
+ return "live region changed";
+ case AccessibilityNotificationLoadComplete:
+ return "load complete";
+ case AccessibilityNotificationMenuListValueChanged:
+ return "menu list changed";
+ case AccessibilityNotificationObjectShow:
+ return "object show";
+ case AccessibilityNotificationObjectHide:
+ return "object hide";
+ case AccessibilityNotificationRowCountChanged:
+ return "row count changed";
+ case AccessibilityNotificationRowCollapsed:
+ return "row collapsed";
+ case AccessibilityNotificationRowExpanded:
+ return "row expanded";
+ case AccessibilityNotificationScrolledToAnchor:
+ return "scrolled to anchor";
+ case AccessibilityNotificationSelectedChildrenChanged:
+ return "selected children changed";
+ case AccessibilityNotificationSelectedTextChanged:
+ return "selected text changed";
+ case AccessibilityNotificationTextInserted:
+ return "text inserted";
+ case AccessibilityNotificationTextRemoved:
+ return "text removed";
+ case AccessibilityNotificationValueChanged:
+ return "value changed";
+ default:
+ NOTREACHED();
+ }
+ return "";
+}
+#endif