Commit c409c0da authored by James Wallace-Lee's avatar James Wallace-Lee Committed by Commit Bot

chrome://accessibility: Don't refresh page on ToggleAccessibility

When the accessibility mode is toggled for individual pages, update the
single row by calling showTree rather than refreshing the whole page.

Bug: 877705
Change-Id: I5c7986fc970f9789bb421525ccea5f68f5fd57e9
Reviewed-on: https://chromium-review.googlesource.com/c/1269236
Commit-Queue: James Wallace-Lee <jamwalla@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601338}
parent ce1b5e78
......@@ -280,16 +280,20 @@ void AccessibilityUIMessageHandler::ToggleAccessibility(
const base::ListValue* args) {
std::string process_id_str;
std::string route_id_str;
std::string should_request_tree_str;
int process_id;
int route_id;
int mode;
CHECK_EQ(3U, args->GetSize());
bool should_request_tree;
CHECK_EQ(4U, args->GetSize());
CHECK(args->GetString(0, &process_id_str));
CHECK(args->GetString(1, &route_id_str));
// TODO(695247): We should pass each ax flag seperately
CHECK(args->GetInteger(2, &mode));
CHECK(args->GetString(3, &should_request_tree_str));
CHECK(base::StringToInt(process_id_str, &process_id));
CHECK(base::StringToInt(route_id_str, &route_id));
should_request_tree = (should_request_tree_str == "true");
AllowJavascript();
content::RenderViewHost* rvh =
......@@ -316,6 +320,19 @@ void AccessibilityUIMessageHandler::ToggleAccessibility(
current_mode.set_mode(ui::AXMode::kHTML, true);
web_contents->SetAccessibilityMode(current_mode);
if (should_request_tree) {
base::ListValue request_args;
request_args.Append(std::make_unique<base::Value>(process_id_str));
request_args.Append(std::make_unique<base::Value>(route_id_str));
RequestWebContentsTree(&request_args);
} else {
// Call accessibility.showTree without a 'tree' field so the row's
// accessibility mode buttons are updated.
AllowJavascript();
std::unique_ptr<base::DictionaryValue> new_mode(BuildTargetDescriptor(rvh));
CallJavascriptFunction("accessibility.showTree", *(new_mode.get()));
}
}
void AccessibilityUIMessageHandler::SetGlobalFlag(const base::ListValue* args) {
......
......@@ -48,10 +48,14 @@ cr.define('accessibility', function() {
}
function toggleAccessibility(data, element, mode) {
chrome.send(
'toggleAccessibility',
[String(data.processId), String(data.routeId), mode]);
document.location.reload();
let id = getIdFromData(data);
let tree = $(id + ':tree');
// If the tree is visible, request a new tree with the updated mode.
let shouldRequestTree = !!tree && tree.style.display != 'none';
chrome.send('toggleAccessibility', [
String(data.processId), String(data.routeId), mode,
String(shouldRequestTree)
]);
}
function requestTree(data, element) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment