Commit 7711020d authored by Akihiro Ota's avatar Akihiro Ota Committed by Commit Bot

Implement basic accessibility for IME candidate window.

Before this fix, assistive technologies (I tested with ChromeVox) were
unable to navigate into the IME candidates. For ChromeVox in particular,
using the arrow keys to navigate the candidates produced no speech
output.

With this fix, ChromeVox can navigate into the IME candidates and
speaks each candidate to the user.

Bug: 1034146
Change-Id: I77b584fc2a2648bc5f9fca479b2363d476628ac4
Relnotes: Make Chrome IME accessible to assistive technology.
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2151672Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarYuichiro Hanada <yhanada@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: Akihiro Ota <akihiroota@chromium.org>
Cr-Commit-Position: refs/heads/master@{#760099}
parent 7ba47ad1
...@@ -42,6 +42,7 @@ component("chromeos") { ...@@ -42,6 +42,7 @@ component("chromeos") {
"//services/device/public/mojom", "//services/device/public/mojom",
"//services/service_manager/public/cpp", "//services/service_manager/public/cpp",
"//skia", "//skia",
"//ui/accessibility:ax_base",
"//ui/aura", "//ui/aura",
"//ui/base", "//ui/base",
"//ui/base/ime", "//ui/base/ime",
......
...@@ -2,10 +2,13 @@ ...@@ -2,10 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ui/chromeos/ime/candidate_view.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/ime/candidate_window.h" #include "ui/base/ime/candidate_window.h"
#include "ui/chromeos/ime/candidate_view.h"
#include "ui/chromeos/ime/candidate_window_constants.h" #include "ui/chromeos/ime/candidate_window_constants.h"
#include "ui/gfx/color_utils.h" #include "ui/gfx/color_utils.h"
#include "ui/native_theme/native_theme.h" #include "ui/native_theme/native_theme.h"
...@@ -177,6 +180,7 @@ void CandidateView::SetHighlighted(bool highlighted) { ...@@ -177,6 +180,7 @@ void CandidateView::SetHighlighted(bool highlighted) {
highlighted_ = highlighted; highlighted_ = highlighted;
if (highlighted) { if (highlighted) {
NotifyAccessibilityEvent(ax::mojom::Event::kSelection, false);
ui::NativeTheme* theme = GetNativeTheme(); ui::NativeTheme* theme = GetNativeTheme();
SetBackground(views::CreateSolidBackground(theme->GetSystemColor( SetBackground(views::CreateSolidBackground(theme->GetSystemColor(
ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused))); ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused)));
...@@ -280,5 +284,10 @@ gfx::Size CandidateView::CalculatePreferredSize() const { ...@@ -280,5 +284,10 @@ gfx::Size CandidateView::CalculatePreferredSize() const {
return size; return size;
} }
void CandidateView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
node_data->SetName(candidate_label_->GetText());
node_data->role = ax::mojom::Role::kMenuItem;
}
} // namespace ime } // namespace ime
} // namespace ui } // namespace ui
...@@ -48,6 +48,7 @@ class UI_CHROMEOS_EXPORT CandidateView : public views::Button { ...@@ -48,6 +48,7 @@ class UI_CHROMEOS_EXPORT CandidateView : public views::Button {
bool OnMouseDragged(const ui::MouseEvent& event) override; bool OnMouseDragged(const ui::MouseEvent& event) override;
void Layout() override; void Layout() override;
gfx::Size CalculatePreferredSize() const override; gfx::Size CalculatePreferredSize() const override;
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
// The orientation of the candidate view. // The orientation of the candidate view.
ui::CandidateWindow::Orientation orientation_; ui::CandidateWindow::Orientation orientation_;
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/chromeos/ime/candidate_view.h" #include "ui/chromeos/ime/candidate_view.h"
#include "ui/chromeos/ime/candidate_window_constants.h" #include "ui/chromeos/ime/candidate_window_constants.h"
#include "ui/display/display.h" #include "ui/display/display.h"
...@@ -411,5 +413,9 @@ void CandidateWindowView::ButtonPressed(views::Button* sender, ...@@ -411,5 +413,9 @@ void CandidateWindowView::ButtonPressed(views::Button* sender,
} }
} }
void CandidateWindowView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
node_data->role = ax::mojom::Role::kMenu;
}
} // namespace ime } // namespace ime
} // namespace ui } // namespace ui
...@@ -83,6 +83,9 @@ class UI_CHROMEOS_EXPORT CandidateWindowView ...@@ -83,6 +83,9 @@ class UI_CHROMEOS_EXPORT CandidateWindowView
// Overridden from views::ButtonListener: // Overridden from views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override; void ButtonPressed(views::Button* sender, const ui::Event& event) override;
// Overridden from View:
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
void SelectCandidateAt(int index_in_page); void SelectCandidateAt(int index_in_page);
void UpdateVisibility(); void UpdateVisibility();
......
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