From aef9284447e6e63d30448481e8cdf01ba1ecdf22 Mon Sep 17 00:00:00 2001 From: "dmazzoni@chromium.org" Date: Fri, 21 May 2010 16:54:36 +0000 Subject: Windows accessibility improvements: 1. All WebKit roles are now passed to the browser and then converted to MSAA roles - this is both because the logic needs to be more complicated, and so we can support Mac accessibility, too. 2. The serializable object used to pass accessibility info from the renderer to the browser now uses a map for uncommon attributes, rather than having a bunch of fields that are almost always empty. 3. Handles the accSelect method with TAKE_FOCUS, allowing assistive technology to set focus to a particular control. 4. Implements several other IAccessible2 interfaces. BUG=25564 BUG=13291 TEST=None Review URL: http://codereview.chromium.org/2121004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47922 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/renderer/render_view.cc | 29 +++++++++++++++++++++++++++-- chrome/renderer/render_view.h | 2 ++ 2 files changed, 29 insertions(+), 2 deletions(-) (limited to 'chrome/renderer') diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 45e2c37..d72b965 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -685,6 +685,9 @@ void RenderView::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(ViewMsg_TranslatePage, OnTranslatePage) IPC_MESSAGE_HANDLER(ViewMsg_RevertTranslation, OnRevertTranslation) IPC_MESSAGE_HANDLER(ViewMsg_GetAccessibilityTree, OnGetAccessibilityTree) + IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityFocus, OnSetAccessibilityFocus) + IPC_MESSAGE_HANDLER(ViewMsg_AccessibilityDoDefaultAction, + OnAccessibilityDoDefaultAction) // Have the super handle all other messages. IPC_MESSAGE_UNHANDLED(RenderWidget::OnMessageReceived(message)) @@ -3929,9 +3932,8 @@ void RenderView::OnUpdateBrowserWindowId(int window_id) { } void RenderView::OnGetAccessibilityTree() { - if (accessibility_.get()) { + if (accessibility_.get()) accessibility_->clear(); - } accessibility_.reset(WebAccessibilityCache::create()); accessibility_->initialize(webview()); @@ -3940,6 +3942,29 @@ void RenderView::OnGetAccessibilityTree() { Send(new ViewHostMsg_AccessibilityTree(routing_id_, dst_tree)); } +void RenderView::OnSetAccessibilityFocus(int acc_obj_id) { + if (!accessibility_.get()) + return; + if (accessibility_->isValidId(acc_obj_id)) { + // TODO(dmazzoni) fix the cache so that id=1000 is not a magic number. + // By convention, calling SetFocus on the root of the tree (id = 1000) + // should clear the current focus. Otherwise set the focus to the new + // node. + if (acc_obj_id == 1000) + webview()->clearFocusedNode(); + else + accessibility_->getObjectById(acc_obj_id).setFocused(true); + } +} + +void RenderView::OnAccessibilityDoDefaultAction(int acc_obj_id) { + if (!accessibility_.get()) + return; + if (accessibility_->isValidId(acc_obj_id)) { + accessibility_->getObjectById(acc_obj_id).performDefaultAction(); + } +} + void RenderView::OnGetAllSavableResourceLinksForCurrentPage( const GURL& page_url) { // Prepare list to storage all savable resource links. diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 35fa19f..972e2a7 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -497,6 +497,8 @@ class RenderView : public RenderWidget, void OnUserScriptIdleTriggered(WebKit::WebFrame* frame); void OnGetAccessibilityTree(); + void OnSetAccessibilityFocus(int acc_obj_id); + void OnAccessibilityDoDefaultAction(int acc_obj_id); #if defined(OS_MACOSX) // Helper routines for GPU plugin support. Used by the -- cgit v1.1