summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorctguil@chromium.org <ctguil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-25 06:41:14 +0000
committerctguil@chromium.org <ctguil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-25 06:41:14 +0000
commitdea2d37cbf7cfa80b8c357d81ca706ac856325b6 (patch)
treea2c6b4991563ffa0567729693951e2eb7e187ee5 /chrome
parent9d3f7d5e85d9834495434d7b925c1ba7933a344f (diff)
downloadchromium_src-dea2d37cbf7cfa80b8c357d81ca706ac856325b6.zip
chromium_src-dea2d37cbf7cfa80b8c357d81ca706ac856325b6.tar.gz
chromium_src-dea2d37cbf7cfa80b8c357d81ca706ac856325b6.tar.bz2
Support additional webkit accessibility notifications and states.
1. Update WebAccessibility::ConvertState to function similarly to WebCore's AccessibleBase::get_accState. 2. Use WebKit's load complete notification to send the renderer's tree to the browser. We enable accessibility on the renderer now instead of requesting a tree. 3. Use WebKit's focused ui element notification to send renderer focus events to the browser. BUG=13291 BUG=38106 TEST=interactive_ui_tests:AccessibilityWinBrowserTest.TestNotificationActiveDescendantChanged TEST=interactive_ui_tests:AccessibilityWinBrowserTest.TestNotificationFocusChanged Review URL: http://codereview.chromium.org/3380017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60569 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/accessibility_win_browsertest.cc120
-rw-r--r--chrome/browser/browser_accessibility_manager_win.cc52
-rw-r--r--chrome/browser/browser_accessibility_manager_win.h10
-rw-r--r--chrome/browser/browser_accessibility_win.cc13
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc9
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.h5
-rw-r--r--chrome/browser/renderer_host/mock_render_process_host.cc3
-rw-r--r--chrome/browser/renderer_host/mock_render_process_host.h2
-rw-r--r--chrome/browser/renderer_host/render_process_host.h3
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc46
-rw-r--r--chrome/browser/renderer_host/render_view_host.h2
-rw-r--r--chrome/browser/renderer_host/render_widget_host.cc22
-rw-r--r--chrome/browser/renderer_host/render_widget_host.h16
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view.h1
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_mac.h2
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_mac.mm8
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_win.cc37
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_win.h4
-rw-r--r--chrome/common/chrome_switches.cc3
-rw-r--r--chrome/common/chrome_switches.h1
-rw-r--r--chrome/common/render_messages_internal.h20
-rw-r--r--chrome/common/render_messages_params.h6
-rw-r--r--chrome/renderer/render_view.cc76
-rw-r--r--chrome/renderer/render_view.h4
24 files changed, 263 insertions, 202 deletions
diff --git a/chrome/browser/accessibility_win_browsertest.cc b/chrome/browser/accessibility_win_browsertest.cc
index c66bf2f..5ca921b 100644
--- a/chrome/browser/accessibility_win_browsertest.cc
+++ b/chrome/browser/accessibility_win_browsertest.cc
@@ -266,17 +266,15 @@ void AccessibleChecker::CheckAccessibleRole(IAccessible* accessible) {
VARIANT var_role = {0};
HRESULT hr =
accessible->get_accRole(CreateI4Variant(CHILDID_SELF), &var_role);
- EXPECT_EQ(hr, S_OK);
- ASSERT_TRUE(role_ == var_role);
+ ASSERT_EQ(hr, S_OK);
+ EXPECT_TRUE(role_ == var_role);
}
void AccessibleChecker::CheckAccessibleValue(IAccessible* accessible) {
CComBSTR value;
HRESULT hr =
accessible->get_accValue(CreateI4Variant(CHILDID_SELF), &value);
- // TODO(ctguil): Use EXPECT_EQ when render widget isn't using prop service.
- // EXPECT_EQ(hr, S_OK);
- EXPECT_TRUE(SUCCEEDED(hr));
+ EXPECT_EQ(S_OK, hr);
// Test that the correct string was returned.
EXPECT_STREQ(value_.c_str(),
@@ -291,8 +289,8 @@ void AccessibleChecker::CheckAccessibleState(IAccessible* accessible) {
HRESULT hr =
accessible->get_accState(CreateI4Variant(CHILDID_SELF), &var_state);
EXPECT_EQ(hr, S_OK);
- EXPECT_EQ(VT_I4, V_VT(&var_state));
- ASSERT_TRUE(state_ == V_I4(&var_state));
+ ASSERT_EQ(VT_I4, V_VT(&var_state));
+ EXPECT_EQ(state_, V_I4(&var_state));
}
void AccessibleChecker::CheckAccessibleChildren(IAccessible* parent) {
@@ -376,6 +374,55 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
}
IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
+ TestNotificationActiveDescendantChanged) {
+ GURL tree_url("data:text/html,<ul tabindex='-1' role='radiogroup'><li id='li'"
+ ">li</li></ul>");
+ browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED);
+ GetRendererAccessible();
+ ui_test_utils::WaitForNotification(
+ NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
+
+ // Check the browser's copy of the renderer accessibility tree.
+ AccessibleChecker list_marker_checker(L"", ROLE_SYSTEM_LISTITEM, L"\x2022");
+ AccessibleChecker static_text_checker(L"", ROLE_SYSTEM_TEXT, L"li");
+ AccessibleChecker list_item_checker(L"", ROLE_SYSTEM_LISTITEM, L"");
+ list_item_checker.SetExpectedState(
+ STATE_SYSTEM_READONLY);
+ AccessibleChecker radio_group_checker(L"", ROLE_SYSTEM_GROUPING, L"");
+ radio_group_checker.SetExpectedState(
+ STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY);
+ AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
+ list_item_checker.AppendExpectedChild(&list_marker_checker);
+ list_item_checker.AppendExpectedChild(&static_text_checker);
+ radio_group_checker.AppendExpectedChild(&list_item_checker);
+ document_checker.AppendExpectedChild(&radio_group_checker);
+ document_checker.CheckAccessible(GetRendererAccessible());
+
+ // Set focus to the radio group.
+ ExecuteScript(L"document.body.children[0].focus()");
+ ui_test_utils::WaitForNotification(
+ NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
+
+ // Check that the accessibility tree of the browser has been updated.
+ radio_group_checker.SetExpectedState(
+ STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED);
+ document_checker.CheckAccessible(GetRendererAccessible());
+
+ // Set the active descendant of the radio group
+ ExecuteScript(
+ L"document.body.children[0].setAttribute('aria-activedescendant', 'li')");
+ ui_test_utils::WaitForNotification(
+ NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
+
+ // Check that the accessibility tree of the browser has been updated.
+ list_item_checker.SetExpectedState(
+ STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED);
+ radio_group_checker.SetExpectedState(
+ STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY);
+ document_checker.CheckAccessible(GetRendererAccessible());
+}
+
+IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
TestNotificationCheckedStateChanged) {
GURL tree_url("data:text/html,<body><input type='checkbox' /></body>");
browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED);
@@ -406,9 +453,9 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
TestNotificationChildrenChanged) {
- // The aria-help attribute causes the node to be in the accessibility tree.
+ // The role attribute causes the node to be in the accessibility tree.
GURL tree_url(
- "data:text/html,<body aria-help='body'></body>");
+ "data:text/html,<body role=group></body>");
browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED);
GetRendererAccessible();
ui_test_utils::WaitForNotification(
@@ -432,14 +479,63 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
}
IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
- SelectedChildrenChanged) {
- GURL tree_url("data:text/html,<body><input type='text' value='old value'/>"
- "</body>");
+ TestNotificationFocusChanged) {
+ // The role attribute causes the node to be in the accessibility tree.
+ GURL tree_url(
+ "data:text/html,<div role=group tabindex='-1'></div>");
+ browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED);
+ GetRendererAccessible();
+ ui_test_utils::WaitForNotification(
+ NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
+
+ // Check the browser's copy of the renderer accessibility tree.
+ AccessibleChecker div_checker(L"", L"div", L"");
+ div_checker.SetExpectedState(
+ STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_OFFSCREEN | STATE_SYSTEM_READONLY);
+ AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
+ document_checker.AppendExpectedChild(&div_checker);
+ document_checker.CheckAccessible(GetRendererAccessible());
+
+ // Focus the div in the document
+ ExecuteScript(L"document.body.children[0].focus()");
+ ui_test_utils::WaitForNotification(
+ NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
+
+ // Check that the accessibility tree of the browser has been updated.
+ div_checker.SetExpectedState(
+ STATE_SYSTEM_FOCUSABLE | STATE_SYSTEM_READONLY | STATE_SYSTEM_FOCUSED);
+ document_checker.CheckAccessible(GetRendererAccessible());
+}
+
+// http://crbug.com/46209
+IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
+ DISABLED_TestNotificationChildrenChanged2) {
+ // The role attribute causes the node to be in the accessibility tree.
+ GURL tree_url(
+ "data:text/html,<div role=group style='visibility: hidden'>text"
+ "</div>");
browser()->OpenURL(tree_url, GURL(), CURRENT_TAB, PageTransition::TYPED);
GetRendererAccessible();
ui_test_utils::WaitForNotification(
NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
+
+ // Check the accessible tree of the browser.
+ AccessibleChecker document_checker(L"", ROLE_SYSTEM_DOCUMENT, L"");
+ document_checker.CheckAccessible(GetRendererAccessible());
+
+ // Change the children of the document body.
+ ExecuteScript(L"document.body.children[0].style.visibility='visible'");
+ ui_test_utils::WaitForNotification(
+ NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED);
+
+ // Check that the accessibility tree of the browser has been updated.
+ AccessibleChecker static_text_checker(L"", ROLE_SYSTEM_TEXT, L"text");
+ AccessibleChecker div_checker(L"", L"DIV", L"");
+ document_checker.AppendExpectedChild(&div_checker);
+ div_checker.AppendExpectedChild(&static_text_checker);
+ document_checker.CheckAccessible(GetRendererAccessible());
}
+
IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest,
TestNotificationValueChanged) {
GURL tree_url("data:text/html,<body><input type='text' value='old value'/>"
diff --git a/chrome/browser/browser_accessibility_manager_win.cc b/chrome/browser/browser_accessibility_manager_win.cc
index 88e6574..7f8b268 100644
--- a/chrome/browser/browser_accessibility_manager_win.cc
+++ b/chrome/browser/browser_accessibility_manager_win.cc
@@ -100,25 +100,8 @@ void BrowserAccessibilityManager::DoDefaultAction(
delegate_->AccessibilityDoDefaultAction(node.renderer_id());
}
-void BrowserAccessibilityManager::OnAccessibilityFocusChange(int renderer_id) {
- base::hash_map<int, LONG>::iterator iter =
- renderer_id_to_child_id_map_.find(renderer_id);
- if (iter == renderer_id_to_child_id_map_.end())
- return;
-
- LONG child_id = iter->second;
- base::hash_map<LONG, BrowserAccessibility*>::iterator uniq_iter =
- child_id_map_.find(child_id);
- if (uniq_iter != child_id_map_.end())
- focus_ = uniq_iter->second;
- ::NotifyWinEvent(EVENT_OBJECT_FOCUS, parent_hwnd_, OBJID_CLIENT, child_id);
-}
-
void BrowserAccessibilityManager::OnAccessibilityNotifications(
const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params) {
- if (delegate_)
- delegate_->AccessibilityNotificationsAck();
-
for (uint32 index = 0; index < params.size(); index++) {
const ViewHostMsg_AccessibilityNotification_Params& param = params[index];
@@ -132,6 +115,14 @@ void BrowserAccessibilityManager::OnAccessibilityNotifications(
OnAccessibilityObjectChildrenChange(param.acc_obj);
break;
case ViewHostMsg_AccessibilityNotification_Params::
+ NOTIFICATION_TYPE_FOCUS_CHANGED:
+ OnAccessibilityObjectFocusChange(param.acc_obj);
+ break;
+ case ViewHostMsg_AccessibilityNotification_Params::
+ NOTIFICATION_TYPE_LOAD_COMPLETE:
+ OnAccessibilityObjectLoadComplete(param.acc_obj);
+ break;
+ case ViewHostMsg_AccessibilityNotification_Params::
NOTIFICATION_TYPE_VALUE_CHANGED:
OnAccessibilityObjectValueChange(param.acc_obj);
break;
@@ -214,6 +205,33 @@ void BrowserAccessibilityManager::OnAccessibilityObjectChildrenChange(
NotifyWinEvent(EVENT_OBJECT_REORDER, parent_hwnd_, OBJID_CLIENT, child_id);
}
+void BrowserAccessibilityManager::OnAccessibilityObjectFocusChange(
+ const webkit_glue::WebAccessibility& acc_obj) {
+ BrowserAccessibility* new_browser_acc = UpdateTree(acc_obj);
+ if (!new_browser_acc)
+ return;
+
+ focus_ = new_browser_acc;
+ LONG child_id = new_browser_acc->child_id();
+ NotifyWinEvent(EVENT_OBJECT_FOCUS, parent_hwnd_, OBJID_CLIENT, child_id);
+}
+
+void BrowserAccessibilityManager::OnAccessibilityObjectLoadComplete(
+ const webkit_glue::WebAccessibility& acc_obj) {
+ root_->InactivateTree();
+ root_->Release();
+ focus_ = NULL;
+
+ root_ = CreateAccessibilityTree(NULL, GetNextChildID(), acc_obj, 0);
+ if (!focus_)
+ focus_ = root_;
+
+ LONG root_id = root_->child_id();
+ NotifyWinEvent(EVENT_OBJECT_FOCUS, parent_hwnd_, OBJID_CLIENT, root_id);
+ NotifyWinEvent(
+ IA2_EVENT_DOCUMENT_LOAD_COMPLETE, parent_hwnd_, OBJID_CLIENT, root_id);
+}
+
void BrowserAccessibilityManager::OnAccessibilityObjectValueChange(
const webkit_glue::WebAccessibility& acc_obj) {
BrowserAccessibility* new_browser_acc = UpdateTree(acc_obj);
diff --git a/chrome/browser/browser_accessibility_manager_win.h b/chrome/browser/browser_accessibility_manager_win.h
index 73994c2..429c66f 100644
--- a/chrome/browser/browser_accessibility_manager_win.h
+++ b/chrome/browser/browser_accessibility_manager_win.h
@@ -36,7 +36,6 @@ class BrowserAccessibilityDelegate {
virtual ~BrowserAccessibilityDelegate() {}
virtual void SetAccessibilityFocus(int acc_obj_id) = 0;
virtual void AccessibilityDoDefaultAction(int acc_obj_id) = 0;
- virtual void AccessibilityNotificationsAck() = 0;
};
// Manages a tree of BrowserAccessibility objects.
@@ -77,9 +76,8 @@ class BrowserAccessibilityManager {
// Tell the renderer to do the default action for this node.
void DoDefaultAction(const BrowserAccessibility& node);
- // Called when the renderer process has notified us of a focus, state,
- // or children change. Send a notification to MSAA clients of the change.
- void OnAccessibilityFocusChange(int acc_obj_id);
+ // Called when the renderer process has notified us of about tree changes.
+ // Send a notification to MSAA clients of the change.
void OnAccessibilityNotifications(
const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params);
@@ -94,6 +92,10 @@ class BrowserAccessibilityManager {
const webkit_glue::WebAccessibility& acc_obj);
void OnAccessibilityObjectChildrenChange(
const webkit_glue::WebAccessibility& acc_obj);
+ void OnAccessibilityObjectFocusChange(
+ const webkit_glue::WebAccessibility& acc_obj);
+ void OnAccessibilityObjectLoadComplete(
+ const webkit_glue::WebAccessibility& acc_obj);
void OnAccessibilityObjectValueChange(
const webkit_glue::WebAccessibility& acc_obj);
diff --git a/chrome/browser/browser_accessibility_win.cc b/chrome/browser/browser_accessibility_win.cc
index fce2daf..61fe5cf 100644
--- a/chrome/browser/browser_accessibility_win.cc
+++ b/chrome/browser/browser_accessibility_win.cc
@@ -1092,22 +1092,35 @@ void BrowserAccessibility::InitRoleAndState(LONG web_role,
if ((web_state >> WebAccessibility::STATE_CHECKED) & 1)
state_ |= STATE_SYSTEM_CHECKED;
+ if ((web_state >> WebAccessibility::STATE_COLLAPSED) & 1)
+ state_ |= STATE_SYSTEM_COLLAPSED;
+ if ((web_state >> WebAccessibility::STATE_EXPANDED) & 1)
+ state_ |= STATE_SYSTEM_EXPANDED;
if ((web_state >> WebAccessibility::STATE_FOCUSABLE) & 1)
state_ |= STATE_SYSTEM_FOCUSABLE;
+ if ((web_state >> WebAccessibility::STATE_HASPOPUP) & 1)
+ state_ |= STATE_SYSTEM_HASPOPUP;
if ((web_state >> WebAccessibility::STATE_HOTTRACKED) & 1)
state_ |= STATE_SYSTEM_HOTTRACKED;
if ((web_state >> WebAccessibility::STATE_INDETERMINATE) & 1)
state_ |= STATE_SYSTEM_INDETERMINATE;
+ if ((web_state >> WebAccessibility::STATE_INVISIBLE) & 1)
+ state_ |= STATE_SYSTEM_INVISIBLE;
if ((web_state >> WebAccessibility::STATE_LINKED) & 1)
state_ |= STATE_SYSTEM_LINKED;
if ((web_state >> WebAccessibility::STATE_MULTISELECTABLE) & 1)
state_ |= STATE_SYSTEM_MULTISELECTABLE;
+ // TODO(ctguil): Support STATE_SYSTEM_EXTSELECTABLE/accSelect.
if ((web_state >> WebAccessibility::STATE_OFFSCREEN) & 1)
state_ |= STATE_SYSTEM_OFFSCREEN;
if ((web_state >> WebAccessibility::STATE_PRESSED) & 1)
state_ |= STATE_SYSTEM_PRESSED;
if ((web_state >> WebAccessibility::STATE_PROTECTED) & 1)
state_ |= STATE_SYSTEM_PROTECTED;
+ if ((web_state >> WebAccessibility::STATE_SELECTABLE) & 1)
+ state_ |= STATE_SYSTEM_SELECTABLE;
+ if ((web_state >> WebAccessibility::STATE_SELECTED) & 1)
+ state_ |= STATE_SYSTEM_SELECTED;
if ((web_state >> WebAccessibility::STATE_READONLY) & 1)
state_ |= STATE_SYSTEM_READONLY;
if ((web_state >> WebAccessibility::STATE_TRAVERSED) & 1)
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index c380801..b6939a6 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -201,6 +201,7 @@ BrowserRenderProcessHost::BrowserRenderProcessHost(Profile* profile)
ALLOW_THIS_IN_INITIALIZER_LIST(cached_dibs_cleaner_(
base::TimeDelta::FromSeconds(5),
this, &BrowserRenderProcessHost::ClearTransportDIBCache)),
+ accessibility_enabled_(false),
extension_process_(false) {
widget_helper_ = new RenderWidgetHelper();
@@ -246,12 +247,15 @@ BrowserRenderProcessHost::~BrowserRenderProcessHost() {
ClearTransportDIBCache();
}
-bool BrowserRenderProcessHost::Init(bool is_extensions_process) {
+bool BrowserRenderProcessHost::Init(
+ bool is_accessibility_enabled, bool is_extensions_process) {
// calling Init() more than once does nothing, this makes it more convenient
// for the view host which may not be sure in some cases
if (channel_.get())
return true;
+ accessibility_enabled_ = is_accessibility_enabled;
+
// It is possible for an extension process to be reused for non-extension
// content, e.g. if an extension calls window.open.
extension_process_ = extension_process_ || is_extensions_process;
@@ -449,6 +453,9 @@ void BrowserRenderProcessHost::AppendRendererCommandLine(
if (logging::DialogsAreSuppressed())
command_line->AppendSwitch(switches::kNoErrorDialogs);
+ if (accessibility_enabled_)
+ command_line->AppendSwitch(switches::kEnableAccessibility);
+
// Now send any options from our own command line we want to propogate.
const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
PropagateBrowserCommandLineToRenderer(browser_command_line, command_line);
diff --git a/chrome/browser/renderer_host/browser_render_process_host.h b/chrome/browser/renderer_host/browser_render_process_host.h
index 3200947..9983c84 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.h
+++ b/chrome/browser/renderer_host/browser_render_process_host.h
@@ -61,7 +61,7 @@ class BrowserRenderProcessHost : public RenderProcessHost,
~BrowserRenderProcessHost();
// RenderProcessHost implementation (public portion).
- virtual bool Init(bool is_extensions_process);
+ virtual bool Init(bool is_accessibility_enabled, bool is_extensions_process);
virtual int GetNextRoutingID();
virtual void CancelResourceRequests(int render_widget_id);
virtual void CrossSiteClosePageACK(const ViewMsg_ClosePage_Params& params);
@@ -198,6 +198,9 @@ class BrowserRenderProcessHost : public RenderProcessHost,
// Buffer visited links and send them to to renderer.
scoped_ptr<VisitedLinkUpdater> visited_link_updater_;
+ // True if this prcoess should have accessibility enabled;
+ bool accessibility_enabled_;
+
// True iff this process is being used as an extension process. Not valid
// when running in single-process mode.
bool extension_process_;
diff --git a/chrome/browser/renderer_host/mock_render_process_host.cc b/chrome/browser/renderer_host/mock_render_process_host.cc
index 3866239..63272f5 100644
--- a/chrome/browser/renderer_host/mock_render_process_host.cc
+++ b/chrome/browser/renderer_host/mock_render_process_host.cc
@@ -20,7 +20,8 @@ MockRenderProcessHost::~MockRenderProcessHost() {
delete transport_dib_;
}
-bool MockRenderProcessHost::Init(bool is_extensions_process) {
+bool MockRenderProcessHost::Init(
+ bool is_accessibility_enabled, bool is_extensions_process) {
return true;
}
diff --git a/chrome/browser/renderer_host/mock_render_process_host.h b/chrome/browser/renderer_host/mock_render_process_host.h
index 608821d..34f00f9 100644
--- a/chrome/browser/renderer_host/mock_render_process_host.h
+++ b/chrome/browser/renderer_host/mock_render_process_host.h
@@ -31,7 +31,7 @@ class MockRenderProcessHost : public RenderProcessHost {
int bad_msg_count() const { return bad_msg_count_; }
// RenderProcessHost implementation (public portion).
- virtual bool Init(bool is_extensions_process);
+ virtual bool Init(bool is_accessibility_enabled, bool is_extensions_process);
virtual int GetNextRoutingID();
virtual void CancelResourceRequests(int render_widget_id);
virtual void CrossSiteClosePageACK(const ViewMsg_ClosePage_Params& params);
diff --git a/chrome/browser/renderer_host/render_process_host.h b/chrome/browser/renderer_host/render_process_host.h
index f2b26fb..19911f0 100644
--- a/chrome/browser/renderer_host/render_process_host.h
+++ b/chrome/browser/renderer_host/render_process_host.h
@@ -148,7 +148,8 @@ class RenderProcessHost : public IPC::Channel::Sender,
// be called once before the object can be used, but can be called after
// that with no effect. Therefore, if the caller isn't sure about whether
// the process has been created, it should just call Init().
- virtual bool Init(bool is_extensions_process) = 0;
+ virtual bool Init(
+ bool is_accessibility_enabled, bool is_extensions_process) = 0;
// Gets the next available routing id.
virtual int GetNextRoutingID() = 0;
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 1cad374..7fe1ce5 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -157,7 +157,7 @@ bool RenderViewHost::CreateRenderView(const string16& frame_name) {
// initialized it) or may not (we have our own process or the old process
// crashed) have been initialized. Calling Init multiple times will be
// ignored, so this is safe.
- if (!process()->Init(is_extension_process_))
+ if (!process()->Init(renderer_accessible(), is_extension_process_))
return false;
DCHECK(process()->HasConnection());
DCHECK(process()->profile());
@@ -844,8 +844,6 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnMsgSelectionChanged)
IPC_MESSAGE_HANDLER(ViewHostMsg_ExtensionPostMessage,
OnExtensionPostMessage)
- IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityFocusChange,
- OnAccessibilityFocusChange)
IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityNotifications,
OnAccessibilityNotifications)
IPC_MESSAGE_HANDLER(ViewHostMsg_OnCSSInserted, OnCSSInserted)
@@ -854,7 +852,6 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(ViewHostMsg_ContentBlocked, OnContentBlocked)
IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed)
IPC_MESSAGE_HANDLER(ViewHostMsg_WebDatabaseAccessed, OnWebDatabaseAccessed)
- IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityTree, OnAccessibilityTree)
IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnMsgFocusedNodeChanged)
IPC_MESSAGE_HANDLER(ViewHostMsg_SetDisplayingPDFContent,
OnSetDisplayingPDFContent)
@@ -1023,12 +1020,6 @@ void RenderViewHost::OnMsgNavigate(const IPC::Message& msg) {
FilterURL(policy, renderer_id, &validated_params.password_form.origin);
FilterURL(policy, renderer_id, &validated_params.password_form.action);
- if (!validated_params.was_within_same_page) {
- // Only set that the document is not loaded if the navigation was not within
- // the current page. If it was within the same page, the document will not
- // load again.
- SetDocumentLoaded(false);
- }
delegate_->DidNavigate(this, validated_params);
}
@@ -1326,7 +1317,6 @@ void RenderViewHost::OnMsgDocumentLoadedInFrame() {
delegate_->GetResourceDelegate();
if (resource_delegate)
resource_delegate->DocumentLoadedInFrame();
- SetDocumentLoaded(true);
}
void RenderViewHost::DisassociateFromPopupCount() {
@@ -1958,36 +1948,34 @@ void RenderViewHost::OnExtensionPostMessage(
}
}
-void RenderViewHost::OnAccessibilityFocusChange(int acc_obj_id) {
- if (view())
- view()->OnAccessibilityFocusChange(acc_obj_id);
-}
-
void RenderViewHost::OnAccessibilityNotifications(
const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params) {
if (view())
view()->OnAccessibilityNotifications(params);
if (params.size() > 0) {
+ for (unsigned i = 0; i < params.size(); i++) {
+ const ViewHostMsg_AccessibilityNotification_Params& param = params[i];
+
+ if (param.notification_type ==
+ ViewHostMsg_AccessibilityNotification_Params::
+ NOTIFICATION_TYPE_LOAD_COMPLETE) {
+ // TODO(ctguil): Remove when mac processes OnAccessibilityNotifications.
+ if (view())
+ view()->UpdateAccessibilityTree(param.acc_obj);
+
+ if (save_accessibility_tree_for_testing_)
+ accessibility_tree_ = param.acc_obj;
+ }
+ }
+
NotificationService::current()->Notify(
NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
Source<RenderViewHost>(this),
NotificationService::NoDetails());
}
-}
-
-void RenderViewHost::OnAccessibilityTree(
- const webkit_glue::WebAccessibility& tree) {
- if (view())
- view()->UpdateAccessibilityTree(tree);
- if (save_accessibility_tree_for_testing_)
- accessibility_tree_ = tree;
-
- NotificationService::current()->Notify(
- NotificationType::RENDER_VIEW_HOST_ACCESSIBILITY_TREE_UPDATED,
- Source<RenderViewHost>(this),
- NotificationService::NoDetails());
+ AccessibilityNotificationsAck();
}
void RenderViewHost::OnCSSInserted() {
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 6d3d156..5fce6d9 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -657,10 +657,8 @@ class RenderViewHost : public RenderWidgetHost {
void OnExtensionRequest(const ViewHostMsg_DomMessage_Params& params);
void OnExtensionPostMessage(int port_id, const std::string& message);
- void OnAccessibilityFocusChange(int acc_obj_id);
void OnAccessibilityNotifications(
const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params);
- void OnAccessibilityTree(const webkit_glue::WebAccessibility& tree);
void OnCSSInserted();
void OnPageContents(const GURL& url,
int32 page_id,
diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc
index cb757ab..6153331 100644
--- a/chrome/browser/renderer_host/render_widget_host.cc
+++ b/chrome/browser/renderer_host/render_widget_host.cc
@@ -1138,22 +1138,6 @@ void RenderWidgetHost::AdvanceToNextMisspelling() {
Send(new ViewMsg_AdvanceToNextMisspelling(routing_id_));
}
-void RenderWidgetHost::RequestAccessibilityTree() {
- Send(new ViewMsg_GetAccessibilityTree(routing_id()));
-}
-
-void RenderWidgetHost::SetDocumentLoaded(bool document_loaded) {
- document_loaded_ = document_loaded;
-
- if (!document_loaded_)
- requested_accessibility_tree_ = false;
-
- if (renderer_accessible_ && document_loaded_) {
- RequestAccessibilityTree();
- requested_accessibility_tree_ = true;
- }
-}
-
void RenderWidgetHost::EnableRendererAccessibility() {
if (renderer_accessible_)
return;
@@ -1165,9 +1149,9 @@ void RenderWidgetHost::EnableRendererAccessibility() {
renderer_accessible_ = true;
- if (document_loaded_ && !requested_accessibility_tree_) {
- RequestAccessibilityTree();
- requested_accessibility_tree_ = true;
+ if (process_->HasConnection()) {
+ // Renderer accessibility wasn't enabled on process launch. Enable it now.
+ Send(new ViewMsg_EnableAccessibility(routing_id()));
}
}
diff --git a/chrome/browser/renderer_host/render_widget_host.h b/chrome/browser/renderer_host/render_widget_host.h
index 8fcedd1..390cc31 100644
--- a/chrome/browser/renderer_host/render_widget_host.h
+++ b/chrome/browser/renderer_host/render_widget_host.h
@@ -146,6 +146,7 @@ class RenderWidgetHost : public IPC::Channel::Listener,
RenderProcessHost* process() const { return process_; }
int routing_id() const { return routing_id_; }
+ static bool renderer_accessible() { return renderer_accessible_; }
// Set the PaintObserver on this object. Takes ownership.
void set_paint_observer(PaintObserver* paint_observer) {
@@ -399,13 +400,6 @@ class RenderWidgetHost : public IPC::Channel::Listener,
}
protected:
- // Aid for determining when an accessibility tree request can be made. Set by
- // TabContents to true on document load and to false on page navigation.
- void SetDocumentLoaded(bool document_loaded);
-
- // Requests a snapshot of an accessible DOM tree from the renderer.
- void RequestAccessibilityTree();
-
// Internal implementation of the public Forward*Event() methods.
void ForwardInputEvent(const WebKit::WebInputEvent& input_event,
int event_size, bool is_keyboard_shortcut);
@@ -688,14 +682,6 @@ class RenderWidgetHost : public IPC::Channel::Listener,
// changed.
bool suppress_next_char_events_;
- // Keep track of if we have a loaded document so that we can request an
- // accessibility tree on demand when renderer accessibility is enabled.
- bool document_loaded_;
-
- // Keep track of if we've already requested the accessibility tree so
- // we don't do it more than once.
- bool requested_accessibility_tree_;
-
// Optional video YUV layer for used for out-of-process compositing.
scoped_ptr<VideoLayer> video_layer_;
diff --git a/chrome/browser/renderer_host/render_widget_host_view.h b/chrome/browser/renderer_host/render_widget_host_view.h
index 1dab773..4258a86 100644
--- a/chrome/browser/renderer_host/render_widget_host_view.h
+++ b/chrome/browser/renderer_host/render_widget_host_view.h
@@ -252,7 +252,6 @@ class RenderWidgetHostView {
virtual void UpdateAccessibilityTree(
const webkit_glue::WebAccessibility& tree) { }
- virtual void OnAccessibilityFocusChange(int acc_obj_id) { }
virtual void OnAccessibilityNotifications(
const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params) {
}
diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.h b/chrome/browser/renderer_host/render_widget_host_view_mac.h
index 688ee42..41b4316 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.h
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.h
@@ -219,8 +219,6 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView {
virtual bool ContainsNativeView(gfx::NativeView native_view) const;
virtual void UpdateAccessibilityTree(
const webkit_glue::WebAccessibility& tree);
- virtual void OnAccessibilityFocusChange(int acc_obj_id);
- virtual void OnAccessibilityObjectStateChange(int acc_obj_id);
// Methods associated with GPU-accelerated plug-in instances and the
// accelerated compositor.
virtual gfx::PluginWindowHandle AllocateFakePluginWindowHandle(bool opaque,
diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
index b727b81..1345f84 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
@@ -1099,14 +1099,6 @@ void RenderWidgetHostViewMac::UpdateAccessibilityTree(
}
}
-void RenderWidgetHostViewMac::OnAccessibilityFocusChange(int acc_obj_id) {
- NOTIMPLEMENTED();
-}
-
-void RenderWidgetHostViewMac::OnAccessibilityObjectStateChange(int acc_obj_id) {
- NOTIMPLEMENTED();
-}
-
void RenderWidgetHostViewMac::SetTextInputActive(bool active) {
if (active) {
if (text_input_type_ == WebKit::WebTextInputTypePassword)
diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc
index ad85f03..2640163 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_win.cc
+++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc
@@ -1477,31 +1477,18 @@ LRESULT RenderWidgetHostViewWin::OnMouseActivate(UINT, WPARAM, LPARAM,
return MA_ACTIVATE;
}
-void RenderWidgetHostViewWin::UpdateAccessibilityTree(
- const webkit_glue::WebAccessibility& tree) {
- browser_accessibility_manager_.reset(
- new BrowserAccessibilityManager(m_hWnd, tree, this));
-
- BrowserAccessibility* root = browser_accessibility_manager_.get()->GetRoot();
- LONG root_id;
- if (root && SUCCEEDED(root->get_uniqueID(&root_id))) {
- ::NotifyWinEvent(
- EVENT_OBJECT_FOCUS, m_hWnd, OBJID_CLIENT, root_id);
- ::NotifyWinEvent(
- IA2_EVENT_DOCUMENT_LOAD_COMPLETE, m_hWnd, OBJID_CLIENT, root_id);
- }
-}
-
-void RenderWidgetHostViewWin::OnAccessibilityFocusChange(int acc_obj_id) {
- if (browser_accessibility_manager_.get()) {
- browser_accessibility_manager_->OnAccessibilityFocusChange(acc_obj_id);
- }
-}
-
void RenderWidgetHostViewWin::OnAccessibilityNotifications(
const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params) {
- if (browser_accessibility_manager_.get())
- browser_accessibility_manager_->OnAccessibilityNotifications(params);
+ if (!browser_accessibility_manager_.get()) {
+ // Use empty document to process notifications
+ webkit_glue::WebAccessibility empty_document;
+ empty_document.role = WebAccessibility::ROLE_DOCUMENT;
+ empty_document.state = 0;
+ browser_accessibility_manager_.reset(
+ new BrowserAccessibilityManager(m_hWnd, empty_document, this));
+ }
+
+ browser_accessibility_manager_->OnAccessibilityNotifications(params);
}
void RenderWidgetHostViewWin::Observe(NotificationType type,
@@ -1546,10 +1533,6 @@ void RenderWidgetHostViewWin::AccessibilityDoDefaultAction(int acc_obj_id) {
render_widget_host_->AccessibilityDoDefaultAction(acc_obj_id);
}
-void RenderWidgetHostViewWin::AccessibilityNotificationsAck() {
- render_widget_host_->AccessibilityNotificationsAck();
-}
-
LRESULT RenderWidgetHostViewWin::OnGetObject(UINT message, WPARAM wparam,
LPARAM lparam, BOOL& handled) {
if (lparam != OBJID_CLIENT) {
diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.h b/chrome/browser/renderer_host/render_widget_host_view_win.h
index 8f00a38..87dd687 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_win.h
+++ b/chrome/browser/renderer_host/render_widget_host_view_win.h
@@ -153,9 +153,6 @@ class RenderWidgetHostViewWin
virtual void SetBackground(const SkBitmap& background);
virtual bool ContainsNativeView(gfx::NativeView native_view) const;
virtual void SetVisuallyDeemphasized(bool deemphasized);
- virtual void UpdateAccessibilityTree(
- const webkit_glue::WebAccessibility& tree);
- virtual void OnAccessibilityFocusChange(int acc_obj_id);
virtual void OnAccessibilityNotifications(
const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params);
@@ -167,7 +164,6 @@ class RenderWidgetHostViewWin
// Implementation of BrowserAccessibilityDelegate:
virtual void SetAccessibilityFocus(int acc_obj_id);
virtual void AccessibilityDoDefaultAction(int acc_obj_id);
- virtual void AccessibilityNotificationsAck();
protected:
// Windows Message Handlers
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index 3f0da98..639d42b 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -359,6 +359,9 @@ extern const char kLogNetLog[] = "log-net-log";
// Enable gpu-accelerated 2d canvas.
const char kEnableAccelerated2dCanvas[] = "enable-accelerated-2d-canvas";
+// Enables WebKit accessibility within the renderer process.
+const char kEnableAccessibility[] = "enable-accessibility";
+
// Enables AeroPeek for each tab. (This switch only works on Windows 7).
const char kEnableAeroPeekTabs[] = "enable-aero-peek-tabs";
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index 105d522..f52dbb9 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -113,6 +113,7 @@ extern const char kDnsPrefetchDisable[];
extern const char kDomAutomationController[];
extern const char kDumpHistogramsOnExit[];
extern const char kEnableAccelerated2dCanvas[];
+extern const char kEnableAccessibility[];
extern const char kEnableAeroPeekTabs[];
extern const char kEnableAuthNegotiatePort[];
extern const char kEnableBackgroundMode[];
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 7b0682f..b5de540 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -992,8 +992,8 @@ IPC_BEGIN_MESSAGES(View)
IPC_MESSAGE_CONTROL1(ViewMsg_ExtensionsUpdated,
ViewMsg_ExtensionsUpdated_Params)
- // Request a tree of Accessibility data from the render process.
- IPC_MESSAGE_ROUTED0(ViewMsg_GetAccessibilityTree)
+ // Enable accessibility in the renderer process.
+ IPC_MESSAGE_ROUTED0(ViewMsg_EnableAccessibility)
// Relay a request from assistive technology to set focus to a given node.
IPC_MESSAGE_ROUTED1(ViewMsg_SetAccessibilityFocus,
@@ -2243,28 +2243,12 @@ IPC_BEGIN_MESSAGES(ViewHost)
IPC_MESSAGE_CONTROL1(ViewHostMsg_ExtensionCloseChannel,
int /* port_id */)
- // Sent as a result of a focus change in the renderer (if accessibility is
- // enabled), to notify the browser side that its accessibility focus needs to
- // change as well. Takes the id of the accessibility object that now has
- // focus.
- IPC_MESSAGE_ROUTED1(ViewHostMsg_AccessibilityFocusChange,
- int /* accessibility object id */)
-
- // Sent by the renderer when the state of an accessibility node changes.
- IPC_MESSAGE_ROUTED1(ViewHostMsg_AccessibilityObjectStateChange,
- webkit_glue::WebAccessibility)
-
// Sent to notify the browser about renderer accessibility notifications.
// The browser responds with a ViewMsg_AccessibilityNotifications_ACK.
IPC_MESSAGE_ROUTED1(
ViewHostMsg_AccessibilityNotifications,
std::vector<ViewHostMsg_AccessibilityNotification_Params>)
- // Send the tree of accessibility data to the browser, where it's cached
- // in order to respond to OS accessibility queries immediately.
- IPC_MESSAGE_ROUTED1(ViewHostMsg_AccessibilityTree,
- webkit_glue::WebAccessibility)
-
// Message sent from the renderer to the browser to request that the browser
// close all sockets. Used for debugging/testing.
IPC_MESSAGE_CONTROL0(ViewHostMsg_CloseCurrentConnections)
diff --git a/chrome/common/render_messages_params.h b/chrome/common/render_messages_params.h
index 0af173e..8cb9d93 100644
--- a/chrome/common/render_messages_params.h
+++ b/chrome/common/render_messages_params.h
@@ -997,6 +997,12 @@ struct ViewHostMsg_AccessibilityNotification_Params {
// The node tree structure has changed.
NOTIFICATION_TYPE_CHILDREN_CHANGED,
+ // The node in focus has changed.
+ NOTIFICATION_TYPE_FOCUS_CHANGED,
+
+ // The document node has loaded.
+ NOTIFICATION_TYPE_LOAD_COMPLETE,
+
// The node value has changed.
NOTIFICATION_TYPE_VALUE_CHANGED,
};
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index c3e2aa0..522f762 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -665,6 +665,8 @@ void RenderView::Init(gfx::NativeViewId parent_hwnd,
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
if (command_line.HasSwitch(switches::kDomAutomationController))
enabled_bindings_ |= BindingsPolicy::DOM_AUTOMATION;
+ if (command_line.HasSwitch(switches::kEnableAccessibility))
+ WebAccessibilityCache::enableAccessibility();
audio_message_filter_ = new AudioMessageFilter(routing_id_);
render_thread_->AddFilter(audio_message_filter_);
@@ -804,7 +806,7 @@ void RenderView::OnMessageReceived(const IPC::Message& message) {
OnCustomContextMenuAction)
IPC_MESSAGE_HANDLER(ViewMsg_TranslatePage, OnTranslatePage)
IPC_MESSAGE_HANDLER(ViewMsg_RevertTranslation, OnRevertTranslation)
- IPC_MESSAGE_HANDLER(ViewMsg_GetAccessibilityTree, OnGetAccessibilityTree)
+ IPC_MESSAGE_HANDLER(ViewMsg_EnableAccessibility, OnEnableAccessibility)
IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityFocus, OnSetAccessibilityFocus)
IPC_MESSAGE_HANDLER(ViewMsg_AccessibilityDoDefaultAction,
OnAccessibilityDoDefaultAction)
@@ -1478,8 +1480,8 @@ void RenderView::UpdateURL(WebFrame* frame) {
if (accessibility_.get() && !navigation_state->was_within_same_page()) {
accessibility_->clear();
accessibility_.reset();
+ pending_accessibility_notifications_.clear();
}
- pending_accessibility_notifications_.clear();
}
// Tell the embedding application that the title of the active page has changed
@@ -4398,16 +4400,20 @@ void RenderView::OnUpdateBrowserWindowId(int window_id) {
browser_window_id_ = window_id;
}
-void RenderView::OnGetAccessibilityTree() {
- if (accessibility_.get())
- accessibility_->clear();
- accessibility_.reset(WebAccessibilityCache::create());
- accessibility_->initialize(webview());
- pending_accessibility_notifications_.clear();
+void RenderView::OnEnableAccessibility() {
+ if (WebAccessibilityCache::accessibilityEnabled())
+ return;
- WebAccessibilityObject src_tree = webview()->accessibilityObject();
- WebAccessibility dst_tree(src_tree, accessibility_.get());
- Send(new ViewHostMsg_AccessibilityTree(routing_id_, dst_tree));
+ WebAccessibilityCache::enableAccessibility();
+
+ if (webview()) {
+ // It's possible that the webview has already loaded a webpage without
+ // accessibility being enabled. Initialize the browser's cached
+ // accessibility tree by sending it a 'load complete' notification.
+ postAccessibilityNotification(
+ webview()->accessibilityObject(),
+ WebKit::WebAccessibilityNotificationLoadComplete);
+ }
}
void RenderView::OnSetAccessibilityFocus(int acc_obj_id) {
@@ -5472,34 +5478,22 @@ void RenderView::LogNavigationState(const NavigationState* state,
<< url.spec();
}
-void RenderView::focusAccessibilityObject(
- const WebAccessibilityObject& acc_obj) {
-#if defined(OS_WIN)
- // TODO(dglazkov): Current logic implies that focus change can only be made
- // after at least one call to RenderView::OnGetAccessibilityInfo, which is
- // where accessibility is initialized. We should determine whether that's
- // right.
- if (!accessibility_.get())
- return;
-
- // Retrieve the accessibility object id of the AccessibilityObject.
- int acc_obj_id = accessibility_->addOrGetId(acc_obj);
-
- // If id is valid, alert the browser side that an accessibility focus change
- // occurred.
- if (acc_obj_id >= 0)
- Send(new ViewHostMsg_AccessibilityFocusChange(routing_id_, acc_obj_id));
-
-#else // defined(OS_WIN)
- // TODO(port): accessibility not yet implemented
- NOTIMPLEMENTED();
-#endif
-}
-
void RenderView::postAccessibilityNotification(
const WebAccessibilityObject& obj,
WebAccessibilityNotification notification) {
- if (!accessibility_.get() || (accessibility_->addOrGetId(obj) < 0))
+ if (!accessibility_.get() && webview()) {
+ // Load complete should be our first notification sent.
+ // TODO(ctguil): Investigate if a different notification is a WebCore bug.
+ if (notification != WebKit::WebAccessibilityNotificationLoadComplete)
+ return;
+
+ // Create and initialize our accessibility cache
+ accessibility_.reset(WebAccessibilityCache::create());
+ accessibility_->initialize(webview());
+ }
+
+ // Add the accessibility object to our cache and ensure it's valid.
+ if (accessibility_->addOrGetId(obj) < 0)
return;
ViewHostMsg_AccessibilityNotification_Params param;
@@ -5514,6 +5508,16 @@ void RenderView::postAccessibilityNotification(
ViewHostMsg_AccessibilityNotification_Params::
NOTIFICATION_TYPE_CHILDREN_CHANGED;
break;
+ case WebKit::WebAccessibilityNotificationFocusedUIElementChanged:
+ param.notification_type =
+ ViewHostMsg_AccessibilityNotification_Params::
+ NOTIFICATION_TYPE_FOCUS_CHANGED;
+ break;
+ case WebKit::WebAccessibilityNotificationLoadComplete:
+ param.notification_type =
+ ViewHostMsg_AccessibilityNotification_Params::
+ NOTIFICATION_TYPE_LOAD_COMPLETE;
+ break;
case WebKit::WebAccessibilityNotificationValueChanged:
param.notification_type =
ViewHostMsg_AccessibilityNotification_Params::
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 1a8e0b5..0826b6c5 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -412,8 +412,6 @@ class RenderView : public RenderWidget,
virtual void navigateBackForwardSoon(int offset);
virtual int historyBackListCount();
virtual int historyForwardListCount();
- virtual void focusAccessibilityObject(
- const WebKit::WebAccessibilityObject& acc_obj);
virtual void postAccessibilityNotification(
const WebKit::WebAccessibilityObject& obj,
WebKit::WebAccessibilityNotification notification);
@@ -801,7 +799,7 @@ class RenderView : public RenderWidget,
void OnFileChooserResponse(const std::vector<FilePath>& paths);
void OnFind(int request_id, const string16&, const WebKit::WebFindOptions&);
void OnFindReplyAck();
- void OnGetAccessibilityTree();
+ void OnEnableAccessibility();
void OnGetAllSavableResourceLinksForCurrentPage(const GURL& page_url);
void OnGetApplicationInfo(int page_id);
void OnGetSerializedHtmlDataForCurrentPageWithLocalLinks(