Skip to content

Commit

Permalink
Convert ax_enums.idl to mojom.
Browse files Browse the repository at this point in the history
The accessibility enums were used in over 300 files and many
of those uses depended on details of the bindings generated
from the IDL file. To keep this as much of a pure refactoring
as possible, this change does the following:

* Implements Parse and ToString functions in ax_enum_util
  that match the behavior of the IDL bindings.
* Explicitly adds a kNone and kLast item to every enum, to
  support code that iterates over enums.

Bug: 650275
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:closure_compilation;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_vr;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I6610169991ea1209629dab9a8c4c2c1f03c4116f
Reviewed-on: https://chromium-review.googlesource.com/877417
Reviewed-by: Daniel Cheng <[email protected]>
Reviewed-by: Scott Violet <[email protected]>
Reviewed-by: David Tseng <[email protected]>
Reviewed-by: Aaron Leventhal <[email protected]>
Commit-Queue: Dominic Mazzoni <[email protected]>
Cr-Commit-Position: refs/heads/master@{#531997}
  • Loading branch information
minorninth authored and Commit Bot committed Jan 26, 2018
1 parent 38a9419 commit dcef1b7
Show file tree
Hide file tree
Showing 321 changed files with 9,167 additions and 5,484 deletions.
1 change: 0 additions & 1 deletion ash/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,6 @@ component("ash") {
"//third_party/qcms",
"//third_party/re2",
"//ui/accessibility",
"//ui/accessibility:ax_gen",
"//ui/app_list/presenter",
"//ui/base",
"//ui/base:ui_data_pack",
Expand Down
4 changes: 2 additions & 2 deletions ash/accelerators/exit_warning_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class ExitWarningWidgetDelegateView : public views::WidgetDelegateView {

void GetAccessibleNodeData(ui::AXNodeData* node_data) override {
node_data->SetName(accessible_name_);
node_data->role = ui::AX_ROLE_ALERT;
node_data->role = ax::mojom::Role::kAlert;
}

private:
Expand Down Expand Up @@ -158,7 +158,7 @@ void ExitWarningHandler::Show() {
widget_->Init(params);
widget_->Show();

delegate->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true);
delegate->NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true);
}

void ExitWarningHandler::Hide() {
Expand Down
7 changes: 4 additions & 3 deletions ash/accessibility/accessibility_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
#include "services/service_manager/public/cpp/connector.h"
#include "services/ui/public/interfaces/accessibility_manager.mojom.h"
#include "services/ui/public/interfaces/constants.mojom.h"
#include "ui/accessibility/ax_enums.h"
#include "ui/accessibility/ax_enum_util.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/base/cursor/cursor_type.h"

using session_manager::SessionState;
Expand Down Expand Up @@ -170,10 +171,10 @@ void AccessibilityController::PlayShutdownSound(
}

void AccessibilityController::HandleAccessibilityGesture(
ui::AXGesture gesture) {
ax::mojom::Gesture gesture) {
if (client_) {
const std::string gesture_str(ui::ToString(gesture));
DCHECK(!gesture_str.empty() || gesture == ui::AX_GESTURE_NONE);
DCHECK(!gesture_str.empty() || gesture == ax::mojom::Gesture::kNone);
client_->HandleAccessibilityGesture(gesture_str);
}
}
Expand Down
4 changes: 2 additions & 2 deletions ash/accessibility/accessibility_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "base/macros.h"
#include "base/time/time.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "ui/accessibility/ax_enums.h"
#include "ui/accessibility/ax_enums.mojom.h"

class PrefChangeRegistrar;
class PrefRegistrySimple;
Expand Down Expand Up @@ -77,7 +77,7 @@ class ASH_EXPORT AccessibilityController

// Forwards an accessibility gesture from the touch exploration controller to
// ChromeVox.
void HandleAccessibilityGesture(ui::AXGesture gesture);
void HandleAccessibilityGesture(ax::mojom::Gesture gesture);

// Toggle dictation.
void ToggleDictation();
Expand Down
2 changes: 1 addition & 1 deletion ash/accessibility/accessibility_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "ash/ash_export.h"
#include "ash/public/cpp/accessibility_types.h"
#include "base/time/time.h"
#include "ui/accessibility/ax_enums.h"
#include "ui/accessibility/ax_enums.mojom.h"

namespace ash {

Expand Down
2 changes: 1 addition & 1 deletion ash/ash_touch_exploration_manager_chromeos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void AshTouchExplorationManager::PlayEnterScreenEarcon() {
}

void AshTouchExplorationManager::HandleAccessibilityGesture(
ui::AXGesture gesture) {
ax::mojom::Gesture gesture) {
Shell::Get()->accessibility_controller()->HandleAccessibilityGesture(gesture);
}

Expand Down
2 changes: 1 addition & 1 deletion ash/ash_touch_exploration_manager_chromeos.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ASH_EXPORT AshTouchExplorationManager
void PlayPassthroughEarcon() override;
void PlayExitScreenEarcon() override;
void PlayEnterScreenEarcon() override;
void HandleAccessibilityGesture(ui::AXGesture gesture) override;
void HandleAccessibilityGesture(ax::mojom::Gesture gesture) override;

// display::DisplayObserver overrides:
void OnDisplayMetricsChanged(const display::Display& display,
Expand Down
5 changes: 3 additions & 2 deletions ash/ash_touch_exploration_manager_chromeos_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ TEST_F(AshTouchExplorationManagerTest, HandleAccessibilityGesture) {
TestAccessibilityControllerClient client;
a11y_controller->SetClient(client.CreateInterfacePtrAndBind());

touch_exploration_manager.HandleAccessibilityGesture(ui::AX_GESTURE_CLICK);
touch_exploration_manager.HandleAccessibilityGesture(
ax::mojom::Gesture::kClick);
a11y_controller->FlushMojoForTest();
EXPECT_EQ("click", client.last_a11y_gesture());

touch_exploration_manager.HandleAccessibilityGesture(
ui::AX_GESTURE_SWIPE_LEFT_1);
ax::mojom::Gesture::kSwipeLeft1);
a11y_controller->FlushMojoForTest();
EXPECT_EQ("swipeLeft1", client.last_a11y_gesture());
}
Expand Down
5 changes: 3 additions & 2 deletions ash/login/ui/lock_contents_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,12 @@ void LockContentsView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
Shelf* shelf = Shelf::ForWindow(GetWidget()->GetNativeWindow());
ShelfWidget* shelf_widget = shelf->shelf_widget();
int next_id = views::AXAuraObjCache::GetInstance()->GetID(shelf_widget);
node_data->AddIntAttribute(ui::AX_ATTR_NEXT_FOCUS_ID, next_id);
node_data->AddIntAttribute(ax::mojom::IntAttribute::kNextFocusId, next_id);

int previous_id =
views::AXAuraObjCache::GetInstance()->GetID(shelf->GetStatusAreaWidget());
node_data->AddIntAttribute(ui::AX_ATTR_PREVIOUS_FOCUS_ID, previous_id);
node_data->AddIntAttribute(ax::mojom::IntAttribute::kPreviousFocusId,
previous_id);
}

void LockContentsView::OnUsersChanged(
Expand Down
6 changes: 3 additions & 3 deletions ash/login/ui/login_bubble.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class LoginErrorBubbleView : public LoginBaseBubbleView {
// views::View:
const char* GetClassName() const override { return "LoginErrorBubbleView"; }
void GetAccessibleNodeData(ui::AXNodeData* node_data) override {
node_data->role = ui::AX_ROLE_TOOLTIP;
node_data->role = ax::mojom::Role::kTooltip;
}

private:
Expand Down Expand Up @@ -123,7 +123,7 @@ class LoginTooltipView : public LoginBaseBubbleView {

// LoginBaseBubbleView:
void GetAccessibleNodeData(ui::AXNodeData* node_data) override {
node_data->role = ui::AX_ROLE_TOOLTIP;
node_data->role = ax::mojom::Role::kTooltip;
}

private:
Expand Down Expand Up @@ -236,7 +236,7 @@ void LoginBubble::Show() {
ScheduleAnimation(true /*visible*/);

// Fire an alert so ChromeVox will read the contents of the bubble.
bubble_view_->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true);
bubble_view_->NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true);
}

void LoginBubble::CloseImmediately() {
Expand Down
2 changes: 1 addition & 1 deletion ash/login/ui/login_password_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class NonAccessibleSeparator : public views::Separator {
// views::Separator:
void GetAccessibleNodeData(ui::AXNodeData* node_data) override {
views::Separator::GetAccessibleNodeData(node_data);
node_data->AddState(ui::AX_STATE_INVISIBLE);
node_data->AddState(ax::mojom::State::kInvisible);
}

private:
Expand Down
2 changes: 1 addition & 1 deletion ash/login/ui/non_accessible_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const char* NonAccessibleView::GetClassName() const {
}

void NonAccessibleView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
node_data->AddState(ui::AX_STATE_INVISIBLE);
node_data->AddState(ax::mojom::State::kInvisible);
}

} // namespace ash
6 changes: 3 additions & 3 deletions ash/message_center/message_center_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class MessageCenterScrollView : public views::ScrollView {
private:
// views::View:
void GetAccessibleNodeData(ui::AXNodeData* node_data) override {
node_data->role = ui::AX_ROLE_DIALOG;
node_data->role = ax::mojom::Role::kDialog;
node_data->SetName(owner_->GetButtonBarTitle());
}

Expand Down Expand Up @@ -259,7 +259,7 @@ void MessageCenterView::OnLockStateChanged(bool locked) {
is_locked_ = locked;
Update(true /* animate */);
// Refresh a11y information, because accessible name of the view changes.
NotifyAccessibilityEvent(ui::AX_EVENT_ARIA_ATTRIBUTE_CHANGED, true);
NotifyAccessibilityEvent(ax::mojom::Event::kAriaAttributeChanged, true);
}

void MessageCenterView::OnAllNotificationsCleared() {
Expand Down Expand Up @@ -670,7 +670,7 @@ void MessageCenterView::UpdateNotification(const std::string& id) {
}

// Notify accessibility that the contents have changed.
view->NotifyAccessibilityEvent(ui::AX_EVENT_CHILDREN_CHANGED, false);
view->NotifyAccessibilityEvent(ax::mojom::Event::kChildrenChanged, false);
}

void MessageCenterView::NotifyAnimationState(bool animating) {
Expand Down
2 changes: 1 addition & 1 deletion ash/message_center/notifier_settings_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ void NotifierSettingsView::SetQuietModeState(bool is_quiet_mode) {
}

void NotifierSettingsView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
node_data->role = ui::AX_ROLE_LIST;
node_data->role = ax::mojom::Role::kList;
node_data->SetName(l10n_util::GetStringUTF16(
IDS_ASH_MESSAGE_CENTER_SETTINGS_DIALOG_DESCRIPTION));
}
Expand Down
2 changes: 1 addition & 1 deletion ash/shelf/app_list_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ bool AppListButton::OnMouseDragged(const ui::MouseEvent& event) {
}

void AppListButton::GetAccessibleNodeData(ui::AXNodeData* node_data) {
node_data->role = ui::AX_ROLE_BUTTON;
node_data->role = ax::mojom::Role::kButton;
node_data->SetName(shelf_view_->GetTitleForView(this));
}

Expand Down
5 changes: 3 additions & 2 deletions ash/shelf/login_shelf_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,14 @@ void LoginShelfView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
if (LockScreen::IsShown()) {
int previous_id = views::AXAuraObjCache::GetInstance()->GetID(
static_cast<views::Widget*>(LockScreen::Get()->window()));
node_data->AddIntAttribute(ui::AX_ATTR_PREVIOUS_FOCUS_ID, previous_id);
node_data->AddIntAttribute(ax::mojom::IntAttribute::kPreviousFocusId,
previous_id);
}

Shelf* shelf = Shelf::ForWindow(GetWidget()->GetNativeWindow());
int next_id =
views::AXAuraObjCache::GetInstance()->GetID(shelf->GetStatusAreaWidget());
node_data->AddIntAttribute(ui::AX_ATTR_NEXT_FOCUS_ID, next_id);
node_data->AddIntAttribute(ax::mojom::IntAttribute::kNextFocusId, next_id);
}

void LoginShelfView::ButtonPressed(views::Button* sender,
Expand Down
2 changes: 1 addition & 1 deletion ash/shelf/shelf_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ bool ShelfButton::OnMouseDragged(const ui::MouseEvent& event) {
}

void ShelfButton::GetAccessibleNodeData(ui::AXNodeData* node_data) {
node_data->role = ui::AX_ROLE_BUTTON;
node_data->role = ax::mojom::Role::kButton;
node_data->SetName(shelf_view_->GetTitleForView(this));
}

Expand Down
2 changes: 1 addition & 1 deletion ash/shelf/shelf_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1620,7 +1620,7 @@ views::FocusTraversable* ShelfView::GetPaneFocusTraversable() {
}

void ShelfView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
node_data->role = ui::AX_ROLE_TOOLBAR;
node_data->role = ax::mojom::Role::kToolbar;
node_data->SetName(l10n_util::GetStringUTF8(IDS_ASH_SHELF_ACCESSIBLE_NAME));
}

Expand Down
6 changes: 3 additions & 3 deletions ash/system/audio/volume_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ class VolumeButton : public ButtonListenerActionableView {
void GetAccessibleNodeData(ui::AXNodeData* node_data) override {
node_data->SetName(
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_VOLUME_MUTE));
node_data->role = ui::AX_ROLE_TOGGLE_BUTTON;
node_data->role = ax::mojom::Role::kToggleButton;
const bool is_pressed = CrasAudioHandler::Get()->IsOutputMuted();
node_data->SetCheckedState(is_pressed ? ui::AX_CHECKED_STATE_TRUE
: ui::AX_CHECKED_STATE_FALSE);
node_data->SetCheckedState(is_pressed ? ax::mojom::CheckedState::kTrue
: ax::mojom::CheckedState::kFalse);
}

views::ImageView* image_;
Expand Down
4 changes: 2 additions & 2 deletions ash/system/date/date_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void BaseDateTimeView::UpdateText() {

void BaseDateTimeView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
ActionableView::GetAccessibleNodeData(node_data);
node_data->role = ui::AX_ROLE_TIME;
node_data->role = ax::mojom::Role::kTime;
}

BaseDateTimeView::BaseDateTimeView(SystemTrayItem* owner)
Expand Down Expand Up @@ -116,7 +116,7 @@ void BaseDateTimeView::UpdateTextInternal(const base::Time& now) {
base::ASCIIToUTF16(", ") +
base::TimeFormatFriendlyDate(now));

NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_CHANGED, true);
NotifyAccessibilityEvent(ax::mojom::Event::kTextChanged, true);
}

void BaseDateTimeView::ChildPreferredSizeChanged(views::View* child) {
Expand Down
2 changes: 1 addition & 1 deletion ash/system/ime/tray_ime_chromeos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "base/logging.h"
#include "base/metrics/user_metrics.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/accessibility/ax_enums.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/font.h"
Expand Down
6 changes: 3 additions & 3 deletions ash/system/ime_menu/ime_list_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ class ImeListItemView : public ActionableView {

void GetAccessibleNodeData(ui::AXNodeData* node_data) override {
ActionableView::GetAccessibleNodeData(node_data);
node_data->role = ui::AX_ROLE_CHECK_BOX;
node_data->SetCheckedState(selected_ ? ui::AX_CHECKED_STATE_TRUE
: ui::AX_CHECKED_STATE_FALSE);
node_data->role = ax::mojom::Role::kCheckBox;
node_data->SetCheckedState(selected_ ? ax::mojom::CheckedState::kTrue
: ax::mojom::CheckedState::kFalse);
}

private:
Expand Down
6 changes: 3 additions & 3 deletions ash/system/ime_menu/ime_menu_tray_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ class ImeMenuTrayTest : public AshTestBase {
// Tests that the checked IME is the current IME.
ui::AXNodeData node_data;
ime.first->GetAccessibleNodeData(&node_data);
const auto checked_state = static_cast<ui::AXCheckedState>(
node_data.GetIntAttribute(ui::AX_ATTR_CHECKED_STATE));
if (checked_state == ui::AX_CHECKED_STATE_TRUE)
const auto checked_state = static_cast<ax::mojom::CheckedState>(
node_data.GetIntAttribute(ax::mojom::IntAttribute::kCheckedState));
if (checked_state == ax::mojom::CheckedState::kTrue)
EXPECT_EQ(expected_current_ime.id, ime.second);
}
}
Expand Down
2 changes: 1 addition & 1 deletion ash/system/network/network_state_list_detailed_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ void NetworkStateListDetailedView::ToggleInfoBubble() {

info_bubble_ = new InfoBubble(tri_view(), CreateNetworkInfoView(), this);
views::BubbleDialogDelegateView::CreateBubble(info_bubble_)->Show();
info_bubble_->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, false);
info_bubble_->NotifyAccessibilityEvent(ax::mojom::Event::kAlert, false);
}

bool NetworkStateListDetailedView::ResetInfoBubble() {
Expand Down
4 changes: 2 additions & 2 deletions ash/system/network/tray_network.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class NetworkTrayView : public TrayItemView,
// views::View:
void GetAccessibleNodeData(ui::AXNodeData* node_data) override {
node_data->SetName(connection_status_string_);
node_data->role = ui::AX_ROLE_BUTTON;
node_data->role = ax::mojom::Role::kButton;
}

// network_icon::AnimationObserver:
Expand Down Expand Up @@ -155,7 +155,7 @@ class NetworkTrayView : public TrayItemView,
if (new_connection_status_string != connection_status_string_) {
connection_status_string_ = new_connection_status_string;
if (notify_a11y && !connection_status_string_.empty())
NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true);
NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true);
}
}

Expand Down
10 changes: 5 additions & 5 deletions ash/system/night_light/night_light_toggle_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "ash/system/night_light/night_light_controller.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/tray_popup_item_style.h"
#include "ui/accessibility/ax_enums.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/paint_vector_icon.h"
Expand Down Expand Up @@ -60,7 +60,7 @@ void NightLightToggleButton::Toggle() {
DCHECK(switches::IsNightLightEnabled());
Shell::Get()->night_light_controller()->Toggle();
Update();
NotifyAccessibilityEvent(ui::AX_EVENT_ARIA_ATTRIBUTE_CHANGED, true);
NotifyAccessibilityEvent(ax::mojom::Event::kAriaAttributeChanged, true);
}

void NightLightToggleButton::Update() {
Expand All @@ -77,9 +77,9 @@ void NightLightToggleButton::Update() {
void NightLightToggleButton::GetAccessibleNodeData(ui::AXNodeData* node_data) {
const bool is_enabled = Shell::Get()->night_light_controller()->GetEnabled();
node_data->SetName(GetNightLightTooltipText(is_enabled));
node_data->role = ui::AX_ROLE_TOGGLE_BUTTON;
node_data->SetCheckedState(is_enabled ? ui::AX_CHECKED_STATE_TRUE
: ui::AX_CHECKED_STATE_FALSE);
node_data->role = ax::mojom::Role::kToggleButton;
node_data->SetCheckedState(is_enabled ? ax::mojom::CheckedState::kTrue
: ax::mojom::CheckedState::kFalse);
}

} // namespace ash
2 changes: 1 addition & 1 deletion ash/system/power/power_status_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void PowerStatusView::Layout() {
}

void PowerStatusView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
node_data->role = ui::AX_ROLE_LABEL_TEXT;
node_data->role = ax::mojom::Role::kLabelText;
node_data->SetName(accessible_name_);
}

Expand Down
Loading

0 comments on commit dcef1b7

Please sign in to comment.