diff options
author | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-11 14:31:09 +0000 |
---|---|---|
committer | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-11 14:31:09 +0000 |
commit | b3df5a4b6ea1c145a0945f2dca73c073ed53dae0 (patch) | |
tree | bb4dc38a4ed280f63fec773a48d78e374f5ba158 /chrome/common | |
parent | faf2ee4705a9e0c154d57cb7daeb0157431d8103 (diff) | |
download | chromium_src-b3df5a4b6ea1c145a0945f2dca73c073ed53dae0.zip chromium_src-b3df5a4b6ea1c145a0945f2dca73c073ed53dae0.tar.gz chromium_src-b3df5a4b6ea1c145a0945f2dca73c073ed53dae0.tar.bz2 |
Reimplement accessibility of web content by caching the entire
accessibility tree in the browser process.
Adds new RPCs for a browser tab to request accessibility info from
a renderer; the renderer responds with a complete tree of
accessibility metadata for the entire DOM, which is then cached
in the RenderWidgetHostView. This part is cross-platform and will
help with accessibility on both Windows and Mac OS X.
For Windows, MSAA support for web content has been rewritten to
use this new cache. Tested in JAWS and NVDA screen readers.
Using Chrome with a screen reader is now fast and stable,
unlike the previous implementation. However, note that most
advanced functionality is still not supported, and much work remains
to make Chrome work well with a screen reader. This is a necessary
step to improve stability first.
BUG=25564
BUG=13291
TEST=See http://codereview.chromium.org/1806001
Review URL: http://codereview.chromium.org/1637018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46916 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/render_messages.h | 141 | ||||
-rw-r--r-- | chrome/common/render_messages_internal.h | 22 | ||||
-rw-r--r-- | chrome/common/render_messages_unittest.cc | 96 |
3 files changed, 170 insertions, 89 deletions
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h index 3770fe2..7f6ce16 100644 --- a/chrome/common/render_messages.h +++ b/chrome/common/render_messages.h @@ -711,80 +711,6 @@ struct ParamTraits<FilterPolicy::Type> { }; template <> -struct ParamTraits<webkit_glue::WebAccessibility::InParams> { - typedef webkit_glue::WebAccessibility::InParams param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.object_id); - WriteParam(m, p.function_id); - WriteParam(m, p.child_id); - WriteParam(m, p.input_long1); - WriteParam(m, p.input_long2); - } - static bool Read(const Message* m, void** iter, param_type* p) { - return - ReadParam(m, iter, &p->object_id) && - ReadParam(m, iter, &p->function_id) && - ReadParam(m, iter, &p->child_id) && - ReadParam(m, iter, &p->input_long1) && - ReadParam(m, iter, &p->input_long2); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"("); - LogParam(p.object_id, l); - l->append(L", "); - LogParam(p.function_id, l); - l->append(L", "); - LogParam(p.child_id, l); - l->append(L", "); - LogParam(p.input_long1, l); - l->append(L", "); - LogParam(p.input_long2, l); - l->append(L")"); - } -}; - -template <> -struct ParamTraits<webkit_glue::WebAccessibility::OutParams> { - typedef webkit_glue::WebAccessibility::OutParams param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.object_id); - WriteParam(m, p.output_long1); - WriteParam(m, p.output_long2); - WriteParam(m, p.output_long3); - WriteParam(m, p.output_long4); - WriteParam(m, p.output_string); - WriteParam(m, p.return_code); - } - static bool Read(const Message* m, void** iter, param_type* p) { - return - ReadParam(m, iter, &p->object_id) && - ReadParam(m, iter, &p->output_long1) && - ReadParam(m, iter, &p->output_long2) && - ReadParam(m, iter, &p->output_long3) && - ReadParam(m, iter, &p->output_long4) && - ReadParam(m, iter, &p->output_string) && - ReadParam(m, iter, &p->return_code); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"("); - LogParam(p.object_id, l); - l->append(L", "); - LogParam(p.output_long1, l); - l->append(L", "); - LogParam(p.output_long2, l); - l->append(L", "); - LogParam(p.output_long3, l); - l->append(L", "); - LogParam(p.output_long4, l); - l->append(L", "); - LogParam(p.output_string, l); - l->append(L", "); - LogParam(p.return_code, l); - l->append(L")"); - } -}; - -template <> struct ParamTraits<ViewHostMsg_ImeControl> { typedef ViewHostMsg_ImeControl param_type; static void Write(Message* m, const param_type& p) { @@ -2668,8 +2594,73 @@ struct ParamTraits<WindowContainerType> { } }; -} // namespace IPC +template <> +struct ParamTraits<webkit_glue::WebAccessibility> { + typedef webkit_glue::WebAccessibility param_type; + static void Write(Message* m, const param_type& p) { + WriteParam(m, p.id); + WriteParam(m, p.name); + WriteParam(m, p.value); + WriteParam(m, p.action); + WriteParam(m, p.description); + WriteParam(m, p.help); + WriteParam(m, p.shortcut); + WriteParam(m, static_cast<int>(p.role)); + WriteParam(m, static_cast<int>(p.state)); + WriteParam(m, p.location); + WriteParam(m, p.children); + } + static bool Read(const Message* m, void** iter, param_type* p) { + bool ret = ReadParam(m, iter, &p->id); + ret = ret && ReadParam(m, iter, &p->name); + ret = ret && ReadParam(m, iter, &p->value); + ret = ret && ReadParam(m, iter, &p->action); + ret = ret && ReadParam(m, iter, &p->description); + ret = ret && ReadParam(m, iter, &p->help); + ret = ret && ReadParam(m, iter, &p->shortcut); + int role = -1; + ret = ret && ReadParam(m, iter, &role); + if (role >= webkit_glue::WebAccessibility::ROLE_NONE && + role < webkit_glue::WebAccessibility::NUM_ROLES) { + p->role = static_cast<webkit_glue::WebAccessibility::Role>(role); + } else { + p->role = webkit_glue::WebAccessibility::ROLE_NONE; + } + int state = 0; + ret = ret && ReadParam(m, iter, &state); + p->state = static_cast<webkit_glue::WebAccessibility::State>(state); + ret = ret && ReadParam(m, iter, &p->location); + ret = ret && ReadParam(m, iter, &p->children); + return ret; + } + static void Log(const param_type& p, std::wstring* l) { + l->append(L"("); + LogParam(p.id, l); + l->append(L", "); + LogParam(p.name, l); + l->append(L", "); + LogParam(p.value, l); + l->append(L", "); + LogParam(p.action, l); + l->append(L", "); + LogParam(p.description, l); + l->append(L", "); + LogParam(p.help, l); + l->append(L", "); + LogParam(p.shortcut, l); + l->append(L", "); + LogParam(static_cast<int>(p.role), l); + l->append(L", "); + LogParam(static_cast<int>(p.state), l); + l->append(L", "); + LogParam(p.location, l); + l->append(L", "); + LogParam(p.children, l); + l->append(L")"); + } +}; +} // namespace IPC #define MESSAGES_INTERNAL_FILE "chrome/common/render_messages_internal.h" #include "ipc/ipc_message_macros.h" diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 763715a..076aab4 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -512,20 +512,6 @@ IPC_BEGIN_MESSAGES(View) // Used to instruct the RenderView to go into "view source" mode. IPC_MESSAGE_ROUTED0(ViewMsg_EnableViewSourceMode) - // Retreive information from the MSAA DOM subtree, for accessibility purposes. - IPC_SYNC_MESSAGE_ROUTED1_1(ViewMsg_GetAccessibilityInfo, - webkit_glue::WebAccessibility::InParams - /* input parameters */, - webkit_glue::WebAccessibility::OutParams - /* output parameters */) - - // Requests the renderer to clear cashed accessibility information. Takes an - // id to clear a specific hashmap entry, and a bool; true clears all, false - // does not. - IPC_MESSAGE_ROUTED2(ViewMsg_ClearAccessibilityInfo, - int /* accessibility object id */, - bool /* clear_all */) - // Get all savable resource links from current webpage, include main // frame and sub-frame. IPC_MESSAGE_ROUTED1(ViewMsg_GetAllSavableResourceLinksForCurrentPage, @@ -943,6 +929,9 @@ IPC_BEGIN_MESSAGES(View) // Notification that the list of extensions with web extents has been updated. IPC_MESSAGE_CONTROL1(ViewMsg_ExtensionExtentsUpdated, ViewMsg_ExtensionExtentsUpdated_Params) + + // Request a tree of Accessibility data from the render process. + IPC_MESSAGE_ROUTED0(ViewMsg_GetAccessibilityTree) IPC_END_MESSAGES(View) @@ -2344,4 +2333,9 @@ IPC_BEGIN_MESSAGES(ViewHost) int /* render_view_id */, int /* bridge_id */) + // 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) + IPC_END_MESSAGES(ViewHost) diff --git a/chrome/common/render_messages_unittest.cc b/chrome/common/render_messages_unittest.cc new file mode 100644 index 0000000..0dc3be8 --- /dev/null +++ b/chrome/common/render_messages_unittest.cc @@ -0,0 +1,96 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/scoped_ptr.h" +#include "base/string16.h" +#include "base/values.h" +#include "chrome/common/render_messages.h" +#include "testing/gtest/include/gtest/gtest.h" + +TEST(RenderMessagesUnittest, WebAccessibility) { + // Test a simple case. + webkit_glue::WebAccessibility input; + input.id = 123; + input.name = ASCIIToUTF16("name"); + input.value = ASCIIToUTF16("value"); + input.action = ASCIIToUTF16("action"); + input.description = ASCIIToUTF16("description"); + input.help = ASCIIToUTF16("help"); + input.shortcut = ASCIIToUTF16("shortcut"); + input.role = webkit_glue::WebAccessibility::ROLE_CHECKBUTTON; + input.state = + (1 << webkit_glue::WebAccessibility::STATE_CHECKED) | + (1 << webkit_glue::WebAccessibility::STATE_FOCUSED); + input.location = WebKit::WebRect(11, 22, 333, 444); + + IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL); + IPC::WriteParam(&msg, input); + + webkit_glue::WebAccessibility output; + void* iter = NULL; + EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output)); + EXPECT_EQ(input.id, output.id); + EXPECT_EQ(input.name, output.name); + EXPECT_EQ(input.value, output.value); + EXPECT_EQ(input.action, output.action); + EXPECT_EQ(input.description, output.description); + EXPECT_EQ(input.help, output.help); + EXPECT_EQ(input.shortcut, output.shortcut); + EXPECT_EQ(input.role, output.role); + EXPECT_EQ(input.state, output.state); + EXPECT_EQ(input.location, output.location); + EXPECT_EQ(input.children.size(), output.children.size()); + + // Test a corrupt case. + IPC::Message bad_msg(1, 2, IPC::Message::PRIORITY_NORMAL); + bad_msg.WriteInt(99); + iter = NULL; + EXPECT_FALSE(IPC::ReadParam(&bad_msg, &iter, &output)); + + // Test a recursive case. + webkit_glue::WebAccessibility outer; + outer.id = 1000; + outer.name = ASCIIToUTF16("outer_name"); + outer.role = webkit_glue::WebAccessibility::ROLE_GROUPING; + outer.state = 0; + outer.location = WebKit::WebRect(0, 0, 1000, 1000); + webkit_glue::WebAccessibility inner1; + inner1.id = 1001; + inner1.name = ASCIIToUTF16("inner1_name"); + inner1.role = webkit_glue::WebAccessibility::ROLE_RADIOBUTTON; + inner1.state = + (1 << webkit_glue::WebAccessibility::STATE_CHECKED) | + (1 << webkit_glue::WebAccessibility::STATE_FOCUSED); + inner1.location = WebKit::WebRect(10, 10, 900, 400); + outer.children.push_back(inner1); + webkit_glue::WebAccessibility inner2; + inner2.id = 1002; + inner2.name = ASCIIToUTF16("inner2_name"); + inner2.role = webkit_glue::WebAccessibility::ROLE_RADIOBUTTON; + inner2.state = (1 << webkit_glue::WebAccessibility::STATE_CHECKED); + inner2.location = WebKit::WebRect(10, 500, 900, 400); + outer.children.push_back(inner2); + + IPC::Message msg2(1, 2, IPC::Message::PRIORITY_NORMAL); + IPC::WriteParam(&msg2, outer); + + void* iter2 = NULL; + EXPECT_TRUE(IPC::ReadParam(&msg2, &iter2, &output)); + EXPECT_EQ(outer.id, output.id); + EXPECT_EQ(outer.name, output.name); + EXPECT_EQ(outer.role, output.role); + EXPECT_EQ(outer.state, output.state); + EXPECT_EQ(outer.location, output.location); + EXPECT_EQ(outer.children.size(), output.children.size()); + EXPECT_EQ(inner1.id, output.children[0].id); + EXPECT_EQ(inner1.name, output.children[0].name); + EXPECT_EQ(inner1.role, output.children[0].role); + EXPECT_EQ(inner1.state, output.children[0].state); + EXPECT_EQ(inner1.location, output.children[0].location); + EXPECT_EQ(inner2.id, output.children[1].id); + EXPECT_EQ(inner2.name, output.children[1].name); + EXPECT_EQ(inner2.role, output.children[1].role); + EXPECT_EQ(inner2.state, output.children[1].state); + EXPECT_EQ(inner2.location, output.children[1].location); +} |