diff --git a/ash/BUILD.gn b/ash/BUILD.gn index e07f65bb86507b..cdd047255d2505 100644 --- a/ash/BUILD.gn +++ b/ash/BUILD.gn @@ -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", diff --git a/ash/accelerators/exit_warning_handler.cc b/ash/accelerators/exit_warning_handler.cc index f68006b6876d87..a96f141dea41a3 100644 --- a/ash/accelerators/exit_warning_handler.cc +++ b/ash/accelerators/exit_warning_handler.cc @@ -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: @@ -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() { diff --git a/ash/accessibility/accessibility_controller.cc b/ash/accessibility/accessibility_controller.cc index 90164b73dd6df7..8f5697c847bbd0 100644 --- a/ash/accessibility/accessibility_controller.cc +++ b/ash/accessibility/accessibility_controller.cc @@ -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; @@ -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); } } diff --git a/ash/accessibility/accessibility_controller.h b/ash/accessibility/accessibility_controller.h index 26e7a49b7b7bb0..68d4a6fb9fee10 100644 --- a/ash/accessibility/accessibility_controller.h +++ b/ash/accessibility/accessibility_controller.h @@ -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; @@ -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(); diff --git a/ash/accessibility/accessibility_delegate.h b/ash/accessibility/accessibility_delegate.h index 098a66d4598663..955e49b60ca6f8 100644 --- a/ash/accessibility/accessibility_delegate.h +++ b/ash/accessibility/accessibility_delegate.h @@ -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 { diff --git a/ash/ash_touch_exploration_manager_chromeos.cc b/ash/ash_touch_exploration_manager_chromeos.cc index 59027d08f30c3b..de6c83109b4c31 100644 --- a/ash/ash_touch_exploration_manager_chromeos.cc +++ b/ash/ash_touch_exploration_manager_chromeos.cc @@ -98,7 +98,7 @@ void AshTouchExplorationManager::PlayEnterScreenEarcon() { } void AshTouchExplorationManager::HandleAccessibilityGesture( - ui::AXGesture gesture) { + ax::mojom::Gesture gesture) { Shell::Get()->accessibility_controller()->HandleAccessibilityGesture(gesture); } diff --git a/ash/ash_touch_exploration_manager_chromeos.h b/ash/ash_touch_exploration_manager_chromeos.h index d7d403cbf8b800..3c8a0ab4a61b78 100644 --- a/ash/ash_touch_exploration_manager_chromeos.h +++ b/ash/ash_touch_exploration_manager_chromeos.h @@ -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, diff --git a/ash/ash_touch_exploration_manager_chromeos_unittest.cc b/ash/ash_touch_exploration_manager_chromeos_unittest.cc index a09881fedccb62..47859d9ac4f500 100644 --- a/ash/ash_touch_exploration_manager_chromeos_unittest.cc +++ b/ash/ash_touch_exploration_manager_chromeos_unittest.cc @@ -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()); } diff --git a/ash/login/ui/lock_contents_view.cc b/ash/login/ui/lock_contents_view.cc index 42a7ad1c0455ef..f0953b1ef41ff1 100644 --- a/ash/login/ui/lock_contents_view.cc +++ b/ash/login/ui/lock_contents_view.cc @@ -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( diff --git a/ash/login/ui/login_bubble.cc b/ash/login/ui/login_bubble.cc index aa3fb6a9efbb7d..d93363443d376e 100644 --- a/ash/login/ui/login_bubble.cc +++ b/ash/login/ui/login_bubble.cc @@ -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: @@ -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: @@ -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() { diff --git a/ash/login/ui/login_password_view.cc b/ash/login/ui/login_password_view.cc index f66fb48bab236b..8bb587870d605a 100644 --- a/ash/login/ui/login_password_view.cc +++ b/ash/login/ui/login_password_view.cc @@ -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: diff --git a/ash/login/ui/non_accessible_view.cc b/ash/login/ui/non_accessible_view.cc index 8712655cbbe8aa..2b09c7d4259682 100644 --- a/ash/login/ui/non_accessible_view.cc +++ b/ash/login/ui/non_accessible_view.cc @@ -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 \ No newline at end of file diff --git a/ash/message_center/message_center_view.cc b/ash/message_center/message_center_view.cc index 1ae0f54f3f3e04..87df321b13d6f7 100644 --- a/ash/message_center/message_center_view.cc +++ b/ash/message_center/message_center_view.cc @@ -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()); } @@ -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() { @@ -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) { diff --git a/ash/message_center/notifier_settings_view.cc b/ash/message_center/notifier_settings_view.cc index e01c856a6c788b..3ca13ebb7608d3 100644 --- a/ash/message_center/notifier_settings_view.cc +++ b/ash/message_center/notifier_settings_view.cc @@ -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)); } diff --git a/ash/shelf/app_list_button.cc b/ash/shelf/app_list_button.cc index aac0bfc96d38a0..309d0d53a6fd96 100644 --- a/ash/shelf/app_list_button.cc +++ b/ash/shelf/app_list_button.cc @@ -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)); } diff --git a/ash/shelf/login_shelf_view.cc b/ash/shelf/login_shelf_view.cc index 9f416d208abd94..3b2f7b5b677b56 100644 --- a/ash/shelf/login_shelf_view.cc +++ b/ash/shelf/login_shelf_view.cc @@ -193,13 +193,14 @@ void LoginShelfView::GetAccessibleNodeData(ui::AXNodeData* node_data) { if (LockScreen::IsShown()) { int previous_id = views::AXAuraObjCache::GetInstance()->GetID( static_cast(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, diff --git a/ash/shelf/shelf_button.cc b/ash/shelf/shelf_button.cc index 38b14e5087adcd..eba6f57b8268fd 100644 --- a/ash/shelf/shelf_button.cc +++ b/ash/shelf/shelf_button.cc @@ -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)); } diff --git a/ash/shelf/shelf_view.cc b/ash/shelf/shelf_view.cc index 3e4181b7d26d62..329c46efc3e45f 100644 --- a/ash/shelf/shelf_view.cc +++ b/ash/shelf/shelf_view.cc @@ -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)); } diff --git a/ash/system/audio/volume_view.cc b/ash/system/audio/volume_view.cc index 476679ccddcc43..30fa1dd79dbbaa 100644 --- a/ash/system/audio/volume_view.cc +++ b/ash/system/audio/volume_view.cc @@ -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_; diff --git a/ash/system/date/date_view.cc b/ash/system/date/date_view.cc index 4da303478d155b..b176927b2d16c2 100644 --- a/ash/system/date/date_view.cc +++ b/ash/system/date/date_view.cc @@ -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) @@ -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) { diff --git a/ash/system/ime/tray_ime_chromeos.cc b/ash/system/ime/tray_ime_chromeos.cc index da215972de792f..a8cd119b49a70e 100644 --- a/ash/system/ime/tray_ime_chromeos.cc +++ b/ash/system/ime/tray_ime_chromeos.cc @@ -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" diff --git a/ash/system/ime_menu/ime_list_view.cc b/ash/system/ime_menu/ime_list_view.cc index 9f7dda96ce8fe0..5eb49ca78746d1 100644 --- a/ash/system/ime_menu/ime_list_view.cc +++ b/ash/system/ime_menu/ime_list_view.cc @@ -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: diff --git a/ash/system/ime_menu/ime_menu_tray_unittest.cc b/ash/system/ime_menu/ime_menu_tray_unittest.cc index 1cca035dd138cb..28f51f242e10c2 100644 --- a/ash/system/ime_menu/ime_menu_tray_unittest.cc +++ b/ash/system/ime_menu/ime_menu_tray_unittest.cc @@ -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( - node_data.GetIntAttribute(ui::AX_ATTR_CHECKED_STATE)); - if (checked_state == ui::AX_CHECKED_STATE_TRUE) + const auto checked_state = static_cast( + node_data.GetIntAttribute(ax::mojom::IntAttribute::kCheckedState)); + if (checked_state == ax::mojom::CheckedState::kTrue) EXPECT_EQ(expected_current_ime.id, ime.second); } } diff --git a/ash/system/network/network_state_list_detailed_view.cc b/ash/system/network/network_state_list_detailed_view.cc index 4cf2048c0066f2..afbff86d3655ce 100644 --- a/ash/system/network/network_state_list_detailed_view.cc +++ b/ash/system/network/network_state_list_detailed_view.cc @@ -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() { diff --git a/ash/system/network/tray_network.cc b/ash/system/network/tray_network.cc index 173e4d6a7886a6..25d39b40bab749 100644 --- a/ash/system/network/tray_network.cc +++ b/ash/system/network/tray_network.cc @@ -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: @@ -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); } } diff --git a/ash/system/night_light/night_light_toggle_button.cc b/ash/system/night_light/night_light_toggle_button.cc index 1cd62a74c231d1..905279dff00ae0 100644 --- a/ash/system/night_light/night_light_toggle_button.cc +++ b/ash/system/night_light/night_light_toggle_button.cc @@ -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" @@ -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() { @@ -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 diff --git a/ash/system/power/power_status_view.cc b/ash/system/power/power_status_view.cc index 5d7ddf7b18b460..82dd14772b4001 100644 --- a/ash/system/power/power_status_view.cc +++ b/ash/system/power/power_status_view.cc @@ -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_); } diff --git a/ash/system/power/tray_power.cc b/ash/system/power/tray_power.cc index 802ce393fb56fb..d7455e735db802 100644 --- a/ash/system/power/tray_power.cc +++ b/ash/system/power/tray_power.cc @@ -106,7 +106,7 @@ class PowerTrayView : public TrayItemView { // Overridden from views::View. void GetAccessibleNodeData(ui::AXNodeData* node_data) override { node_data->SetName(accessible_name_); - node_data->role = ui::AX_ROLE_BUTTON; + node_data->role = ax::mojom::Role::kButton; } void UpdateStatus(bool battery_alert) { @@ -115,7 +115,7 @@ class PowerTrayView : public TrayItemView { if (battery_alert) { accessible_name_ = PowerStatus::Get()->GetAccessibleNameString(true); - NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); + NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true); } } diff --git a/ash/system/toast/toast_overlay.cc b/ash/system/toast/toast_overlay.cc index e6f8d3c55fed3a..742f952a94f431 100644 --- a/ash/system/toast/toast_overlay.cc +++ b/ash/system/toast/toast_overlay.cc @@ -254,7 +254,7 @@ void ToastOverlay::Show(bool visible) { overlay_widget_->Show(); // Notify accessibility about the overlay. - overlay_view_->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, false); + overlay_view_->NotifyAccessibilityEvent(ax::mojom::Event::kAlert, false); } else { overlay_widget_->Hide(); } diff --git a/ash/system/tray/actionable_view.cc b/ash/system/tray/actionable_view.cc index bd643a9f747a88..7804450fc0c08c 100644 --- a/ash/system/tray/actionable_view.cc +++ b/ash/system/tray/actionable_view.cc @@ -63,7 +63,7 @@ bool ActionableView::OnKeyPressed(const ui::KeyEvent& event) { } void ActionableView::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_BUTTON; + node_data->role = ax::mojom::Role::kButton; node_data->SetName(accessible_name()); } diff --git a/ash/system/tray/hover_highlight_view.cc b/ash/system/tray/hover_highlight_view.cc index 8a5c88574a1301..bb84df7a631bbc 100644 --- a/ash/system/tray/hover_highlight_view.cc +++ b/ash/system/tray/hover_highlight_view.cc @@ -176,7 +176,7 @@ void HoverHighlightView::SetAccessiblityState( AccessibilityState accessibility_state) { accessibility_state_ = accessibility_state; if (accessibility_state_ != AccessibilityState::DEFAULT) - NotifyAccessibilityEvent(ui::AX_EVENT_CHECKED_STATE_CHANGED, true); + NotifyAccessibilityEvent(ax::mojom::Event::kCheckedStateChanged, true); } void HoverHighlightView::Reset() { @@ -199,17 +199,17 @@ bool HoverHighlightView::PerformAction(const ui::Event& event) { void HoverHighlightView::GetAccessibleNodeData(ui::AXNodeData* node_data) { ActionableView::GetAccessibleNodeData(node_data); - ui::AXCheckedState checked_state; + ax::mojom::CheckedState checked_state; if (accessibility_state_ == AccessibilityState::CHECKED_CHECKBOX) - checked_state = ui::AX_CHECKED_STATE_TRUE; + checked_state = ax::mojom::CheckedState::kTrue; else if (accessibility_state_ == AccessibilityState::UNCHECKED_CHECKBOX) - checked_state = ui::AX_CHECKED_STATE_FALSE; + checked_state = ax::mojom::CheckedState::kFalse; else return; // Not a checkbox // Checkbox - node_data->role = ui::AX_ROLE_CHECK_BOX; + node_data->role = ax::mojom::Role::kCheckBox; node_data->SetCheckedState(checked_state); } diff --git a/ash/system/tray/system_tray_bubble.cc b/ash/system/tray/system_tray_bubble.cc index a5b796bfe68656..b6b6fcc875cceb 100644 --- a/ash/system/tray/system_tray_bubble.cc +++ b/ash/system/tray/system_tray_bubble.cc @@ -204,7 +204,7 @@ void SystemTrayBubble::InitView(views::View* anchor, CreateItemViews(login_status); if (bubble_view_->CanActivate()) { - bubble_view_->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); + bubble_view_->NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true); } } diff --git a/ash/system/tray/tray_background_view.cc b/ash/system/tray/tray_background_view.cc index c3f7110a0ded29..e669c0a3a5f1ca 100644 --- a/ash/system/tray/tray_background_view.cc +++ b/ash/system/tray/tray_background_view.cc @@ -311,13 +311,14 @@ void TrayBackgroundView::GetAccessibleNodeData(ui::AXNodeData* node_data) { if (LockScreen::IsShown()) { int next_id = views::AXAuraObjCache::GetInstance()->GetID( static_cast(LockScreen::Get()->window())); - node_data->AddIntAttribute(ui::AX_ATTR_NEXT_FOCUS_ID, next_id); + node_data->AddIntAttribute(ax::mojom::IntAttribute::kNextFocusId, next_id); } Shelf* shelf = Shelf::ForWindow(GetWidget()->GetNativeWindow()); ShelfWidget* shelf_widget = shelf->shelf_widget(); int previous_id = views::AXAuraObjCache::GetInstance()->GetID(shelf_widget); - node_data->AddIntAttribute(ui::AX_ATTR_PREVIOUS_FOCUS_ID, previous_id); + node_data->AddIntAttribute(ax::mojom::IntAttribute::kPreviousFocusId, + previous_id); } void TrayBackgroundView::ChildPreferredSizeChanged(views::View* child) { diff --git a/ash/system/tray/tray_info_label.cc b/ash/system/tray/tray_info_label.cc index 2cbfc50dddca10..3af08f37de4b1d 100644 --- a/ash/system/tray/tray_info_label.cc +++ b/ash/system/tray/tray_info_label.cc @@ -69,7 +69,7 @@ void TrayInfoLabel::GetAccessibleNodeData(ui::AXNodeData* node_data) { ActionableView::GetAccessibleNodeData(node_data); if (!IsClickable()) - node_data->role = ui::AX_ROLE_LABEL_TEXT; + node_data->role = ax::mojom::Role::kLabelText; } bool TrayInfoLabel::IsClickable() { diff --git a/ash/system/tray/tray_info_label_unittest.cc b/ash/system/tray/tray_info_label_unittest.cc index 8c21d58a6fa157..ef259811fd1836 100644 --- a/ash/system/tray/tray_info_label_unittest.cc +++ b/ash/system/tray/tray_info_label_unittest.cc @@ -75,9 +75,9 @@ class TrayInfoLabelTest : public AshTestBase { label_->GetAccessibleNodeData(&node_data); if (expected_clickable) - EXPECT_EQ(ui::AX_ROLE_BUTTON, node_data.role); + EXPECT_EQ(ax::mojom::Role::kButton, node_data.role); else - EXPECT_EQ(ui::AX_ROLE_LABEL_TEXT, node_data.role); + EXPECT_EQ(ax::mojom::Role::kLabelText, node_data.role); } void VerifyClicks(const std::vector& expected_clicked_message_ids) { diff --git a/ash/system/tray_caps_lock.cc b/ash/system/tray_caps_lock.cc index 3a3c6a24979a03..9edf4699108fc5 100644 --- a/ash/system/tray_caps_lock.cc +++ b/ash/system/tray_caps_lock.cc @@ -152,7 +152,7 @@ class CapsLockDefaultView : public ActionableView { private: void GetAccessibleNodeData(ui::AXNodeData* node_data) override { - node_data->role = ui::AX_ROLE_BUTTON; + node_data->role = ax::mojom::Role::kButton; node_data->SetName(text_label_->text()); } diff --git a/ash/system/user/button_from_view.cc b/ash/system/user/button_from_view.cc index fc05ffb349cc91..560f676d08427b 100644 --- a/ash/system/user/button_from_view.cc +++ b/ash/system/user/button_from_view.cc @@ -63,10 +63,12 @@ void ButtonFromView::GetAccessibleNodeData(ui::AXNodeData* node_data) { views::Button::GetAccessibleNodeData(node_data); // If no label has been explicitly set via Button::SetAccessibleName(), // use the content's label. - if (node_data->GetStringAttribute(ui::AX_ATTR_NAME).empty()) { + if (node_data->GetStringAttribute(ax::mojom::StringAttribute::kName) + .empty()) { ui::AXNodeData content_data; content_->GetAccessibleNodeData(&content_data); - node_data->SetName(content_data.GetStringAttribute(ui::AX_ATTR_NAME)); + node_data->SetName( + content_data.GetStringAttribute(ax::mojom::StringAttribute::kName)); } } diff --git a/ash/system/user/tray_user_unittest.cc b/ash/system/user/tray_user_unittest.cc index 905f8d40f0d7cd..4cd418291284c2 100644 --- a/ash/system/user/tray_user_unittest.cc +++ b/ash/system/user/tray_user_unittest.cc @@ -170,8 +170,8 @@ TEST_F(TrayUserTest, AccessibleLabelContainsSingleUserInfo) { view->GetAccessibleNodeData(&node_data); EXPECT_EQ( base::UTF8ToUTF16("Über tray Über tray Über tray Über tray First@tray"), - node_data.GetString16Attribute(ui::AX_ATTR_NAME)); - EXPECT_EQ(ui::AX_ROLE_STATIC_TEXT, node_data.role); + node_data.GetString16Attribute(ax::mojom::StringAttribute::kName)); + EXPECT_EQ(ax::mojom::Role::kStaticText, node_data.role); } TEST_F(TrayUserTest, AccessibleLabelContainsMultiUserInfo) { @@ -185,8 +185,8 @@ TEST_F(TrayUserTest, AccessibleLabelContainsMultiUserInfo) { view->GetAccessibleNodeData(&node_data); EXPECT_EQ( base::UTF8ToUTF16("Über tray Über tray Über tray Über tray First@tray"), - node_data.GetString16Attribute(ui::AX_ATTR_NAME)); - EXPECT_EQ(ui::AX_ROLE_BUTTON, node_data.role); + node_data.GetString16Attribute(ax::mojom::StringAttribute::kName)); + EXPECT_EQ(ax::mojom::Role::kButton, node_data.role); } // Make sure that in multi user mode the user panel can be activated and there diff --git a/ash/system/user/user_card_view.cc b/ash/system/user/user_card_view.cc index 650531cbd1510f..2cd529df40e368 100644 --- a/ash/system/user/user_card_view.cc +++ b/ash/system/user/user_card_view.cc @@ -219,7 +219,7 @@ void PublicAccountUserDetails::OnPaint(gfx::Canvas* canvas) { void PublicAccountUserDetails::GetAccessibleNodeData( ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_STATIC_TEXT; + node_data->role = ax::mojom::Role::kStaticText; node_data->SetName(text_); } @@ -309,7 +309,7 @@ void UserCardView::SetSuppressCaptureIcon(bool suppressed) { } void UserCardView::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_STATIC_TEXT; + node_data->role = ax::mojom::Role::kStaticText; std::vector labels; // Construct the name by concatenating descendants' names. @@ -321,8 +321,8 @@ void UserCardView::GetAccessibleNodeData(ui::AXNodeData* node_data) { if (view != this) { ui::AXNodeData descendant_data; view->GetAccessibleNodeData(&descendant_data); - base::string16 label = - descendant_data.GetString16Attribute(ui::AX_ATTR_NAME); + base::string16 label = descendant_data.GetString16Attribute( + ax::mojom::StringAttribute::kName); // If we find a non-empty name, use that and don't descend further into // the tree. if (!label.empty()) { diff --git a/ash/test/ash_test_views_delegate.cc b/ash/test/ash_test_views_delegate.cc index e010f1915db871..f17edbe052b3e1 100644 --- a/ash/test/ash_test_views_delegate.cc +++ b/ash/test/ash_test_views_delegate.cc @@ -24,8 +24,9 @@ void AshTestViewsDelegate::OnBeforeWidgetInit( } } -void AshTestViewsDelegate::NotifyAccessibilityEvent(views::View* view, - ui::AXEvent event_type) { +void AshTestViewsDelegate::NotifyAccessibilityEvent( + views::View* view, + ax::mojom::Event event_type) { TestViewsDelegate::NotifyAccessibilityEvent(view, event_type); if (test_accessibility_event_delegate_) { diff --git a/ash/test/ash_test_views_delegate.h b/ash/test/ash_test_views_delegate.h index 1883e689e7d633..33a65bd603b9ed 100644 --- a/ash/test/ash_test_views_delegate.h +++ b/ash/test/ash_test_views_delegate.h @@ -15,7 +15,7 @@ class TestAccessibilityEventDelegate { TestAccessibilityEventDelegate() {} virtual ~TestAccessibilityEventDelegate() {} virtual void NotifyAccessibilityEvent(views::View* view, - ui::AXEvent event_type) = 0; + ax::mojom::Event event_type) = 0; }; // Ash specific ViewsDelegate. In addition to creating a TestWebContents this @@ -37,7 +37,7 @@ class AshTestViewsDelegate : public views::TestViewsDelegate { views::Widget::InitParams* params, views::internal::NativeWidgetDelegate* delegate) override; void NotifyAccessibilityEvent(views::View* view, - ui::AXEvent event_type) override; + ax::mojom::Event event_type) override; views::TestViewsDelegate::ProcessMenuAcceleratorResult ProcessAcceleratorWhileMenuShowing( const ui::Accelerator& accelerator) override; diff --git a/ash/wm/overview/window_selector_item.cc b/ash/wm/overview/window_selector_item.cc index 1e7c6199c1ace9..e9edc1fd671a34 100644 --- a/ash/wm/overview/window_selector_item.cc +++ b/ash/wm/overview/window_selector_item.cc @@ -672,7 +672,7 @@ void WindowSelectorItem::SetSelected(bool selected) { void WindowSelectorItem::SendAccessibleSelectionEvent() { caption_container_view_->listener_button()->NotifyAccessibilityEvent( - ui::AX_EVENT_SELECTION, true); + ax::mojom::Event::kSelection, true); } void WindowSelectorItem::CloseWindow() { diff --git a/ash/wm/window_cycle_list.cc b/ash/wm/window_cycle_list.cc index 9bf31611fd088c..47478a1ce5eb60 100644 --- a/ash/wm/window_cycle_list.cc +++ b/ash/wm/window_cycle_list.cc @@ -135,7 +135,7 @@ class WindowPreviewView : public views::View, public aura::WindowObserver { } void GetAccessibleNodeData(ui::AXNodeData* node_data) override { - node_data->role = ui::AX_ROLE_WINDOW; + node_data->role = ax::mojom::Role::kWindow; node_data->SetName(window_title_->text()); } diff --git a/chrome/browser/accessibility/accessibility_extension_api.h b/chrome/browser/accessibility/accessibility_extension_api.h index 0e81cbd0f20bc3..5e6b70c878ecbc 100644 --- a/chrome/browser/accessibility/accessibility_extension_api.h +++ b/chrome/browser/accessibility/accessibility_extension_api.h @@ -11,7 +11,7 @@ #include "base/memory/singleton.h" #include "base/values.h" #include "extensions/browser/extension_function.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" // API function that enables or disables web content accessibility support. class AccessibilityPrivateSetNativeAccessibilityEnabledFunction diff --git a/chrome/browser/accessibility/interstitial_accessibility_browsertest.cc b/chrome/browser/accessibility/interstitial_accessibility_browsertest.cc index 8cf1c3b7d0d43b..4449cea28e006f 100644 --- a/chrome/browser/accessibility/interstitial_accessibility_browsertest.cc +++ b/chrome/browser/accessibility/interstitial_accessibility_browsertest.cc @@ -29,7 +29,8 @@ class InterstitialAccessibilityBrowserTest : public InProcessBrowserTest { std::string GetNameOfFocusedNode(content::WebContents* web_contents) { ui::AXNodeData focused_node_data = content::GetFocusedAccessibilityNodeInfo(web_contents); - return focused_node_data.GetStringAttribute(ui::AX_ATTR_NAME); + return focused_node_data.GetStringAttribute( + ax::mojom::StringAttribute::kName); } protected: diff --git a/chrome/browser/apps/guest_view/web_view_browsertest.cc b/chrome/browser/apps/guest_view/web_view_browsertest.cc index af5a95fe09c3e1..d582f8ba549c1b 100644 --- a/chrome/browser/apps/guest_view/web_view_browsertest.cc +++ b/chrome/browser/apps/guest_view/web_view_browsertest.cc @@ -3793,13 +3793,13 @@ IN_PROC_BROWSER_TEST_P(WebViewAccessibilityTest, FocusAccessibility) { // Wait for focus to land on the "root web area" role, representing // focus on the main document itself. while (content::GetFocusedAccessibilityNodeInfo(web_contents).role != - ui::AX_ROLE_ROOT_WEB_AREA) { + ax::mojom::Role::kRootWebArea) { content::WaitForAccessibilityFocusChange(); } // Now keep pressing the Tab key until focus lands on a button. while (content::GetFocusedAccessibilityNodeInfo(web_contents).role != - ui::AX_ROLE_BUTTON) { + ax::mojom::Role::kButton) { content::SimulateKeyPress(web_contents, ui::DomKey::FromCharacter('\t'), ui::DomCode::TAB, ui::VKEY_TAB, false, false, false, false); @@ -3810,18 +3810,16 @@ IN_PROC_BROWSER_TEST_P(WebViewAccessibilityTest, FocusAccessibility) { // "Guest button". ui::AXNodeData node_data = content::GetFocusedAccessibilityNodeInfo(web_contents); - EXPECT_EQ("Guest button", node_data.GetStringAttribute(ui::AX_ATTR_NAME)); + EXPECT_EQ("Guest button", + node_data.GetStringAttribute(ax::mojom::StringAttribute::kName)); } class WebContentsAccessibilityEventWatcher : public content::WebContentsObserver { public: - WebContentsAccessibilityEventWatcher( - content::WebContents* web_contents, - ui::AXEvent event) - : content::WebContentsObserver(web_contents), - event_(event), - count_(0) {} + WebContentsAccessibilityEventWatcher(content::WebContents* web_contents, + ax::mojom::Event event) + : content::WebContentsObserver(web_contents), event_(event), count_(0) {} ~WebContentsAccessibilityEventWatcher() override {} void Wait() { @@ -3849,7 +3847,7 @@ class WebContentsAccessibilityEventWatcher private: scoped_refptr loop_runner_; - ui::AXEvent event_; + ax::mojom::Event event_; ui::AXNodeData node_data_; size_t count_; }; @@ -3863,9 +3861,9 @@ IN_PROC_BROWSER_TEST_P(WebViewAccessibilityTest, DISABLED_TouchAccessibility) { // Listen for accessibility events on both WebContents. WebContentsAccessibilityEventWatcher main_event_watcher( - web_contents, ui::AX_EVENT_HOVER); + web_contents, ax::mojom::Event::kHover); WebContentsAccessibilityEventWatcher guest_event_watcher( - guest_web_contents, ui::AX_EVENT_HOVER); + guest_web_contents, ax::mojom::Event::kHover); // Send an accessibility touch event to the main WebContents, but // positioned on top of the button inside the inner WebView. @@ -3882,7 +3880,7 @@ IN_PROC_BROWSER_TEST_P(WebViewAccessibilityTest, DISABLED_TouchAccessibility) { guest_event_watcher.Wait(); ui::AXNodeData hit_node = guest_event_watcher.node_data(); EXPECT_EQ(1U, guest_event_watcher.count()); - EXPECT_EQ(ui::AX_ROLE_BUTTON, hit_node.role); + EXPECT_EQ(ax::mojom::Role::kButton, hit_node.role); EXPECT_EQ(0U, main_event_watcher.count()); } diff --git a/chrome/browser/chromeos/accessibility/accessibility_manager.h b/chrome/browser/chromeos/accessibility/accessibility_manager.h index 8e2f4153ba465a..f45a37445223d2 100644 --- a/chrome/browser/chromeos/accessibility/accessibility_manager.h +++ b/chrome/browser/chromeos/accessibility/accessibility_manager.h @@ -266,7 +266,7 @@ class AccessibilityManager // Forward an accessibility gesture from the touch exploration controller // to ChromeVox. - // TODO(warx): |gesture| comes from ui::ToString() on a ui::AXGesture. + // TODO(warx): |gesture| comes from ui::ToString() on a ax::mojom::Gesture. void HandleAccessibilityGesture(const std::string& gesture); // Update the touch exploration controller so that synthesized diff --git a/chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc b/chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc index c5af8395be84f3..1f0fa3e11b2fc8 100644 --- a/chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc +++ b/chrome/browser/chromeos/accessibility/spoken_feedback_browsertest.cc @@ -622,7 +622,7 @@ IN_PROC_BROWSER_TEST_P(SpokenFeedbackTest, DISABLED_TouchExploreStatusTray) { // Send an accessibility hover event on the system tray, which is // what we get when you tap it on a touch screen when ChromeVox is on. ash::SystemTray* tray = ash::Shell::Get()->GetPrimarySystemTray(); - tray->NotifyAccessibilityEvent(ui::AX_EVENT_HOVER, true); + tray->NotifyAccessibilityEvent(ax::mojom::Event::kHover, true); EXPECT_EQ("Status tray,", speech_monitor_.GetNextUtterance()); EXPECT_TRUE(base::MatchPattern(speech_monitor_.GetNextUtterance(), "time*,")); diff --git a/chrome/browser/chromeos/arc/accessibility/arc_accessibility_helper_bridge.cc b/chrome/browser/chromeos/arc/accessibility/arc_accessibility_helper_bridge.cc index b6939444155d5f..a9fd9a044517e0 100644 --- a/chrome/browser/chromeos/arc/accessibility/arc_accessibility_helper_bridge.cc +++ b/chrome/browser/chromeos/arc/accessibility/arc_accessibility_helper_bridge.cc @@ -286,12 +286,12 @@ void ArcAccessibilityHelperBridge::OnAccessibilityEvent( if (surface && tree_source->GetTreeData(&tree_data)) { surface->SetAXTreeId(tree_data.tree_id); - // Dispatch AX_EVENT_CHILDREN_CHANGED to force AXNodeData of the - // notification updated. Before AXTreeId is set, its AXNodeData is + // Dispatch ax::mojom::Event::kChildrenChanged to force AXNodeData of + // the notification updated. Before AXTreeId is set, its AXNodeData is // populated as a button. if (surface->IsAttached()) { surface->GetAttachedHost()->NotifyAccessibilityEvent( - ui::AX_EVENT_CHILDREN_CHANGED, false); + ax::mojom::Event::kChildrenChanged, false); } } } @@ -369,41 +369,41 @@ void ArcAccessibilityHelperBridge::OnAction( action_data->window_id = tree_source->window_id(); switch (data.action) { - case ui::AX_ACTION_DO_DEFAULT: + case ax::mojom::Action::kDoDefault: action_data->action_type = arc::mojom::AccessibilityActionType::CLICK; break; - case ui::AX_ACTION_FOCUS: + case ax::mojom::Action::kFocus: action_data->action_type = arc::mojom::AccessibilityActionType::ACCESSIBILITY_FOCUS; break; - case ui::AX_ACTION_SCROLL_TO_MAKE_VISIBLE: + case ax::mojom::Action::kScrollToMakeVisible: action_data->action_type = arc::mojom::AccessibilityActionType::SHOW_ON_SCREEN; break; - case ui::AX_ACTION_SCROLL_BACKWARD: + case ax::mojom::Action::kScrollBackward: action_data->action_type = arc::mojom::AccessibilityActionType::SCROLL_BACKWARD; break; - case ui::AX_ACTION_SCROLL_FORWARD: + case ax::mojom::Action::kScrollForward: action_data->action_type = arc::mojom::AccessibilityActionType::SCROLL_FORWARD; break; - case ui::AX_ACTION_SCROLL_UP: + case ax::mojom::Action::kScrollUp: action_data->action_type = arc::mojom::AccessibilityActionType::SCROLL_UP; break; - case ui::AX_ACTION_SCROLL_DOWN: + case ax::mojom::Action::kScrollDown: action_data->action_type = arc::mojom::AccessibilityActionType::SCROLL_DOWN; break; - case ui::AX_ACTION_SCROLL_LEFT: + case ax::mojom::Action::kScrollLeft: action_data->action_type = arc::mojom::AccessibilityActionType::SCROLL_LEFT; break; - case ui::AX_ACTION_SCROLL_RIGHT: + case ax::mojom::Action::kScrollRight: action_data->action_type = arc::mojom::AccessibilityActionType::SCROLL_RIGHT; break; - case ui::AX_ACTION_CUSTOM_ACTION: + case ax::mojom::Action::kCustomAction: action_data->action_type = arc::mojom::AccessibilityActionType::CUSTOM_ACTION; action_data->custom_action_id = data.custom_action_id; @@ -527,15 +527,15 @@ void ArcAccessibilityHelperBridge::OnNotificationSurfaceAdded( surface->SetAXTreeId(tree_data.tree_id); - // Dispatch AX_EVENT_CHILDREN_CHANGED to force AXNodeData of the notification - // updated. As order of OnNotificationSurfaceAdded call is not guaranteed, we - // are dispatching the event in both ArcAccessibilityHelperBridge and - // ArcNotificationContentView. The event needs to be dispatched after 1. ax - // tree id is set to the surface, 2 the surface is attached to the content - // view. + // Dispatch ax::mojom::Event::kChildrenChanged to force AXNodeData of the + // notification updated. As order of OnNotificationSurfaceAdded call is not + // guaranteed, we are dispatching the event in both + // ArcAccessibilityHelperBridge and ArcNotificationContentView. The event + // needs to be dispatched after 1. ax tree id is set to the surface, 2 the + // surface is attached to the content view. if (surface->IsAttached()) { surface->GetAttachedHost()->NotifyAccessibilityEvent( - ui::AX_EVENT_CHILDREN_CHANGED, false); + ax::mojom::Event::kChildrenChanged, false); } } diff --git a/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.cc b/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.cc index b3c3270ddaacb9..11b2595f2809f0 100644 --- a/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.cc +++ b/chrome/browser/chromeos/arc/accessibility/ax_tree_source_arc.cc @@ -10,6 +10,7 @@ #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h" #include "chrome/common/extensions/chrome_extension_messages.h" #include "components/exo/wm_helper.h" +#include "ui/accessibility/ax_enum_util.h" #include "ui/accessibility/platform/ax_android_constants.h" #include "ui/aura/window.h" #include "ui/views/focus/focus_manager.h" @@ -18,29 +19,29 @@ namespace { -ui::AXEvent ToAXEvent(arc::mojom::AccessibilityEventType arc_event_type) { +ax::mojom::Event ToAXEvent(arc::mojom::AccessibilityEventType arc_event_type) { switch (arc_event_type) { case arc::mojom::AccessibilityEventType::VIEW_FOCUSED: case arc::mojom::AccessibilityEventType::VIEW_ACCESSIBILITY_FOCUSED: - return ui::AX_EVENT_FOCUS; + return ax::mojom::Event::kFocus; case arc::mojom::AccessibilityEventType::VIEW_CLICKED: case arc::mojom::AccessibilityEventType::VIEW_LONG_CLICKED: - return ui::AX_EVENT_CLICKED; + return ax::mojom::Event::kClicked; case arc::mojom::AccessibilityEventType::VIEW_TEXT_CHANGED: - return ui::AX_EVENT_TEXT_CHANGED; + return ax::mojom::Event::kTextChanged; case arc::mojom::AccessibilityEventType::VIEW_TEXT_SELECTION_CHANGED: - return ui::AX_EVENT_TEXT_SELECTION_CHANGED; + return ax::mojom::Event::kTextSelectionChanged; case arc::mojom::AccessibilityEventType::WINDOW_STATE_CHANGED: case arc::mojom::AccessibilityEventType::NOTIFICATION_STATE_CHANGED: case arc::mojom::AccessibilityEventType::WINDOW_CONTENT_CHANGED: case arc::mojom::AccessibilityEventType::WINDOWS_CHANGED: - return ui::AX_EVENT_LAYOUT_COMPLETE; + return ax::mojom::Event::kLayoutComplete; case arc::mojom::AccessibilityEventType::VIEW_HOVER_ENTER: - return ui::AX_EVENT_HOVER; + return ax::mojom::Event::kHover; case arc::mojom::AccessibilityEventType::ANNOUNCEMENT: - return ui::AX_EVENT_ALERT; + return ax::mojom::Event::kAlert; case arc::mojom::AccessibilityEventType::VIEW_SCROLLED: - return ui::AX_EVENT_SCROLL_POSITION_CHANGED; + return ax::mojom::Event::kScrollPositionChanged; case arc::mojom::AccessibilityEventType::VIEW_SELECTED: case arc::mojom::AccessibilityEventType::VIEW_HOVER_EXIT: case arc::mojom::AccessibilityEventType::TOUCH_EXPLORATION_GESTURE_START: @@ -53,11 +54,11 @@ ui::AXEvent ToAXEvent(arc::mojom::AccessibilityEventType arc_event_type) { case arc::mojom::AccessibilityEventType::TOUCH_INTERACTION_END: case arc::mojom::AccessibilityEventType::VIEW_CONTEXT_CLICKED: case arc::mojom::AccessibilityEventType::ASSIST_READING_CONTEXT: - return ui::AX_EVENT_CHILDREN_CHANGED; + return ax::mojom::Event::kChildrenChanged; default: - return ui::AX_EVENT_CHILDREN_CHANGED; + return ax::mojom::Event::kChildrenChanged; } - return ui::AX_EVENT_CHILDREN_CHANGED; + return ax::mojom::Event::kChildrenChanged; } bool GetBooleanProperty(arc::mojom::AccessibilityNodeInfoData* node, @@ -161,7 +162,8 @@ void PopulateAXRole(arc::mojom::AccessibilityNodeInfoData* node, if (GetStringProperty(node, arc::mojom::AccessibilityStringProperty::CLASS_NAME, &class_name)) { - out_data->AddStringAttribute(ui::AX_ATTR_CLASS_NAME, class_name); + out_data->AddStringAttribute(ax::mojom::StringAttribute::kClassName, + class_name); } if (HasCoveringSpan(node, arc::mojom::AccessibilityStringProperty::TEXT, @@ -169,7 +171,7 @@ void PopulateAXRole(arc::mojom::AccessibilityNodeInfoData* node, HasCoveringSpan( node, arc::mojom::AccessibilityStringProperty::CONTENT_DESCRIPTION, arc::mojom::SpanType::URL)) { - out_data->role = ui::AX_ROLE_LINK; + out_data->role = ax::mojom::Role::kLink; return; } @@ -177,10 +179,10 @@ void PopulateAXRole(arc::mojom::AccessibilityNodeInfoData* node, node->collection_item_info.get(); if (collection_item_info) { if (collection_item_info->is_heading) { - out_data->role = ui::AX_ROLE_HEADING; + out_data->role = ax::mojom::Role::kHeading; } else { - out_data->role = ui::AX_ROLE_LIST_ITEM; - out_data->AddIntAttribute(ui::AX_ATTR_POS_IN_SET, + out_data->role = ax::mojom::Role::kListItem; + out_data->AddIntAttribute(ax::mojom::IntAttribute::kPosInSet, collection_item_info->row_index); } return; @@ -190,8 +192,8 @@ void PopulateAXRole(arc::mojom::AccessibilityNodeInfoData* node, if (GetStringProperty(node, arc::mojom::AccessibilityStringProperty::CHROME_ROLE, &chrome_role)) { - ui::AXRole role_value = ui::ParseAXRole(chrome_role); - if (role_value != ui::AX_ROLE_NONE) { + ax::mojom::Role role_value = ui::ParseRole(chrome_role.c_str()); + if (role_value != ax::mojom::Role::kNone) { out_data->role = role_value; return; } @@ -206,44 +208,44 @@ void PopulateAXRole(arc::mojom::AccessibilityNodeInfoData* node, // These mappings were taken from accessibility utils (Android -> Chrome) and // BrowserAccessibilityAndroid. They do not completely match the above two // sources. - MAP_ROLE(ui::kAXAbsListViewClassname, ui::AX_ROLE_LIST); - MAP_ROLE(ui::kAXButtonClassname, ui::AX_ROLE_BUTTON); - MAP_ROLE(ui::kAXCheckBoxClassname, ui::AX_ROLE_CHECK_BOX); - MAP_ROLE(ui::kAXCheckedTextViewClassname, ui::AX_ROLE_STATIC_TEXT); - MAP_ROLE(ui::kAXCompoundButtonClassname, ui::AX_ROLE_CHECK_BOX); - MAP_ROLE(ui::kAXDialogClassname, ui::AX_ROLE_DIALOG); - MAP_ROLE(ui::kAXEditTextClassname, ui::AX_ROLE_TEXT_FIELD); - MAP_ROLE(ui::kAXGridViewClassname, ui::AX_ROLE_TABLE); - MAP_ROLE(ui::kAXImageClassname, ui::AX_ROLE_IMAGE); - MAP_ROLE(ui::kAXImageButtonClassname, ui::AX_ROLE_BUTTON); + MAP_ROLE(ui::kAXAbsListViewClassname, ax::mojom::Role::kList); + MAP_ROLE(ui::kAXButtonClassname, ax::mojom::Role::kButton); + MAP_ROLE(ui::kAXCheckBoxClassname, ax::mojom::Role::kCheckBox); + MAP_ROLE(ui::kAXCheckedTextViewClassname, ax::mojom::Role::kStaticText); + MAP_ROLE(ui::kAXCompoundButtonClassname, ax::mojom::Role::kCheckBox); + MAP_ROLE(ui::kAXDialogClassname, ax::mojom::Role::kDialog); + MAP_ROLE(ui::kAXEditTextClassname, ax::mojom::Role::kTextField); + MAP_ROLE(ui::kAXGridViewClassname, ax::mojom::Role::kTable); + MAP_ROLE(ui::kAXImageClassname, ax::mojom::Role::kImage); + MAP_ROLE(ui::kAXImageButtonClassname, ax::mojom::Role::kButton); if (GetBooleanProperty(node, arc::mojom::AccessibilityBooleanProperty::CLICKABLE)) { - MAP_ROLE(ui::kAXImageViewClassname, ui::AX_ROLE_BUTTON); + MAP_ROLE(ui::kAXImageViewClassname, ax::mojom::Role::kButton); } else { - MAP_ROLE(ui::kAXImageViewClassname, ui::AX_ROLE_IMAGE); + MAP_ROLE(ui::kAXImageViewClassname, ax::mojom::Role::kImage); } - MAP_ROLE(ui::kAXListViewClassname, ui::AX_ROLE_LIST); - MAP_ROLE(ui::kAXMenuItemClassname, ui::AX_ROLE_MENU_ITEM); - MAP_ROLE(ui::kAXPagerClassname, ui::AX_ROLE_GROUP); - MAP_ROLE(ui::kAXProgressBarClassname, ui::AX_ROLE_PROGRESS_INDICATOR); - MAP_ROLE(ui::kAXRadioButtonClassname, ui::AX_ROLE_RADIO_BUTTON); - MAP_ROLE(ui::kAXSeekBarClassname, ui::AX_ROLE_SLIDER); - MAP_ROLE(ui::kAXSpinnerClassname, ui::AX_ROLE_POP_UP_BUTTON); - MAP_ROLE(ui::kAXSwitchClassname, ui::AX_ROLE_SWITCH); - MAP_ROLE(ui::kAXTabWidgetClassname, ui::AX_ROLE_TAB_LIST); - MAP_ROLE(ui::kAXToggleButtonClassname, ui::AX_ROLE_TOGGLE_BUTTON); - MAP_ROLE(ui::kAXViewClassname, ui::AX_ROLE_GENERIC_CONTAINER); - MAP_ROLE(ui::kAXViewGroupClassname, ui::AX_ROLE_GROUP); - MAP_ROLE(ui::kAXWebViewClassname, ui::AX_ROLE_WEB_VIEW); + MAP_ROLE(ui::kAXListViewClassname, ax::mojom::Role::kList); + MAP_ROLE(ui::kAXMenuItemClassname, ax::mojom::Role::kMenuItem); + MAP_ROLE(ui::kAXPagerClassname, ax::mojom::Role::kGroup); + MAP_ROLE(ui::kAXProgressBarClassname, ax::mojom::Role::kProgressIndicator); + MAP_ROLE(ui::kAXRadioButtonClassname, ax::mojom::Role::kRadioButton); + MAP_ROLE(ui::kAXSeekBarClassname, ax::mojom::Role::kSlider); + MAP_ROLE(ui::kAXSpinnerClassname, ax::mojom::Role::kPopUpButton); + MAP_ROLE(ui::kAXSwitchClassname, ax::mojom::Role::kSwitch); + MAP_ROLE(ui::kAXTabWidgetClassname, ax::mojom::Role::kTabList); + MAP_ROLE(ui::kAXToggleButtonClassname, ax::mojom::Role::kToggleButton); + MAP_ROLE(ui::kAXViewClassname, ax::mojom::Role::kGenericContainer); + MAP_ROLE(ui::kAXViewGroupClassname, ax::mojom::Role::kGroup); + MAP_ROLE(ui::kAXWebViewClassname, ax::mojom::Role::kWebView); #undef MAP_ROLE std::string text; GetStringProperty(node, arc::mojom::AccessibilityStringProperty::TEXT, &text); if (!text.empty()) - out_data->role = ui::AX_ROLE_STATIC_TEXT; + out_data->role = ax::mojom::Role::kStaticText; else - out_data->role = ui::AX_ROLE_GENERIC_CONTAINER; + out_data->role = ax::mojom::Role::kGenericContainer; } void PopulateAXState(arc::mojom::AccessibilityNodeInfoData* node, @@ -257,27 +259,27 @@ void PopulateAXState(arc::mojom::AccessibilityNodeInfoData* node, // These mappings were taken from accessibility utils (Android -> Chrome) and // BrowserAccessibilityAndroid. They do not completely match the above two // sources. - MAP_STATE(AXBooleanProperty::EDITABLE, ui::AX_STATE_EDITABLE); - MAP_STATE(AXBooleanProperty::FOCUSABLE, ui::AX_STATE_FOCUSABLE); - MAP_STATE(AXBooleanProperty::MULTI_LINE, ui::AX_STATE_MULTILINE); - MAP_STATE(AXBooleanProperty::PASSWORD, ui::AX_STATE_PROTECTED); - MAP_STATE(AXBooleanProperty::SELECTED, ui::AX_STATE_SELECTED); + MAP_STATE(AXBooleanProperty::EDITABLE, ax::mojom::State::kEditable); + MAP_STATE(AXBooleanProperty::FOCUSABLE, ax::mojom::State::kFocusable); + MAP_STATE(AXBooleanProperty::MULTI_LINE, ax::mojom::State::kMultiline); + MAP_STATE(AXBooleanProperty::PASSWORD, ax::mojom::State::kProtected); + MAP_STATE(AXBooleanProperty::SELECTED, ax::mojom::State::kSelected); #undef MAP_STATE if (GetBooleanProperty(node, AXBooleanProperty::CHECKABLE)) { const bool is_checked = GetBooleanProperty(node, AXBooleanProperty::CHECKED); - out_data->SetCheckedState(is_checked ? ui::AX_CHECKED_STATE_TRUE - : ui::AX_CHECKED_STATE_FALSE); + out_data->SetCheckedState(is_checked ? ax::mojom::CheckedState::kTrue + : ax::mojom::CheckedState::kFalse); } if (!GetBooleanProperty(node, AXBooleanProperty::ENABLED)) { - out_data->SetRestriction(ui::AX_RESTRICTION_DISABLED); + out_data->SetRestriction(ax::mojom::Restriction::kDisabled); } if (!GetBooleanProperty(node, AXBooleanProperty::VISIBLE_TO_USER)) { - out_data->AddState(ui::AX_STATE_INVISIBLE); + out_data->AddState(ax::mojom::State::kInvisible); } } @@ -299,8 +301,8 @@ class AXTreeSourceArc::FocusStealer : public views::View { // views::View overrides. void GetAccessibleNodeData(ui::AXNodeData* node_data) override { - node_data->AddIntAttribute(ui::AX_ATTR_CHILD_TREE_ID, id_); - node_data->role = ui::AX_ROLE_CLIENT; + node_data->AddIntAttribute(ax::mojom::IntAttribute::kChildTreeId, id_); + node_data->role = ax::mojom::Role::kClient; } private: @@ -473,7 +475,7 @@ void AXTreeSourceArc::SerializeNode(mojom::AccessibilityNodeInfoData* node, int32_t id = node->id; out_data->id = id; if (id == root_id_) - out_data->role = ui::AX_ROLE_ROOT_WEB_AREA; + out_data->role = ax::mojom::Role::kRootWebArea; else PopulateAXRole(node, out_data); @@ -492,7 +494,7 @@ void AXTreeSourceArc::SerializeNode(mojom::AccessibilityNodeInfoData* node, std::string role_description; if (GetStringProperty(node, AXStringProperty::ROLE_DESCRIPTION, &role_description)) { - out_data->AddStringAttribute(ui::AX_ATTR_ROLE_DESCRIPTION, + out_data->AddStringAttribute(ax::mojom::StringAttribute::kRoleDescription, role_description); } @@ -500,21 +502,21 @@ void AXTreeSourceArc::SerializeNode(mojom::AccessibilityNodeInfoData* node, PopulateAXState(node, out_data); if (GetBooleanProperty( node, arc::mojom::AccessibilityBooleanProperty::SCROLLABLE)) { - out_data->AddBoolAttribute(ui::AX_ATTR_SCROLLABLE, true); + out_data->AddBoolAttribute(ax::mojom::BoolAttribute::kScrollable, true); } if (GetBooleanProperty(node, arc::mojom::AccessibilityBooleanProperty::CLICKABLE)) { - out_data->AddBoolAttribute(ui::AX_ATTR_CLICKABLE, true); + out_data->AddBoolAttribute(ax::mojom::BoolAttribute::kClickable, true); } // Range info. arc::mojom::AccessibilityRangeInfoData* range_info = node->range_info.get(); if (range_info) { - out_data->AddFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, + out_data->AddFloatAttribute(ax::mojom::FloatAttribute::kValueForRange, range_info->current); - out_data->AddFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE, + out_data->AddFloatAttribute(ax::mojom::FloatAttribute::kMinValueForRange, range_info->min); - out_data->AddFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE, + out_data->AddFloatAttribute(ax::mojom::FloatAttribute::kMaxValueForRange, range_info->max); } @@ -532,17 +534,17 @@ void AXTreeSourceArc::SerializeNode(mojom::AccessibilityNodeInfoData* node, local_bounds.width(), local_bounds.height()); } - if (out_data->role == ui::AX_ROLE_TEXT_FIELD && !text.empty()) - out_data->AddStringAttribute(ui::AX_ATTR_VALUE, text); + if (out_data->role == ax::mojom::Role::kTextField && !text.empty()) + out_data->AddStringAttribute(ax::mojom::StringAttribute::kValue, text); // Integer properties. int32_t val; if (GetIntProperty(node, AXIntProperty::TEXT_SELECTION_START, &val) && val >= 0) - out_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, val); + out_data->AddIntAttribute(ax::mojom::IntAttribute::kTextSelStart, val); if (GetIntProperty(node, AXIntProperty::TEXT_SELECTION_END, &val) && val >= 0) - out_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, val); + out_data->AddIntAttribute(ax::mojom::IntAttribute::kTextSelEnd, val); // Custom actions. std::vector custom_action_ids; @@ -556,11 +558,12 @@ void AXTreeSourceArc::SerializeNode(mojom::AccessibilityNodeInfoData* node, CHECK(!custom_action_ids.empty()); CHECK_EQ(custom_action_ids.size(), custom_action_descriptions.size()); - out_data->AddAction(ui::AX_ACTION_CUSTOM_ACTION); - out_data->AddIntListAttribute(ui::AX_ATTR_CUSTOM_ACTION_IDS, + out_data->AddAction(ax::mojom::Action::kCustomAction); + out_data->AddIntListAttribute(ax::mojom::IntListAttribute::kCustomActionIds, custom_action_ids); - out_data->AddStringListAttribute(ui::AX_ATTR_CUSTOM_ACTION_DESCRIPTIONS, - custom_action_descriptions); + out_data->AddStringListAttribute( + ax::mojom::StringListAttribute::kCustomActionDescriptions, + custom_action_descriptions); } } @@ -605,7 +608,7 @@ void AXTreeSourceArc::Reset() { if (focus_stealer_->parent()) { views::View* parent = focus_stealer_->parent(); parent->RemoveChildView(focus_stealer_.get()); - parent->NotifyAccessibilityEvent(ui::AX_EVENT_CHILDREN_CHANGED, false); + parent->NotifyAccessibilityEvent(ax::mojom::Event::kChildrenChanged, false); } focus_stealer_.reset(); extensions::AutomationEventRouter* router = diff --git a/chrome/browser/chromeos/arc/voice_interaction/arc_voice_interaction_arc_home_service_browsertest.cc b/chrome/browser/chromeos/arc/voice_interaction/arc_voice_interaction_arc_home_service_browsertest.cc index f876b3457b8cbf..d1744e7d9f302b 100644 --- a/chrome/browser/chromeos/arc/voice_interaction/arc_voice_interaction_arc_home_service_browsertest.cc +++ b/chrome/browser/chromeos/arc/voice_interaction/arc_voice_interaction_arc_home_service_browsertest.cc @@ -127,7 +127,8 @@ IN_PROC_BROWSER_TEST_F(ArcVoiceInteractionArcHomeServiceTest, VoiceInteractionStructureSelectTest) { // Help ensure accessibility states are tested correctly. // When the states are not tested correctly (bit shifted), the option appears - // to have AX_STATE_PROTECTED, and text is incorrectly set as password dots. + // to have ax::mojom::State::kProtected, and text is incorrectly set as + // password dots. auto result = GetVoiceInteractionStructure( "
"); ASSERT_FALSE(result.is_null()); diff --git a/chrome/browser/chromeos/login/existing_user_controller.cc b/chrome/browser/chromeos/login/existing_user_controller.cc index f1a0592dba8fb6..a6b8ba1ca56f53 100644 --- a/chrome/browser/chromeos/login/existing_user_controller.cc +++ b/chrome/browser/chromeos/login/existing_user_controller.cc @@ -96,7 +96,7 @@ #include "net/http/http_transaction_factory.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_getter.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/base/l10n/l10n_util.h" #include "ui/views/widget/widget.h" diff --git a/chrome/browser/chromeos/ui/idle_app_name_notification_view.cc b/chrome/browser/chromeos/ui/idle_app_name_notification_view.cc index 20cb39833c2944..e35d44ab926a1e 100644 --- a/chrome/browser/chromeos/ui/idle_app_name_notification_view.cc +++ b/chrome/browser/chromeos/ui/idle_app_name_notification_view.cc @@ -91,7 +91,7 @@ void CreateAndShowWidget(views::WidgetDelegateView* delegate, widget->SetBounds(bounds); // Allow to use the message for spoken feedback. - delegate->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); + delegate->NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true); } } // namespace @@ -175,7 +175,7 @@ class IdleAppNameNotificationDelegateView void GetAccessibleNodeData(ui::AXNodeData* node_data) override { node_data->SetName(spoken_text_); - node_data->role = ui::AX_ROLE_ALERT; + node_data->role = ax::mojom::Role::kAlert; } // ImplicitAnimationObserver overrides @@ -239,7 +239,7 @@ base::string16 IdleAppNameNotificationView::GetShownTextForTest() { ui::AXNodeData node_data; DCHECK(view_); view_->GetAccessibleNodeData(&node_data); - return node_data.GetString16Attribute(ui::AX_ATTR_NAME); + return node_data.GetString16Attribute(ax::mojom::StringAttribute::kName); } void IdleAppNameNotificationView::ShowMessage( diff --git a/chrome/browser/extensions/BUILD.gn b/chrome/browser/extensions/BUILD.gn index 84da164401f373..649ea9d9e02584 100644 --- a/chrome/browser/extensions/BUILD.gn +++ b/chrome/browser/extensions/BUILD.gn @@ -903,7 +903,7 @@ static_library("extensions") { "//third_party/libaddressinput:util", "//third_party/re2", "//third_party/zlib/google:zip", - "//ui/accessibility:ax_gen", + "//ui/accessibility:ax_enums_mojo", "//ui/base", "//ui/base/ime", "//ui/display/manager", diff --git a/chrome/browser/extensions/api/automation_internal/automation_event_router.cc b/chrome/browser/extensions/api/automation_internal/automation_event_router.cc index b54484f9b58d69..b87d67a8227cdf 100644 --- a/chrome/browser/extensions/api/automation_internal/automation_event_router.cc +++ b/chrome/browser/extensions/api/automation_internal/automation_event_router.cc @@ -23,7 +23,7 @@ #include "extensions/browser/event_router.h" #include "extensions/common/extension.h" #include "ui/accessibility/ax_action_data.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_node_data.h" namespace extensions { diff --git a/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc b/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc index fb6ae1dac9e124..e8309a03a776af 100644 --- a/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc +++ b/chrome/browser/extensions/api/automation_internal/automation_internal_api.cc @@ -38,6 +38,7 @@ #include "extensions/common/extension_messages.h" #include "extensions/common/permissions/permissions_data.h" #include "ui/accessibility/ax_action_data.h" +#include "ui/accessibility/ax_enum_util.h" #include "ui/accessibility/ax_host_delegate.h" #include "ui/accessibility/ax_tree_id_registry.h" @@ -209,7 +210,7 @@ class AutomationWebContentsObserver std::vector details; content::AXEventNotificationDetails detail; detail.ax_tree_id = id.first->GetAXTreeID(); - detail.event_type = ui::AX_EVENT_MEDIA_STARTED_PLAYING; + detail.event_type = ax::mojom::Event::kMediaStartedPlaying; details.push_back(detail); AccessibilityEventReceived(details); } @@ -221,7 +222,7 @@ class AutomationWebContentsObserver std::vector details; content::AXEventNotificationDetails detail; detail.ax_tree_id = id.first->GetAXTreeID(); - detail.event_type = ui::AX_EVENT_MEDIA_STOPPED_PLAYING; + detail.event_type = ax::mojom::Event::kMediaStoppedPlaying; details.push_back(detail); AccessibilityEventReceived(details); } @@ -240,7 +241,7 @@ class AutomationWebContentsObserver content::AXEventNotificationDetails detail; detail.ax_tree_id = rfh->GetAXTreeID(); - detail.event_type = ui::AX_EVENT_MEDIA_STARTED_PLAYING; + detail.event_type = ax::mojom::Event::kMediaStartedPlaying; details.push_back(detail); AccessibilityEventReceived(details); } @@ -338,17 +339,17 @@ AutomationInternalPerformActionFunction::ConvertToAXActionData( action->request_id = request_id ? *request_id : -1; switch (params->args.action_type) { case api::automation_internal::ACTION_TYPE_DODEFAULT: - action->action = ui::AX_ACTION_DO_DEFAULT; + action->action = ax::mojom::Action::kDoDefault; break; case api::automation_internal::ACTION_TYPE_FOCUS: - action->action = ui::AX_ACTION_FOCUS; + action->action = ax::mojom::Action::kFocus; break; case api::automation_internal::ACTION_TYPE_GETIMAGEDATA: { api::automation_internal::GetImageDataParams get_image_data_params; EXTENSION_FUNCTION_VALIDATE( api::automation_internal::GetImageDataParams::Populate( params->opt_args.additional_properties, &get_image_data_params)); - action->action = ui::AX_ACTION_GET_IMAGE_DATA; + action->action = ax::mojom::Action::kGetImageData; action->target_rect = gfx::Rect(0, 0, get_image_data_params.max_width, get_image_data_params.max_height); break; @@ -358,34 +359,34 @@ AutomationInternalPerformActionFunction::ConvertToAXActionData( EXTENSION_FUNCTION_VALIDATE( api::automation_internal::HitTestParams::Populate( params->opt_args.additional_properties, &hit_test_params)); - action->action = ui::AX_ACTION_HIT_TEST; + action->action = ax::mojom::Action::kHitTest; action->target_point = gfx::Point(hit_test_params.x, hit_test_params.y); action->hit_test_event_to_fire = - ui::ParseAXEvent(hit_test_params.event_to_fire); - if (action->hit_test_event_to_fire == ui::AX_EVENT_NONE) + ui::ParseEvent(hit_test_params.event_to_fire.c_str()); + if (action->hit_test_event_to_fire == ax::mojom::Event::kNone) return RespondNow(NoArguments()); break; } case api::automation_internal::ACTION_TYPE_MAKEVISIBLE: - action->action = ui::AX_ACTION_SCROLL_TO_MAKE_VISIBLE; + action->action = ax::mojom::Action::kScrollToMakeVisible; break; case api::automation_internal::ACTION_TYPE_SCROLLBACKWARD: - action->action = ui::AX_ACTION_SCROLL_BACKWARD; + action->action = ax::mojom::Action::kScrollBackward; break; case api::automation_internal::ACTION_TYPE_SCROLLFORWARD: - action->action = ui::AX_ACTION_SCROLL_FORWARD; + action->action = ax::mojom::Action::kScrollForward; break; case api::automation_internal::ACTION_TYPE_SCROLLUP: - action->action = ui::AX_ACTION_SCROLL_UP; + action->action = ax::mojom::Action::kScrollUp; break; case api::automation_internal::ACTION_TYPE_SCROLLDOWN: - action->action = ui::AX_ACTION_SCROLL_DOWN; + action->action = ax::mojom::Action::kScrollDown; break; case api::automation_internal::ACTION_TYPE_SCROLLLEFT: - action->action = ui::AX_ACTION_SCROLL_LEFT; + action->action = ax::mojom::Action::kScrollLeft; break; case api::automation_internal::ACTION_TYPE_SCROLLRIGHT: - action->action = ui::AX_ACTION_SCROLL_RIGHT; + action->action = ax::mojom::Action::kScrollRight; break; case api::automation_internal::ACTION_TYPE_SETSELECTION: { api::automation_internal::SetSelectionParams selection_params; @@ -396,17 +397,17 @@ AutomationInternalPerformActionFunction::ConvertToAXActionData( action->anchor_offset = selection_params.anchor_offset; action->focus_node_id = selection_params.focus_node_id; action->focus_offset = selection_params.focus_offset; - action->action = ui::AX_ACTION_SET_SELECTION; + action->action = ax::mojom::Action::kSetSelection; break; } case api::automation_internal::ACTION_TYPE_SHOWCONTEXTMENU: { - action->action = ui::AX_ACTION_SHOW_CONTEXT_MENU; + action->action = ax::mojom::Action::kShowContextMenu; break; } case api::automation_internal:: ACTION_TYPE_SETSEQUENTIALFOCUSNAVIGATIONSTARTINGPOINT: { action->action = - ui::AX_ACTION_SET_SEQUENTIAL_FOCUS_NAVIGATION_STARTING_POINT; + ax::mojom::Action::kSetSequentialFocusNavigationStartingPoint; break; } case api::automation_internal::ACTION_TYPE_CUSTOMACTION: { @@ -416,7 +417,7 @@ AutomationInternalPerformActionFunction::ConvertToAXActionData( api::automation_internal::PerformCustomActionParams::Populate( params->opt_args.additional_properties, &perform_custom_action_params)); - action->action = ui::AX_ACTION_CUSTOM_ACTION; + action->action = ax::mojom::Action::kCustomAction; action->custom_action_id = perform_custom_action_params.custom_action_id; break; } diff --git a/chrome/browser/pdf/pdf_extension_test.cc b/chrome/browser/pdf/pdf_extension_test.cc index d77c732d6b0a28..5208ddedc0b191 100644 --- a/chrome/browser/pdf/pdf_extension_test.cc +++ b/chrome/browser/pdf/pdf_extension_test.cc @@ -63,6 +63,7 @@ #include "extensions/test/result_catcher.h" #include "net/dns/mock_host_resolver.h" #include "net/test/embedded_test_server/embedded_test_server.h" +#include "ui/accessibility/ax_enum_util.h" #include "ui/base/clipboard/clipboard.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/test/test_clipboard.h" @@ -629,7 +630,7 @@ static std::string DumpPdfAccessibilityTree(const ui::AXTreeUpdate& ax_tree) { std::map id_to_indentation; bool found_embedded_object = false; for (auto& node : ax_tree.nodes) { - if (node.role == ui::AX_ROLE_EMBEDDED_OBJECT) + if (node.role == ax::mojom::Role::kEmbeddedObject) found_embedded_object = true; if (!found_embedded_object) continue; @@ -638,7 +639,8 @@ static std::string DumpPdfAccessibilityTree(const ui::AXTreeUpdate& ax_tree) { ax_tree_dump += std::string(2 * indent, ' '); ax_tree_dump += ui::ToString(node.role); - std::string name = node.GetStringAttribute(ui::AX_ATTR_NAME); + std::string name = + node.GetStringAttribute(ax::mojom::StringAttribute::kName); base::ReplaceChars(name, "\r\n", "", &name); if (!name.empty()) ax_tree_dump += " '" + name + "'"; diff --git a/chrome/browser/resources/chromeos/chromevox/chromevox/background/kbexplorer.js b/chrome/browser/resources/chromeos/chromevox/chromevox/background/kbexplorer.js index 017d5e3278c9cf..2269a7eb83b5c0 100644 --- a/chrome/browser/resources/chromeos/chromevox/chromevox/background/kbexplorer.js +++ b/chrome/browser/resources/chromeos/chromevox/chromevox/background/kbexplorer.js @@ -200,7 +200,7 @@ cvox.KbExplorer.onBrailleKeyEvent = function(evt) { /** * Handles accessibility gestures from the touch screen. - * @param {string} gesture The gesture to handle, based on the AXGesture enum + * @param {string} gesture The gesture to handle, based on the ax::mojom::Gesture enum * defined in ui/accessibility/ax_enums.idl */ cvox.KbExplorer.onAccessibilityGesture = function(gesture) { diff --git a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js index 313d6245b69d57..f76f5f8eeeaa39 100644 --- a/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js +++ b/chrome/browser/resources/chromeos/chromevox/cvox2/background/background.js @@ -151,7 +151,7 @@ Background = function() { }; /** - * Map from gesture names (AXGesture defined in ui/accessibility/ax_enums.idl) + * Map from gesture names (ax::mojom::Gesture defined in ui/accessibility/ax_enums.idl) * to commands. * @type {Object} * @const @@ -462,7 +462,7 @@ Background.prototype = { /** * Handles accessibility gestures from the touch screen. - * @param {string} gesture The gesture to handle, based on the AXGesture enum + * @param {string} gesture The gesture to handle, based on the ax::mojom::Gesture enum * defined in ui/accessibility/ax_enums.idl * @private */ diff --git a/chrome/browser/ui/ash/accessibility/ax_tree_source_aura_unittest.cc b/chrome/browser/ui/ash/accessibility/ax_tree_source_aura_unittest.cc index 424a7028b3af16..843587aa0f8a9d 100644 --- a/chrome/browser/ui/ash/accessibility/ax_tree_source_aura_unittest.cc +++ b/chrome/browser/ui/ash/accessibility/ax_tree_source_aura_unittest.cc @@ -12,7 +12,7 @@ #include "chrome/browser/ui/aura/accessibility/ax_tree_source_aura.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/accessibility/ax_action_data.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_node.h" #include "ui/accessibility/ax_serializable_tree.h" #include "ui/accessibility/ax_tree_serializer.h" @@ -125,7 +125,7 @@ TEST_F(AXTreeSourceAuraTest, DoDefault) { // Click and verify focus. ASSERT_FALSE(textfield_->HasFocus()); ui::AXActionData action_data; - action_data.action = ui::AX_ACTION_DO_DEFAULT; + action_data.action = ax::mojom::Action::kDoDefault; action_data.target_node_id = textfield_wrapper->GetUniqueId().Get(); textfield_wrapper->HandleAccessibleAction(action_data); ASSERT_TRUE(textfield_->HasFocus()); @@ -141,7 +141,7 @@ TEST_F(AXTreeSourceAuraTest, Focus) { // Focus and verify. ASSERT_FALSE(textfield_->HasFocus()); ui::AXActionData action_data; - action_data.action = ui::AX_ACTION_FOCUS; + action_data.action = ax::mojom::Action::kFocus; action_data.target_node_id = textfield_wrapper->GetUniqueId().Get(); textfield_wrapper->HandleAccessibleAction(action_data); ASSERT_TRUE(textfield_->HasFocus()); @@ -184,6 +184,6 @@ TEST_F(AXTreeSourceAuraTest, Serialize) { } ASSERT_NE(-1, text_field_update_index); - ASSERT_EQ(ui::AX_ROLE_TEXT_FIELD, + ASSERT_EQ(ax::mojom::Role::kTextField, out_update2.nodes[text_field_update_index].role); } diff --git a/chrome/browser/ui/aura/accessibility/automation_manager_aura.cc b/chrome/browser/ui/aura/accessibility/automation_manager_aura.cc index 109267ce414ba8..03b5e921b06a9a 100644 --- a/chrome/browser/ui/aura/accessibility/automation_manager_aura.cc +++ b/chrome/browser/ui/aura/accessibility/automation_manager_aura.cc @@ -18,7 +18,7 @@ #include "content/public/browser/browser_context.h" #include "content/public/browser/render_frame_host.h" #include "ui/accessibility/ax_action_data.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_tree_id_registry.h" #include "ui/accessibility/platform/aura_window_properties.h" #include "ui/aura/env.h" @@ -83,7 +83,7 @@ void AutomationManagerAura::Enable(BrowserContext* context) { enabled_ = true; Reset(false); - SendEvent(context, current_tree_->GetRoot(), ui::AX_EVENT_LOAD_COMPLETE); + SendEvent(context, current_tree_->GetRoot(), ax::mojom::Event::kLoadComplete); views::AXAuraObjCache::GetInstance()->SetDelegate(this); #if defined(OS_CHROMEOS) @@ -91,7 +91,7 @@ void AutomationManagerAura::Enable(BrowserContext* context) { if (active_window) { views::AXAuraObjWrapper* focus = views::AXAuraObjCache::GetInstance()->GetOrCreate(active_window); - SendEvent(context, focus, ui::AX_EVENT_CHILDREN_CHANGED); + SendEvent(context, focus, ax::mojom::Event::kChildrenChanged); } #endif } @@ -103,7 +103,7 @@ void AutomationManagerAura::Disable() { void AutomationManagerAura::HandleEvent(BrowserContext* context, views::View* view, - ui::AXEvent event_type) { + ax::mojom::Event event_type) { if (!enabled_) return; @@ -121,7 +121,7 @@ void AutomationManagerAura::HandleAlert(content::BrowserContext* context, views::AXAuraObjWrapper* obj = static_cast(current_tree_->GetRoot()) ->GetAlertForText(text); - SendEvent(context, obj, ui::AX_EVENT_ALERT); + SendEvent(context, obj, ax::mojom::Event::kAlert); } void AutomationManagerAura::PerformAction(const ui::AXActionData& data) { @@ -129,7 +129,7 @@ void AutomationManagerAura::PerformAction(const ui::AXActionData& data) { // Unlike all of the other actions, a hit test requires determining the // node to perform the action on first. - if (data.action == ui::AX_ACTION_HIT_TEST) { + if (data.action == ax::mojom::Action::kHitTest) { PerformHitTest(data); return; } @@ -145,11 +145,11 @@ void AutomationManagerAura::OnChildWindowRemoved( if (!parent) parent = current_tree_->GetRoot(); - SendEvent(nullptr, parent, ui::AX_EVENT_CHILDREN_CHANGED); + SendEvent(nullptr, parent, ax::mojom::Event::kChildrenChanged); } void AutomationManagerAura::OnEvent(views::AXAuraObjWrapper* aura_obj, - ui::AXEvent event_type) { + ax::mojom::Event event_type) { SendEvent(nullptr, aura_obj, event_type); } @@ -171,7 +171,7 @@ void AutomationManagerAura::Reset(bool reset_serializer) { void AutomationManagerAura::SendEvent(BrowserContext* context, views::AXAuraObjWrapper* aura_obj, - ui::AXEvent event_type) { + ax::mojom::Event event_type) { if (!current_tree_serializer_) return; diff --git a/chrome/browser/ui/aura/accessibility/automation_manager_aura.h b/chrome/browser/ui/aura/accessibility/automation_manager_aura.h index c6ec8a1cd6a2be..edd73882488bd3 100644 --- a/chrome/browser/ui/aura/accessibility/automation_manager_aura.h +++ b/chrome/browser/ui/aura/accessibility/automation_manager_aura.h @@ -53,7 +53,7 @@ class AutomationManagerAura : public ui::AXHostDelegate, // Handle an event fired upon a |View|. void HandleEvent(content::BrowserContext* context, views::View* view, - ui::AXEvent event_type); + ax::mojom::Event event_type); void HandleAlert(content::BrowserContext* context, const std::string& text); @@ -63,7 +63,7 @@ class AutomationManagerAura : public ui::AXHostDelegate, // views::AXAuraObjCache::Delegate implementation. void OnChildWindowRemoved(views::AXAuraObjWrapper* parent) override; void OnEvent(views::AXAuraObjWrapper* aura_obj, - ui::AXEvent event_type) override; + ax::mojom::Event event_type) override; protected: AutomationManagerAura(); @@ -80,7 +80,7 @@ class AutomationManagerAura : public ui::AXHostDelegate, void SendEvent(content::BrowserContext* context, views::AXAuraObjWrapper* aura_obj, - ui::AXEvent event_type); + ax::mojom::Event event_type); void PerformHitTest(const ui::AXActionData& data); @@ -98,7 +98,8 @@ class AutomationManagerAura : public ui::AXHostDelegate, bool processing_events_; - std::vector> pending_events_; + std::vector> + pending_events_; DISALLOW_COPY_AND_ASSIGN(AutomationManagerAura); }; diff --git a/chrome/browser/ui/aura/accessibility/automation_manager_aura_browsertest.cc b/chrome/browser/ui/aura/accessibility/automation_manager_aura_browsertest.cc index ade6d0763a3aa7..4ab9dd265e923c 100644 --- a/chrome/browser/ui/aura/accessibility/automation_manager_aura_browsertest.cc +++ b/chrome/browser/ui/aura/accessibility/automation_manager_aura_browsertest.cc @@ -26,7 +26,7 @@ void FindAllHostsOfWebContentsWithAXTreeID( std::vector* web_hosts) { ui::AXNodeData node_data; tree->SerializeNode(node, &node_data); - if (node_data.GetIntAttribute(ui::AX_ATTR_CHILD_TREE_ID) == + if (node_data.GetIntAttribute(ax::mojom::IntAttribute::kChildTreeId) == target_ax_tree_id) { web_hosts->push_back(node); } @@ -74,7 +74,7 @@ IN_PROC_BROWSER_TEST_F(AutomationManagerAuraBrowserTest, WebAppearsOnce) { if (web_hosts.size() == 1) { ui::AXNodeData node_data; tree->SerializeNode(web_hosts[0], &node_data); - EXPECT_EQ(ui::AX_ROLE_WEB_VIEW, node_data.role); + EXPECT_EQ(ax::mojom::Role::kWebView, node_data.role); } else { for (size_t i = 0; i < web_hosts.size(); i++) { ui::AXNodeData node_data; diff --git a/chrome/browser/ui/aura/accessibility/ax_root_obj_wrapper.cc b/chrome/browser/ui/aura/accessibility/ax_root_obj_wrapper.cc index dd03af7c280332..d1bab1736fdd58 100644 --- a/chrome/browser/ui/aura/accessibility/ax_root_obj_wrapper.cc +++ b/chrome/browser/ui/aura/accessibility/ax_root_obj_wrapper.cc @@ -52,8 +52,8 @@ void AXRootObjWrapper::GetChildren( void AXRootObjWrapper::Serialize(ui::AXNodeData* out_node_data) { out_node_data->id = unique_id_.Get(); - out_node_data->role = ui::AX_ROLE_DESKTOP; - out_node_data->AddStringAttribute(ui::AX_ATTR_CHROME_CHANNEL, + out_node_data->role = ax::mojom::Role::kDesktop; + out_node_data->AddStringAttribute(ax::mojom::StringAttribute::kChromeChannel, chrome::GetChannelString()); } diff --git a/chrome/browser/ui/aura/accessibility/ax_tree_source_aura.cc b/chrome/browser/ui/aura/accessibility/ax_tree_source_aura.cc index e6cca883581b41..f9729d4fde9684 100644 --- a/chrome/browser/ui/aura/accessibility/ax_tree_source_aura.cc +++ b/chrome/browser/ui/aura/accessibility/ax_tree_source_aura.cc @@ -36,7 +36,7 @@ bool AXTreeSourceAura::HandleAccessibleAction(const ui::AXActionData& action) { // In Views, we only support setting the selection within a single node, // not across multiple nodes like on the web. - if (action.action == ui::AX_ACTION_SET_SELECTION) { + if (action.action == ax::mojom::Action::kSetSelection) { if (action.anchor_node_id != action.focus_node_id) { NOTREACHED(); return false; @@ -121,19 +121,20 @@ void AXTreeSourceAura::SerializeNode(AXAuraObjWrapper* node, out_data->offset_container_id = parent->GetUniqueId().Get(); } - if (out_data->role == ui::AX_ROLE_WEB_VIEW) { + if (out_data->role == ax::mojom::Role::kWebView) { views::View* view = static_cast(node)->view(); content::WebContents* contents = static_cast(view)->GetWebContents(); content::RenderFrameHost* rfh = contents->GetMainFrame(); if (rfh) { int ax_tree_id = rfh->GetAXTreeID(); - out_data->AddIntAttribute(ui::AX_ATTR_CHILD_TREE_ID, ax_tree_id); + out_data->AddIntAttribute(ax::mojom::IntAttribute::kChildTreeId, + ax_tree_id); } - } else if (out_data->role == ui::AX_ROLE_WINDOW || - out_data->role == ui::AX_ROLE_DIALOG) { + } else if (out_data->role == ax::mojom::Role::kWindow || + out_data->role == ax::mojom::Role::kDialog) { // Add clips children flag by default to these roles. - out_data->AddBoolAttribute(ui::AX_ATTR_CLIPS_CHILDREN, true); + out_data->AddBoolAttribute(ax::mojom::BoolAttribute::kClipsChildren, true); } } diff --git a/chrome/browser/ui/autofill/autofill_popup_controller_impl.h b/chrome/browser/ui/autofill/autofill_popup_controller_impl.h index bedbca43c13ee6..106e35cf61bbd0 100644 --- a/chrome/browser/ui/autofill/autofill_popup_controller_impl.h +++ b/chrome/browser/ui/autofill/autofill_popup_controller_impl.h @@ -16,7 +16,7 @@ #include "chrome/browser/ui/autofill/autofill_popup_controller.h" #include "chrome/browser/ui/autofill/autofill_popup_layout_model.h" #include "chrome/browser/ui/autofill/popup_controller_common.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect_f.h" #include "ui/native_theme/native_theme.h" diff --git a/chrome/browser/ui/views/autofill/autofill_popup_view_native_views.cc b/chrome/browser/ui/views/autofill/autofill_popup_view_native_views.cc index bad2b32b90bc37..e05a858862b09a 100644 --- a/chrome/browser/ui/views/autofill/autofill_popup_view_native_views.cc +++ b/chrome/browser/ui/views/autofill/autofill_popup_view_native_views.cc @@ -61,7 +61,7 @@ class AutofillPopupChildView : public views::View { private: // views::Views implementation void GetAccessibleNodeData(ui::AXNodeData* node_data) override { - node_data->role = ui::AX_ROLE_MENU_ITEM; + node_data->role = ax::mojom::Role::kMenuItem; node_data->SetName(controller_->GetSuggestionAt(line_number_).value); } diff --git a/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc b/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc index 61c2c0f90ebefc..8bf5772c744550 100644 --- a/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc +++ b/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc @@ -44,7 +44,7 @@ class AutofillPopupChildView : public views::View { // views::Views implementation void GetAccessibleNodeData(ui::AXNodeData* node_data) override { - node_data->role = ui::AX_ROLE_MENU_ITEM; + node_data->role = ax::mojom::Role::kMenuItem; node_data->SetName(suggestion_.value); } @@ -68,14 +68,14 @@ AutofillPopupViewViews::~AutofillPopupViewViews() {} void AutofillPopupViewViews::Show() { DoShow(); - NotifyAccessibilityEvent(ui::AX_EVENT_MENU_START, true); + NotifyAccessibilityEvent(ax::mojom::Event::kMenuStart, true); } void AutofillPopupViewViews::Hide() { // The controller is no longer valid after it hides us. controller_ = NULL; DoHide(); - NotifyAccessibilityEvent(ui::AX_EVENT_MENU_END, true); + NotifyAccessibilityEvent(ax::mojom::Event::kMenuEnd, true); } void AutofillPopupViewViews::OnSuggestionsChanged() { @@ -119,7 +119,7 @@ void AutofillPopupViewViews::OnSelectedRowChanged( if (current_row_selection) { DCHECK_LT(*current_row_selection, child_count()); child_at(*current_row_selection) - ->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); + ->NotifyAccessibilityEvent(ax::mojom::Event::kSelection, true); } } @@ -243,7 +243,7 @@ void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas, } void AutofillPopupViewViews::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_MENU; + node_data->role = ax::mojom::Role::kMenu; node_data->SetName( l10n_util::GetStringUTF16(IDS_AUTOFILL_POPUP_ACCESSIBLE_NODE_DATA)); } diff --git a/chrome/browser/ui/views/autofill/password_generation_popup_view_views.cc b/chrome/browser/ui/views/autofill/password_generation_popup_view_views.cc index fb2a97701199bb..4c549568579bf7 100644 --- a/chrome/browser/ui/views/autofill/password_generation_popup_view_views.cc +++ b/chrome/browser/ui/views/autofill/password_generation_popup_view_views.cc @@ -202,7 +202,7 @@ void PasswordGenerationPopupViewViews::PasswordSelectionUpdated() { return; if (controller_->password_selected()) - NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); + NotifyAccessibilityEvent(ax::mojom::Event::kSelection, true); password_view_->SetBackground(views::CreateThemedSolidBackground( password_view_, @@ -276,7 +276,7 @@ PasswordGenerationPopupView* PasswordGenerationPopupView::Create( void PasswordGenerationPopupViewViews::GetAccessibleNodeData( ui::AXNodeData* node_data) { node_data->SetName(controller_->SuggestedText()); - node_data->role = ui::AX_ROLE_MENU_ITEM; + node_data->role = ax::mojom::Role::kMenuItem; } } // namespace autofill diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc index 5e391fc11eaa0a..c3a62bb947f50a 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc @@ -572,7 +572,7 @@ class BookmarkBarView::ButtonSeparatorView : public views::View { void GetAccessibleNodeData(ui::AXNodeData* node_data) override { node_data->SetName(l10n_util::GetStringUTF8(IDS_ACCNAME_SEPARATOR)); - node_data->role = ui::AX_ROLE_SPLITTER; + node_data->role = ax::mojom::Role::kSplitter; } private: @@ -1221,7 +1221,7 @@ void BookmarkBarView::VisibilityChanged(View* starting_from, bool is_visible) { } void BookmarkBarView::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_ACCNAME_BOOKMARKS)); } diff --git a/chrome/browser/ui/views/chrome_views_delegate.cc b/chrome/browser/ui/views/chrome_views_delegate.cc index 2fd1925536feb3..476e0e66dfa916 100644 --- a/chrome/browser/ui/views/chrome_views_delegate.cc +++ b/chrome/browser/ui/views/chrome_views_delegate.cc @@ -125,7 +125,8 @@ bool ChromeViewsDelegate::GetSavedWindowPlacement( } void ChromeViewsDelegate::NotifyAccessibilityEvent( - views::View* view, ui::AXEvent event_type) { + views::View* view, + ax::mojom::Event event_type) { #if defined(USE_AURA) AutomationManagerAura::GetInstance()->HandleEvent( GetProfileForWindow(view->GetWidget()), view, event_type); diff --git a/chrome/browser/ui/views/chrome_views_delegate.h b/chrome/browser/ui/views/chrome_views_delegate.h index ae9d5a0914ffaf..7e6d5fcca1df5f 100644 --- a/chrome/browser/ui/views/chrome_views_delegate.h +++ b/chrome/browser/ui/views/chrome_views_delegate.h @@ -10,7 +10,7 @@ #include "base/location.h" #include "base/macros.h" #include "build/build_config.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/views/views_delegate.h" class ScopedKeepAlive; @@ -30,7 +30,7 @@ class ChromeViewsDelegate : public views::ViewsDelegate { gfx::Rect* bounds, ui::WindowShowState* show_state) const override; void NotifyAccessibilityEvent(views::View* view, - ui::AXEvent event_type) override; + ax::mojom::Event event_type) override; #if defined(OS_CHROMEOS) ProcessMenuAcceleratorResult ProcessAcceleratorWhileMenuShowing( const ui::Accelerator& accelerator) override; diff --git a/chrome/browser/ui/views/conflicting_module_view_win.cc b/chrome/browser/ui/views/conflicting_module_view_win.cc index 292f26e1ebf447..97f2327e6b7517 100644 --- a/chrome/browser/ui/views/conflicting_module_view_win.cc +++ b/chrome/browser/ui/views/conflicting_module_view_win.cc @@ -106,8 +106,8 @@ void ConflictingModuleView::ShowBubble() { bubble_shown.SetValue(bubble_shown.GetValue() + 1); } -ui::AXRole ConflictingModuleView::GetAccessibleWindowRole() const { - return ui::AX_ROLE_ALERT_DIALOG; +ax::mojom::Role ConflictingModuleView::GetAccessibleWindowRole() const { + return ax::mojom::Role::kAlertDialog; } void ConflictingModuleView::OnWidgetClosing(views::Widget* widget) { diff --git a/chrome/browser/ui/views/conflicting_module_view_win.h b/chrome/browser/ui/views/conflicting_module_view_win.h index c6f744130db954..06dd735d9b555e 100644 --- a/chrome/browser/ui/views/conflicting_module_view_win.h +++ b/chrome/browser/ui/views/conflicting_module_view_win.h @@ -33,7 +33,7 @@ class ConflictingModuleView : public views::BubbleDialogDelegateView, void ShowBubble(); // views::BubbleDialogDelegateView: - ui::AXRole GetAccessibleWindowRole() const override; + ax::mojom::Role GetAccessibleWindowRole() const override; void OnWidgetClosing(views::Widget* widget) override; bool Accept() override; base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; diff --git a/chrome/browser/ui/views/critical_notification_bubble_view.cc b/chrome/browser/ui/views/critical_notification_bubble_view.cc index 0fc2b8f0e14a2b..14c57189b027d8 100644 --- a/chrome/browser/ui/views/critical_notification_bubble_view.cc +++ b/chrome/browser/ui/views/critical_notification_bubble_view.cc @@ -139,11 +139,11 @@ void CriticalNotificationBubbleView::Init() { void CriticalNotificationBubbleView::GetAccessibleNodeData( ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_ALERT; + node_data->role = ax::mojom::Role::kAlert; } void CriticalNotificationBubbleView::ViewHierarchyChanged( const ViewHierarchyChangedDetails& details) { if (details.is_add && details.child == this) - NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); + NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true); } diff --git a/chrome/browser/ui/views/desktop_capture/desktop_media_list_view.cc b/chrome/browser/ui/views/desktop_capture/desktop_media_list_view.cc index 00e7121b241f01..837e7690b760f4 100644 --- a/chrome/browser/ui/views/desktop_capture/desktop_media_list_view.cc +++ b/chrome/browser/ui/views/desktop_capture/desktop_media_list_view.cc @@ -277,6 +277,6 @@ DesktopMediaSourceView* DesktopMediaListView::GetChild(int index) { } void DesktopMediaListView::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_GROUP; + node_data->role = ax::mojom::Role::kGroup; node_data->SetName(accessible_name_); } diff --git a/chrome/browser/ui/views/desktop_capture/desktop_media_source_view.cc b/chrome/browser/ui/views/desktop_capture/desktop_media_source_view.cc index 2bbb08af52e041..705715f375af3f 100644 --- a/chrome/browser/ui/views/desktop_capture/desktop_media_source_view.cc +++ b/chrome/browser/ui/views/desktop_capture/desktop_media_source_view.cc @@ -200,6 +200,6 @@ void DesktopMediaSourceView::OnGestureEvent(ui::GestureEvent* event) { } void DesktopMediaSourceView::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_BUTTON; + node_data->role = ax::mojom::Role::kButton; node_data->SetName(label_->text()); } diff --git a/chrome/browser/ui/views/download/download_item_view.cc b/chrome/browser/ui/views/download/download_item_view.cc index 13d843f2eb693e..f12fe378f4e07c 100644 --- a/chrome/browser/ui/views/download/download_item_view.cc +++ b/chrome/browser/ui/views/download/download_item_view.cc @@ -492,11 +492,11 @@ bool DownloadItemView::GetTooltipText(const gfx::Point& p, void DownloadItemView::GetAccessibleNodeData(ui::AXNodeData* node_data) { node_data->SetName(accessible_name_); - node_data->role = ui::AX_ROLE_BUTTON; + node_data->role = ax::mojom::Role::kButton; if (model_.IsDangerous()) { - node_data->SetRestriction(ui::AX_RESTRICTION_DISABLED); + node_data->SetRestriction(ax::mojom::Restriction::kDisabled); } else { - node_data->AddState(ui::AX_STATE_HASPOPUP); + node_data->AddState(ax::mojom::State::kHaspopup); } } @@ -1119,7 +1119,7 @@ void DownloadItemView::UpdateAccessibleName() { // has changed so they can announce it immediately. if (new_name != accessible_name_) { accessible_name_ = new_name; - NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_CHANGED, true); + NotifyAccessibilityEvent(ax::mojom::Event::kTextChanged, true); } } diff --git a/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc b/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc index 58f28cc04814e3..2f7712d4f2a936 100644 --- a/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc +++ b/chrome/browser/ui/views/extensions/extension_install_dialog_view.cc @@ -65,7 +65,7 @@ class RatingsView : public views::View { ~RatingsView() override {} void GetAccessibleNodeData(ui::AXNodeData* node_data) override { - node_data->role = ui::AX_ROLE_STATIC_TEXT; + node_data->role = ax::mojom::Role::kStaticText; base::string16 accessible_text; if (rating_count_ == 0) { accessible_text = l10n_util::GetStringUTF16( @@ -95,7 +95,7 @@ class RatingStar : public views::ImageView { // views::ImageView: void GetAccessibleNodeData(ui::AXNodeData* node_data) override { - node_data->role = ui::AX_ROLE_IGNORED; + node_data->role = ax::mojom::Role::kIgnored; } private: @@ -112,7 +112,7 @@ class RatingLabel : public views::Label { // views::Label: void GetAccessibleNodeData(ui::AXNodeData* node_data) override { - node_data->role = ui::AX_ROLE_IGNORED; + node_data->role = ax::mojom::Role::kIgnored; } private: diff --git a/chrome/browser/ui/views/extensions/extension_install_dialog_view_browsertest.cc b/chrome/browser/ui/views/extensions/extension_install_dialog_view_browsertest.cc index 1506550167d565..8f96a0be20a856 100644 --- a/chrome/browser/ui/views/extensions/extension_install_dialog_view_browsertest.cc +++ b/chrome/browser/ui/views/extensions/extension_install_dialog_view_browsertest.cc @@ -428,15 +428,16 @@ void ExtensionInstallDialogRatingsSectionTest::TestRatingsSectionA11y( { ui::AXNodeData node_data; rating_view->GetAccessibleNodeData(&node_data); - EXPECT_EQ(ui::AX_ROLE_STATIC_TEXT, node_data.role); - EXPECT_EQ(expected_text, node_data.GetStringAttribute(ui::AX_ATTR_NAME)); + EXPECT_EQ(ax::mojom::Role::kStaticText, node_data.role); + EXPECT_EQ(expected_text, + node_data.GetStringAttribute(ax::mojom::StringAttribute::kName)); } for (int i = 0; i < rating_view->child_count(); ++i) { views::View* child = rating_view->child_at(i); ui::AXNodeData node_data; child->GetAccessibleNodeData(&node_data); - EXPECT_EQ(ui::AX_ROLE_IGNORED, node_data.role); + EXPECT_EQ(ax::mojom::Role::kIgnored, node_data.role); } modal_dialog->Close(); diff --git a/chrome/browser/ui/views/extensions/extension_message_bubble_view_browsertest.cc b/chrome/browser/ui/views/extensions/extension_message_bubble_view_browsertest.cc index ba242786bb2d7f..9193fdabf5a3ae 100644 --- a/chrome/browser/ui/views/extensions/extension_message_bubble_view_browsertest.cc +++ b/chrome/browser/ui/views/extensions/extension_message_bubble_view_browsertest.cc @@ -130,7 +130,7 @@ void ExtensionMessageBubbleViewBrowserTest::ClickLearnMoreButton( // to report a valid state. ui::AXNodeData node_data; bubble->GetWidget()->GetRootView()->GetAccessibleNodeData(&node_data); - EXPECT_EQ(ui::AX_ROLE_DIALOG, node_data.role); + EXPECT_EQ(ax::mojom::Role::kDialog, node_data.role); } void ExtensionMessageBubbleViewBrowserTest::ClickActionButton( diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc index f24d730a71f101..697abbb2617c01 100644 --- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc +++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.cc @@ -323,7 +323,7 @@ const char* BrowserNonClientFrameViewAsh::GetClassName() const { void BrowserNonClientFrameViewAsh::GetAccessibleNodeData( ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_TITLE_BAR; + node_data->role = ax::mojom::Role::kTitleBar; } gfx::Size BrowserNonClientFrameViewAsh::GetMinimumSize() const { diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view_mus.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view_mus.cc index 05fb9ef62e1e3b..a3456f2351641d 100644 --- a/chrome/browser/ui/views/frame/browser_non_client_frame_view_mus.cc +++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view_mus.cc @@ -329,7 +329,7 @@ const char* BrowserNonClientFrameViewMus::GetClassName() const { void BrowserNonClientFrameViewMus::GetAccessibleNodeData( ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_TITLE_BAR; + node_data->role = ax::mojom::Role::kTitleBar; } gfx::Size BrowserNonClientFrameViewMus::GetMinimumSize() const { diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index e0f5351f323524..4f2019f875ad8c 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -1985,7 +1985,7 @@ void BrowserView::ChildPreferredSizeChanged(View* child) { } void BrowserView::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_CLIENT; + node_data->role = ax::mojom::Role::kClient; } void BrowserView::OnThemeChanged() { diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc index d5d0c13b80a2c7..962d75c35f000a 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc @@ -293,7 +293,7 @@ void OpaqueBrowserFrameView::ActivationChanged(bool active) { // OpaqueBrowserFrameView, views::View overrides: void OpaqueBrowserFrameView::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_TITLE_BAR; + node_data->role = ax::mojom::Role::kTitleBar; } void OpaqueBrowserFrameView::OnNativeThemeChanged( diff --git a/chrome/browser/ui/views/hover_button_unittest.cc b/chrome/browser/ui/views/hover_button_unittest.cc index 32aa8f652677fe..5851b003906022 100644 --- a/chrome/browser/ui/views/hover_button_unittest.cc +++ b/chrome/browser/ui/views/hover_button_unittest.cc @@ -99,7 +99,8 @@ TEST_F(HoverButtonTest, TooltipAndAccessibleName) { ui::AXNodeData data; button->GetAccessibleNodeData(&data); std::string accessible_name; - data.GetStringAttribute(ui::AX_ATTR_NAME, &accessible_name); + data.GetStringAttribute(ax::mojom::StringAttribute::kName, + &accessible_name); // The accessible name should always be the title and subtitle concatenated // by \n. @@ -141,7 +142,8 @@ TEST_F(HoverButtonTest, CustomTooltip) { ui::AXNodeData data; button->GetAccessibleNodeData(&data); std::string accessible_name; - data.GetStringAttribute(ui::AX_ATTR_NAME, &accessible_name); + data.GetStringAttribute(ax::mojom::StringAttribute::kName, + &accessible_name); // The accessible name should always be the title and subtitle concatenated // by \n. diff --git a/chrome/browser/ui/views/infobars/infobar_container_view.cc b/chrome/browser/ui/views/infobars/infobar_container_view.cc index 0005ff21f12ea7..8f934265174f13 100644 --- a/chrome/browser/ui/views/infobars/infobar_container_view.cc +++ b/chrome/browser/ui/views/infobars/infobar_container_view.cc @@ -118,7 +118,7 @@ void InfoBarContainerView::Layout() { } void InfoBarContainerView::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_GROUP; + node_data->role = ax::mojom::Role::kGroup; node_data->SetName(l10n_util::GetStringUTF8(IDS_ACCNAME_INFOBAR_CONTAINER)); } diff --git a/chrome/browser/ui/views/infobars/infobar_view.cc b/chrome/browser/ui/views/infobars/infobar_view.cc index f96505947292fb..507510d1759e7e 100644 --- a/chrome/browser/ui/views/infobars/infobar_view.cc +++ b/chrome/browser/ui/views/infobars/infobar_view.cc @@ -271,7 +271,7 @@ void InfoBarView::PlatformSpecificShow(bool animate) { // that if we gain focus we'll know what the previously-focused element was. SetFocusManager(GetFocusManager()); - NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); + NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true); } void InfoBarView::PlatformSpecificHide(bool animate) { @@ -303,8 +303,9 @@ void InfoBarView::PlatformSpecificOnHeightsRecalculated() { void InfoBarView::GetAccessibleNodeData(ui::AXNodeData* node_data) { node_data->SetName(l10n_util::GetStringUTF8(IDS_ACCNAME_INFOBAR)); - node_data->role = ui::AX_ROLE_ALERT; - node_data->AddStringAttribute(ui::AX_ATTR_KEY_SHORTCUTS, "Alt+Shift+A"); + node_data->role = ax::mojom::Role::kAlert; + node_data->AddStringAttribute(ax::mojom::StringAttribute::kKeyShortcuts, + "Alt+Shift+A"); } gfx::Size InfoBarView::CalculatePreferredSize() const { @@ -330,7 +331,7 @@ void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) { // infobar. if (focused_before && focused_now && !Contains(focused_before) && Contains(focused_now)) { - NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); + NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true); } } diff --git a/chrome/browser/ui/views/location_bar/bubble_icon_view.cc b/chrome/browser/ui/views/location_bar/bubble_icon_view.cc index bb25e5ec169d84..c7612c22bb444b 100644 --- a/chrome/browser/ui/views/location_bar/bubble_icon_view.cc +++ b/chrome/browser/ui/views/location_bar/bubble_icon_view.cc @@ -62,7 +62,7 @@ void BubbleIconView::OnBubbleCreated(LocationBarBubbleDelegateView* bubble) { void BubbleIconView::GetAccessibleNodeData(ui::AXNodeData* node_data) { image_->GetAccessibleNodeData(node_data); - node_data->role = ui::AX_ROLE_BUTTON; + node_data->role = ax::mojom::Role::kButton; } bool BubbleIconView::GetTooltipText(const gfx::Point& p, diff --git a/chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.cc b/chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.cc index 64d838a2d21654..038220ce20f1bc 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.cc +++ b/chrome/browser/ui/views/location_bar/location_bar_bubble_delegate_view.cc @@ -102,7 +102,7 @@ void LocationBarBubbleDelegateView::ShowForReason(DisplayReason reason) { GetWidget()->GetRootView()->GetViewAccessibility().OverrideDescription( l10n_util::GetStringUTF8(IDS_SHOW_BUBBLE_INACTIVE_DESCRIPTION)); } - GetWidget()->GetRootView()->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, + GetWidget()->GetRootView()->NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true); } diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc index be8afdf0c143fa..7689bce5d71659 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc @@ -427,7 +427,7 @@ bool LocationBarView::HasFocus() const { } void LocationBarView::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_GROUP; + node_data->role = ax::mojom::Role::kGroup; } gfx::Size LocationBarView::CalculatePreferredSize() const { diff --git a/chrome/browser/ui/views/location_bar/location_icon_view.cc b/chrome/browser/ui/views/location_bar/location_icon_view.cc index fb2fa9ead08429..3dea10a31ad356 100644 --- a/chrome/browser/ui/views/location_bar/location_icon_view.cc +++ b/chrome/browser/ui/views/location_bar/location_icon_view.cc @@ -74,12 +74,12 @@ bool LocationIconView::ShowBubble(const ui::Event& event) { void LocationIconView::GetAccessibleNodeData(ui::AXNodeData* node_data) { if (location_bar_->GetOmniboxView()->IsEditingOrEmpty()) { - node_data->role = ui::AX_ROLE_NONE; + node_data->role = ax::mojom::Role::kNone; return; } IconLabelBubbleView::GetAccessibleNodeData(node_data); - node_data->role = ui::AX_ROLE_POP_UP_BUTTON; + node_data->role = ax::mojom::Role::kPopUpButton; } bool LocationIconView::IsBubbleShowing() const { diff --git a/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc b/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc index 2cd43df4b0fba5..be613ca71c3242 100644 --- a/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc +++ b/chrome/browser/ui/views/location_bar/zoom_bubble_view.cc @@ -465,7 +465,7 @@ void ZoomBubbleView::SetExtensionInfo(const extensions::Extension* extension) { void ZoomBubbleView::UpdateZoomPercent() { label_->SetText(base::FormatPercent( zoom::ZoomController::FromWebContents(web_contents())->GetZoomPercent())); - label_->NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_CHANGED, true); + label_->NotifyAccessibilityEvent(ax::mojom::Event::kTextChanged, true); } void ZoomBubbleView::UpdateZoomIconVisibility() { diff --git a/chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.cc b/chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.cc index f8ba00c597356c..5e29e4a3dfd3e5 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.cc @@ -185,7 +185,7 @@ void OmniboxPopupContentsView::UpdatePopupAppearance() { // No matches or the IME is showing a popup window which may overlap // the omnibox popup window. Close any existing popup. if (popup_) { - NotifyAccessibilityEvent(ui::AX_EVENT_EXPANDED_CHANGED, true); + NotifyAccessibilityEvent(ax::mojom::Event::kExpandedChanged, true); size_animation_.Stop(); // NOTE: Do NOT use CloseNow() here, as we may be deep in a callstack @@ -297,9 +297,10 @@ void OmniboxPopupContentsView::UpdatePopupAppearance() { popup_->ShowInactive(); // Popup is now expanded and first item will be selected. - NotifyAccessibilityEvent(ui::AX_EVENT_EXPANDED_CHANGED, true); + NotifyAccessibilityEvent(ax::mojom::Event::kExpandedChanged, true); if (result_view_at(0)) - result_view_at(0)->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); + result_view_at(0)->NotifyAccessibilityEvent(ax::mojom::Event::kSelection, + true); } else { // Animate the popup shrinking, but don't animate growing larger since that // would make the popup feel less responsive. @@ -459,12 +460,12 @@ OmniboxResultView* OmniboxPopupContentsView::result_view_at(size_t i) { void OmniboxPopupContentsView::GetAccessibleNodeData( ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_LIST_BOX; + node_data->role = ax::mojom::Role::kListBox; if (IsOpen()) { - node_data->AddState(ui::AX_STATE_EXPANDED); + node_data->AddState(ax::mojom::State::kExpanded); } else { - node_data->AddState(ui::AX_STATE_COLLAPSED); - node_data->AddState(ui::AX_STATE_INVISIBLE); + node_data->AddState(ax::mojom::State::kCollapsed); + node_data->AddState(ax::mojom::State::kInvisible); } } diff --git a/chrome/browser/ui/views/omnibox/omnibox_result_view.cc b/chrome/browser/ui/views/omnibox/omnibox_result_view.cc index a298a01b39817f..8ee071c361fc77 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_result_view.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_result_view.cc @@ -305,7 +305,7 @@ void OmniboxResultView::OnSelected() { // The text is also accessible via text/value change events in the omnibox but // this selection event allows the screen reader to get more details about the // list and the user's position within it. - NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); + NotifyAccessibilityEvent(ax::mojom::Event::kSelection, true); } OmniboxResultView::ResultViewState OmniboxResultView::GetState() const { @@ -372,22 +372,25 @@ void OmniboxResultView::OnMouseExited(const ui::MouseEvent& event) { void OmniboxResultView::GetAccessibleNodeData(ui::AXNodeData* node_data) { // Get the label without the ", n of m" positional text appended. - // The positional info is provided via AX_ATTR_POS_IN_SET/SET_SIZE - // and providing it via text as well would result in duplicate announcements. + // The positional info is provided via + // ax::mojom::IntAttribute::kPosInSet/SET_SIZE and providing it via text as + // well would result in duplicate announcements. node_data->SetName( AutocompleteMatchType::ToAccessibilityLabel(match_, match_.contents)); - node_data->role = ui::AX_ROLE_LIST_BOX_OPTION; - node_data->AddIntAttribute(ui::AX_ATTR_POS_IN_SET, model_index_ + 1); - node_data->AddIntAttribute(ui::AX_ATTR_SET_SIZE, model_->child_count()); + node_data->role = ax::mojom::Role::kListBoxOption; + node_data->AddIntAttribute(ax::mojom::IntAttribute::kPosInSet, + model_index_ + 1); + node_data->AddIntAttribute(ax::mojom::IntAttribute::kSetSize, + model_->child_count()); - node_data->AddState(ui::AX_STATE_SELECTABLE); + node_data->AddState(ax::mojom::State::kSelectable); switch (GetState()) { case SELECTED: - node_data->AddState(ui::AX_STATE_SELECTED); + node_data->AddState(ax::mojom::State::kSelected); break; case HOVERED: - node_data->AddState(ui::AX_STATE_HOVERED); + node_data->AddState(ax::mojom::State::kHovered); break; default: break; diff --git a/chrome/browser/ui/views/omnibox/omnibox_result_view_unittest.cc b/chrome/browser/ui/views/omnibox/omnibox_result_view_unittest.cc index 957eae431cda98..d864b79d18d82d 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_result_view_unittest.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_result_view_unittest.cc @@ -215,27 +215,29 @@ TEST_F(OmniboxResultViewTest, AccessibleNodeData) { result_view()->SetMatch(match); ui::AXNodeData result_node_data; result_view()->GetAccessibleNodeData(&result_node_data); - EXPECT_TRUE(result_node_data.HasState(ui::AX_STATE_SELECTABLE)); - EXPECT_FALSE(result_node_data.HasState(ui::AX_STATE_SELECTED)); - EXPECT_EQ(result_node_data.role, ui::AX_ROLE_LIST_BOX_OPTION); + EXPECT_TRUE(result_node_data.HasState(ax::mojom::State::kSelectable)); + EXPECT_FALSE(result_node_data.HasState(ax::mojom::State::kSelected)); + EXPECT_EQ(result_node_data.role, ax::mojom::Role::kListBoxOption); EXPECT_EQ( - result_node_data.GetString16Attribute(ui::AX_ATTR_NAME), + result_node_data.GetString16Attribute(ax::mojom::StringAttribute::kName), base::ASCIIToUTF16("Google https://google.com location from history")); - EXPECT_EQ(result_node_data.GetIntAttribute(ui::AX_ATTR_POS_IN_SET), - kTestResultViewIndex + 1); - EXPECT_EQ(result_node_data.GetIntAttribute(ui::AX_ATTR_SET_SIZE), 6); + EXPECT_EQ( + result_node_data.GetIntAttribute(ax::mojom::IntAttribute::kPosInSet), + kTestResultViewIndex + 1); + EXPECT_EQ(result_node_data.GetIntAttribute(ax::mojom::IntAttribute::kSetSize), + 6); // Select it and check selected state. result_view()->OnMousePressed( CreateEvent(ui::ET_MOUSE_PRESSED, ui::EF_LEFT_MOUSE_BUTTON)); result_view()->GetAccessibleNodeData(&result_node_data); - EXPECT_TRUE(result_node_data.HasState(ui::AX_STATE_SELECTED)); + EXPECT_TRUE(result_node_data.HasState(ax::mojom::State::kSelected)); // Check accessibility of list box. ui::AXNodeData popup_node_data; popup_view()->GetAccessibleNodeData(&popup_node_data); - EXPECT_EQ(popup_node_data.role, ui::AX_ROLE_LIST_BOX); - EXPECT_FALSE(popup_node_data.HasState(ui::AX_STATE_EXPANDED)); - EXPECT_TRUE(popup_node_data.HasState(ui::AX_STATE_COLLAPSED)); - EXPECT_TRUE(popup_node_data.HasState(ui::AX_STATE_INVISIBLE)); + EXPECT_EQ(popup_node_data.role, ax::mojom::Role::kListBox); + EXPECT_FALSE(popup_node_data.HasState(ax::mojom::State::kExpanded)); + EXPECT_TRUE(popup_node_data.HasState(ax::mojom::State::kCollapsed)); + EXPECT_TRUE(popup_node_data.HasState(ax::mojom::State::kInvisible)); } diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc index 9cafcf6624b965..ee25f8bd91299e 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc @@ -735,16 +735,18 @@ bool OmniboxViewViews::SkipDefaultKeyEventProcessing( } void OmniboxViewViews::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_TEXT_FIELD; + node_data->role = ax::mojom::Role::kTextField; node_data->SetName(l10n_util::GetStringUTF8(IDS_ACCNAME_LOCATION)); - node_data->AddStringAttribute(ui::AX_ATTR_AUTO_COMPLETE, "both"); + node_data->AddStringAttribute(ax::mojom::StringAttribute::kAutoComplete, + "both"); // Expose keyboard shortcut where it makes sense. #if defined(OS_MACOSX) // Use cloverleaf symbol for command key. - node_data->AddStringAttribute(ui::AX_ATTR_KEY_SHORTCUTS, + node_data->AddStringAttribute(ax::mojom::StringAttribute::kKeyShortcuts, base::WideToUTF8(L"\u2318L")); #else - node_data->AddStringAttribute(ui::AX_ATTR_KEY_SHORTCUTS, "Ctrl+L"); + node_data->AddStringAttribute(ax::mojom::StringAttribute::kKeyShortcuts, + "Ctrl+L"); #endif if (friendly_suggestion_text_.empty()) { // While user edits text, use the exact text displayed in the omnibox. @@ -768,7 +770,8 @@ void OmniboxViewViews::GetAccessibleNodeData(ui::AXNodeData* node_data) { // the omnibox. int32_t popup_view_id = popup_view_->GetViewAccessibility().GetUniqueId().Get(); - node_data->AddIntListAttribute(ui::AX_ATTR_CONTROLS_IDS, {popup_view_id}); + node_data->AddIntListAttribute(ax::mojom::IntListAttribute::kControlsIds, + {popup_view_id}); base::string16::size_type entry_start; base::string16::size_type entry_end; @@ -781,16 +784,16 @@ void OmniboxViewViews::GetAccessibleNodeData(ui::AXNodeData* node_data) { GetSelectionBounds(&entry_start, &entry_end); } node_data->AddIntAttribute( - ui::AX_ATTR_TEXT_SEL_START, + ax::mojom::IntAttribute::kTextSelStart, entry_start + friendly_suggestion_text_prefix_length_); node_data->AddIntAttribute( - ui::AX_ATTR_TEXT_SEL_END, + ax::mojom::IntAttribute::kTextSelEnd, entry_end + friendly_suggestion_text_prefix_length_); if (popup_window_mode_) { - node_data->SetRestriction(ui::AX_RESTRICTION_READ_ONLY); + node_data->SetRestriction(ax::mojom::Restriction::kReadOnly); } else { - node_data->AddState(ui::AX_STATE_EDITABLE); + node_data->AddState(ax::mojom::State::kEditable); } } @@ -799,10 +802,10 @@ bool OmniboxViewViews::HandleAccessibleAction( if (read_only()) return Textfield::HandleAccessibleAction(action_data); - if (action_data.action == ui::AX_ACTION_SET_VALUE) { + if (action_data.action == ax::mojom::Action::kSetValue) { SetUserText(action_data.value, true); return true; - } else if (action_data.action == ui::AX_ACTION_REPLACE_SELECTED_TEXT) { + } else if (action_data.action == ax::mojom::Action::kReplaceSelectedText) { model()->SetInputInProgress(true); if (saved_selection_for_focus_change_.IsValid()) { SelectRange(saved_selection_for_focus_change_); @@ -811,10 +814,10 @@ bool OmniboxViewViews::HandleAccessibleAction( InsertOrReplaceText(action_data.value); TextChanged(); return true; - } else if (action_data.action == ui::AX_ACTION_SET_SELECTION) { + } else if (action_data.action == ax::mojom::Action::kSetSelection) { // Adjust for friendly text inserted at the start of the url. ui::AXActionData set_selection_action_data; - set_selection_action_data.action = ui::AX_ACTION_SET_SELECTION; + set_selection_action_data.action = ax::mojom::Action::kSetSelection; set_selection_action_data.anchor_node_id = action_data.anchor_node_id; set_selection_action_data.focus_offset = action_data.focus_offset - friendly_suggestion_text_prefix_length_; diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc index 6c33b7d2ae154c..bac2effe68e0eb 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views_browsertest.cc @@ -541,21 +541,22 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, FriendlyAccessibleLabel) { omnibox_view_views->GetAccessibleNodeData(&node_data); EXPECT_EQ(base::ASCIIToUTF16( "Google https://google.com location from history, 1 of 1"), - node_data.GetString16Attribute(ui::AX_ATTR_VALUE)); + node_data.GetString16Attribute(ax::mojom::StringAttribute::kValue)); // Selection offsets are moved over by length the inserted descriptive text // prefix ("Google") + 1 for the space. EXPECT_EQ(kFriendlyPrefixLength, - node_data.GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END)); + node_data.GetIntAttribute(ax::mojom::IntAttribute::kTextSelEnd)); EXPECT_EQ(kFriendlyPrefixLength + static_cast(match_url.size()), - node_data.GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START)); - EXPECT_EQ("both", node_data.GetStringAttribute(ui::AX_ATTR_AUTO_COMPLETE)); - EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, node_data.role); + node_data.GetIntAttribute(ax::mojom::IntAttribute::kTextSelStart)); + EXPECT_EQ("both", node_data.GetStringAttribute( + ax::mojom::StringAttribute::kAutoComplete)); + EXPECT_EQ(ax::mojom::Role::kTextField, node_data.role); // Select second character -- even though the friendly "Google " prefix is // part of the exposed accessible text, setting the selection within select // the intended part of the editable text. ui::AXActionData set_selection_action_data; - set_selection_action_data.action = ui::AX_ACTION_SET_SELECTION; + set_selection_action_data.action = ax::mojom::Action::kSetSelection; set_selection_action_data.anchor_node_id = node_data.id; set_selection_action_data.focus_offset = kFriendlyPrefixLength + 1; set_selection_action_data.anchor_offset = kFriendlyPrefixLength + 3; @@ -572,7 +573,7 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, FriendlyAccessibleLabel) { // edited text. omnibox_view_views->GetAccessibleNodeData(&node_data); EXPECT_EQ(base::ASCIIToUTF16("hxps://google.com"), - node_data.GetString16Attribute(ui::AX_ATTR_VALUE)); + node_data.GetString16Attribute(ax::mojom::StringAttribute::kValue)); } // Ensure that the Omnibox popup exposes appropriate accessibility semantics, @@ -597,9 +598,9 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, AccessiblePopup) { omnibox_view_views->GetPopupContentsView(); ui::AXNodeData popup_node_data_1; popup_view->GetAccessibleNodeData(&popup_node_data_1); - EXPECT_FALSE(popup_node_data_1.HasState(ui::AX_STATE_EXPANDED)); - EXPECT_TRUE(popup_node_data_1.HasState(ui::AX_STATE_COLLAPSED)); - EXPECT_TRUE(popup_node_data_1.HasState(ui::AX_STATE_INVISIBLE)); + EXPECT_FALSE(popup_node_data_1.HasState(ax::mojom::State::kExpanded)); + EXPECT_TRUE(popup_node_data_1.HasState(ax::mojom::State::kCollapsed)); + EXPECT_TRUE(popup_node_data_1.HasState(ax::mojom::State::kInvisible)); // Populate suggestions for the omnibox popup. AutocompleteController* autocomplete_controller = @@ -620,7 +621,7 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, AccessiblePopup) { EXPECT_TRUE(omnibox_view->model()->popup_model()->IsOpen()); ui::AXNodeData popup_node_data_2; popup_view->GetAccessibleNodeData(&popup_node_data_2); - EXPECT_TRUE(popup_node_data_2.HasState(ui::AX_STATE_EXPANDED)); - EXPECT_FALSE(popup_node_data_2.HasState(ui::AX_STATE_COLLAPSED)); - EXPECT_FALSE(popup_node_data_2.HasState(ui::AX_STATE_INVISIBLE)); + EXPECT_TRUE(popup_node_data_2.HasState(ax::mojom::State::kExpanded)); + EXPECT_FALSE(popup_node_data_2.HasState(ax::mojom::State::kCollapsed)); + EXPECT_FALSE(popup_node_data_2.HasState(ax::mojom::State::kInvisible)); } diff --git a/chrome/browser/ui/views/page_info/non_accessible_image_view.cc b/chrome/browser/ui/views/page_info/non_accessible_image_view.cc index 2a02fbff7de2aa..16bfd6504f77c8 100644 --- a/chrome/browser/ui/views/page_info/non_accessible_image_view.cc +++ b/chrome/browser/ui/views/page_info/non_accessible_image_view.cc @@ -4,9 +4,9 @@ #include "chrome/browser/ui/views/page_info/non_accessible_image_view.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_node_data.h" void NonAccessibleImageView::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->AddState(ui::AX_STATE_INVISIBLE); + node_data->AddState(ax::mojom::State::kInvisible); } diff --git a/chrome/browser/ui/views/page_info/page_info_bubble_view_browsertest.cc b/chrome/browser/ui/views/page_info/page_info_bubble_view_browsertest.cc index 3bf15151e72965..ea25a7e341d59b 100644 --- a/chrome/browser/ui/views/page_info/page_info_bubble_view_browsertest.cc +++ b/chrome/browser/ui/views/page_info/page_info_bubble_view_browsertest.cc @@ -48,7 +48,7 @@ class ClickEvent : public ui::Event { void PerformMouseClickOnView(views::View* view) { ui::AXActionData data; - data.action = ui::AX_ACTION_DO_DEFAULT; + data.action = ax::mojom::Action::kDoDefault; view->HandleAccessibleAction(data); } diff --git a/chrome/browser/ui/views/page_info/page_info_bubble_view_unittest.cc b/chrome/browser/ui/views/page_info/page_info_bubble_view_unittest.cc index 3c46ce1ff0761f..d6ce3bf341ce49 100644 --- a/chrome/browser/ui/views/page_info/page_info_bubble_view_unittest.cc +++ b/chrome/browser/ui/views/page_info/page_info_bubble_view_unittest.cc @@ -76,7 +76,7 @@ class PageInfoBubbleViewTestApi { ui::AXNodeData data; view_->cookie_button_->GetAccessibleNodeData(&data); std::string name; - data.GetStringAttribute(ui::AX_ATTR_NAME, &name); + data.GetStringAttribute(ax::mojom::StringAttribute::kName, &name); return base::ASCIIToUTF16(name); } EXPECT_TRUE(view_->cookie_link_legacy_); diff --git a/chrome/browser/ui/views/permission_bubble/permission_prompt_impl.cc b/chrome/browser/ui/views/permission_bubble/permission_prompt_impl.cc index f77678a5e684de..f29c47d2eea52a 100644 --- a/chrome/browser/ui/views/permission_bubble/permission_prompt_impl.cc +++ b/chrome/browser/ui/views/permission_bubble/permission_prompt_impl.cc @@ -74,7 +74,7 @@ class PermissionsBubbleDialogDelegateView void CloseBubble(); // BubbleDialogDelegateView: - ui::AXRole GetAccessibleWindowRole() const override; + ax::mojom::Role GetAccessibleWindowRole() const override; base::string16 GetAccessibleWindowTitle() const override; bool ShouldShowCloseButton() const override; base::string16 GetWindowTitle() const override; @@ -178,9 +178,9 @@ void PermissionsBubbleDialogDelegateView::AddedToWidget() { GetBubbleFrameView()->SetTitleView(std::move(title)); } -ui::AXRole PermissionsBubbleDialogDelegateView::GetAccessibleWindowRole() +ax::mojom::Role PermissionsBubbleDialogDelegateView::GetAccessibleWindowRole() const { - return ui::AX_ROLE_ALERT_DIALOG; + return ax::mojom::Role::kAlertDialog; } base::string16 PermissionsBubbleDialogDelegateView::GetAccessibleWindowTitle() diff --git a/chrome/browser/ui/views/tabs/tab.cc b/chrome/browser/ui/views/tabs/tab.cc index 236029e6121dfd..f9439b4f346f8f 100644 --- a/chrome/browser/ui/views/tabs/tab.cc +++ b/chrome/browser/ui/views/tabs/tab.cc @@ -771,12 +771,12 @@ void Tab::OnMouseExited(const ui::MouseEvent& event) { } void Tab::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_TAB; + node_data->role = ax::mojom::Role::kTab; node_data->SetName(controller_->GetAccessibleTabName(this)); - node_data->AddState(ui::AX_STATE_MULTISELECTABLE); - node_data->AddState(ui::AX_STATE_SELECTABLE); + node_data->AddState(ax::mojom::State::kMultiselectable); + node_data->AddState(ax::mojom::State::kSelectable); if (IsSelected()) - node_data->AddState(ui::AX_STATE_SELECTED); + node_data->AddState(ax::mojom::State::kSelected); } void Tab::OnGestureEvent(ui::GestureEvent* event) { diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc index ffa26591e9bad3..2e5fd2e1785dd5 100644 --- a/chrome/browser/ui/views/tabs/tab_strip.cc +++ b/chrome/browser/ui/views/tabs/tab_strip.cc @@ -676,14 +676,14 @@ void TabStrip::SetSelection(const ui::ListSelectionModel& old_selection, // Fire accessibility events that reflect the changes to selection. for (size_t i = 0; i < no_longer_selected.size(); ++i) { tab_at(no_longer_selected[i]) - ->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION_REMOVE, true); + ->NotifyAccessibilityEvent(ax::mojom::Event::kSelectionRemove, true); } for (size_t i = 0; i < newly_selected.size(); ++i) { tab_at(newly_selected[i]) - ->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION_ADD, true); + ->NotifyAccessibilityEvent(ax::mojom::Event::kSelectionAdd, true); } tab_at(new_selection.active()) - ->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); + ->NotifyAccessibilityEvent(ax::mojom::Event::kSelection, true); } void TabStrip::TabTitleChangedNotLoading(int model_index) { @@ -1269,7 +1269,7 @@ int TabStrip::OnPerformDrop(const DropTargetEvent& event) { } void TabStrip::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_TAB_LIST; + node_data->role = ax::mojom::Role::kTabList; } views::View* TabStrip::GetTooltipHandlerForPoint(const gfx::Point& point) { diff --git a/chrome/browser/ui/views/toolbar/app_menu.cc b/chrome/browser/ui/views/toolbar/app_menu.cc index 1348c81c9cce82..80e63e91473ded 100644 --- a/chrome/browser/ui/views/toolbar/app_menu.cc +++ b/chrome/browser/ui/views/toolbar/app_menu.cc @@ -126,7 +126,7 @@ class FullscreenButton : public ImageButton { void GetAccessibleNodeData(ui::AXNodeData* node_data) override { ImageButton::GetAccessibleNodeData(node_data); - node_data->role = ui::AX_ROLE_MENU_ITEM; + node_data->role = ax::mojom::Role::kMenuItem; } private: @@ -267,7 +267,7 @@ class InMenuButton : public LabelButton { void GetAccessibleNodeData(ui::AXNodeData* node_data) override { LabelButton::GetAccessibleNodeData(node_data); if (!role_is_button_) - node_data->role = ui::AX_ROLE_MENU_ITEM; + node_data->role = ax::mojom::Role::kMenuItem; } // views::LabelButton @@ -638,7 +638,7 @@ class AppMenu::ZoomView : public AppMenuView { contents->GetMinimumZoomPercent()); } zoom_label_->SetText(base::FormatPercent(zoom)); - zoom_label_->NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_CHANGED, true); + zoom_label_->NotifyAccessibilityEvent(ax::mojom::Event::kTextChanged, true); zoom_label_max_width_valid_ = false; } diff --git a/chrome/browser/ui/views/toolbar/browser_actions_container.cc b/chrome/browser/ui/views/toolbar/browser_actions_container.cc index 6b9212779c8bfa..990960effddfd5 100644 --- a/chrome/browser/ui/views/toolbar/browser_actions_container.cc +++ b/chrome/browser/ui/views/toolbar/browser_actions_container.cc @@ -497,7 +497,7 @@ int BrowserActionsContainer::OnPerformDrop( } void BrowserActionsContainer::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_GROUP; + node_data->role = ax::mojom::Role::kGroup; node_data->SetName(l10n_util::GetStringUTF8(IDS_ACCNAME_EXTENSIONS)); } diff --git a/chrome/browser/ui/views/toolbar/toolbar_action_view.cc b/chrome/browser/ui/views/toolbar/toolbar_action_view.cc index b6cb3dd2397fac..73ba44031135ac 100644 --- a/chrome/browser/ui/views/toolbar/toolbar_action_view.cc +++ b/chrome/browser/ui/views/toolbar/toolbar_action_view.cc @@ -78,7 +78,7 @@ ToolbarActionView::~ToolbarActionView() { void ToolbarActionView::GetAccessibleNodeData(ui::AXNodeData* node_data) { views::MenuButton::GetAccessibleNodeData(node_data); - node_data->role = ui::AX_ROLE_BUTTON; + node_data->role = ax::mojom::Role::kButton; } std::unique_ptr ToolbarActionView::CreateDefaultBorder() diff --git a/chrome/browser/ui/views/toolbar/toolbar_action_view_unittest.cc b/chrome/browser/ui/views/toolbar/toolbar_action_view_unittest.cc index f5f220a6c1145a..40ef70b0b1a582 100644 --- a/chrome/browser/ui/views/toolbar/toolbar_action_view_unittest.cc +++ b/chrome/browser/ui/views/toolbar/toolbar_action_view_unittest.cc @@ -220,7 +220,8 @@ TEST_F(ToolbarActionViewUnitTest, BasicToolbarActionViewTest) { EXPECT_EQ(tooltip, tooltip_test); ui::AXNodeData ax_node_data; view.GetAccessibleNodeData(&ax_node_data); - EXPECT_EQ(name, ax_node_data.GetString16Attribute(ui::AX_ATTR_NAME)); + EXPECT_EQ(name, ax_node_data.GetString16Attribute( + ax::mojom::StringAttribute::kName)); // The button should start in normal state, with no actions executed. EXPECT_EQ(views::Button::STATE_NORMAL, view.state()); diff --git a/chrome/browser/ui/views/toolbar/toolbar_button.cc b/chrome/browser/ui/views/toolbar/toolbar_button.cc index 7eab841aad29bf..f72b9f0b38c59f 100644 --- a/chrome/browser/ui/views/toolbar/toolbar_button.cc +++ b/chrome/browser/ui/views/toolbar/toolbar_button.cc @@ -127,10 +127,10 @@ void ToolbarButton::OnGestureEvent(ui::GestureEvent* event) { void ToolbarButton::GetAccessibleNodeData(ui::AXNodeData* node_data) { Button::GetAccessibleNodeData(node_data); - node_data->role = ui::AX_ROLE_BUTTON; - node_data->AddState(ui::AX_STATE_HASPOPUP); + node_data->role = ax::mojom::Role::kButton; + node_data->AddState(ax::mojom::State::kHaspopup); if (enabled()) - node_data->SetDefaultActionVerb(ui::AX_DEFAULT_ACTION_VERB_PRESS); + node_data->SetDefaultActionVerb(ax::mojom::DefaultActionVerb::kPress); } void ToolbarButton::ShowContextMenuForView(View* source, diff --git a/chrome/browser/vr/BUILD.gn b/chrome/browser/vr/BUILD.gn index 4087b87f8ceece..91b38941dbc9e9 100644 --- a/chrome/browser/vr/BUILD.gn +++ b/chrome/browser/vr/BUILD.gn @@ -379,7 +379,7 @@ source_set("vr_test_support") { "//mojo/edk/system", "//skia", "//testing/gtest", - "//ui/accessibility:ax_gen", + "//ui/accessibility:ax_enums_mojo", "//ui/gfx:test_support", # TODO(mthiesse, crbug.com/769373): Remove dependency on device/vr:fakes. diff --git a/chrome/common/extensions/api/BUILD.gn b/chrome/common/extensions/api/BUILD.gn index 542500f1ef6fd3..0beab1fa9fd122 100644 --- a/chrome/common/extensions/api/BUILD.gn +++ b/chrome/common/extensions/api/BUILD.gn @@ -218,7 +218,7 @@ json_schema_api("api_registration") { "//components/sync", "//skia", "//third_party/metrics_proto", - "//ui/accessibility:ax_gen", + "//ui/accessibility:ax_enums_mojo", ] if (is_chromeos) { deps += [ "//components/drive:proto" ] diff --git a/chrome/common/extensions/chrome_extension_messages.h b/chrome/common/extensions/chrome_extension_messages.h index b45e71f4cc34e8..9ac7c6b95cf9be 100644 --- a/chrome/common/extensions/chrome_extension_messages.h +++ b/chrome/common/extensions/chrome_extension_messages.h @@ -18,7 +18,7 @@ #include "chrome/common/extensions/api/automation_internal.h" #include "extensions/common/stack_frame.h" #include "ipc/ipc_message_macros.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_node_data.h" #include "ui/accessibility/ax_relative_bounds.h" #include "ui/accessibility/ax_tree_data.h" @@ -83,13 +83,13 @@ IPC_STRUCT_BEGIN(ExtensionMsg_AccessibilityEventParams) IPC_STRUCT_MEMBER(ui::AXTreeUpdate, update) // Type of event. - IPC_STRUCT_MEMBER(ui::AXEvent, event_type) + IPC_STRUCT_MEMBER(ax::mojom::Event, event_type) // ID of the node that the event applies to. IPC_STRUCT_MEMBER(int, id) // The source of this event. - IPC_STRUCT_MEMBER(ui::AXEventFrom, event_from) + IPC_STRUCT_MEMBER(ax::mojom::EventFrom, event_from) // The mouse location in screen coordinates. IPC_STRUCT_MEMBER(gfx::Point, mouse_location) diff --git a/chrome/renderer/extensions/automation_ax_tree_wrapper.cc b/chrome/renderer/extensions/automation_ax_tree_wrapper.cc index b038cc297f094e..ef84a93ec49120 100644 --- a/chrome/renderer/extensions/automation_ax_tree_wrapper.cc +++ b/chrome/renderer/extensions/automation_ax_tree_wrapper.cc @@ -10,106 +10,106 @@ namespace extensions { namespace { -// Convert from AXEvent to api::automation::EventType. -api::automation::EventType ToAutomationEvent(ui::AXEvent event_type) { +// Convert from ax::mojom::Event to api::automation::EventType. +api::automation::EventType ToAutomationEvent(ax::mojom::Event event_type) { switch (event_type) { - case ui::AX_EVENT_NONE: + case ax::mojom::Event::kNone: return api::automation::EVENT_TYPE_NONE; - case ui::AX_EVENT_ACTIVEDESCENDANTCHANGED: + case ax::mojom::Event::kActiveDescendantChanged: return api::automation::EVENT_TYPE_ACTIVEDESCENDANTCHANGED; - case ui::AX_EVENT_ALERT: + case ax::mojom::Event::kAlert: return api::automation::EVENT_TYPE_ALERT; - case ui::AX_EVENT_ARIA_ATTRIBUTE_CHANGED: + case ax::mojom::Event::kAriaAttributeChanged: return api::automation::EVENT_TYPE_ARIAATTRIBUTECHANGED; - case ui::AX_EVENT_AUTOCORRECTION_OCCURED: + case ax::mojom::Event::kAutocorrectionOccured: return api::automation::EVENT_TYPE_AUTOCORRECTIONOCCURED; - case ui::AX_EVENT_BLUR: + case ax::mojom::Event::kBlur: return api::automation::EVENT_TYPE_BLUR; - case ui::AX_EVENT_CHECKED_STATE_CHANGED: + case ax::mojom::Event::kCheckedStateChanged: return api::automation::EVENT_TYPE_CHECKEDSTATECHANGED; - case ui::AX_EVENT_CHILDREN_CHANGED: + case ax::mojom::Event::kChildrenChanged: return api::automation::EVENT_TYPE_CHILDRENCHANGED; - case ui::AX_EVENT_CLICKED: + case ax::mojom::Event::kClicked: return api::automation::EVENT_TYPE_CLICKED; - case ui::AX_EVENT_DOCUMENT_SELECTION_CHANGED: + case ax::mojom::Event::kDocumentSelectionChanged: return api::automation::EVENT_TYPE_DOCUMENTSELECTIONCHANGED; - case ui::AX_EVENT_EXPANDED_CHANGED: + case ax::mojom::Event::kExpandedChanged: return api::automation::EVENT_TYPE_EXPANDEDCHANGED; - case ui::AX_EVENT_FOCUS: + case ax::mojom::Event::kFocus: return api::automation::EVENT_TYPE_FOCUS; - case ui::AX_EVENT_HIDE: + case ax::mojom::Event::kHide: return api::automation::EVENT_TYPE_HIDE; - case ui::AX_EVENT_HIT_TEST_RESULT: + case ax::mojom::Event::kHitTestResult: return api::automation::EVENT_TYPE_HITTESTRESULT; - case ui::AX_EVENT_HOVER: + case ax::mojom::Event::kHover: return api::automation::EVENT_TYPE_HOVER; - case ui::AX_EVENT_IMAGE_FRAME_UPDATED: + case ax::mojom::Event::kImageFrameUpdated: return api::automation::EVENT_TYPE_IMAGEFRAMEUPDATED; - case ui::AX_EVENT_INVALID_STATUS_CHANGED: + case ax::mojom::Event::kInvalidStatusChanged: return api::automation::EVENT_TYPE_INVALIDSTATUSCHANGED; - case ui::AX_EVENT_LAYOUT_COMPLETE: + case ax::mojom::Event::kLayoutComplete: return api::automation::EVENT_TYPE_LAYOUTCOMPLETE; - case ui::AX_EVENT_LIVE_REGION_CREATED: + case ax::mojom::Event::kLiveRegionCreated: return api::automation::EVENT_TYPE_LIVEREGIONCREATED; - case ui::AX_EVENT_LIVE_REGION_CHANGED: + case ax::mojom::Event::kLiveRegionChanged: return api::automation::EVENT_TYPE_LIVEREGIONCHANGED; - case ui::AX_EVENT_LOAD_COMPLETE: + case ax::mojom::Event::kLoadComplete: return api::automation::EVENT_TYPE_LOADCOMPLETE; - case ui::AX_EVENT_LOCATION_CHANGED: + case ax::mojom::Event::kLocationChanged: return api::automation::EVENT_TYPE_LOCATIONCHANGED; - case ui::AX_EVENT_MEDIA_STARTED_PLAYING: + case ax::mojom::Event::kMediaStartedPlaying: return api::automation::EVENT_TYPE_MEDIASTARTEDPLAYING; - case ui::AX_EVENT_MEDIA_STOPPED_PLAYING: + case ax::mojom::Event::kMediaStoppedPlaying: return api::automation::EVENT_TYPE_MEDIASTOPPEDPLAYING; - case ui::AX_EVENT_MENU_END: + case ax::mojom::Event::kMenuEnd: return api::automation::EVENT_TYPE_MENUEND; - case ui::AX_EVENT_MENU_LIST_ITEM_SELECTED: + case ax::mojom::Event::kMenuListItemSelected: return api::automation::EVENT_TYPE_MENULISTITEMSELECTED; - case ui::AX_EVENT_MENU_LIST_VALUE_CHANGED: + case ax::mojom::Event::kMenuListValueChanged: return api::automation::EVENT_TYPE_MENULISTVALUECHANGED; - case ui::AX_EVENT_MENU_POPUP_END: + case ax::mojom::Event::kMenuPopupEnd: return api::automation::EVENT_TYPE_MENUPOPUPEND; - case ui::AX_EVENT_MENU_POPUP_START: + case ax::mojom::Event::kMenuPopupStart: return api::automation::EVENT_TYPE_MENUPOPUPSTART; - case ui::AX_EVENT_MENU_START: + case ax::mojom::Event::kMenuStart: return api::automation::EVENT_TYPE_MENUSTART; - case ui::AX_EVENT_MOUSE_CANCELED: + case ax::mojom::Event::kMouseCanceled: return api::automation::EVENT_TYPE_MOUSECANCELED; - case ui::AX_EVENT_MOUSE_DRAGGED: + case ax::mojom::Event::kMouseDragged: return api::automation::EVENT_TYPE_MOUSEDRAGGED; - case ui::AX_EVENT_MOUSE_MOVED: + case ax::mojom::Event::kMouseMoved: return api::automation::EVENT_TYPE_MOUSEMOVED; - case ui::AX_EVENT_MOUSE_PRESSED: + case ax::mojom::Event::kMousePressed: return api::automation::EVENT_TYPE_MOUSEPRESSED; - case ui::AX_EVENT_MOUSE_RELEASED: + case ax::mojom::Event::kMouseReleased: return api::automation::EVENT_TYPE_MOUSERELEASED; - case ui::AX_EVENT_ROW_COLLAPSED: + case ax::mojom::Event::kRowCollapsed: return api::automation::EVENT_TYPE_ROWCOLLAPSED; - case ui::AX_EVENT_ROW_COUNT_CHANGED: + case ax::mojom::Event::kRowCountChanged: return api::automation::EVENT_TYPE_ROWCOUNTCHANGED; - case ui::AX_EVENT_ROW_EXPANDED: + case ax::mojom::Event::kRowExpanded: return api::automation::EVENT_TYPE_ROWEXPANDED; - case ui::AX_EVENT_SCROLL_POSITION_CHANGED: + case ax::mojom::Event::kScrollPositionChanged: return api::automation::EVENT_TYPE_SCROLLPOSITIONCHANGED; - case ui::AX_EVENT_SCROLLED_TO_ANCHOR: + case ax::mojom::Event::kScrolledToAnchor: return api::automation::EVENT_TYPE_SCROLLEDTOANCHOR; - case ui::AX_EVENT_SELECTED_CHILDREN_CHANGED: + case ax::mojom::Event::kSelectedChildrenChanged: return api::automation::EVENT_TYPE_SELECTEDCHILDRENCHANGED; - case ui::AX_EVENT_SELECTION: + case ax::mojom::Event::kSelection: return api::automation::EVENT_TYPE_SELECTION; - case ui::AX_EVENT_SELECTION_ADD: + case ax::mojom::Event::kSelectionAdd: return api::automation::EVENT_TYPE_SELECTIONADD; - case ui::AX_EVENT_SELECTION_REMOVE: + case ax::mojom::Event::kSelectionRemove: return api::automation::EVENT_TYPE_SELECTIONREMOVE; - case ui::AX_EVENT_SHOW: + case ax::mojom::Event::kShow: return api::automation::EVENT_TYPE_SHOW; - case ui::AX_EVENT_TEXT_CHANGED: + case ax::mojom::Event::kTextChanged: return api::automation::EVENT_TYPE_TEXTCHANGED; - case ui::AX_EVENT_TEXT_SELECTION_CHANGED: + case ax::mojom::Event::kTextSelectionChanged: return api::automation::EVENT_TYPE_TEXTSELECTIONCHANGED; - case ui::AX_EVENT_TREE_CHANGED: + case ax::mojom::Event::kTreeChanged: return api::automation::EVENT_TYPE_TREECHANGED; - case ui::AX_EVENT_VALUE_CHANGED: + case ax::mojom::Event::kValueChanged: return api::automation::EVENT_TYPE_VALUECHANGED; } @@ -227,8 +227,8 @@ void AutomationAXTreeWrapper::OnNodeDataWillChange( const ui::AXNodeData& old_node_data, const ui::AXNodeData& new_node_data) { AXEventGenerator::OnNodeDataWillChange(tree, old_node_data, new_node_data); - if (old_node_data.GetStringAttribute(ui::AX_ATTR_NAME) != - new_node_data.GetStringAttribute(ui::AX_ATTR_NAME)) + if (old_node_data.GetStringAttribute(ax::mojom::StringAttribute::kName) != + new_node_data.GetStringAttribute(ax::mojom::StringAttribute::kName)) text_changed_node_ids_.push_back(new_node_data.id); } diff --git a/chrome/renderer/extensions/automation_internal_custom_bindings.cc b/chrome/renderer/extensions/automation_internal_custom_bindings.cc index 44013f9f482aae..fb7c76b6056dfa 100644 --- a/chrome/renderer/extensions/automation_internal_custom_bindings.cc +++ b/chrome/renderer/extensions/automation_internal_custom_bindings.cc @@ -27,7 +27,8 @@ #include "gin/converter.h" #include "gin/data_object_builder.h" #include "ipc/message_filter.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enum_util.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_node.h" #include "ui/gfx/geometry/rect_conversions.h" @@ -104,7 +105,8 @@ static gfx::Rect ComputeGlobalNodeBounds(AutomationAXTreeWrapper* tree_wrapper, } ui::AXNode* FindNodeWithChildTreeId(ui::AXNode* node, int child_tree_id) { - if (child_tree_id == node->data().GetIntAttribute(ui::AX_ATTR_CHILD_TREE_ID)) + if (child_tree_id == + node->data().GetIntAttribute(ax::mojom::IntAttribute::kChildTreeId)) return node; for (int i = 0; i < node->child_count(); ++i) { @@ -462,7 +464,7 @@ AutomationInternalCustomBindings::AutomationInternalCustomBindings( AutomationAXTreeWrapper* tree_wrapper) { result.Set(CreateV8String( isolate, - ToString(tree_wrapper->tree()->data().sel_anchor_affinity))); + ui::ToString(tree_wrapper->tree()->data().sel_anchor_affinity))); }); RouteTreeIDFunction( "GetFocusObjectID", @@ -484,7 +486,7 @@ AutomationInternalCustomBindings::AutomationInternalCustomBindings( AutomationAXTreeWrapper* tree_wrapper) { result.Set(CreateV8String( isolate, - ToString(tree_wrapper->tree()->data().sel_focus_affinity))); + ui::ToString(tree_wrapper->tree()->data().sel_focus_affinity))); }); // Bindings that take a Tree ID and Node ID and return a property of the node. @@ -567,7 +569,7 @@ AutomationInternalCustomBindings::AutomationInternalCustomBindings( [](v8::Isolate* isolate, v8::ReturnValue result, AutomationAXTreeWrapper* tree_wrapper, ui::AXNode* node, int start, int end) { - if (node->data().role != ui::AX_ROLE_INLINE_TEXT_BOX) { + if (node->data().role != ax::mojom::Role::kInlineTextBox) { gfx::Rect global_bounds = ComputeGlobalNodeBounds(tree_wrapper, node); result.Set(RectToV8Object(isolate, global_bounds)); } @@ -575,9 +577,10 @@ AutomationInternalCustomBindings::AutomationInternalCustomBindings( // Use character offsets to compute the local bounds of this subrange. gfx::RectF local_bounds(0, 0, node->data().location.width(), node->data().location.height()); - std::string name = node->data().GetStringAttribute(ui::AX_ATTR_NAME); - std::vector character_offsets = - node->data().GetIntListAttribute(ui::AX_ATTR_CHARACTER_OFFSETS); + std::string name = + node->data().GetStringAttribute(ax::mojom::StringAttribute::kName); + std::vector character_offsets = node->data().GetIntListAttribute( + ax::mojom::IntListAttribute::kCharacterOffsets); int len = static_cast(std::min(name.size(), character_offsets.size())); if (start >= 0 && start <= end && end <= len) { @@ -585,21 +588,21 @@ AutomationInternalCustomBindings::AutomationInternalCustomBindings( int end_offset = end > 0 ? character_offsets[end - 1] : 0; switch (node->data().GetTextDirection()) { - case ui::AX_TEXT_DIRECTION_LTR: + case ax::mojom::TextDirection::kLtr: default: local_bounds.set_x(local_bounds.x() + start_offset); local_bounds.set_width(end_offset - start_offset); break; - case ui::AX_TEXT_DIRECTION_RTL: + case ax::mojom::TextDirection::kRtl: local_bounds.set_x(local_bounds.x() + local_bounds.width() - end_offset); local_bounds.set_width(end_offset - start_offset); break; - case ui::AX_TEXT_DIRECTION_TTB: + case ax::mojom::TextDirection::kTtb: local_bounds.set_y(local_bounds.y() + start_offset); local_bounds.set_height(end_offset - start_offset); break; - case ui::AX_TEXT_DIRECTION_BTT: + case ax::mojom::TextDirection::kBtt: local_bounds.set_y(local_bounds.y() + local_bounds.height() - end_offset); local_bounds.set_height(end_offset - start_offset); @@ -624,8 +627,8 @@ AutomationInternalCustomBindings::AutomationInternalCustomBindings( "GetStringAttribute", [](v8::Isolate* isolate, v8::ReturnValue result, ui::AXNode* node, const std::string& attribute_name) { - ui::AXStringAttribute attribute = - ui::ParseAXStringAttribute(attribute_name); + ax::mojom::StringAttribute attribute = + ui::ParseStringAttribute(attribute_name.c_str()); std::string attr_value; if (!node->data().GetStringAttribute(attribute, &attr_value)) return; @@ -636,8 +639,8 @@ AutomationInternalCustomBindings::AutomationInternalCustomBindings( "GetBoolAttribute", [](v8::Isolate* isolate, v8::ReturnValue result, ui::AXNode* node, const std::string& attribute_name) { - ui::AXBoolAttribute attribute = - ui::ParseAXBoolAttribute(attribute_name); + ax::mojom::BoolAttribute attribute = + ui::ParseBoolAttribute(attribute_name.c_str()); bool attr_value; if (!node->data().GetBoolAttribute(attribute, &attr_value)) return; @@ -648,7 +651,8 @@ AutomationInternalCustomBindings::AutomationInternalCustomBindings( "GetIntAttribute", [](v8::Isolate* isolate, v8::ReturnValue result, ui::AXNode* node, const std::string& attribute_name) { - ui::AXIntAttribute attribute = ui::ParseAXIntAttribute(attribute_name); + ax::mojom::IntAttribute attribute = + ui::ParseIntAttribute(attribute_name.c_str()); int attr_value; if (!node->data().GetIntAttribute(attribute, &attr_value)) return; @@ -659,8 +663,8 @@ AutomationInternalCustomBindings::AutomationInternalCustomBindings( "GetFloatAttribute", [](v8::Isolate* isolate, v8::ReturnValue result, ui::AXNode* node, const std::string& attribute_name) { - ui::AXFloatAttribute attribute = - ui::ParseAXFloatAttribute(attribute_name); + ax::mojom::FloatAttribute attribute = + ui::ParseFloatAttribute(attribute_name.c_str()); float attr_value; if (!node->data().GetFloatAttribute(attribute, &attr_value)) @@ -672,8 +676,8 @@ AutomationInternalCustomBindings::AutomationInternalCustomBindings( "GetIntListAttribute", [](v8::Isolate* isolate, v8::ReturnValue result, ui::AXNode* node, const std::string& attribute_name) { - ui::AXIntListAttribute attribute = - ui::ParseAXIntListAttribute(attribute_name); + ax::mojom::IntListAttribute attribute = + ui::ParseIntListAttribute(attribute_name.c_str()); if (!node->data().HasIntListAttribute(attribute)) return; const std::vector& attr_value = @@ -700,39 +704,44 @@ AutomationInternalCustomBindings::AutomationInternalCustomBindings( "GetNameFrom", [](v8::Isolate* isolate, v8::ReturnValue result, AutomationAXTreeWrapper* tree_wrapper, ui::AXNode* node) { - ui::AXNameFrom name_from = static_cast( - node->data().GetIntAttribute(ui::AX_ATTR_NAME_FROM)); + ax::mojom::NameFrom name_from = static_cast( + node->data().GetIntAttribute(ax::mojom::IntAttribute::kNameFrom)); std::string name_from_str = ui::ToString(name_from); result.Set(v8::String::NewFromUtf8(isolate, name_from_str.c_str())); }); RouteNodeIDFunction( "GetBold", [](v8::Isolate* isolate, v8::ReturnValue result, AutomationAXTreeWrapper* tree_wrapper, ui::AXNode* node) { - bool value = (node->data().GetIntAttribute(ui::AX_ATTR_TEXT_STYLE) & - ui::AX_TEXT_STYLE_BOLD) != 0; + bool value = + (node->data().GetIntAttribute(ax::mojom::IntAttribute::kTextStyle) & + static_cast(ax::mojom::TextStyle::kTextStyleBold)) != 0; result.Set(v8::Boolean::New(isolate, value)); }); RouteNodeIDFunction( "GetItalic", [](v8::Isolate* isolate, v8::ReturnValue result, AutomationAXTreeWrapper* tree_wrapper, ui::AXNode* node) { - bool value = (node->data().GetIntAttribute(ui::AX_ATTR_TEXT_STYLE) & - ui::AX_TEXT_STYLE_ITALIC) != 0; + bool value = + (node->data().GetIntAttribute(ax::mojom::IntAttribute::kTextStyle) & + static_cast(ax::mojom::TextStyle::kTextStyleItalic)) != 0; result.Set(v8::Boolean::New(isolate, value)); }); RouteNodeIDFunction("GetUnderline", [](v8::Isolate* isolate, v8::ReturnValue result, AutomationAXTreeWrapper* tree_wrapper, ui::AXNode* node) { - bool value = (node->data().GetIntAttribute(ui::AX_ATTR_TEXT_STYLE) & - ui::AX_TEXT_STYLE_UNDERLINE) != 0; + bool value = + (node->data().GetIntAttribute(ax::mojom::IntAttribute::kTextStyle) & + static_cast(ax::mojom::TextStyle::kTextStyleUnderline)) != 0; result.Set(v8::Boolean::New(isolate, value)); }); RouteNodeIDFunction( "GetLineThrough", [](v8::Isolate* isolate, v8::ReturnValue result, AutomationAXTreeWrapper* tree_wrapper, ui::AXNode* node) { - bool value = (node->data().GetIntAttribute(ui::AX_ATTR_TEXT_STYLE) & - ui::AX_TEXT_STYLE_LINE_THROUGH) != 0; + bool value = + (node->data().GetIntAttribute(ax::mojom::IntAttribute::kTextStyle) & + static_cast( + ax::mojom::TextStyle::kTextStyleLineThrough)) != 0; result.Set(v8::Boolean::New(isolate, value)); }); RouteNodeIDFunction( @@ -740,7 +749,8 @@ AutomationInternalCustomBindings::AutomationInternalCustomBindings( [](v8::Isolate* isolate, v8::ReturnValue result, AutomationAXTreeWrapper* tree_wrapper, ui::AXNode* node) { const std::vector& custom_action_ids = - node->data().GetIntListAttribute(ui::AX_ATTR_CUSTOM_ACTION_IDS); + node->data().GetIntListAttribute( + ax::mojom::IntListAttribute::kCustomActionIds); if (custom_action_ids.empty()) { result.SetUndefined(); return; @@ -748,7 +758,7 @@ AutomationInternalCustomBindings::AutomationInternalCustomBindings( const std::vector& custom_action_descriptions = node->data().GetStringListAttribute( - ui::AX_ATTR_CUSTOM_ACTION_DESCRIPTIONS); + ax::mojom::StringListAttribute::kCustomActionDescriptions); if (custom_action_ids.size() != custom_action_descriptions.size()) { NOTREACHED(); return; @@ -764,23 +774,25 @@ AutomationInternalCustomBindings::AutomationInternalCustomBindings( } result.Set(custom_actions); }); - RouteNodeIDFunction("GetChecked", [](v8::Isolate* isolate, - v8::ReturnValue result, - AutomationAXTreeWrapper* tree_wrapper, - ui::AXNode* node) { - const ui::AXCheckedState checked_state = static_cast( - node->data().GetIntAttribute(ui::AX_ATTR_CHECKED_STATE)); - if (checked_state) { - const std::string checked_str = ui::ToString(checked_state); - result.Set(v8::String::NewFromUtf8(isolate, checked_str.c_str())); - } - }); + RouteNodeIDFunction( + "GetChecked", + [](v8::Isolate* isolate, v8::ReturnValue result, + AutomationAXTreeWrapper* tree_wrapper, ui::AXNode* node) { + const ax::mojom::CheckedState checked_state = + static_cast(node->data().GetIntAttribute( + ax::mojom::IntAttribute::kCheckedState)); + if (checked_state != ax::mojom::CheckedState::kNone) { + const std::string checked_str = ui::ToString(checked_state); + result.Set(v8::String::NewFromUtf8(isolate, checked_str.c_str())); + } + }); RouteNodeIDFunction( "GetRestriction", [](v8::Isolate* isolate, v8::ReturnValue result, AutomationAXTreeWrapper* tree_wrapper, ui::AXNode* node) { - const ui::AXRestriction restriction = node->data().GetRestriction(); - if (restriction != ui::AX_RESTRICTION_NONE) { + const ax::mojom::Restriction restriction = + node->data().GetRestriction(); + if (restriction != ax::mojom::Restriction::kNone) { const std::string restriction_str = ui::ToString(restriction); result.Set(v8::String::NewFromUtf8(isolate, restriction_str.c_str())); } @@ -843,25 +855,26 @@ void AutomationInternalCustomBindings::GetSchemaAdditions( v8::Isolate* isolate = GetIsolate(); gin::DataObjectBuilder name_from_type(isolate); - for (int32_t i = static_cast(ui::AX_NAME_FROM_NONE); - i <= static_cast(ui::AX_NAME_FROM_LAST); ++i) { + for (int32_t i = static_cast(ax::mojom::NameFrom::kNone); + i <= static_cast(ax::mojom::NameFrom::kLast); ++i) { name_from_type.Set( - i, base::StringPiece(ui::ToString(static_cast(i)))); + i, + base::StringPiece(ui::ToString(static_cast(i)))); } gin::DataObjectBuilder restriction(isolate); - for (int32_t i = static_cast(ui::AX_RESTRICTION_NONE); - i <= static_cast(ui::AX_RESTRICTION_LAST); ++i) { - restriction.Set( - i, base::StringPiece(ui::ToString(static_cast(i)))); + for (int32_t i = static_cast(ax::mojom::Restriction::kNone); + i <= static_cast(ax::mojom::Restriction::kLast); ++i) { + restriction.Set(i, base::StringPiece(ui::ToString( + static_cast(i)))); } gin::DataObjectBuilder description_from_type(isolate); - for (int32_t i = static_cast(ui::AX_DESCRIPTION_FROM_NONE); - i <= static_cast(ui::AX_DESCRIPTION_FROM_LAST); ++i) { + for (int32_t i = static_cast(ax::mojom::DescriptionFrom::kNone); + i <= static_cast(ax::mojom::DescriptionFrom::kLast); ++i) { description_from_type.Set( - i, - base::StringPiece(ui::ToString(static_cast(i)))); + i, base::StringPiece( + ui::ToString(static_cast(i)))); } args.GetReturnValue().Set( @@ -938,12 +951,12 @@ bool AutomationInternalCustomBindings::GetFocusInternal( // If the focused node is the owner of a child tree, that indicates // a node within the child tree is the one that actually has focus. - while (focus->data().HasIntAttribute(ui::AX_ATTR_CHILD_TREE_ID)) { + while (focus->data().HasIntAttribute(ax::mojom::IntAttribute::kChildTreeId)) { // Try to keep following focus recursively, by letting |tree_id| be the // new subtree to search in, while keeping |focus_tree_id| set to the tree // where we know we found a focused node. int child_tree_id = - focus->data().GetIntAttribute(ui::AX_ATTR_CHILD_TREE_ID); + focus->data().GetIntAttribute(ax::mojom::IntAttribute::kChildTreeId); AutomationAXTreeWrapper* child_tree_wrapper = GetAutomationAXTreeWrapperFromTreeID(child_tree_id); @@ -1045,7 +1058,7 @@ void AutomationInternalCustomBindings::GetState( uint32_t state_pos = 0, state_shifter = node->data().state; while (state_shifter) { if (state_shifter & 1) - state.Set(ToString(static_cast(state_pos)), true); + state.Set(ui::ToString(static_cast(state_pos)), true); state_shifter = state_shifter >> 1; state_pos++; } @@ -1106,7 +1119,7 @@ ui::AXNode* AutomationInternalCustomBindings::GetParent( (*in_out_tree_wrapper)->host_node_id()); if (parent) { int parent_child_tree_id = - parent->data().GetIntAttribute(ui::AX_ATTR_CHILD_TREE_ID); + parent->data().GetIntAttribute(ax::mojom::IntAttribute::kChildTreeId); if (parent_child_tree_id == (*in_out_tree_wrapper)->tree_id()) { *in_out_tree_wrapper = parent_tree_wrapper; return parent; @@ -1244,22 +1257,24 @@ void AutomationInternalCustomBindings::SendTreeChangeEvent( // Always notify the custom bindings when there's a node with a child tree // ID that might need to be loaded. - if (node->data().HasIntAttribute(ui::AX_ATTR_CHILD_TREE_ID)) + if (node->data().HasIntAttribute(ax::mojom::IntAttribute::kChildTreeId)) SendChildTreeIDEvent(tree, node); bool has_filter = false; if (tree_change_observer_overall_filter_ & (1 << api::automation::TREE_CHANGE_OBSERVER_FILTER_LIVEREGIONTREECHANGES)) { - if (node->data().HasStringAttribute(ui::AX_ATTR_CONTAINER_LIVE_STATUS) || - node->data().role == ui::AX_ROLE_ALERT) { + if (node->data().HasStringAttribute( + ax::mojom::StringAttribute::kContainerLiveStatus) || + node->data().role == ax::mojom::Role::kAlert) { has_filter = true; } } if (tree_change_observer_overall_filter_ & (1 << api::automation::TREE_CHANGE_OBSERVER_FILTER_TEXTMARKERCHANGES)) { - if (node->data().HasIntListAttribute(ui::AX_ATTR_MARKER_TYPES)) + if (node->data().HasIntListAttribute( + ax::mojom::IntListAttribute::kMarkerTypes)) has_filter = true; } @@ -1283,13 +1298,14 @@ void AutomationInternalCustomBindings::SendTreeChangeEvent( continue; case api::automation::TREE_CHANGE_OBSERVER_FILTER_LIVEREGIONTREECHANGES: if (!node->data().HasStringAttribute( - ui::AX_ATTR_CONTAINER_LIVE_STATUS) && - node->data().role != ui::AX_ROLE_ALERT) { + ax::mojom::StringAttribute::kContainerLiveStatus) && + node->data().role != ax::mojom::Role::kAlert) { continue; } break; case api::automation::TREE_CHANGE_OBSERVER_FILTER_TEXTMARKERCHANGES: - if (!node->data().HasIntListAttribute(ui::AX_ATTR_MARKER_TYPES)) + if (!node->data().HasIntListAttribute( + ax::mojom::IntListAttribute::kMarkerTypes)) continue; break; case api::automation::TREE_CHANGE_OBSERVER_FILTER_ALLTREECHANGES: @@ -1314,7 +1330,7 @@ void AutomationInternalCustomBindings::SendAutomationEvent( event_params->SetInteger("treeID", params.tree_id); event_params->SetInteger("targetID", target_id); event_params->SetString("eventType", api::automation::ToString(event_type)); - event_params->SetString("eventFrom", ToString(params.event_from)); + event_params->SetString("eventFrom", ui::ToString(params.event_from)); event_params->SetInteger("actionRequestID", params.action_request_id); event_params->SetInteger("mouseX", params.mouse_location.x()); event_params->SetInteger("mouseY", params.mouse_location.y()); diff --git a/chrome/test/chromedriver/BUILD.gn b/chrome/test/chromedriver/BUILD.gn index d91cb06b8729af..6a04c0f5200fc8 100644 --- a/chrome/test/chromedriver/BUILD.gn +++ b/chrome/test/chromedriver/BUILD.gn @@ -185,7 +185,7 @@ source_set("automation_client_lib") { "//third_party/WebKit/public:features", "//third_party/zlib:minizip", "//third_party/zlib/google:zip", - "//ui/accessibility:ax_gen", + "//ui/accessibility:ax_enums_mojo", "//ui/base", "//ui/gfx", "//ui/gfx/geometry", diff --git a/components/pdf/renderer/pdf_accessibility_tree.cc b/components/pdf/renderer/pdf_accessibility_tree.cc index 4f806f7c18e9c6..9bb3ff38dcd1a2 100644 --- a/components/pdf/renderer/pdf_accessibility_tree.cc +++ b/components/pdf/renderer/pdf_accessibility_tree.cc @@ -80,7 +80,7 @@ void PdfAccessibilityTree::SetAccessibilityDocInfo( return; doc_info_ = doc_info; - doc_node_ = CreateNode(ui::AX_ROLE_GROUP); + doc_node_ = CreateNode(ax::mojom::Role::kGroup); // Because all of the coordinates are expressed relative to the // doc's coordinates, the origin of the doc must be (0, 0). Its @@ -101,11 +101,10 @@ void PdfAccessibilityTree::SetAccessibilityPageInfo( CHECK_GE(page_index, 0U); CHECK_LT(page_index, doc_info_.page_count); - ui::AXNodeData* page_node = CreateNode(ui::AX_ROLE_REGION); + ui::AXNodeData* page_node = CreateNode(ax::mojom::Role::kRegion); page_node->AddStringAttribute( - ui::AX_ATTR_NAME, - l10n_util::GetPluralStringFUTF8( - IDS_PDF_PAGE_INDEX, page_index + 1)); + ax::mojom::StringAttribute::kName, + l10n_util::GetPluralStringFUTF8(IDS_PDF_PAGE_INDEX, page_index + 1)); gfx::RectF page_bounds = ToRectF(page_info.bounds); page_node->location = page_bounds; @@ -133,39 +132,43 @@ void PdfAccessibilityTree::SetAccessibilityPageInfo( // If we don't have a paragraph, create one. if (!para_node) { - para_node = CreateNode(ui::AX_ROLE_PARAGRAPH); + para_node = CreateNode(ax::mojom::Role::kParagraph); page_node->child_ids.push_back(para_node->id); if (heading_font_size_threshold > 0 && text_run.font_size > heading_font_size_threshold) { - para_node->role = ui::AX_ROLE_HEADING; - para_node->AddIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL, 2); - para_node->AddStringAttribute(ui::AX_ATTR_HTML_TAG, "h2"); + para_node->role = ax::mojom::Role::kHeading; + para_node->AddIntAttribute(ax::mojom::IntAttribute::kHierarchicalLevel, + 2); + para_node->AddStringAttribute(ax::mojom::StringAttribute::kHtmlTag, + "h2"); } // This node is for the text inside the paragraph, it includes // the text of all of the text runs. - static_text_node = CreateNode(ui::AX_ROLE_STATIC_TEXT); + static_text_node = CreateNode(ax::mojom::Role::kStaticText); para_node->child_ids.push_back(static_text_node->id); } // Add this text run to the current static text node. - ui::AXNodeData* inline_text_box_node = CreateNode( - ui::AX_ROLE_INLINE_TEXT_BOX); + ui::AXNodeData* inline_text_box_node = + CreateNode(ax::mojom::Role::kInlineTextBox); static_text_node->child_ids.push_back(inline_text_box_node->id); - inline_text_box_node->AddStringAttribute(ui::AX_ATTR_NAME, chars_utf8); + inline_text_box_node->AddStringAttribute(ax::mojom::StringAttribute::kName, + chars_utf8); gfx::RectF text_run_bounds = ToGfxRectF(text_run.bounds); text_run_bounds += page_bounds.OffsetFromOrigin(); inline_text_box_node->location = text_run_bounds; - inline_text_box_node->AddIntListAttribute(ui::AX_ATTR_CHARACTER_OFFSETS, - char_offsets); + inline_text_box_node->AddIntListAttribute( + ax::mojom::IntListAttribute::kCharacterOffsets, char_offsets); para_node->location.Union(inline_text_box_node->location); static_text_node->location.Union(inline_text_box_node->location); if (i == text_runs.size() - 1) { - static_text_node->AddStringAttribute(ui::AX_ATTR_NAME, static_text); + static_text_node->AddStringAttribute(ax::mojom::StringAttribute::kName, + static_text); break; } @@ -174,7 +177,8 @@ void PdfAccessibilityTree::SetAccessibilityPageInfo( if (text_run.font_size != text_runs[i + 1].font_size || (line_spacing_threshold > 0 && line_spacing > line_spacing_threshold)) { - static_text_node->AddStringAttribute(ui::AX_ATTR_NAME, static_text); + static_text_node->AddStringAttribute(ax::mojom::StringAttribute::kName, + static_text); para_node = nullptr; static_text_node = nullptr; static_text.clear(); @@ -280,14 +284,14 @@ gfx::RectF PdfAccessibilityTree::ToRectF(const PP_Rect& r) { return gfx::RectF(r.point.x, r.point.y, r.size.width, r.size.height); } -ui::AXNodeData* PdfAccessibilityTree::CreateNode(ui::AXRole role) { +ui::AXNodeData* PdfAccessibilityTree::CreateNode(ax::mojom::Role role) { content::RenderAccessibility* render_accessibility = GetRenderAccessibility(); DCHECK(render_accessibility); ui::AXNodeData* node = new ui::AXNodeData(); node->id = render_accessibility->GenerateAXID(); node->role = role; - node->SetRestriction(ui::AX_RESTRICTION_READ_ONLY); + node->SetRestriction(ax::mojom::Restriction::kReadOnly); // All nodes other than the first one have coordinates relative to // the first node. diff --git a/components/pdf/renderer/pdf_accessibility_tree.h b/components/pdf/renderer/pdf_accessibility_tree.h index d4b65013548785..1f8076a6335889 100644 --- a/components/pdf/renderer/pdf_accessibility_tree.h +++ b/components/pdf/renderer/pdf_accessibility_tree.h @@ -76,7 +76,7 @@ class PdfAccessibilityTree int char_index); gfx::Vector2dF ToVector2dF(const PP_Point& p); gfx::RectF ToRectF(const PP_Rect& r); - ui::AXNodeData* CreateNode(ui::AXRole role); + ui::AXNodeData* CreateNode(ax::mojom::Role role); float GetDeviceScaleFactor() const; content::RenderAccessibility* GetRenderAccessibility(); gfx::Transform* MakeTransformFromViewInfo(); diff --git a/components/pdf/renderer/pdf_accessibility_tree_browsertest.cc b/components/pdf/renderer/pdf_accessibility_tree_browsertest.cc index 385e6d2400d22f..0936c5f8d7cb8b 100644 --- a/components/pdf/renderer/pdf_accessibility_tree_browsertest.cc +++ b/components/pdf/renderer/pdf_accessibility_tree_browsertest.cc @@ -121,7 +121,8 @@ TEST_F(PdfAccessibilityTreeTest, TestEmptyPDFPage) { pdf_accessibility_tree.SetAccessibilityPageInfo(page_info_, text_runs_, chars_); - EXPECT_EQ(ui::AX_ROLE_GROUP, pdf_accessibility_tree.GetRoot()->data().role); + EXPECT_EQ(ax::mojom::Role::kGroup, + pdf_accessibility_tree.GetRoot()->data().role); } TEST_F(PdfAccessibilityTreeTest, TestAccessibilityDisabledDuringPDFLoad) { diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn index b79aace9c03c46..c019bf8030acf7 100644 --- a/content/browser/BUILD.gn +++ b/content/browser/BUILD.gn @@ -168,7 +168,7 @@ jumbo_source_set("browser") { "//third_party/zlib/google:compression_utils", "//third_party/zlib/google:zip", "//ui/accessibility", - "//ui/accessibility:ax_gen", + "//ui/accessibility:ax_enums_mojo", "//ui/base", "//ui/base:ui_features", "//ui/base/ime", diff --git a/content/browser/accessibility/accessibility_action_browsertest.cc b/content/browser/accessibility/accessibility_action_browsertest.cc index a413c18423aafd..96a46abd1e5669 100644 --- a/content/browser/accessibility/accessibility_action_browsertest.cc +++ b/content/browser/accessibility/accessibility_action_browsertest.cc @@ -27,7 +27,7 @@ class AccessibilityActionBrowserTest : public ContentBrowserTest { ~AccessibilityActionBrowserTest() override {} protected: - BrowserAccessibility* FindNode(ui::AXRole role, + BrowserAccessibility* FindNode(ax::mojom::Role role, const std::string& name) { BrowserAccessibility* root = GetManager()->GetRoot(); CHECK(root); @@ -42,8 +42,8 @@ class AccessibilityActionBrowserTest : public ContentBrowserTest { void GetBitmapFromImageDataURL(BrowserAccessibility* target, SkBitmap* bitmap) { - std::string image_data_url = target->GetStringAttribute( - ui::AX_ATTR_IMAGE_DATA_URL); + std::string image_data_url = + target->GetStringAttribute(ax::mojom::StringAttribute::kImageDataUrl); std::string mimetype; std::string charset; std::string png_data; @@ -56,12 +56,11 @@ class AccessibilityActionBrowserTest : public ContentBrowserTest { } private: - BrowserAccessibility* FindNodeInSubtree( - BrowserAccessibility& node, - ui::AXRole role, - const std::string& name) { + BrowserAccessibility* FindNodeInSubtree(BrowserAccessibility& node, + ax::mojom::Role role, + const std::string& name) { if (node.GetRole() == role && - node.GetStringAttribute(ui::AX_ATTR_NAME) == name) + node.GetStringAttribute(ax::mojom::StringAttribute::kName) == name) return &node; for (unsigned int i = 0; i < node.PlatformChildCount(); ++i) { BrowserAccessibility* result = FindNodeInSubtree( @@ -78,8 +77,9 @@ class AccessibilityActionBrowserTest : public ContentBrowserTest { IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest, FocusAction) { NavigateToURL(shell(), GURL(url::kAboutBlankURL)); - AccessibilityNotificationWaiter waiter( - shell()->web_contents(), ui::kAXModeComplete, ui::AX_EVENT_LOAD_COMPLETE); + AccessibilityNotificationWaiter waiter(shell()->web_contents(), + ui::kAXModeComplete, + ax::mojom::Event::kLoadComplete); GURL url("data:text/html," "" "" @@ -87,11 +87,11 @@ IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest, FocusAction) { NavigateToURL(shell(), url); waiter.WaitForNotification(); - BrowserAccessibility* target = FindNode(ui::AX_ROLE_BUTTON, "One"); + BrowserAccessibility* target = FindNode(ax::mojom::Role::kButton, "One"); ASSERT_NE(nullptr, target); AccessibilityNotificationWaiter waiter2( - shell()->web_contents(), ui::kAXModeComplete, ui::AX_EVENT_FOCUS); + shell()->web_contents(), ui::kAXModeComplete, ax::mojom::Event::kFocus); GetManager()->SetFocus(*target); waiter2.WaitForNotification(); @@ -103,53 +103,59 @@ IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest, IncrementDecrementActions) { NavigateToURL(shell(), GURL(url::kAboutBlankURL)); - AccessibilityNotificationWaiter waiter( - shell()->web_contents(), ui::kAXModeComplete, ui::AX_EVENT_LOAD_COMPLETE); + AccessibilityNotificationWaiter waiter(shell()->web_contents(), + ui::kAXModeComplete, + ax::mojom::Event::kLoadComplete); GURL url("data:text/html," ""); NavigateToURL(shell(), url); waiter.WaitForNotification(); - BrowserAccessibility* target = FindNode(ui::AX_ROLE_SLIDER, ""); + BrowserAccessibility* target = FindNode(ax::mojom::Role::kSlider, ""); ASSERT_NE(nullptr, target); - EXPECT_EQ(8.0, target->GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE)); + EXPECT_EQ(8.0, target->GetFloatAttribute( + ax::mojom::FloatAttribute::kValueForRange)); // Increment, should result in value changing from 8 to 10. { AccessibilityNotificationWaiter waiter2(shell()->web_contents(), ui::kAXModeComplete, - ui::AX_EVENT_VALUE_CHANGED); + ax::mojom::Event::kValueChanged); GetManager()->Increment(*target); waiter2.WaitForNotification(); } - EXPECT_EQ(10.0, target->GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE)); + EXPECT_EQ(10.0, target->GetFloatAttribute( + ax::mojom::FloatAttribute::kValueForRange)); // Increment, should result in value staying the same (max). { AccessibilityNotificationWaiter waiter2(shell()->web_contents(), ui::kAXModeComplete, - ui::AX_EVENT_VALUE_CHANGED); + ax::mojom::Event::kValueChanged); GetManager()->Increment(*target); waiter2.WaitForNotification(); } - EXPECT_EQ(10.0, target->GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE)); + EXPECT_EQ(10.0, target->GetFloatAttribute( + ax::mojom::FloatAttribute::kValueForRange)); // Decrement, should result in value changing from 10 to 8. { AccessibilityNotificationWaiter waiter2(shell()->web_contents(), ui::kAXModeComplete, - ui::AX_EVENT_VALUE_CHANGED); + ax::mojom::Event::kValueChanged); GetManager()->Decrement(*target); waiter2.WaitForNotification(); } - EXPECT_EQ(8.0, target->GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE)); + EXPECT_EQ(8.0, target->GetFloatAttribute( + ax::mojom::FloatAttribute::kValueForRange)); } IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest, CanvasGetImage) { NavigateToURL(shell(), GURL(url::kAboutBlankURL)); - AccessibilityNotificationWaiter waiter( - shell()->web_contents(), ui::kAXModeComplete, ui::AX_EVENT_LOAD_COMPLETE); + AccessibilityNotificationWaiter waiter(shell()->web_contents(), + ui::kAXModeComplete, + ax::mojom::Event::kLoadComplete); GURL url("data:text/html," "" "" @@ -171,12 +177,12 @@ IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest, CanvasGetImage) { NavigateToURL(shell(), url); waiter.WaitForNotification(); - BrowserAccessibility* target = FindNode(ui::AX_ROLE_CANVAS, "canvas"); + BrowserAccessibility* target = FindNode(ax::mojom::Role::kCanvas, "canvas"); ASSERT_NE(nullptr, target); AccessibilityNotificationWaiter waiter2(shell()->web_contents(), ui::kAXModeComplete, - ui::AX_EVENT_IMAGE_FRAME_UPDATED); + ax::mojom::Event::kImageFrameUpdated); GetManager()->GetImageData(*target, gfx::Size()); waiter2.WaitForNotification(); @@ -197,8 +203,9 @@ IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest, CanvasGetImage) { IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest, CanvasGetImageScale) { NavigateToURL(shell(), GURL(url::kAboutBlankURL)); - AccessibilityNotificationWaiter waiter( - shell()->web_contents(), ui::kAXModeComplete, ui::AX_EVENT_LOAD_COMPLETE); + AccessibilityNotificationWaiter waiter(shell()->web_contents(), + ui::kAXModeComplete, + ax::mojom::Event::kLoadComplete); GURL url("data:text/html," "" "" @@ -214,12 +221,12 @@ IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest, CanvasGetImageScale) { NavigateToURL(shell(), url); waiter.WaitForNotification(); - BrowserAccessibility* target = FindNode(ui::AX_ROLE_CANVAS, "canvas"); + BrowserAccessibility* target = FindNode(ax::mojom::Role::kCanvas, "canvas"); ASSERT_NE(nullptr, target); AccessibilityNotificationWaiter waiter2(shell()->web_contents(), ui::kAXModeComplete, - ui::AX_EVENT_IMAGE_FRAME_UPDATED); + ax::mojom::Event::kImageFrameUpdated); GetManager()->GetImageData(*target, gfx::Size(4, 4)); waiter2.WaitForNotification(); @@ -240,8 +247,9 @@ IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest, CanvasGetImageScale) { IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest, ImgElementGetImage) { NavigateToURL(shell(), GURL(url::kAboutBlankURL)); - AccessibilityNotificationWaiter waiter( - shell()->web_contents(), ui::kAXModeComplete, ui::AX_EVENT_LOAD_COMPLETE); + AccessibilityNotificationWaiter waiter(shell()->web_contents(), + ui::kAXModeComplete, + ax::mojom::Event::kLoadComplete); GURL url("data:text/html," "" "web_contents(), ui::kAXModeComplete, ui::AX_EVENT_FOCUS); + shell()->web_contents(), ui::kAXModeComplete, ax::mojom::Event::kFocus); ASSERT_TRUE( ExecuteScript(shell(), "document.getElementById('button').focus();")); waiter.WaitForNotification(); @@ -116,18 +116,18 @@ IN_PROC_BROWSER_TEST_F(AccessibilityIpcErrorBrowserTest, // Use this for debugging if the test fails. VLOG(1) << tree->ToString(); - EXPECT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, root->data().role); + EXPECT_EQ(ax::mojom::Role::kRootWebArea, root->data().role); ASSERT_EQ(2, root->child_count()); const ui::AXNode* live_region = root->ChildAtIndex(0); ASSERT_EQ(1, live_region->child_count()); - EXPECT_EQ(ui::AX_ROLE_GENERIC_CONTAINER, live_region->data().role); + EXPECT_EQ(ax::mojom::Role::kGenericContainer, live_region->data().role); const ui::AXNode* para = live_region->ChildAtIndex(0); - EXPECT_EQ(ui::AX_ROLE_PARAGRAPH, para->data().role); + EXPECT_EQ(ax::mojom::Role::kParagraph, para->data().role); const ui::AXNode* button = root->ChildAtIndex(1); - EXPECT_EQ(ui::AX_ROLE_BUTTON, button->data().role); + EXPECT_EQ(ax::mojom::Role::kButton, button->data().role); } #if defined(OS_ANDROID) @@ -153,7 +153,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityIpcErrorBrowserTest, // the first event. AccessibilityNotificationWaiter waiter(shell()->web_contents(), ui::kAXModeComplete, - ui::AX_EVENT_LAYOUT_COMPLETE); + ax::mojom::Event::kLayoutComplete); waiter.WaitForNotification(); } @@ -182,7 +182,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityIpcErrorBrowserTest, AccessibilityNotificationWaiter waiter(shell()->web_contents(), ui::kAXModeComplete, - ui::AX_EVENT_LOAD_COMPLETE); + ax::mojom::Event::kLoadComplete); waiter.WaitForNotification(); } diff --git a/content/browser/accessibility/accessibility_mode_browsertest.cc b/content/browser/accessibility/accessibility_mode_browsertest.cc index 6bffc59b39fb26..8bbb7346b012e4 100644 --- a/content/browser/accessibility/accessibility_mode_browsertest.cc +++ b/content/browser/accessibility/accessibility_mode_browsertest.cc @@ -32,7 +32,7 @@ class AccessibilityModeTest : public ContentBrowserTest { } protected: - const BrowserAccessibility* FindNode(ui::AXRole role, + const BrowserAccessibility* FindNode(ax::mojom::Role role, const std::string& name) { const BrowserAccessibility* root = GetManager()->GetRoot(); CHECK(root); @@ -48,10 +48,10 @@ class AccessibilityModeTest : public ContentBrowserTest { private: const BrowserAccessibility* FindNodeInSubtree( const BrowserAccessibility& node, - ui::AXRole role, + ax::mojom::Role role, const std::string& name) { if (node.GetRole() == role && - node.GetStringAttribute(ui::AX_ATTR_NAME) == name) + node.GetStringAttribute(ax::mojom::StringAttribute::kName) == name) return &node; for (unsigned int i = 0; i < node.PlatformChildCount(); ++i) { const BrowserAccessibility* result = FindNodeInSubtree( @@ -118,18 +118,20 @@ IN_PROC_BROWSER_TEST_F(AccessibilityModeTest, #if !defined(OS_ANDROID) NavigateToURL(shell(), GURL(url::kAboutBlankURL)); - AccessibilityNotificationWaiter waiter( - shell()->web_contents(), ui::kAXModeComplete, ui::AX_EVENT_LOAD_COMPLETE); + AccessibilityNotificationWaiter waiter(shell()->web_contents(), + ui::kAXModeComplete, + ax::mojom::Event::kLoadComplete); GURL url("data:text/html,

Para

"); NavigateToURL(shell(), url); waiter.WaitForNotification(); - const BrowserAccessibility* text = FindNode(ui::AX_ROLE_STATIC_TEXT, "Para"); + const BrowserAccessibility* text = + FindNode(ax::mojom::Role::kStaticText, "Para"); ASSERT_NE(nullptr, text); ASSERT_EQ(1U, text->InternalChildCount()); BrowserAccessibility* inline_text = text->InternalGetChild(0); ASSERT_NE(nullptr, inline_text); - EXPECT_EQ(ui::AX_ROLE_INLINE_TEXT_BOX, inline_text->GetRole()); + EXPECT_EQ(ax::mojom::Role::kInlineTextBox, inline_text->GetRole()); #endif // !defined(OS_ANDROID) } @@ -143,12 +145,13 @@ IN_PROC_BROWSER_TEST_F(AccessibilityModeTest, AccessibilityNotificationWaiter waiter( shell()->web_contents(), ui::AXMode::kNativeAPIs | ui::AXMode::kWebContents, - ui::AX_EVENT_LOAD_COMPLETE); + ax::mojom::Event::kLoadComplete); GURL url("data:text/html,

Para

"); NavigateToURL(shell(), url); waiter.WaitForNotification(); - const BrowserAccessibility* text = FindNode(ui::AX_ROLE_STATIC_TEXT, "Para"); + const BrowserAccessibility* text = + FindNode(ax::mojom::Role::kStaticText, "Para"); ASSERT_NE(nullptr, text); EXPECT_EQ(0U, text->InternalChildCount()); #endif // !defined(OS_ANDROID) @@ -160,26 +163,29 @@ IN_PROC_BROWSER_TEST_F(AccessibilityModeTest, AddScreenReaderModeFlag) { AccessibilityNotificationWaiter waiter( shell()->web_contents(), ui::AXMode::kNativeAPIs | ui::AXMode::kWebContents, - ui::AX_EVENT_LOAD_COMPLETE); + ax::mojom::Event::kLoadComplete); GURL url("data:text/html,"); NavigateToURL(shell(), url); waiter.WaitForNotification(); - const BrowserAccessibility* textbox = FindNode(ui::AX_ROLE_TEXT_FIELD, "Foo"); + const BrowserAccessibility* textbox = + FindNode(ax::mojom::Role::kTextField, "Foo"); ASSERT_NE(nullptr, textbox); - EXPECT_FALSE(textbox->HasStringAttribute(ui::AX_ATTR_PLACEHOLDER)); + EXPECT_FALSE( + textbox->HasStringAttribute(ax::mojom::StringAttribute::kPlaceholder)); int original_id = textbox->GetId(); AccessibilityNotificationWaiter waiter2(shell()->web_contents(), ui::AXMode(), - ui::AX_EVENT_LOAD_COMPLETE); + ax::mojom::Event::kLoadComplete); BrowserAccessibilityStateImpl::GetInstance()->AddAccessibilityModeFlags( ui::AXMode::kScreenReader); waiter2.WaitForNotification(); - const BrowserAccessibility* textbox2 = FindNode( - ui::AX_ROLE_TEXT_FIELD, "Foo"); + const BrowserAccessibility* textbox2 = + FindNode(ax::mojom::Role::kTextField, "Foo"); ASSERT_NE(nullptr, textbox2); - EXPECT_TRUE(textbox2->HasStringAttribute(ui::AX_ATTR_PLACEHOLDER)); + EXPECT_TRUE( + textbox2->HasStringAttribute(ax::mojom::StringAttribute::kPlaceholder)); EXPECT_EQ(original_id, textbox2->GetId()); } diff --git a/content/browser/accessibility/accessibility_tree_formatter_blink.cc b/content/browser/accessibility/accessibility_tree_formatter_blink.cc index 948363a8eb6de7..21252dd19178d8 100644 --- a/content/browser/accessibility/accessibility_tree_formatter_blink.cc +++ b/content/browser/accessibility/accessibility_tree_formatter_blink.cc @@ -16,7 +16,7 @@ #include "base/strings/utf_string_conversions.h" #include "base/values.h" #include "content/browser/accessibility/browser_accessibility_manager.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/gfx/geometry/rect_conversions.h" #include "ui/gfx/transform.h" @@ -36,7 +36,7 @@ const char* STATE_OFFSCREEN = "offscreen"; uint32_t AccessibilityTreeFormatterBlink::ChildCount( const BrowserAccessibility& node) const { - if (node.HasIntAttribute(ui::AX_ATTR_CHILD_TREE_ID)) + if (node.HasIntAttribute(ax::mojom::IntAttribute::kChildTreeId)) return node.PlatformChildCount(); else return node.InternalChildCount(); @@ -45,16 +45,17 @@ uint32_t AccessibilityTreeFormatterBlink::ChildCount( BrowserAccessibility* AccessibilityTreeFormatterBlink::GetChild( const BrowserAccessibility& node, uint32_t i) const { - if (node.HasIntAttribute(ui::AX_ATTR_CHILD_TREE_ID)) + if (node.HasIntAttribute(ax::mojom::IntAttribute::kChildTreeId)) return node.PlatformGetChild(i); else return node.InternalGetChild(i); } -// TODO(aleventhal) Convert ax enums to friendly strings, e.g. AXCheckedState. +// TODO(aleventhal) Convert ax enums to friendly strings, e.g. +// ax::mojom::CheckedState. std::string AccessibilityTreeFormatterBlink::IntAttrToString( const BrowserAccessibility& node, - ui::AXIntAttribute attr, + ax::mojom::IntAttribute attr, int value) const { if (ui::IsNodeIdIntAttribute(attr)) { // Relation @@ -63,66 +64,66 @@ std::string AccessibilityTreeFormatterBlink::IntAttrToString( } switch (attr) { - case ui::AX_ATTR_ARIA_CURRENT_STATE: - return ui::ToString(static_cast(value)); - case ui::AX_ATTR_CHECKED_STATE: - return ui::ToString(static_cast(value)); - case ui::AX_ATTR_DEFAULT_ACTION_VERB: - return ui::ToString(static_cast(value)); - case ui::AX_ATTR_DESCRIPTION_FROM: - return ui::ToString(static_cast(value)); - case ui::AX_ATTR_INVALID_STATE: - return ui::ToString(static_cast(value)); - case ui::AX_ATTR_NAME_FROM: - return ui::ToString(static_cast(value)); - case ui::AX_ATTR_RESTRICTION: - return ui::ToString(static_cast(value)); - case ui::AX_ATTR_SORT_DIRECTION: - return ui::ToString(static_cast(value)); - case ui::AX_ATTR_TEXT_DIRECTION: - return ui::ToString(static_cast(value)); + case ax::mojom::IntAttribute::kAriaCurrentState: + return ui::ToString(static_cast(value)); + case ax::mojom::IntAttribute::kCheckedState: + return ui::ToString(static_cast(value)); + case ax::mojom::IntAttribute::kDefaultActionVerb: + return ui::ToString(static_cast(value)); + case ax::mojom::IntAttribute::kDescriptionFrom: + return ui::ToString(static_cast(value)); + case ax::mojom::IntAttribute::kInvalidState: + return ui::ToString(static_cast(value)); + case ax::mojom::IntAttribute::kNameFrom: + return ui::ToString(static_cast(value)); + case ax::mojom::IntAttribute::kRestriction: + return ui::ToString(static_cast(value)); + case ax::mojom::IntAttribute::kSortDirection: + return ui::ToString(static_cast(value)); + case ax::mojom::IntAttribute::kTextDirection: + return ui::ToString(static_cast(value)); // No pretty printing necessary for these: - case ui::AX_ATTR_ACTIVEDESCENDANT_ID: - case ui::AX_ATTR_ARIA_CELL_COLUMN_INDEX: - case ui::AX_ATTR_ARIA_CELL_ROW_INDEX: - case ui::AX_ATTR_ARIA_COLUMN_COUNT: - case ui::AX_ATTR_ARIA_ROW_COUNT: - case ui::AX_ATTR_BACKGROUND_COLOR: - case ui::AX_ATTR_CHILD_TREE_ID: - case ui::AX_ATTR_COLOR: - case ui::AX_ATTR_COLOR_VALUE: - case ui::AX_ATTR_DETAILS_ID: - case ui::AX_ATTR_ERRORMESSAGE_ID: - case ui::AX_ATTR_HIERARCHICAL_LEVEL: - case ui::AX_ATTR_IN_PAGE_LINK_TARGET_ID: - case ui::AX_ATTR_MEMBER_OF_ID: - case ui::AX_ATTR_NEXT_FOCUS_ID: - case ui::AX_ATTR_NEXT_ON_LINE_ID: - case ui::AX_ATTR_POS_IN_SET: - case ui::AX_ATTR_PREVIOUS_FOCUS_ID: - case ui::AX_ATTR_PREVIOUS_ON_LINE_ID: - case ui::AX_ATTR_SCROLL_X: - case ui::AX_ATTR_SCROLL_X_MAX: - case ui::AX_ATTR_SCROLL_X_MIN: - case ui::AX_ATTR_SCROLL_Y: - case ui::AX_ATTR_SCROLL_Y_MAX: - case ui::AX_ATTR_SCROLL_Y_MIN: - case ui::AX_ATTR_SET_SIZE: - case ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX: - case ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN: - case ui::AX_ATTR_TABLE_CELL_ROW_INDEX: - case ui::AX_ATTR_TABLE_CELL_ROW_SPAN: - case ui::AX_ATTR_TABLE_COLUMN_COUNT: - case ui::AX_ATTR_TABLE_COLUMN_HEADER_ID: - case ui::AX_ATTR_TABLE_COLUMN_INDEX: - case ui::AX_ATTR_TABLE_HEADER_ID: - case ui::AX_ATTR_TABLE_ROW_COUNT: - case ui::AX_ATTR_TABLE_ROW_HEADER_ID: - case ui::AX_ATTR_TABLE_ROW_INDEX: - case ui::AX_ATTR_TEXT_SEL_END: - case ui::AX_ATTR_TEXT_SEL_START: - case ui::AX_ATTR_TEXT_STYLE: - case ui::AX_INT_ATTRIBUTE_NONE: + case ax::mojom::IntAttribute::kActivedescendantId: + case ax::mojom::IntAttribute::kAriaCellColumnIndex: + case ax::mojom::IntAttribute::kAriaCellRowIndex: + case ax::mojom::IntAttribute::kAriaColumnCount: + case ax::mojom::IntAttribute::kAriaRowCount: + case ax::mojom::IntAttribute::kBackgroundColor: + case ax::mojom::IntAttribute::kChildTreeId: + case ax::mojom::IntAttribute::kColor: + case ax::mojom::IntAttribute::kColorValue: + case ax::mojom::IntAttribute::kDetailsId: + case ax::mojom::IntAttribute::kErrormessageId: + case ax::mojom::IntAttribute::kHierarchicalLevel: + case ax::mojom::IntAttribute::kInPageLinkTargetId: + case ax::mojom::IntAttribute::kMemberOfId: + case ax::mojom::IntAttribute::kNextFocusId: + case ax::mojom::IntAttribute::kNextOnLineId: + case ax::mojom::IntAttribute::kPosInSet: + case ax::mojom::IntAttribute::kPreviousFocusId: + case ax::mojom::IntAttribute::kPreviousOnLineId: + case ax::mojom::IntAttribute::kScrollX: + case ax::mojom::IntAttribute::kScrollXMax: + case ax::mojom::IntAttribute::kScrollXMin: + case ax::mojom::IntAttribute::kScrollY: + case ax::mojom::IntAttribute::kScrollYMax: + case ax::mojom::IntAttribute::kScrollYMin: + case ax::mojom::IntAttribute::kSetSize: + case ax::mojom::IntAttribute::kTableCellColumnIndex: + case ax::mojom::IntAttribute::kTableCellColumnSpan: + case ax::mojom::IntAttribute::kTableCellRowIndex: + case ax::mojom::IntAttribute::kTableCellRowSpan: + case ax::mojom::IntAttribute::kTableColumnCount: + case ax::mojom::IntAttribute::kTableColumnHeaderId: + case ax::mojom::IntAttribute::kTableColumnIndex: + case ax::mojom::IntAttribute::kTableHeaderId: + case ax::mojom::IntAttribute::kTableRowCount: + case ax::mojom::IntAttribute::kTableRowHeaderId: + case ax::mojom::IntAttribute::kTableRowIndex: + case ax::mojom::IntAttribute::kTextSelEnd: + case ax::mojom::IntAttribute::kTextSelStart: + case ax::mojom::IntAttribute::kTextStyle: + case ax::mojom::IntAttribute::kNone: break; } @@ -161,9 +162,10 @@ void AccessibilityTreeFormatterBlink::AddProperties( dict->SetInteger("unclippedBoundsWidth", unclipped_bounds.width()); dict->SetInteger("unclippedBoundsHeight", unclipped_bounds.height()); - for (int32_t state_index = static_cast(ui::AX_STATE_NONE); - state_index <= static_cast(ui::AX_STATE_LAST); ++state_index) { - auto state = static_cast(state_index); + for (int32_t state_index = static_cast(ax::mojom::State::kNone); + state_index <= static_cast(ax::mojom::State::kLast); + ++state_index) { + auto state = static_cast(state_index); if (node.HasState(state)) dict->SetBoolean(ui::ToString(state), true); } @@ -171,45 +173,49 @@ void AccessibilityTreeFormatterBlink::AddProperties( if (offscreen) dict->SetBoolean(STATE_OFFSCREEN, true); - for (int32_t attr_index = static_cast(ui::AX_STRING_ATTRIBUTE_NONE); - attr_index <= static_cast(ui::AX_STRING_ATTRIBUTE_LAST); + for (int32_t attr_index = + static_cast(ax::mojom::StringAttribute::kNone); + attr_index <= static_cast(ax::mojom::StringAttribute::kLast); ++attr_index) { - auto attr = static_cast(attr_index); + auto attr = static_cast(attr_index); if (node.HasStringAttribute(attr)) dict->SetString(ui::ToString(attr), node.GetStringAttribute(attr)); } - for (int32_t attr_index = static_cast(ui::AX_INT_ATTRIBUTE_NONE); - attr_index <= static_cast(ui::AX_INT_ATTRIBUTE_LAST); + for (int32_t attr_index = + static_cast(ax::mojom::IntAttribute::kNone); + attr_index <= static_cast(ax::mojom::IntAttribute::kLast); ++attr_index) { - auto attr = static_cast(attr_index); + auto attr = static_cast(attr_index); if (node.HasIntAttribute(attr)) { int value = node.GetIntAttribute(attr); dict->SetString(ui::ToString(attr), IntAttrToString(node, attr, value)); } } - for (int32_t attr_index = static_cast(ui::AX_FLOAT_ATTRIBUTE_NONE); - attr_index <= static_cast(ui::AX_FLOAT_ATTRIBUTE_LAST); + for (int32_t attr_index = + static_cast(ax::mojom::FloatAttribute::kNone); + attr_index <= static_cast(ax::mojom::FloatAttribute::kLast); ++attr_index) { - auto attr = static_cast(attr_index); + auto attr = static_cast(attr_index); if (node.HasFloatAttribute(attr) && isfinite(node.GetFloatAttribute(attr))) dict->SetDouble(ui::ToString(attr), node.GetFloatAttribute(attr)); } - for (int32_t attr_index = static_cast(ui::AX_BOOL_ATTRIBUTE_NONE); - attr_index <= static_cast(ui::AX_BOOL_ATTRIBUTE_LAST); + for (int32_t attr_index = + static_cast(ax::mojom::BoolAttribute::kNone); + attr_index <= static_cast(ax::mojom::BoolAttribute::kLast); ++attr_index) { - auto attr = static_cast(attr_index); + auto attr = static_cast(attr_index); if (node.HasBoolAttribute(attr)) dict->SetBoolean(ui::ToString(attr), node.GetBoolAttribute(attr)); } for (int32_t attr_index = - static_cast(ui::AX_INT_LIST_ATTRIBUTE_NONE); - attr_index <= static_cast(ui::AX_INT_LIST_ATTRIBUTE_LAST); + static_cast(ax::mojom::IntListAttribute::kNone); + attr_index <= static_cast(ax::mojom::IntListAttribute::kLast); ++attr_index) { - auto attr = static_cast(attr_index); + auto attr = static_cast(attr_index); if (node.HasIntListAttribute(attr)) { std::vector values; node.GetIntListAttribute(attr, &values); @@ -242,10 +248,11 @@ void AccessibilityTreeFormatterBlink::AddProperties( } std::vector actions_strings; - for (int32_t action_index = static_cast(ui::AX_ACTION_NONE) + 1; - action_index <= static_cast(ui::AX_ACTION_LAST); + for (int32_t action_index = + static_cast(ax::mojom::Action::kNone) + 1; + action_index <= static_cast(ax::mojom::Action::kLast); ++action_index) { - auto action = static_cast(action_index); + auto action = static_cast(action_index); if (node.HasAction(action)) actions_strings.push_back(ui::ToString(action)); } @@ -272,9 +279,10 @@ base::string16 AccessibilityTreeFormatterBlink::ProcessTreeForOutput( dict.GetString("internalRole", &role_value); WriteAttribute(true, base::UTF16ToUTF8(role_value), &line); - for (int state_index = static_cast(ui::AX_STATE_NONE); - state_index <= static_cast(ui::AX_STATE_LAST); ++state_index) { - auto state = static_cast(state_index); + for (int state_index = static_cast(ax::mojom::State::kNone); + state_index <= static_cast(ax::mojom::State::kLast); + ++state_index) { + auto state = static_cast(state_index); const base::Value* value; if (!dict.Get(ui::ToString(state), &value)) continue; @@ -320,10 +328,10 @@ base::string16 AccessibilityTreeFormatterBlink::ProcessTreeForOutput( if (dict.GetBoolean("transform", &transform) && transform) WriteAttribute(false, "transform", &line); - for (int attr_index = static_cast(ui::AX_STRING_ATTRIBUTE_NONE); - attr_index <= static_cast(ui::AX_STRING_ATTRIBUTE_LAST); + for (int attr_index = static_cast(ax::mojom::StringAttribute::kNone); + attr_index <= static_cast(ax::mojom::StringAttribute::kLast); ++attr_index) { - auto attr = static_cast(attr_index); + auto attr = static_cast(attr_index); std::string string_value; if (!dict.GetString(ui::ToString(attr), &string_value)) continue; @@ -333,10 +341,10 @@ base::string16 AccessibilityTreeFormatterBlink::ProcessTreeForOutput( &line); } - for (int attr_index = static_cast(ui::AX_INT_ATTRIBUTE_NONE); - attr_index <= static_cast(ui::AX_INT_ATTRIBUTE_LAST); + for (int attr_index = static_cast(ax::mojom::IntAttribute::kNone); + attr_index <= static_cast(ax::mojom::IntAttribute::kLast); ++attr_index) { - auto attr = static_cast(attr_index); + auto attr = static_cast(attr_index); std::string string_value; if (!dict.GetString(ui::ToString(attr), &string_value)) continue; @@ -346,10 +354,10 @@ base::string16 AccessibilityTreeFormatterBlink::ProcessTreeForOutput( &line); } - for (int attr_index = static_cast(ui::AX_BOOL_ATTRIBUTE_NONE); - attr_index <= static_cast(ui::AX_BOOL_ATTRIBUTE_LAST); + for (int attr_index = static_cast(ax::mojom::BoolAttribute::kNone); + attr_index <= static_cast(ax::mojom::BoolAttribute::kLast); ++attr_index) { - auto attr = static_cast(attr_index); + auto attr = static_cast(attr_index); bool bool_value; if (!dict.GetBoolean(ui::ToString(attr), &bool_value)) continue; @@ -359,10 +367,10 @@ base::string16 AccessibilityTreeFormatterBlink::ProcessTreeForOutput( &line); } - for (int attr_index = static_cast(ui::AX_FLOAT_ATTRIBUTE_NONE); - attr_index <= static_cast(ui::AX_FLOAT_ATTRIBUTE_LAST); + for (int attr_index = static_cast(ax::mojom::FloatAttribute::kNone); + attr_index <= static_cast(ax::mojom::FloatAttribute::kLast); ++attr_index) { - auto attr = static_cast(attr_index); + auto attr = static_cast(attr_index); double float_value; if (!dict.GetDouble(ui::ToString(attr), &float_value)) continue; @@ -371,10 +379,11 @@ base::string16 AccessibilityTreeFormatterBlink::ProcessTreeForOutput( &line); } - for (int attr_index = static_cast(ui::AX_INT_LIST_ATTRIBUTE_NONE); - attr_index <= static_cast(ui::AX_INT_LIST_ATTRIBUTE_LAST); + for (int attr_index = + static_cast(ax::mojom::IntListAttribute::kNone); + attr_index <= static_cast(ax::mojom::IntListAttribute::kLast); ++attr_index) { - auto attr = static_cast(attr_index); + auto attr = static_cast(attr_index); const base::ListValue* value; if (!dict.GetList(ui::ToString(attr), &value)) continue; diff --git a/content/browser/accessibility/accessibility_tree_formatter_blink.h b/content/browser/accessibility/accessibility_tree_formatter_blink.h index b72cc5863bc47b..dba381fe38eeac 100644 --- a/content/browser/accessibility/accessibility_tree_formatter_blink.h +++ b/content/browser/accessibility/accessibility_tree_formatter_blink.h @@ -28,7 +28,7 @@ class CONTENT_EXPORT AccessibilityTreeFormatterBlink void AddProperties(const BrowserAccessibility& node, base::DictionaryValue* dict) override; std::string IntAttrToString(const BrowserAccessibility& node, - ui::AXIntAttribute attr, + ax::mojom::IntAttribute attr, int value) const; base::string16 ProcessTreeForOutput( const base::DictionaryValue& node, diff --git a/content/browser/accessibility/accessibility_win_browsertest.cc b/content/browser/accessibility/accessibility_win_browsertest.cc index 36d1e62ae24f79..61abcad9255b95 100644 --- a/content/browser/accessibility/accessibility_win_browsertest.cc +++ b/content/browser/accessibility/accessibility_win_browsertest.cc @@ -116,8 +116,9 @@ AccessibilityWinBrowserTest::~AccessibilityWinBrowserTest() { void AccessibilityWinBrowserTest::LoadInitialAccessibilityTreeFromHtml( const std::string& html, ui::AXMode accessibility_mode) { - AccessibilityNotificationWaiter waiter( - shell()->web_contents(), accessibility_mode, ui::AX_EVENT_LOAD_COMPLETE); + AccessibilityNotificationWaiter waiter(shell()->web_contents(), + accessibility_mode, + ax::mojom::Event::kLoadComplete); GURL html_data_url("data:text/html," + html); NavigateToURL(shell(), html_data_url); waiter.WaitForNotification(); @@ -173,9 +174,9 @@ void AccessibilityWinBrowserTest::SetUpInputField( ASSERT_HRESULT_SUCCEEDED(input.CopyTo(input_text->GetAddressOf())); // Set the caret on the last character. - AccessibilityNotificationWaiter waiter(shell()->web_contents(), - ui::kAXModeComplete, - ui::AX_EVENT_TEXT_SELECTION_CHANGED); + AccessibilityNotificationWaiter waiter( + shell()->web_contents(), ui::kAXModeComplete, + ax::mojom::Event::kTextSelectionChanged); std::wstring caret_offset = base::UTF16ToWide(base::IntToString16( static_cast(CONTENTS_LENGTH - 1))); ExecuteScript(std::wstring( @@ -225,9 +226,9 @@ void AccessibilityWinBrowserTest::SetUpTextareaField( ASSERT_HRESULT_SUCCEEDED(textarea.CopyTo(textarea_text->GetAddressOf())); // Set the caret on the last character. - AccessibilityNotificationWaiter waiter(shell()->web_contents(), - ui::kAXModeComplete, - ui::AX_EVENT_TEXT_SELECTION_CHANGED); + AccessibilityNotificationWaiter waiter( + shell()->web_contents(), ui::kAXModeComplete, + ax::mojom::Event::kTextSelectionChanged); std::wstring caret_offset = base::UTF16ToWide(base::IntToString16( static_cast(CONTENTS_LENGTH - 1))); ExecuteScript(std::wstring( @@ -735,8 +736,9 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, // Set focus to the radio group. std::unique_ptr waiter( - new AccessibilityNotificationWaiter( - shell()->web_contents(), ui::kAXModeComplete, ui::AX_EVENT_FOCUS)); + new AccessibilityNotificationWaiter(shell()->web_contents(), + ui::kAXModeComplete, + ax::mojom::Event::kFocus)); ExecuteScript(L"document.body.children[0].focus()"); waiter->WaitForNotification(); @@ -747,7 +749,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, // Set the active descendant of the radio group waiter.reset(new AccessibilityNotificationWaiter( - shell()->web_contents(), ui::kAXModeComplete, ui::AX_EVENT_FOCUS)); + shell()->web_contents(), ui::kAXModeComplete, ax::mojom::Event::kFocus)); ExecuteScript( L"document.body.children[0].setAttribute('aria-activedescendant', 'li')"); waiter->WaitForNotification(); @@ -778,9 +780,9 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, // Check the checkbox. std::unique_ptr waiter( - new AccessibilityNotificationWaiter(shell()->web_contents(), - ui::kAXModeComplete, - ui::AX_EVENT_CHECKED_STATE_CHANGED)); + new AccessibilityNotificationWaiter( + shell()->web_contents(), ui::kAXModeComplete, + ax::mojom::Event::kCheckedStateChanged)); ExecuteScript(L"document.body.children[0].checked=true"); waiter->WaitForNotification(); @@ -807,7 +809,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, std::unique_ptr waiter( new AccessibilityNotificationWaiter(shell()->web_contents(), ui::kAXModeComplete, - ui::AX_EVENT_CHILDREN_CHANGED)); + ax::mojom::Event::kChildrenChanged)); ExecuteScript(L"document.body.innerHTML='new text'"); waiter->WaitForNotification(); @@ -833,7 +835,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, std::unique_ptr waiter( new AccessibilityNotificationWaiter(shell()->web_contents(), ui::kAXModeComplete, - ui::AX_EVENT_CHILDREN_CHANGED)); + ax::mojom::Event::kChildrenChanged)); ExecuteScript(L"document.body.children[0].style.visibility='visible'"); waiter->WaitForNotification(); @@ -864,8 +866,9 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, // Focus the div in the document std::unique_ptr waiter( - new AccessibilityNotificationWaiter( - shell()->web_contents(), ui::kAXModeComplete, ui::AX_EVENT_FOCUS)); + new AccessibilityNotificationWaiter(shell()->web_contents(), + ui::kAXModeComplete, + ax::mojom::Event::kFocus)); ExecuteScript(L"document.body.children[0].focus()"); waiter->WaitForNotification(); @@ -877,7 +880,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, // Focus the document accessible. This will un-focus the current node. waiter.reset(new AccessibilityNotificationWaiter( - shell()->web_contents(), ui::kAXModeComplete, ui::AX_EVENT_BLUR)); + shell()->web_contents(), ui::kAXModeComplete, ax::mojom::Event::kBlur)); Microsoft::WRL::ComPtr document_accessible( GetRendererAccessible()); ASSERT_NE(document_accessible.Get(), reinterpret_cast(NULL)); @@ -913,7 +916,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, std::unique_ptr waiter( new AccessibilityNotificationWaiter(shell()->web_contents(), ui::kAXModeComplete, - ui::AX_EVENT_VALUE_CHANGED)); + ax::mojom::Event::kValueChanged)); ExecuteScript(L"document.body.children[0].value='new value'"); waiter->WaitForNotification(); @@ -1150,7 +1153,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, ui::AXMode::kNativeAPIs | ui::AXMode::kWebContents | ui::AXMode::kScreenReader, - ui::AX_EVENT_LOAD_COMPLETE); + ax::mojom::Event::kLoadComplete); EXPECT_HRESULT_SUCCEEDED(paragraph_text->get_characterExtents( 0, IA2_COORDTYPE_SCREEN_RELATIVE, &x, &y, &width, &height)); // X and y coordinates should be available without @@ -1183,7 +1186,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestScrollToPoint) { paragraph->accLocation(&prev_x, &prev_y, &width, &height, childid_self)); AccessibilityNotificationWaiter location_changed_waiter( shell()->web_contents(), ui::kAXModeComplete, - ui::AX_EVENT_LOCATION_CHANGED); + ax::mojom::Event::kLocationChanged); EXPECT_HRESULT_SUCCEEDED( paragraph->scrollToPoint(IA2_COORDTYPE_PARENT_RELATIVE, 0, 0)); location_changed_waiter.WaitForNotification(); @@ -1213,9 +1216,9 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestSetCaretOffset) { EXPECT_EQ(S_OK, hr); EXPECT_EQ(CONTENTS_LENGTH - 1, caret_offset); - AccessibilityNotificationWaiter waiter(shell()->web_contents(), - ui::kAXModeComplete, - ui::AX_EVENT_TEXT_SELECTION_CHANGED); + AccessibilityNotificationWaiter waiter( + shell()->web_contents(), ui::kAXModeComplete, + ax::mojom::Event::kTextSelectionChanged); caret_offset = 0; hr = input_text->setCaretOffset(caret_offset); EXPECT_EQ(S_OK, hr); @@ -1236,9 +1239,9 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, EXPECT_EQ(S_OK, hr); EXPECT_EQ(CONTENTS_LENGTH - 1, caret_offset); - AccessibilityNotificationWaiter waiter(shell()->web_contents(), - ui::kAXModeComplete, - ui::AX_EVENT_TEXT_SELECTION_CHANGED); + AccessibilityNotificationWaiter waiter( + shell()->web_contents(), ui::kAXModeComplete, + ax::mojom::Event::kTextSelectionChanged); caret_offset = 0; hr = textarea_text->setCaretOffset(caret_offset); EXPECT_EQ(S_OK, hr); @@ -1260,9 +1263,9 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestSetSelection) { // There is no selection, just a caret. EXPECT_EQ(E_INVALIDARG, hr); - AccessibilityNotificationWaiter waiter(shell()->web_contents(), - ui::kAXModeComplete, - ui::AX_EVENT_TEXT_SELECTION_CHANGED); + AccessibilityNotificationWaiter waiter( + shell()->web_contents(), ui::kAXModeComplete, + ax::mojom::Event::kTextSelectionChanged); start_offset = 0; end_offset = CONTENTS_LENGTH; EXPECT_HRESULT_FAILED(input_text->setSelection(1, start_offset, end_offset)); @@ -1299,9 +1302,9 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestMultiLineSetSelection) { // There is no selection, just a caret. EXPECT_EQ(E_INVALIDARG, hr); - AccessibilityNotificationWaiter waiter(shell()->web_contents(), - ui::kAXModeComplete, - ui::AX_EVENT_TEXT_SELECTION_CHANGED); + AccessibilityNotificationWaiter waiter( + shell()->web_contents(), ui::kAXModeComplete, + ax::mojom::Event::kTextSelectionChanged); start_offset = 0; end_offset = CONTENTS_LENGTH; EXPECT_HRESULT_FAILED( @@ -1339,7 +1342,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, AccessibilityNotificationWaiter waiter( shell()->web_contents(), ui::kAXModeComplete, - ui::AX_EVENT_DOCUMENT_SELECTION_CHANGED); + ax::mojom::Event::kDocumentSelectionChanged); LONG start_offset = 0; LONG end_offset = n_characters; EXPECT_HRESULT_FAILED( @@ -1955,8 +1958,9 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestIAccessibleAction) { image_name.Release(); // Cllicking the image will change its name. EXPECT_HRESULT_SUCCEEDED(image_action->doAction(0)); - AccessibilityNotificationWaiter waiter( - shell()->web_contents(), ui::kAXModeComplete, ui::AX_EVENT_TEXT_CHANGED); + AccessibilityNotificationWaiter waiter(shell()->web_contents(), + ui::kAXModeComplete, + ax::mojom::Event::kTextChanged); waiter.WaitForNotification(); EXPECT_HRESULT_SUCCEEDED( image->get_accName(childid_self, image_name.Receive())); @@ -1981,8 +1985,9 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, HasHWNDAfterNavigation) { web_contents_view_aura->set_init_rwhv_with_null_parent_for_testing(true); // Navigate to a new page and wait for the accessibility tree to load. - AccessibilityNotificationWaiter waiter( - shell()->web_contents(), ui::kAXModeComplete, ui::AX_EVENT_LOAD_COMPLETE); + AccessibilityNotificationWaiter waiter(shell()->web_contents(), + ui::kAXModeComplete, + ax::mojom::Event::kLoadComplete); NavigateToURL(shell(), embedded_test_server()->GetURL( "/accessibility/html/article.html")); waiter.WaitForNotification(); @@ -2003,8 +2008,9 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, HasHWNDAfterNavigation) { IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestAccNavigateInTables) { ASSERT_TRUE(embedded_test_server()->Start()); - AccessibilityNotificationWaiter waiter( - shell()->web_contents(), ui::kAXModeComplete, ui::AX_EVENT_LOAD_COMPLETE); + AccessibilityNotificationWaiter waiter(shell()->web_contents(), + ui::kAXModeComplete, + ax::mojom::Event::kLoadComplete); NavigateToURL(shell(), embedded_test_server()->GetURL( "/accessibility/html/table-spans.html")); waiter.WaitForNotification(); @@ -2139,9 +2145,9 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestScrollTo) { // Call scrollTo on the first target. Ensure it ends up very near the // center of the window. - AccessibilityNotificationWaiter waiter(shell()->web_contents(), - ui::kAXModeComplete, - ui::AX_EVENT_SCROLL_POSITION_CHANGED); + AccessibilityNotificationWaiter waiter( + shell()->web_contents(), ui::kAXModeComplete, + ax::mojom::Event::kScrollPositionChanged); ASSERT_HRESULT_SUCCEEDED(target->scrollTo(IA2_SCROLL_TYPE_ANYWHERE)); waiter.WaitForNotification(); @@ -2157,9 +2163,9 @@ IN_PROC_BROWSER_TEST_F(AccessibilityWinBrowserTest, TestScrollTo) { // Now call scrollTo on the second target. Ensure it ends up very near the // center of the window. - AccessibilityNotificationWaiter waiter2(shell()->web_contents(), - ui::kAXModeComplete, - ui::AX_EVENT_SCROLL_POSITION_CHANGED); + AccessibilityNotificationWaiter waiter2( + shell()->web_contents(), ui::kAXModeComplete, + ax::mojom::Event::kScrollPositionChanged); ASSERT_HRESULT_SUCCEEDED(target2->scrollTo(IA2_SCROLL_TYPE_ANYWHERE)); waiter2.WaitForNotification(); diff --git a/content/browser/accessibility/android_granularity_movement_browsertest.cc b/content/browser/accessibility/android_granularity_movement_browsertest.cc index fffbd1da712631..7a8740516e0ce3 100644 --- a/content/browser/accessibility/android_granularity_movement_browsertest.cc +++ b/content/browser/accessibility/android_granularity_movement_browsertest.cc @@ -41,7 +41,7 @@ class AndroidGranularityMovementBrowserTest : public ContentBrowserTest { // Load the page. AccessibilityNotificationWaiter waiter(shell()->web_contents(), ui::kAXModeComplete, - ui::AX_EVENT_LOAD_COMPLETE); + ax::mojom::Event::kLoadComplete); NavigateToURL(shell(), url); waiter.WaitForNotification(); @@ -71,7 +71,7 @@ class AndroidGranularityMovementBrowserTest : public ContentBrowserTest { int granularity) { AccessibilityNotificationWaiter waiter(shell()->web_contents(), ui::kAXModeComplete, - ui::AX_EVENT_TREE_CHANGED); + ax::mojom::Event::kTreeChanged); node->manager()->LoadInlineTextBoxes(*node); waiter.WaitForNotification(); diff --git a/content/browser/accessibility/browser_accessibility.cc b/content/browser/accessibility/browser_accessibility.cc index 25c0a1846154d9..af50081327ca62 100644 --- a/content/browser/accessibility/browser_accessibility.cc +++ b/content/browser/accessibility/browser_accessibility.cc @@ -58,12 +58,12 @@ bool BrowserAccessibility::PlatformIsLeaf() const { // (Note that whilst ARIA buttons can have only presentational children, HTML5 // buttons are allowed to have content.) switch (GetRole()) { - case ui::AX_ROLE_IMAGE: - case ui::AX_ROLE_METER: - case ui::AX_ROLE_SCROLL_BAR: - case ui::AX_ROLE_SLIDER: - case ui::AX_ROLE_SPLITTER: - case ui::AX_ROLE_PROGRESS_INDICATOR: + case ax::mojom::Role::kImage: + case ax::mojom::Role::kMeter: + case ax::mojom::Role::kScrollBar: + case ax::mojom::Role::kSlider: + case ax::mojom::Role::kSplitter: + case ax::mojom::Role::kProgressIndicator: return true; default: return false; @@ -71,10 +71,10 @@ bool BrowserAccessibility::PlatformIsLeaf() const { } uint32_t BrowserAccessibility::PlatformChildCount() const { - if (HasIntAttribute(ui::AX_ATTR_CHILD_TREE_ID)) { + if (HasIntAttribute(ax::mojom::IntAttribute::kChildTreeId)) { BrowserAccessibilityManager* child_manager = BrowserAccessibilityManager::FromID( - GetIntAttribute(ui::AX_ATTR_CHILD_TREE_ID)); + GetIntAttribute(ax::mojom::IntAttribute::kChildTreeId)); if (child_manager && child_manager->GetRoot()->PlatformGetParent() == this) return 1; @@ -103,30 +103,31 @@ bool BrowserAccessibility::IsDescendantOf( } bool BrowserAccessibility::IsDocument() const { - return GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || - GetRole() == ui::AX_ROLE_WEB_AREA; + return GetRole() == ax::mojom::Role::kRootWebArea || + GetRole() == ax::mojom::Role::kWebArea; } bool BrowserAccessibility::IsTextOnlyObject() const { - return GetRole() == ui::AX_ROLE_STATIC_TEXT || - GetRole() == ui::AX_ROLE_LINE_BREAK || - GetRole() == ui::AX_ROLE_INLINE_TEXT_BOX; + return GetRole() == ax::mojom::Role::kStaticText || + GetRole() == ax::mojom::Role::kLineBreak || + GetRole() == ax::mojom::Role::kInlineTextBox; } bool BrowserAccessibility::IsLineBreakObject() const { - return GetRole() == ui::AX_ROLE_LINE_BREAK || + return GetRole() == ax::mojom::Role::kLineBreak || (IsTextOnlyObject() && PlatformGetParent() && - PlatformGetParent()->GetRole() == ui::AX_ROLE_LINE_BREAK); + PlatformGetParent()->GetRole() == ax::mojom::Role::kLineBreak); } BrowserAccessibility* BrowserAccessibility::PlatformGetChild( uint32_t child_index) const { BrowserAccessibility* result = nullptr; - if (child_index == 0 && HasIntAttribute(ui::AX_ATTR_CHILD_TREE_ID)) { + if (child_index == 0 && + HasIntAttribute(ax::mojom::IntAttribute::kChildTreeId)) { BrowserAccessibilityManager* child_manager = BrowserAccessibilityManager::FromID( - GetIntAttribute(ui::AX_ATTR_CHILD_TREE_ID)); + GetIntAttribute(ax::mojom::IntAttribute::kChildTreeId)); if (child_manager && child_manager->GetRoot()->PlatformGetParent() == this) result = child_manager->GetRoot(); } else { @@ -186,7 +187,7 @@ bool BrowserAccessibility::IsPreviousSiblingOnSameLine() const { leaf_object = this; int32_t previous_on_line_id; - if (leaf_object->GetIntAttribute(ui::AX_ATTR_PREVIOUS_ON_LINE_ID, + if (leaf_object->GetIntAttribute(ax::mojom::IntAttribute::kPreviousOnLineId, &previous_on_line_id)) { const BrowserAccessibility* previous_on_line = manager()->GetFromID(previous_on_line_id); @@ -210,7 +211,7 @@ bool BrowserAccessibility::IsNextSiblingOnSameLine() const { leaf_object = this; int32_t next_on_line_id; - if (leaf_object->GetIntAttribute(ui::AX_ATTR_NEXT_ON_LINE_ID, + if (leaf_object->GetIntAttribute(ax::mojom::IntAttribute::kNextOnLineId, &next_on_line_id)) { const BrowserAccessibility* next_on_line = manager()->GetFromID(next_on_line_id); @@ -317,7 +318,7 @@ gfx::RectF BrowserAccessibility::GetLocation() const { return GetData().location; } -ui::AXRole BrowserAccessibility::GetRole() const { +ax::mojom::Role BrowserAccessibility::GetRole() const { return GetData().role; } @@ -350,7 +351,7 @@ gfx::Rect BrowserAccessibility::GetPageBoundsForRange(int start, int len) if (IsPlainTextField() && InternalChildCount() == 1) return InternalGetChild(0)->GetPageBoundsForRange(start, len); - if (GetRole() != ui::AX_ROLE_STATIC_TEXT) { + if (GetRole() != ax::mojom::Role::kStaticText) { gfx::Rect bounds; for (size_t i = 0; i < InternalChildCount() && len > 0; ++i) { BrowserAccessibility* child = InternalGetChild(i); @@ -384,7 +385,7 @@ gfx::Rect BrowserAccessibility::GetPageBoundsForRange(int start, int len) gfx::Rect bounds; for (size_t i = 0; i < InternalChildCount() && child_end < start + len; ++i) { BrowserAccessibility* child = InternalGetChild(i); - if (child->GetRole() != ui::AX_ROLE_INLINE_TEXT_BOX) { + if (child->GetRole() != ax::mojom::Role::kInlineTextBox) { DLOG(WARNING) << "BrowserAccessibility objects with role STATIC_TEXT " << "should have children of role INLINE_TEXT_BOX."; continue; @@ -409,8 +410,8 @@ gfx::Rect BrowserAccessibility::GetPageBoundsForRange(int start, int len) DCHECK_GE(local_end, 0); DCHECK_LE(local_end, child_length); - const std::vector& character_offsets = - child->GetIntListAttribute(ui::AX_ATTR_CHARACTER_OFFSETS); + const std::vector& character_offsets = child->GetIntListAttribute( + ax::mojom::IntListAttribute::kCharacterOffsets); int character_offsets_length = static_cast(character_offsets.size()); if (character_offsets_length < child_length) { // Blink might not return pixel offsets for all characters. @@ -424,33 +425,33 @@ gfx::Rect BrowserAccessibility::GetPageBoundsForRange(int start, int len) local_end > 0 ? character_offsets[local_end - 1] : 0; gfx::Rect child_rect = child->GetPageBoundsRect(); - auto text_direction = static_cast( - child->GetIntAttribute(ui::AX_ATTR_TEXT_DIRECTION)); + auto text_direction = static_cast( + child->GetIntAttribute(ax::mojom::IntAttribute::kTextDirection)); gfx::Rect child_overlap_rect; switch (text_direction) { - case ui::AX_TEXT_DIRECTION_NONE: - case ui::AX_TEXT_DIRECTION_LTR: { + case ax::mojom::TextDirection::kNone: + case ax::mojom::TextDirection::kLtr: { int left = child_rect.x() + start_pixel_offset; int right = child_rect.x() + end_pixel_offset; child_overlap_rect = gfx::Rect(left, child_rect.y(), right - left, child_rect.height()); break; } - case ui::AX_TEXT_DIRECTION_RTL: { + case ax::mojom::TextDirection::kRtl: { int right = child_rect.right() - start_pixel_offset; int left = child_rect.right() - end_pixel_offset; child_overlap_rect = gfx::Rect(left, child_rect.y(), right - left, child_rect.height()); break; } - case ui::AX_TEXT_DIRECTION_TTB: { + case ax::mojom::TextDirection::kTtb: { int top = child_rect.y() + start_pixel_offset; int bottom = child_rect.y() + end_pixel_offset; child_overlap_rect = gfx::Rect(child_rect.x(), top, child_rect.width(), bottom - top); break; } - case ui::AX_TEXT_DIRECTION_BTT: { + case ax::mojom::TextDirection::kBtt: { int bottom = child_rect.bottom() - start_pixel_offset; int top = child_rect.bottom() - end_pixel_offset; child_overlap_rect = gfx::Rect(child_rect.x(), top, @@ -480,7 +481,8 @@ gfx::Rect BrowserAccessibility::GetScreenBoundsForRange(int start, int len) } base::string16 BrowserAccessibility::GetValue() const { - base::string16 value = GetString16Attribute(ui::AX_ATTR_VALUE); + base::string16 value = + GetString16Attribute(ax::mojom::StringAttribute::kValue); // Some screen readers like Jaws and VoiceOver require a value to be set in // text fields with rich content, even though the same information is // available on the children. @@ -505,7 +507,7 @@ BrowserAccessibility* BrowserAccessibility::ApproximateHitTest( // Skip table columns because cells are only contained in rows, // not columns. - if (child->GetRole() == ui::AX_ROLE_COLUMN) + if (child->GetRole() == ax::mojom::Role::kColumn) continue; if (child->GetScreenBoundsRect().Contains(point)) { @@ -546,37 +548,38 @@ void BrowserAccessibility::NativeReleaseReference() { } bool BrowserAccessibility::HasBoolAttribute( - ui::AXBoolAttribute attribute) const { + ax::mojom::BoolAttribute attribute) const { return GetData().HasBoolAttribute(attribute); } bool BrowserAccessibility::GetBoolAttribute( - ui::AXBoolAttribute attribute) const { + ax::mojom::BoolAttribute attribute) const { return GetData().GetBoolAttribute(attribute); } -bool BrowserAccessibility::GetBoolAttribute( - ui::AXBoolAttribute attribute, bool* value) const { +bool BrowserAccessibility::GetBoolAttribute(ax::mojom::BoolAttribute attribute, + bool* value) const { return GetData().GetBoolAttribute(attribute, value); } bool BrowserAccessibility::HasFloatAttribute( - ui::AXFloatAttribute attribute) const { + ax::mojom::FloatAttribute attribute) const { return GetData().HasFloatAttribute(attribute); } float BrowserAccessibility::GetFloatAttribute( - ui::AXFloatAttribute attribute) const { + ax::mojom::FloatAttribute attribute) const { return GetData().GetFloatAttribute(attribute); } bool BrowserAccessibility::GetFloatAttribute( - ui::AXFloatAttribute attribute, float* value) const { + ax::mojom::FloatAttribute attribute, + float* value) const { return GetData().GetFloatAttribute(attribute, value); } bool BrowserAccessibility::HasInheritedStringAttribute( - ui::AXStringAttribute attribute) const { + ax::mojom::StringAttribute attribute) const { if (!instance_active()) return false; @@ -587,7 +590,7 @@ bool BrowserAccessibility::HasInheritedStringAttribute( } const std::string& BrowserAccessibility::GetInheritedStringAttribute( - ui::AXStringAttribute attribute) const { + ax::mojom::StringAttribute attribute) const { if (!instance_active()) return base::EmptyString(); @@ -601,7 +604,7 @@ const std::string& BrowserAccessibility::GetInheritedStringAttribute( } bool BrowserAccessibility::GetInheritedStringAttribute( - ui::AXStringAttribute attribute, + ax::mojom::StringAttribute attribute, std::string* value) const { if (!instance_active()) { *value = std::string(); @@ -615,7 +618,7 @@ bool BrowserAccessibility::GetInheritedStringAttribute( } base::string16 BrowserAccessibility::GetInheritedString16Attribute( - ui::AXStringAttribute attribute) const { + ax::mojom::StringAttribute attribute) const { if (!instance_active()) return base::string16(); @@ -629,7 +632,7 @@ base::string16 BrowserAccessibility::GetInheritedString16Attribute( } bool BrowserAccessibility::GetInheritedString16Attribute( - ui::AXStringAttribute attribute, + ax::mojom::StringAttribute attribute, base::string16* value) const { if (!instance_active()) { *value = base::string16(); @@ -643,56 +646,59 @@ bool BrowserAccessibility::GetInheritedString16Attribute( } bool BrowserAccessibility::HasIntAttribute( - ui::AXIntAttribute attribute) const { + ax::mojom::IntAttribute attribute) const { return GetData().HasIntAttribute(attribute); } -int BrowserAccessibility::GetIntAttribute(ui::AXIntAttribute attribute) const { +int BrowserAccessibility::GetIntAttribute( + ax::mojom::IntAttribute attribute) const { return GetData().GetIntAttribute(attribute); } -bool BrowserAccessibility::GetIntAttribute( - ui::AXIntAttribute attribute, int* value) const { +bool BrowserAccessibility::GetIntAttribute(ax::mojom::IntAttribute attribute, + int* value) const { return GetData().GetIntAttribute(attribute, value); } bool BrowserAccessibility::HasStringAttribute( - ui::AXStringAttribute attribute) const { + ax::mojom::StringAttribute attribute) const { return GetData().HasStringAttribute(attribute); } const std::string& BrowserAccessibility::GetStringAttribute( - ui::AXStringAttribute attribute) const { + ax::mojom::StringAttribute attribute) const { return GetData().GetStringAttribute(attribute); } bool BrowserAccessibility::GetStringAttribute( - ui::AXStringAttribute attribute, std::string* value) const { + ax::mojom::StringAttribute attribute, + std::string* value) const { return GetData().GetStringAttribute(attribute, value); } base::string16 BrowserAccessibility::GetString16Attribute( - ui::AXStringAttribute attribute) const { + ax::mojom::StringAttribute attribute) const { return GetData().GetString16Attribute(attribute); } -bool BrowserAccessibility::GetString16Attribute(ui::AXStringAttribute attribute, - base::string16* value) const { +bool BrowserAccessibility::GetString16Attribute( + ax::mojom::StringAttribute attribute, + base::string16* value) const { return GetData().GetString16Attribute(attribute, value); } bool BrowserAccessibility::HasIntListAttribute( - ui::AXIntListAttribute attribute) const { + ax::mojom::IntListAttribute attribute) const { return GetData().HasIntListAttribute(attribute); } const std::vector& BrowserAccessibility::GetIntListAttribute( - ui::AXIntListAttribute attribute) const { + ax::mojom::IntListAttribute attribute) const { return GetData().GetIntListAttribute(attribute); } bool BrowserAccessibility::GetIntListAttribute( - ui::AXIntListAttribute attribute, + ax::mojom::IntListAttribute attribute, std::vector* value) const { return GetData().GetIntListAttribute(attribute, value); } @@ -711,17 +717,18 @@ base::string16 BrowserAccessibility::GetText() const { return GetInnerText(); } -bool BrowserAccessibility::HasState(ui::AXState state_enum) const { +bool BrowserAccessibility::HasState(ax::mojom::State state_enum) const { return GetData().HasState(state_enum); } -bool BrowserAccessibility::HasAction(ui::AXAction action_enum) const { +bool BrowserAccessibility::HasAction(ax::mojom::Action action_enum) const { return GetData().HasAction(action_enum); } bool BrowserAccessibility::HasCaret() const { - if (IsPlainTextField() && HasIntAttribute(ui::AX_ATTR_TEXT_SEL_START) && - HasIntAttribute(ui::AX_ATTR_TEXT_SEL_END)) { + if (IsPlainTextField() && + HasIntAttribute(ax::mojom::IntAttribute::kTextSelStart) && + HasIntAttribute(ax::mojom::IntAttribute::kTextSelEnd)) { return true; } @@ -735,8 +742,8 @@ bool BrowserAccessibility::HasCaret() const { } bool BrowserAccessibility::IsWebAreaForPresentationalIframe() const { - if (GetRole() != ui::AX_ROLE_WEB_AREA && - GetRole() != ui::AX_ROLE_ROOT_WEB_AREA) { + if (GetRole() != ax::mojom::Role::kWebArea && + GetRole() != ax::mojom::Role::kRootWebArea) { return false; } @@ -744,7 +751,7 @@ bool BrowserAccessibility::IsWebAreaForPresentationalIframe() const { if (!parent) return false; - return parent->GetRole() == ui::AX_ROLE_IFRAME_PRESENTATIONAL; + return parent->GetRole() == ax::mojom::Role::kIframePresentational; } bool BrowserAccessibility::IsClickable() const { @@ -755,20 +762,21 @@ bool BrowserAccessibility::IsPlainTextField() const { // We need to check both the role and editable state, because some ARIA text // fields may in fact not be editable, whilst some editable fields might not // have the role. - return !HasState(ui::AX_STATE_RICHLY_EDITABLE) && - (GetRole() == ui::AX_ROLE_TEXT_FIELD || - GetRole() == ui::AX_ROLE_TEXT_FIELD_WITH_COMBO_BOX || - GetRole() == ui::AX_ROLE_SEARCH_BOX || - GetBoolAttribute(ui::AX_ATTR_EDITABLE_ROOT)); + return !HasState(ax::mojom::State::kRichlyEditable) && + (GetRole() == ax::mojom::Role::kTextField || + GetRole() == ax::mojom::Role::kTextFieldWithComboBox || + GetRole() == ax::mojom::Role::kSearchBox || + GetBoolAttribute(ax::mojom::BoolAttribute::kEditableRoot)); } bool BrowserAccessibility::IsRichTextField() const { - return GetBoolAttribute(ui::AX_ATTR_EDITABLE_ROOT) && - HasState(ui::AX_STATE_RICHLY_EDITABLE); + return GetBoolAttribute(ax::mojom::BoolAttribute::kEditableRoot) && + HasState(ax::mojom::State::kRichlyEditable); } bool BrowserAccessibility::HasExplicitlyEmptyName() const { - return GetData().GetNameFrom() == ui::AX_NAME_FROM_ATTRIBUTE_EXPLICITLY_EMPTY; + return GetData().GetNameFrom() == + ax::mojom::NameFrom::kAttributeExplicitlyEmpty; } std::string BrowserAccessibility::ComputeAccessibleNameFromDescendants() const { @@ -776,11 +784,12 @@ std::string BrowserAccessibility::ComputeAccessibleNameFromDescendants() const { for (size_t i = 0; i < InternalChildCount(); ++i) { BrowserAccessibility* child = InternalGetChild(i); std::string child_name; - if (child->GetStringAttribute(ui::AX_ATTR_NAME, &child_name)) { + if (child->GetStringAttribute(ax::mojom::StringAttribute::kName, + &child_name)) { if (!name.empty()) name += " "; name += child_name; - } else if (!child->HasState(ui::AX_STATE_FOCUSABLE)) { + } else if (!child->HasState(ax::mojom::State::kFocusable)) { child_name = child->ComputeAccessibleNameFromDescendants(); if (!child_name.empty()) { if (!name.empty()) @@ -801,7 +810,7 @@ std::vector BrowserAccessibility::GetLineStartOffsets() const { BrowserAccessibilityPosition::AXPositionInstance BrowserAccessibility::CreatePositionAt(int offset, - ui::AXTextAffinity affinity) const { + ax::mojom::TextAffinity affinity) const { DCHECK(manager_); return BrowserAccessibilityPosition::CreateTextPosition( manager_->ax_tree_id(), GetId(), offset, affinity); @@ -809,7 +818,7 @@ BrowserAccessibility::CreatePositionAt(int offset, base::string16 BrowserAccessibility::GetInnerText() const { if (IsTextOnlyObject()) - return GetString16Attribute(ui::AX_ATTR_NAME); + return GetString16Attribute(ax::mojom::StringAttribute::kName); base::string16 text; for (size_t i = 0; i < InternalChildCount(); ++i) @@ -833,8 +842,8 @@ gfx::Rect BrowserAccessibility::RelativeToAbsoluteBounds( !root->PlatformGetParent()) { int sx = 0; int sy = 0; - if (root->GetIntAttribute(ui::AX_ATTR_SCROLL_X, &sx) && - root->GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &sy)) { + if (root->GetIntAttribute(ax::mojom::IntAttribute::kScrollX, &sx) && + root->GetIntAttribute(ax::mojom::IntAttribute::kScrollY, &sy)) { bounds.Offset(sx, sy); } } @@ -855,14 +864,14 @@ bool BrowserAccessibility::IsOffscreen() const { } std::set BrowserAccessibility::GetReverseRelations( - ui::AXIntAttribute attr, + ax::mojom::IntAttribute attr, int32_t dst_id) { DCHECK(manager_); return manager_->ax_tree()->GetReverseRelations(attr, dst_id); } std::set BrowserAccessibility::GetReverseRelations( - ui::AXIntListAttribute attr, + ax::mojom::IntListAttribute attr, int32_t dst_id) { DCHECK(manager_); return manager_->ax_tree()->GetReverseRelations(attr, dst_id); @@ -984,17 +993,17 @@ BrowserAccessibility::GetTargetForNativeAccessibilityEvent() { bool BrowserAccessibility::AccessibilityPerformAction( const ui::AXActionData& data) { - if (data.action == ui::AX_ACTION_DO_DEFAULT) { + if (data.action == ax::mojom::Action::kDoDefault) { manager_->DoDefaultAction(*this); return true; } - if (data.action == ui::AX_ACTION_FOCUS) { + if (data.action == ax::mojom::Action::kFocus) { manager_->SetFocus(*this); return true; } - if (data.action == ui::AX_ACTION_SCROLL_TO_POINT) { + if (data.action == ax::mojom::Action::kScrollToPoint) { // target_point is in screen coordinates. We need to convert this to frame // coordinates because that's what BrowserAccessiblity cares about. gfx::Point target = @@ -1005,7 +1014,7 @@ bool BrowserAccessibility::AccessibilityPerformAction( return true; } - if (data.action == ui::AX_ACTION_SCROLL_TO_MAKE_VISIBLE) { + if (data.action == ax::mojom::Action::kScrollToMakeVisible) { manager_->ScrollToMakeVisible(*this, data.target_rect); return true; } diff --git a/content/browser/accessibility/browser_accessibility.h b/content/browser/accessibility/browser_accessibility.h index 222a1912faa468..333c4aab57be7a 100644 --- a/content/browser/accessibility/browser_accessibility.h +++ b/content/browser/accessibility/browser_accessibility.h @@ -224,7 +224,7 @@ class CONTENT_EXPORT BrowserAccessibility : public ui::AXPlatformNodeDelegate { int32_t GetId() const; gfx::RectF GetLocation() const; - ui::AXRole GetRole() const; + ax::mojom::Role GetRole() const; int32_t GetState() const; typedef base::StringPairs HtmlAttributes; @@ -250,44 +250,44 @@ class CONTENT_EXPORT BrowserAccessibility : public ui::AXPlatformNodeDelegate { // attribute is not present. In addition, strings can be returned as // either std::string or base::string16, for convenience. - bool HasBoolAttribute(ui::AXBoolAttribute attr) const; - bool GetBoolAttribute(ui::AXBoolAttribute attr) const; - bool GetBoolAttribute(ui::AXBoolAttribute attr, bool* value) const; + bool HasBoolAttribute(ax::mojom::BoolAttribute attr) const; + bool GetBoolAttribute(ax::mojom::BoolAttribute attr) const; + bool GetBoolAttribute(ax::mojom::BoolAttribute attr, bool* value) const; - bool HasFloatAttribute(ui::AXFloatAttribute attr) const; - float GetFloatAttribute(ui::AXFloatAttribute attr) const; - bool GetFloatAttribute(ui::AXFloatAttribute attr, float* value) const; + bool HasFloatAttribute(ax::mojom::FloatAttribute attr) const; + float GetFloatAttribute(ax::mojom::FloatAttribute attr) const; + bool GetFloatAttribute(ax::mojom::FloatAttribute attr, float* value) const; - bool HasInheritedStringAttribute(ui::AXStringAttribute attribute) const; + bool HasInheritedStringAttribute(ax::mojom::StringAttribute attribute) const; const std::string& GetInheritedStringAttribute( - ui::AXStringAttribute attribute) const; - bool GetInheritedStringAttribute(ui::AXStringAttribute attribute, + ax::mojom::StringAttribute attribute) const; + bool GetInheritedStringAttribute(ax::mojom::StringAttribute attribute, std::string* value) const; base::string16 GetInheritedString16Attribute( - ui::AXStringAttribute attribute) const; - bool GetInheritedString16Attribute(ui::AXStringAttribute attribute, + ax::mojom::StringAttribute attribute) const; + bool GetInheritedString16Attribute(ax::mojom::StringAttribute attribute, base::string16* value) const; - bool HasIntAttribute(ui::AXIntAttribute attribute) const; - int GetIntAttribute(ui::AXIntAttribute attribute) const; - bool GetIntAttribute(ui::AXIntAttribute attribute, int* value) const; + bool HasIntAttribute(ax::mojom::IntAttribute attribute) const; + int GetIntAttribute(ax::mojom::IntAttribute attribute) const; + bool GetIntAttribute(ax::mojom::IntAttribute attribute, int* value) const; - bool HasStringAttribute( - ui::AXStringAttribute attribute) const; - const std::string& GetStringAttribute(ui::AXStringAttribute attribute) const; - bool GetStringAttribute(ui::AXStringAttribute attribute, + bool HasStringAttribute(ax::mojom::StringAttribute attribute) const; + const std::string& GetStringAttribute( + ax::mojom::StringAttribute attribute) const; + bool GetStringAttribute(ax::mojom::StringAttribute attribute, std::string* value) const; base::string16 GetString16Attribute( - ui::AXStringAttribute attribute) const; - bool GetString16Attribute(ui::AXStringAttribute attribute, + ax::mojom::StringAttribute attribute) const; + bool GetString16Attribute(ax::mojom::StringAttribute attribute, base::string16* value) const; - bool HasIntListAttribute(ui::AXIntListAttribute attribute) const; + bool HasIntListAttribute(ax::mojom::IntListAttribute attribute) const; const std::vector& GetIntListAttribute( - ui::AXIntListAttribute attribute) const; - bool GetIntListAttribute(ui::AXIntListAttribute attribute, + ax::mojom::IntListAttribute attribute) const; + bool GetIntListAttribute(ax::mojom::IntListAttribute attribute, std::vector* value) const; // Retrieve the value of a html attribute from the attribute map and @@ -301,8 +301,8 @@ class CONTENT_EXPORT BrowserAccessibility : public ui::AXPlatformNodeDelegate { virtual base::string16 GetText() const; // Returns true if the bit corresponding to the given enum is 1. - bool HasState(ui::AXState state_enum) const; - bool HasAction(ui::AXAction action_enum) const; + bool HasState(ax::mojom::State state_enum) const; + bool HasAction(ax::mojom::Action action_enum) const; // Returns true if the caret is active on this object. bool HasCaret() const; @@ -324,7 +324,8 @@ class CONTENT_EXPORT BrowserAccessibility : public ui::AXPlatformNodeDelegate { // Creates a text position rooted at this object. BrowserAccessibilityPosition::AXPositionInstance CreatePositionAt( int offset, - ui::AXTextAffinity affinity = ui::AX_TEXT_AFFINITY_DOWNSTREAM) const; + ax::mojom::TextAffinity affinity = + ax::mojom::TextAffinity::kDownstream) const; // Gets the text offsets where new lines start. std::vector GetLineStartOffsets() const; @@ -347,9 +348,9 @@ class CONTENT_EXPORT BrowserAccessibility : public ui::AXPlatformNodeDelegate { bool AccessibilityPerformAction(const ui::AXActionData& data) override; bool ShouldIgnoreHoveredStateForTesting() override; bool IsOffscreen() const override; - std::set GetReverseRelations(ui::AXIntAttribute attr, + std::set GetReverseRelations(ax::mojom::IntAttribute attr, int32_t dst_id) override; - std::set GetReverseRelations(ui::AXIntListAttribute attr, + std::set GetReverseRelations(ax::mojom::IntListAttribute attr, int32_t dst_id) override; protected: diff --git a/content/browser/accessibility/browser_accessibility_android.cc b/content/browser/accessibility/browser_accessibility_android.cc index 416014116ca9da..f69911939a9d58 100644 --- a/content/browser/accessibility/browser_accessibility_android.cc +++ b/content/browser/accessibility/browser_accessibility_android.cc @@ -123,17 +123,16 @@ bool BrowserAccessibilityAndroid::PlatformIsLeaf() const { return true; // Iframes are always allowed to contain children. - if (IsIframe() || - GetRole() == ui::AX_ROLE_ROOT_WEB_AREA || - GetRole() == ui::AX_ROLE_WEB_AREA) { + if (IsIframe() || GetRole() == ax::mojom::Role::kRootWebArea || + GetRole() == ax::mojom::Role::kWebArea) { return false; } // Date and time controls should drop their children. switch (GetRole()) { - case ui::AX_ROLE_DATE: - case ui::AX_ROLE_DATE_TIME: - case ui::AX_ROLE_INPUT_TIME: + case ax::mojom::Role::kDate: + case ax::mojom::Role::kDateTime: + case ax::mojom::Role::kInputTime: return true; default: break; @@ -148,11 +147,11 @@ bool BrowserAccessibilityAndroid::PlatformIsLeaf() const { if (manager_android->prune_tree_for_screen_reader()) { // Headings with text can drop their children. base::string16 name = GetText(); - if (GetRole() == ui::AX_ROLE_HEADING && !name.empty()) + if (GetRole() == ax::mojom::Role::kHeading && !name.empty()) return true; // Focusable nodes with text can drop their children. - if (HasState(ui::AX_STATE_FOCUSABLE) && !name.empty()) + if (HasState(ax::mojom::State::kFocusable) && !name.empty()) return true; // Nodes with only static text as children can drop their children. @@ -164,57 +163,56 @@ bool BrowserAccessibilityAndroid::PlatformIsLeaf() const { } bool BrowserAccessibilityAndroid::IsCheckable() const { - return HasIntAttribute(ui::AX_ATTR_CHECKED_STATE); + return HasIntAttribute(ax::mojom::IntAttribute::kCheckedState); } bool BrowserAccessibilityAndroid::IsChecked() const { - return GetIntAttribute(ui::AX_ATTR_CHECKED_STATE) == - ui::AX_CHECKED_STATE_TRUE; + return GetData().GetCheckedState() == ax::mojom::CheckedState::kTrue; } bool BrowserAccessibilityAndroid::IsClickable() const { // If it has a custom default action verb except for - // AX_DEFAULT_ACTION_VERB_CLICK_ANCESTOR, it's definitely clickable. - // AX_DEFAULT_ACTION_VERB_CLICK_ANCESTOR is used when an element with a click - // listener is present in its ancestry chain. - if (HasIntAttribute(ui::AX_ATTR_DEFAULT_ACTION_VERB) && - (GetIntAttribute(ui::AX_ATTR_DEFAULT_ACTION_VERB) != - ui::AX_DEFAULT_ACTION_VERB_CLICK_ANCESTOR)) { + // ax::mojom::DefaultActionVerb::kClickAncestor, it's definitely clickable. + // ax::mojom::DefaultActionVerb::kClickAncestor is used when an element with a + // click listener is present in its ancestry chain. + if (HasIntAttribute(ax::mojom::IntAttribute::kDefaultActionVerb) && + (GetData().GetDefaultActionVerb() != + ax::mojom::DefaultActionVerb::kClickAncestor)) { return true; } // Otherwise return true if it's focusable, but skip web areas and iframes. - if (IsIframe() || (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA)) + if (IsIframe() || (GetRole() == ax::mojom::Role::kRootWebArea)) return false; return IsFocusable(); } bool BrowserAccessibilityAndroid::IsCollapsed() const { - return HasState(ui::AX_STATE_COLLAPSED); + return HasState(ax::mojom::State::kCollapsed); } // TODO(dougt) Move to ax_role_properties? bool BrowserAccessibilityAndroid::IsCollection() const { - return (ui::IsTableLikeRole(GetRole()) || GetRole() == ui::AX_ROLE_LIST || - GetRole() == ui::AX_ROLE_LIST_BOX || - GetRole() == ui::AX_ROLE_DESCRIPTION_LIST || - GetRole() == ui::AX_ROLE_TREE); + return (ui::IsTableLikeRole(GetRole()) || + GetRole() == ax::mojom::Role::kList || + GetRole() == ax::mojom::Role::kListBox || + GetRole() == ax::mojom::Role::kDescriptionList || + GetRole() == ax::mojom::Role::kTree); } bool BrowserAccessibilityAndroid::IsCollectionItem() const { - return (GetRole() == ui::AX_ROLE_CELL || - GetRole() == ui::AX_ROLE_COLUMN_HEADER || - GetRole() == ui::AX_ROLE_DESCRIPTION_LIST_TERM || - GetRole() == ui::AX_ROLE_LIST_BOX_OPTION || - GetRole() == ui::AX_ROLE_LIST_ITEM || - GetRole() == ui::AX_ROLE_ROW_HEADER || - GetRole() == ui::AX_ROLE_TREE_ITEM); + return (GetRole() == ax::mojom::Role::kCell || + GetRole() == ax::mojom::Role::kColumnHeader || + GetRole() == ax::mojom::Role::kDescriptionListTerm || + GetRole() == ax::mojom::Role::kListBoxOption || + GetRole() == ax::mojom::Role::kListItem || + GetRole() == ax::mojom::Role::kRowHeader || + GetRole() == ax::mojom::Role::kTreeItem); } bool BrowserAccessibilityAndroid::IsContentInvalid() const { - return HasIntAttribute(ui::AX_ATTR_INVALID_STATE) && - GetIntAttribute(ui::AX_ATTR_INVALID_STATE) != - ui::AX_INVALID_STATE_FALSE; + return HasIntAttribute(ax::mojom::IntAttribute::kInvalidState) && + GetData().GetInvalidState() != ax::mojom::InvalidState::kFalse; } bool BrowserAccessibilityAndroid::IsDismissable() const { @@ -226,12 +224,11 @@ bool BrowserAccessibilityAndroid::IsEditableText() const { } bool BrowserAccessibilityAndroid::IsEnabled() const { - return GetIntAttribute(ui::AX_ATTR_RESTRICTION) != - ui::AX_RESTRICTION_DISABLED; + return GetData().GetRestriction() != ax::mojom::Restriction::kDisabled; } bool BrowserAccessibilityAndroid::IsExpanded() const { - return HasState(ui::AX_STATE_EXPANDED); + return HasState(ax::mojom::State::kExpanded); } bool BrowserAccessibilityAndroid::IsFocusable() const { @@ -240,10 +237,10 @@ bool BrowserAccessibilityAndroid::IsFocusable() const { // Otherwise mark it as not focusable to avoid the user landing on // empty container elements in the tree. if (IsIframe() || - (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA && PlatformGetParent())) - return HasStringAttribute(ui::AX_ATTR_NAME); + (GetRole() == ax::mojom::Role::kRootWebArea && PlatformGetParent())) + return HasStringAttribute(ax::mojom::StringAttribute::kName); - return HasState(ui::AX_STATE_FOCUSABLE); + return HasState(ax::mojom::State::kFocusable); } bool BrowserAccessibilityAndroid::IsFocused() const { @@ -256,15 +253,15 @@ bool BrowserAccessibilityAndroid::IsHeading() const { if (parent && parent->IsHeading()) return true; - return (GetRole() == ui::AX_ROLE_COLUMN_HEADER || - GetRole() == ui::AX_ROLE_HEADING || - GetRole() == ui::AX_ROLE_ROW_HEADER); + return (GetRole() == ax::mojom::Role::kColumnHeader || + GetRole() == ax::mojom::Role::kHeading || + GetRole() == ax::mojom::Role::kRowHeader); } bool BrowserAccessibilityAndroid::IsHierarchical() const { - return (GetRole() == ui::AX_ROLE_LIST || - GetRole() == ui::AX_ROLE_DESCRIPTION_LIST || - GetRole() == ui::AX_ROLE_TREE); + return (GetRole() == ax::mojom::Role::kList || + GetRole() == ax::mojom::Role::kDescriptionList || + GetRole() == ax::mojom::Role::kTree); } bool BrowserAccessibilityAndroid::IsLink() const { @@ -272,39 +269,39 @@ bool BrowserAccessibilityAndroid::IsLink() const { } bool BrowserAccessibilityAndroid::IsMultiLine() const { - return HasState(ui::AX_STATE_MULTILINE); + return HasState(ax::mojom::State::kMultiline); } bool BrowserAccessibilityAndroid::IsPassword() const { - return HasState(ui::AX_STATE_PROTECTED); + return HasState(ax::mojom::State::kProtected); } bool BrowserAccessibilityAndroid::IsRangeType() const { - return (GetRole() == ui::AX_ROLE_PROGRESS_INDICATOR || - GetRole() == ui::AX_ROLE_METER || - GetRole() == ui::AX_ROLE_SCROLL_BAR || - GetRole() == ui::AX_ROLE_SLIDER || - (GetRole() == ui::AX_ROLE_SPLITTER && IsFocusable())); + return (GetRole() == ax::mojom::Role::kProgressIndicator || + GetRole() == ax::mojom::Role::kMeter || + GetRole() == ax::mojom::Role::kScrollBar || + GetRole() == ax::mojom::Role::kSlider || + (GetRole() == ax::mojom::Role::kSplitter && IsFocusable())); } bool BrowserAccessibilityAndroid::IsScrollable() const { - return HasIntAttribute(ui::AX_ATTR_SCROLL_X_MAX); + return HasIntAttribute(ax::mojom::IntAttribute::kScrollXMax); } bool BrowserAccessibilityAndroid::IsSelected() const { - return HasState(ui::AX_STATE_SELECTED); + return HasState(ax::mojom::State::kSelected); } bool BrowserAccessibilityAndroid::IsSlider() const { - return GetRole() == ui::AX_ROLE_SLIDER; + return GetRole() == ax::mojom::Role::kSlider; } bool BrowserAccessibilityAndroid::IsVisibleToUser() const { - return !HasState(ui::AX_STATE_INVISIBLE); + return !HasState(ax::mojom::State::kInvisible); } bool BrowserAccessibilityAndroid::IsInterestingOnAndroid() const { - if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA && GetText().empty()) + if (GetRole() == ax::mojom::Role::kRootWebArea && GetText().empty()) return true; // Focusable nodes are always interesting. Note that IsFocusable() @@ -352,7 +349,7 @@ const BrowserAccessibilityAndroid* } bool BrowserAccessibilityAndroid::AreInlineTextBoxesLoaded() const { - if (GetRole() == ui::AX_ROLE_STATIC_TEXT) + if (GetRole() == ax::mojom::Role::kStaticText) return InternalChildCount() > 0; // Return false if any descendant needs to load inline text boxes. @@ -369,7 +366,7 @@ bool BrowserAccessibilityAndroid::AreInlineTextBoxesLoaded() const { } bool BrowserAccessibilityAndroid::CanOpenPopup() const { - return HasState(ui::AX_STATE_HASPOPUP); + return HasState(ax::mojom::State::kHaspopup); } const char* BrowserAccessibilityAndroid::GetClassName() const { @@ -378,8 +375,7 @@ const char* BrowserAccessibilityAndroid::GetClassName() const { } base::string16 BrowserAccessibilityAndroid::GetText() const { - if (IsIframe() || - GetRole() == ui::AX_ROLE_WEB_AREA) { + if (IsIframe() || GetRole() == ax::mojom::Role::kWebArea) { return base::string16(); } @@ -391,9 +387,9 @@ base::string16 BrowserAccessibilityAndroid::GetText() const { // For color wells, the color is stored in separate attributes. // Perhaps we could return color names in the future? - if (GetRole() == ui::AX_ROLE_COLOR_WELL) { - unsigned int color = - static_cast(GetIntAttribute(ui::AX_ATTR_COLOR_VALUE)); + if (GetRole() == ax::mojom::Role::kColorWell) { + unsigned int color = static_cast( + GetIntAttribute(ax::mojom::IntAttribute::kColorValue)); unsigned int red = SkColorGetR(color); unsigned int green = SkColorGetG(color); unsigned int blue = SkColorGetB(color); @@ -401,7 +397,7 @@ base::string16 BrowserAccessibilityAndroid::GetText() const { base::StringPrintf("#%02X%02X%02X", red, green, blue)); } - base::string16 text = GetString16Attribute(ui::AX_ATTR_NAME); + base::string16 text = GetString16Attribute(ax::mojom::StringAttribute::kName); if (text.empty()) text = value; @@ -409,7 +405,7 @@ base::string16 BrowserAccessibilityAndroid::GetText() const { // accessible text. For almost all other focusable nodes we try to // get text from contents, but for the root element that's redundant // and often way too verbose. - if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA) + if (GetRole() == ax::mojom::Role::kRootWebArea) return text; // This is called from PlatformIsLeaf, so don't call PlatformChildCount @@ -422,9 +418,9 @@ base::string16 BrowserAccessibilityAndroid::GetText() const { } } - if (text.empty() && (IsLink() || GetRole() == ui::AX_ROLE_IMAGE) && + if (text.empty() && (IsLink() || GetRole() == ax::mojom::Role::kImage) && !HasExplicitlyEmptyName()) { - base::string16 url = GetString16Attribute(ui::AX_ATTR_URL); + base::string16 url = GetString16Attribute(ax::mojom::StringAttribute::kUrl); text = ui::AXSnapshotNodeAndroid::AXUrlBaseText(url); } @@ -432,12 +428,14 @@ base::string16 BrowserAccessibilityAndroid::GetText() const { } base::string16 BrowserAccessibilityAndroid::GetHint() const { - base::string16 description = GetString16Attribute(ui::AX_ATTR_DESCRIPTION); + base::string16 description = + GetString16Attribute(ax::mojom::StringAttribute::kDescription); // If we're returning the value as the main text, then return both the // accessible name and description as the hint. if (ShouldExposeValueAsName()) { - base::string16 name = GetString16Attribute(ui::AX_ATTR_NAME); + base::string16 name = + GetString16Attribute(ax::mojom::StringAttribute::kName); if (!name.empty() && !description.empty()) return name + base::ASCIIToUTF16(" ") + description; else if (!name.empty()) @@ -448,7 +446,7 @@ base::string16 BrowserAccessibilityAndroid::GetHint() const { } std::string BrowserAccessibilityAndroid::GetRoleString() const { - return ToString(GetRole()); + return ui::ToString(GetRole()); } base::string16 BrowserAccessibilityAndroid::GetRoleDescription() const { @@ -456,8 +454,8 @@ base::string16 BrowserAccessibilityAndroid::GetRoleDescription() const { // As a special case, if we have a heading level return a string like // "heading level 1", etc. - if (GetRole() == ui::AX_ROLE_HEADING) { - int level = GetIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL); + if (GetRole() == ax::mojom::Role::kHeading) { + int level = GetIntAttribute(ax::mojom::IntAttribute::kHierarchicalLevel); if (level >= 1 && level <= 6) { std::vector values; values.push_back(base::IntToString16(level)); @@ -469,387 +467,387 @@ base::string16 BrowserAccessibilityAndroid::GetRoleDescription() const { int message_id = -1; switch (GetRole()) { - case ui::AX_ROLE_ABBR: + case ax::mojom::Role::kAbbr: // No role description. break; - case ui::AX_ROLE_ALERT_DIALOG: + case ax::mojom::Role::kAlertDialog: message_id = IDS_AX_ROLE_ALERT_DIALOG; break; - case ui::AX_ROLE_ALERT: + case ax::mojom::Role::kAlert: message_id = IDS_AX_ROLE_ALERT; break; - case ui::AX_ROLE_ANCHOR: + case ax::mojom::Role::kAnchor: // No role description. break; - case ui::AX_ROLE_ANNOTATION: + case ax::mojom::Role::kAnnotation: // No role description. break; - case ui::AX_ROLE_APPLICATION: + case ax::mojom::Role::kApplication: message_id = IDS_AX_ROLE_APPLICATION; break; - case ui::AX_ROLE_ARTICLE: + case ax::mojom::Role::kArticle: message_id = IDS_AX_ROLE_ARTICLE; break; - case ui::AX_ROLE_AUDIO: + case ax::mojom::Role::kAudio: message_id = IDS_AX_MEDIA_AUDIO_ELEMENT; break; - case ui::AX_ROLE_BANNER: + case ax::mojom::Role::kBanner: message_id = IDS_AX_ROLE_BANNER; break; - case ui::AX_ROLE_BLOCKQUOTE: + case ax::mojom::Role::kBlockquote: message_id = IDS_AX_ROLE_BLOCKQUOTE; break; - case ui::AX_ROLE_BUTTON: + case ax::mojom::Role::kButton: message_id = IDS_AX_ROLE_BUTTON; break; - case ui::AX_ROLE_CANVAS: + case ax::mojom::Role::kCanvas: // No role description. break; - case ui::AX_ROLE_CAPTION: + case ax::mojom::Role::kCaption: // No role description. break; - case ui::AX_ROLE_CARET: + case ax::mojom::Role::kCaret: // No role description. break; - case ui::AX_ROLE_CELL: + case ax::mojom::Role::kCell: message_id = IDS_AX_ROLE_CELL; break; - case ui::AX_ROLE_CHECK_BOX: + case ax::mojom::Role::kCheckBox: message_id = IDS_AX_ROLE_CHECK_BOX; break; - case ui::AX_ROLE_CLIENT: + case ax::mojom::Role::kClient: // No role description. break; - case ui::AX_ROLE_COLOR_WELL: + case ax::mojom::Role::kColorWell: message_id = IDS_AX_ROLE_COLOR_WELL; break; - case ui::AX_ROLE_COLUMN_HEADER: + case ax::mojom::Role::kColumnHeader: message_id = IDS_AX_ROLE_COLUMN_HEADER; break; - case ui::AX_ROLE_COLUMN: + case ax::mojom::Role::kColumn: // No role description. break; - case ui::AX_ROLE_COMBO_BOX_GROUPING: + case ax::mojom::Role::kComboBoxGrouping: // No role descripotion. break; - case ui::AX_ROLE_COMBO_BOX_MENU_BUTTON: + case ax::mojom::Role::kComboBoxMenuButton: // No role descripotion. break; - case ui::AX_ROLE_COMPLEMENTARY: + case ax::mojom::Role::kComplementary: message_id = IDS_AX_ROLE_COMPLEMENTARY; break; - case ui::AX_ROLE_CONTENT_INFO: + case ax::mojom::Role::kContentInfo: message_id = IDS_AX_ROLE_CONTENT_INFO; break; - case ui::AX_ROLE_DATE: + case ax::mojom::Role::kDate: message_id = IDS_AX_ROLE_DATE; break; - case ui::AX_ROLE_DATE_TIME: + case ax::mojom::Role::kDateTime: message_id = IDS_AX_ROLE_DATE_TIME; break; - case ui::AX_ROLE_DEFINITION: + case ax::mojom::Role::kDefinition: message_id = IDS_AX_ROLE_DEFINITION; break; - case ui::AX_ROLE_DESCRIPTION_LIST_DETAIL: + case ax::mojom::Role::kDescriptionListDetail: message_id = IDS_AX_ROLE_DEFINITION; break; - case ui::AX_ROLE_DESCRIPTION_LIST: + case ax::mojom::Role::kDescriptionList: // No role description. break; - case ui::AX_ROLE_DESCRIPTION_LIST_TERM: + case ax::mojom::Role::kDescriptionListTerm: // No role description. break; - case ui::AX_ROLE_DESKTOP: + case ax::mojom::Role::kDesktop: // No role description. break; - case ui::AX_ROLE_DETAILS: + case ax::mojom::Role::kDetails: // No role description. break; - case ui::AX_ROLE_DIALOG: + case ax::mojom::Role::kDialog: message_id = IDS_AX_ROLE_DIALOG; break; - case ui::AX_ROLE_DIRECTORY: + case ax::mojom::Role::kDirectory: message_id = IDS_AX_ROLE_DIRECTORY; break; - case ui::AX_ROLE_DISCLOSURE_TRIANGLE: + case ax::mojom::Role::kDisclosureTriangle: message_id = IDS_AX_ROLE_DISCLOSURE_TRIANGLE; break; - case ui::AX_ROLE_DOCUMENT: + case ax::mojom::Role::kDocument: message_id = IDS_AX_ROLE_DOCUMENT; break; - case ui::AX_ROLE_EMBEDDED_OBJECT: + case ax::mojom::Role::kEmbeddedObject: message_id = IDS_AX_ROLE_EMBEDDED_OBJECT; break; - case ui::AX_ROLE_FEED: + case ax::mojom::Role::kFeed: message_id = IDS_AX_ROLE_FEED; break; - case ui::AX_ROLE_FIGCAPTION: + case ax::mojom::Role::kFigcaption: // No role description. break; - case ui::AX_ROLE_FIGURE: + case ax::mojom::Role::kFigure: message_id = IDS_AX_ROLE_GRAPHIC; break; - case ui::AX_ROLE_FOOTER: + case ax::mojom::Role::kFooter: message_id = IDS_AX_ROLE_FOOTER; break; - case ui::AX_ROLE_FORM: + case ax::mojom::Role::kForm: // No role description. break; - case ui::AX_ROLE_GENERIC_CONTAINER: + case ax::mojom::Role::kGenericContainer: // No role description. break; - case ui::AX_ROLE_GRID: + case ax::mojom::Role::kGrid: message_id = IDS_AX_ROLE_TABLE; break; - case ui::AX_ROLE_GROUP: + case ax::mojom::Role::kGroup: // No role description. break; - case ui::AX_ROLE_HEADING: + case ax::mojom::Role::kHeading: // Note that code above this switch statement handles headings with // a level, returning a string like "heading level 1", etc. message_id = IDS_AX_ROLE_HEADING; break; - case ui::AX_ROLE_IFRAME: + case ax::mojom::Role::kIframe: // No role description. break; - case ui::AX_ROLE_IFRAME_PRESENTATIONAL: + case ax::mojom::Role::kIframePresentational: // No role description. break; - case ui::AX_ROLE_IGNORED: + case ax::mojom::Role::kIgnored: // No role description. break; - case ui::AX_ROLE_IMAGE_MAP: + case ax::mojom::Role::kImageMap: message_id = IDS_AX_ROLE_GRAPHIC; break; - case ui::AX_ROLE_IMAGE: + case ax::mojom::Role::kImage: message_id = IDS_AX_ROLE_GRAPHIC; break; - case ui::AX_ROLE_INLINE_TEXT_BOX: + case ax::mojom::Role::kInlineTextBox: // No role description. break; - case ui::AX_ROLE_INPUT_TIME: + case ax::mojom::Role::kInputTime: message_id = IDS_AX_ROLE_INPUT_TIME; break; - case ui::AX_ROLE_LABEL_TEXT: + case ax::mojom::Role::kLabelText: // No role description. break; - case ui::AX_ROLE_LEGEND: + case ax::mojom::Role::kLegend: // No role description. break; - case ui::AX_ROLE_LINE_BREAK: + case ax::mojom::Role::kLineBreak: // No role description. break; - case ui::AX_ROLE_LINK: + case ax::mojom::Role::kLink: message_id = IDS_AX_ROLE_LINK; break; - case ui::AX_ROLE_LIST_BOX_OPTION: + case ax::mojom::Role::kListBoxOption: // No role description. break; - case ui::AX_ROLE_LIST_BOX: + case ax::mojom::Role::kListBox: message_id = IDS_AX_ROLE_LIST_BOX; break; - case ui::AX_ROLE_LIST_ITEM: + case ax::mojom::Role::kListItem: // No role description. break; - case ui::AX_ROLE_LIST_MARKER: + case ax::mojom::Role::kListMarker: // No role description. break; - case ui::AX_ROLE_LIST: + case ax::mojom::Role::kList: // No role description. break; - case ui::AX_ROLE_LOCATION_BAR: + case ax::mojom::Role::kLocationBar: // No role description. break; - case ui::AX_ROLE_LOG: + case ax::mojom::Role::kLog: message_id = IDS_AX_ROLE_LOG; break; - case ui::AX_ROLE_MAIN: + case ax::mojom::Role::kMain: message_id = IDS_AX_ROLE_MAIN_CONTENT; break; - case ui::AX_ROLE_MARK: + case ax::mojom::Role::kMark: message_id = IDS_AX_ROLE_MARK; break; - case ui::AX_ROLE_MARQUEE: + case ax::mojom::Role::kMarquee: message_id = IDS_AX_ROLE_MARQUEE; break; - case ui::AX_ROLE_MATH: + case ax::mojom::Role::kMath: message_id = IDS_AX_ROLE_MATH; break; - case ui::AX_ROLE_MENU: + case ax::mojom::Role::kMenu: message_id = IDS_AX_ROLE_MENU; break; - case ui::AX_ROLE_MENU_BAR: + case ax::mojom::Role::kMenuBar: message_id = IDS_AX_ROLE_MENU_BAR; break; - case ui::AX_ROLE_MENU_BUTTON: + case ax::mojom::Role::kMenuButton: message_id = IDS_AX_ROLE_MENU_BUTTON; break; - case ui::AX_ROLE_MENU_ITEM: + case ax::mojom::Role::kMenuItem: message_id = IDS_AX_ROLE_MENU_ITEM; break; - case ui::AX_ROLE_MENU_ITEM_CHECK_BOX: + case ax::mojom::Role::kMenuItemCheckBox: message_id = IDS_AX_ROLE_CHECK_BOX; break; - case ui::AX_ROLE_MENU_ITEM_RADIO: + case ax::mojom::Role::kMenuItemRadio: message_id = IDS_AX_ROLE_RADIO; break; - case ui::AX_ROLE_MENU_LIST_OPTION: + case ax::mojom::Role::kMenuListOption: // No role description. break; - case ui::AX_ROLE_MENU_LIST_POPUP: + case ax::mojom::Role::kMenuListPopup: // No role description. break; - case ui::AX_ROLE_METER: + case ax::mojom::Role::kMeter: message_id = IDS_AX_ROLE_METER; break; - case ui::AX_ROLE_NAVIGATION: + case ax::mojom::Role::kNavigation: message_id = IDS_AX_ROLE_NAVIGATIONAL_LINK; break; - case ui::AX_ROLE_NOTE: + case ax::mojom::Role::kNote: message_id = IDS_AX_ROLE_NOTE; break; - case ui::AX_ROLE_PANE: + case ax::mojom::Role::kPane: // No role description. break; - case ui::AX_ROLE_PARAGRAPH: + case ax::mojom::Role::kParagraph: // No role description. break; - case ui::AX_ROLE_POP_UP_BUTTON: + case ax::mojom::Role::kPopUpButton: message_id = IDS_AX_ROLE_POP_UP_BUTTON; break; - case ui::AX_ROLE_PRE: + case ax::mojom::Role::kPre: // No role description. break; - case ui::AX_ROLE_PRESENTATIONAL: + case ax::mojom::Role::kPresentational: // No role description. break; - case ui::AX_ROLE_PROGRESS_INDICATOR: + case ax::mojom::Role::kProgressIndicator: message_id = IDS_AX_ROLE_PROGRESS_INDICATOR; break; - case ui::AX_ROLE_RADIO_BUTTON: + case ax::mojom::Role::kRadioButton: message_id = IDS_AX_ROLE_RADIO; break; - case ui::AX_ROLE_RADIO_GROUP: + case ax::mojom::Role::kRadioGroup: message_id = IDS_AX_ROLE_RADIO_GROUP; break; - case ui::AX_ROLE_REGION: + case ax::mojom::Role::kRegion: message_id = IDS_AX_ROLE_REGION; break; - case ui::AX_ROLE_ROOT_WEB_AREA: + case ax::mojom::Role::kRootWebArea: // No role description. break; - case ui::AX_ROLE_ROW_HEADER: + case ax::mojom::Role::kRowHeader: message_id = IDS_AX_ROLE_ROW_HEADER; break; - case ui::AX_ROLE_ROW: + case ax::mojom::Role::kRow: // No role description. break; - case ui::AX_ROLE_RUBY: + case ax::mojom::Role::kRuby: // No role description. break; - case ui::AX_ROLE_SVG_ROOT: + case ax::mojom::Role::kSvgRoot: message_id = IDS_AX_ROLE_GRAPHIC; break; - case ui::AX_ROLE_SCROLL_BAR: + case ax::mojom::Role::kScrollBar: message_id = IDS_AX_ROLE_SCROLL_BAR; break; - case ui::AX_ROLE_SEARCH: + case ax::mojom::Role::kSearch: message_id = IDS_AX_ROLE_SEARCH; break; - case ui::AX_ROLE_SEARCH_BOX: + case ax::mojom::Role::kSearchBox: message_id = IDS_AX_ROLE_SEARCH_BOX; break; - case ui::AX_ROLE_SLIDER: + case ax::mojom::Role::kSlider: message_id = IDS_AX_ROLE_SLIDER; break; - case ui::AX_ROLE_SLIDER_THUMB: + case ax::mojom::Role::kSliderThumb: // No role description. break; - case ui::AX_ROLE_SPIN_BUTTON_PART: + case ax::mojom::Role::kSpinButtonPart: // No role description. break; - case ui::AX_ROLE_SPIN_BUTTON: + case ax::mojom::Role::kSpinButton: message_id = IDS_AX_ROLE_SPIN_BUTTON; break; - case ui::AX_ROLE_SPLITTER: + case ax::mojom::Role::kSplitter: message_id = IDS_AX_ROLE_SPLITTER; break; - case ui::AX_ROLE_STATIC_TEXT: + case ax::mojom::Role::kStaticText: // No role description. break; - case ui::AX_ROLE_STATUS: + case ax::mojom::Role::kStatus: message_id = IDS_AX_ROLE_STATUS; break; - case ui::AX_ROLE_SWITCH: + case ax::mojom::Role::kSwitch: message_id = IDS_AX_ROLE_SWITCH; break; - case ui::AX_ROLE_TAB_LIST: + case ax::mojom::Role::kTabList: message_id = IDS_AX_ROLE_TAB_LIST; break; - case ui::AX_ROLE_TAB_PANEL: + case ax::mojom::Role::kTabPanel: message_id = IDS_AX_ROLE_TAB_PANEL; break; - case ui::AX_ROLE_TAB: + case ax::mojom::Role::kTab: message_id = IDS_AX_ROLE_TAB; break; - case ui::AX_ROLE_TABLE_HEADER_CONTAINER: + case ax::mojom::Role::kTableHeaderContainer: // No role description. break; - case ui::AX_ROLE_TABLE: + case ax::mojom::Role::kTable: message_id = IDS_AX_ROLE_TABLE; break; - case ui::AX_ROLE_TERM: + case ax::mojom::Role::kTerm: message_id = IDS_AX_ROLE_DESCRIPTION_TERM; break; - case ui::AX_ROLE_TEXT_FIELD: + case ax::mojom::Role::kTextField: // No role description. break; - case ui::AX_ROLE_TEXT_FIELD_WITH_COMBO_BOX: + case ax::mojom::Role::kTextFieldWithComboBox: // No role description. break; - case ui::AX_ROLE_TIME: + case ax::mojom::Role::kTime: message_id = IDS_AX_ROLE_TIME; break; - case ui::AX_ROLE_TIMER: + case ax::mojom::Role::kTimer: message_id = IDS_AX_ROLE_TIMER; break; - case ui::AX_ROLE_TITLE_BAR: + case ax::mojom::Role::kTitleBar: // No role description. break; - case ui::AX_ROLE_TOGGLE_BUTTON: + case ax::mojom::Role::kToggleButton: message_id = IDS_AX_ROLE_TOGGLE_BUTTON; break; - case ui::AX_ROLE_TOOLBAR: + case ax::mojom::Role::kToolbar: message_id = IDS_AX_ROLE_TOOLBAR; break; - case ui::AX_ROLE_TREE_GRID: + case ax::mojom::Role::kTreeGrid: message_id = IDS_AX_ROLE_TREE_GRID; break; - case ui::AX_ROLE_TREE_ITEM: + case ax::mojom::Role::kTreeItem: message_id = IDS_AX_ROLE_TREE_ITEM; break; - case ui::AX_ROLE_TREE: + case ax::mojom::Role::kTree: message_id = IDS_AX_ROLE_TREE; break; - case ui::AX_ROLE_UNKNOWN: + case ax::mojom::Role::kUnknown: // No role description. break; - case ui::AX_ROLE_TOOLTIP: + case ax::mojom::Role::kTooltip: message_id = IDS_AX_ROLE_TOOLTIP; break; - case ui::AX_ROLE_VIDEO: + case ax::mojom::Role::kVideo: message_id = IDS_AX_MEDIA_VIDEO_ELEMENT; break; - case ui::AX_ROLE_WEB_AREA: + case ax::mojom::Role::kWebArea: // No role description. break; - case ui::AX_ROLE_WEB_VIEW: + case ax::mojom::Role::kWebView: // No role description. break; - case ui::AX_ROLE_WINDOW: + case ax::mojom::Role::kWindow: // No role description. break; - case ui::AX_ROLE_NONE: + case ax::mojom::Role::kNone: // No role description. break; } @@ -865,17 +863,17 @@ int BrowserAccessibilityAndroid::GetItemIndex() const { if (IsRangeType()) { // Return a percentage here for live feedback in an AccessibilityEvent. // The exact value is returned in RangeCurrentValue. - float min = GetFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE); - float max = GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE); - float value = GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE); + float min = GetFloatAttribute(ax::mojom::FloatAttribute::kMinValueForRange); + float max = GetFloatAttribute(ax::mojom::FloatAttribute::kMaxValueForRange); + float value = GetFloatAttribute(ax::mojom::FloatAttribute::kValueForRange); if (max > min && value >= min && value <= max) index = static_cast(((value - min)) * 100 / (max - min)); } else { switch (GetRole()) { - case ui::AX_ROLE_LIST_ITEM: - case ui::AX_ROLE_LIST_BOX_OPTION: - case ui::AX_ROLE_TREE_ITEM: - index = GetIntAttribute(ui::AX_ATTR_POS_IN_SET) - 1; + case ax::mojom::Role::kListItem: + case ax::mojom::Role::kListBoxOption: + case ax::mojom::Role::kTreeItem: + index = GetIntAttribute(ax::mojom::IntAttribute::kPosInSet) - 1; break; default: break; @@ -893,9 +891,9 @@ int BrowserAccessibilityAndroid::GetItemCount() const { count = 100; } else { switch (GetRole()) { - case ui::AX_ROLE_LIST: - case ui::AX_ROLE_LIST_BOX: - case ui::AX_ROLE_DESCRIPTION_LIST: + case ax::mojom::Role::kList: + case ax::mojom::Role::kListBox: + case ax::mojom::Role::kDescriptionList: count = PlatformChildCount(); break; default: @@ -907,8 +905,8 @@ int BrowserAccessibilityAndroid::GetItemCount() const { bool BrowserAccessibilityAndroid::CanScrollForward() const { if (IsSlider()) { - float value = GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE); - float max = GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE); + float value = GetFloatAttribute(ax::mojom::FloatAttribute::kValueForRange); + float max = GetFloatAttribute(ax::mojom::FloatAttribute::kMaxValueForRange); return value < max; } else { return GetScrollX() < GetMaxScrollX() || @@ -918,8 +916,8 @@ bool BrowserAccessibilityAndroid::CanScrollForward() const { bool BrowserAccessibilityAndroid::CanScrollBackward() const { if (IsSlider()) { - float value = GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE); - float min = GetFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE); + float value = GetFloatAttribute(ax::mojom::FloatAttribute::kValueForRange); + float min = GetFloatAttribute(ax::mojom::FloatAttribute::kMinValueForRange); return value > min; } else { return GetScrollX() > GetMinScrollX() || @@ -945,50 +943,51 @@ bool BrowserAccessibilityAndroid::CanScrollRight() const { int BrowserAccessibilityAndroid::GetScrollX() const { int value = 0; - GetIntAttribute(ui::AX_ATTR_SCROLL_X, &value); + GetIntAttribute(ax::mojom::IntAttribute::kScrollX, &value); return value; } int BrowserAccessibilityAndroid::GetScrollY() const { int value = 0; - GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &value); + GetIntAttribute(ax::mojom::IntAttribute::kScrollY, &value); return value; } int BrowserAccessibilityAndroid::GetMinScrollX() const { - return GetIntAttribute(ui::AX_ATTR_SCROLL_X_MIN); + return GetIntAttribute(ax::mojom::IntAttribute::kScrollXMin); } int BrowserAccessibilityAndroid::GetMinScrollY() const { - return GetIntAttribute(ui::AX_ATTR_SCROLL_Y_MIN); + return GetIntAttribute(ax::mojom::IntAttribute::kScrollYMin); } int BrowserAccessibilityAndroid::GetMaxScrollX() const { - return GetIntAttribute(ui::AX_ATTR_SCROLL_X_MAX); + return GetIntAttribute(ax::mojom::IntAttribute::kScrollXMax); } int BrowserAccessibilityAndroid::GetMaxScrollY() const { - return GetIntAttribute(ui::AX_ATTR_SCROLL_Y_MAX); + return GetIntAttribute(ax::mojom::IntAttribute::kScrollYMax); } bool BrowserAccessibilityAndroid::Scroll(int direction) const { - int x_initial = GetIntAttribute(ui::AX_ATTR_SCROLL_X); - int x_min = GetIntAttribute(ui::AX_ATTR_SCROLL_X_MIN); - int x_max = GetIntAttribute(ui::AX_ATTR_SCROLL_X_MAX); - int y_initial = GetIntAttribute(ui::AX_ATTR_SCROLL_Y); - int y_min = GetIntAttribute(ui::AX_ATTR_SCROLL_Y_MIN); - int y_max = GetIntAttribute(ui::AX_ATTR_SCROLL_Y_MAX); + int x_initial = GetIntAttribute(ax::mojom::IntAttribute::kScrollX); + int x_min = GetIntAttribute(ax::mojom::IntAttribute::kScrollXMin); + int x_max = GetIntAttribute(ax::mojom::IntAttribute::kScrollXMax); + int y_initial = GetIntAttribute(ax::mojom::IntAttribute::kScrollY); + int y_min = GetIntAttribute(ax::mojom::IntAttribute::kScrollYMin); + int y_max = GetIntAttribute(ax::mojom::IntAttribute::kScrollYMax); // Figure out the bounding box of the visible portion of this scrollable // view so we know how much to scroll by. gfx::Rect bounds; - if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA && !PlatformGetParent()) { + if (GetRole() == ax::mojom::Role::kRootWebArea && !PlatformGetParent()) { // If this is the root web area, use the bounds of the view to determine // how big one page is. if (!manager()->delegate()) return false; bounds = manager()->delegate()->AccessibilityGetViewBounds(); - } else if (GetRole() == ui::AX_ROLE_ROOT_WEB_AREA && PlatformGetParent()) { + } else if (GetRole() == ax::mojom::Role::kRootWebArea && + PlatformGetParent()) { // If this is a web area inside of an iframe, try to use the bounds of // the containing element. BrowserAccessibility* parent = PlatformGetParent(); @@ -1122,13 +1121,13 @@ base::string16 BrowserAccessibilityAndroid::GetTextChangeBeforeText() const { int BrowserAccessibilityAndroid::GetSelectionStart() const { int sel_start = 0; - GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, &sel_start); + GetIntAttribute(ax::mojom::IntAttribute::kTextSelStart, &sel_start); return sel_start; } int BrowserAccessibilityAndroid::GetSelectionEnd() const { int sel_end = 0; - GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, &sel_end); + GetIntAttribute(ax::mojom::IntAttribute::kTextSelEnd, &sel_end); return sel_end; } @@ -1138,8 +1137,8 @@ int BrowserAccessibilityAndroid::GetEditableTextLength() const { } int BrowserAccessibilityAndroid::AndroidInputType() const { - std::string html_tag = GetStringAttribute( - ui::AX_ATTR_HTML_TAG); + std::string html_tag = + GetStringAttribute(ax::mojom::StringAttribute::kHtmlTag); if (html_tag != "input") return ANDROID_TEXT_INPUTTYPE_TYPE_NULL; @@ -1174,8 +1173,8 @@ int BrowserAccessibilityAndroid::AndroidInputType() const { } int BrowserAccessibilityAndroid::AndroidLiveRegionType() const { - std::string live = GetStringAttribute( - ui::AX_ATTR_LIVE_STATUS); + std::string live = + GetStringAttribute(ax::mojom::StringAttribute::kLiveStatus); if (live == "polite") return ANDROID_VIEW_VIEW_ACCESSIBILITY_LIVE_REGION_POLITE; else if (live == "assertive") @@ -1189,13 +1188,13 @@ int BrowserAccessibilityAndroid::AndroidRangeType() const { int BrowserAccessibilityAndroid::RowCount() const { if (ui::IsTableLikeRole(GetRole())) { - return CountChildrenWithRole(ui::AX_ROLE_ROW); + return CountChildrenWithRole(ax::mojom::Role::kRow); } - if (GetRole() == ui::AX_ROLE_LIST || - GetRole() == ui::AX_ROLE_LIST_BOX || - GetRole() == ui::AX_ROLE_DESCRIPTION_LIST || - GetRole() == ui::AX_ROLE_TREE) { + if (GetRole() == ax::mojom::Role::kList || + GetRole() == ax::mojom::Role::kListBox || + GetRole() == ax::mojom::Role::kDescriptionList || + GetRole() == ax::mojom::Role::kTree) { return PlatformChildCount(); } @@ -1204,43 +1203,43 @@ int BrowserAccessibilityAndroid::RowCount() const { int BrowserAccessibilityAndroid::ColumnCount() const { if (ui::IsTableLikeRole(GetRole())) { - return CountChildrenWithRole(ui::AX_ROLE_COLUMN); + return CountChildrenWithRole(ax::mojom::Role::kColumn); } return 0; } int BrowserAccessibilityAndroid::RowIndex() const { - if (GetRole() == ui::AX_ROLE_LIST_ITEM || - GetRole() == ui::AX_ROLE_LIST_BOX_OPTION || - GetRole() == ui::AX_ROLE_TREE_ITEM) { + if (GetRole() == ax::mojom::Role::kListItem || + GetRole() == ax::mojom::Role::kListBoxOption || + GetRole() == ax::mojom::Role::kTreeItem) { return GetIndexInParent(); } - return GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX); + return GetIntAttribute(ax::mojom::IntAttribute::kTableCellRowIndex); } int BrowserAccessibilityAndroid::RowSpan() const { - return GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_SPAN); + return GetIntAttribute(ax::mojom::IntAttribute::kTableCellRowSpan); } int BrowserAccessibilityAndroid::ColumnIndex() const { - return GetIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX); + return GetIntAttribute(ax::mojom::IntAttribute::kTableCellColumnIndex); } int BrowserAccessibilityAndroid::ColumnSpan() const { - return GetIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN); + return GetIntAttribute(ax::mojom::IntAttribute::kTableCellColumnSpan); } float BrowserAccessibilityAndroid::RangeMin() const { - return GetFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE); + return GetFloatAttribute(ax::mojom::FloatAttribute::kMinValueForRange); } float BrowserAccessibilityAndroid::RangeMax() const { - return GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE); + return GetFloatAttribute(ax::mojom::FloatAttribute::kMaxValueForRange); } float BrowserAccessibilityAndroid::RangeCurrentValue() const { - return GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE); + return GetFloatAttribute(ax::mojom::FloatAttribute::kValueForRange); } void BrowserAccessibilityAndroid::GetGranularityBoundaries( @@ -1272,12 +1271,12 @@ void BrowserAccessibilityAndroid::GetLineBoundaries( // If this is a static text node, get the line boundaries from the // inline text boxes if possible. - if (GetRole() == ui::AX_ROLE_STATIC_TEXT) { + if (GetRole() == ax::mojom::Role::kStaticText) { int last_y = 0; for (uint32_t i = 0; i < InternalChildCount(); i++) { BrowserAccessibilityAndroid* child = static_cast(InternalGetChild(i)); - CHECK_EQ(ui::AX_ROLE_INLINE_TEXT_BOX, child->GetRole()); + CHECK_EQ(ax::mojom::Role::kInlineTextBox, child->GetRole()); // TODO(dmazzoni): replace this with a proper API to determine // if two inline text boxes are on the same line. http://crbug.com/421771 int y = child->GetPageBoundsRect().y(); @@ -1307,11 +1306,11 @@ void BrowserAccessibilityAndroid::GetWordBoundaries( std::vector* word_starts, std::vector* word_ends, int offset) { - if (GetRole() == ui::AX_ROLE_INLINE_TEXT_BOX) { + if (GetRole() == ax::mojom::Role::kInlineTextBox) { const std::vector& starts = - GetIntListAttribute(ui::AX_ATTR_WORD_STARTS); + GetIntListAttribute(ax::mojom::IntListAttribute::kWordStarts); const std::vector& ends = - GetIntListAttribute(ui::AX_ATTR_WORD_ENDS); + GetIntListAttribute(ax::mojom::IntListAttribute::kWordEnds); for (size_t i = 0; i < starts.size(); ++i) { word_starts->push_back(offset + starts[i]); word_ends->push_back(offset + ends[i]); @@ -1358,8 +1357,8 @@ bool BrowserAccessibilityAndroid::HasFocusableNonOptionChild() const { // from within this! for (uint32_t i = 0; i < InternalChildCount(); i++) { BrowserAccessibility* child = InternalGetChild(i); - if (child->HasState(ui::AX_STATE_FOCUSABLE) && - child->GetRole() != ui::AX_ROLE_MENU_LIST_OPTION) + if (child->HasState(ax::mojom::State::kFocusable) && + child->GetRole() != ax::mojom::Role::kMenuListOption) return true; if (static_cast(child) ->HasFocusableNonOptionChild()) @@ -1388,8 +1387,8 @@ bool BrowserAccessibilityAndroid::HasOnlyTextAndImageChildren() const { // from within this! for (uint32_t i = 0; i < InternalChildCount(); i++) { BrowserAccessibility* child = InternalGetChild(i); - if (child->GetRole() != ui::AX_ROLE_STATIC_TEXT && - child->GetRole() != ui::AX_ROLE_IMAGE) { + if (child->GetRole() != ax::mojom::Role::kStaticText && + child->GetRole() != ax::mojom::Role::kImage) { return false; } } @@ -1397,8 +1396,8 @@ bool BrowserAccessibilityAndroid::HasOnlyTextAndImageChildren() const { } bool BrowserAccessibilityAndroid::IsIframe() const { - return (GetRole() == ui::AX_ROLE_IFRAME || - GetRole() == ui::AX_ROLE_IFRAME_PRESENTATIONAL); + return (GetRole() == ax::mojom::Role::kIframe || + GetRole() == ax::mojom::Role::kIframePresentational); } bool BrowserAccessibilityAndroid::ShouldExposeValueAsName() const { @@ -1406,13 +1405,13 @@ bool BrowserAccessibilityAndroid::ShouldExposeValueAsName() const { if (value.empty()) return false; - if (HasState(ui::AX_STATE_EDITABLE)) + if (HasState(ax::mojom::State::kEditable)) return true; switch (GetRole()) { - case ui::AX_ROLE_POP_UP_BUTTON: - case ui::AX_ROLE_TEXT_FIELD: - case ui::AX_ROLE_TEXT_FIELD_WITH_COMBO_BOX: + case ax::mojom::Role::kPopUpButton: + case ax::mojom::Role::kTextField: + case ax::mojom::Role::kTextFieldWithComboBox: return true; default: break; @@ -1433,7 +1432,8 @@ void BrowserAccessibilityAndroid::OnDataChanged() { } } -int BrowserAccessibilityAndroid::CountChildrenWithRole(ui::AXRole role) const { +int BrowserAccessibilityAndroid::CountChildrenWithRole( + ax::mojom::Role role) const { int count = 0; for (uint32_t i = 0; i < PlatformChildCount(); i++) { if (PlatformGetChild(i)->GetRole() == role) diff --git a/content/browser/accessibility/browser_accessibility_android.h b/content/browser/accessibility/browser_accessibility_android.h index 8ac237a8a4a9f9..51401427942807 100644 --- a/content/browser/accessibility/browser_accessibility_android.h +++ b/content/browser/accessibility/browser_accessibility_android.h @@ -155,7 +155,7 @@ class CONTENT_EXPORT BrowserAccessibilityAndroid : public BrowserAccessibility { bool IsIframe() const; bool ShouldExposeValueAsName() const; - int CountChildrenWithRole(ui::AXRole role) const; + int CountChildrenWithRole(ax::mojom::Role role) const; static size_t CommonPrefixLength(const base::string16 a, const base::string16 b); diff --git a/content/browser/accessibility/browser_accessibility_cocoa.h b/content/browser/accessibility/browser_accessibility_cocoa.h index 599882f102846d..a03585269db635 100644 --- a/content/browser/accessibility/browser_accessibility_cocoa.h +++ b/content/browser/accessibility/browser_accessibility_cocoa.h @@ -55,7 +55,7 @@ struct AXTextEdit { // Convenience method to get the internal, cross-platform role // from browserAccessibility_. -- (ui::AXRole)internalRole; +- (ax::mojom::Role)internalRole; // Convenience method to get the BrowserAccessibilityDelegate from // the manager. diff --git a/content/browser/accessibility/browser_accessibility_cocoa.mm b/content/browser/accessibility/browser_accessibility_cocoa.mm index 6b68a59ddad2cb..079b544af6f983 100644 --- a/content/browser/accessibility/browser_accessibility_cocoa.mm +++ b/content/browser/accessibility/browser_accessibility_cocoa.mm @@ -38,7 +38,7 @@ ui::AXRange; using AXTextMarkerRangeRef = CFTypeRef; using AXTextMarkerRef = CFTypeRef; -using StringAttribute = ui::AXStringAttribute; +using StringAttribute = ax::mojom::StringAttribute; using content::BrowserAccessibilityPosition; using content::AccessibilityMatchPredicate; using content::BrowserAccessibility; @@ -214,7 +214,7 @@ AXPlatformRange CreateRangeFromTextMarkerRange( BrowserAccessibilityPositionInstance CreateTextPosition( const BrowserAccessibility& object, int offset, - ui::AXTextAffinity affinity) { + ax::mojom::TextAffinity affinity) { if (!object.instance_active()) return BrowserAccessibilityPosition::CreateNullPosition(); @@ -226,10 +226,10 @@ BrowserAccessibilityPositionInstance CreateTextPosition( AXPlatformRange CreateTextRange(const BrowserAccessibility& start_object, int start_offset, - ui::AXTextAffinity start_affinity, + ax::mojom::TextAffinity start_affinity, const BrowserAccessibility& end_object, int end_offset, - ui::AXTextAffinity end_affinity) { + ax::mojom::TextAffinity end_affinity) { BrowserAccessibilityPositionInstance anchor = CreateTextPosition(start_object, start_offset, start_affinity); BrowserAccessibilityPositionInstance focus = @@ -243,15 +243,15 @@ void AddMisspelledTextAttributes( NSMutableAttributedString* attributed_string) { [attributed_string beginEditing]; for (const BrowserAccessibility* text_object : text_only_objects) { - const std::vector& marker_types = - text_object->GetIntListAttribute(ui::AX_ATTR_MARKER_TYPES); - const std::vector& marker_starts = - text_object->GetIntListAttribute(ui::AX_ATTR_MARKER_STARTS); - const std::vector& marker_ends = - text_object->GetIntListAttribute(ui::AX_ATTR_MARKER_ENDS); + const std::vector& marker_types = text_object->GetIntListAttribute( + ax::mojom::IntListAttribute::kMarkerTypes); + const std::vector& marker_starts = text_object->GetIntListAttribute( + ax::mojom::IntListAttribute::kMarkerStarts); + const std::vector& marker_ends = text_object->GetIntListAttribute( + ax::mojom::IntListAttribute::kMarkerEnds); for (size_t i = 0; i < marker_types.size(); ++i) { if (!(marker_types[i] & - static_cast(ui::AX_MARKER_TYPE_SPELLING))) { + static_cast(ax::mojom::MarkerType::kSpelling))) { continue; } @@ -280,7 +280,7 @@ void AddMisspelledTextAttributes( BrowserAccessibility* start_object; BrowserAccessibility* end_object; int start_offset, end_offset; - ui::AXTextAffinity start_affinity, end_affinity; + ax::mojom::TextAffinity start_affinity, end_affinity; AXPlatformRange ax_range = CreateRangeFromTextMarkerRange(marker_range); if (ax_range.IsNull()) return nil; @@ -336,7 +336,7 @@ void AddMisspelledTextAttributes( // GetState checks the bitmask used in AXNodeData to check // if the given state was set on the accessibility object. -bool GetState(BrowserAccessibility* accessibility, ui::AXState state) { +bool GetState(BrowserAccessibility* accessibility, ax::mojom::State state) { return accessibility->GetData().HasState(state); } @@ -664,31 +664,31 @@ - (void)detach { - (NSString*)accessKey { if (![self instanceActive]) return nil; - return NSStringForStringAttribute( - browserAccessibility_, ui::AX_ATTR_ACCESS_KEY); + return NSStringForStringAttribute(browserAccessibility_, + ax::mojom::StringAttribute::kAccessKey); } - (NSNumber*)ariaAtomic { if (![self instanceActive]) return nil; bool boolValue = browserAccessibility_->GetBoolAttribute( - ui::AX_ATTR_LIVE_ATOMIC); + ax::mojom::BoolAttribute::kLiveAtomic); return [NSNumber numberWithBool:boolValue]; } - (NSNumber*)ariaBusy { if (![self instanceActive]) return nil; - return [NSNumber - numberWithBool:browserAccessibility_->GetBoolAttribute(ui::AX_ATTR_BUSY)]; + return [NSNumber numberWithBool:browserAccessibility_->GetBoolAttribute( + ax::mojom::BoolAttribute::kBusy)]; } - (NSNumber*)ariaColumnCount { if (!ui::IsTableLikeRole(browserAccessibility_->GetRole())) return nil; int count = -1; - if (!browserAccessibility_->GetIntAttribute(ui::AX_ATTR_ARIA_COLUMN_COUNT, - &count)) { + if (!browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kAriaColumnCount, &count)) { return nil; } return [NSNumber numberWithInt:count]; @@ -699,7 +699,7 @@ - (NSNumber*)ariaColumnIndex { return nil; int index = -1; if (!browserAccessibility_->GetIntAttribute( - ui::AX_ATTR_ARIA_CELL_COLUMN_INDEX, &index)) { + ax::mojom::IntAttribute::kAriaCellColumnIndex, &index)) { return nil; } return [NSNumber numberWithInt:index]; @@ -708,30 +708,30 @@ - (NSNumber*)ariaColumnIndex { - (NSString*)ariaLive { if (![self instanceActive]) return nil; - return NSStringForStringAttribute( - browserAccessibility_, ui::AX_ATTR_LIVE_STATUS); + return NSStringForStringAttribute(browserAccessibility_, + ax::mojom::StringAttribute::kLiveStatus); } - (NSNumber*)ariaPosInSet { if (![self instanceActive]) return nil; - return [NSNumber numberWithInt: - browserAccessibility_->GetIntAttribute(ui::AX_ATTR_POS_IN_SET)]; + return [NSNumber numberWithInt:browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kPosInSet)]; } - (NSString*)ariaRelevant { if (![self instanceActive]) return nil; return NSStringForStringAttribute(browserAccessibility_, - ui::AX_ATTR_LIVE_RELEVANT); + ax::mojom::StringAttribute::kLiveRelevant); } - (NSNumber*)ariaRowCount { if (!ui::IsTableLikeRole(browserAccessibility_->GetRole())) return nil; int count = -1; - if (!browserAccessibility_->GetIntAttribute(ui::AX_ATTR_ARIA_ROW_COUNT, - &count)) { + if (!browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kAriaRowCount, &count)) { return nil; } return [NSNumber numberWithInt:count]; @@ -741,8 +741,8 @@ - (NSNumber*)ariaRowIndex { if (!ui::IsCellOrTableHeaderRole(browserAccessibility_->GetRole())) return nil; int index = -1; - if (!browserAccessibility_->GetIntAttribute(ui::AX_ATTR_ARIA_CELL_ROW_INDEX, - &index)) { + if (!browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kAriaCellRowIndex, &index)) { return nil; } return [NSNumber numberWithInt:index]; @@ -751,8 +751,8 @@ - (NSNumber*)ariaRowIndex { - (NSNumber*)ariaSetSize { if (![self instanceActive]) return nil; - return [NSNumber numberWithInt: - browserAccessibility_->GetIntAttribute(ui::AX_ATTR_SET_SIZE)]; + return [NSNumber numberWithInt:browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kSetSize)]; } // Returns an array of BrowserAccessibilityCocoa objects, representing the @@ -776,7 +776,7 @@ - (NSArray*)children { // Also, add indirect children (if any). const std::vector& indirectChildIds = browserAccessibility_->GetIntListAttribute( - ui::AX_ATTR_INDIRECT_CHILD_IDS); + ax::mojom::IntListAttribute::kIndirectChildIds); for (uint32_t i = 0; i < indirectChildIds.size(); ++i) { int32_t child_id = indirectChildIds[i]; BrowserAccessibility* child = @@ -808,32 +808,33 @@ - (void)childrenChanged { - (BOOL)isColumnHeaderForCurrentCell:(BrowserAccessibility*)header { int cell_first_col = -1; int cell_colspan = -1; - browserAccessibility_->GetIntAttribute(ui::AX_ATTR_ARIA_CELL_COLUMN_INDEX, - &cell_first_col); + browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kAriaCellColumnIndex, &cell_first_col); if (cell_first_col < 0) { - browserAccessibility_->GetIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, - &cell_first_col); + browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kTableCellColumnIndex, &cell_first_col); } if (cell_first_col < 0) return false; - browserAccessibility_->GetIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN, - &cell_colspan); + browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kTableCellColumnSpan, &cell_colspan); if (cell_colspan <= 0) cell_colspan = 1; int cell_last_col = cell_first_col + cell_colspan - 1; int header_first_col = -1; int header_colspan = -1; - header->GetIntAttribute(ui::AX_ATTR_ARIA_CELL_COLUMN_INDEX, + header->GetIntAttribute(ax::mojom::IntAttribute::kAriaCellColumnIndex, &header_first_col); if (header_first_col < 0) { - header->GetIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, + header->GetIntAttribute(ax::mojom::IntAttribute::kTableCellColumnIndex, &header_first_col); } if (header_first_col < 0) return false; - header->GetIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN, &header_colspan); + header->GetIntAttribute(ax::mojom::IntAttribute::kTableCellColumnSpan, + &header_colspan); if (header_colspan <= 0) header_colspan = 1; int header_last_col = header_first_col + header_colspan - 1; @@ -860,12 +861,12 @@ - (NSArray*)columnHeaders { NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; const std::vector& uniqueCellIds = - table->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); + table->GetIntListAttribute(ax::mojom::IntListAttribute::kUniqueCellIds); for (size_t i = 0; i < uniqueCellIds.size(); ++i) { int id = uniqueCellIds[i]; BrowserAccessibility* cell = browserAccessibility_->manager()->GetFromID(id); - if (cell && cell->GetRole() == ui::AX_ROLE_COLUMN_HEADER) { + if (cell && cell->GetRole() == ax::mojom::Role::kColumnHeader) { // Expose all column headers on table object. // Expose only relevant column headers on cell object. if (is_table_like || [self isColumnHeaderForCurrentCell:cell]) @@ -884,9 +885,9 @@ - (NSValue*)columnIndexRange { int column = -1; int colspan = -1; browserAccessibility_->GetIntAttribute( - ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, &column); + ax::mojom::IntAttribute::kTableCellColumnIndex, &column); browserAccessibility_->GetIntAttribute( - ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN, &colspan); + ax::mojom::IntAttribute::kTableCellColumnSpan, &colspan); if (column >= 0 && colspan >= 1) return [NSValue valueWithRange:NSMakeRange(column, colspan)]; return nil; @@ -924,17 +925,18 @@ - (NSString*)description { if ([self shouldExposeTitleUIElement]) return @""; - ui::AXNameFrom nameFrom = static_cast( - browserAccessibility_->GetIntAttribute(ui::AX_ATTR_NAME_FROM)); + ax::mojom::NameFrom nameFrom = + static_cast(browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kNameFrom)); std::string name = browserAccessibility_->GetStringAttribute( - ui::AX_ATTR_NAME); + ax::mojom::StringAttribute::kName); if (!name.empty()) { // On Mac OS X, the accessible name of an object is exposed as its // title if it comes from visible text, and as its description // otherwise, but never both. - if (nameFrom == ui::AX_NAME_FROM_CONTENTS || - nameFrom == ui::AX_NAME_FROM_RELATED_ELEMENT || - nameFrom == ui::AX_NAME_FROM_VALUE) { + if (nameFrom == ax::mojom::NameFrom::kContents || + nameFrom == ax::mojom::NameFrom::kRelatedElement || + nameFrom == ax::mojom::NameFrom::kValue) { return @""; } else { return base::SysUTF8ToNSString(name); @@ -949,7 +951,7 @@ - (NSString*)description { std::string url; if (browserAccessibility_->GetStringAttribute( - ui::AX_ATTR_URL, &url)) { + ax::mojom::StringAttribute::kUrl, &url)) { // Given a url like http://foo.com/bar/baz.png, just return the // base name, e.g., "baz.png". size_t leftIndex = url.rfind('/'); @@ -962,11 +964,11 @@ - (NSString*)description { // If it's focusable but didn't have any other name or value, compute a name // from its descendants. base::string16 value = browserAccessibility_->GetValue(); - if (browserAccessibility_->HasState(ui::AX_STATE_FOCUSABLE) && + if (browserAccessibility_->HasState(ax::mojom::State::kFocusable) && !ui::IsControl(browserAccessibility_->GetRole()) && value.empty() && - [self internalRole] != ui::AX_ROLE_DATE_TIME && - [self internalRole] != ui::AX_ROLE_WEB_AREA && - [self internalRole] != ui::AX_ROLE_ROOT_WEB_AREA) { + [self internalRole] != ax::mojom::Role::kDateTime && + [self internalRole] != ax::mojom::Role::kWebArea && + [self internalRole] != ax::mojom::Role::kRootWebArea) { return base::SysUTF8ToNSString( browserAccessibility_->ComputeAccessibleNameFromDescendants()); } @@ -977,9 +979,9 @@ - (NSString*)description { - (NSNumber*)disclosing { if (![self instanceActive]) return nil; - if ([self internalRole] == ui::AX_ROLE_TREE_ITEM) { - return [NSNumber numberWithBool: - GetState(browserAccessibility_, ui::AX_STATE_EXPANDED)]; + if ([self internalRole] == ax::mojom::Role::kTreeItem) { + return [NSNumber numberWithBool:GetState(browserAccessibility_, + ax::mojom::State::kExpanded)]; } else { return nil; } @@ -997,11 +999,10 @@ - (id)disclosedByRow { - (NSNumber*)disclosureLevel { if (![self instanceActive]) return nil; - ui::AXRole role = [self internalRole]; - if (role == ui::AX_ROLE_ROW || - role == ui::AX_ROLE_TREE_ITEM) { + ax::mojom::Role role = [self internalRole]; + if (role == ax::mojom::Role::kRow || role == ax::mojom::Role::kTreeItem) { int level = browserAccessibility_->GetIntAttribute( - ui::AX_ATTR_HIERARCHICAL_LEVEL); + ax::mojom::IntAttribute::kHierarchicalLevel); // Mac disclosureLevel is 0-based, but web levels are 1-based. if (level > 0) level--; @@ -1047,7 +1048,7 @@ - (id)editableAncestor { BrowserAccessibilityCocoa* editableRoot = self; while (![editableRoot browserAccessibility]->GetBoolAttribute( - ui::AX_ATTR_EDITABLE_ROOT)) { + ax::mojom::BoolAttribute::kEditableRoot)) { BrowserAccessibilityCocoa* parent = [editableRoot parent]; if (!parent || ![parent isKindOfClass:[self class]] || ![parent instanceActive]) { @@ -1063,7 +1064,7 @@ - (NSNumber*)enabled { return nil; return [NSNumber numberWithBool:browserAccessibility_->GetData().GetRestriction() != - ui::AX_RESTRICTION_DISABLED]; + ax::mojom::Restriction::kDisabled]; } // Returns a text marker that points to the last character in the document that @@ -1081,8 +1082,8 @@ - (id)endTextMarker { - (NSNumber*)expanded { if (![self instanceActive]) return nil; - return [NSNumber numberWithBool: - GetState(browserAccessibility_, ui::AX_STATE_EXPANDED)]; + return [NSNumber numberWithBool:GetState(browserAccessibility_, + ax::mojom::State::kExpanded)]; } - (NSNumber*)focused { @@ -1111,13 +1112,13 @@ - (id)header { int headerElementId = -1; if (ui::IsTableLikeRole(browserAccessibility_->GetRole())) { browserAccessibility_->GetIntAttribute( - ui::AX_ATTR_TABLE_HEADER_ID, &headerElementId); - } else if ([self internalRole] == ui::AX_ROLE_COLUMN) { + ax::mojom::IntAttribute::kTableHeaderId, &headerElementId); + } else if ([self internalRole] == ax::mojom::Role::kColumn) { browserAccessibility_->GetIntAttribute( - ui::AX_ATTR_TABLE_COLUMN_HEADER_ID, &headerElementId); - } else if ([self internalRole] == ui::AX_ROLE_ROW) { + ax::mojom::IntAttribute::kTableColumnHeaderId, &headerElementId); + } else if ([self internalRole] == ax::mojom::Role::kRow) { browserAccessibility_->GetIntAttribute( - ui::AX_ATTR_TABLE_ROW_HEADER_ID, &headerElementId); + ax::mojom::IntAttribute::kTableRowHeaderId, &headerElementId); } if (headerElementId > 0) { @@ -1132,8 +1133,8 @@ - (id)header { - (NSString*)help { if (![self instanceActive]) return nil; - return NSStringForStringAttribute( - browserAccessibility_, ui::AX_ATTR_DESCRIPTION); + return NSStringForStringAttribute(browserAccessibility_, + ax::mojom::StringAttribute::kDescription); } - (id)highestEditableAncestor { @@ -1159,13 +1160,13 @@ - (id)highestEditableAncestor { - (NSNumber*)index { if (![self instanceActive]) return nil; - if ([self internalRole] == ui::AX_ROLE_COLUMN) { + if ([self internalRole] == ax::mojom::Role::kColumn) { int columnIndex = browserAccessibility_->GetIntAttribute( - ui::AX_ATTR_TABLE_COLUMN_INDEX); + ax::mojom::IntAttribute::kTableColumnIndex); return [NSNumber numberWithInt:columnIndex]; - } else if ([self internalRole] == ui::AX_ROLE_ROW) { + } else if ([self internalRole] == ax::mojom::Role::kRow) { int rowIndex = browserAccessibility_->GetIntAttribute( - ui::AX_ATTR_TABLE_ROW_INDEX); + ax::mojom::IntAttribute::kTableRowIndex); return [NSNumber numberWithInt:rowIndex]; } @@ -1178,10 +1179,10 @@ - (NSNumber*)insertionPointLineNumber { // TODO(nektar): Deprecate sel_start and sel_end attributes. int selStart, selEnd; - if (!browserAccessibility_->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, - &selStart) || - !browserAccessibility_->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, - &selEnd)) { + if (!browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kTextSelStart, &selStart) || + !browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kTextSelEnd, &selEnd)) { return nil; } @@ -1211,23 +1212,22 @@ - (NSString*)invalid { return nil; int invalidState; if (!browserAccessibility_->GetIntAttribute( - ui::AX_ATTR_INVALID_STATE, &invalidState)) + ax::mojom::IntAttribute::kInvalidState, &invalidState)) return @"false"; - switch (static_cast(invalidState)) { - case ui::AX_INVALID_STATE_FALSE: + switch (static_cast(invalidState)) { + case ax::mojom::InvalidState::kFalse: return @"false"; - case ui::AX_INVALID_STATE_TRUE: + case ax::mojom::InvalidState::kTrue: return @"true"; - case ui::AX_INVALID_STATE_SPELLING: + case ax::mojom::InvalidState::kSpelling: return @"spelling"; - case ui::AX_INVALID_STATE_GRAMMAR: + case ax::mojom::InvalidState::kGrammar: return @"grammar"; - case ui::AX_INVALID_STATE_OTHER: { + case ax::mojom::InvalidState::kOther: { std::string ariaInvalidValue; if (browserAccessibility_->GetStringAttribute( - ui::AX_ATTR_ARIA_INVALID_VALUE, - &ariaInvalidValue)) + ax::mojom::StringAttribute::kAriaInvalidValue, &ariaInvalidValue)) return base::SysUTF8ToNSString(ariaInvalidValue); // Return @"true" since we cannot be more specific about the value. return @"true"; @@ -1243,39 +1243,42 @@ - (NSNumber*)isMultiSelectable { if (![self instanceActive]) return nil; return [NSNumber numberWithBool:GetState(browserAccessibility_, - ui::AX_STATE_MULTISELECTABLE)]; + ax::mojom::State::kMultiselectable)]; } - (NSString*)placeholderValue { if (![self instanceActive]) return nil; - ui::AXNameFrom nameFrom = static_cast( - browserAccessibility_->GetIntAttribute(ui::AX_ATTR_NAME_FROM)); - if (nameFrom == ui::AX_NAME_FROM_PLACEHOLDER) { - return NSStringForStringAttribute( - browserAccessibility_, ui::AX_ATTR_NAME); + ax::mojom::NameFrom nameFrom = + static_cast(browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kNameFrom)); + if (nameFrom == ax::mojom::NameFrom::kPlaceholder) { + return NSStringForStringAttribute(browserAccessibility_, + ax::mojom::StringAttribute::kName); } - ui::AXDescriptionFrom descriptionFrom = static_cast( - browserAccessibility_->GetIntAttribute(ui::AX_ATTR_DESCRIPTION_FROM)); - if (descriptionFrom == ui::AX_DESCRIPTION_FROM_PLACEHOLDER) { - return NSStringForStringAttribute( - browserAccessibility_, ui::AX_ATTR_DESCRIPTION); + ax::mojom::DescriptionFrom descriptionFrom = + static_cast( + browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kDescriptionFrom)); + if (descriptionFrom == ax::mojom::DescriptionFrom::kPlaceholder) { + return NSStringForStringAttribute(browserAccessibility_, + ax::mojom::StringAttribute::kDescription); } - return NSStringForStringAttribute( - browserAccessibility_, ui::AX_ATTR_PLACEHOLDER); + return NSStringForStringAttribute(browserAccessibility_, + ax::mojom::StringAttribute::kPlaceholder); } - (NSString*)language { if (![self instanceActive]) return nil; return NSStringForStringAttribute(browserAccessibility_, - ui::AX_ATTR_LANGUAGE); + ax::mojom::StringAttribute::kLanguage); } // private -- (void)addLinkedUIElementsFromAttribute:(ui::AXIntListAttribute)attribute +- (void)addLinkedUIElementsFromAttribute:(ax::mojom::IntListAttribute)attribute addTo:(NSMutableArray*)outArray { const std::vector& attributeValues = browserAccessibility_->GetIntListAttribute(attribute); @@ -1290,19 +1293,24 @@ - (void)addLinkedUIElementsFromAttribute:(ui::AXIntListAttribute)attribute // private - (NSArray*)linkedUIElements { NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; - [self addLinkedUIElementsFromAttribute:ui::AX_ATTR_CONTROLS_IDS addTo:ret]; - [self addLinkedUIElementsFromAttribute:ui::AX_ATTR_FLOWTO_IDS addTo:ret]; + [self + addLinkedUIElementsFromAttribute:ax::mojom::IntListAttribute::kControlsIds + addTo:ret]; + [self addLinkedUIElementsFromAttribute:ax::mojom::IntListAttribute::kFlowtoIds + addTo:ret]; int target_id; - if (browserAccessibility_->GetIntAttribute(ui::AX_ATTR_IN_PAGE_LINK_TARGET_ID, - &target_id)) { + if (browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kInPageLinkTargetId, &target_id)) { BrowserAccessibility* target = browserAccessibility_->manager()->GetFromID( static_cast(target_id)); if (target) [ret addObject:ToBrowserAccessibilityCocoa(target)]; } - [self addLinkedUIElementsFromAttribute:ui::AX_ATTR_RADIO_GROUP_IDS addTo:ret]; + [self addLinkedUIElementsFromAttribute:ax::mojom::IntListAttribute:: + kRadioGroupIds + addTo:ret]; if ([ret count] == 0) return nil; return ret; @@ -1326,7 +1334,7 @@ - (NSNumber*)maxValue { if (![self instanceActive]) return nil; float floatValue = browserAccessibility_->GetFloatAttribute( - ui::AX_ATTR_MAX_VALUE_FOR_RANGE); + ax::mojom::FloatAttribute::kMaxValueForRange); return [NSNumber numberWithFloat:floatValue]; } @@ -1334,16 +1342,16 @@ - (NSNumber*)minValue { if (![self instanceActive]) return nil; float floatValue = browserAccessibility_->GetFloatAttribute( - ui::AX_ATTR_MIN_VALUE_FOR_RANGE); + ax::mojom::FloatAttribute::kMinValueForRange); return [NSNumber numberWithFloat:floatValue]; } - (NSString*)orientation { if (![self instanceActive]) return nil; - if (GetState(browserAccessibility_, ui::AX_STATE_VERTICAL)) + if (GetState(browserAccessibility_, ax::mojom::State::kVertical)) return NSAccessibilityVerticalOrientationValue; - else if (GetState(browserAccessibility_, ui::AX_STATE_HORIZONTAL)) + else if (GetState(browserAccessibility_, ax::mojom::State::kHorizontal)) return NSAccessibilityHorizontalOrientationValue; return @""; @@ -1396,14 +1404,14 @@ - (NSValue*)position { - (NSNumber*)required { if (![self instanceActive]) return nil; - return [NSNumber numberWithBool: - GetState(browserAccessibility_, ui::AX_STATE_REQUIRED)]; + return [NSNumber numberWithBool:GetState(browserAccessibility_, + ax::mojom::State::kRequired)]; } // Returns an enum indicating the role from browserAccessibility_. // internal -- (ui::AXRole)internalRole { - return static_cast(browserAccessibility_->GetRole()); +- (ax::mojom::Role)internalRole { + return static_cast(browserAccessibility_->GetRole()); } // Returns true if this object should expose its accessible name using @@ -1416,13 +1424,15 @@ - (BOOL)shouldExposeTitleUIElement { if (!ui::IsControl(browserAccessibility_->GetRole())) return false; - ui::AXNameFrom nameFrom = static_cast( - browserAccessibility_->GetIntAttribute(ui::AX_ATTR_NAME_FROM)); - if (nameFrom != ui::AX_NAME_FROM_RELATED_ELEMENT) + ax::mojom::NameFrom nameFrom = + static_cast(browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kNameFrom)); + if (nameFrom != ax::mojom::NameFrom::kRelatedElement) return false; std::vector labelledby_ids = - browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_LABELLEDBY_IDS); + browserAccessibility_->GetIntListAttribute( + ax::mojom::IntListAttribute::kLabelledbyIds); if (labelledby_ids.size() != 1) return false; @@ -1431,7 +1441,8 @@ - (BOOL)shouldExposeTitleUIElement { if (!label) return false; - std::string labelName = label->GetStringAttribute(ui::AX_ATTR_NAME); + std::string labelName = + label->GetStringAttribute(ax::mojom::StringAttribute::kName); return !labelName.empty(); } @@ -1512,20 +1523,20 @@ - (NSString*)role { if (![self instanceActive]) return nil; - ui::AXRole role = [self internalRole]; - if (role == ui::AX_ROLE_CANVAS && + ax::mojom::Role role = [self internalRole]; + if (role == ax::mojom::Role::kCanvas && browserAccessibility_->GetBoolAttribute( - ui::AX_ATTR_CANVAS_HAS_FALLBACK)) { + ax::mojom::BoolAttribute::kCanvasHasFallback)) { return NSAccessibilityGroupRole; } if ((browserAccessibility_->IsPlainTextField() && - browserAccessibility_->HasState(ui::AX_STATE_MULTILINE)) || + browserAccessibility_->HasState(ax::mojom::State::kMultiline)) || browserAccessibility_->IsRichTextField()) { return NSAccessibilityTextAreaRole; } - if (role == ui::AX_ROLE_IMAGE && + if (role == ax::mojom::Role::kImage && browserAccessibility_->HasExplicitlyEmptyName()) return NSAccessibilityUnknownRole; @@ -1544,9 +1555,9 @@ - (NSString*)roleDescription { return nil; if (browserAccessibility_->HasStringAttribute( - ui::AX_ATTR_ROLE_DESCRIPTION)) { + ax::mojom::StringAttribute::kRoleDescription)) { return NSStringForStringAttribute( - browserAccessibility_, ui::AX_ATTR_ROLE_DESCRIPTION); + browserAccessibility_, ax::mojom::StringAttribute::kRoleDescription); } NSString* role = [self role]; @@ -1574,10 +1585,10 @@ - (NSString*)roleDescription { !browserAccessibility_->IsWebAreaForPresentationalIframe()) { std::string role; if (browserAccessibility_->GetHtmlAttribute("role", &role)) { - ui::AXRole internalRole = [self internalRole]; - if ((internalRole != ui::AX_ROLE_GROUP && - internalRole != ui::AX_ROLE_LIST_ITEM) || - internalRole == ui::AX_ROLE_TAB) { + ax::mojom::Role internalRole = [self internalRole]; + if ((internalRole != ax::mojom::Role::kGroup && + internalRole != ax::mojom::Role::kListItem) || + internalRole == ax::mojom::Role::kTab) { // TODO(dtseng): This is not localized; see crbug/84814. return base::SysUTF8ToNSString(role); } @@ -1585,78 +1596,78 @@ - (NSString*)roleDescription { } switch([self internalRole]) { - case ui::AX_ROLE_ARTICLE: - return base::SysUTF16ToNSString(content_client->GetLocalizedString( - IDS_AX_ROLE_ARTICLE)); - case ui::AX_ROLE_BANNER: - return base::SysUTF16ToNSString(content_client->GetLocalizedString( - IDS_AX_ROLE_BANNER)); - case ui::AX_ROLE_CHECK_BOX: - return base::SysUTF16ToNSString(content_client->GetLocalizedString( - IDS_AX_ROLE_CHECK_BOX)); - case ui::AX_ROLE_COMPLEMENTARY: - return base::SysUTF16ToNSString(content_client->GetLocalizedString( - IDS_AX_ROLE_COMPLEMENTARY)); - case ui::AX_ROLE_CONTENT_INFO: - return base::SysUTF16ToNSString(content_client->GetLocalizedString( - IDS_AX_ROLE_CONTENT_INFO)); - case ui::AX_ROLE_DESCRIPTION_LIST: - return base::SysUTF16ToNSString(content_client->GetLocalizedString( - IDS_AX_ROLE_DESCRIPTION_LIST)); - case ui::AX_ROLE_DESCRIPTION_LIST_DETAIL: - return base::SysUTF16ToNSString(content_client->GetLocalizedString( - IDS_AX_ROLE_DEFINITION)); - case ui::AX_ROLE_DESCRIPTION_LIST_TERM: - return base::SysUTF16ToNSString(content_client->GetLocalizedString( - IDS_AX_ROLE_DESCRIPTION_TERM)); - case ui::AX_ROLE_DISCLOSURE_TRIANGLE: - return base::SysUTF16ToNSString(content_client->GetLocalizedString( - IDS_AX_ROLE_DISCLOSURE_TRIANGLE)); - case ui::AX_ROLE_FIGURE: - return base::SysUTF16ToNSString(content_client->GetLocalizedString( - IDS_AX_ROLE_FIGURE)); - case ui::AX_ROLE_FOOTER: - return base::SysUTF16ToNSString(content_client->GetLocalizedString( - IDS_AX_ROLE_FOOTER)); - case ui::AX_ROLE_FORM: - return base::SysUTF16ToNSString(content_client->GetLocalizedString( - IDS_AX_ROLE_FORM)); - case ui::AX_ROLE_MAIN: - return base::SysUTF16ToNSString(content_client->GetLocalizedString( - IDS_AX_ROLE_MAIN_CONTENT)); - case ui::AX_ROLE_MARK: - return base::SysUTF16ToNSString(content_client->GetLocalizedString( - IDS_AX_ROLE_MARK)); - case ui::AX_ROLE_MATH: - return base::SysUTF16ToNSString(content_client->GetLocalizedString( - IDS_AX_ROLE_MATH)); - case ui::AX_ROLE_NAVIGATION: - return base::SysUTF16ToNSString(content_client->GetLocalizedString( - IDS_AX_ROLE_NAVIGATIONAL_LINK)); - case ui::AX_ROLE_REGION: - return base::SysUTF16ToNSString(content_client->GetLocalizedString( - IDS_AX_ROLE_REGION)); - case ui::AX_ROLE_SPIN_BUTTON: - // This control is similar to what VoiceOver calls a "stepper". - return base::SysUTF16ToNSString(content_client->GetLocalizedString( - IDS_AX_ROLE_STEPPER)); - case ui::AX_ROLE_STATUS: - return base::SysUTF16ToNSString(content_client->GetLocalizedString( - IDS_AX_ROLE_STATUS)); - case ui::AX_ROLE_SEARCH_BOX: - return base::SysUTF16ToNSString(content_client->GetLocalizedString( - IDS_AX_ROLE_SEARCH_BOX)); - case ui::AX_ROLE_SWITCH: - return base::SysUTF16ToNSString(content_client->GetLocalizedString( - IDS_AX_ROLE_SWITCH)); - case ui::AX_ROLE_TERM: - return base::SysUTF16ToNSString(content_client->GetLocalizedString( - IDS_AX_ROLE_DESCRIPTION_TERM)); - case ui::AX_ROLE_TOGGLE_BUTTON: - return base::SysUTF16ToNSString(content_client->GetLocalizedString( - IDS_AX_ROLE_TOGGLE_BUTTON)); - default: - break; + case ax::mojom::Role::kArticle: + return base::SysUTF16ToNSString( + content_client->GetLocalizedString(IDS_AX_ROLE_ARTICLE)); + case ax::mojom::Role::kBanner: + return base::SysUTF16ToNSString( + content_client->GetLocalizedString(IDS_AX_ROLE_BANNER)); + case ax::mojom::Role::kCheckBox: + return base::SysUTF16ToNSString( + content_client->GetLocalizedString(IDS_AX_ROLE_CHECK_BOX)); + case ax::mojom::Role::kComplementary: + return base::SysUTF16ToNSString( + content_client->GetLocalizedString(IDS_AX_ROLE_COMPLEMENTARY)); + case ax::mojom::Role::kContentInfo: + return base::SysUTF16ToNSString( + content_client->GetLocalizedString(IDS_AX_ROLE_CONTENT_INFO)); + case ax::mojom::Role::kDescriptionList: + return base::SysUTF16ToNSString( + content_client->GetLocalizedString(IDS_AX_ROLE_DESCRIPTION_LIST)); + case ax::mojom::Role::kDescriptionListDetail: + return base::SysUTF16ToNSString( + content_client->GetLocalizedString(IDS_AX_ROLE_DEFINITION)); + case ax::mojom::Role::kDescriptionListTerm: + return base::SysUTF16ToNSString( + content_client->GetLocalizedString(IDS_AX_ROLE_DESCRIPTION_TERM)); + case ax::mojom::Role::kDisclosureTriangle: + return base::SysUTF16ToNSString( + content_client->GetLocalizedString(IDS_AX_ROLE_DISCLOSURE_TRIANGLE)); + case ax::mojom::Role::kFigure: + return base::SysUTF16ToNSString( + content_client->GetLocalizedString(IDS_AX_ROLE_FIGURE)); + case ax::mojom::Role::kFooter: + return base::SysUTF16ToNSString( + content_client->GetLocalizedString(IDS_AX_ROLE_FOOTER)); + case ax::mojom::Role::kForm: + return base::SysUTF16ToNSString( + content_client->GetLocalizedString(IDS_AX_ROLE_FORM)); + case ax::mojom::Role::kMain: + return base::SysUTF16ToNSString( + content_client->GetLocalizedString(IDS_AX_ROLE_MAIN_CONTENT)); + case ax::mojom::Role::kMark: + return base::SysUTF16ToNSString( + content_client->GetLocalizedString(IDS_AX_ROLE_MARK)); + case ax::mojom::Role::kMath: + return base::SysUTF16ToNSString( + content_client->GetLocalizedString(IDS_AX_ROLE_MATH)); + case ax::mojom::Role::kNavigation: + return base::SysUTF16ToNSString( + content_client->GetLocalizedString(IDS_AX_ROLE_NAVIGATIONAL_LINK)); + case ax::mojom::Role::kRegion: + return base::SysUTF16ToNSString( + content_client->GetLocalizedString(IDS_AX_ROLE_REGION)); + case ax::mojom::Role::kSpinButton: + // This control is similar to what VoiceOver calls a "stepper". + return base::SysUTF16ToNSString( + content_client->GetLocalizedString(IDS_AX_ROLE_STEPPER)); + case ax::mojom::Role::kStatus: + return base::SysUTF16ToNSString( + content_client->GetLocalizedString(IDS_AX_ROLE_STATUS)); + case ax::mojom::Role::kSearchBox: + return base::SysUTF16ToNSString( + content_client->GetLocalizedString(IDS_AX_ROLE_SEARCH_BOX)); + case ax::mojom::Role::kSwitch: + return base::SysUTF16ToNSString( + content_client->GetLocalizedString(IDS_AX_ROLE_SWITCH)); + case ax::mojom::Role::kTerm: + return base::SysUTF16ToNSString( + content_client->GetLocalizedString(IDS_AX_ROLE_DESCRIPTION_TERM)); + case ax::mojom::Role::kToggleButton: + return base::SysUTF16ToNSString( + content_client->GetLocalizedString(IDS_AX_ROLE_TOGGLE_BUTTON)); + default: + break; } return NSAccessibilityRoleDescription(role, nil); @@ -1665,17 +1676,17 @@ - (NSString*)roleDescription { - (BOOL)isRowHeaderForCurrentCell:(BrowserAccessibility*)header { int cell_first_row = -1; int cell_rowspan = -1; - browserAccessibility_->GetIntAttribute(ui::AX_ATTR_ARIA_CELL_ROW_INDEX, - &cell_first_row); + browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kAriaCellRowIndex, &cell_first_row); if (cell_first_row < 0) { - browserAccessibility_->GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX, - &cell_first_row); + browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kTableCellRowIndex, &cell_first_row); } if (cell_first_row < 0) return false; - browserAccessibility_->GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_SPAN, - &cell_rowspan); + browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kTableCellRowSpan, &cell_rowspan); if (cell_rowspan <= 0) cell_rowspan = 1; @@ -1683,15 +1694,17 @@ - (BOOL)isRowHeaderForCurrentCell:(BrowserAccessibility*)header { int header_first_row = -1; int header_rowspan = -1; - header->GetIntAttribute(ui::AX_ATTR_ARIA_CELL_ROW_INDEX, &header_first_row); + header->GetIntAttribute(ax::mojom::IntAttribute::kAriaCellRowIndex, + &header_first_row); if (header_first_row < 0) { - header->GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX, + header->GetIntAttribute(ax::mojom::IntAttribute::kTableCellRowIndex, &header_first_row); } if (header_first_row < 0) return false; - header->GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_SPAN, &header_rowspan); + header->GetIntAttribute(ax::mojom::IntAttribute::kTableCellRowSpan, + &header_rowspan); if (header_rowspan <= 0) header_rowspan = 1; @@ -1718,12 +1731,12 @@ - (NSArray*)rowHeaders { NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; const std::vector& uniqueCellIds = - table->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); + table->GetIntListAttribute(ax::mojom::IntListAttribute::kUniqueCellIds); for (size_t i = 0; i < uniqueCellIds.size(); ++i) { int id = uniqueCellIds[i]; BrowserAccessibility* cell = browserAccessibility_->manager()->GetFromID(id); - if (cell && cell->GetRole() == ui::AX_ROLE_ROW_HEADER) { + if (cell && cell->GetRole() == ax::mojom::Role::kRowHeader) { if (is_table_like || [self isRowHeaderForCurrentCell:cell]) [ret addObject:ToBrowserAccessibilityCocoa(cell)]; } @@ -1740,9 +1753,9 @@ - (NSValue*)rowIndexRange { int row = -1; int rowspan = -1; browserAccessibility_->GetIntAttribute( - ui::AX_ATTR_TABLE_CELL_ROW_INDEX, &row); + ax::mojom::IntAttribute::kTableCellRowIndex, &row); browserAccessibility_->GetIntAttribute( - ui::AX_ATTR_TABLE_CELL_ROW_SPAN, &rowspan); + ax::mojom::IntAttribute::kTableCellRowSpan, &rowspan); if (row >= 0 && rowspan >= 1) return [NSValue valueWithRange:NSMakeRange(row, rowspan)]; return nil; @@ -1753,16 +1766,16 @@ - (NSArray*)rows { return nil; NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; - if ([self internalRole] == ui::AX_ROLE_TABLE|| - [self internalRole] == ui::AX_ROLE_GRID) { + if ([self internalRole] == ax::mojom::Role::kTable || + [self internalRole] == ax::mojom::Role::kGrid) { for (BrowserAccessibilityCocoa* child in [self children]) { if ([[child role] isEqualToString:NSAccessibilityRowRole]) [ret addObject:child]; } - } else if ([self internalRole] == ui::AX_ROLE_COLUMN) { + } else if ([self internalRole] == ax::mojom::Role::kColumn) { const std::vector& indirectChildIds = browserAccessibility_->GetIntListAttribute( - ui::AX_ATTR_INDIRECT_CHILD_IDS); + ax::mojom::IntListAttribute::kIndirectChildIds); for (uint32_t i = 0; i < indirectChildIds.size(); ++i) { int id = indirectChildIds[i]; BrowserAccessibility* rowElement = @@ -1793,7 +1806,7 @@ - (NSArray*)selectedChildren { // If it's not multiselectable, try to skip iterating over the // children. - if (!GetState(browserAccessibility_, ui::AX_STATE_MULTISELECTABLE)) { + if (!GetState(browserAccessibility_, ax::mojom::State::kMultiselectable)) { // First try the focused child. if (focusedChild && focusedChild != browserAccessibility_) { [ret addObject:ToBrowserAccessibilityCocoa(focusedChild)]; @@ -1803,7 +1816,8 @@ - (NSArray*)selectedChildren { // Next try the active descendant. int activeDescendantId; if (browserAccessibility_->GetIntAttribute( - ui::AX_ATTR_ACTIVEDESCENDANT_ID, &activeDescendantId)) { + ax::mojom::IntAttribute::kActivedescendantId, + &activeDescendantId)) { BrowserAccessibility* activeDescendant = manager->GetFromID(activeDescendantId); if (activeDescendant) { @@ -1820,7 +1834,7 @@ - (NSArray*)selectedChildren { for (uint32_t index = 0; index < childCount; ++index) { BrowserAccessibility* child = browserAccessibility_->PlatformGetChild(index); - if (child->HasState(ui::AX_STATE_SELECTED)) + if (child->HasState(ax::mojom::State::kSelected)) [ret addObject:ToBrowserAccessibilityCocoa(child)]; } @@ -1840,10 +1854,10 @@ - (NSString*)selectedText { // TODO(nektar): Deprecate sel_start and sel_end attributes. int selStart, selEnd; - if (!browserAccessibility_->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, - &selStart) || - !browserAccessibility_->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, - &selEnd)) { + if (!browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kTextSelStart, &selStart) || + !browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kTextSelEnd, &selEnd)) { return nil; } @@ -1861,10 +1875,10 @@ - (NSValue*)selectedTextRange { // TODO(nektar): Deprecate sel_start and sel_end attributes. int selStart, selEnd; - if (!browserAccessibility_->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, - &selStart) || - !browserAccessibility_->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, - &selEnd)) { + if (!browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kTextSelStart, &selStart) || + !browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kTextSelEnd, &selEnd)) { return nil; } @@ -1898,9 +1912,10 @@ - (id)selectedTextMarkerRange { if (anchorOffset < 0 || focusOffset < 0) return nil; - ui::AXTextAffinity anchorAffinity = - manager->GetTreeData().sel_anchor_affinity; - ui::AXTextAffinity focusAffinity = manager->GetTreeData().sel_focus_affinity; + ax::mojom::TextAffinity anchorAffinity = + manager->GetTreeData().sel_anchor_affinity; + ax::mojom::TextAffinity focusAffinity = + manager->GetTreeData().sel_focus_affinity; return CreateTextMarkerRange(CreateTextRange(*anchorObject, anchorOffset, anchorAffinity, *focusObject, @@ -1919,17 +1934,17 @@ - (NSString*)sortDirection { return nil; int sortDirection; if (!browserAccessibility_->GetIntAttribute( - ui::AX_ATTR_SORT_DIRECTION, &sortDirection)) + ax::mojom::IntAttribute::kSortDirection, &sortDirection)) return nil; - switch (static_cast(sortDirection)) { - case ui::AX_SORT_DIRECTION_UNSORTED: + switch (static_cast(sortDirection)) { + case ax::mojom::SortDirection::kUnsorted: return nil; - case ui::AX_SORT_DIRECTION_ASCENDING: + case ax::mojom::SortDirection::kAscending: return NSAccessibilityAscendingSortDirectionValue; - case ui::AX_SORT_DIRECTION_DESCENDING: + case ax::mojom::SortDirection::kDescending: return NSAccessibilityDescendingSortDirectionValue; - case ui::AX_SORT_DIRECTION_OTHER: + case ax::mojom::SortDirection::kOther: return NSAccessibilityUnknownSortDirectionValue; default: NOTREACHED(); @@ -1956,14 +1971,14 @@ - (NSString*) subrole { return nil; if (browserAccessibility_->IsPlainTextField() && - GetState(browserAccessibility_, ui::AX_STATE_PROTECTED)) { + GetState(browserAccessibility_, ax::mojom::State::kProtected)) { return NSAccessibilitySecureTextFieldSubrole; } - if ([self internalRole] == ui::AX_ROLE_DESCRIPTION_LIST) + if ([self internalRole] == ax::mojom::Role::kDescriptionList) return NSAccessibilityDefinitionListSubrole; - if ([self internalRole] == ui::AX_ROLE_LIST) + if ([self internalRole] == ax::mojom::Role::kList) return NSAccessibilityContentListSubrole; return [AXPlatformNodeCocoa nativeSubroleFromAXRole:[self internalRole]]; @@ -1975,7 +1990,7 @@ - (NSArray*)tabs { return nil; NSMutableArray* tabSubtree = [[[NSMutableArray alloc] init] autorelease]; - if ([self internalRole] == ui::AX_ROLE_TAB) + if ([self internalRole] == ax::mojom::Role::kTab) [tabSubtree addObject:self]; for (uint i=0; i < [[self children] count]; ++i) { @@ -1999,23 +2014,24 @@ - (NSString*)title { if ([self shouldExposeTitleUIElement]) return @""; - ui::AXNameFrom nameFrom = static_cast( - browserAccessibility_->GetIntAttribute(ui::AX_ATTR_NAME_FROM)); + ax::mojom::NameFrom nameFrom = + static_cast(browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kNameFrom)); // On Mac OS X, cell titles are "" if it it came from content. NSString* role = [self role]; if ([role isEqualToString:NSAccessibilityCellRole] && - nameFrom == ui::AX_NAME_FROM_CONTENTS) + nameFrom == ax::mojom::NameFrom::kContents) return @""; // On Mac OS X, the accessible name of an object is exposed as its // title if it comes from visible text, and as its description // otherwise, but never both. - if (nameFrom == ui::AX_NAME_FROM_CONTENTS || - nameFrom == ui::AX_NAME_FROM_RELATED_ELEMENT || - nameFrom == ui::AX_NAME_FROM_VALUE) { - return NSStringForStringAttribute( - browserAccessibility_, ui::AX_ATTR_NAME); + if (nameFrom == ax::mojom::NameFrom::kContents || + nameFrom == ax::mojom::NameFrom::kRelatedElement || + nameFrom == ax::mojom::NameFrom::kValue) { + return NSStringForStringAttribute(browserAccessibility_, + ax::mojom::StringAttribute::kName); } return nil; @@ -2028,10 +2044,12 @@ - (id)titleUIElement { return nil; std::vector labelledby_ids = - browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_LABELLEDBY_IDS); - ui::AXNameFrom nameFrom = static_cast( - browserAccessibility_->GetIntAttribute(ui::AX_ATTR_NAME_FROM)); - if (nameFrom == ui::AX_NAME_FROM_RELATED_ELEMENT && + browserAccessibility_->GetIntListAttribute( + ax::mojom::IntListAttribute::kLabelledbyIds); + ax::mojom::NameFrom nameFrom = + static_cast(browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kNameFrom)); + if (nameFrom == ax::mojom::NameFrom::kRelatedElement && labelledby_ids.size() == 1) { BrowserAccessibility* titleElement = browserAccessibility_->manager()->GetFromID(labelledby_ids[0]); @@ -2049,7 +2067,8 @@ - (NSURL*)url { if ([[self role] isEqualToString:@"AXWebArea"]) url = browserAccessibility_->manager()->GetTreeData().url; else - url = browserAccessibility_->GetStringAttribute(ui::AX_ATTR_URL); + url = browserAccessibility_->GetStringAttribute( + ax::mojom::StringAttribute::kUrl); if (url.empty()) return nil; @@ -2062,33 +2081,37 @@ - (id)value { return nil; if (ui::IsNameExposedInAXValueForRole([self internalRole])) - return NSStringForStringAttribute(browserAccessibility_, ui::AX_ATTR_NAME); + return NSStringForStringAttribute(browserAccessibility_, + ax::mojom::StringAttribute::kName); NSString* role = [self role]; if ([role isEqualToString:@"AXHeading"]) { int level = 0; if (browserAccessibility_->GetIntAttribute( - ui::AX_ATTR_HIERARCHICAL_LEVEL, &level)) { + ax::mojom::IntAttribute::kHierarchicalLevel, &level)) { return [NSNumber numberWithInt:level]; } } else if ([role isEqualToString:NSAccessibilityButtonRole]) { // AXValue does not make sense for pure buttons. return @""; } else if (browserAccessibility_->HasIntAttribute( - ui::AX_ATTR_CHECKED_STATE) || + ax::mojom::IntAttribute::kCheckedState) || [role isEqualToString:NSAccessibilityRadioButtonRole]) { int value; - const auto checkedState = static_cast( - browserAccessibility_->GetIntAttribute(ui::AX_ATTR_CHECKED_STATE)); + const auto checkedState = static_cast( + browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kCheckedState)); switch (checkedState) { - case ui::AX_CHECKED_STATE_TRUE: + case ax::mojom::CheckedState::kTrue: value = 1; break; - case ui::AX_CHECKED_STATE_MIXED: + case ax::mojom::CheckedState::kMixed: value = 2; break; default: - value = GetState(browserAccessibility_, ui::AX_STATE_SELECTED) ? 1 : 0; + value = GetState(browserAccessibility_, ax::mojom::State::kSelected) + ? 1 + : 0; break; } return [NSNumber numberWithInt:value]; @@ -2097,15 +2120,16 @@ - (id)value { [role isEqualToString:NSAccessibilityIncrementorRole] || [role isEqualToString:NSAccessibilityScrollBarRole] || ([role isEqualToString:NSAccessibilitySplitterRole] && - browserAccessibility_->HasState(ui::AX_STATE_FOCUSABLE))) { + browserAccessibility_->HasState(ax::mojom::State::kFocusable))) { float floatValue; if (browserAccessibility_->GetFloatAttribute( - ui::AX_ATTR_VALUE_FOR_RANGE, &floatValue)) { + ax::mojom::FloatAttribute::kValueForRange, &floatValue)) { return [NSNumber numberWithFloat:floatValue]; } } else if ([role isEqualToString:NSAccessibilityColorWellRole]) { - unsigned int color = static_cast( - browserAccessibility_->GetIntAttribute(ui::AX_ATTR_COLOR_VALUE)); + unsigned int color = + static_cast(browserAccessibility_->GetIntAttribute( + ax::mojom::IntAttribute::kColorValue)); unsigned int red = SkColorGetR(color); unsigned int green = SkColorGetG(color); unsigned int blue = SkColorGetB(color); @@ -2137,7 +2161,8 @@ - (NSArray*)visibleCells { return nil; NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; const std::vector& uniqueCellIds = - browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS); + browserAccessibility_->GetIntListAttribute( + ax::mojom::IntListAttribute::kUniqueCellIds); for (size_t i = 0; i < uniqueCellIds.size(); ++i) { int id = uniqueCellIds[i]; BrowserAccessibility* cell = @@ -2169,8 +2194,8 @@ - (NSArray*)visibleRows { - (NSNumber*)visited { if (![self instanceActive]) return nil; - return [NSNumber numberWithBool: - GetState(browserAccessibility_, ui::AX_STATE_VISITED)]; + return [NSNumber numberWithBool:GetState(browserAccessibility_, + ax::mojom::State::kVisited)]; } - (id)window { @@ -2290,8 +2315,8 @@ - (id)accessibilityAttributeValue:(NSString*)attribute if ([attribute isEqualToString: NSAccessibilityCellForColumnAndRowParameterizedAttribute]) { - if ([self internalRole] != ui::AX_ROLE_TABLE && - [self internalRole] != ui::AX_ROLE_GRID) { + if ([self internalRole] != ax::mojom::Role::kTable && + [self internalRole] != ax::mojom::Role::kGrid) { return nil; } if (![parameter isKindOfClass:[NSArray class]]) @@ -2302,9 +2327,9 @@ - (id)accessibilityAttributeValue:(NSString*)attribute int column = [[array objectAtIndex:0] intValue]; int row = [[array objectAtIndex:1] intValue]; int num_columns = browserAccessibility_->GetIntAttribute( - ui::AX_ATTR_TABLE_COLUMN_COUNT); + ax::mojom::IntAttribute::kTableColumnCount); int num_rows = browserAccessibility_->GetIntAttribute( - ui::AX_ATTR_TABLE_ROW_COUNT); + ax::mojom::IntAttribute::kTableRowCount); if (column < 0 || column >= num_columns || row < 0 || row >= num_rows) { return nil; @@ -2313,11 +2338,11 @@ - (id)accessibilityAttributeValue:(NSString*)attribute i < browserAccessibility_->PlatformChildCount(); ++i) { BrowserAccessibility* child = browserAccessibility_->PlatformGetChild(i); - if (child->GetRole() != ui::AX_ROLE_ROW) + if (child->GetRole() != ax::mojom::Role::kRow) continue; int rowIndex; - if (!child->GetIntAttribute( - ui::AX_ATTR_TABLE_ROW_INDEX, &rowIndex)) { + if (!child->GetIntAttribute(ax::mojom::IntAttribute::kTableRowIndex, + &rowIndex)) { continue; } if (rowIndex < row) @@ -2332,8 +2357,7 @@ - (id)accessibilityAttributeValue:(NSString*)attribute continue; int colIndex; if (!cell->GetIntAttribute( - ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, - &colIndex)) { + ax::mojom::IntAttribute::kTableCellColumnIndex, &colIndex)) { continue; } if (colIndex == column) @@ -2525,7 +2549,7 @@ - (id)accessibilityAttributeValue:(NSString*)attribute if ([attribute isEqualToString: NSAccessibilityBoundsForRangeParameterizedAttribute]) { - if ([self internalRole] != ui::AX_ROLE_STATIC_TEXT) + if ([self internalRole] != ax::mojom::Role::kStaticText) return nil; NSRange range = [(NSValue*)parameter rangeValue]; gfx::Rect rect = browserAccessibility_->GetScreenBoundsForRange( @@ -2691,7 +2715,7 @@ - (NSArray*)accessibilityParameterizedAttributeNames { ]]; } - if (browserAccessibility_->HasState(ui::AX_STATE_EDITABLE)) { + if (browserAccessibility_->HasState(ax::mojom::State::kEditable)) { [ret addObjectsFromArray:@[ NSAccessibilityLineForIndexParameterizedAttribute, NSAccessibilityRangeForLineParameterizedAttribute, @@ -2705,14 +2729,14 @@ - (NSArray*)accessibilityParameterizedAttributeNames { ]]; } - if ([self internalRole] == ui::AX_ROLE_STATIC_TEXT) { + if ([self internalRole] == ax::mojom::Role::kStaticText) { [ret addObjectsFromArray:@[ NSAccessibilityBoundsForRangeParameterizedAttribute ]]; } - if ([self internalRole] == ui::AX_ROLE_ROOT_WEB_AREA || - [self internalRole] == ui::AX_ROLE_WEB_AREA) { + if ([self internalRole] == ax::mojom::Role::kRootWebArea || + [self internalRole] == ax::mojom::Role::kWebArea) { [ret addObjectsFromArray: @[ NSAccessibilityTextMarkerIsValidParameterizedAttribute, NSAccessibilityIndexForTextMarkerParameterizedAttribute, @@ -2738,8 +2762,8 @@ - (NSArray*)accessibilityActionNames { if (ui::IsMenuRelated(browserAccessibility_->GetRole())) [actions addObject:NSAccessibilityCancelAction]; - if ([self internalRole] == ui::AX_ROLE_SLIDER || - [self internalRole] == ui::AX_ROLE_SPIN_BUTTON) { + if ([self internalRole] == ax::mojom::Role::kSlider || + [self internalRole] == ax::mojom::Role::kSpinButton) { [actions addObjectsFromArray:@[ NSAccessibilityIncrementAction, NSAccessibilityDecrementAction ]]; @@ -2845,12 +2869,12 @@ - (NSArray*)accessibilityAttributeNames { NSAccessibilityARIARowIndexAttribute, @"AXSortDirection", ]]; - if ([self internalRole] != ui::AX_ROLE_COLUMN_HEADER) { + if ([self internalRole] != ax::mojom::Role::kColumnHeader) { [ret addObjectsFromArray:@[ NSAccessibilityColumnHeaderUIElementsAttribute, ]]; } - if ([self internalRole] != ui::AX_ROLE_ROW_HEADER) { + if ([self internalRole] != ax::mojom::Role::kRowHeader) { [ret addObjectsFromArray:@[ NSAccessibilityRowHeaderUIElementsAttribute, ]]; @@ -2866,7 +2890,7 @@ - (NSArray*)accessibilityAttributeNames { [role isEqualToString:NSAccessibilityIncrementorRole] || [role isEqualToString:NSAccessibilityScrollBarRole] || ([role isEqualToString:NSAccessibilitySplitterRole] && - browserAccessibility_->HasState(ui::AX_STATE_FOCUSABLE))) { + browserAccessibility_->HasState(ax::mojom::State::kFocusable))) { [ret addObjectsFromArray:@[ NSAccessibilityMaxValueAttribute, NSAccessibilityMinValueAttribute, NSAccessibilityValueDescriptionAttribute @@ -2903,7 +2927,7 @@ - (NSArray*)accessibilityAttributeNames { } // Caret navigation and text selection attributes. - if (browserAccessibility_->HasState(ui::AX_STATE_EDITABLE)) { + if (browserAccessibility_->HasState(ax::mojom::State::kEditable)) { [ret addObjectsFromArray:@[ NSAccessibilityInsertionPointLineNumberAttribute, NSAccessibilityNumberOfCharactersAttribute, @@ -2919,27 +2943,30 @@ - (NSArray*)accessibilityAttributeNames { } // Position in set and Set size - if (browserAccessibility_->HasIntAttribute(ui::AX_ATTR_POS_IN_SET)) { + if (browserAccessibility_->HasIntAttribute( + ax::mojom::IntAttribute::kPosInSet)) { [ret addObjectsFromArray:@[ NSAccessibilityARIAPosInSetAttribute ]]; } - if (browserAccessibility_->HasIntAttribute(ui::AX_ATTR_SET_SIZE)) { + if (browserAccessibility_->HasIntAttribute( + ax::mojom::IntAttribute::kSetSize)) { [ret addObjectsFromArray:@[ NSAccessibilityARIASetSizeAttribute ]]; } // Live regions. if (browserAccessibility_->HasStringAttribute( - ui::AX_ATTR_LIVE_STATUS)) { + ax::mojom::StringAttribute::kLiveStatus)) { [ret addObjectsFromArray:@[ NSAccessibilityARIALiveAttribute ]]; } if (browserAccessibility_->HasStringAttribute( - ui::AX_ATTR_LIVE_RELEVANT)) { + ax::mojom::StringAttribute::kLiveRelevant)) { [ret addObjectsFromArray:@[ NSAccessibilityARIARelevantAttribute ]]; } if (browserAccessibility_->HasBoolAttribute( - ui::AX_ATTR_LIVE_ATOMIC)) { + ax::mojom::BoolAttribute::kLiveAtomic)) { [ret addObjectsFromArray:@[ NSAccessibilityARIAAtomicAttribute ]]; } - if (browserAccessibility_->HasBoolAttribute(ui::AX_ATTR_BUSY)) { + if (browserAccessibility_->HasBoolAttribute( + ax::mojom::BoolAttribute::kBusy)) { [ret addObjectsFromArray:@[ NSAccessibilityARIABusyAttribute ]]; } @@ -2954,32 +2981,36 @@ - (NSArray*)accessibilityAttributeNames { } // Add expanded attribute only if it has expanded or collapsed state. - if (GetState(browserAccessibility_, ui::AX_STATE_EXPANDED) || - GetState(browserAccessibility_, ui::AX_STATE_COLLAPSED)) { + if (GetState(browserAccessibility_, ax::mojom::State::kExpanded) || + GetState(browserAccessibility_, ax::mojom::State::kCollapsed)) { [ret addObjectsFromArray:@[ NSAccessibilityExpandedAttribute ]]; } - if (GetState(browserAccessibility_, ui::AX_STATE_VERTICAL) - || GetState(browserAccessibility_, ui::AX_STATE_HORIZONTAL)) { + if (GetState(browserAccessibility_, ax::mojom::State::kVertical) || + GetState(browserAccessibility_, ax::mojom::State::kHorizontal)) { [ret addObjectsFromArray:@[ NSAccessibilityOrientationAttribute ]]; } - if (browserAccessibility_->HasStringAttribute(ui::AX_ATTR_PLACEHOLDER)) { + if (browserAccessibility_->HasStringAttribute( + ax::mojom::StringAttribute::kPlaceholder)) { [ret addObjectsFromArray:@[ NSAccessibilityPlaceholderValueAttribute ]]; } - if (GetState(browserAccessibility_, ui::AX_STATE_REQUIRED)) { + if (GetState(browserAccessibility_, ax::mojom::State::kRequired)) { [ret addObjectsFromArray:@[ @"AXRequired" ]]; } - if (browserAccessibility_->HasStringAttribute(ui::AX_ATTR_LANGUAGE)) { + if (browserAccessibility_->HasStringAttribute( + ax::mojom::StringAttribute::kLanguage)) { [ret addObjectsFromArray:@[ NSAccessibilityLanguageAttribute ]]; } // Title UI Element. - if (browserAccessibility_->HasIntListAttribute(ui::AX_ATTR_LABELLEDBY_IDS) && - browserAccessibility_->GetIntListAttribute(ui::AX_ATTR_LABELLEDBY_IDS) - .size() > 0) { + if (browserAccessibility_->HasIntListAttribute( + ax::mojom::IntListAttribute::kLabelledbyIds) && + browserAccessibility_ + ->GetIntListAttribute(ax::mojom::IntListAttribute::kLabelledbyIds) + .size() > 0) { [ret addObjectsFromArray:@[ NSAccessibilityTitleUIElementAttribute ]]; } // TODO(aboxhall): expose NSAccessibilityServesAsTitleForUIElementsAttribute @@ -3009,17 +3040,17 @@ - (BOOL)accessibilityIsAttributeSettable:(NSString*)attribute { return NO; if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) { - if ([self internalRole] == ui::AX_ROLE_DATE_TIME) + if ([self internalRole] == ax::mojom::Role::kDateTime) return NO; - return GetState(browserAccessibility_, ui::AX_STATE_FOCUSABLE); + return GetState(browserAccessibility_, ax::mojom::State::kFocusable); } if ([attribute isEqualToString:NSAccessibilityValueAttribute]) - return browserAccessibility_->HasAction(ui::AX_ACTION_SET_VALUE); + return browserAccessibility_->HasAction(ax::mojom::Action::kSetValue); if ([attribute isEqualToString:NSAccessibilitySelectedTextRangeAttribute] && - browserAccessibility_->HasState(ui::AX_STATE_EDITABLE)) { + browserAccessibility_->HasState(ax::mojom::State::kEditable)) { return YES; } diff --git a/content/browser/accessibility/browser_accessibility_com_win.cc b/content/browser/accessibility/browser_accessibility_com_win.cc index d2df434b1618d0..c1f26e9e46cf78 100644 --- a/content/browser/accessibility/browser_accessibility_com_win.cc +++ b/content/browser/accessibility/browser_accessibility_com_win.cc @@ -732,7 +732,8 @@ STDMETHODIMP BrowserAccessibilityComWin::get_anchorTarget( BSTR target; if (!(MSAAState() & STATE_SYSTEM_LINKED) || - FAILED(GetStringAttributeAsBstr(ui::AX_ATTR_URL, &target))) { + FAILED(GetStringAttributeAsBstr(ax::mojom::StringAttribute::kUrl, + &target))) { target = SysAllocString(L""); } DCHECK(target); @@ -800,7 +801,7 @@ STDMETHODIMP BrowserAccessibilityComWin::nActions(long* n_actions) { // to work properly because the |IAccessibleHyperlink| interface inherits from // |IAccessibleAction|. if (IsHyperlink() || - owner()->HasIntAttribute(ui::AX_ATTR_DEFAULT_ACTION_VERB)) { + owner()->HasIntAttribute(ax::mojom::IntAttribute::kDefaultActionVerb)) { *n_actions = 1; } else { *n_actions = 0; @@ -815,7 +816,7 @@ STDMETHODIMP BrowserAccessibilityComWin::doAction(long action_index) { if (!owner()) return E_FAIL; - if (!owner()->HasIntAttribute(ui::AX_ATTR_DEFAULT_ACTION_VERB) || + if (!owner()->HasIntAttribute(ax::mojom::IntAttribute::kDefaultActionVerb) || action_index != 0) return E_INVALIDARG; @@ -851,14 +852,15 @@ STDMETHODIMP BrowserAccessibilityComWin::get_name(long action_index, return E_INVALIDARG; int action; - if (!owner()->GetIntAttribute(ui::AX_ATTR_DEFAULT_ACTION_VERB, &action) || + if (!owner()->GetIntAttribute(ax::mojom::IntAttribute::kDefaultActionVerb, + &action) || action_index != 0) { *name = nullptr; return E_INVALIDARG; } base::string16 action_verb = ui::ActionVerbToUnlocalizedString( - static_cast(action)); + static_cast(action)); if (action_verb.empty() || action_verb == L"none") { *name = nullptr; return S_FALSE; @@ -881,14 +883,15 @@ BrowserAccessibilityComWin::get_localizedName(long action_index, return E_INVALIDARG; int action; - if (!owner()->GetIntAttribute(ui::AX_ATTR_DEFAULT_ACTION_VERB, &action) || + if (!owner()->GetIntAttribute(ax::mojom::IntAttribute::kDefaultActionVerb, + &action) || action_index != 0) { *localized_name = nullptr; return E_INVALIDARG; } base::string16 action_verb = ui::ActionVerbToLocalizedString( - static_cast(action)); + static_cast(action)); if (action_verb.empty()) { *localized_name = nullptr; return S_FALSE; @@ -913,7 +916,8 @@ STDMETHODIMP BrowserAccessibilityComWin::get_currentValue(VARIANT* value) { return E_INVALIDARG; float float_val; - if (GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, &float_val)) { + if (GetFloatAttribute(ax::mojom::FloatAttribute::kValueForRange, + &float_val)) { value->vt = VT_R8; value->dblVal = float_val; return S_OK; @@ -933,7 +937,8 @@ STDMETHODIMP BrowserAccessibilityComWin::get_minimumValue(VARIANT* value) { return E_INVALIDARG; float float_val; - if (GetFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE, &float_val)) { + if (GetFloatAttribute(ax::mojom::FloatAttribute::kMinValueForRange, + &float_val)) { value->vt = VT_R8; value->dblVal = float_val; return S_OK; @@ -953,7 +958,8 @@ STDMETHODIMP BrowserAccessibilityComWin::get_maximumValue(VARIANT* value) { return E_INVALIDARG; float float_val; - if (GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE, &float_val)) { + if (GetFloatAttribute(ax::mojom::FloatAttribute::kMaxValueForRange, + &float_val)) { value->vt = VT_R8; value->dblVal = float_val; return S_OK; @@ -1101,7 +1107,7 @@ STDMETHODIMP BrowserAccessibilityComWin::get_nodeInfo( } base::string16 tag; - if (owner()->GetString16Attribute(ui::AX_ATTR_HTML_TAG, &tag)) + if (owner()->GetString16Attribute(ax::mojom::StringAttribute::kHtmlTag, &tag)) *node_name = SysAllocString(tag.c_str()); else *node_name = nullptr; @@ -1200,7 +1206,8 @@ STDMETHODIMP BrowserAccessibilityComWin::get_computedStyle( base::string16 display; if (max_style_properties == 0 || - !owner()->GetString16Attribute(ui::AX_ATTR_DISPLAY, &display)) { + !owner()->GetString16Attribute(ax::mojom::StringAttribute::kDisplay, + &display)) { *num_style_properties = 0; return S_OK; } @@ -1232,7 +1239,7 @@ STDMETHODIMP BrowserAccessibilityComWin::get_computedStyleForProperties( reinterpret_cast(style_properties[i])); if (name == L"display") { base::string16 display = - owner()->GetString16Attribute(ui::AX_ATTR_DISPLAY); + owner()->GetString16Attribute(ax::mojom::StringAttribute::kDisplay); style_values[i] = SysAllocString(display.c_str()); } else { style_values[i] = NULL; @@ -1371,11 +1378,11 @@ STDMETHODIMP BrowserAccessibilityComWin::get_innerHTML(BSTR* innerHTML) { AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); if (!owner()) return E_FAIL; - if (owner()->GetRole() != ui::AX_ROLE_MATH) + if (owner()->GetRole() != ax::mojom::Role::kMath) return E_NOTIMPL; base::string16 inner_html = - owner()->GetString16Attribute(ui::AX_ATTR_INNER_HTML); + owner()->GetString16Attribute(ax::mojom::StringAttribute::kInnerHtml); *innerHTML = SysAllocString(inner_html.c_str()); DCHECK(*innerHTML); return S_OK; @@ -1398,8 +1405,8 @@ STDMETHODIMP BrowserAccessibilityComWin::get_language(BSTR* language) { if (!owner()) return E_FAIL; - base::string16 lang = - owner()->GetInheritedString16Attribute(ui::AX_ATTR_LANGUAGE); + base::string16 lang = owner()->GetInheritedString16Attribute( + ax::mojom::StringAttribute::kLanguage); if (lang.empty()) lang = L"en-US"; @@ -1421,7 +1428,7 @@ STDMETHODIMP BrowserAccessibilityComWin::get_domText(BSTR* dom_text) { if (!dom_text) return E_INVALIDARG; - return GetStringAttributeAsBstr(ui::AX_ATTR_NAME, dom_text); + return GetStringAttributeAsBstr(ax::mojom::StringAttribute::kName, dom_text); } STDMETHODIMP BrowserAccessibilityComWin::get_clippedSubstringBounds( @@ -1507,8 +1514,8 @@ STDMETHODIMP BrowserAccessibilityComWin::get_fontFamily(BSTR* font_family) { if (!owner()) return E_FAIL; - base::string16 family = - owner()->GetInheritedString16Attribute(ui::AX_ATTR_FONT_FAMILY); + base::string16 family = owner()->GetInheritedString16Attribute( + ax::mojom::StringAttribute::kFontFamily); if (family.empty()) return S_FALSE; @@ -1605,7 +1612,7 @@ STDMETHODIMP BrowserAccessibilityComWin::GetPatternProvider( return E_FAIL; if (id == UIA_ValuePatternId || id == UIA_TextPatternId) { - if (owner()->HasState(ui::AX_STATE_EDITABLE)) { + if (owner()->HasState(ax::mojom::State::kEditable)) { DVLOG(1) << "Returning UIA text provider"; base::win::UIATextProvider::CreateTextProvider(GetRangeValueText(), true, provider); @@ -1624,7 +1631,7 @@ STDMETHODIMP BrowserAccessibilityComWin::GetPropertyValue(PROPERTYID id, V_VT(ret) = VT_EMPTY; if (id == UIA_ControlTypePropertyId) { - if (owner()->HasState(ui::AX_STATE_EDITABLE)) { + if (owner()->HasState(ax::mojom::State::kEditable)) { V_VT(ret) = VT_I4; ret->lVal = UIA_EditControlTypeId; DVLOG(1) << "Returning Edit control type"; @@ -1761,7 +1768,7 @@ BrowserAccessibilityComWin::CreatePositionForSelectionAt(int offset) const { BrowserAccessibilityPositionInstance position = owner()->CreatePositionAt(offset)->AsLeafTextPosition(); if (position->GetAnchor() && - position->GetAnchor()->GetRole() == ui::AX_ROLE_INLINE_TEXT_BOX) { + position->GetAnchor()->GetRole() == ax::mojom::Role::kInlineTextBox) { return position->CreateParentPosition(); } return position; @@ -1795,10 +1802,11 @@ void BrowserAccessibilityComWin::UpdateStep1ComputeWinAttributes() { win_attributes_->ia2_state = ComputeIA2State(); win_attributes_->ia2_attributes = ComputeIA2Attributes(); - win_attributes_->name = owner()->GetString16Attribute(ui::AX_ATTR_NAME); + win_attributes_->name = + owner()->GetString16Attribute(ax::mojom::StringAttribute::kName); win_attributes_->description = - owner()->GetString16Attribute(ui::AX_ATTR_DESCRIPTION); + owner()->GetString16Attribute(ax::mojom::StringAttribute::kDescription); win_attributes_->value = GetValue(); } @@ -1839,7 +1847,8 @@ void BrowserAccessibilityComWin::UpdateStep3FireEvents( if (is_selected_now || was_selected_before) { bool multiselect = false; if (owner()->PlatformGetParent() && - owner()->PlatformGetParent()->HasState(ui::AX_STATE_MULTISELECTABLE)) + owner()->PlatformGetParent()->HasState( + ax::mojom::State::kMultiselectable)) multiselect = true; if (multiselect) { @@ -1858,8 +1867,8 @@ void BrowserAccessibilityComWin::UpdateStep3FireEvents( // Fire an event if this container object has scrolled. int sx = 0; int sy = 0; - if (owner()->GetIntAttribute(ui::AX_ATTR_SCROLL_X, &sx) && - owner()->GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &sy)) { + if (owner()->GetIntAttribute(ax::mojom::IntAttribute::kScrollX, &sx) && + owner()->GetIntAttribute(ax::mojom::IntAttribute::kScrollY, &sy)) { if (sx != previous_scroll_x_ || sy != previous_scroll_y_) FireNativeEvent(EVENT_SYSTEM_SCROLLINGEND); previous_scroll_x_ = sx; @@ -1885,7 +1894,7 @@ void BrowserAccessibilityComWin::UpdateStep3FireEvents( // control itself. BrowserAccessibilityComWin* parent = ToBrowserAccessibilityComWin(owner()->PlatformGetParent()); - if (parent && (parent->owner()->HasState(ui::AX_STATE_EDITABLE) || + if (parent && (parent->owner()->HasState(ax::mojom::State::kEditable) || owner()->IsTextOnlyObject())) { parent->owner()->UpdatePlatformAttributes(); } @@ -1924,14 +1933,15 @@ std::vector BrowserAccessibilityComWin::ComputeTextAttributes() // We include list markers for now, but there might be other objects that are // auto generated. // TODO(nektar): Compute what objects are auto-generated in Blink. - if (owner()->GetRole() == ui::AX_ROLE_LIST_MARKER) + if (owner()->GetRole() == ax::mojom::Role::kListMarker) attributes.push_back(L"auto-generated:true"); else attributes.push_back(L"auto-generated:false"); int color; base::string16 color_value(L"transparent"); - if (owner()->GetIntAttribute(ui::AX_ATTR_BACKGROUND_COLOR, &color)) { + if (owner()->GetIntAttribute(ax::mojom::IntAttribute::kBackgroundColor, + &color)) { unsigned int alpha = SkColorGetA(color); unsigned int red = SkColorGetR(color); unsigned int green = SkColorGetG(color); @@ -1945,7 +1955,7 @@ std::vector BrowserAccessibilityComWin::ComputeTextAttributes() SanitizeStringAttributeForIA2(color_value, &color_value); attributes.push_back(L"background-color:" + color_value); - if (owner()->GetIntAttribute(ui::AX_ATTR_COLOR, &color)) { + if (owner()->GetIntAttribute(ax::mojom::IntAttribute::kColor, &color)) { unsigned int red = SkColorGetR(color); unsigned int green = SkColorGetG(color); unsigned int blue = SkColorGetB(color); @@ -1958,8 +1968,8 @@ std::vector BrowserAccessibilityComWin::ComputeTextAttributes() SanitizeStringAttributeForIA2(color_value, &color_value); attributes.push_back(L"color:" + color_value); - base::string16 font_family( - owner()->GetInheritedString16Attribute(ui::AX_ATTR_FONT_FAMILY)); + base::string16 font_family(owner()->GetInheritedString16Attribute( + ax::mojom::StringAttribute::kFontFamily)); // Attribute has no default value. if (!font_family.empty()) { SanitizeStringAttributeForIA2(font_family, &font_family); @@ -1968,7 +1978,7 @@ std::vector BrowserAccessibilityComWin::ComputeTextAttributes() float font_size; // Attribute has no default value. - if (GetFloatAttribute(ui::AX_ATTR_FONT_SIZE, &font_size)) { + if (GetFloatAttribute(ax::mojom::FloatAttribute::kFontSize, &font_size)) { // The IA2 Spec requires the value to be in pt, not in pixels. // There are 72 points per inch. // We assume that there are 96 pixels per inch on a standard display. @@ -1978,50 +1988,56 @@ std::vector BrowserAccessibilityComWin::ComputeTextAttributes() L"pt"); } - int32_t text_style = owner()->GetIntAttribute(ui::AX_ATTR_TEXT_STYLE); - if (text_style == static_cast(ui::AX_TEXT_STYLE_NONE)) { + int32_t text_style = + owner()->GetIntAttribute(ax::mojom::IntAttribute::kTextStyle); + if (text_style == static_cast(ax::mojom::TextStyle::kNone)) { attributes.push_back(L"font-style:normal"); attributes.push_back(L"font-weight:normal"); } else { - if (text_style & static_cast(ui::AX_TEXT_STYLE_ITALIC)) { + if (text_style & + static_cast(ax::mojom::TextStyle::kTextStyleItalic)) { attributes.push_back(L"font-style:italic"); } else { attributes.push_back(L"font-style:normal"); } - if (text_style & static_cast(ui::AX_TEXT_STYLE_BOLD)) { + if (text_style & + static_cast(ax::mojom::TextStyle::kTextStyleBold)) { attributes.push_back(L"font-weight:bold"); } else { attributes.push_back(L"font-weight:normal"); } } - int32_t invalid_state = owner()->GetIntAttribute(ui::AX_ATTR_INVALID_STATE); - switch (static_cast(invalid_state)) { - case ui::AX_INVALID_STATE_NONE: - case ui::AX_INVALID_STATE_FALSE: + int32_t invalid_state = + owner()->GetIntAttribute(ax::mojom::IntAttribute::kInvalidState); + switch (static_cast(invalid_state)) { + case ax::mojom::InvalidState::kNone: + case ax::mojom::InvalidState::kFalse: attributes.push_back(L"invalid:false"); break; - case ui::AX_INVALID_STATE_TRUE: + case ax::mojom::InvalidState::kTrue: attributes.push_back(L"invalid:true"); break; - case ui::AX_INVALID_STATE_SPELLING: - case ui::AX_INVALID_STATE_GRAMMAR: { + case ax::mojom::InvalidState::kSpelling: + case ax::mojom::InvalidState::kGrammar: { base::string16 spelling_grammar_value; - if (invalid_state & static_cast(ui::AX_INVALID_STATE_SPELLING)) + if (invalid_state & + static_cast(ax::mojom::InvalidState::kSpelling)) spelling_grammar_value = L"spelling"; else if (invalid_state & - static_cast(ui::AX_INVALID_STATE_GRAMMAR)) + static_cast(ax::mojom::InvalidState::kGrammar)) spelling_grammar_value = L"grammar"; else spelling_grammar_value = L"spelling,grammar"; attributes.push_back(L"invalid:" + spelling_grammar_value); break; } - case ui::AX_INVALID_STATE_OTHER: { + case ax::mojom::InvalidState::kOther: { base::string16 aria_invalid_value; - if (owner()->GetString16Attribute(ui::AX_ATTR_ARIA_INVALID_VALUE, - &aria_invalid_value)) { + if (owner()->GetString16Attribute( + ax::mojom::StringAttribute::kAriaInvalidValue, + &aria_invalid_value)) { SanitizeStringAttributeForIA2(aria_invalid_value, &aria_invalid_value); attributes.push_back(L"invalid:" + aria_invalid_value); } else { @@ -2032,8 +2048,8 @@ std::vector BrowserAccessibilityComWin::ComputeTextAttributes() } } - base::string16 language( - owner()->GetInheritedString16Attribute(ui::AX_ATTR_LANGUAGE)); + base::string16 language(owner()->GetInheritedString16Attribute( + ax::mojom::StringAttribute::kLanguage)); // Default value should be L"en-US". if (language.empty()) { attributes.push_back(L"language:en-US"); @@ -2045,7 +2061,8 @@ std::vector BrowserAccessibilityComWin::ComputeTextAttributes() // TODO(nektar): Add Blink support for the following attributes. // Currently set to their default values as dictated by the IA2 Spec. attributes.push_back(L"text-line-through-mode:continuous"); - if (text_style & static_cast(ui::AX_TEXT_STYLE_LINE_THROUGH)) { + if (text_style & + static_cast(ax::mojom::TextStyle::kTextStyleLineThrough)) { // TODO(nektar): Figure out a more specific value. attributes.push_back(L"text-line-through-style:solid"); } else { @@ -2053,7 +2070,8 @@ std::vector BrowserAccessibilityComWin::ComputeTextAttributes() } // Default value must be the empty string. attributes.push_back(L"text-line-through-text:"); - if (text_style & static_cast(ui::AX_TEXT_STYLE_LINE_THROUGH)) { + if (text_style & + static_cast(ax::mojom::TextStyle::kTextStyleLineThrough)) { // TODO(nektar): Figure out a more specific value. attributes.push_back(L"text-line-through-type:single"); } else { @@ -2064,7 +2082,8 @@ std::vector BrowserAccessibilityComWin::ComputeTextAttributes() attributes.push_back(L"text-position:baseline"); attributes.push_back(L"text-shadow:none"); attributes.push_back(L"text-underline-mode:continuous"); - if (text_style & static_cast(ui::AX_TEXT_STYLE_UNDERLINE)) { + if (text_style & + static_cast(ax::mojom::TextStyle::kTextStyleUnderline)) { // TODO(nektar): Figure out a more specific value. attributes.push_back(L"text-underline-style:solid"); attributes.push_back(L"text-underline-type:single"); @@ -2074,20 +2093,20 @@ std::vector BrowserAccessibilityComWin::ComputeTextAttributes() } attributes.push_back(L"text-underline-width:auto"); - auto text_direction = static_cast( - owner()->GetIntAttribute(ui::AX_ATTR_TEXT_DIRECTION)); + auto text_direction = static_cast( + owner()->GetIntAttribute(ax::mojom::IntAttribute::kTextDirection)); switch (text_direction) { - case ui::AX_TEXT_DIRECTION_NONE: - case ui::AX_TEXT_DIRECTION_LTR: + case ax::mojom::TextDirection::kNone: + case ax::mojom::TextDirection::kLtr: attributes.push_back(L"writing-mode:lr"); break; - case ui::AX_TEXT_DIRECTION_RTL: + case ax::mojom::TextDirection::kRtl: attributes.push_back(L"writing-mode:rl"); break; - case ui::AX_TEXT_DIRECTION_TTB: + case ax::mojom::TextDirection::kTtb: attributes.push_back(L"writing-mode:tb"); break; - case ui::AX_TEXT_DIRECTION_BTT: + case ax::mojom::TextDirection::kBtt: // Not listed in the IA2 Spec. attributes.push_back(L"writing-mode:bt"); break; @@ -2106,14 +2125,14 @@ BrowserAccessibilityComWin::GetSpellingAttributes() { std::map> spelling_attributes; if (owner()->IsTextOnlyObject()) { const std::vector& marker_types = - owner()->GetIntListAttribute(ui::AX_ATTR_MARKER_TYPES); - const std::vector& marker_starts = - owner()->GetIntListAttribute(ui::AX_ATTR_MARKER_STARTS); + owner()->GetIntListAttribute(ax::mojom::IntListAttribute::kMarkerTypes); + const std::vector& marker_starts = owner()->GetIntListAttribute( + ax::mojom::IntListAttribute::kMarkerStarts); const std::vector& marker_ends = - owner()->GetIntListAttribute(ui::AX_ATTR_MARKER_ENDS); + owner()->GetIntListAttribute(ax::mojom::IntListAttribute::kMarkerEnds); for (size_t i = 0; i < marker_types.size(); ++i) { if (!(marker_types[i] & - static_cast(ui::AX_MARKER_TYPE_SPELLING))) + static_cast(ax::mojom::MarkerType::kSpelling))) continue; int start_offset = marker_starts[i]; int end_offset = marker_ends[i]; @@ -2172,7 +2191,7 @@ BrowserAccessibilityComWin* BrowserAccessibilityComWin::GetTargetFromChildID( } HRESULT BrowserAccessibilityComWin::GetStringAttributeAsBstr( - ui::AXStringAttribute attribute, + ax::mojom::StringAttribute attribute, BSTR* value_bstr) { base::string16 str; if (!owner()) @@ -2254,7 +2273,7 @@ LONG BrowserAccessibilityComWin::FindBoundary( HandleSpecialTextOffset(&start_offset); // If the |start_offset| is equal to the location of the caret, then use the // focus affinity, otherwise default to downstream affinity. - ui::AXTextAffinity affinity = ui::AX_TEXT_AFFINITY_DOWNSTREAM; + ax::mojom::TextAffinity affinity = ax::mojom::TextAffinity::kDownstream; int selection_start, selection_end; GetSelectionOffsets(&selection_start, &selection_end); if (selection_end >= 0 && start_offset == selection_end) @@ -2349,16 +2368,16 @@ bool BrowserAccessibilityComWin::IsListBoxOptionOrMenuListOption() { if (!owner()->PlatformGetParent()) return false; - ui::AXRole role = owner()->GetRole(); - ui::AXRole parent_role = owner()->PlatformGetParent()->GetRole(); + ax::mojom::Role role = owner()->GetRole(); + ax::mojom::Role parent_role = owner()->PlatformGetParent()->GetRole(); - if (role == ui::AX_ROLE_LIST_BOX_OPTION && - parent_role == ui::AX_ROLE_LIST_BOX) { + if (role == ax::mojom::Role::kListBoxOption && + parent_role == ax::mojom::Role::kListBox) { return true; } - if (role == ui::AX_ROLE_MENU_LIST_OPTION && - parent_role == ui::AX_ROLE_MENU_LIST_POPUP) { + if (role == ax::mojom::Role::kMenuListOption && + parent_role == ax::mojom::Role::kMenuListPopup) { return true; } diff --git a/content/browser/accessibility/browser_accessibility_com_win.h b/content/browser/accessibility/browser_accessibility_com_win.h index d601a6414e4ffe..2a86324f644bd5 100644 --- a/content/browser/accessibility/browser_accessibility_com_win.h +++ b/content/browser/accessibility/browser_accessibility_com_win.h @@ -467,7 +467,7 @@ class __declspec(uuid("562072fe-3390-43b1-9e2c-dd4118f5ac79")) // Retrieve the value of an attribute from the string attribute map and // if found and nonempty, allocate a new BSTR (with SysAllocString) // and return S_OK. If not found or empty, return S_FALSE. - HRESULT GetStringAttributeAsBstr(ui::AXStringAttribute attribute, + HRESULT GetStringAttributeAsBstr(ax::mojom::StringAttribute attribute, BSTR* value_bstr); // Merges the given spelling attributes, i.e. document marker information, diff --git a/content/browser/accessibility/browser_accessibility_mac_unittest.mm b/content/browser/accessibility/browser_accessibility_mac_unittest.mm index f62219fc0e88b3..217faec21d1623 100644 --- a/content/browser/accessibility/browser_accessibility_mac_unittest.mm +++ b/content/browser/accessibility/browser_accessibility_mac_unittest.mm @@ -38,8 +38,9 @@ void RebuildAccessibilityTree() { root_.id = 1000; root_.location.set_width(500); root_.location.set_height(100); - root_.role = ui::AX_ROLE_ROOT_WEB_AREA; - root_.AddStringAttribute(ui::AX_ATTR_DESCRIPTION, "HelpText"); + root_.role = ax::mojom::Role::kRootWebArea; + root_.AddStringAttribute(ax::mojom::StringAttribute::kDescription, + "HelpText"); root_.child_ids.push_back(1001); root_.child_ids.push_back(1002); @@ -48,14 +49,14 @@ void RebuildAccessibilityTree() { child1.SetName("Child1"); child1.location.set_width(250); child1.location.set_height(100); - child1.role = ui::AX_ROLE_BUTTON; + child1.role = ax::mojom::Role::kButton; ui::AXNodeData child2; child2.id = 1002; child2.location.set_x(250); child2.location.set_width(250); child2.location.set_height(100); - child2.role = ui::AX_ROLE_HEADING; + child2.role = ax::mojom::Role::kHeading; manager_.reset(new BrowserAccessibilityManagerMac( MakeAXTreeUpdate(root_, child1, child2), nullptr)); @@ -69,7 +70,7 @@ void SetRootValue(std::string value) { root_.SetValue(value); AXEventNotificationDetails param; param.update.nodes.push_back(root_); - param.event_type = ui::AX_EVENT_VALUE_CHANGED; + param.event_type = ax::mojom::Event::kValueChanged; param.id = root_.id; std::vector events{param}; manager_->OnAccessibilityEvents(events); diff --git a/content/browser/accessibility/browser_accessibility_manager.cc b/content/browser/accessibility/browser_accessibility_manager.cc index 9fbb14c0fe348a..653157e3e9456b 100644 --- a/content/browser/accessibility/browser_accessibility_manager.cc +++ b/content/browser/accessibility/browser_accessibility_manager.cc @@ -27,7 +27,8 @@ BrowserAccessibility* FindNodeWithChildTreeId(BrowserAccessibility* node, if (!node) return nullptr; - if (node->GetIntAttribute(ui::AX_ATTR_CHILD_TREE_ID) == ax_tree_id) + if (node->GetIntAttribute(ax::mojom::IntAttribute::kChildTreeId) == + ax_tree_id) return node; for (unsigned int i = 0; i < node->InternalChildCount(); ++i) { @@ -203,7 +204,7 @@ ui::AXTreeUpdate BrowserAccessibilityManager::GetEmptyDocument() { ui::AXNodeData empty_document; empty_document.id = 0; - empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA; + empty_document.role = ax::mojom::Role::kRootWebArea; ui::AXTreeUpdate update; update.nodes.push_back(empty_document); return update; @@ -228,7 +229,7 @@ void BrowserAccessibilityManager::FireFocusEventsIfNeeded() { // or for the document to actually finish loading. if (focus && focus == focus->manager()->GetRoot() && focus->PlatformChildCount() == 0 && - !focus->GetBoolAttribute(ui::AX_ATTR_BUSY) && + !focus->GetBoolAttribute(ax::mojom::BoolAttribute::kBusy) && !focus->manager()->GetTreeData().loaded) { focus = nullptr; } @@ -292,7 +293,7 @@ BrowserAccessibilityManager::GetParentNodeFromParentTree() { parent_node_id_from_parent_tree_); if (parent_node) { int parent_child_tree_id = - parent_node->GetIntAttribute(ui::AX_ATTR_CHILD_TREE_ID); + parent_node->GetIntAttribute(ax::mojom::IntAttribute::kChildTreeId); if (parent_child_tree_id == ax_tree_id_) return parent_node; } @@ -417,7 +418,7 @@ void BrowserAccessibilityManager::OnAccessibilityEvents( if (!event_target) return; - if (detail.event_type == ui::AX_EVENT_HOVER) + if (detail.event_type == ax::mojom::Event::kHover) GetRootManager()->CacheHitTestResult(event_target); FireBlinkEvent(detail.event_type, event_target); @@ -476,7 +477,7 @@ void BrowserAccessibilityManager::ActivateFindInPageResult( // The "scrolled to anchor" notification is a great way to get a // screen reader to jump directly to a specific location in a document. - FireBlinkEvent(ui::AX_EVENT_SCROLLED_TO_ANCHOR, node); + FireBlinkEvent(ax::mojom::Event::kScrolledToAnchor, node); } BrowserAccessibility* BrowserAccessibilityManager::GetActiveDescendant( @@ -486,19 +487,19 @@ BrowserAccessibility* BrowserAccessibilityManager::GetActiveDescendant( int32_t active_descendant_id; BrowserAccessibility* active_descendant = nullptr; - if (focus->GetIntAttribute(ui::AX_ATTR_ACTIVEDESCENDANT_ID, + if (focus->GetIntAttribute(ax::mojom::IntAttribute::kActivedescendantId, &active_descendant_id)) { active_descendant = focus->manager()->GetFromID(active_descendant_id); } - if (focus->GetRole() == ui::AX_ROLE_POP_UP_BUTTON) { + if (focus->GetRole() == ax::mojom::Role::kPopUpButton) { BrowserAccessibility* child = focus->InternalGetChild(0); - if (child && child->GetRole() == ui::AX_ROLE_MENU_LIST_POPUP) { + if (child && child->GetRole() == ax::mojom::Role::kMenuListPopup) { // The active descendant is found on the menu list popup, i.e. on the // actual list and not on the button that opens it. // If there is no active descendant, focus should stay on the button so // that Windows screen readers would enable their virtual cursor. - if (child->GetIntAttribute(ui::AX_ATTR_ACTIVEDESCENDANT_ID, + if (child->GetIntAttribute(ax::mojom::IntAttribute::kActivedescendantId, &active_descendant_id)) { active_descendant = child->manager()->GetFromID(active_descendant_id); } @@ -541,10 +542,10 @@ BrowserAccessibilityManager::GetFocusFromThisOrDescendantFrame() { if (!obj) return GetRoot(); - if (obj->HasIntAttribute(ui::AX_ATTR_CHILD_TREE_ID)) { + if (obj->HasIntAttribute(ax::mojom::IntAttribute::kChildTreeId)) { BrowserAccessibilityManager* child_manager = BrowserAccessibilityManager::FromID( - obj->GetIntAttribute(ui::AX_ATTR_CHILD_TREE_ID)); + obj->GetIntAttribute(ax::mojom::IntAttribute::kChildTreeId)); if (child_manager) return child_manager->GetFocusFromThisOrDescendantFrame(); } @@ -557,7 +558,7 @@ void BrowserAccessibilityManager::SetFocus(const BrowserAccessibility& node) { return; ui::AXActionData action_data; - action_data.action = ui::AX_ACTION_FOCUS; + action_data.action = ax::mojom::Action::kFocus; action_data.target_node_id = node.GetId(); delegate_->AccessibilityPerformAction(action_data); } @@ -586,7 +587,7 @@ void BrowserAccessibilityManager::Decrement( return; ui::AXActionData action_data; - action_data.action = ui::AX_ACTION_DECREMENT; + action_data.action = ax::mojom::Action::kDecrement; action_data.target_node_id = node.GetId(); delegate_->AccessibilityPerformAction(action_data); } @@ -597,7 +598,7 @@ void BrowserAccessibilityManager::DoDefaultAction( return; ui::AXActionData action_data; - action_data.action = ui::AX_ACTION_DO_DEFAULT; + action_data.action = ax::mojom::Action::kDoDefault; action_data.target_node_id = node.GetId(); delegate_->AccessibilityPerformAction(action_data); } @@ -609,7 +610,7 @@ void BrowserAccessibilityManager::GetImageData( return; ui::AXActionData action_data; - action_data.action = ui::AX_ACTION_GET_IMAGE_DATA; + action_data.action = ax::mojom::Action::kGetImageData; action_data.target_node_id = node.GetId(); action_data.target_rect = gfx::Rect(gfx::Point(), max_size); delegate_->AccessibilityPerformAction(action_data); @@ -621,7 +622,7 @@ void BrowserAccessibilityManager::Increment( return; ui::AXActionData action_data; - action_data.action = ui::AX_ACTION_INCREMENT; + action_data.action = ax::mojom::Action::kIncrement; action_data.target_node_id = node.GetId(); delegate_->AccessibilityPerformAction(action_data); } @@ -632,7 +633,7 @@ void BrowserAccessibilityManager::ShowContextMenu( return; ui::AXActionData action_data; - action_data.action = ui::AX_ACTION_SHOW_CONTEXT_MENU; + action_data.action = ax::mojom::Action::kShowContextMenu; action_data.target_node_id = node.GetId(); delegate_->AccessibilityPerformAction(action_data); } @@ -644,7 +645,7 @@ void BrowserAccessibilityManager::ScrollToMakeVisible( ui::AXActionData action_data; action_data.target_node_id = node.GetId(); - action_data.action = ui::AX_ACTION_SCROLL_TO_MAKE_VISIBLE; + action_data.action = ax::mojom::Action::kScrollToMakeVisible; action_data.target_rect = subfocus; delegate_->AccessibilityPerformAction(action_data); } @@ -656,7 +657,7 @@ void BrowserAccessibilityManager::ScrollToPoint( ui::AXActionData action_data; action_data.target_node_id = node.GetId(); - action_data.action = ui::AX_ACTION_SCROLL_TO_POINT; + action_data.action = ax::mojom::Action::kScrollToPoint; action_data.target_point = point; delegate_->AccessibilityPerformAction(action_data); } @@ -668,7 +669,7 @@ void BrowserAccessibilityManager::SetScrollOffset( ui::AXActionData action_data; action_data.target_node_id = node.GetId(); - action_data.action = ui::AX_ACTION_SET_SCROLL_OFFSET; + action_data.action = ax::mojom::Action::kSetScrollOffset; action_data.target_point = offset; delegate_->AccessibilityPerformAction(action_data); } @@ -681,7 +682,7 @@ void BrowserAccessibilityManager::SetValue( ui::AXActionData action_data; action_data.target_node_id = node.GetId(); - action_data.action = ui::AX_ACTION_SET_VALUE; + action_data.action = ax::mojom::Action::kSetValue; action_data.value = value; delegate_->AccessibilityPerformAction(action_data); } @@ -695,7 +696,7 @@ void BrowserAccessibilityManager::SetSelection(AXPlatformRange range) { action_data.anchor_offset = range.anchor()->text_offset(); action_data.focus_node_id = range.focus()->anchor_id(); action_data.focus_offset = range.focus()->text_offset(); - action_data.action = ui::AX_ACTION_SET_SELECTION; + action_data.action = ax::mojom::Action::kSetSelection; delegate_->AccessibilityPerformAction(action_data); } @@ -705,7 +706,7 @@ void BrowserAccessibilityManager::LoadInlineTextBoxes( return; ui::AXActionData action_data; - action_data.action = ui::AX_ACTION_LOAD_INLINE_TEXT_BOXES; + action_data.action = ax::mojom::Action::kLoadInlineTextBoxes; action_data.target_node_id = node.GetId(); delegate_->AccessibilityPerformAction(action_data); } @@ -715,9 +716,9 @@ void BrowserAccessibilityManager::HitTest(const gfx::Point& point) { return; ui::AXActionData action_data; - action_data.action = ui::AX_ACTION_HIT_TEST; + action_data.action = ax::mojom::Action::kHitTest; action_data.target_point = point; - action_data.hit_test_event_to_fire = ui::AX_EVENT_HOVER; + action_data.hit_test_event_to_fire = ax::mojom::Event::kHover; delegate_->AccessibilityPerformAction(action_data); } @@ -760,7 +761,7 @@ BrowserAccessibility* BrowserAccessibilityManager::PreviousInTreeOrder( // For android, this needs to be handled carefully. If not, there is a chance // of getting into infinite loop. if (can_wrap_to_last_element && - object->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA && + object->GetRole() == ax::mojom::Role::kRootWebArea && object->PlatformChildCount() != 0) { return object->PlatformDeepestLastChild(); } @@ -830,11 +831,11 @@ bool BrowserAccessibilityManager::FindIndicesInCommonParent( } // static -ui::AXTreeOrder BrowserAccessibilityManager::CompareNodes( +ax::mojom::TreeOrder BrowserAccessibilityManager::CompareNodes( const BrowserAccessibility& object1, const BrowserAccessibility& object2) { if (&object1 == &object2) - return ui::AX_TREE_ORDER_EQUAL; + return ax::mojom::TreeOrder::kEqual; BrowserAccessibility* common_parent; int child_index1; @@ -842,17 +843,17 @@ ui::AXTreeOrder BrowserAccessibilityManager::CompareNodes( if (FindIndicesInCommonParent( object1, object2, &common_parent, &child_index1, &child_index2)) { if (child_index1 < child_index2) - return ui::AX_TREE_ORDER_BEFORE; + return ax::mojom::TreeOrder::kBefore; if (child_index1 > child_index2) - return ui::AX_TREE_ORDER_AFTER; + return ax::mojom::TreeOrder::kAfter; } if (object2.IsDescendantOf(&object1)) - return ui::AX_TREE_ORDER_BEFORE; + return ax::mojom::TreeOrder::kBefore; if (object1.IsDescendantOf(&object2)) - return ui::AX_TREE_ORDER_AFTER; + return ax::mojom::TreeOrder::kAfter; - return ui::AX_TREE_ORDER_UNDEFINED; + return ax::mojom::TreeOrder::kUndefined; } std::vector @@ -1025,10 +1026,10 @@ gfx::Rect BrowserAccessibilityManager::GetPageBoundsForRange( const BrowserAccessibility* last = &end_object; switch (CompareNodes(*first, *last)) { - case ui::AX_TREE_ORDER_BEFORE: - case ui::AX_TREE_ORDER_EQUAL: + case ax::mojom::TreeOrder::kBefore: + case ax::mojom::TreeOrder::kEqual: break; - case ui::AX_TREE_ORDER_AFTER: + case ax::mojom::TreeOrder::kAfter: std::swap(first, last); std::swap(start_offset, end_offset); break; diff --git a/content/browser/accessibility/browser_accessibility_manager.h b/content/browser/accessibility/browser_accessibility_manager.h index adf726fd95a468..17912e348017f5 100644 --- a/content/browser/accessibility/browser_accessibility_manager.h +++ b/content/browser/accessibility/browser_accessibility_manager.h @@ -130,7 +130,7 @@ class CONTENT_EXPORT BrowserAccessibilityManager : public ui::AXEventGenerator { // Subclasses override these methods to send native event notifications. virtual void FireFocusEvent(BrowserAccessibility* node); - virtual void FireBlinkEvent(ui::AXEvent event_type, + virtual void FireBlinkEvent(ax::mojom::Event event_type, BrowserAccessibility* node) {} virtual void FireGeneratedEvent(AXEventGenerator::Event event_type, BrowserAccessibility* node) {} @@ -313,9 +313,8 @@ class CONTENT_EXPORT BrowserAccessibilityManager : public ui::AXEventGenerator { // Sets |out_is_before| to true if |object1| comes before |object2| // in tree order (pre-order traversal), and false if the objects are the // same or not in the same tree. - static ui::AXTreeOrder CompareNodes( - const BrowserAccessibility& object1, - const BrowserAccessibility& object2); + static ax::mojom::TreeOrder CompareNodes(const BrowserAccessibility& object1, + const BrowserAccessibility& object2); static std::vector FindTextOnlyObjectsInRange( const BrowserAccessibility& start_object, diff --git a/content/browser/accessibility/browser_accessibility_manager_android.cc b/content/browser/accessibility/browser_accessibility_manager_android.cc index e5a68d70945c1d..384b277a190173 100644 --- a/content/browser/accessibility/browser_accessibility_manager_android.cc +++ b/content/browser/accessibility/browser_accessibility_manager_android.cc @@ -44,9 +44,8 @@ BrowserAccessibilityManagerAndroid::~BrowserAccessibilityManagerAndroid() { ui::AXTreeUpdate BrowserAccessibilityManagerAndroid::GetEmptyDocument() { ui::AXNodeData empty_document; empty_document.id = 0; - empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA; - empty_document.AddIntAttribute(ui::AX_ATTR_RESTRICTION, - ui::AX_RESTRICTION_READ_ONLY); + empty_document.role = ax::mojom::Role::kRootWebArea; + empty_document.SetRestriction(ax::mojom::Restriction::kReadOnly); ui::AXTreeUpdate update; update.root_id = empty_document.id; @@ -96,7 +95,7 @@ void BrowserAccessibilityManagerAndroid::FireLocationChanged( } void BrowserAccessibilityManagerAndroid::FireBlinkEvent( - ui::AXEvent event_type, + ax::mojom::Event event_type, BrowserAccessibility* node) { BrowserAccessibilityManager::FireBlinkEvent(event_type, node); WebContentsAccessibilityAndroid* wcax = GetWebContentsAXFromRootManager(); @@ -111,13 +110,13 @@ void BrowserAccessibilityManagerAndroid::FireBlinkEvent( static_cast(node); switch (event_type) { - case ui::AX_EVENT_HOVER: + case ax::mojom::Event::kHover: HandleHoverEvent(node); break; - case ui::AX_EVENT_SCROLLED_TO_ANCHOR: + case ax::mojom::Event::kScrolledToAnchor: wcax->HandleScrolledToAnchor(android_node->unique_id()); break; - case ui::AX_EVENT_CLICKED: + case ax::mojom::Event::kClicked: wcax->HandleClicked(android_node->unique_id()); break; default: diff --git a/content/browser/accessibility/browser_accessibility_manager_android.h b/content/browser/accessibility/browser_accessibility_manager_android.h index 5c6c03a1e63ebd..745e810b4a6208 100644 --- a/content/browser/accessibility/browser_accessibility_manager_android.h +++ b/content/browser/accessibility/browser_accessibility_manager_android.h @@ -82,7 +82,7 @@ class CONTENT_EXPORT BrowserAccessibilityManagerAndroid const std::vector& params) override; void FireFocusEvent(BrowserAccessibility* node) override; - void FireBlinkEvent(ui::AXEvent event_type, + void FireBlinkEvent(ax::mojom::Event event_type, BrowserAccessibility* node) override; void FireGeneratedEvent(AXEventGenerator::Event event_type, BrowserAccessibility* node) override; diff --git a/content/browser/accessibility/browser_accessibility_manager_auralinux.cc b/content/browser/accessibility/browser_accessibility_manager_auralinux.cc index 1c2190d099289d..f57d21a11958b0 100644 --- a/content/browser/accessibility/browser_accessibility_manager_auralinux.cc +++ b/content/browser/accessibility/browser_accessibility_manager_auralinux.cc @@ -42,7 +42,7 @@ ui::AXTreeUpdate BrowserAccessibilityManagerAuraLinux::GetEmptyDocument() { ui::AXNodeData empty_document; empty_document.id = 0; - empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA; + empty_document.role = ax::mojom::Role::kRootWebArea; ui::AXTreeUpdate update; update.root_id = empty_document.id; update.nodes.push_back(empty_document); @@ -54,12 +54,12 @@ void BrowserAccessibilityManagerAuraLinux::FireFocusEvent( BrowserAccessibilityManager::FireFocusEvent(node); if (node->IsNative()) { ToBrowserAccessibilityAuraLinux(node)->GetNode()->NotifyAccessibilityEvent( - ui::AX_EVENT_FOCUS); + ax::mojom::Event::kFocus); } } void BrowserAccessibilityManagerAuraLinux::FireBlinkEvent( - ui::AXEvent event_type, + ax::mojom::Event event_type, BrowserAccessibility* node) { BrowserAccessibilityManager::FireBlinkEvent(event_type, node); // Need to implement. diff --git a/content/browser/accessibility/browser_accessibility_manager_auralinux.h b/content/browser/accessibility/browser_accessibility_manager_auralinux.h index 4d47128efa81df..c7537427ff1a96 100644 --- a/content/browser/accessibility/browser_accessibility_manager_auralinux.h +++ b/content/browser/accessibility/browser_accessibility_manager_auralinux.h @@ -27,7 +27,7 @@ class CONTENT_EXPORT BrowserAccessibilityManagerAuraLinux // Implementation of BrowserAccessibilityManager methods. void FireFocusEvent(BrowserAccessibility* node) override; - void FireBlinkEvent(ui::AXEvent event_type, + void FireBlinkEvent(ax::mojom::Event event_type, BrowserAccessibility* node) override; void FireGeneratedEvent(AXEventGenerator::Event event_type, BrowserAccessibility* node) override; diff --git a/content/browser/accessibility/browser_accessibility_manager_mac.h b/content/browser/accessibility/browser_accessibility_manager_mac.h index bf5626f049f51c..8f88334ea983fb 100644 --- a/content/browser/accessibility/browser_accessibility_manager_mac.h +++ b/content/browser/accessibility/browser_accessibility_manager_mac.h @@ -35,7 +35,7 @@ class CONTENT_EXPORT BrowserAccessibilityManagerMac // Implementation of BrowserAccessibilityManager. void FireFocusEvent(BrowserAccessibility* node) override; - void FireBlinkEvent(ui::AXEvent event_type, + void FireBlinkEvent(ax::mojom::Event event_type, BrowserAccessibility* node) override; void FireGeneratedEvent(AXEventGenerator::Event event_type, BrowserAccessibility* node) override; diff --git a/content/browser/accessibility/browser_accessibility_manager_mac.mm b/content/browser/accessibility/browser_accessibility_manager_mac.mm index 423902c20c7e82..8c915a7e7b4759 100644 --- a/content/browser/accessibility/browser_accessibility_manager_mac.mm +++ b/content/browser/accessibility/browser_accessibility_manager_mac.mm @@ -134,7 +134,7 @@ BrowserAccessibilityManagerMac::GetEmptyDocument() { ui::AXNodeData empty_document; empty_document.id = 0; - empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA; + empty_document.role = ax::mojom::Role::kRootWebArea; ui::AXTreeUpdate update; update.root_id = empty_document.id; update.nodes.push_back(empty_document); @@ -148,8 +148,9 @@ // information about the number of selected items will never be reported. // For editable combo boxes, focus should stay on the combo box so the user // will not be taken out of the combo box while typing. - if (focus && (focus->GetRole() == ui::AX_ROLE_LIST_BOX || - (focus->GetRole() == ui::AX_ROLE_TEXT_FIELD_WITH_COMBO_BOX))) { + if (focus && + (focus->GetRole() == ax::mojom::Role::kListBox || + (focus->GetRole() == ax::mojom::Role::kTextFieldWithComboBox))) { return focus; } @@ -165,15 +166,15 @@ } void BrowserAccessibilityManagerMac::FireBlinkEvent( - ui::AXEvent event_type, + ax::mojom::Event event_type, BrowserAccessibility* node) { BrowserAccessibilityManager::FireBlinkEvent(event_type, node); NSString* mac_notification = nullptr; switch (event_type) { - case ui::AX_EVENT_AUTOCORRECTION_OCCURED: + case ax::mojom::Event::kAutocorrectionOccured: mac_notification = NSAccessibilityAutocorrectionOccurredNotification; break; - case ui::AX_EVENT_LAYOUT_COMPLETE: + case ax::mojom::Event::kLayoutComplete: mac_notification = NSAccessibilityLayoutCompleteNotification; break; default: @@ -197,9 +198,9 @@ NSString* mac_notification = nullptr; switch (event_type) { case Event::ACTIVE_DESCENDANT_CHANGED: - if (node->GetRole() == ui::AX_ROLE_TREE) { + if (node->GetRole() == ax::mojom::Role::kTree) { mac_notification = NSAccessibilitySelectedRowsChangedNotification; - } else if (node->GetRole() == ui::AX_ROLE_TEXT_FIELD_WITH_COMBO_BOX) { + } else if (node->GetRole() == ax::mojom::Role::kTextFieldWithComboBox) { // Even though the selected item in the combo box has changed, we don't // want to post a focus change because this will take the focus out of // the combo box where the user might be typing. @@ -213,8 +214,8 @@ break; case Event::LOAD_COMPLETE: // This notification should only be fired on the top document. - // Iframes should use |AX_EVENT_LAYOUT_COMPLETE| to signify that they have - // finished loading. + // Iframes should use |ax::mojom::Event::kLayoutComplete| to signify that + // they have finished loading. if (IsRootTree()) { mac_notification = NSAccessibilityLoadCompleteNotification; } else { @@ -335,16 +336,16 @@ mac_notification = NSAccessibilityRowCountChangedNotification; break; case Event::EXPANDED: - if (node->GetRole() == ui::AX_ROLE_ROW || - node->GetRole() == ui::AX_ROLE_TREE_ITEM) { + if (node->GetRole() == ax::mojom::Role::kRow || + node->GetRole() == ax::mojom::Role::kTreeItem) { mac_notification = NSAccessibilityRowExpandedNotification; } else { mac_notification = NSAccessibilityExpandedChanged; } break; case Event::COLLAPSED: - if (node->GetRole() == ui::AX_ROLE_ROW || - node->GetRole() == ui::AX_ROLE_TREE_ITEM) { + if (node->GetRole() == ax::mojom::Role::kRow || + node->GetRole() == ax::mojom::Role::kTreeItem) { mac_notification = NSAccessibilityRowCollapsedNotification; } else { mac_notification = NSAccessibilityExpandedChanged; @@ -401,7 +402,7 @@ std::set changed_editable_roots; for (const auto& change : changes) { const BrowserAccessibility* obj = GetFromAXNode(change.node); - if (obj && obj->IsNative() && obj->HasState(ui::AX_STATE_EDITABLE)) { + if (obj && obj->IsNative() && obj->HasState(ax::mojom::State::kEditable)) { const BrowserAccessibilityCocoa* editable_root = [ToBrowserAccessibilityCocoa(obj) editableAncestor]; if (editable_root && [editable_root instanceActive]) diff --git a/content/browser/accessibility/browser_accessibility_manager_unittest.cc b/content/browser/accessibility/browser_accessibility_manager_unittest.cc index 3201caac0d0de8..dcd5699b67516d 100644 --- a/content/browser/accessibility/browser_accessibility_manager_unittest.cc +++ b/content/browser/accessibility/browser_accessibility_manager_unittest.cc @@ -90,17 +90,17 @@ TEST(BrowserAccessibilityManagerTest, TestNoLeaks) { ui::AXNodeData button; button.id = 2; button.SetName("Button"); - button.role = ui::AX_ROLE_BUTTON; + button.role = ax::mojom::Role::kButton; ui::AXNodeData checkbox; checkbox.id = 3; checkbox.SetName("Checkbox"); - checkbox.role = ui::AX_ROLE_CHECK_BOX; + checkbox.role = ax::mojom::Role::kCheckBox; ui::AXNodeData root; root.id = 1; root.SetName("Document"); - root.role = ui::AX_ROLE_ROOT_WEB_AREA; + root.role = ax::mojom::Role::kRootWebArea; root.child_ids.push_back(2); root.child_ids.push_back(3); @@ -164,22 +164,22 @@ TEST(BrowserAccessibilityManagerTest, TestReuseBrowserAccessibilityObjects) { ui::AXNodeData tree1_child1; tree1_child1.id = 2; tree1_child1.SetName("Child1"); - tree1_child1.role = ui::AX_ROLE_BUTTON; + tree1_child1.role = ax::mojom::Role::kButton; ui::AXNodeData tree1_child2; tree1_child2.id = 3; tree1_child2.SetName("Child2"); - tree1_child2.role = ui::AX_ROLE_BUTTON; + tree1_child2.role = ax::mojom::Role::kButton; ui::AXNodeData tree1_child3; tree1_child3.id = 4; tree1_child3.SetName("Child3"); - tree1_child3.role = ui::AX_ROLE_BUTTON; + tree1_child3.role = ax::mojom::Role::kButton; ui::AXNodeData tree1_root; tree1_root.id = 1; tree1_root.SetName("Document"); - tree1_root.role = ui::AX_ROLE_ROOT_WEB_AREA; + tree1_root.role = ax::mojom::Role::kRootWebArea; tree1_root.child_ids.push_back(2); tree1_root.child_ids.push_back(3); tree1_root.child_ids.push_back(4); @@ -195,12 +195,12 @@ TEST(BrowserAccessibilityManagerTest, TestReuseBrowserAccessibilityObjects) { ui::AXNodeData tree2_child0; tree2_child0.id = 5; tree2_child0.SetName("Child0"); - tree2_child0.role = ui::AX_ROLE_BUTTON; + tree2_child0.role = ax::mojom::Role::kButton; ui::AXNodeData tree2_root; tree2_root.id = 1; tree2_root.SetName("DocumentChanged"); - tree2_root.role = ui::AX_ROLE_ROOT_WEB_AREA; + tree2_root.role = ax::mojom::Role::kRootWebArea; tree2_root.child_ids.push_back(5); tree2_root.child_ids.push_back(2); tree2_root.child_ids.push_back(3); @@ -241,7 +241,7 @@ TEST(BrowserAccessibilityManagerTest, TestReuseBrowserAccessibilityObjects) { std::vector params; params.push_back(AXEventNotificationDetails()); AXEventNotificationDetails* msg = ¶ms[0]; - msg->event_type = ui::AX_EVENT_CHILDREN_CHANGED; + msg->event_type = ax::mojom::Event::kChildrenChanged; msg->update.nodes.push_back(tree2_root); msg->update.nodes.push_back(tree2_child0); msg->id = tree2_root.id; @@ -293,40 +293,40 @@ TEST(BrowserAccessibilityManagerTest, TestReuseBrowserAccessibilityObjects2) { ui::AXNodeData tree1_grandchild1; tree1_grandchild1.id = 4; tree1_grandchild1.SetName("GrandChild1"); - tree1_grandchild1.role = ui::AX_ROLE_BUTTON; + tree1_grandchild1.role = ax::mojom::Role::kButton; ui::AXNodeData tree1_child1; tree1_child1.id = 3; tree1_child1.SetName("Child1"); - tree1_child1.role = ui::AX_ROLE_BUTTON; + tree1_child1.role = ax::mojom::Role::kButton; tree1_child1.child_ids.push_back(4); ui::AXNodeData tree1_grandchild2; tree1_grandchild2.id = 6; tree1_grandchild2.SetName("GrandChild1"); - tree1_grandchild2.role = ui::AX_ROLE_BUTTON; + tree1_grandchild2.role = ax::mojom::Role::kButton; ui::AXNodeData tree1_child2; tree1_child2.id = 5; tree1_child2.SetName("Child2"); - tree1_child2.role = ui::AX_ROLE_BUTTON; + tree1_child2.role = ax::mojom::Role::kButton; tree1_child2.child_ids.push_back(6); ui::AXNodeData tree1_grandchild3; tree1_grandchild3.id = 8; tree1_grandchild3.SetName("GrandChild3"); - tree1_grandchild3.role = ui::AX_ROLE_BUTTON; + tree1_grandchild3.role = ax::mojom::Role::kButton; ui::AXNodeData tree1_child3; tree1_child3.id = 7; tree1_child3.SetName("Child3"); - tree1_child3.role = ui::AX_ROLE_BUTTON; + tree1_child3.role = ax::mojom::Role::kButton; tree1_child3.child_ids.push_back(8); ui::AXNodeData tree1_container; tree1_container.id = 2; tree1_container.SetName("Container"); - tree1_container.role = ui::AX_ROLE_GROUP; + tree1_container.role = ax::mojom::Role::kGroup; tree1_container.child_ids.push_back(3); tree1_container.child_ids.push_back(5); tree1_container.child_ids.push_back(7); @@ -334,7 +334,7 @@ TEST(BrowserAccessibilityManagerTest, TestReuseBrowserAccessibilityObjects2) { ui::AXNodeData tree1_root; tree1_root.id = 1; tree1_root.SetName("Document"); - tree1_root.role = ui::AX_ROLE_ROOT_WEB_AREA; + tree1_root.role = ax::mojom::Role::kRootWebArea; tree1_root.child_ids.push_back(2); // Tree 2: @@ -352,18 +352,18 @@ TEST(BrowserAccessibilityManagerTest, TestReuseBrowserAccessibilityObjects2) { ui::AXNodeData tree2_grandchild0; tree2_grandchild0.id = 9; tree2_grandchild0.SetName("GrandChild0"); - tree2_grandchild0.role = ui::AX_ROLE_BUTTON; + tree2_grandchild0.role = ax::mojom::Role::kButton; ui::AXNodeData tree2_child0; tree2_child0.id = 10; tree2_child0.SetName("Child0"); - tree2_child0.role = ui::AX_ROLE_BUTTON; + tree2_child0.role = ax::mojom::Role::kButton; tree2_child0.child_ids.push_back(9); ui::AXNodeData tree2_container; tree2_container.id = 2; tree2_container.SetName("Container"); - tree2_container.role = ui::AX_ROLE_GROUP; + tree2_container.role = ax::mojom::Role::kGroup; tree2_container.child_ids.push_back(10); tree2_container.child_ids.push_back(3); tree2_container.child_ids.push_back(5); @@ -406,7 +406,7 @@ TEST(BrowserAccessibilityManagerTest, TestReuseBrowserAccessibilityObjects2) { std::vector params; params.push_back(AXEventNotificationDetails()); AXEventNotificationDetails* msg = ¶ms[0]; - msg->event_type = ui::AX_EVENT_CHILDREN_CHANGED; + msg->event_type = ax::mojom::Event::kChildrenChanged; msg->update.nodes.push_back(tree2_container); msg->update.nodes.push_back(tree2_child0); msg->update.nodes.push_back(tree2_grandchild0); @@ -465,7 +465,7 @@ TEST(BrowserAccessibilityManagerTest, TestMoveChildUp) { ui::AXNodeData tree1_1; tree1_1.id = 1; - tree1_1.role = ui::AX_ROLE_ROOT_WEB_AREA; + tree1_1.role = ax::mojom::Role::kRootWebArea; tree1_1.child_ids.push_back(2); tree1_1.child_ids.push_back(3); @@ -504,7 +504,7 @@ TEST(BrowserAccessibilityManagerTest, TestMoveChildUp) { std::vector params; params.push_back(AXEventNotificationDetails()); AXEventNotificationDetails* msg = ¶ms[0]; - msg->event_type = ui::AX_EVENT_CHILDREN_CHANGED; + msg->event_type = ax::mojom::Event::kChildrenChanged; msg->update.nodes.push_back(tree2_1); msg->update.nodes.push_back(tree2_4); msg->update.nodes.push_back(tree2_5); @@ -528,7 +528,7 @@ TEST(BrowserAccessibilityManagerTest, DISABLED_TestFatalError) { ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; + root.role = ax::mojom::Role::kRootWebArea; root.child_ids.push_back(2); root.child_ids.push_back(2); @@ -546,7 +546,7 @@ TEST(BrowserAccessibilityManagerTest, DISABLED_TestFatalError) { ui::AXNodeData root2; root2.id = 1; - root2.role = ui::AX_ROLE_ROOT_WEB_AREA; + root2.role = ax::mojom::Role::kRootWebArea; root2.child_ids.push_back(2); root2.child_ids.push_back(3); @@ -582,22 +582,22 @@ TEST(BrowserAccessibilityManagerTest, DISABLED_TestFatalError) { TEST(BrowserAccessibilityManagerTest, BoundsForRange) { ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; + root.role = ax::mojom::Role::kRootWebArea; root.location = gfx::RectF(0, 0, 800, 600); ui::AXNodeData static_text; static_text.id = 2; static_text.SetName("Hello, world."); - static_text.role = ui::AX_ROLE_STATIC_TEXT; + static_text.role = ax::mojom::Role::kStaticText; static_text.location = gfx::RectF(100, 100, 29, 18); root.child_ids.push_back(2); ui::AXNodeData inline_text1; inline_text1.id = 3; inline_text1.SetName("Hello, "); - inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; + inline_text1.role = ax::mojom::Role::kInlineTextBox; inline_text1.location = gfx::RectF(100, 100, 29, 9); - inline_text1.SetTextDirection(ui::AX_TEXT_DIRECTION_LTR); + inline_text1.SetTextDirection(ax::mojom::TextDirection::kLtr); std::vector character_offsets1; character_offsets1.push_back(6); // 0 character_offsets1.push_back(11); // 1 @@ -607,15 +607,15 @@ TEST(BrowserAccessibilityManagerTest, BoundsForRange) { character_offsets1.push_back(29); // 5 character_offsets1.push_back(29); // 6 (note that the space has no width) inline_text1.AddIntListAttribute( - ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); + ax::mojom::IntListAttribute::kCharacterOffsets, character_offsets1); static_text.child_ids.push_back(3); ui::AXNodeData inline_text2; inline_text2.id = 4; inline_text2.SetName("world."); - inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; + inline_text2.role = ax::mojom::Role::kInlineTextBox; inline_text2.location = gfx::RectF(100, 109, 28, 9); - inline_text2.SetTextDirection(ui::AX_TEXT_DIRECTION_LTR); + inline_text2.SetTextDirection(ax::mojom::TextDirection::kLtr); std::vector character_offsets2; character_offsets2.push_back(5); character_offsets2.push_back(10); @@ -624,7 +624,7 @@ TEST(BrowserAccessibilityManagerTest, BoundsForRange) { character_offsets2.push_back(25); character_offsets2.push_back(28); inline_text2.AddIntListAttribute( - ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); + ax::mojom::IntListAttribute::kCharacterOffsets, character_offsets2); static_text.child_ids.push_back(4); std::unique_ptr manager( @@ -666,42 +666,42 @@ TEST(BrowserAccessibilityManagerTest, BoundsForRange) { TEST(BrowserAccessibilityManagerTest, BoundsForRangeMultiElement) { ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; + root.role = ax::mojom::Role::kRootWebArea; root.location = gfx::RectF(0, 0, 800, 600); ui::AXNodeData static_text; static_text.id = 2; static_text.SetName("ABC"); - static_text.role = ui::AX_ROLE_STATIC_TEXT; + static_text.role = ax::mojom::Role::kStaticText; static_text.location = gfx::RectF(0, 20, 33, 9); root.child_ids.push_back(2); ui::AXNodeData inline_text1; inline_text1.id = 3; inline_text1.SetName("ABC"); - inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; + inline_text1.role = ax::mojom::Role::kInlineTextBox; inline_text1.location = gfx::RectF(0, 20, 33, 9); - inline_text1.SetTextDirection(ui::AX_TEXT_DIRECTION_LTR); + inline_text1.SetTextDirection(ax::mojom::TextDirection::kLtr); std::vector character_offsets { 10, 21, 33 }; inline_text1.AddIntListAttribute( - ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets); + ax::mojom::IntListAttribute::kCharacterOffsets, character_offsets); static_text.child_ids.push_back(3); ui::AXNodeData static_text2; static_text2.id = 4; static_text2.SetName("ABC"); - static_text2.role = ui::AX_ROLE_STATIC_TEXT; + static_text2.role = ax::mojom::Role::kStaticText; static_text2.location = gfx::RectF(10, 40, 33, 9); root.child_ids.push_back(4); ui::AXNodeData inline_text2; inline_text2.id = 5; inline_text2.SetName("ABC"); - inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; + inline_text2.role = ax::mojom::Role::kInlineTextBox; inline_text2.location = gfx::RectF(10, 40, 33, 9); - inline_text2.SetTextDirection(ui::AX_TEXT_DIRECTION_LTR); + inline_text2.SetTextDirection(ax::mojom::TextDirection::kLtr); inline_text2.AddIntListAttribute( - ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets); + ax::mojom::IntListAttribute::kCharacterOffsets, character_offsets); static_text2.child_ids.push_back(5); std::unique_ptr manager( @@ -773,42 +773,42 @@ TEST(BrowserAccessibilityManagerTest, BoundsForRangeBiDi) { ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; + root.role = ax::mojom::Role::kRootWebArea; root.location = gfx::RectF(0, 0, 800, 600); ui::AXNodeData static_text; static_text.id = 2; static_text.SetName("123abc"); - static_text.role = ui::AX_ROLE_STATIC_TEXT; + static_text.role = ax::mojom::Role::kStaticText; static_text.location = gfx::RectF(100, 100, 60, 20); root.child_ids.push_back(2); ui::AXNodeData inline_text1; inline_text1.id = 3; inline_text1.SetName("123"); - inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; + inline_text1.role = ax::mojom::Role::kInlineTextBox; inline_text1.location = gfx::RectF(100, 100, 30, 20); - inline_text1.SetTextDirection(ui::AX_TEXT_DIRECTION_LTR); + inline_text1.SetTextDirection(ax::mojom::TextDirection::kLtr); std::vector character_offsets1; character_offsets1.push_back(10); // 0 character_offsets1.push_back(20); // 1 character_offsets1.push_back(30); // 2 inline_text1.AddIntListAttribute( - ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); + ax::mojom::IntListAttribute::kCharacterOffsets, character_offsets1); static_text.child_ids.push_back(3); ui::AXNodeData inline_text2; inline_text2.id = 4; inline_text2.SetName("abc"); - inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; + inline_text2.role = ax::mojom::Role::kInlineTextBox; inline_text2.location = gfx::RectF(130, 100, 30, 20); - inline_text2.SetTextDirection(ui::AX_TEXT_DIRECTION_RTL); + inline_text2.SetTextDirection(ax::mojom::TextDirection::kRtl); std::vector character_offsets2; character_offsets2.push_back(10); character_offsets2.push_back(20); character_offsets2.push_back(30); inline_text2.AddIntListAttribute( - ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); + ax::mojom::IntListAttribute::kCharacterOffsets, character_offsets2); static_text.child_ids.push_back(4); std::unique_ptr manager( @@ -846,30 +846,30 @@ TEST(BrowserAccessibilityManagerTest, BoundsForRangeBiDi) { TEST(BrowserAccessibilityManagerTest, BoundsForRangeScrolledWindow) { ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; - root.AddIntAttribute(ui::AX_ATTR_SCROLL_X, 25); - root.AddIntAttribute(ui::AX_ATTR_SCROLL_Y, 50); + root.role = ax::mojom::Role::kRootWebArea; + root.AddIntAttribute(ax::mojom::IntAttribute::kScrollX, 25); + root.AddIntAttribute(ax::mojom::IntAttribute::kScrollY, 50); root.location = gfx::RectF(0, 0, 800, 600); ui::AXNodeData static_text; static_text.id = 2; static_text.SetName("ABC"); - static_text.role = ui::AX_ROLE_STATIC_TEXT; + static_text.role = ax::mojom::Role::kStaticText; static_text.location = gfx::RectF(100, 100, 16, 9); root.child_ids.push_back(2); ui::AXNodeData inline_text; inline_text.id = 3; inline_text.SetName("ABC"); - inline_text.role = ui::AX_ROLE_INLINE_TEXT_BOX; + inline_text.role = ax::mojom::Role::kInlineTextBox; inline_text.location = gfx::RectF(100, 100, 16, 9); - inline_text.SetTextDirection(ui::AX_TEXT_DIRECTION_LTR); + inline_text.SetTextDirection(ax::mojom::TextDirection::kLtr); std::vector character_offsets1; character_offsets1.push_back(6); // 0 character_offsets1.push_back(11); // 1 character_offsets1.push_back(16); // 2 inline_text.AddIntListAttribute( - ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); + ax::mojom::IntListAttribute::kCharacterOffsets, character_offsets1); static_text.child_ids.push_back(3); std::unique_ptr manager( @@ -895,13 +895,13 @@ TEST(BrowserAccessibilityManagerTest, BoundsForRangeScrolledWindow) { TEST(BrowserAccessibilityManagerTest, BoundsForRangeOnParentElement) { ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; + root.role = ax::mojom::Role::kRootWebArea; root.child_ids.push_back(2); root.location = gfx::RectF(0, 0, 800, 600); ui::AXNodeData div; div.id = 2; - div.role = ui::AX_ROLE_GENERIC_CONTAINER; + div.role = ax::mojom::Role::kGenericContainer; div.location = gfx::RectF(100, 100, 100, 20); div.child_ids.push_back(3); div.child_ids.push_back(4); @@ -910,46 +910,46 @@ TEST(BrowserAccessibilityManagerTest, BoundsForRangeOnParentElement) { ui::AXNodeData static_text1; static_text1.id = 3; static_text1.SetName("AB"); - static_text1.role = ui::AX_ROLE_STATIC_TEXT; + static_text1.role = ax::mojom::Role::kStaticText; static_text1.location = gfx::RectF(100, 100, 40, 20); static_text1.child_ids.push_back(6); ui::AXNodeData img; img.id = 4; img.SetName("Test image"); - img.role = ui::AX_ROLE_IMAGE; + img.role = ax::mojom::Role::kImage; img.location = gfx::RectF(140, 100, 20, 20); ui::AXNodeData static_text2; static_text2.id = 5; static_text2.SetName("CD"); - static_text2.role = ui::AX_ROLE_STATIC_TEXT; + static_text2.role = ax::mojom::Role::kStaticText; static_text2.location = gfx::RectF(160, 100, 40, 20); static_text2.child_ids.push_back(7); ui::AXNodeData inline_text1; inline_text1.id = 6; inline_text1.SetName("AB"); - inline_text1.role = ui::AX_ROLE_INLINE_TEXT_BOX; + inline_text1.role = ax::mojom::Role::kInlineTextBox; inline_text1.location = gfx::RectF(100, 100, 40, 20); - inline_text1.SetTextDirection(ui::AX_TEXT_DIRECTION_LTR); + inline_text1.SetTextDirection(ax::mojom::TextDirection::kLtr); std::vector character_offsets1; character_offsets1.push_back(20); // 0 character_offsets1.push_back(40); // 1 inline_text1.AddIntListAttribute( - ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets1); + ax::mojom::IntListAttribute::kCharacterOffsets, character_offsets1); ui::AXNodeData inline_text2; inline_text2.id = 7; inline_text2.SetName("CD"); - inline_text2.role = ui::AX_ROLE_INLINE_TEXT_BOX; + inline_text2.role = ax::mojom::Role::kInlineTextBox; inline_text2.location = gfx::RectF(160, 100, 40, 20); - inline_text2.SetTextDirection(ui::AX_TEXT_DIRECTION_LTR); + inline_text2.SetTextDirection(ax::mojom::TextDirection::kLtr); std::vector character_offsets2; character_offsets2.push_back(20); // 0 character_offsets2.push_back(40); // 1 inline_text2.AddIntListAttribute( - ui::AX_ATTR_CHARACTER_OFFSETS, character_offsets2); + ax::mojom::IntListAttribute::kCharacterOffsets, character_offsets2); std::unique_ptr manager( BrowserAccessibilityManager::Create( @@ -983,7 +983,7 @@ TEST(BrowserAccessibilityManagerTest, BoundsForRangeOnParentElement) { TEST(BrowserAccessibilityManagerTest, TestNextPreviousInTreeOrder) { ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; + root.role = ax::mojom::Role::kRootWebArea; ui::AXNodeData node2; node2.id = 2; @@ -1047,43 +1047,43 @@ TEST(BrowserAccessibilityManagerTest, TestNextPreviousInTreeOrder) { EXPECT_EQ(root_accessible, manager->PreviousInTreeOrder(node2_accessible, true)); - EXPECT_EQ(ui::AX_TREE_ORDER_EQUAL, - BrowserAccessibilityManager::CompareNodes( - *root_accessible, *root_accessible)); - - EXPECT_EQ(ui::AX_TREE_ORDER_BEFORE, - BrowserAccessibilityManager::CompareNodes( - *node2_accessible, *node3_accessible)); - EXPECT_EQ(ui::AX_TREE_ORDER_AFTER, - BrowserAccessibilityManager::CompareNodes( - *node3_accessible, *node2_accessible)); - - EXPECT_EQ(ui::AX_TREE_ORDER_BEFORE, - BrowserAccessibilityManager::CompareNodes( - *node2_accessible, *node4_accessible)); - EXPECT_EQ(ui::AX_TREE_ORDER_AFTER, - BrowserAccessibilityManager::CompareNodes( - *node4_accessible, *node2_accessible)); - - EXPECT_EQ(ui::AX_TREE_ORDER_BEFORE, - BrowserAccessibilityManager::CompareNodes( - *node3_accessible, *node4_accessible)); - EXPECT_EQ(ui::AX_TREE_ORDER_AFTER, - BrowserAccessibilityManager::CompareNodes( - *node4_accessible, *node3_accessible)); - - EXPECT_EQ(ui::AX_TREE_ORDER_BEFORE, - BrowserAccessibilityManager::CompareNodes( - *root_accessible, *node2_accessible)); - EXPECT_EQ(ui::AX_TREE_ORDER_AFTER, - BrowserAccessibilityManager::CompareNodes( - *node2_accessible, *root_accessible)); + EXPECT_EQ(ax::mojom::TreeOrder::kEqual, + BrowserAccessibilityManager::CompareNodes(*root_accessible, + *root_accessible)); + + EXPECT_EQ(ax::mojom::TreeOrder::kBefore, + BrowserAccessibilityManager::CompareNodes(*node2_accessible, + *node3_accessible)); + EXPECT_EQ(ax::mojom::TreeOrder::kAfter, + BrowserAccessibilityManager::CompareNodes(*node3_accessible, + *node2_accessible)); + + EXPECT_EQ(ax::mojom::TreeOrder::kBefore, + BrowserAccessibilityManager::CompareNodes(*node2_accessible, + *node4_accessible)); + EXPECT_EQ(ax::mojom::TreeOrder::kAfter, + BrowserAccessibilityManager::CompareNodes(*node4_accessible, + *node2_accessible)); + + EXPECT_EQ(ax::mojom::TreeOrder::kBefore, + BrowserAccessibilityManager::CompareNodes(*node3_accessible, + *node4_accessible)); + EXPECT_EQ(ax::mojom::TreeOrder::kAfter, + BrowserAccessibilityManager::CompareNodes(*node4_accessible, + *node3_accessible)); + + EXPECT_EQ(ax::mojom::TreeOrder::kBefore, + BrowserAccessibilityManager::CompareNodes(*root_accessible, + *node2_accessible)); + EXPECT_EQ(ax::mojom::TreeOrder::kAfter, + BrowserAccessibilityManager::CompareNodes(*node2_accessible, + *root_accessible)); } TEST(BrowserAccessibilityManagerTest, TestNextPreviousTextOnlyObject) { ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; + root.role = ax::mojom::Role::kRootWebArea; ui::AXNodeData node2; node2.id = 2; @@ -1091,7 +1091,7 @@ TEST(BrowserAccessibilityManagerTest, TestNextPreviousTextOnlyObject) { ui::AXNodeData text1; text1.id = 3; - text1.role = ui::AX_ROLE_STATIC_TEXT; + text1.role = ax::mojom::Role::kStaticText; root.child_ids.push_back(3); ui::AXNodeData node3; @@ -1100,7 +1100,7 @@ TEST(BrowserAccessibilityManagerTest, TestNextPreviousTextOnlyObject) { ui::AXNodeData text2; text2.id = 5; - text2.role = ui::AX_ROLE_STATIC_TEXT; + text2.role = ax::mojom::Role::kStaticText; node3.child_ids.push_back(5); ui::AXNodeData node4; @@ -1109,7 +1109,7 @@ TEST(BrowserAccessibilityManagerTest, TestNextPreviousTextOnlyObject) { ui::AXNodeData text3; text3.id = 7; - text3.role = ui::AX_ROLE_STATIC_TEXT; + text3.role = ax::mojom::Role::kStaticText; node3.child_ids.push_back(7); ui::AXNodeData node5; @@ -1118,7 +1118,7 @@ TEST(BrowserAccessibilityManagerTest, TestNextPreviousTextOnlyObject) { ui::AXNodeData text4; text4.id = 9; - text4.role = ui::AX_ROLE_LINE_BREAK; + text4.role = ax::mojom::Role::kLineBreak; node5.child_ids.push_back(9); std::unique_ptr manager( @@ -1184,49 +1184,49 @@ TEST(BrowserAccessibilityManagerTest, TestNextPreviousTextOnlyObject) { TEST(BrowserAccessibilityManagerTest, TestFindIndicesInCommonParent) { ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; + root.role = ax::mojom::Role::kRootWebArea; ui::AXNodeData div; div.id = 2; - div.role = ui::AX_ROLE_GENERIC_CONTAINER; + div.role = ax::mojom::Role::kGenericContainer; root.child_ids.push_back(div.id); ui::AXNodeData button; button.id = 3; - button.role = ui::AX_ROLE_BUTTON; + button.role = ax::mojom::Role::kButton; div.child_ids.push_back(button.id); ui::AXNodeData button_text; button_text.id = 4; - button_text.role = ui::AX_ROLE_STATIC_TEXT; + button_text.role = ax::mojom::Role::kStaticText; button_text.SetName("Button"); button.child_ids.push_back(button_text.id); ui::AXNodeData line_break; line_break.id = 5; - line_break.role = ui::AX_ROLE_LINE_BREAK; + line_break.role = ax::mojom::Role::kLineBreak; line_break.SetName("\n"); div.child_ids.push_back(line_break.id); ui::AXNodeData paragraph; paragraph.id = 6; - paragraph.role = ui::AX_ROLE_PARAGRAPH; + paragraph.role = ax::mojom::Role::kParagraph; root.child_ids.push_back(paragraph.id); ui::AXNodeData paragraph_text; paragraph_text.id = 7; - paragraph_text.role = ui::AX_ROLE_STATIC_TEXT; + paragraph_text.role = ax::mojom::Role::kStaticText; paragraph.child_ids.push_back(paragraph_text.id); ui::AXNodeData paragraph_line1; paragraph_line1.id = 8; - paragraph_line1.role = ui::AX_ROLE_INLINE_TEXT_BOX; + paragraph_line1.role = ax::mojom::Role::kInlineTextBox; paragraph_line1.SetName("Hello "); paragraph_text.child_ids.push_back(paragraph_line1.id); ui::AXNodeData paragraph_line2; paragraph_line2.id = 9; - paragraph_line2.role = ui::AX_ROLE_INLINE_TEXT_BOX; + paragraph_line2.role = ax::mojom::Role::kInlineTextBox; paragraph_line2.SetName("world."); paragraph_text.child_ids.push_back(paragraph_line2.id); @@ -1327,50 +1327,50 @@ TEST(BrowserAccessibilityManagerTest, TestFindIndicesInCommonParent) { TEST(BrowserAccessibilityManagerTest, TestGetTextForRange) { ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; + root.role = ax::mojom::Role::kRootWebArea; ui::AXNodeData div; div.id = 2; - div.role = ui::AX_ROLE_GENERIC_CONTAINER; + div.role = ax::mojom::Role::kGenericContainer; root.child_ids.push_back(div.id); ui::AXNodeData button; button.id = 3; - button.role = ui::AX_ROLE_BUTTON; + button.role = ax::mojom::Role::kButton; div.child_ids.push_back(button.id); ui::AXNodeData button_text; button_text.id = 4; - button_text.role = ui::AX_ROLE_STATIC_TEXT; + button_text.role = ax::mojom::Role::kStaticText; button_text.SetName("Button"); button.child_ids.push_back(button_text.id); ui::AXNodeData line_break; line_break.id = 5; - line_break.role = ui::AX_ROLE_LINE_BREAK; + line_break.role = ax::mojom::Role::kLineBreak; line_break.SetName("\n"); div.child_ids.push_back(line_break.id); ui::AXNodeData paragraph; paragraph.id = 6; - paragraph.role = ui::AX_ROLE_PARAGRAPH; + paragraph.role = ax::mojom::Role::kParagraph; root.child_ids.push_back(paragraph.id); ui::AXNodeData paragraph_text; paragraph_text.id = 7; - paragraph_text.role = ui::AX_ROLE_STATIC_TEXT; + paragraph_text.role = ax::mojom::Role::kStaticText; paragraph_text.SetName("Hello world."); paragraph.child_ids.push_back(paragraph_text.id); ui::AXNodeData paragraph_line1; paragraph_line1.id = 8; - paragraph_line1.role = ui::AX_ROLE_INLINE_TEXT_BOX; + paragraph_line1.role = ax::mojom::Role::kInlineTextBox; paragraph_line1.SetName("Hello "); paragraph_text.child_ids.push_back(paragraph_line1.id); ui::AXNodeData paragraph_line2; paragraph_line2.id = 9; - paragraph_line2.role = ui::AX_ROLE_INLINE_TEXT_BOX; + paragraph_line2.role = ax::mojom::Role::kInlineTextBox; paragraph_line2.SetName("world."); paragraph_text.child_ids.push_back(paragraph_line2.id); @@ -1494,7 +1494,7 @@ TEST(BrowserAccessibilityManagerTest, DeletingFocusedNodeDoesNotCrash) { // Create a really simple tree with one root node and one focused child. ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; + root.role = ax::mojom::Role::kRootWebArea; root.child_ids.push_back(2); ui::AXNodeData node2; @@ -1513,13 +1513,13 @@ TEST(BrowserAccessibilityManagerTest, DeletingFocusedNodeDoesNotCrash) { // Now replace the tree with a new tree consisting of a single root. ui::AXNodeData root2; root2.id = 3; - root2.role = ui::AX_ROLE_ROOT_WEB_AREA; + root2.role = ax::mojom::Role::kRootWebArea; std::vector events2; events2.push_back(AXEventNotificationDetails()); events2[0].update = MakeAXTreeUpdate(root2); events2[0].id = -1; - events2[0].event_type = ui::AX_EVENT_NONE; + events2[0].event_type = ax::mojom::Event::kNone; manager->OnAccessibilityEvents(events2); // Make sure that the focused node was updated to the new root and @@ -1532,7 +1532,7 @@ TEST(BrowserAccessibilityManagerTest, DeletingFocusedNodeDoesNotCrash2) { // Create a really simple tree with one root node and one focused child. ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; + root.role = ax::mojom::Role::kRootWebArea; root.child_ids.push_back(2); root.child_ids.push_back(3); root.child_ids.push_back(4); @@ -1559,7 +1559,7 @@ TEST(BrowserAccessibilityManagerTest, DeletingFocusedNodeDoesNotCrash2) { // Now replace the tree with a new tree consisting of a single root. ui::AXNodeData root2; root2.id = 3; - root2.role = ui::AX_ROLE_ROOT_WEB_AREA; + root2.role = ax::mojom::Role::kRootWebArea; // Make an update the explicitly clears the previous root. std::vector events2; @@ -1567,7 +1567,7 @@ TEST(BrowserAccessibilityManagerTest, DeletingFocusedNodeDoesNotCrash2) { events2[0].update = MakeAXTreeUpdate(root2); events2[0].update.node_id_to_clear = 1; events2[0].id = -1; - events2[0].event_type = ui::AX_EVENT_NONE; + events2[0].event_type = ax::mojom::Event::kNone; manager->OnAccessibilityEvents(events2); // Make sure that the focused node was updated to the new root and diff --git a/content/browser/accessibility/browser_accessibility_manager_win.cc b/content/browser/accessibility/browser_accessibility_manager_win.cc index e5a1c931547e7c..4f019bc3e80398 100644 --- a/content/browser/accessibility/browser_accessibility_manager_win.cc +++ b/content/browser/accessibility/browser_accessibility_manager_win.cc @@ -56,8 +56,8 @@ ui::AXTreeUpdate BrowserAccessibilityManagerWin::GetEmptyDocument() { ui::AXNodeData empty_document; empty_document.id = 0; - empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA; - empty_document.AddBoolAttribute(ui::AX_ATTR_BUSY, true); + empty_document.role = ax::mojom::Role::kRootWebArea; + empty_document.AddBoolAttribute(ax::mojom::BoolAttribute::kBusy, true); ui::AXTreeUpdate update; update.root_id = empty_document.id; @@ -105,14 +105,14 @@ void BrowserAccessibilityManagerWin::FireFocusEvent( } void BrowserAccessibilityManagerWin::FireBlinkEvent( - ui::AXEvent event_type, + ax::mojom::Event event_type, BrowserAccessibility* node) { BrowserAccessibilityManager::FireBlinkEvent(event_type, node); switch (event_type) { - case ui::AX_EVENT_LOCATION_CHANGED: + case ax::mojom::Event::kLocationChanged: FireWinAccessibilityEvent(IA2_EVENT_VISIBLE_DATA_CHANGED, node); break; - case ui::AX_EVENT_SCROLLED_TO_ANCHOR: + case ax::mojom::Event::kScrolledToAnchor: FireWinAccessibilityEvent(EVENT_SYSTEM_SCROLLINGSTART, node); break; default: @@ -213,7 +213,7 @@ void BrowserAccessibilityManagerWin::FireWinAccessibilityEvent( // Inline text boxes are an internal implementation detail, we don't // expose them to Windows. - if (node->GetRole() == ui::AX_ROLE_INLINE_TEXT_BOX) + if (node->GetRole() == ax::mojom::Role::kInlineTextBox) return; // Pass the negation of this node's unique id in the |child_id| diff --git a/content/browser/accessibility/browser_accessibility_manager_win.h b/content/browser/accessibility/browser_accessibility_manager_win.h index 6a4a65a5d8f710..ff982d080c3c19 100644 --- a/content/browser/accessibility/browser_accessibility_manager_win.h +++ b/content/browser/accessibility/browser_accessibility_manager_win.h @@ -43,7 +43,7 @@ class CONTENT_EXPORT BrowserAccessibilityManagerWin gfx::Rect GetViewBounds() override; void FireFocusEvent(BrowserAccessibility* node) override; - void FireBlinkEvent(ui::AXEvent event_type, + void FireBlinkEvent(ax::mojom::Event event_type, BrowserAccessibility* node) override; void FireGeneratedEvent(AXEventGenerator::Event event_type, BrowserAccessibility* node) override; diff --git a/content/browser/accessibility/browser_accessibility_position.cc b/content/browser/accessibility/browser_accessibility_position.cc index 392be1972397e0..b7f027966f5427 100644 --- a/content/browser/accessibility/browser_accessibility_position.cc +++ b/content/browser/accessibility/browser_accessibility_position.cc @@ -9,7 +9,7 @@ #include "content/browser/accessibility/accessibility_flags.h" #include "content/browser/accessibility/browser_accessibility.h" #include "content/browser/accessibility/browser_accessibility_manager.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" namespace content { @@ -136,14 +136,16 @@ std::vector BrowserAccessibilityPosition::GetWordStartOffsets() const { if (IsNullPosition()) return std::vector(); DCHECK(GetAnchor()); - return GetAnchor()->GetIntListAttribute(ui::AX_ATTR_WORD_STARTS); + return GetAnchor()->GetIntListAttribute( + ax::mojom::IntListAttribute::kWordStarts); } std::vector BrowserAccessibilityPosition::GetWordEndOffsets() const { if (IsNullPosition()) return std::vector(); DCHECK(GetAnchor()); - return GetAnchor()->GetIntListAttribute(ui::AX_ATTR_WORD_ENDS); + return GetAnchor()->GetIntListAttribute( + ax::mojom::IntListAttribute::kWordEnds); } int32_t BrowserAccessibilityPosition::GetNextOnLineID(int32_t node_id) const { @@ -151,8 +153,8 @@ int32_t BrowserAccessibilityPosition::GetNextOnLineID(int32_t node_id) const { return INVALID_ANCHOR_ID; BrowserAccessibility* node = GetNodeInTree(tree_id(), node_id); int next_on_line_id; - if (!node || - !node->GetIntAttribute(ui::AX_ATTR_NEXT_ON_LINE_ID, &next_on_line_id)) { + if (!node || !node->GetIntAttribute(ax::mojom::IntAttribute::kNextOnLineId, + &next_on_line_id)) { return INVALID_ANCHOR_ID; } return static_cast(next_on_line_id); @@ -164,8 +166,9 @@ int32_t BrowserAccessibilityPosition::GetPreviousOnLineID( return INVALID_ANCHOR_ID; BrowserAccessibility* node = GetNodeInTree(tree_id(), node_id); int previous_on_line_id; - if (!node || !node->GetIntAttribute(ui::AX_ATTR_PREVIOUS_ON_LINE_ID, - &previous_on_line_id)) { + if (!node || + !node->GetIntAttribute(ax::mojom::IntAttribute::kPreviousOnLineId, + &previous_on_line_id)) { return INVALID_ANCHOR_ID; } return static_cast(previous_on_line_id); diff --git a/content/browser/accessibility/browser_accessibility_win_unittest.cc b/content/browser/accessibility/browser_accessibility_win_unittest.cc index fad7dcf5c361fc..b410bf74463255 100644 --- a/content/browser/accessibility/browser_accessibility_win_unittest.cc +++ b/content/browser/accessibility/browser_accessibility_win_unittest.cc @@ -64,17 +64,17 @@ TEST_F(BrowserAccessibilityTest, TestNoLeaks) { ui::AXNodeData button; button.id = 2; button.SetName("Button"); - button.role = ui::AX_ROLE_BUTTON; + button.role = ax::mojom::Role::kButton; ui::AXNodeData checkbox; checkbox.id = 3; checkbox.SetName("Checkbox"); - checkbox.role = ui::AX_ROLE_CHECK_BOX; + checkbox.role = ax::mojom::Role::kCheckBox; ui::AXNodeData root; root.id = 1; root.SetName("Document"); - root.role = ui::AX_ROLE_ROOT_WEB_AREA; + root.role = ax::mojom::Role::kRootWebArea; root.child_ids.push_back(2); root.child_ids.push_back(3); @@ -122,13 +122,13 @@ TEST_F(BrowserAccessibilityTest, TestChildrenChange) { // BrowserAccessibilityManager. ui::AXNodeData text; text.id = 2; - text.role = ui::AX_ROLE_STATIC_TEXT; + text.role = ax::mojom::Role::kStaticText; text.SetName("old text"); ui::AXNodeData root; root.id = 1; root.SetName("Document"); - root.role = ui::AX_ROLE_ROOT_WEB_AREA; + root.role = ax::mojom::Role::kRootWebArea; root.child_ids.push_back(2); // Construct a BrowserAccessibilityManager with this @@ -164,10 +164,10 @@ TEST_F(BrowserAccessibilityTest, TestChildrenChange) { // Notify the BrowserAccessibilityManager that the text child has changed. AXContentNodeData text2; text2.id = 2; - text2.role = ui::AX_ROLE_STATIC_TEXT; + text2.role = ax::mojom::Role::kStaticText; text2.SetName("new text"); AXEventNotificationDetails param; - param.event_type = ui::AX_EVENT_CHILDREN_CHANGED; + param.event_type = ax::mojom::Event::kChildrenChanged; param.update.nodes.push_back(text2); param.id = text2.id; std::vector events; @@ -202,22 +202,22 @@ TEST_F(BrowserAccessibilityTest, TestChildrenChangeNoLeaks) { // BrowserAccessibilityManager. ui::AXNodeData div; div.id = 2; - div.role = ui::AX_ROLE_GROUP; + div.role = ax::mojom::Role::kGroup; ui::AXNodeData text3; text3.id = 3; - text3.role = ui::AX_ROLE_STATIC_TEXT; + text3.role = ax::mojom::Role::kStaticText; ui::AXNodeData text4; text4.id = 4; - text4.role = ui::AX_ROLE_STATIC_TEXT; + text4.role = ax::mojom::Role::kStaticText; div.child_ids.push_back(3); div.child_ids.push_back(4); ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; + root.role = ax::mojom::Role::kRootWebArea; root.child_ids.push_back(2); // Construct a BrowserAccessibilityManager with this @@ -233,7 +233,7 @@ TEST_F(BrowserAccessibilityTest, TestChildrenChangeNoLeaks) { // were removed and ensure that only one BrowserAccessibility instance exists. root.child_ids.clear(); AXEventNotificationDetails param; - param.event_type = ui::AX_EVENT_CHILDREN_CHANGED; + param.event_type = ax::mojom::Event::kChildrenChanged; param.update.nodes.push_back(root); param.id = root.id; std::vector events; @@ -252,17 +252,17 @@ TEST_F(BrowserAccessibilityTest, TestTextBoundaries) { ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; + root.role = ax::mojom::Role::kRootWebArea; root.child_ids.push_back(2); ui::AXNodeData text_field; text_field.id = 2; - text_field.role = ui::AX_ROLE_TEXT_FIELD; - text_field.AddState(ui::AX_STATE_EDITABLE); + text_field.role = ax::mojom::Role::kTextField; + text_field.AddState(ax::mojom::State::kEditable); text_field.SetValue(text_value); std::vector line_start_offsets; line_start_offsets.push_back(15); - text_field.AddIntListAttribute(ui::AX_ATTR_CACHED_LINE_STARTS, + text_field.AddIntListAttribute(ax::mojom::IntListAttribute::kCachedLineStarts, line_start_offsets); text_field.child_ids.push_back(3); text_field.child_ids.push_back(5); @@ -270,50 +270,52 @@ TEST_F(BrowserAccessibilityTest, TestTextBoundaries) { ui::AXNodeData static_text1; static_text1.id = 3; - static_text1.role = ui::AX_ROLE_STATIC_TEXT; - static_text1.AddState(ui::AX_STATE_EDITABLE); + static_text1.role = ax::mojom::Role::kStaticText; + static_text1.AddState(ax::mojom::State::kEditable); static_text1.SetName(line1); static_text1.child_ids.push_back(4); ui::AXNodeData inline_box1; inline_box1.id = 4; - inline_box1.role = ui::AX_ROLE_INLINE_TEXT_BOX; - inline_box1.AddState(ui::AX_STATE_EDITABLE); + inline_box1.role = ax::mojom::Role::kInlineTextBox; + inline_box1.AddState(ax::mojom::State::kEditable); inline_box1.SetName(line1); std::vector word_start_offsets1; word_start_offsets1.push_back(0); word_start_offsets1.push_back(4); word_start_offsets1.push_back(8); - inline_box1.AddIntListAttribute( - ui::AX_ATTR_WORD_STARTS, word_start_offsets1); + inline_box1.AddIntListAttribute(ax::mojom::IntListAttribute::kWordStarts, + word_start_offsets1); ui::AXNodeData line_break; line_break.id = 5; - line_break.role = ui::AX_ROLE_LINE_BREAK; - line_break.AddState(ui::AX_STATE_EDITABLE); + line_break.role = ax::mojom::Role::kLineBreak; + line_break.AddState(ax::mojom::State::kEditable); line_break.SetName("\n"); - inline_box1.AddIntAttribute(ui::AX_ATTR_NEXT_ON_LINE_ID, line_break.id); - line_break.AddIntAttribute(ui::AX_ATTR_PREVIOUS_ON_LINE_ID, inline_box1.id); + inline_box1.AddIntAttribute(ax::mojom::IntAttribute::kNextOnLineId, + line_break.id); + line_break.AddIntAttribute(ax::mojom::IntAttribute::kPreviousOnLineId, + inline_box1.id); ui::AXNodeData static_text2; static_text2.id = 6; - static_text2.role = ui::AX_ROLE_STATIC_TEXT; - static_text2.AddState(ui::AX_STATE_EDITABLE); + static_text2.role = ax::mojom::Role::kStaticText; + static_text2.AddState(ax::mojom::State::kEditable); static_text2.SetName(line2); static_text2.child_ids.push_back(7); ui::AXNodeData inline_box2; inline_box2.id = 7; - inline_box2.role = ui::AX_ROLE_INLINE_TEXT_BOX; - inline_box2.AddState(ui::AX_STATE_EDITABLE); + inline_box2.role = ax::mojom::Role::kInlineTextBox; + inline_box2.AddState(ax::mojom::State::kEditable); inline_box2.SetName(line2); std::vector word_start_offsets2; word_start_offsets2.push_back(0); word_start_offsets2.push_back(5); word_start_offsets2.push_back(10); - inline_box2.AddIntListAttribute( - ui::AX_ATTR_WORD_STARTS, word_start_offsets2); + inline_box2.AddIntListAttribute(ax::mojom::IntListAttribute::kWordStarts, + word_start_offsets2); std::unique_ptr manager( BrowserAccessibilityManager::Create( @@ -416,17 +418,17 @@ TEST_F(BrowserAccessibilityTest, TestSimpleHypertext) { ui::AXNodeData text1; text1.id = 11; - text1.role = ui::AX_ROLE_STATIC_TEXT; + text1.role = ax::mojom::Role::kStaticText; text1.SetName(text1_name); ui::AXNodeData text2; text2.id = 12; - text2.role = ui::AX_ROLE_STATIC_TEXT; + text2.role = ax::mojom::Role::kStaticText; text2.SetName(text2_name); ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; + root.role = ax::mojom::Role::kRootWebArea; root.child_ids.push_back(text1.id); root.child_ids.push_back(text2.id); @@ -494,25 +496,25 @@ TEST_F(BrowserAccessibilityTest, TestComplexHypertext) { ui::AXNodeData text1; text1.id = 11; - text1.role = ui::AX_ROLE_STATIC_TEXT; + text1.role = ax::mojom::Role::kStaticText; text1.SetName(base::UTF16ToUTF8(text1_name)); ui::AXNodeData combo_box; combo_box.id = 12; - combo_box.role = ui::AX_ROLE_TEXT_FIELD_WITH_COMBO_BOX; - combo_box.AddState(ui::AX_STATE_EDITABLE); + combo_box.role = ax::mojom::Role::kTextFieldWithComboBox; + combo_box.AddState(ax::mojom::State::kEditable); combo_box.SetName(base::UTF16ToUTF8(combo_box_name)); combo_box.SetValue(base::UTF16ToUTF8(combo_box_value)); ui::AXNodeData text2; text2.id = 13; - text2.role = ui::AX_ROLE_STATIC_TEXT; + text2.role = ax::mojom::Role::kStaticText; text2.SetName(base::UTF16ToUTF8(text2_name)); ui::AXNodeData check_box; check_box.id = 14; - check_box.role = ui::AX_ROLE_CHECK_BOX; - check_box.SetCheckedState(ui::AX_CHECKED_STATE_TRUE); + check_box.role = ax::mojom::Role::kCheckBox; + check_box.SetCheckedState(ax::mojom::CheckedState::kTrue); check_box.SetName(base::UTF16ToUTF8(check_box_name)); check_box.SetValue(base::UTF16ToUTF8(check_box_value)); @@ -520,21 +522,21 @@ TEST_F(BrowserAccessibilityTest, TestComplexHypertext) { button.id = 15; button_text.id = 17; button_text.SetName(base::UTF16ToUTF8(button_text_name)); - button.role = ui::AX_ROLE_BUTTON; - button_text.role = ui::AX_ROLE_STATIC_TEXT; + button.role = ax::mojom::Role::kButton; + button_text.role = ax::mojom::Role::kStaticText; button.child_ids.push_back(button_text.id); ui::AXNodeData link, link_text; link.id = 16; link_text.id = 18; link_text.SetName(base::UTF16ToUTF8(link_text_name)); - link.role = ui::AX_ROLE_LINK; - link_text.role = ui::AX_ROLE_STATIC_TEXT; + link.role = ax::mojom::Role::kLink; + link_text.role = ax::mojom::Role::kStaticText; link.child_ids.push_back(link_text.id); ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; + root.role = ax::mojom::Role::kRootWebArea; root.child_ids.push_back(text1.id); root.child_ids.push_back(combo_box.id); root.child_ids.push_back(text2.id); @@ -642,25 +644,25 @@ TEST_F(BrowserAccessibilityTest, TestCreateEmptyDocument) { // Verify the root is as we expect by default. BrowserAccessibility* root = manager->GetRoot(); EXPECT_EQ(0, root->GetId()); - EXPECT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, root->GetRole()); + EXPECT_EQ(ax::mojom::Role::kRootWebArea, root->GetRole()); EXPECT_EQ(0, root->GetState()); - EXPECT_EQ(true, root->GetBoolAttribute(ui::AX_ATTR_BUSY)); + EXPECT_EQ(true, root->GetBoolAttribute(ax::mojom::BoolAttribute::kBusy)); // Tree with a child textfield. ui::AXNodeData tree1_1; tree1_1.id = 1; - tree1_1.role = ui::AX_ROLE_ROOT_WEB_AREA; + tree1_1.role = ax::mojom::Role::kRootWebArea; tree1_1.child_ids.push_back(2); ui::AXNodeData tree1_2; tree1_2.id = 2; - tree1_2.role = ui::AX_ROLE_TEXT_FIELD; + tree1_2.role = ax::mojom::Role::kTextField; // Process a load complete. std::vector params; params.push_back(AXEventNotificationDetails()); AXEventNotificationDetails* msg = ¶ms[0]; - msg->event_type = ui::AX_EVENT_LOAD_COMPLETE; + msg->event_type = ax::mojom::Event::kLoadComplete; msg->update.root_id = tree1_1.id; msg->update.nodes.push_back(tree1_1); msg->update.nodes.push_back(tree1_2); @@ -674,18 +676,18 @@ TEST_F(BrowserAccessibilityTest, TestCreateEmptyDocument) { EXPECT_NE(root, manager->GetRoot()); // And the proper child remains. - EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, acc1_2->GetRole()); + EXPECT_EQ(ax::mojom::Role::kTextField, acc1_2->GetRole()); EXPECT_EQ(2, acc1_2->GetId()); // Tree with a child button. ui::AXNodeData tree2_1; tree2_1.id = 1; - tree2_1.role = ui::AX_ROLE_ROOT_WEB_AREA; + tree2_1.role = ax::mojom::Role::kRootWebArea; tree2_1.child_ids.push_back(3); ui::AXNodeData tree2_2; tree2_2.id = 3; - tree2_2.role = ui::AX_ROLE_BUTTON; + tree2_2.role = ax::mojom::Role::kButton; msg->update.nodes.clear(); msg->update.nodes.push_back(tree2_1); @@ -701,7 +703,7 @@ TEST_F(BrowserAccessibilityTest, TestCreateEmptyDocument) { EXPECT_NE(root, manager->GetRoot()); // And the new child exists. - EXPECT_EQ(ui::AX_ROLE_BUTTON, acc2_2->GetRole()); + EXPECT_EQ(ax::mojom::Role::kButton, acc2_2->GetRole()); EXPECT_EQ(3, acc2_2->GetId()); // Ensure we properly cleaned up. @@ -727,9 +729,9 @@ TEST_F(BrowserAccessibilityTest, EmptyDocHasUniqueIdWin) { // Verify the root is as we expect by default. BrowserAccessibility* root = manager->GetRoot(); EXPECT_EQ(0, root->GetId()); - EXPECT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, root->GetRole()); + EXPECT_EQ(ax::mojom::Role::kRootWebArea, root->GetRole()); EXPECT_EQ(0, root->GetState()); - EXPECT_EQ(true, root->GetBoolAttribute(ui::AX_ATTR_BUSY)); + EXPECT_EQ(true, root->GetBoolAttribute(ax::mojom::BoolAttribute::kBusy)); BrowserAccessibilityWin* win_root = ToBrowserAccessibilityWin(root); @@ -744,21 +746,23 @@ TEST_F(BrowserAccessibilityTest, EmptyDocHasUniqueIdWin) { TEST_F(BrowserAccessibilityTest, TestIA2Attributes) { ui::AXNodeData pseudo_before; pseudo_before.id = 2; - pseudo_before.role = ui::AX_ROLE_GENERIC_CONTAINER; - pseudo_before.AddStringAttribute(ui::AX_ATTR_HTML_TAG, ""); - pseudo_before.AddStringAttribute(ui::AX_ATTR_DISPLAY, "none"); + pseudo_before.role = ax::mojom::Role::kGenericContainer; + pseudo_before.AddStringAttribute(ax::mojom::StringAttribute::kHtmlTag, + ""); + pseudo_before.AddStringAttribute(ax::mojom::StringAttribute::kDisplay, + "none"); ui::AXNodeData checkbox; checkbox.id = 3; checkbox.SetName("Checkbox"); - checkbox.role = ui::AX_ROLE_CHECK_BOX; - checkbox.SetCheckedState(ui::AX_CHECKED_STATE_TRUE); + checkbox.role = ax::mojom::Role::kCheckBox; + checkbox.SetCheckedState(ax::mojom::CheckedState::kTrue); ui::AXNodeData root; root.id = 1; root.SetName("Document"); - root.role = ui::AX_ROLE_ROOT_WEB_AREA; - root.AddState(ui::AX_STATE_FOCUSABLE); + root.role = ax::mojom::Role::kRootWebArea; + root.AddState(ax::mojom::State::kFocusable); root.child_ids.push_back(2); root.child_ids.push_back(3); @@ -802,22 +806,22 @@ TEST_F(BrowserAccessibilityTest, TestIA2Attributes) { TEST_F(BrowserAccessibilityTest, TestValueAttributeInTextControls) { ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; - root.AddState(ui::AX_STATE_FOCUSABLE); + root.role = ax::mojom::Role::kRootWebArea; + root.AddState(ax::mojom::State::kFocusable); ui::AXNodeData combo_box, combo_box_text; combo_box.id = 2; combo_box_text.id = 3; combo_box.SetName("Combo box:"); combo_box_text.SetName("Combo box text"); - combo_box.role = ui::AX_ROLE_TEXT_FIELD_WITH_COMBO_BOX; - combo_box_text.role = ui::AX_ROLE_STATIC_TEXT; - combo_box.AddBoolAttribute(ui::AX_ATTR_EDITABLE_ROOT, true); - combo_box.AddState(ui::AX_STATE_EDITABLE); - combo_box.AddState(ui::AX_STATE_RICHLY_EDITABLE); - combo_box.AddState(ui::AX_STATE_FOCUSABLE); - combo_box_text.AddState(ui::AX_STATE_EDITABLE); - combo_box_text.AddState(ui::AX_STATE_RICHLY_EDITABLE); + combo_box.role = ax::mojom::Role::kTextFieldWithComboBox; + combo_box_text.role = ax::mojom::Role::kStaticText; + combo_box.AddBoolAttribute(ax::mojom::BoolAttribute::kEditableRoot, true); + combo_box.AddState(ax::mojom::State::kEditable); + combo_box.AddState(ax::mojom::State::kRichlyEditable); + combo_box.AddState(ax::mojom::State::kFocusable); + combo_box_text.AddState(ax::mojom::State::kEditable); + combo_box_text.AddState(ax::mojom::State::kRichlyEditable); combo_box.child_ids.push_back(combo_box_text.id); ui::AXNodeData search_box, search_box_text, new_line; @@ -827,43 +831,43 @@ TEST_F(BrowserAccessibilityTest, TestValueAttributeInTextControls) { search_box.SetName("Search for:"); search_box_text.SetName("Search box text"); new_line.SetName("\n"); - search_box.role = ui::AX_ROLE_SEARCH_BOX; - search_box_text.role = ui::AX_ROLE_STATIC_TEXT; - new_line.role = ui::AX_ROLE_LINE_BREAK; - search_box.AddBoolAttribute(ui::AX_ATTR_EDITABLE_ROOT, true); - search_box.AddState(ui::AX_STATE_EDITABLE); - search_box.AddState(ui::AX_STATE_RICHLY_EDITABLE); - search_box.AddState(ui::AX_STATE_FOCUSABLE); - search_box_text.AddState(ui::AX_STATE_EDITABLE); - search_box_text.AddState(ui::AX_STATE_RICHLY_EDITABLE); - new_line.AddState(ui::AX_STATE_EDITABLE); - new_line.AddState(ui::AX_STATE_RICHLY_EDITABLE); + search_box.role = ax::mojom::Role::kSearchBox; + search_box_text.role = ax::mojom::Role::kStaticText; + new_line.role = ax::mojom::Role::kLineBreak; + search_box.AddBoolAttribute(ax::mojom::BoolAttribute::kEditableRoot, true); + search_box.AddState(ax::mojom::State::kEditable); + search_box.AddState(ax::mojom::State::kRichlyEditable); + search_box.AddState(ax::mojom::State::kFocusable); + search_box_text.AddState(ax::mojom::State::kEditable); + search_box_text.AddState(ax::mojom::State::kRichlyEditable); + new_line.AddState(ax::mojom::State::kEditable); + new_line.AddState(ax::mojom::State::kRichlyEditable); search_box.child_ids.push_back(search_box_text.id); search_box.child_ids.push_back(new_line.id); ui::AXNodeData text_field; text_field.id = 7; - text_field.role = ui::AX_ROLE_TEXT_FIELD; - text_field.AddBoolAttribute(ui::AX_ATTR_EDITABLE_ROOT, true); - text_field.AddState(ui::AX_STATE_EDITABLE); - text_field.AddState(ui::AX_STATE_FOCUSABLE); + text_field.role = ax::mojom::Role::kTextField; + text_field.AddBoolAttribute(ax::mojom::BoolAttribute::kEditableRoot, true); + text_field.AddState(ax::mojom::State::kEditable); + text_field.AddState(ax::mojom::State::kFocusable); text_field.SetValue("Text field text"); ui::AXNodeData link, link_text; link.id = 8; link_text.id = 9; link_text.SetName("Link text"); - link.role = ui::AX_ROLE_LINK; - link_text.role = ui::AX_ROLE_STATIC_TEXT; + link.role = ax::mojom::Role::kLink; + link_text.role = ax::mojom::Role::kStaticText; link.child_ids.push_back(link_text.id); ui::AXNodeData slider, slider_text; slider.id = 10; slider_text.id = 11; - slider.AddFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, 5.0F); + slider.AddFloatAttribute(ax::mojom::FloatAttribute::kValueForRange, 5.0F); slider_text.SetName("Slider text"); - slider.role = ui::AX_ROLE_SLIDER; - slider_text.role = ui::AX_ROLE_STATIC_TEXT; + slider.role = ax::mojom::Role::kSlider; + slider_text.role = ax::mojom::Role::kStaticText; slider.child_ids.push_back(slider_text.id); root.child_ids.push_back(2); // Combo box. @@ -969,39 +973,39 @@ TEST_F(BrowserAccessibilityTest, TestWordBoundariesInTextControls) { ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; - root.AddState(ui::AX_STATE_FOCUSABLE); + root.role = ax::mojom::Role::kRootWebArea; + root.AddState(ax::mojom::State::kFocusable); ui::AXNodeData textarea, textarea_div, textarea_text; textarea.id = 2; textarea_div.id = 3; textarea_text.id = 4; - textarea.role = ui::AX_ROLE_TEXT_FIELD; - textarea_div.role = ui::AX_ROLE_GENERIC_CONTAINER; - textarea_text.role = ui::AX_ROLE_STATIC_TEXT; - textarea.AddState(ui::AX_STATE_EDITABLE); - textarea.AddState(ui::AX_STATE_FOCUSABLE); - textarea.AddState(ui::AX_STATE_MULTILINE); - textarea_div.AddState(ui::AX_STATE_EDITABLE); - textarea_text.AddState(ui::AX_STATE_EDITABLE); + textarea.role = ax::mojom::Role::kTextField; + textarea_div.role = ax::mojom::Role::kGenericContainer; + textarea_text.role = ax::mojom::Role::kStaticText; + textarea.AddState(ax::mojom::State::kEditable); + textarea.AddState(ax::mojom::State::kFocusable); + textarea.AddState(ax::mojom::State::kMultiline); + textarea_div.AddState(ax::mojom::State::kEditable); + textarea_text.AddState(ax::mojom::State::kEditable); textarea.SetValue(base::UTF16ToUTF8(text)); textarea_text.SetName(base::UTF16ToUTF8(text)); - textarea.AddStringAttribute(ui::AX_ATTR_HTML_TAG, "textarea"); + textarea.AddStringAttribute(ax::mojom::StringAttribute::kHtmlTag, "textarea"); textarea.child_ids.push_back(textarea_div.id); textarea_div.child_ids.push_back(textarea_text.id); ui::AXNodeData textarea_line1, textarea_line2; textarea_line1.id = 5; textarea_line2.id = 6; - textarea_line1.role = ui::AX_ROLE_INLINE_TEXT_BOX; - textarea_line2.role = ui::AX_ROLE_INLINE_TEXT_BOX; - textarea_line1.AddState(ui::AX_STATE_EDITABLE); - textarea_line2.AddState(ui::AX_STATE_EDITABLE); + textarea_line1.role = ax::mojom::Role::kInlineTextBox; + textarea_line2.role = ax::mojom::Role::kInlineTextBox; + textarea_line1.AddState(ax::mojom::State::kEditable); + textarea_line2.AddState(ax::mojom::State::kEditable); textarea_line1.SetName(base::UTF16ToUTF8(line1)); textarea_line2.SetName(base::UTF16ToUTF8(line2)); - textarea_line1.AddIntListAttribute(ui::AX_ATTR_WORD_STARTS, + textarea_line1.AddIntListAttribute(ax::mojom::IntListAttribute::kWordStarts, line1_word_starts); - textarea_line2.AddIntListAttribute(ui::AX_ATTR_WORD_STARTS, + textarea_line2.AddIntListAttribute(ax::mojom::IntListAttribute::kWordStarts, line2_word_starts); textarea_text.child_ids.push_back(textarea_line1.id); textarea_text.child_ids.push_back(textarea_line2.id); @@ -1010,26 +1014,26 @@ TEST_F(BrowserAccessibilityTest, TestWordBoundariesInTextControls) { text_field.id = 7; text_field_div.id = 8; text_field_text.id = 9; - text_field.role = ui::AX_ROLE_TEXT_FIELD; - text_field_div.role = ui::AX_ROLE_GENERIC_CONTAINER; - text_field_text.role = ui::AX_ROLE_STATIC_TEXT; - text_field.AddState(ui::AX_STATE_EDITABLE); - text_field.AddState(ui::AX_STATE_FOCUSABLE); - text_field_div.AddState(ui::AX_STATE_EDITABLE); - text_field_text.AddState(ui::AX_STATE_EDITABLE); + text_field.role = ax::mojom::Role::kTextField; + text_field_div.role = ax::mojom::Role::kGenericContainer; + text_field_text.role = ax::mojom::Role::kStaticText; + text_field.AddState(ax::mojom::State::kEditable); + text_field.AddState(ax::mojom::State::kFocusable); + text_field_div.AddState(ax::mojom::State::kEditable); + text_field_text.AddState(ax::mojom::State::kEditable); text_field.SetValue(base::UTF16ToUTF8(line1)); text_field_text.SetName(base::UTF16ToUTF8(line1)); - text_field.AddStringAttribute(ui::AX_ATTR_HTML_TAG, "input"); + text_field.AddStringAttribute(ax::mojom::StringAttribute::kHtmlTag, "input"); text_field.html_attributes.push_back(std::make_pair("type", "text")); text_field.child_ids.push_back(text_field_div.id); text_field_div.child_ids.push_back(text_field_text.id); ui::AXNodeData text_field_line; text_field_line.id = 10; - text_field_line.role = ui::AX_ROLE_INLINE_TEXT_BOX; - text_field_line.AddState(ui::AX_STATE_EDITABLE); + text_field_line.role = ax::mojom::Role::kInlineTextBox; + text_field_line.AddState(ax::mojom::State::kEditable); text_field_line.SetName(base::UTF16ToUTF8(line1)); - text_field_line.AddIntListAttribute(ui::AX_ATTR_WORD_STARTS, + text_field_line.AddIntListAttribute(ax::mojom::IntListAttribute::kWordStarts, line1_word_starts); text_field_text.child_ids.push_back(text_field_line.id); @@ -1108,28 +1112,28 @@ TEST_F(BrowserAccessibilityTest, TestWordBoundariesInTextControls) { TEST_F(BrowserAccessibilityTest, TestCaretAndSelectionInSimpleFields) { ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; - root.AddState(ui::AX_STATE_FOCUSABLE); + root.role = ax::mojom::Role::kRootWebArea; + root.AddState(ax::mojom::State::kFocusable); ui::AXNodeData combo_box; combo_box.id = 2; - combo_box.role = ui::AX_ROLE_TEXT_FIELD_WITH_COMBO_BOX; - combo_box.AddState(ui::AX_STATE_EDITABLE); - combo_box.AddState(ui::AX_STATE_FOCUSABLE); + combo_box.role = ax::mojom::Role::kTextFieldWithComboBox; + combo_box.AddState(ax::mojom::State::kEditable); + combo_box.AddState(ax::mojom::State::kFocusable); combo_box.SetValue("Test1"); // Place the caret between 't' and 'e'. - combo_box.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, 1); - combo_box.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, 1); + combo_box.AddIntAttribute(ax::mojom::IntAttribute::kTextSelStart, 1); + combo_box.AddIntAttribute(ax::mojom::IntAttribute::kTextSelEnd, 1); ui::AXNodeData text_field; text_field.id = 3; - text_field.role = ui::AX_ROLE_TEXT_FIELD; - text_field.AddState(ui::AX_STATE_EDITABLE); - text_field.AddState(ui::AX_STATE_FOCUSABLE); + text_field.role = ax::mojom::Role::kTextField; + text_field.AddState(ax::mojom::State::kEditable); + text_field.AddState(ax::mojom::State::kFocusable); text_field.SetValue("Test2"); // Select the letter 'e'. - text_field.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, 1); - text_field.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, 2); + text_field.AddIntAttribute(ax::mojom::IntAttribute::kTextSelStart, 1); + text_field.AddIntAttribute(ax::mojom::IntAttribute::kTextSelEnd, 2); root.child_ids.push_back(2); root.child_ids.push_back(3); @@ -1204,35 +1208,35 @@ TEST_F(BrowserAccessibilityTest, TestCaretAndSelectionInSimpleFields) { TEST_F(BrowserAccessibilityTest, TestCaretInContentEditables) { ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; - root.AddState(ui::AX_STATE_FOCUSABLE); + root.role = ax::mojom::Role::kRootWebArea; + root.AddState(ax::mojom::State::kFocusable); ui::AXNodeData div_editable; div_editable.id = 2; - div_editable.role = ui::AX_ROLE_GENERIC_CONTAINER; - div_editable.AddState(ui::AX_STATE_EDITABLE); - div_editable.AddState(ui::AX_STATE_FOCUSABLE); + div_editable.role = ax::mojom::Role::kGenericContainer; + div_editable.AddState(ax::mojom::State::kEditable); + div_editable.AddState(ax::mojom::State::kFocusable); ui::AXNodeData text; text.id = 3; - text.role = ui::AX_ROLE_STATIC_TEXT; - text.AddState(ui::AX_STATE_EDITABLE); + text.role = ax::mojom::Role::kStaticText; + text.AddState(ax::mojom::State::kEditable); text.SetName("Click "); ui::AXNodeData link; link.id = 4; - link.role = ui::AX_ROLE_LINK; - link.AddState(ui::AX_STATE_EDITABLE); - link.AddState(ui::AX_STATE_FOCUSABLE); - link.AddState(ui::AX_STATE_LINKED); + link.role = ax::mojom::Role::kLink; + link.AddState(ax::mojom::State::kEditable); + link.AddState(ax::mojom::State::kFocusable); + link.AddState(ax::mojom::State::kLinked); link.SetName("here"); ui::AXNodeData link_text; link_text.id = 5; - link_text.role = ui::AX_ROLE_STATIC_TEXT; - link_text.AddState(ui::AX_STATE_EDITABLE); - link_text.AddState(ui::AX_STATE_FOCUSABLE); - link_text.AddState(ui::AX_STATE_LINKED); + link_text.role = ax::mojom::Role::kStaticText; + link_text.AddState(ax::mojom::State::kEditable); + link_text.AddState(ax::mojom::State::kFocusable); + link_text.AddState(ax::mojom::State::kLinked); link_text.SetName("here"); root.child_ids.push_back(2); @@ -1325,36 +1329,36 @@ TEST_F(BrowserAccessibilityTest, TestCaretInContentEditables) { TEST_F(BrowserAccessibilityTest, TestSelectionInContentEditables) { ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; - root.AddState(ui::AX_STATE_FOCUSABLE); + root.role = ax::mojom::Role::kRootWebArea; + root.AddState(ax::mojom::State::kFocusable); ui::AXNodeData div_editable; div_editable.id = 2; - div_editable.role = ui::AX_ROLE_GENERIC_CONTAINER; - div_editable.AddState(ui::AX_STATE_FOCUSABLE); - div_editable.AddState(ui::AX_STATE_EDITABLE); + div_editable.role = ax::mojom::Role::kGenericContainer; + div_editable.AddState(ax::mojom::State::kFocusable); + div_editable.AddState(ax::mojom::State::kEditable); ui::AXNodeData text; text.id = 3; - text.role = ui::AX_ROLE_STATIC_TEXT; - text.AddState(ui::AX_STATE_FOCUSABLE); - text.AddState(ui::AX_STATE_EDITABLE); + text.role = ax::mojom::Role::kStaticText; + text.AddState(ax::mojom::State::kFocusable); + text.AddState(ax::mojom::State::kEditable); text.SetName("Click "); ui::AXNodeData link; link.id = 4; - link.role = ui::AX_ROLE_LINK; - link.AddState(ui::AX_STATE_FOCUSABLE); - link.AddState(ui::AX_STATE_EDITABLE); - link.AddState(ui::AX_STATE_LINKED); + link.role = ax::mojom::Role::kLink; + link.AddState(ax::mojom::State::kFocusable); + link.AddState(ax::mojom::State::kEditable); + link.AddState(ax::mojom::State::kLinked); link.SetName("here"); ui::AXNodeData link_text; link_text.id = 5; - link_text.role = ui::AX_ROLE_STATIC_TEXT; - link_text.AddState(ui::AX_STATE_FOCUSABLE); - link_text.AddState(ui::AX_STATE_EDITABLE); - link_text.AddState(ui::AX_STATE_LINKED); + link_text.role = ax::mojom::Role::kStaticText; + link_text.AddState(ax::mojom::State::kFocusable); + link_text.AddState(ax::mojom::State::kEditable); + link_text.AddState(ax::mojom::State::kLinked); link_text.SetName("here"); root.child_ids.push_back(2); @@ -1481,26 +1485,26 @@ TEST_F(BrowserAccessibilityTest, TestSelectionInContentEditables) { TEST_F(BrowserAccessibilityTest, TestIAccessibleHyperlink) { ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; - root.AddState(ui::AX_STATE_FOCUSABLE); + root.role = ax::mojom::Role::kRootWebArea; + root.AddState(ax::mojom::State::kFocusable); ui::AXNodeData div; div.id = 2; - div.role = ui::AX_ROLE_GENERIC_CONTAINER; - div.AddState(ui::AX_STATE_FOCUSABLE); + div.role = ax::mojom::Role::kGenericContainer; + div.AddState(ax::mojom::State::kFocusable); ui::AXNodeData text; text.id = 3; - text.role = ui::AX_ROLE_STATIC_TEXT; + text.role = ax::mojom::Role::kStaticText; text.SetName("Click "); ui::AXNodeData link; link.id = 4; - link.role = ui::AX_ROLE_LINK; - link.AddState(ui::AX_STATE_FOCUSABLE); - link.AddState(ui::AX_STATE_LINKED); + link.role = ax::mojom::Role::kLink; + link.AddState(ax::mojom::State::kFocusable); + link.AddState(ax::mojom::State::kLinked); link.SetName("here"); - link.AddStringAttribute(ui::AX_ATTR_URL, "example.com"); + link.AddStringAttribute(ax::mojom::StringAttribute::kUrl, "example.com"); root.child_ids.push_back(2); div.child_ids.push_back(3); @@ -1642,59 +1646,65 @@ TEST_F(BrowserAccessibilityTest, TestIAccessibleHyperlink) { TEST_F(BrowserAccessibilityTest, TestTextAttributesInContentEditables) { ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; - root.AddState(ui::AX_STATE_FOCUSABLE); + root.role = ax::mojom::Role::kRootWebArea; + root.AddState(ax::mojom::State::kFocusable); ui::AXNodeData div_editable; div_editable.id = 2; - div_editable.role = ui::AX_ROLE_GENERIC_CONTAINER; - div_editable.AddState(ui::AX_STATE_EDITABLE); - div_editable.AddState(ui::AX_STATE_FOCUSABLE); - div_editable.AddStringAttribute(ui::AX_ATTR_FONT_FAMILY, "Helvetica"); + div_editable.role = ax::mojom::Role::kGenericContainer; + div_editable.AddState(ax::mojom::State::kEditable); + div_editable.AddState(ax::mojom::State::kFocusable); + div_editable.AddStringAttribute(ax::mojom::StringAttribute::kFontFamily, + "Helvetica"); ui::AXNodeData text_before; text_before.id = 3; - text_before.role = ui::AX_ROLE_STATIC_TEXT; - text_before.AddState(ui::AX_STATE_EDITABLE); + text_before.role = ax::mojom::Role::kStaticText; + text_before.AddState(ax::mojom::State::kEditable); text_before.SetName("Before "); text_before.AddIntAttribute( - ui::AX_ATTR_TEXT_STYLE, - static_cast(ui::AX_TEXT_STYLE_BOLD) | - static_cast(ui::AX_TEXT_STYLE_ITALIC)); + ax::mojom::IntAttribute::kTextStyle, + static_cast(ax::mojom::TextStyle::kTextStyleBold) | + static_cast(ax::mojom::TextStyle::kTextStyleItalic)); ui::AXNodeData link; link.id = 4; - link.role = ui::AX_ROLE_LINK; - link.AddState(ui::AX_STATE_EDITABLE); - link.AddState(ui::AX_STATE_FOCUSABLE); - link.AddState(ui::AX_STATE_LINKED); + link.role = ax::mojom::Role::kLink; + link.AddState(ax::mojom::State::kEditable); + link.AddState(ax::mojom::State::kFocusable); + link.AddState(ax::mojom::State::kLinked); link.SetName("lnk"); - link.AddIntAttribute(ui::AX_ATTR_TEXT_STYLE, - static_cast(ui::AX_TEXT_STYLE_UNDERLINE)); + link.AddIntAttribute( + ax::mojom::IntAttribute::kTextStyle, + static_cast(ax::mojom::TextStyle::kTextStyleUnderline)); ui::AXNodeData link_text; link_text.id = 5; - link_text.role = ui::AX_ROLE_STATIC_TEXT; - link_text.AddState(ui::AX_STATE_EDITABLE); - link_text.AddState(ui::AX_STATE_FOCUSABLE); - link_text.AddState(ui::AX_STATE_LINKED); + link_text.role = ax::mojom::Role::kStaticText; + link_text.AddState(ax::mojom::State::kEditable); + link_text.AddState(ax::mojom::State::kFocusable); + link_text.AddState(ax::mojom::State::kLinked); link_text.SetName("lnk"); - link_text.AddIntAttribute(ui::AX_ATTR_TEXT_STYLE, - static_cast(ui::AX_TEXT_STYLE_UNDERLINE)); + link_text.AddIntAttribute( + ax::mojom::IntAttribute::kTextStyle, + static_cast(ax::mojom::TextStyle::kTextStyleUnderline)); // The name "lnk" is misspelled. std::vector marker_types{ - static_cast(ui::AX_MARKER_TYPE_SPELLING)}; + static_cast(ax::mojom::MarkerType::kSpelling)}; std::vector marker_starts{0}; std::vector marker_ends{3}; - link_text.AddIntListAttribute(ui::AX_ATTR_MARKER_TYPES, marker_types); - link_text.AddIntListAttribute(ui::AX_ATTR_MARKER_STARTS, marker_starts); - link_text.AddIntListAttribute(ui::AX_ATTR_MARKER_ENDS, marker_ends); + link_text.AddIntListAttribute(ax::mojom::IntListAttribute::kMarkerTypes, + marker_types); + link_text.AddIntListAttribute(ax::mojom::IntListAttribute::kMarkerStarts, + marker_starts); + link_text.AddIntListAttribute(ax::mojom::IntListAttribute::kMarkerEnds, + marker_ends); ui::AXNodeData text_after; text_after.id = 6; - text_after.role = ui::AX_ROLE_STATIC_TEXT; - text_after.AddState(ui::AX_STATE_EDITABLE); + text_after.role = ax::mojom::Role::kStaticText; + text_after.AddState(ax::mojom::State::kEditable); text_after.SetName(" after."); // Leave text style as normal. @@ -1885,42 +1895,46 @@ TEST_F(BrowserAccessibilityTest, TestExistingMisspellingsInSimpleTextFields) { ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; - root.AddState(ui::AX_STATE_FOCUSABLE); + root.role = ax::mojom::Role::kRootWebArea; + root.AddState(ax::mojom::State::kFocusable); ui::AXNodeData combo_box; combo_box.id = 2; - combo_box.role = ui::AX_ROLE_TEXT_FIELD_WITH_COMBO_BOX; - combo_box.AddState(ui::AX_STATE_EDITABLE); - combo_box.AddState(ui::AX_STATE_FOCUSABLE); + combo_box.role = ax::mojom::Role::kTextFieldWithComboBox; + combo_box.AddState(ax::mojom::State::kEditable); + combo_box.AddState(ax::mojom::State::kFocusable); combo_box.SetValue(value1 + value2); ui::AXNodeData combo_box_div; combo_box_div.id = 3; - combo_box_div.role = ui::AX_ROLE_GENERIC_CONTAINER; - combo_box_div.AddState(ui::AX_STATE_EDITABLE); + combo_box_div.role = ax::mojom::Role::kGenericContainer; + combo_box_div.AddState(ax::mojom::State::kEditable); ui::AXNodeData static_text1; static_text1.id = 4; - static_text1.role = ui::AX_ROLE_STATIC_TEXT; - static_text1.AddState(ui::AX_STATE_EDITABLE); + static_text1.role = ax::mojom::Role::kStaticText; + static_text1.AddState(ax::mojom::State::kEditable); static_text1.SetName(value1); ui::AXNodeData static_text2; static_text2.id = 5; - static_text2.role = ui::AX_ROLE_STATIC_TEXT; - static_text2.AddState(ui::AX_STATE_EDITABLE); + static_text2.role = ax::mojom::Role::kStaticText; + static_text2.AddState(ax::mojom::State::kEditable); static_text2.SetName(value2); std::vector marker_types; - marker_types.push_back(static_cast(ui::AX_MARKER_TYPE_SPELLING)); + marker_types.push_back( + static_cast(ax::mojom::MarkerType::kSpelling)); std::vector marker_starts; marker_starts.push_back(0); std::vector marker_ends; marker_ends.push_back(4); - static_text2.AddIntListAttribute(ui::AX_ATTR_MARKER_TYPES, marker_types); - static_text2.AddIntListAttribute(ui::AX_ATTR_MARKER_STARTS, marker_starts); - static_text2.AddIntListAttribute(ui::AX_ATTR_MARKER_ENDS, marker_ends); + static_text2.AddIntListAttribute(ax::mojom::IntListAttribute::kMarkerTypes, + marker_types); + static_text2.AddIntListAttribute(ax::mojom::IntListAttribute::kMarkerStarts, + marker_starts); + static_text2.AddIntListAttribute(ax::mojom::IntListAttribute::kMarkerEnds, + marker_ends); root.child_ids.push_back(combo_box.id); combo_box.child_ids.push_back(combo_box_div.id); @@ -1998,31 +2012,31 @@ TEST_F(BrowserAccessibilityTest, TestNewMisspellingsInSimpleTextFields) { ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; - root.AddState(ui::AX_STATE_FOCUSABLE); + root.role = ax::mojom::Role::kRootWebArea; + root.AddState(ax::mojom::State::kFocusable); ui::AXNodeData combo_box; combo_box.id = 2; - combo_box.role = ui::AX_ROLE_TEXT_FIELD_WITH_COMBO_BOX; - combo_box.AddState(ui::AX_STATE_EDITABLE); - combo_box.AddState(ui::AX_STATE_FOCUSABLE); + combo_box.role = ax::mojom::Role::kTextFieldWithComboBox; + combo_box.AddState(ax::mojom::State::kEditable); + combo_box.AddState(ax::mojom::State::kFocusable); combo_box.SetValue(value1 + value2); ui::AXNodeData combo_box_div; combo_box_div.id = 3; - combo_box_div.role = ui::AX_ROLE_GENERIC_CONTAINER; - combo_box_div.AddState(ui::AX_STATE_EDITABLE); + combo_box_div.role = ax::mojom::Role::kGenericContainer; + combo_box_div.AddState(ax::mojom::State::kEditable); ui::AXNodeData static_text1; static_text1.id = 4; - static_text1.role = ui::AX_ROLE_STATIC_TEXT; - static_text1.AddState(ui::AX_STATE_EDITABLE); + static_text1.role = ax::mojom::Role::kStaticText; + static_text1.AddState(ax::mojom::State::kEditable); static_text1.SetName(value1); ui::AXNodeData static_text2; static_text2.id = 5; - static_text2.role = ui::AX_ROLE_STATIC_TEXT; - static_text2.AddState(ui::AX_STATE_EDITABLE); + static_text2.role = ax::mojom::Role::kStaticText; + static_text2.AddState(ax::mojom::State::kEditable); static_text2.SetName(value2); root.child_ids.push_back(combo_box.id); @@ -2064,12 +2078,15 @@ TEST_F(BrowserAccessibilityTest, TestNewMisspellingsInSimpleTextFields) { // Add the spelling markers on "helo". std::vector marker_types{ - static_cast(ui::AX_MARKER_TYPE_SPELLING)}; + static_cast(ax::mojom::MarkerType::kSpelling)}; std::vector marker_starts{0}; std::vector marker_ends{4}; - static_text2.AddIntListAttribute(ui::AX_ATTR_MARKER_TYPES, marker_types); - static_text2.AddIntListAttribute(ui::AX_ATTR_MARKER_STARTS, marker_starts); - static_text2.AddIntListAttribute(ui::AX_ATTR_MARKER_ENDS, marker_ends); + static_text2.AddIntListAttribute(ax::mojom::IntListAttribute::kMarkerTypes, + marker_types); + static_text2.AddIntListAttribute(ax::mojom::IntListAttribute::kMarkerStarts, + marker_starts); + static_text2.AddIntListAttribute(ax::mojom::IntListAttribute::kMarkerEnds, + marker_ends); ui::AXTree* tree = const_cast(manager->ax_tree()); ASSERT_NE(nullptr, tree); ASSERT_TRUE(tree->Unserialize(MakeAXTreeUpdate(static_text2))); @@ -2117,26 +2134,26 @@ TEST_F(BrowserAccessibilityTest, TestNewMisspellingsInSimpleTextFields) { TEST_F(BrowserAccessibilityTest, TestDeepestFirstLastChild) { ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; + root.role = ax::mojom::Role::kRootWebArea; ui::AXNodeData child1; child1.id = 2; - child1.role = ui::AX_ROLE_STATIC_TEXT; + child1.role = ax::mojom::Role::kStaticText; root.child_ids.push_back(2); ui::AXNodeData child2; child2.id = 3; - child2.role = ui::AX_ROLE_STATIC_TEXT; + child2.role = ax::mojom::Role::kStaticText; root.child_ids.push_back(3); ui::AXNodeData child2_child1; child2_child1.id = 4; - child2_child1.role = ui::AX_ROLE_INLINE_TEXT_BOX; + child2_child1.role = ax::mojom::Role::kInlineTextBox; child2.child_ids.push_back(4); ui::AXNodeData child2_child2; child2_child2.id = 5; - child2_child2.role = ui::AX_ROLE_INLINE_TEXT_BOX; + child2_child2.role = ax::mojom::Role::kInlineTextBox; child2.child_ids.push_back(5); std::unique_ptr manager( @@ -2196,30 +2213,30 @@ TEST_F(BrowserAccessibilityTest, TestDeepestFirstLastChild) { TEST_F(BrowserAccessibilityTest, TestInheritedStringAttributes) { ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; - root.AddStringAttribute(ui::AX_ATTR_LANGUAGE, "en-US"); - root.AddStringAttribute(ui::AX_ATTR_FONT_FAMILY, "Helvetica"); + root.role = ax::mojom::Role::kRootWebArea; + root.AddStringAttribute(ax::mojom::StringAttribute::kLanguage, "en-US"); + root.AddStringAttribute(ax::mojom::StringAttribute::kFontFamily, "Helvetica"); ui::AXNodeData child1; child1.id = 2; - child1.role = ui::AX_ROLE_STATIC_TEXT; + child1.role = ax::mojom::Role::kStaticText; root.child_ids.push_back(2); ui::AXNodeData child2; child2.id = 3; - child2.role = ui::AX_ROLE_STATIC_TEXT; - child2.AddStringAttribute(ui::AX_ATTR_LANGUAGE, "fr"); - child2.AddStringAttribute(ui::AX_ATTR_FONT_FAMILY, "Arial"); + child2.role = ax::mojom::Role::kStaticText; + child2.AddStringAttribute(ax::mojom::StringAttribute::kLanguage, "fr"); + child2.AddStringAttribute(ax::mojom::StringAttribute::kFontFamily, "Arial"); root.child_ids.push_back(3); ui::AXNodeData child2_child1; child2_child1.id = 4; - child2_child1.role = ui::AX_ROLE_INLINE_TEXT_BOX; + child2_child1.role = ax::mojom::Role::kInlineTextBox; child2.child_ids.push_back(4); ui::AXNodeData child2_child2; child2_child2.id = 5; - child2_child2.role = ui::AX_ROLE_INLINE_TEXT_BOX; + child2_child2.role = ax::mojom::Role::kInlineTextBox; child2.child_ids.push_back(5); std::unique_ptr manager( @@ -2243,68 +2260,68 @@ TEST_F(BrowserAccessibilityTest, TestInheritedStringAttributes) { ASSERT_NE(nullptr, child2_child2_accessible); // Test GetInheritedString16Attribute(attribute). - EXPECT_EQ( - base::UTF8ToUTF16("en-US"), - root_accessible->GetInheritedString16Attribute(ui::AX_ATTR_LANGUAGE)); - EXPECT_EQ( - base::UTF8ToUTF16("en-US"), - child1_accessible->GetInheritedString16Attribute(ui::AX_ATTR_LANGUAGE)); - EXPECT_EQ( - base::UTF8ToUTF16("fr"), - child2_accessible->GetInheritedString16Attribute(ui::AX_ATTR_LANGUAGE)); + EXPECT_EQ(base::UTF8ToUTF16("en-US"), + root_accessible->GetInheritedString16Attribute( + ax::mojom::StringAttribute::kLanguage)); + EXPECT_EQ(base::UTF8ToUTF16("en-US"), + child1_accessible->GetInheritedString16Attribute( + ax::mojom::StringAttribute::kLanguage)); + EXPECT_EQ(base::UTF8ToUTF16("fr"), + child2_accessible->GetInheritedString16Attribute( + ax::mojom::StringAttribute::kLanguage)); EXPECT_EQ(base::UTF8ToUTF16("fr"), child2_child1_accessible->GetInheritedString16Attribute( - ui::AX_ATTR_LANGUAGE)); + ax::mojom::StringAttribute::kLanguage)); EXPECT_EQ(base::UTF8ToUTF16("fr"), child2_child2_accessible->GetInheritedString16Attribute( - ui::AX_ATTR_LANGUAGE)); + ax::mojom::StringAttribute::kLanguage)); // Test GetInheritedString16Attribute(attribute, out_value). base::string16 value16; EXPECT_TRUE(root_accessible->GetInheritedString16Attribute( - ui::AX_ATTR_LANGUAGE, &value16)); + ax::mojom::StringAttribute::kLanguage, &value16)); EXPECT_EQ(base::UTF8ToUTF16("en-US"), value16); EXPECT_TRUE(child1_accessible->GetInheritedString16Attribute( - ui::AX_ATTR_LANGUAGE, &value16)); + ax::mojom::StringAttribute::kLanguage, &value16)); EXPECT_EQ(base::UTF8ToUTF16("en-US"), value16); EXPECT_TRUE(child2_accessible->GetInheritedString16Attribute( - ui::AX_ATTR_LANGUAGE, &value16)); + ax::mojom::StringAttribute::kLanguage, &value16)); EXPECT_EQ(base::UTF8ToUTF16("fr"), value16); EXPECT_TRUE(child2_child1_accessible->GetInheritedString16Attribute( - ui::AX_ATTR_LANGUAGE, &value16)); + ax::mojom::StringAttribute::kLanguage, &value16)); EXPECT_EQ(base::UTF8ToUTF16("fr"), value16); EXPECT_TRUE(child2_child2_accessible->GetInheritedString16Attribute( - ui::AX_ATTR_LANGUAGE, &value16)); + ax::mojom::StringAttribute::kLanguage, &value16)); EXPECT_EQ(base::UTF8ToUTF16("fr"), value16); // Test GetInheritedStringAttribute(attribute). EXPECT_EQ("Helvetica", root_accessible->GetInheritedStringAttribute( - ui::AX_ATTR_FONT_FAMILY)); + ax::mojom::StringAttribute::kFontFamily)); EXPECT_EQ("Helvetica", child1_accessible->GetInheritedStringAttribute( - ui::AX_ATTR_FONT_FAMILY)); + ax::mojom::StringAttribute::kFontFamily)); EXPECT_EQ("Arial", child2_accessible->GetInheritedStringAttribute( - ui::AX_ATTR_FONT_FAMILY)); + ax::mojom::StringAttribute::kFontFamily)); EXPECT_EQ("Arial", child2_child1_accessible->GetInheritedStringAttribute( - ui::AX_ATTR_FONT_FAMILY)); + ax::mojom::StringAttribute::kFontFamily)); EXPECT_EQ("Arial", child2_child2_accessible->GetInheritedStringAttribute( - ui::AX_ATTR_FONT_FAMILY)); + ax::mojom::StringAttribute::kFontFamily)); // Test GetInheritedStringAttribute(attribute, out_value). std::string value; EXPECT_TRUE(root_accessible->GetInheritedStringAttribute( - ui::AX_ATTR_FONT_FAMILY, &value)); + ax::mojom::StringAttribute::kFontFamily, &value)); EXPECT_EQ("Helvetica", value); EXPECT_TRUE(child1_accessible->GetInheritedStringAttribute( - ui::AX_ATTR_FONT_FAMILY, &value)); + ax::mojom::StringAttribute::kFontFamily, &value)); EXPECT_EQ("Helvetica", value); EXPECT_TRUE(child2_accessible->GetInheritedStringAttribute( - ui::AX_ATTR_FONT_FAMILY, &value)); + ax::mojom::StringAttribute::kFontFamily, &value)); EXPECT_EQ("Arial", value); EXPECT_TRUE(child2_child1_accessible->GetInheritedStringAttribute( - ui::AX_ATTR_FONT_FAMILY, &value)); + ax::mojom::StringAttribute::kFontFamily, &value)); EXPECT_EQ("Arial", value); EXPECT_TRUE(child2_child2_accessible->GetInheritedStringAttribute( - ui::AX_ATTR_FONT_FAMILY, &value)); + ax::mojom::StringAttribute::kFontFamily, &value)); EXPECT_EQ("Arial", value); } @@ -2318,7 +2335,7 @@ TEST_F(BrowserAccessibilityTest, TestSanitizeStringAttributeForIA2) { TEST_F(BrowserAccessibilityTest, UniqueIdWinInvalidAfterDeletingTree) { ui::AXNodeData root_node; root_node.id = 1; - root_node.role = ui::AX_ROLE_ROOT_WEB_AREA; + root_node.role = ax::mojom::Role::kRootWebArea; ui::AXNodeData child_node; child_node.id = 2; @@ -2377,7 +2394,7 @@ TEST_F(BrowserAccessibilityTest, UniqueIdWinInvalidAfterDeletingTree) { TEST_F(BrowserAccessibilityTest, AccChildOnlyReturnsDescendants) { ui::AXNodeData root_node; root_node.id = 1; - root_node.role = ui::AX_ROLE_ROOT_WEB_AREA; + root_node.role = ax::mojom::Role::kRootWebArea; ui::AXNodeData child_node; child_node.id = 2; @@ -2405,19 +2422,20 @@ TEST_F(BrowserAccessibilityTest, AccChildOnlyReturnsDescendants) { TEST_F(BrowserAccessibilityTest, TestIAccessible2Relations) { ui::AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; + root.role = ax::mojom::Role::kRootWebArea; // Reflexive relations should be ignored. std::vector describedby_ids = {1, 2, 3}; - root.AddIntListAttribute(ui::AX_ATTR_DESCRIBEDBY_IDS, describedby_ids); + root.AddIntListAttribute(ax::mojom::IntListAttribute::kDescribedbyIds, + describedby_ids); ui::AXNodeData child1; child1.id = 2; - child1.role = ui::AX_ROLE_STATIC_TEXT; + child1.role = ax::mojom::Role::kStaticText; root.child_ids.push_back(2); ui::AXNodeData child2; child2.id = 3; - child2.role = ui::AX_ROLE_STATIC_TEXT; + child2.role = ax::mojom::Role::kStaticText; root.child_ids.push_back(3); std::unique_ptr manager( @@ -2520,9 +2538,10 @@ TEST_F(BrowserAccessibilityTest, TestIAccessible2Relations) { // Try adding one more relation. std::vector labelledby_ids = {3}; - child1.AddIntListAttribute(ui::AX_ATTR_LABELLEDBY_IDS, labelledby_ids); + child1.AddIntListAttribute(ax::mojom::IntListAttribute::kLabelledbyIds, + labelledby_ids); AXEventNotificationDetails event; - event.event_type = ui::AX_EVENT_ARIA_ATTRIBUTE_CHANGED; + event.event_type = ax::mojom::Event::kAriaAttributeChanged; event.update.nodes.push_back(child1); event.id = child1.id; std::vector events = {event}; diff --git a/content/browser/accessibility/cross_platform_accessibility_browsertest.cc b/content/browser/accessibility/cross_platform_accessibility_browsertest.cc index 4fb7c11c68c381..14d88ae68bdb21 100644 --- a/content/browser/accessibility/cross_platform_accessibility_browsertest.cc +++ b/content/browser/accessibility/cross_platform_accessibility_browsertest.cc @@ -46,10 +46,9 @@ class CrossPlatformAccessibilityBrowserTest : public ContentBrowserTest { // notification that it's been received. const ui::AXTree& GetAXTree( ui::AXMode accessibility_mode = ui::kAXModeComplete) { - AccessibilityNotificationWaiter waiter( - shell()->web_contents(), - accessibility_mode, - ui::AX_EVENT_LAYOUT_COMPLETE); + AccessibilityNotificationWaiter waiter(shell()->web_contents(), + accessibility_mode, + ax::mojom::Event::kLayoutComplete); waiter.WaitForNotification(); return waiter.GetAXTree(); } @@ -69,11 +68,9 @@ class CrossPlatformAccessibilityBrowserTest : public ContentBrowserTest { protected: std::string GetAttr(const ui::AXNode* node, - const ui::AXStringAttribute attr); - int GetIntAttr(const ui::AXNode* node, - const ui::AXIntAttribute attr); - bool GetBoolAttr(const ui::AXNode* node, - const ui::AXBoolAttribute attr); + const ax::mojom::StringAttribute attr); + int GetIntAttr(const ui::AXNode* node, const ax::mojom::IntAttribute attr); + bool GetBoolAttr(const ui::AXNode* node, const ax::mojom::BoolAttribute attr); private: #if defined(OS_WIN) @@ -100,7 +97,7 @@ void CrossPlatformAccessibilityBrowserTest::TearDownOnMainThread() { // attribute as a UTF-8 string. std::string CrossPlatformAccessibilityBrowserTest::GetAttr( const ui::AXNode* node, - const ui::AXStringAttribute attr) { + const ax::mojom::StringAttribute attr) { const ui::AXNodeData& data = node->data(); for (size_t i = 0; i < data.string_attributes.size(); ++i) { if (data.string_attributes[i].first == attr) @@ -113,7 +110,7 @@ std::string CrossPlatformAccessibilityBrowserTest::GetAttr( // integer attribute. int CrossPlatformAccessibilityBrowserTest::GetIntAttr( const ui::AXNode* node, - const ui::AXIntAttribute attr) { + const ax::mojom::IntAttribute attr) { const ui::AXNodeData& data = node->data(); for (size_t i = 0; i < data.int_attributes.size(); ++i) { if (data.int_attributes[i].first == attr) @@ -126,7 +123,7 @@ int CrossPlatformAccessibilityBrowserTest::GetIntAttr( // boolean attribute. bool CrossPlatformAccessibilityBrowserTest::GetBoolAttr( const ui::AXNode* node, - const ui::AXBoolAttribute attr) { + const ax::mojom::BoolAttribute attr) { const ui::AXNodeData& data = node->data(); for (size_t i = 0; i < data.bool_attributes.size(); ++i) { if (data.bool_attributes[i].first == attr) @@ -157,33 +154,30 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, EXPECT_STREQ("text/html", tree.data().mimetype.c_str()); // Check properties of the root element of the tree. - EXPECT_STREQ( - "Accessibility Test", - GetAttr(root, ui::AX_ATTR_NAME).c_str()); - EXPECT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, root->data().role); + EXPECT_STREQ("Accessibility Test", + GetAttr(root, ax::mojom::StringAttribute::kName).c_str()); + EXPECT_EQ(ax::mojom::Role::kRootWebArea, root->data().role); // Check properties of the BODY element. ASSERT_EQ(1, root->child_count()); const ui::AXNode* body = root->ChildAtIndex(0); - EXPECT_EQ(ui::AX_ROLE_GROUP, body->data().role); + EXPECT_EQ(ax::mojom::Role::kGroup, body->data().role); EXPECT_STREQ("body", - GetAttr(body, ui::AX_ATTR_HTML_TAG).c_str()); + GetAttr(body, ax::mojom::StringAttribute::kHtmlTag).c_str()); EXPECT_STREQ("block", - GetAttr(body, ui::AX_ATTR_DISPLAY).c_str()); + GetAttr(body, ax::mojom::StringAttribute::kDisplay).c_str()); // Check properties of the two children of the BODY element. ASSERT_EQ(2, body->child_count()); const ui::AXNode* button = body->ChildAtIndex(0); - EXPECT_EQ(ui::AX_ROLE_BUTTON, button->data().role); - EXPECT_STREQ( - "input", GetAttr(button, ui::AX_ATTR_HTML_TAG).c_str()); - EXPECT_STREQ( - "push", - GetAttr(button, ui::AX_ATTR_NAME).c_str()); - EXPECT_STREQ( - "inline-block", - GetAttr(button, ui::AX_ATTR_DISPLAY).c_str()); + EXPECT_EQ(ax::mojom::Role::kButton, button->data().role); + EXPECT_STREQ("input", + GetAttr(button, ax::mojom::StringAttribute::kHtmlTag).c_str()); + EXPECT_STREQ("push", + GetAttr(button, ax::mojom::StringAttribute::kName).c_str()); + EXPECT_STREQ("inline-block", + GetAttr(button, ax::mojom::StringAttribute::kDisplay).c_str()); ASSERT_EQ(2U, button->data().html_attributes.size()); EXPECT_STREQ("type", button->data().html_attributes[0].first.c_str()); EXPECT_STREQ("button", button->data().html_attributes[0].second.c_str()); @@ -191,12 +185,11 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, EXPECT_STREQ("push", button->data().html_attributes[1].second.c_str()); const ui::AXNode* checkbox = body->ChildAtIndex(1); - EXPECT_EQ(ui::AX_ROLE_CHECK_BOX, checkbox->data().role); - EXPECT_STREQ( - "input", GetAttr(checkbox, ui::AX_ATTR_HTML_TAG).c_str()); - EXPECT_STREQ( - "inline-block", - GetAttr(checkbox, ui::AX_ATTR_DISPLAY).c_str()); + EXPECT_EQ(ax::mojom::Role::kCheckBox, checkbox->data().role); + EXPECT_STREQ("input", + GetAttr(checkbox, ax::mojom::StringAttribute::kHtmlTag).c_str()); + EXPECT_STREQ("inline-block", + GetAttr(checkbox, ax::mojom::StringAttribute::kDisplay).c_str()); ASSERT_EQ(1U, checkbox->data().html_attributes.size()); EXPECT_STREQ("type", checkbox->data().html_attributes[0].first.c_str()); EXPECT_STREQ("checkbox", checkbox->data().html_attributes[0].second.c_str()); @@ -220,14 +213,13 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, const ui::AXNode* body = root->ChildAtIndex(0); ASSERT_EQ(1, body->child_count()); const ui::AXNode* text = body->ChildAtIndex(0); - EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, text->data().role); - EXPECT_STREQ( - "input", GetAttr(text, ui::AX_ATTR_HTML_TAG).c_str()); - EXPECT_EQ(0, GetIntAttr(text, ui::AX_ATTR_TEXT_SEL_START)); - EXPECT_EQ(0, GetIntAttr(text, ui::AX_ATTR_TEXT_SEL_END)); - EXPECT_STREQ( - "Hello, world.", - GetAttr(text, ui::AX_ATTR_VALUE).c_str()); + EXPECT_EQ(ax::mojom::Role::kTextField, text->data().role); + EXPECT_STREQ("input", + GetAttr(text, ax::mojom::StringAttribute::kHtmlTag).c_str()); + EXPECT_EQ(0, GetIntAttr(text, ax::mojom::IntAttribute::kTextSelStart)); + EXPECT_EQ(0, GetIntAttr(text, ax::mojom::IntAttribute::kTextSelEnd)); + EXPECT_STREQ("Hello, world.", + GetAttr(text, ax::mojom::StringAttribute::kValue).c_str()); // TODO(dmazzoni): as soon as more accessibility code is cross-platform, // this code should test that the accessible info is dynamically updated @@ -252,14 +244,13 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, const ui::AXNode* body = root->ChildAtIndex(0); ASSERT_EQ(1, body->child_count()); const ui::AXNode* text = body->ChildAtIndex(0); - EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, text->data().role); - EXPECT_STREQ( - "input", GetAttr(text, ui::AX_ATTR_HTML_TAG).c_str()); - EXPECT_EQ(0, GetIntAttr(text, ui::AX_ATTR_TEXT_SEL_START)); - EXPECT_EQ(13, GetIntAttr(text, ui::AX_ATTR_TEXT_SEL_END)); - EXPECT_STREQ( - "Hello, world.", - GetAttr(text, ui::AX_ATTR_VALUE).c_str()); + EXPECT_EQ(ax::mojom::Role::kTextField, text->data().role); + EXPECT_STREQ("input", + GetAttr(text, ax::mojom::StringAttribute::kHtmlTag).c_str()); + EXPECT_EQ(0, GetIntAttr(text, ax::mojom::IntAttribute::kTextSelStart)); + EXPECT_EQ(13, GetIntAttr(text, ax::mojom::IntAttribute::kTextSelEnd)); + EXPECT_STREQ("Hello, world.", + GetAttr(text, ax::mojom::StringAttribute::kValue).c_str()); } IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, @@ -280,27 +271,27 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, const ui::AXNode* root = tree.root(); ASSERT_EQ(1, root->child_count()); const ui::AXNode* table = root->ChildAtIndex(0); - EXPECT_EQ(ui::AX_ROLE_TABLE, table->data().role); + EXPECT_EQ(ax::mojom::Role::kTable, table->data().role); const ui::AXNode* row = table->ChildAtIndex(0); - EXPECT_EQ(ui::AX_ROLE_ROW, row->data().role); + EXPECT_EQ(ax::mojom::Role::kRow, row->data().role); const ui::AXNode* cell1 = row->ChildAtIndex(0); - EXPECT_EQ(ui::AX_ROLE_CELL, cell1->data().role); + EXPECT_EQ(ax::mojom::Role::kCell, cell1->data().role); const ui::AXNode* cell2 = row->ChildAtIndex(1); - EXPECT_EQ(ui::AX_ROLE_CELL, cell2->data().role); + EXPECT_EQ(ax::mojom::Role::kCell, cell2->data().role); const ui::AXNode* column1 = table->ChildAtIndex(1); - EXPECT_EQ(ui::AX_ROLE_COLUMN, column1->data().role); + EXPECT_EQ(ax::mojom::Role::kColumn, column1->data().role); EXPECT_EQ(0, column1->child_count()); EXPECT_EQ(1U, column1->data().intlist_attributes.size()); - EXPECT_EQ(ui::AX_ATTR_INDIRECT_CHILD_IDS, + EXPECT_EQ(ax::mojom::IntListAttribute::kIndirectChildIds, column1->data().intlist_attributes[0].first); const std::vector column1_indirect_child_ids = column1->data().intlist_attributes[0].second; EXPECT_EQ(1U, column1_indirect_child_ids.size()); EXPECT_EQ(cell1->id(), column1_indirect_child_ids[0]); const ui::AXNode* column2 = table->ChildAtIndex(2); - EXPECT_EQ(ui::AX_ROLE_COLUMN, column2->data().role); + EXPECT_EQ(ax::mojom::Role::kColumn, column2->data().role); EXPECT_EQ(0, column2->child_count()); - EXPECT_EQ(ui::AX_ATTR_INDIRECT_CHILD_IDS, + EXPECT_EQ(ax::mojom::IntListAttribute::kIndirectChildIds, column2->data().intlist_attributes[0].first); const std::vector column2_indirect_child_ids = column2->data().intlist_attributes[0].second; @@ -354,32 +345,31 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, ASSERT_EQ(3, body->child_count()); const ui::AXNode* button1 = body->ChildAtIndex(0); - EXPECT_EQ(ui::AX_ROLE_BUTTON, button1->data().role); - EXPECT_STREQ( - "Button 1", - GetAttr(button1, ui::AX_ATTR_NAME).c_str()); + EXPECT_EQ(ax::mojom::Role::kButton, button1->data().role); + EXPECT_STREQ("Button 1", + GetAttr(button1, ax::mojom::StringAttribute::kName).c_str()); const ui::AXNode* iframe = body->ChildAtIndex(1); EXPECT_STREQ("iframe", - GetAttr(iframe, ui::AX_ATTR_HTML_TAG).c_str()); + GetAttr(iframe, ax::mojom::StringAttribute::kHtmlTag).c_str()); ASSERT_EQ(1, iframe->child_count()); const ui::AXNode* sub_document = iframe->ChildAtIndex(0); - EXPECT_EQ(ui::AX_ROLE_WEB_AREA, sub_document->data().role); + EXPECT_EQ(ax::mojom::Role::kWebArea, sub_document->data().role); ASSERT_EQ(1, sub_document->child_count()); const ui::AXNode* sub_body = sub_document->ChildAtIndex(0); ASSERT_EQ(1, sub_body->child_count()); const ui::AXNode* button2 = sub_body->ChildAtIndex(0); - EXPECT_EQ(ui::AX_ROLE_BUTTON, button2->data().role); + EXPECT_EQ(ax::mojom::Role::kButton, button2->data().role); EXPECT_STREQ("Button 2", - GetAttr(button2, ui::AX_ATTR_NAME).c_str()); + GetAttr(button2, ax::mojom::StringAttribute::kName).c_str()); const ui::AXNode* button3 = body->ChildAtIndex(2); - EXPECT_EQ(ui::AX_ROLE_BUTTON, button3->data().role); + EXPECT_EQ(ax::mojom::Role::kButton, button3->data().role); EXPECT_STREQ("Button 3", - GetAttr(button3, ui::AX_ATTR_NAME).c_str()); + GetAttr(button3, ax::mojom::StringAttribute::kName).c_str()); } IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, @@ -425,23 +415,22 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, const ui::AXTree& tree = GetAXTree(); const ui::AXNode* root = tree.root(); const ui::AXNode* table = root->ChildAtIndex(0); - EXPECT_EQ(ui::AX_ROLE_TABLE, table->data().role); + EXPECT_EQ(ax::mojom::Role::kTable, table->data().role); ASSERT_GE(table->child_count(), 5); - EXPECT_EQ(ui::AX_ROLE_ROW, table->ChildAtIndex(0)->data().role); - EXPECT_EQ(ui::AX_ROLE_ROW, table->ChildAtIndex(1)->data().role); - EXPECT_EQ(ui::AX_ROLE_COLUMN, table->ChildAtIndex(2)->data().role); - EXPECT_EQ(ui::AX_ROLE_COLUMN, table->ChildAtIndex(3)->data().role); - EXPECT_EQ(ui::AX_ROLE_COLUMN, table->ChildAtIndex(4)->data().role); - EXPECT_EQ(3, - GetIntAttr(table, ui::AX_ATTR_TABLE_COLUMN_COUNT)); - EXPECT_EQ(2, GetIntAttr(table, ui::AX_ATTR_TABLE_ROW_COUNT)); + EXPECT_EQ(ax::mojom::Role::kRow, table->ChildAtIndex(0)->data().role); + EXPECT_EQ(ax::mojom::Role::kRow, table->ChildAtIndex(1)->data().role); + EXPECT_EQ(ax::mojom::Role::kColumn, table->ChildAtIndex(2)->data().role); + EXPECT_EQ(ax::mojom::Role::kColumn, table->ChildAtIndex(3)->data().role); + EXPECT_EQ(ax::mojom::Role::kColumn, table->ChildAtIndex(4)->data().role); + EXPECT_EQ(3, GetIntAttr(table, ax::mojom::IntAttribute::kTableColumnCount)); + EXPECT_EQ(2, GetIntAttr(table, ax::mojom::IntAttribute::kTableRowCount)); const ui::AXNode* cell1 = table->ChildAtIndex(0)->ChildAtIndex(0); const ui::AXNode* cell2 = table->ChildAtIndex(0)->ChildAtIndex(1); const ui::AXNode* cell3 = table->ChildAtIndex(1)->ChildAtIndex(0); const ui::AXNode* cell4 = table->ChildAtIndex(1)->ChildAtIndex(1); - ASSERT_EQ(ui::AX_ATTR_CELL_IDS, + ASSERT_EQ(ax::mojom::IntListAttribute::kCellIds, table->data().intlist_attributes[0].first); const std::vector& table_cell_ids = table->data().intlist_attributes[0].second; @@ -453,26 +442,24 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, EXPECT_EQ(cell4->id(), table_cell_ids[4]); EXPECT_EQ(cell4->id(), table_cell_ids[5]); - EXPECT_EQ(0, GetIntAttr(cell1, - ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX)); - EXPECT_EQ(0, GetIntAttr(cell1, - ui::AX_ATTR_TABLE_CELL_ROW_INDEX)); - EXPECT_EQ(2, GetIntAttr(cell1, - ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN)); - EXPECT_EQ(1, GetIntAttr(cell1, - ui::AX_ATTR_TABLE_CELL_ROW_SPAN)); - EXPECT_EQ(2, GetIntAttr(cell2, - ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX)); - EXPECT_EQ(1, GetIntAttr(cell2, - ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN)); - EXPECT_EQ(0, GetIntAttr(cell3, - ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX)); - EXPECT_EQ(1, GetIntAttr(cell3, - ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN)); - EXPECT_EQ(1, GetIntAttr(cell4, - ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX)); - EXPECT_EQ(2, GetIntAttr(cell4, - ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN)); + EXPECT_EQ(0, + GetIntAttr(cell1, ax::mojom::IntAttribute::kTableCellColumnIndex)); + EXPECT_EQ(0, GetIntAttr(cell1, ax::mojom::IntAttribute::kTableCellRowIndex)); + EXPECT_EQ(2, + GetIntAttr(cell1, ax::mojom::IntAttribute::kTableCellColumnSpan)); + EXPECT_EQ(1, GetIntAttr(cell1, ax::mojom::IntAttribute::kTableCellRowSpan)); + EXPECT_EQ(2, + GetIntAttr(cell2, ax::mojom::IntAttribute::kTableCellColumnIndex)); + EXPECT_EQ(1, + GetIntAttr(cell2, ax::mojom::IntAttribute::kTableCellColumnSpan)); + EXPECT_EQ(0, + GetIntAttr(cell3, ax::mojom::IntAttribute::kTableCellColumnIndex)); + EXPECT_EQ(1, + GetIntAttr(cell3, ax::mojom::IntAttribute::kTableCellColumnSpan)); + EXPECT_EQ(1, + GetIntAttr(cell4, ax::mojom::IntAttribute::kTableCellColumnIndex)); + EXPECT_EQ(2, + GetIntAttr(cell4, ax::mojom::IntAttribute::kTableCellColumnSpan)); } IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, @@ -489,7 +476,7 @@ IN_PROC_BROWSER_TEST_F(CrossPlatformAccessibilityBrowserTest, const ui::AXNode* root = tree.root(); ASSERT_EQ(1, root->child_count()); const ui::AXNode* textbox = root->ChildAtIndex(0); - EXPECT_TRUE(textbox->data().HasAction(ui::AX_ACTION_SET_VALUE)); + EXPECT_TRUE(textbox->data().HasAction(ax::mojom::Action::kSetValue)); } } // namespace content diff --git a/content/browser/accessibility/dump_accessibility_browsertest_base.cc b/content/browser/accessibility/dump_accessibility_browsertest_base.cc index 313d721c749c35..768ebc90d04876 100644 --- a/content/browser/accessibility/dump_accessibility_browsertest_base.cc +++ b/content/browser/accessibility/dump_accessibility_browsertest_base.cc @@ -52,15 +52,15 @@ const char kSignalDiff[] = "*"; // that represents a fully loaded web document with the given url. bool AccessibilityTreeContainsLoadedDocWithUrl(BrowserAccessibility* node, const std::string& url) { - if (node->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA && - node->GetStringAttribute(ui::AX_ATTR_URL) == url) { + if (node->GetRole() == ax::mojom::Role::kRootWebArea && + node->GetStringAttribute(ax::mojom::StringAttribute::kUrl) == url) { // Ensure the doc has finished loading and has a non-zero size. return node->manager()->GetTreeData().loaded && (node->GetData().location.width() > 0 && node->GetData().location.height() > 0); } - if (node->GetRole() == ui::AX_ROLE_WEB_AREA && - node->GetStringAttribute(ui::AX_ATTR_URL) == url) { + if (node->GetRole() == ax::mojom::Role::kWebArea && + node->GetStringAttribute(ax::mojom::StringAttribute::kUrl) == url) { // Ensure the doc has finished loading. return node->manager()->GetTreeData().loaded; } @@ -269,13 +269,13 @@ void DumpAccessibilityTestBase::RunTestForPlatform( // Load the url, then enable accessibility. NavigateToURL(shell(), url); AccessibilityNotificationWaiter accessibility_waiter( - web_contents, ui::kAXModeComplete, ui::AX_EVENT_NONE); + web_contents, ui::kAXModeComplete, ax::mojom::Event::kNone); accessibility_waiter.WaitForNotification(); } else { // Enable accessibility, then load the test html and wait for the // "load complete" AX event. AccessibilityNotificationWaiter accessibility_waiter( - web_contents, ui::kAXModeComplete, ui::AX_EVENT_LOAD_COMPLETE); + web_contents, ui::kAXModeComplete, ax::mojom::Event::kLoadComplete); NavigateToURL(shell(), url); accessibility_waiter.WaitForNotification(); } @@ -346,8 +346,8 @@ void DumpAccessibilityTestBase::RunTestForPlatform( // Block until the next accessibility notification in any frame. VLOG(1) << "Waiting until the next accessibility event"; - AccessibilityNotificationWaiter accessibility_waiter(main_frame, - ui::AX_EVENT_NONE); + AccessibilityNotificationWaiter accessibility_waiter( + main_frame, ax::mojom::Event::kNone); for (FrameTreeNode* node : frame_tree->Nodes()) accessibility_waiter.ListenToAdditionalFrame(node->current_frame_host()); accessibility_waiter.WaitForNotification(); diff --git a/content/browser/accessibility/dump_accessibility_events_browsertest.cc b/content/browser/accessibility/dump_accessibility_events_browsertest.cc index 8d245a2af71d2e..91050816aef624 100644 --- a/content/browser/accessibility/dump_accessibility_events_browsertest.cc +++ b/content/browser/accessibility/dump_accessibility_events_browsertest.cc @@ -92,7 +92,7 @@ std::vector DumpAccessibilityEventsTest::Dump() { // a result of this function. std::unique_ptr waiter; waiter.reset(new AccessibilityNotificationWaiter( - shell()->web_contents(), ui::kAXModeComplete, ui::AX_EVENT_NONE)); + shell()->web_contents(), ui::kAXModeComplete, ax::mojom::Event::kNone)); web_contents->GetMainFrame()->ExecuteJavaScriptForTests( base::ASCIIToUTF16("go()")); @@ -106,7 +106,7 @@ std::vector DumpAccessibilityEventsTest::Dump() { // sentinel by calling AccessibilityHitTest and waiting for a HOVER // event in response. waiter.reset(new AccessibilityNotificationWaiter( - shell()->web_contents(), ui::kAXModeComplete, ui::AX_EVENT_HOVER)); + shell()->web_contents(), ui::kAXModeComplete, ax::mojom::Event::kHover)); BrowserAccessibilityManager* manager = web_contents->GetRootBrowserAccessibilityManager(); manager->HitTest(gfx::Point(0, 0)); diff --git a/content/browser/accessibility/fullscreen_browsertest.cc b/content/browser/accessibility/fullscreen_browsertest.cc index a93f137234f195..ce8d3ae1385a51 100644 --- a/content/browser/accessibility/fullscreen_browsertest.cc +++ b/content/browser/accessibility/fullscreen_browsertest.cc @@ -22,7 +22,7 @@ class AccessibilityFullscreenBrowserTest : public ContentBrowserTest { protected: BrowserAccessibility* FindButton(BrowserAccessibility* node) { - if (node->GetRole() == ui::AX_ROLE_BUTTON) + if (node->GetRole() == ax::mojom::Role::kButton) return node; for (unsigned i = 0; i < node->PlatformChildCount(); i++) { if (BrowserAccessibility* button = FindButton(node->PlatformGetChild(i))) @@ -32,7 +32,7 @@ class AccessibilityFullscreenBrowserTest : public ContentBrowserTest { } int CountLinks(BrowserAccessibility* node) { - if (node->GetRole() == ui::AX_ROLE_LINK) + if (node->GetRole() == ax::mojom::Role::kLink) return 1; int links_in_children = 0; for (unsigned i = 0; i < node->PlatformChildCount(); i++) { @@ -77,8 +77,9 @@ IN_PROC_BROWSER_TEST_F(AccessibilityFullscreenBrowserTest, FakeFullscreenDelegate delegate; shell()->web_contents()->SetDelegate(&delegate); - AccessibilityNotificationWaiter waiter( - shell()->web_contents(), ui::kAXModeComplete, ui::AX_EVENT_LOAD_COMPLETE); + AccessibilityNotificationWaiter waiter(shell()->web_contents(), + ui::kAXModeComplete, + ax::mojom::Event::kLoadComplete); GURL url( embedded_test_server()->GetURL("/accessibility/fullscreen/links.html")); NavigateToURL(shell(), url); diff --git a/content/browser/accessibility/hit_testing_browsertest.cc b/content/browser/accessibility/hit_testing_browsertest.cc index 93d8aeadf5ea5b..1e19acac20fe49 100644 --- a/content/browser/accessibility/hit_testing_browsertest.cc +++ b/content/browser/accessibility/hit_testing_browsertest.cc @@ -26,7 +26,7 @@ class AccessibilityHitTestingBrowserTest : public ContentBrowserTest { protected: BrowserAccessibility* HitTestAndWaitForResultWithEvent( const gfx::Point& point, - ui::AXEvent event_to_fire) { + ax::mojom::Event event_to_fire) { WebContentsImpl* web_contents = static_cast(shell()->web_contents()); FrameTree* frame_tree = web_contents->GetFrameTree(); @@ -38,7 +38,7 @@ class AccessibilityHitTestingBrowserTest : public ContentBrowserTest { for (FrameTreeNode* node : frame_tree->Nodes()) event_waiter.ListenToAdditionalFrame(node->current_frame_host()); ui::AXActionData action_data; - action_data.action = ui::AX_ACTION_HIT_TEST; + action_data.action = ax::mojom::Action::kHitTest; action_data.target_point = UseZoomForDSFEnabled() ? ScaleToRoundedPoint(point, manager->device_scale_factor()) @@ -56,7 +56,7 @@ class AccessibilityHitTestingBrowserTest : public ContentBrowserTest { } BrowserAccessibility* HitTestAndWaitForResult(const gfx::Point& point) { - return HitTestAndWaitForResultWithEvent(point, ui::AX_EVENT_HOVER); + return HitTestAndWaitForResultWithEvent(point, ax::mojom::Event::kHover); } BrowserAccessibility* CallCachingAsyncHitTest(const gfx::Point& point) { @@ -71,7 +71,7 @@ class AccessibilityHitTestingBrowserTest : public ContentBrowserTest { // Each call to CachingAsyncHitTest results in at least one HOVER // event received. Block until we receive it. AccessibilityNotificationWaiter hover_waiter( - shell()->web_contents(), ui::kAXModeComplete, ui::AX_EVENT_HOVER); + shell()->web_contents(), ui::kAXModeComplete, ax::mojom::Event::kHover); for (FrameTreeNode* node : frame_tree->Nodes()) hover_waiter.ListenToAdditionalFrame(node->current_frame_host()); BrowserAccessibility* result = manager->CachingAsyncHitTest(screen_point); @@ -85,8 +85,9 @@ IN_PROC_BROWSER_TEST_F(AccessibilityHitTestingBrowserTest, NavigateToURL(shell(), GURL(url::kAboutBlankURL)); // Load the page. - AccessibilityNotificationWaiter waiter( - shell()->web_contents(), ui::kAXModeComplete, ui::AX_EVENT_LOAD_COMPLETE); + AccessibilityNotificationWaiter waiter(shell()->web_contents(), + ui::kAXModeComplete, + ax::mojom::Event::kLoadComplete); const char url_str[] = "data:text/html," "" @@ -102,7 +103,7 @@ IN_PROC_BROWSER_TEST_F(AccessibilityHitTestingBrowserTest, BrowserAccessibility* hit_node = HitTestAndWaitForResult(gfx::Point(-1, -1)); ASSERT_TRUE(hit_node != nullptr); - ASSERT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, hit_node->GetRole()); + ASSERT_EQ(ax::mojom::Role::kRootWebArea, hit_node->GetRole()); } IN_PROC_BROWSER_TEST_F(AccessibilityHitTestingBrowserTest, @@ -111,8 +112,9 @@ IN_PROC_BROWSER_TEST_F(AccessibilityHitTestingBrowserTest, NavigateToURL(shell(), GURL(url::kAboutBlankURL)); - AccessibilityNotificationWaiter waiter( - shell()->web_contents(), ui::kAXModeComplete, ui::AX_EVENT_LOAD_COMPLETE); + AccessibilityNotificationWaiter waiter(shell()->web_contents(), + ui::kAXModeComplete, + ax::mojom::Event::kLoadComplete); GURL url(embedded_test_server()->GetURL( "/accessibility/html/iframe-coordinates.html")); NavigateToURL(shell(), url); @@ -131,37 +133,40 @@ IN_PROC_BROWSER_TEST_F(AccessibilityHitTestingBrowserTest, BrowserAccessibility* hit_node; hit_node = HitTestAndWaitForResult(gfx::Point(50, 50)); ASSERT_TRUE(hit_node != nullptr); - ASSERT_EQ(ui::AX_ROLE_BUTTON, hit_node->GetRole()); - ASSERT_EQ("Button", hit_node->GetStringAttribute(ui::AX_ATTR_NAME)); + ASSERT_EQ(ax::mojom::Role::kButton, hit_node->GetRole()); + ASSERT_EQ("Button", + hit_node->GetStringAttribute(ax::mojom::StringAttribute::kName)); // (50, 305) -> div in first iframe hit_node = HitTestAndWaitForResult(gfx::Point(50, 305)); ASSERT_TRUE(hit_node != nullptr); - ASSERT_EQ(ui::AX_ROLE_GENERIC_CONTAINER, hit_node->GetRole()); + ASSERT_EQ(ax::mojom::Role::kGenericContainer, hit_node->GetRole()); // (50, 350) -> "Ordinary Button" hit_node = HitTestAndWaitForResult(gfx::Point(50, 350)); ASSERT_TRUE(hit_node != nullptr); - ASSERT_EQ(ui::AX_ROLE_BUTTON, hit_node->GetRole()); - ASSERT_EQ("Ordinary Button", hit_node->GetStringAttribute(ui::AX_ATTR_NAME)); + ASSERT_EQ(ax::mojom::Role::kButton, hit_node->GetRole()); + ASSERT_EQ("Ordinary Button", + hit_node->GetStringAttribute(ax::mojom::StringAttribute::kName)); // (50, 455) -> "Scrolled Button" hit_node = HitTestAndWaitForResult(gfx::Point(50, 455)); ASSERT_TRUE(hit_node != nullptr); - ASSERT_EQ(ui::AX_ROLE_BUTTON, hit_node->GetRole()); - ASSERT_EQ("Scrolled Button", hit_node->GetStringAttribute(ui::AX_ATTR_NAME)); + ASSERT_EQ(ax::mojom::Role::kButton, hit_node->GetRole()); + ASSERT_EQ("Scrolled Button", + hit_node->GetStringAttribute(ax::mojom::StringAttribute::kName)); // (50, 505) -> div in second iframe hit_node = HitTestAndWaitForResult(gfx::Point(50, 505)); ASSERT_TRUE(hit_node != nullptr); - ASSERT_EQ(ui::AX_ROLE_GENERIC_CONTAINER, hit_node->GetRole()); + ASSERT_EQ(ax::mojom::Role::kGenericContainer, hit_node->GetRole()); // (50, 505) -> div in second iframe // but with a different event - hit_node = - HitTestAndWaitForResultWithEvent(gfx::Point(50, 505), ui::AX_EVENT_ALERT); + hit_node = HitTestAndWaitForResultWithEvent(gfx::Point(50, 505), + ax::mojom::Event::kAlert); ASSERT_NE(hit_node, nullptr); - ASSERT_EQ(ui::AX_ROLE_GENERIC_CONTAINER, hit_node->GetRole()); + ASSERT_EQ(ax::mojom::Role::kGenericContainer, hit_node->GetRole()); } IN_PROC_BROWSER_TEST_F(AccessibilityHitTestingBrowserTest, @@ -170,8 +175,9 @@ IN_PROC_BROWSER_TEST_F(AccessibilityHitTestingBrowserTest, NavigateToURL(shell(), GURL(url::kAboutBlankURL)); - AccessibilityNotificationWaiter waiter( - shell()->web_contents(), ui::kAXModeComplete, ui::AX_EVENT_LOAD_COMPLETE); + AccessibilityNotificationWaiter waiter(shell()->web_contents(), + ui::kAXModeComplete, + ax::mojom::Event::kLoadComplete); GURL url(embedded_test_server()->GetURL( "/accessibility/hit_testing/hit_testing.html")); NavigateToURL(shell(), url); @@ -193,39 +199,42 @@ IN_PROC_BROWSER_TEST_F(AccessibilityHitTestingBrowserTest, BrowserAccessibility* hit_node; hit_node = CallCachingAsyncHitTest(gfx::Point(50, 50)); ASSERT_TRUE(hit_node != nullptr); - ASSERT_NE(ui::AX_ROLE_BUTTON, hit_node->GetRole()); + ASSERT_NE(ax::mojom::Role::kButton, hit_node->GetRole()); hit_node = CallCachingAsyncHitTest(gfx::Point(50, 50)); - ASSERT_EQ("Button", hit_node->GetStringAttribute(ui::AX_ATTR_NAME)); + ASSERT_EQ("Button", + hit_node->GetStringAttribute(ax::mojom::StringAttribute::kName)); // (50, 305) -> div in first iframe hit_node = CallCachingAsyncHitTest(gfx::Point(50, 305)); ASSERT_TRUE(hit_node != nullptr); - ASSERT_NE(ui::AX_ROLE_GENERIC_CONTAINER, hit_node->GetRole()); + ASSERT_NE(ax::mojom::Role::kGenericContainer, hit_node->GetRole()); hit_node = CallCachingAsyncHitTest(gfx::Point(50, 305)); - ASSERT_EQ(ui::AX_ROLE_GENERIC_CONTAINER, hit_node->GetRole()); + ASSERT_EQ(ax::mojom::Role::kGenericContainer, hit_node->GetRole()); // (50, 350) -> "Ordinary Button" hit_node = CallCachingAsyncHitTest(gfx::Point(50, 350)); ASSERT_TRUE(hit_node != nullptr); - ASSERT_NE(ui::AX_ROLE_BUTTON, hit_node->GetRole()); + ASSERT_NE(ax::mojom::Role::kButton, hit_node->GetRole()); hit_node = CallCachingAsyncHitTest(gfx::Point(50, 350)); - ASSERT_EQ(ui::AX_ROLE_BUTTON, hit_node->GetRole()); - ASSERT_EQ("Ordinary Button", hit_node->GetStringAttribute(ui::AX_ATTR_NAME)); + ASSERT_EQ(ax::mojom::Role::kButton, hit_node->GetRole()); + ASSERT_EQ("Ordinary Button", + hit_node->GetStringAttribute(ax::mojom::StringAttribute::kName)); // (50, 455) -> "Scrolled Button" hit_node = CallCachingAsyncHitTest(gfx::Point(50, 455)); ASSERT_TRUE(hit_node != nullptr); - ASSERT_NE(ui::AX_ROLE_BUTTON, hit_node->GetRole()); + ASSERT_NE(ax::mojom::Role::kButton, hit_node->GetRole()); hit_node = CallCachingAsyncHitTest(gfx::Point(50, 455)); - ASSERT_EQ(ui::AX_ROLE_BUTTON, hit_node->GetRole()); - ASSERT_EQ("Scrolled Button", hit_node->GetStringAttribute(ui::AX_ATTR_NAME)); + ASSERT_EQ(ax::mojom::Role::kButton, hit_node->GetRole()); + ASSERT_EQ("Scrolled Button", + hit_node->GetStringAttribute(ax::mojom::StringAttribute::kName)); // (50, 505) -> div in second iframe hit_node = CallCachingAsyncHitTest(gfx::Point(50, 505)); ASSERT_TRUE(hit_node != nullptr); - ASSERT_NE(ui::AX_ROLE_GENERIC_CONTAINER, hit_node->GetRole()); + ASSERT_NE(ax::mojom::Role::kGenericContainer, hit_node->GetRole()); hit_node = CallCachingAsyncHitTest(gfx::Point(50, 505)); - ASSERT_EQ(ui::AX_ROLE_GENERIC_CONTAINER, hit_node->GetRole()); + ASSERT_EQ(ax::mojom::Role::kGenericContainer, hit_node->GetRole()); } } // namespace content diff --git a/content/browser/accessibility/one_shot_accessibility_tree_search.cc b/content/browser/accessibility/one_shot_accessibility_tree_search.cc index 865ec9b484b408..88c6d11040795d 100644 --- a/content/browser/accessibility/one_shot_accessibility_tree_search.cc +++ b/content/browser/accessibility/one_shot_accessibility_tree_search.cc @@ -11,7 +11,7 @@ #include "base/strings/utf_string_conversions.h" #include "content/browser/accessibility/browser_accessibility.h" #include "content/browser/accessibility/browser_accessibility_manager.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_node.h" #include "ui/accessibility/ax_role_properties.h" @@ -21,14 +21,18 @@ namespace content { // attributes that might be relevant for a text search. void GetNodeStrings(BrowserAccessibility* node, std::vector* strings) { - if (node->HasStringAttribute(ui::AX_ATTR_NAME)) - strings->push_back(node->GetString16Attribute(ui::AX_ATTR_NAME)); - if (node->HasStringAttribute(ui::AX_ATTR_DESCRIPTION)) - strings->push_back(node->GetString16Attribute(ui::AX_ATTR_DESCRIPTION)); - if (node->HasStringAttribute(ui::AX_ATTR_VALUE)) - strings->push_back(node->GetString16Attribute(ui::AX_ATTR_VALUE)); - if (node->HasStringAttribute(ui::AX_ATTR_PLACEHOLDER)) - strings->push_back(node->GetString16Attribute(ui::AX_ATTR_PLACEHOLDER)); + if (node->HasStringAttribute(ax::mojom::StringAttribute::kName)) + strings->push_back( + node->GetString16Attribute(ax::mojom::StringAttribute::kName)); + if (node->HasStringAttribute(ax::mojom::StringAttribute::kDescription)) + strings->push_back( + node->GetString16Attribute(ax::mojom::StringAttribute::kDescription)); + if (node->HasStringAttribute(ax::mojom::StringAttribute::kValue)) + strings->push_back( + node->GetString16Attribute(ax::mojom::StringAttribute::kValue)); + if (node->HasStringAttribute(ax::mojom::StringAttribute::kPlaceholder)) + strings->push_back( + node->GetString16Attribute(ax::mojom::StringAttribute::kPlaceholder)); } OneShotAccessibilityTreeSearch::OneShotAccessibilityTreeSearch( @@ -190,7 +194,7 @@ bool OneShotAccessibilityTreeSearch::Matches(BrowserAccessibility* node) { } if (visible_only_) { - if (node->HasState(ui::AX_STATE_INVISIBLE) || node->IsOffscreen()) { + if (node->HasState(ax::mojom::State::kInvisible) || node->IsOffscreen()) { return false; } } @@ -223,17 +227,17 @@ bool OneShotAccessibilityTreeSearch::Matches(BrowserAccessibility* node) { bool AccessibilityArticlePredicate( BrowserAccessibility* start, BrowserAccessibility* node) { - return node->GetRole() == ui::AX_ROLE_ARTICLE; + return node->GetRole() == ax::mojom::Role::kArticle; } bool AccessibilityButtonPredicate( BrowserAccessibility* start, BrowserAccessibility* node) { switch (node->GetRole()) { - case ui::AX_ROLE_BUTTON: - case ui::AX_ROLE_MENU_BUTTON: - case ui::AX_ROLE_POP_UP_BUTTON: - case ui::AX_ROLE_SWITCH: - case ui::AX_ROLE_TOGGLE_BUTTON: + case ax::mojom::Role::kButton: + case ax::mojom::Role::kMenuButton: + case ax::mojom::Role::kPopUpButton: + case ax::mojom::Role::kSwitch: + case ax::mojom::Role::kToggleButton: return true; default: return false; @@ -242,33 +246,33 @@ bool AccessibilityButtonPredicate( bool AccessibilityBlockquotePredicate( BrowserAccessibility* start, BrowserAccessibility* node) { - return node->GetRole() == ui::AX_ROLE_BLOCKQUOTE; + return node->GetRole() == ax::mojom::Role::kBlockquote; } bool AccessibilityCheckboxPredicate( BrowserAccessibility* start, BrowserAccessibility* node) { - return (node->GetRole() == ui::AX_ROLE_CHECK_BOX || - node->GetRole() == ui::AX_ROLE_MENU_ITEM_CHECK_BOX); + return (node->GetRole() == ax::mojom::Role::kCheckBox || + node->GetRole() == ax::mojom::Role::kMenuItemCheckBox); } bool AccessibilityComboboxPredicate( BrowserAccessibility* start, BrowserAccessibility* node) { - return (node->GetRole() == ui::AX_ROLE_COMBO_BOX_GROUPING || - node->GetRole() == ui::AX_ROLE_COMBO_BOX_MENU_BUTTON || - node->GetRole() == ui::AX_ROLE_TEXT_FIELD_WITH_COMBO_BOX || - node->GetRole() == ui::AX_ROLE_POP_UP_BUTTON); + return (node->GetRole() == ax::mojom::Role::kComboBoxGrouping || + node->GetRole() == ax::mojom::Role::kComboBoxMenuButton || + node->GetRole() == ax::mojom::Role::kTextFieldWithComboBox || + node->GetRole() == ax::mojom::Role::kPopUpButton); } bool AccessibilityControlPredicate( BrowserAccessibility* start, BrowserAccessibility* node) { if (ui::IsControl(node->GetRole())) return true; - if (node->HasState(ui::AX_STATE_FOCUSABLE) && - node->GetRole() != ui::AX_ROLE_IFRAME && - node->GetRole() != ui::AX_ROLE_IFRAME_PRESENTATIONAL && - node->GetRole() != ui::AX_ROLE_LINK && - node->GetRole() != ui::AX_ROLE_WEB_AREA && - node->GetRole() != ui::AX_ROLE_ROOT_WEB_AREA) { + if (node->HasState(ax::mojom::State::kFocusable) && + node->GetRole() != ax::mojom::Role::kIframe && + node->GetRole() != ax::mojom::Role::kIframePresentational && + node->GetRole() != ax::mojom::Role::kLink && + node->GetRole() != ax::mojom::Role::kWebArea && + node->GetRole() != ax::mojom::Role::kRootWebArea) { return true; } return false; @@ -276,11 +280,11 @@ bool AccessibilityControlPredicate( bool AccessibilityFocusablePredicate( BrowserAccessibility* start, BrowserAccessibility* node) { - bool focusable = node->HasState(ui::AX_STATE_FOCUSABLE); - if (node->GetRole() == ui::AX_ROLE_IFRAME || - node->GetRole() == ui::AX_ROLE_IFRAME_PRESENTATIONAL || - node->GetRole() == ui::AX_ROLE_WEB_AREA || - node->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA) { + bool focusable = node->HasState(ax::mojom::State::kFocusable); + if (node->GetRole() == ax::mojom::Role::kIframe || + node->GetRole() == ax::mojom::Role::kIframePresentational || + node->GetRole() == ax::mojom::Role::kWebArea || + node->GetRole() == ax::mojom::Role::kRootWebArea) { focusable = false; } return focusable; @@ -288,56 +292,63 @@ bool AccessibilityFocusablePredicate( bool AccessibilityGraphicPredicate( BrowserAccessibility* start, BrowserAccessibility* node) { - return node->GetRole() == ui::AX_ROLE_IMAGE; + return node->GetRole() == ax::mojom::Role::kImage; } bool AccessibilityHeadingPredicate( BrowserAccessibility* start, BrowserAccessibility* node) { - return (node->GetRole() == ui::AX_ROLE_HEADING); + return (node->GetRole() == ax::mojom::Role::kHeading); } bool AccessibilityH1Predicate( BrowserAccessibility* start, BrowserAccessibility* node) { - return (node->GetRole() == ui::AX_ROLE_HEADING && - node->GetIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL) == 1); + return (node->GetRole() == ax::mojom::Role::kHeading && + node->GetIntAttribute(ax::mojom::IntAttribute::kHierarchicalLevel) == + 1); } bool AccessibilityH2Predicate( BrowserAccessibility* start, BrowserAccessibility* node) { - return (node->GetRole() == ui::AX_ROLE_HEADING && - node->GetIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL) == 2); + return (node->GetRole() == ax::mojom::Role::kHeading && + node->GetIntAttribute(ax::mojom::IntAttribute::kHierarchicalLevel) == + 2); } bool AccessibilityH3Predicate( BrowserAccessibility* start, BrowserAccessibility* node) { - return (node->GetRole() == ui::AX_ROLE_HEADING && - node->GetIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL) == 3); + return (node->GetRole() == ax::mojom::Role::kHeading && + node->GetIntAttribute(ax::mojom::IntAttribute::kHierarchicalLevel) == + 3); } bool AccessibilityH4Predicate( BrowserAccessibility* start, BrowserAccessibility* node) { - return (node->GetRole() == ui::AX_ROLE_HEADING && - node->GetIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL) == 4); + return (node->GetRole() == ax::mojom::Role::kHeading && + node->GetIntAttribute(ax::mojom::IntAttribute::kHierarchicalLevel) == + 4); } bool AccessibilityH5Predicate( BrowserAccessibility* start, BrowserAccessibility* node) { - return (node->GetRole() == ui::AX_ROLE_HEADING && - node->GetIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL) == 5); + return (node->GetRole() == ax::mojom::Role::kHeading && + node->GetIntAttribute(ax::mojom::IntAttribute::kHierarchicalLevel) == + 5); } bool AccessibilityH6Predicate( BrowserAccessibility* start, BrowserAccessibility* node) { - return (node->GetRole() == ui::AX_ROLE_HEADING && - node->GetIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL) == 6); + return (node->GetRole() == ax::mojom::Role::kHeading && + node->GetIntAttribute(ax::mojom::IntAttribute::kHierarchicalLevel) == + 6); } bool AccessibilityHeadingSameLevelPredicate( BrowserAccessibility* start, BrowserAccessibility* node) { - return (node->GetRole() == ui::AX_ROLE_HEADING && - start->GetRole() == ui::AX_ROLE_HEADING && - (node->GetIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL) == - start->GetIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL))); + return ( + node->GetRole() == ax::mojom::Role::kHeading && + start->GetRole() == ax::mojom::Role::kHeading && + (node->GetIntAttribute(ax::mojom::IntAttribute::kHierarchicalLevel) == + start->GetIntAttribute(ax::mojom::IntAttribute::kHierarchicalLevel))); } bool AccessibilityFramePredicate( @@ -346,22 +357,22 @@ bool AccessibilityFramePredicate( return false; if (!node->PlatformGetParent()) return false; - return (node->GetRole() == ui::AX_ROLE_WEB_AREA || - node->GetRole() == ui::AX_ROLE_ROOT_WEB_AREA); + return (node->GetRole() == ax::mojom::Role::kWebArea || + node->GetRole() == ax::mojom::Role::kRootWebArea); } bool AccessibilityLandmarkPredicate( BrowserAccessibility* start, BrowserAccessibility* node) { switch (node->GetRole()) { - case ui::AX_ROLE_APPLICATION: - case ui::AX_ROLE_ARTICLE: - case ui::AX_ROLE_BANNER: - case ui::AX_ROLE_COMPLEMENTARY: - case ui::AX_ROLE_CONTENT_INFO: - case ui::AX_ROLE_MAIN: - case ui::AX_ROLE_NAVIGATION: - case ui::AX_ROLE_SEARCH: - case ui::AX_ROLE_REGION: + case ax::mojom::Role::kApplication: + case ax::mojom::Role::kArticle: + case ax::mojom::Role::kBanner: + case ax::mojom::Role::kComplementary: + case ax::mojom::Role::kContentInfo: + case ax::mojom::Role::kMain: + case ax::mojom::Role::kNavigation: + case ax::mojom::Role::kSearch: + case ax::mojom::Role::kRegion: return true; default: return false; @@ -370,48 +381,49 @@ bool AccessibilityLandmarkPredicate( bool AccessibilityLinkPredicate( BrowserAccessibility* start, BrowserAccessibility* node) { - return node->GetRole() == ui::AX_ROLE_LINK; + return node->GetRole() == ax::mojom::Role::kLink; } bool AccessibilityListPredicate( BrowserAccessibility* start, BrowserAccessibility* node) { - return (node->GetRole() == ui::AX_ROLE_LIST_BOX || - node->GetRole() == ui::AX_ROLE_LIST || - node->GetRole() == ui::AX_ROLE_DESCRIPTION_LIST); + return (node->GetRole() == ax::mojom::Role::kListBox || + node->GetRole() == ax::mojom::Role::kList || + node->GetRole() == ax::mojom::Role::kDescriptionList); } bool AccessibilityListItemPredicate( BrowserAccessibility* start, BrowserAccessibility* node) { - return (node->GetRole() == ui::AX_ROLE_LIST_ITEM || - node->GetRole() == ui::AX_ROLE_DESCRIPTION_LIST_TERM || - node->GetRole() == ui::AX_ROLE_LIST_BOX_OPTION); + return (node->GetRole() == ax::mojom::Role::kListItem || + node->GetRole() == ax::mojom::Role::kDescriptionListTerm || + node->GetRole() == ax::mojom::Role::kListBoxOption); } bool AccessibilityLiveRegionPredicate( BrowserAccessibility* start, BrowserAccessibility* node) { - return node->HasStringAttribute(ui::AX_ATTR_LIVE_STATUS); + return node->HasStringAttribute(ax::mojom::StringAttribute::kLiveStatus); } bool AccessibilityMainPredicate( BrowserAccessibility* start, BrowserAccessibility* node) { - return (node->GetRole() == ui::AX_ROLE_MAIN); + return (node->GetRole() == ax::mojom::Role::kMain); } bool AccessibilityMediaPredicate( BrowserAccessibility* start, BrowserAccessibility* node) { - const std::string& tag = node->GetStringAttribute(ui::AX_ATTR_HTML_TAG); + const std::string& tag = + node->GetStringAttribute(ax::mojom::StringAttribute::kHtmlTag); return tag == "audio" || tag == "video"; } bool AccessibilityRadioButtonPredicate( BrowserAccessibility* start, BrowserAccessibility* node) { - return (node->GetRole() == ui::AX_ROLE_RADIO_BUTTON || - node->GetRole() == ui::AX_ROLE_MENU_ITEM_RADIO); + return (node->GetRole() == ax::mojom::Role::kRadioButton || + node->GetRole() == ax::mojom::Role::kMenuItemRadio); } bool AccessibilityRadioGroupPredicate( BrowserAccessibility* start, BrowserAccessibility* node) { - return node->GetRole() == ui::AX_ROLE_RADIO_GROUP; + return node->GetRole() == ax::mojom::Role::kRadioGroup; } bool AccessibilityTablePredicate( @@ -426,20 +438,23 @@ bool AccessibilityTextfieldPredicate( bool AccessibilityTextStyleBoldPredicate( BrowserAccessibility* start, BrowserAccessibility* node) { - int32_t style = node->GetIntAttribute(ui::AX_ATTR_TEXT_STYLE); - return 0 != (style & static_cast(ui::AX_TEXT_STYLE_BOLD)); + int32_t style = node->GetIntAttribute(ax::mojom::IntAttribute::kTextStyle); + return 0 != + (style & static_cast(ax::mojom::TextStyle::kTextStyleBold)); } bool AccessibilityTextStyleItalicPredicate( BrowserAccessibility* start, BrowserAccessibility* node) { - int32_t style = node->GetIntAttribute(ui::AX_ATTR_TEXT_STYLE); - return 0 != (style & static_cast(ui::AX_TEXT_STYLE_BOLD)); + int32_t style = node->GetIntAttribute(ax::mojom::IntAttribute::kTextStyle); + return 0 != + (style & static_cast(ax::mojom::TextStyle::kTextStyleBold)); } bool AccessibilityTextStyleUnderlinePredicate( BrowserAccessibility* start, BrowserAccessibility* node) { - int32_t style = node->GetIntAttribute(ui::AX_ATTR_TEXT_STYLE); - return 0 != (style & static_cast(ui::AX_TEXT_STYLE_UNDERLINE)); + int32_t style = node->GetIntAttribute(ax::mojom::IntAttribute::kTextStyle); + return 0 != (style & + static_cast(ax::mojom::TextStyle::kTextStyleUnderline)); } bool AccessibilityTreePredicate( @@ -449,14 +464,14 @@ bool AccessibilityTreePredicate( bool AccessibilityUnvisitedLinkPredicate( BrowserAccessibility* start, BrowserAccessibility* node) { - return node->GetRole() == ui::AX_ROLE_LINK && - !node->HasState(ui::AX_STATE_VISITED); + return node->GetRole() == ax::mojom::Role::kLink && + !node->HasState(ax::mojom::State::kVisited); } bool AccessibilityVisitedLinkPredicate( BrowserAccessibility* start, BrowserAccessibility* node) { - return node->GetRole() == ui::AX_ROLE_LINK && - node->HasState(ui::AX_STATE_VISITED); + return node->GetRole() == ax::mojom::Role::kLink && + node->HasState(ax::mojom::State::kVisited); } } // namespace content diff --git a/content/browser/accessibility/one_shot_accessibility_tree_search_unittest.cc b/content/browser/accessibility/one_shot_accessibility_tree_search_unittest.cc index 13a377496ae644..10544bb6994265 100644 --- a/content/browser/accessibility/one_shot_accessibility_tree_search_unittest.cc +++ b/content/browser/accessibility/one_shot_accessibility_tree_search_unittest.cc @@ -65,9 +65,9 @@ void MAYBE_OneShotAccessibilityTreeSearchTest::SetUp() { ui::AXNodeData root; root.id = 1; root.SetName("Document"); - root.role = ui::AX_ROLE_ROOT_WEB_AREA; + root.role = ax::mojom::Role::kRootWebArea; root.location = gfx::RectF(0, 0, 800, 600); - root.AddBoolAttribute(ui::AX_ATTR_CLIPS_CHILDREN, true); + root.AddBoolAttribute(ax::mojom::BoolAttribute::kClipsChildren, true); root.child_ids.push_back(2); root.child_ids.push_back(3); root.child_ids.push_back(6); @@ -75,12 +75,12 @@ void MAYBE_OneShotAccessibilityTreeSearchTest::SetUp() { ui::AXNodeData heading; heading.id = 2; heading.SetName("Heading"); - heading.role = ui::AX_ROLE_HEADING; + heading.role = ax::mojom::Role::kHeading; heading.location = gfx::RectF(0, 0, 800, 50); ui::AXNodeData list; list.id = 3; - list.role = ui::AX_ROLE_LIST; + list.role = ax::mojom::Role::kList; list.location = gfx::RectF(0, 50, 500, 500); list.child_ids.push_back(4); list.child_ids.push_back(5); @@ -88,19 +88,19 @@ void MAYBE_OneShotAccessibilityTreeSearchTest::SetUp() { ui::AXNodeData list_item_1; list_item_1.id = 4; list_item_1.SetName("Autobots"); - list_item_1.role = ui::AX_ROLE_LIST_ITEM; + list_item_1.role = ax::mojom::Role::kListItem; list_item_1.location = gfx::RectF(10, 10, 200, 30); ui::AXNodeData list_item_2; list_item_2.id = 5; list_item_2.SetName("Decepticons"); - list_item_2.role = ui::AX_ROLE_LIST_ITEM; + list_item_2.role = ax::mojom::Role::kListItem; list_item_2.location = gfx::RectF(10, 40, 200, 60); ui::AXNodeData footer; footer.id = 6; footer.SetName("Footer"); - footer.role = ui::AX_ROLE_FOOTER; + footer.role = ax::mojom::Role::kFooter; footer.location = gfx::RectF(0, 650, 100, 800); tree_.reset(new TestBrowserAccessibilityManager( @@ -237,10 +237,10 @@ TEST_F(MAYBE_OneShotAccessibilityTreeSearchTest, CaseInsensitiveStringMatch) { TEST_F(MAYBE_OneShotAccessibilityTreeSearchTest, OnePredicate) { OneShotAccessibilityTreeSearch search(tree_->GetRoot()); - search.AddPredicate([](BrowserAccessibility* start, - BrowserAccessibility* current) { - return current->GetRole() == ui::AX_ROLE_LIST_ITEM; - }); + search.AddPredicate( + [](BrowserAccessibility* start, BrowserAccessibility* current) { + return current->GetRole() == ax::mojom::Role::kListItem; + }); ASSERT_EQ(2U, search.CountMatches()); EXPECT_EQ(4, search.GetMatchAtIndex(0)->GetId()); EXPECT_EQ(5, search.GetMatchAtIndex(1)->GetId()); @@ -248,11 +248,11 @@ TEST_F(MAYBE_OneShotAccessibilityTreeSearchTest, OnePredicate) { TEST_F(MAYBE_OneShotAccessibilityTreeSearchTest, TwoPredicates) { OneShotAccessibilityTreeSearch search(tree_->GetRoot()); - search.AddPredicate([](BrowserAccessibility* start, - BrowserAccessibility* current) { - return (current->GetRole() == ui::AX_ROLE_LIST || - current->GetRole() == ui::AX_ROLE_LIST_ITEM); - }); + search.AddPredicate( + [](BrowserAccessibility* start, BrowserAccessibility* current) { + return (current->GetRole() == ax::mojom::Role::kList || + current->GetRole() == ax::mojom::Role::kListItem); + }); search.AddPredicate([](BrowserAccessibility* start, BrowserAccessibility* current) { return (current->GetId() % 2 == 1); diff --git a/content/browser/accessibility/site_per_process_accessibility_browsertest.cc b/content/browser/accessibility/site_per_process_accessibility_browsertest.cc index 3e779ffde1965b..20778de755763d 100644 --- a/content/browser/accessibility/site_per_process_accessibility_browsertest.cc +++ b/content/browser/accessibility/site_per_process_accessibility_browsertest.cc @@ -104,31 +104,33 @@ IN_PROC_BROWSER_TEST_F(MAYBE_SitePerProcessAccessibilityBrowserTest, // Assert that we can walk from the main frame down into the child frame // directly, getting correct roles and data along the way. BrowserAccessibility* ax_root = main_frame_manager->GetRoot(); - EXPECT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, ax_root->GetRole()); + EXPECT_EQ(ax::mojom::Role::kRootWebArea, ax_root->GetRole()); ASSERT_EQ(1U, ax_root->PlatformChildCount()); BrowserAccessibility* ax_group = ax_root->PlatformGetChild(0); - EXPECT_EQ(ui::AX_ROLE_GENERIC_CONTAINER, ax_group->GetRole()); + EXPECT_EQ(ax::mojom::Role::kGenericContainer, ax_group->GetRole()); ASSERT_EQ(2U, ax_group->PlatformChildCount()); BrowserAccessibility* ax_iframe = ax_group->PlatformGetChild(0); - EXPECT_EQ(ui::AX_ROLE_IFRAME, ax_iframe->GetRole()); + EXPECT_EQ(ax::mojom::Role::kIframe, ax_iframe->GetRole()); ASSERT_EQ(1U, ax_iframe->PlatformChildCount()); BrowserAccessibility* ax_child_frame_root = ax_iframe->PlatformGetChild(0); - EXPECT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, ax_child_frame_root->GetRole()); + EXPECT_EQ(ax::mojom::Role::kRootWebArea, ax_child_frame_root->GetRole()); ASSERT_EQ(1U, ax_child_frame_root->PlatformChildCount()); - EXPECT_EQ("Title Of Awesomeness", - ax_child_frame_root->GetStringAttribute(ui::AX_ATTR_NAME)); + EXPECT_EQ("Title Of Awesomeness", ax_child_frame_root->GetStringAttribute( + ax::mojom::StringAttribute::kName)); BrowserAccessibility* ax_child_frame_group = ax_child_frame_root->PlatformGetChild(0); - EXPECT_EQ(ui::AX_ROLE_GENERIC_CONTAINER, ax_child_frame_group->GetRole()); + EXPECT_EQ(ax::mojom::Role::kGenericContainer, + ax_child_frame_group->GetRole()); ASSERT_EQ(1U, ax_child_frame_group->PlatformChildCount()); BrowserAccessibility* ax_child_frame_static_text = ax_child_frame_group->PlatformGetChild(0); - EXPECT_EQ(ui::AX_ROLE_STATIC_TEXT, ax_child_frame_static_text->GetRole()); + EXPECT_EQ(ax::mojom::Role::kStaticText, + ax_child_frame_static_text->GetRole()); ASSERT_EQ(0U, ax_child_frame_static_text->PlatformChildCount()); // Last, check that the parent of the child frame root is correct. diff --git a/content/browser/accessibility/snapshot_ax_tree_browsertest.cc b/content/browser/accessibility/snapshot_ax_tree_browsertest.cc index 91b21b0f056368..b3ef560870c915 100644 --- a/content/browser/accessibility/snapshot_ax_tree_browsertest.cc +++ b/content/browser/accessibility/snapshot_ax_tree_browsertest.cc @@ -48,8 +48,10 @@ void DumpRolesAndNamesAsText(const ui::AXNode* node, for (int i = 0; i < indent; i++) *dst += " "; *dst += ui::ToString(node->data().role); - if (node->data().HasStringAttribute(ui::AX_ATTR_NAME)) - *dst += " '" + node->data().GetStringAttribute(ui::AX_ATTR_NAME) + "'"; + if (node->data().HasStringAttribute(ax::mojom::StringAttribute::kName)) + *dst += " '" + + node->data().GetStringAttribute(ax::mojom::StringAttribute::kName) + + "'"; *dst += "\n"; for (int i = 0; i < node->child_count(); ++i) DumpRolesAndNamesAsText(node->children()[i], indent + 1, dst); @@ -84,11 +86,11 @@ IN_PROC_BROWSER_TEST_F(SnapshotAXTreeBrowserTest, ui::AXTree tree(waiter.snapshot()); ui::AXNode* root = tree.root(); ASSERT_NE(nullptr, root); - ASSERT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, root->data().role); + ASSERT_EQ(ax::mojom::Role::kRootWebArea, root->data().role); ui::AXNode* group = root->ChildAtIndex(0); - ASSERT_EQ(ui::AX_ROLE_GENERIC_CONTAINER, group->data().role); + ASSERT_EQ(ax::mojom::Role::kGenericContainer, group->data().role); ui::AXNode* button = group->ChildAtIndex(0); - ASSERT_EQ(ui::AX_ROLE_BUTTON, button->data().role); + ASSERT_EQ(ax::mojom::Role::kButton, button->data().role); } IN_PROC_BROWSER_TEST_F(SnapshotAXTreeBrowserTest, diff --git a/content/browser/accessibility/touch_accessibility_aura_browsertest.cc b/content/browser/accessibility/touch_accessibility_aura_browsertest.cc index db03887f46ba1d..94d6a730b04663 100644 --- a/content/browser/accessibility/touch_accessibility_aura_browsertest.cc +++ b/content/browser/accessibility/touch_accessibility_aura_browsertest.cc @@ -38,7 +38,7 @@ class TouchAccessibilityBrowserTest : public ContentBrowserTest { void NavigateToUrlAndWaitForAccessibilityTree(const GURL& url) { AccessibilityNotificationWaiter waiter(shell()->web_contents(), ui::kAXModeComplete, - ui::AX_EVENT_LOAD_COMPLETE); + ax::mojom::Event::kLoadComplete); NavigateToURL(shell(), url); waiter.WaitForNotification(); } @@ -94,7 +94,7 @@ IN_PROC_BROWSER_TEST_F(TouchAccessibilityBrowserTest, // touch exploration event in the center of that cell, and assert that we // get an accessibility hover event fired in the correct cell. AccessibilityNotificationWaiter waiter( - shell()->web_contents(), ui::kAXModeComplete, ui::AX_EVENT_HOVER); + shell()->web_contents(), ui::kAXModeComplete, ax::mojom::Event::kHover); for (int row = 0; row < 5; ++row) { for (int col = 0; col < 7; ++col) { std::string expected_cell_text = base::IntToString(row * 7 + col); @@ -111,7 +111,8 @@ IN_PROC_BROWSER_TEST_F(TouchAccessibilityBrowserTest, BrowserAccessibility* hit = manager->GetFromID(target_id); BrowserAccessibility* child = hit->PlatformGetChild(0); ASSERT_NE(nullptr, child); - cell_text = child->GetData().GetStringAttribute(ui::AX_ATTR_NAME); + cell_text = child->GetData().GetStringAttribute( + ax::mojom::StringAttribute::kName); VLOG(1) << "Got hover event in cell with text: " << cell_text; } while (cell_text != expected_cell_text); } @@ -139,14 +140,14 @@ IN_PROC_BROWSER_TEST_F(TouchAccessibilityBrowserTest, // Send a touch exploration event to the button in the first iframe. // A touch exploration event is just a mouse move event with // the ui::EF_TOUCH_ACCESSIBILITY flag set. - AccessibilityNotificationWaiter waiter( - child_frame, ui::AX_EVENT_HOVER); + AccessibilityNotificationWaiter waiter(child_frame, ax::mojom::Event::kHover); SendTouchExplorationEvent(50, 350); waiter.WaitForNotification(); int target_id = waiter.event_target_id(); BrowserAccessibility* hit = child_manager->GetFromID(target_id); - EXPECT_EQ(ui::AX_ROLE_BUTTON, hit->GetData().role); - std::string text = hit->GetData().GetStringAttribute(ui::AX_ATTR_NAME); + EXPECT_EQ(ax::mojom::Role::kButton, hit->GetData().role); + std::string text = + hit->GetData().GetStringAttribute(ax::mojom::StringAttribute::kName); EXPECT_EQ("Ordinary Button", text); } @@ -176,14 +177,14 @@ IN_PROC_BROWSER_TEST_F(TouchAccessibilityBrowserTest, // Send a touch exploration event to the button in the first iframe. // A touch exploration event is just a mouse move event with // the ui::EF_TOUCH_ACCESSIBILITY flag set. - AccessibilityNotificationWaiter waiter( - child_frame, ui::AX_EVENT_HOVER); + AccessibilityNotificationWaiter waiter(child_frame, ax::mojom::Event::kHover); SendTouchExplorationEvent(50, 350); waiter.WaitForNotification(); int target_id = waiter.event_target_id(); BrowserAccessibility* hit = child_manager->GetFromID(target_id); - EXPECT_EQ(ui::AX_ROLE_BUTTON, hit->GetData().role); - std::string text = hit->GetData().GetStringAttribute(ui::AX_ATTR_NAME); + EXPECT_EQ(ax::mojom::Role::kButton, hit->GetData().role); + std::string text = + hit->GetData().GetStringAttribute(ax::mojom::StringAttribute::kName); EXPECT_EQ("Ordinary Button", text); } diff --git a/content/browser/accessibility/web_contents_accessibility_android.cc b/content/browser/accessibility/web_contents_accessibility_android.cc index de1a79acf500a4..ca40f85aeaf62a 100644 --- a/content/browser/accessibility/web_contents_accessibility_android.cc +++ b/content/browser/accessibility/web_contents_accessibility_android.cc @@ -194,16 +194,16 @@ base::LazyInstance::Leaky g_all_search_keys = bool SectionPredicate(BrowserAccessibility* start, BrowserAccessibility* node) { switch (node->GetRole()) { - case ui::AX_ROLE_ARTICLE: - case ui::AX_ROLE_APPLICATION: - case ui::AX_ROLE_BANNER: - case ui::AX_ROLE_COMPLEMENTARY: - case ui::AX_ROLE_CONTENT_INFO: - case ui::AX_ROLE_HEADING: - case ui::AX_ROLE_MAIN: - case ui::AX_ROLE_NAVIGATION: - case ui::AX_ROLE_SEARCH: - case ui::AX_ROLE_REGION: + case ax::mojom::Role::kArticle: + case ax::mojom::Role::kApplication: + case ax::mojom::Role::kBanner: + case ax::mojom::Role::kComplementary: + case ax::mojom::Role::kContentInfo: + case ax::mojom::Role::kHeading: + case ax::mojom::Role::kMain: + case ax::mojom::Role::kNavigation: + case ax::mojom::Role::kSearch: + case ax::mojom::Role::kRegion: return true; default: return false; @@ -623,7 +623,7 @@ jint WebContentsAccessibilityAndroid::GetEditableTextSelectionStart( if (!node) return false; - return node->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START); + return node->GetIntAttribute(ax::mojom::IntAttribute::kTextSelStart); } jint WebContentsAccessibilityAndroid::GetEditableTextSelectionEnd( @@ -634,7 +634,7 @@ jint WebContentsAccessibilityAndroid::GetEditableTextSelectionEnd( if (!node) return false; - return node->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END); + return node->GetIntAttribute(ax::mojom::IntAttribute::kTextSelEnd); } jboolean WebContentsAccessibilityAndroid::PopulateAccessibilityNodeInfo( @@ -678,7 +678,8 @@ jboolean WebContentsAccessibilityAndroid::PopulateAccessibilityNodeInfo( base::android::ConvertUTF16ToJavaString(env, node->GetText()), node->IsLink(), node->IsEditableText(), base::android::ConvertUTF16ToJavaString( - env, node->GetInheritedString16Attribute(ui::AX_ATTR_LANGUAGE))); + env, node->GetInheritedString16Attribute( + ax::mojom::StringAttribute::kLanguage))); base::string16 element_id; if (node->GetHtmlAttribute("id", &element_id)) { Java_WebContentsAccessibility_setAccessibilityNodeInfoViewIdResourceName( @@ -703,16 +704,17 @@ jboolean WebContentsAccessibilityAndroid::PopulateAccessibilityNodeInfo( base::android::ConvertUTF8ToJavaString(env, node->GetRoleString()), base::android::ConvertUTF16ToJavaString(env, node->GetRoleDescription()), base::android::ConvertUTF16ToJavaString(env, node->GetHint()), - node->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START), - node->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END)); + node->GetIntAttribute(ax::mojom::IntAttribute::kTextSelStart), + node->GetIntAttribute(ax::mojom::IntAttribute::kTextSelEnd)); Java_WebContentsAccessibility_setAccessibilityNodeInfoLollipopAttributes( env, obj, info, node->CanOpenPopup(), node->IsContentInvalid(), node->IsDismissable(), node->IsMultiLine(), node->AndroidInputType(), node->AndroidLiveRegionType()); - bool has_character_locations = node->GetRole() == ui::AX_ROLE_STATIC_TEXT || - node->IsInterestingOnAndroid(); + bool has_character_locations = + node->GetRole() == ax::mojom::Role::kStaticText || + node->IsInterestingOnAndroid(); Java_WebContentsAccessibility_setAccessibilityNodeInfoOAttributes( env, obj, info, has_character_locations); @@ -883,9 +885,12 @@ jboolean WebContentsAccessibilityAndroid::AdjustSlider( if (!android_node->IsSlider() || !android_node->IsEnabled()) return false; - float value = node->GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE); - float min = node->GetFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE); - float max = node->GetFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE); + float value = + node->GetFloatAttribute(ax::mojom::FloatAttribute::kValueForRange); + float min = + node->GetFloatAttribute(ax::mojom::FloatAttribute::kMinValueForRange); + float max = + node->GetFloatAttribute(ax::mojom::FloatAttribute::kMaxValueForRange); if (max <= min) return false; @@ -1051,7 +1056,7 @@ bool WebContentsAccessibilityAndroid::IsSlider(JNIEnv* env, if (!node) return false; - return node->GetRole() == ui::AX_ROLE_SLIDER; + return node->GetRole() == ax::mojom::Role::kSlider; } void WebContentsAccessibilityAndroid::OnAutofillPopupDisplayed( @@ -1071,11 +1076,11 @@ void WebContentsAccessibilityAndroid::OnAutofillPopupDisplayed( g_autofill_popup_proxy_node = BrowserAccessibility::Create(); g_autofill_popup_proxy_node_ax_node = new ui::AXNode(nullptr, -1, -1); ui::AXNodeData ax_node_data; - ax_node_data.role = ui::AX_ROLE_MENU; + ax_node_data.role = ax::mojom::Role::kMenu; ax_node_data.SetName("Autofill"); - ax_node_data.SetRestriction(ui::AX_RESTRICTION_READ_ONLY); - ax_node_data.AddState(ui::AX_STATE_FOCUSABLE); - ax_node_data.AddState(ui::AX_STATE_SELECTABLE); + ax_node_data.SetRestriction(ax::mojom::Restriction::kReadOnly); + ax_node_data.AddState(ax::mojom::State::kFocusable); + ax_node_data.AddState(ax::mojom::State::kSelectable); g_autofill_popup_proxy_node_ax_node->SetData(ax_node_data); g_autofill_popup_proxy_node->Init(root_manager_, g_autofill_popup_proxy_node_ax_node); diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc index 195a8aad12d67d..9b814222b11baa 100644 --- a/content/browser/frame_host/render_frame_host_impl.cc +++ b/content/browser/frame_host/render_frame_host_impl.cc @@ -2601,7 +2601,7 @@ void RenderFrameHostImpl::OnAccessibilityChildFrameHitTestResult( const gfx::Point& point, int child_frame_routing_id, int child_frame_browser_plugin_instance_id, - ui::AXEvent event_to_fire) { + ax::mojom::Event event_to_fire) { RenderFrameHostImpl* child_frame = nullptr; if (child_frame_routing_id) { RenderFrameProxyHost* rfph = nullptr; @@ -2623,7 +2623,7 @@ void RenderFrameHostImpl::OnAccessibilityChildFrameHitTestResult( ui::AXActionData action_data; action_data.request_id = action_request_id; action_data.target_point = point; - action_data.action = ui::AX_ACTION_HIT_TEST; + action_data.action = ax::mojom::Action::kHitTest; action_data.hit_test_event_to_fire = event_to_fire; child_frame->AccessibilityPerformAction(action_data); @@ -3920,7 +3920,7 @@ void RenderFrameHostImpl::RequestAXTreeSnapshot( } void RenderFrameHostImpl::SetAccessibilityCallbackForTesting( - const base::Callback& + const base::Callback& callback) { accessibility_testing_callback_ = callback; } @@ -4234,12 +4234,12 @@ void RenderFrameHostImpl::AXContentNodeDataToAXNodeData( switch (attr) { case AX_CONTENT_ATTR_CHILD_ROUTING_ID: dst->int_attributes.push_back(std::make_pair( - ui::AX_ATTR_CHILD_TREE_ID, RoutingIDToAXTreeID(value))); + ax::mojom::IntAttribute::kChildTreeId, RoutingIDToAXTreeID(value))); break; case AX_CONTENT_ATTR_CHILD_BROWSER_PLUGIN_INSTANCE_ID: - dst->int_attributes.push_back(std::make_pair( - ui::AX_ATTR_CHILD_TREE_ID, - BrowserPluginInstanceIDToAXTreeID(value))); + dst->int_attributes.push_back( + std::make_pair(ax::mojom::IntAttribute::kChildTreeId, + BrowserPluginInstanceIDToAXTreeID(value))); break; case AX_CONTENT_INT_ATTRIBUTE_LAST: NOTREACHED(); diff --git a/content/browser/frame_host/render_frame_host_impl.h b/content/browser/frame_host/render_frame_host_impl.h index 8f11766770e20b..9e02cfdd986c1f 100644 --- a/content/browser/frame_host/render_frame_host_impl.h +++ b/content/browser/frame_host/render_frame_host_impl.h @@ -489,7 +489,7 @@ class CONTENT_EXPORT RenderFrameHostImpl // renderer process, and the accessibility tree it sent can be // retrieved using GetAXTreeForTesting(). void SetAccessibilityCallbackForTesting( - const base::Callback& + const base::Callback& callback); // Called when the metadata about the accessibility tree for this frame @@ -805,7 +805,7 @@ class CONTENT_EXPORT RenderFrameHostImpl const gfx::Point& point, int child_frame_routing_id, int child_frame_browser_plugin_instance_id, - ui::AXEvent event_to_fire); + ax::mojom::Event event_to_fire); void OnAccessibilitySnapshotResponse( int callback_id, const AXContentTreeUpdate& snapshot); @@ -1225,7 +1225,7 @@ class CONTENT_EXPORT RenderFrameHostImpl #endif // defined(OS_ANDROID) // Callback when an event is received, for testing. - base::Callback + base::Callback accessibility_testing_callback_; // The most recently received accessibility tree - for testing only. std::unique_ptr ax_tree_for_testing_; diff --git a/content/common/accessibility_messages.h b/content/common/accessibility_messages.h index 678209ce3f7020..2fa64a2fdfb759 100644 --- a/content/common/accessibility_messages.h +++ b/content/common/accessibility_messages.h @@ -28,7 +28,7 @@ IPC_ENUM_TRAITS_MAX_VALUE(content::AXContentIntAttribute, content::AX_CONTENT_INT_ATTRIBUTE_LAST) -IPC_ENUM_TRAITS_MAX_VALUE(ui::AXAction, ui::AX_ACTION_LAST) +IPC_ENUM_TRAITS_MAX_VALUE(ax::mojom::Action, ax::mojom::Action::kLast) IPC_STRUCT_TRAITS_BEGIN(ui::AXActionData) IPC_STRUCT_TRAITS_MEMBER(action) @@ -100,13 +100,13 @@ IPC_STRUCT_BEGIN(AccessibilityHostMsg_EventParams) IPC_STRUCT_MEMBER(content::AXContentTreeUpdate, update) // Type of event. - IPC_STRUCT_MEMBER(ui::AXEvent, event_type) + IPC_STRUCT_MEMBER(ax::mojom::Event, event_type) // ID of the node that the event applies to. IPC_STRUCT_MEMBER(int, id) // The source of this event. - IPC_STRUCT_MEMBER(ui::AXEventFrom, event_from) + IPC_STRUCT_MEMBER(ax::mojom::EventFrom, event_from) // ID of the action request triggering this event. IPC_STRUCT_MEMBER(int, action_request_id) @@ -156,7 +156,7 @@ IPC_MESSAGE_ROUTED1(AccessibilityMsg_PerformAction, // it fires an accessibility event of type |event_to_fire| on the target. IPC_MESSAGE_ROUTED3(AccessibilityMsg_HitTest, gfx::Point /* location to test */, - ui::AXEvent /* event to fire */, + ax::mojom::Event /* event to fire */, int /* action request id */) // Tells the render view that a AccessibilityHostMsg_Events @@ -216,7 +216,7 @@ IPC_MESSAGE_ROUTED5(AccessibilityHostMsg_ChildFrameHitTestResult, gfx::Point /* location tested */, int /* routing id of child frame */, int /* browser plugin instance id of child frame */, - ui::AXEvent /* event to fire */) + ax::mojom::Event /* event to fire */) // Sent in response to AccessibilityMsg_SnapshotTree. The callback id that was // passed to the request will be returned in |callback_id|, along with diff --git a/content/public/android/BUILD.gn b/content/public/android/BUILD.gn index f6095ce8edea9b..a883ba6e6da5a1 100644 --- a/content/public/android/BUILD.gn +++ b/content/public/android/BUILD.gn @@ -60,7 +60,6 @@ android_library("content_java") { "//third_party/WebKit/public:blink_headers_java", "//third_party/android_tools:android_support_annotations_java", "//third_party/jsr-305:jsr_305_javalib", - "//ui/accessibility:ui_accessibility_java", "//ui/android:ui_java", "//ui/gfx/geometry/mojo:mojo_java", ] diff --git a/content/public/browser/ax_event_notification_details.cc b/content/public/browser/ax_event_notification_details.cc index a06542cfecd83b..97dbc5ba3f8997 100644 --- a/content/public/browser/ax_event_notification_details.cc +++ b/content/public/browser/ax_event_notification_details.cc @@ -7,10 +7,10 @@ namespace content { AXEventNotificationDetails::AXEventNotificationDetails() - : event_type(ui::AX_EVENT_NONE), + : event_type(ax::mojom::Event::kNone), id(-1), ax_tree_id(-1), - event_from(ui::AX_EVENT_FROM_NONE), + event_from(ax::mojom::EventFrom::kNone), action_request_id(-1) {} AXEventNotificationDetails::AXEventNotificationDetails( diff --git a/content/public/browser/ax_event_notification_details.h b/content/public/browser/ax_event_notification_details.h index 8e94b475f20f76..6732cc3c0d5cbf 100644 --- a/content/public/browser/ax_event_notification_details.h +++ b/content/public/browser/ax_event_notification_details.h @@ -24,10 +24,10 @@ struct CONTENT_EXPORT AXEventNotificationDetails { ~AXEventNotificationDetails(); ui::AXTreeUpdate update; - ui::AXEvent event_type; + ax::mojom::Event event_type; int id; int ax_tree_id; - ui::AXEventFrom event_from; + ax::mojom::EventFrom event_from; int action_request_id; }; diff --git a/content/public/common/common_param_traits_macros.h b/content/public/common/common_param_traits_macros.h index a714130a50d837..b4fb17f3b499d4 100644 --- a/content/public/common/common_param_traits_macros.h +++ b/content/public/common/common_param_traits_macros.h @@ -255,18 +255,23 @@ IPC_STRUCT_TRAITS_BEGIN(blink::mojom::WindowFeatures) IPC_STRUCT_TRAITS_MEMBER(scrollbars_visible) IPC_STRUCT_TRAITS_END() -IPC_ENUM_TRAITS_MAX_VALUE(ui::AXEvent, ui::AX_EVENT_LAST) -IPC_ENUM_TRAITS_MAX_VALUE(ui::AXRole, ui::AX_ROLE_LAST) -IPC_ENUM_TRAITS_MAX_VALUE(ui::AXBoolAttribute, ui::AX_BOOL_ATTRIBUTE_LAST) -IPC_ENUM_TRAITS_MAX_VALUE(ui::AXFloatAttribute, ui::AX_FLOAT_ATTRIBUTE_LAST) -IPC_ENUM_TRAITS_MAX_VALUE(ui::AXIntAttribute, ui::AX_INT_ATTRIBUTE_LAST) -IPC_ENUM_TRAITS_MAX_VALUE(ui::AXIntListAttribute, - ui::AX_INT_LIST_ATTRIBUTE_LAST) -IPC_ENUM_TRAITS_MAX_VALUE(ui::AXStringListAttribute, - ui::AX_STRING_LIST_ATTRIBUTE_LAST) -IPC_ENUM_TRAITS_MAX_VALUE(ui::AXStringAttribute, ui::AX_STRING_ATTRIBUTE_LAST) -IPC_ENUM_TRAITS_MAX_VALUE(ui::AXTextAffinity, ui::AX_TEXT_AFFINITY_LAST) -IPC_ENUM_TRAITS_MAX_VALUE(ui::AXEventFrom, ui::AX_EVENT_FROM_LAST) +IPC_ENUM_TRAITS_MAX_VALUE(ax::mojom::Event, ax::mojom::Event::kLast) +IPC_ENUM_TRAITS_MAX_VALUE(ax::mojom::Role, ax::mojom::Role::kLast) +IPC_ENUM_TRAITS_MAX_VALUE(ax::mojom::BoolAttribute, + ax::mojom::BoolAttribute::kLast) +IPC_ENUM_TRAITS_MAX_VALUE(ax::mojom::FloatAttribute, + ax::mojom::FloatAttribute::kLast) +IPC_ENUM_TRAITS_MAX_VALUE(ax::mojom::IntAttribute, + ax::mojom::IntAttribute::kLast) +IPC_ENUM_TRAITS_MAX_VALUE(ax::mojom::IntListAttribute, + ax::mojom::IntListAttribute::kLast) +IPC_ENUM_TRAITS_MAX_VALUE(ax::mojom::StringListAttribute, + ax::mojom::StringListAttribute::kLast) +IPC_ENUM_TRAITS_MAX_VALUE(ax::mojom::StringAttribute, + ax::mojom::StringAttribute::kLast) +IPC_ENUM_TRAITS_MAX_VALUE(ax::mojom::TextAffinity, + ax::mojom::TextAffinity::kLast) +IPC_ENUM_TRAITS_MAX_VALUE(ax::mojom::EventFrom, ax::mojom::EventFrom::kLast) IPC_STRUCT_TRAITS_BEGIN(ui::AXRelativeBounds) IPC_STRUCT_TRAITS_MEMBER(offset_container_id) diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc index 8199a9188bf030..d1c45c40aa92c1 100644 --- a/content/public/test/browser_test_utils.cc +++ b/content/public/test/browser_test_utils.cc @@ -1375,7 +1375,7 @@ ui::AXNodeData GetFocusedAccessibilityNodeInfo(WebContents* web_contents) { bool AccessibilityTreeContainsNodeWithName(BrowserAccessibility* node, const std::string& name) { - if (node->GetStringAttribute(ui::AX_ATTR_NAME) == name) + if (node->GetStringAttribute(ax::mojom::StringAttribute::kName) == name) return true; for (unsigned i = 0; i < node->PlatformChildCount(); i++) { if (AccessibilityTreeContainsNodeWithName(node->PlatformGetChild(i), name)) @@ -1403,8 +1403,8 @@ void WaitForAccessibilityTreeToContainNodeWithName(WebContents* web_contents, FrameTree* frame_tree = web_contents_impl->GetFrameTree(); while (!main_frame_manager || !AccessibilityTreeContainsNodeWithName( main_frame_manager->GetRoot(), name)) { - AccessibilityNotificationWaiter accessibility_waiter(main_frame, - ui::AX_EVENT_NONE); + AccessibilityNotificationWaiter accessibility_waiter( + main_frame, ax::mojom::Event::kNone); for (FrameTreeNode* node : frame_tree->Nodes()) { accessibility_waiter.ListenToAdditionalFrame( node->current_frame_host()); diff --git a/content/renderer/accessibility/aom_content_ax_tree.cc b/content/renderer/accessibility/aom_content_ax_tree.cc index 021bdfcb7ed2b5..6eced2e665612c 100644 --- a/content/renderer/accessibility/aom_content_ax_tree.cc +++ b/content/renderer/accessibility/aom_content_ax_tree.cc @@ -6,7 +6,8 @@ #include "content/common/ax_content_node_data.h" #include "content/renderer/accessibility/render_accessibility_impl.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enum_util.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_node.h" namespace content { @@ -35,8 +36,8 @@ bool AomContentAxTree::ComputeAccessibilityTree() { blink::WebString AomContentAxTree::GetNameForAXNode(int32_t axID) { ui::AXNode* node = tree_.GetFromId(axID); - return (node) ? blink::WebString::FromUTF8( - node->data().GetStringAttribute(ui::AX_ATTR_NAME)) + return (node) ? blink::WebString::FromUTF8(node->data().GetStringAttribute( + ax::mojom::StringAttribute::kName)) : blink::WebString(); } diff --git a/content/renderer/accessibility/blink_ax_enum_conversion.cc b/content/renderer/accessibility/blink_ax_enum_conversion.cc index 1f81e9519788f7..268e803f86c7df 100644 --- a/content/renderer/accessibility/blink_ax_enum_conversion.cc +++ b/content/renderer/accessibility/blink_ax_enum_conversion.cc @@ -12,573 +12,580 @@ void AXStateFromBlink(const blink::WebAXObject& o, ui::AXNodeData* dst) { blink::WebAXExpanded expanded = o.IsExpanded(); if (expanded) { if (expanded == blink::kWebAXExpandedCollapsed) - dst->AddState(ui::AX_STATE_COLLAPSED); + dst->AddState(ax::mojom::State::kCollapsed); else if (expanded == blink::kWebAXExpandedExpanded) - dst->AddState(ui::AX_STATE_EXPANDED); + dst->AddState(ax::mojom::State::kExpanded); } if (o.CanSetFocusAttribute()) - dst->AddState(ui::AX_STATE_FOCUSABLE); + dst->AddState(ax::mojom::State::kFocusable); if (o.Role() == blink::kWebAXRolePopUpButton || o.AriaHasPopup()) - dst->AddState(ui::AX_STATE_HASPOPUP); + dst->AddState(ax::mojom::State::kHaspopup); if (o.IsHovered()) - dst->AddState(ui::AX_STATE_HOVERED); + dst->AddState(ax::mojom::State::kHovered); if (!o.IsVisible()) - dst->AddState(ui::AX_STATE_INVISIBLE); + dst->AddState(ax::mojom::State::kInvisible); if (o.IsLinked()) - dst->AddState(ui::AX_STATE_LINKED); + dst->AddState(ax::mojom::State::kLinked); if (o.IsMultiline()) - dst->AddState(ui::AX_STATE_MULTILINE); + dst->AddState(ax::mojom::State::kMultiline); if (o.IsMultiSelectable()) - dst->AddState(ui::AX_STATE_MULTISELECTABLE); + dst->AddState(ax::mojom::State::kMultiselectable); if (o.IsPasswordField()) - dst->AddState(ui::AX_STATE_PROTECTED); + dst->AddState(ax::mojom::State::kProtected); if (o.IsRequired()) - dst->AddState(ui::AX_STATE_REQUIRED); + dst->AddState(ax::mojom::State::kRequired); if (o.IsSelected() != blink::kWebAXSelectedStateUndefined) - dst->AddState(ui::AX_STATE_SELECTABLE); + dst->AddState(ax::mojom::State::kSelectable); if (o.IsEditable()) - dst->AddState(ui::AX_STATE_EDITABLE); + dst->AddState(ax::mojom::State::kEditable); if (o.IsSelected() == blink::kWebAXSelectedStateTrue) - dst->AddState(ui::AX_STATE_SELECTED); + dst->AddState(ax::mojom::State::kSelected); if (o.IsRichlyEditable()) - dst->AddState(ui::AX_STATE_RICHLY_EDITABLE); + dst->AddState(ax::mojom::State::kRichlyEditable); if (o.IsVisited()) - dst->AddState(ui::AX_STATE_VISITED); + dst->AddState(ax::mojom::State::kVisited); if (o.Orientation() == blink::kWebAXOrientationVertical) - dst->AddState(ui::AX_STATE_VERTICAL); + dst->AddState(ax::mojom::State::kVertical); else if (o.Orientation() == blink::kWebAXOrientationHorizontal) - dst->AddState(ui::AX_STATE_HORIZONTAL); + dst->AddState(ax::mojom::State::kHorizontal); if (o.IsVisited()) - dst->AddState(ui::AX_STATE_VISITED); + dst->AddState(ax::mojom::State::kVisited); } -ui::AXRole AXRoleFromBlink(blink::WebAXRole role) { +ax::mojom::Role AXRoleFromBlink(blink::WebAXRole role) { switch (role) { case blink::kWebAXRoleAbbr: - return ui::AX_ROLE_ABBR; + return ax::mojom::Role::kAbbr; case blink::kWebAXRoleAlert: - return ui::AX_ROLE_ALERT; + return ax::mojom::Role::kAlert; case blink::kWebAXRoleAlertDialog: - return ui::AX_ROLE_ALERT_DIALOG; + return ax::mojom::Role::kAlertDialog; case blink::kWebAXRoleAnchor: - return ui::AX_ROLE_ANCHOR; + return ax::mojom::Role::kAnchor; case blink::kWebAXRoleAnnotation: - return ui::AX_ROLE_ANNOTATION; + return ax::mojom::Role::kAnnotation; case blink::kWebAXRoleApplication: - return ui::AX_ROLE_APPLICATION; + return ax::mojom::Role::kApplication; case blink::kWebAXRoleArticle: - return ui::AX_ROLE_ARTICLE; + return ax::mojom::Role::kArticle; case blink::kWebAXRoleAudio: - return ui::AX_ROLE_AUDIO; + return ax::mojom::Role::kAudio; case blink::kWebAXRoleBanner: - return ui::AX_ROLE_BANNER; + return ax::mojom::Role::kBanner; case blink::kWebAXRoleBlockquote: - return ui::AX_ROLE_BLOCKQUOTE; + return ax::mojom::Role::kBlockquote; case blink::kWebAXRoleButton: - return ui::AX_ROLE_BUTTON; + return ax::mojom::Role::kButton; case blink::kWebAXRoleCanvas: - return ui::AX_ROLE_CANVAS; + return ax::mojom::Role::kCanvas; case blink::kWebAXRoleCaption: - return ui::AX_ROLE_CAPTION; + return ax::mojom::Role::kCaption; case blink::kWebAXRoleCell: - return ui::AX_ROLE_CELL; + return ax::mojom::Role::kCell; case blink::kWebAXRoleCheckBox: - return ui::AX_ROLE_CHECK_BOX; + return ax::mojom::Role::kCheckBox; case blink::kWebAXRoleColorWell: - return ui::AX_ROLE_COLOR_WELL; + return ax::mojom::Role::kColorWell; case blink::kWebAXRoleColumn: - return ui::AX_ROLE_COLUMN; + return ax::mojom::Role::kColumn; case blink::kWebAXRoleColumnHeader: - return ui::AX_ROLE_COLUMN_HEADER; + return ax::mojom::Role::kColumnHeader; case blink::kWebAXRoleComboBoxGrouping: - return ui::AX_ROLE_COMBO_BOX_GROUPING; + return ax::mojom::Role::kComboBoxGrouping; case blink::kWebAXRoleComboBoxMenuButton: - return ui::AX_ROLE_COMBO_BOX_MENU_BUTTON; + return ax::mojom::Role::kComboBoxMenuButton; case blink::kWebAXRoleComplementary: - return ui::AX_ROLE_COMPLEMENTARY; + return ax::mojom::Role::kComplementary; case blink::kWebAXRoleContentInfo: - return ui::AX_ROLE_CONTENT_INFO; + return ax::mojom::Role::kContentInfo; case blink::kWebAXRoleDate: - return ui::AX_ROLE_DATE; + return ax::mojom::Role::kDate; case blink::kWebAXRoleDateTime: - return ui::AX_ROLE_DATE_TIME; + return ax::mojom::Role::kDateTime; case blink::kWebAXRoleDefinition: - return ui::AX_ROLE_DEFINITION; + return ax::mojom::Role::kDefinition; case blink::kWebAXRoleDescriptionListDetail: - return ui::AX_ROLE_DESCRIPTION_LIST_DETAIL; + return ax::mojom::Role::kDescriptionListDetail; case blink::kWebAXRoleDescriptionList: - return ui::AX_ROLE_DESCRIPTION_LIST; + return ax::mojom::Role::kDescriptionList; case blink::kWebAXRoleDescriptionListTerm: - return ui::AX_ROLE_DESCRIPTION_LIST_TERM; + return ax::mojom::Role::kDescriptionListTerm; case blink::kWebAXRoleDetails: - return ui::AX_ROLE_DETAILS; + return ax::mojom::Role::kDetails; case blink::kWebAXRoleDialog: - return ui::AX_ROLE_DIALOG; + return ax::mojom::Role::kDialog; case blink::kWebAXRoleDirectory: - return ui::AX_ROLE_DIRECTORY; + return ax::mojom::Role::kDirectory; case blink::kWebAXRoleDisclosureTriangle: - return ui::AX_ROLE_DISCLOSURE_TRIANGLE; + return ax::mojom::Role::kDisclosureTriangle; case blink::kWebAXRoleDocument: - return ui::AX_ROLE_DOCUMENT; + return ax::mojom::Role::kDocument; case blink::kWebAXRoleEmbeddedObject: - return ui::AX_ROLE_EMBEDDED_OBJECT; + return ax::mojom::Role::kEmbeddedObject; case blink::kWebAXRoleFeed: - return ui::AX_ROLE_FEED; + return ax::mojom::Role::kFeed; case blink::kWebAXRoleFigcaption: - return ui::AX_ROLE_FIGCAPTION; + return ax::mojom::Role::kFigcaption; case blink::kWebAXRoleFigure: - return ui::AX_ROLE_FIGURE; + return ax::mojom::Role::kFigure; case blink::kWebAXRoleFooter: - return ui::AX_ROLE_FOOTER; + return ax::mojom::Role::kFooter; case blink::kWebAXRoleForm: - return ui::AX_ROLE_FORM; + return ax::mojom::Role::kForm; case blink::kWebAXRoleGenericContainer: - return ui::AX_ROLE_GENERIC_CONTAINER; + return ax::mojom::Role::kGenericContainer; case blink::kWebAXRoleGrid: - return ui::AX_ROLE_GRID; + return ax::mojom::Role::kGrid; case blink::kWebAXRoleGroup: - return ui::AX_ROLE_GROUP; + return ax::mojom::Role::kGroup; case blink::kWebAXRoleHeading: - return ui::AX_ROLE_HEADING; + return ax::mojom::Role::kHeading; case blink::kWebAXRoleIframe: - return ui::AX_ROLE_IFRAME; + return ax::mojom::Role::kIframe; case blink::kWebAXRoleIframePresentational: - return ui::AX_ROLE_IFRAME_PRESENTATIONAL; + return ax::mojom::Role::kIframePresentational; case blink::kWebAXRoleIgnored: - return ui::AX_ROLE_IGNORED; + return ax::mojom::Role::kIgnored; case blink::kWebAXRoleImage: - return ui::AX_ROLE_IMAGE; + return ax::mojom::Role::kImage; case blink::kWebAXRoleImageMap: - return ui::AX_ROLE_IMAGE_MAP; + return ax::mojom::Role::kImageMap; case blink::kWebAXRoleInlineTextBox: - return ui::AX_ROLE_INLINE_TEXT_BOX; + return ax::mojom::Role::kInlineTextBox; case blink::kWebAXRoleInputTime: - return ui::AX_ROLE_INPUT_TIME; + return ax::mojom::Role::kInputTime; case blink::kWebAXRoleLabel: - return ui::AX_ROLE_LABEL_TEXT; + return ax::mojom::Role::kLabelText; case blink::kWebAXRoleLegend: - return ui::AX_ROLE_LEGEND; + return ax::mojom::Role::kLegend; case blink::kWebAXRoleLink: - return ui::AX_ROLE_LINK; + return ax::mojom::Role::kLink; case blink::kWebAXRoleList: - return ui::AX_ROLE_LIST; + return ax::mojom::Role::kList; case blink::kWebAXRoleListBox: - return ui::AX_ROLE_LIST_BOX; + return ax::mojom::Role::kListBox; case blink::kWebAXRoleListBoxOption: - return ui::AX_ROLE_LIST_BOX_OPTION; + return ax::mojom::Role::kListBoxOption; case blink::kWebAXRoleListItem: - return ui::AX_ROLE_LIST_ITEM; + return ax::mojom::Role::kListItem; case blink::kWebAXRoleListMarker: - return ui::AX_ROLE_LIST_MARKER; + return ax::mojom::Role::kListMarker; case blink::kWebAXRoleLog: - return ui::AX_ROLE_LOG; + return ax::mojom::Role::kLog; case blink::kWebAXRoleMain: - return ui::AX_ROLE_MAIN; + return ax::mojom::Role::kMain; case blink::kWebAXRoleMarquee: - return ui::AX_ROLE_MARQUEE; + return ax::mojom::Role::kMarquee; case blink::kWebAXRoleMark: - return ui::AX_ROLE_MARK; + return ax::mojom::Role::kMark; case blink::kWebAXRoleMath: - return ui::AX_ROLE_MATH; + return ax::mojom::Role::kMath; case blink::kWebAXRoleMenu: - return ui::AX_ROLE_MENU; + return ax::mojom::Role::kMenu; case blink::kWebAXRoleMenuBar: - return ui::AX_ROLE_MENU_BAR; + return ax::mojom::Role::kMenuBar; case blink::kWebAXRoleMenuButton: - return ui::AX_ROLE_MENU_BUTTON; + return ax::mojom::Role::kMenuButton; case blink::kWebAXRoleMenuItem: - return ui::AX_ROLE_MENU_ITEM; + return ax::mojom::Role::kMenuItem; case blink::kWebAXRoleMenuItemCheckBox: - return ui::AX_ROLE_MENU_ITEM_CHECK_BOX; + return ax::mojom::Role::kMenuItemCheckBox; case blink::kWebAXRoleMenuItemRadio: - return ui::AX_ROLE_MENU_ITEM_RADIO; + return ax::mojom::Role::kMenuItemRadio; case blink::kWebAXRoleMenuListOption: - return ui::AX_ROLE_MENU_LIST_OPTION; + return ax::mojom::Role::kMenuListOption; case blink::kWebAXRoleMenuListPopup: - return ui::AX_ROLE_MENU_LIST_POPUP; + return ax::mojom::Role::kMenuListPopup; case blink::kWebAXRoleMeter: - return ui::AX_ROLE_METER; + return ax::mojom::Role::kMeter; case blink::kWebAXRoleNavigation: - return ui::AX_ROLE_NAVIGATION; + return ax::mojom::Role::kNavigation; case blink::kWebAXRoleNone: - return ui::AX_ROLE_NONE; + return ax::mojom::Role::kNone; case blink::kWebAXRoleNote: - return ui::AX_ROLE_NOTE; + return ax::mojom::Role::kNote; case blink::kWebAXRoleParagraph: - return ui::AX_ROLE_PARAGRAPH; + return ax::mojom::Role::kParagraph; case blink::kWebAXRolePopUpButton: - return ui::AX_ROLE_POP_UP_BUTTON; + return ax::mojom::Role::kPopUpButton; case blink::kWebAXRolePre: - return ui::AX_ROLE_PRE; + return ax::mojom::Role::kPre; case blink::kWebAXRolePresentational: - return ui::AX_ROLE_PRESENTATIONAL; + return ax::mojom::Role::kPresentational; case blink::kWebAXRoleProgressIndicator: - return ui::AX_ROLE_PROGRESS_INDICATOR; + return ax::mojom::Role::kProgressIndicator; case blink::kWebAXRoleRadioButton: - return ui::AX_ROLE_RADIO_BUTTON; + return ax::mojom::Role::kRadioButton; case blink::kWebAXRoleRadioGroup: - return ui::AX_ROLE_RADIO_GROUP; + return ax::mojom::Role::kRadioGroup; case blink::kWebAXRoleRegion: - return ui::AX_ROLE_REGION; + return ax::mojom::Role::kRegion; case blink::kWebAXRoleRow: - return ui::AX_ROLE_ROW; + return ax::mojom::Role::kRow; case blink::kWebAXRoleRuby: - return ui::AX_ROLE_RUBY; + return ax::mojom::Role::kRuby; case blink::kWebAXRoleRowHeader: - return ui::AX_ROLE_ROW_HEADER; + return ax::mojom::Role::kRowHeader; case blink::kWebAXRoleSVGRoot: - return ui::AX_ROLE_SVG_ROOT; + return ax::mojom::Role::kSvgRoot; case blink::kWebAXRoleScrollBar: - return ui::AX_ROLE_SCROLL_BAR; + return ax::mojom::Role::kScrollBar; case blink::kWebAXRoleSearch: - return ui::AX_ROLE_SEARCH; + return ax::mojom::Role::kSearch; case blink::kWebAXRoleSearchBox: - return ui::AX_ROLE_SEARCH_BOX; + return ax::mojom::Role::kSearchBox; case blink::kWebAXRoleSlider: - return ui::AX_ROLE_SLIDER; + return ax::mojom::Role::kSlider; case blink::kWebAXRoleSliderThumb: - return ui::AX_ROLE_SLIDER_THUMB; + return ax::mojom::Role::kSliderThumb; case blink::kWebAXRoleSpinButton: - return ui::AX_ROLE_SPIN_BUTTON; + return ax::mojom::Role::kSpinButton; case blink::kWebAXRoleSpinButtonPart: - return ui::AX_ROLE_SPIN_BUTTON_PART; + return ax::mojom::Role::kSpinButtonPart; case blink::kWebAXRoleSplitter: - return ui::AX_ROLE_SPLITTER; + return ax::mojom::Role::kSplitter; case blink::kWebAXRoleStaticText: - return ui::AX_ROLE_STATIC_TEXT; + return ax::mojom::Role::kStaticText; case blink::kWebAXRoleStatus: - return ui::AX_ROLE_STATUS; + return ax::mojom::Role::kStatus; case blink::kWebAXRoleSwitch: - return ui::AX_ROLE_SWITCH; + return ax::mojom::Role::kSwitch; case blink::kWebAXRoleTab: - return ui::AX_ROLE_TAB; + return ax::mojom::Role::kTab; case blink::kWebAXRoleTabList: - return ui::AX_ROLE_TAB_LIST; + return ax::mojom::Role::kTabList; case blink::kWebAXRoleTabPanel: - return ui::AX_ROLE_TAB_PANEL; + return ax::mojom::Role::kTabPanel; case blink::kWebAXRoleTable: - return ui::AX_ROLE_TABLE; + return ax::mojom::Role::kTable; case blink::kWebAXRoleTableHeaderContainer: - return ui::AX_ROLE_TABLE_HEADER_CONTAINER; + return ax::mojom::Role::kTableHeaderContainer; case blink::kWebAXRoleTerm: - return ui::AX_ROLE_TERM; + return ax::mojom::Role::kTerm; case blink::kWebAXRoleTextField: - return ui::AX_ROLE_TEXT_FIELD; + return ax::mojom::Role::kTextField; case blink::kWebAXRoleTextFieldWithComboBox: - return ui::AX_ROLE_TEXT_FIELD_WITH_COMBO_BOX; + return ax::mojom::Role::kTextFieldWithComboBox; case blink::kWebAXRoleTime: - return ui::AX_ROLE_TIME; + return ax::mojom::Role::kTime; case blink::kWebAXRoleTimer: - return ui::AX_ROLE_TIMER; + return ax::mojom::Role::kTimer; case blink::kWebAXRoleToggleButton: - return ui::AX_ROLE_TOGGLE_BUTTON; + return ax::mojom::Role::kToggleButton; case blink::kWebAXRoleToolbar: - return ui::AX_ROLE_TOOLBAR; + return ax::mojom::Role::kToolbar; case blink::kWebAXRoleTree: - return ui::AX_ROLE_TREE; + return ax::mojom::Role::kTree; case blink::kWebAXRoleTreeGrid: - return ui::AX_ROLE_TREE_GRID; + return ax::mojom::Role::kTreeGrid; case blink::kWebAXRoleTreeItem: - return ui::AX_ROLE_TREE_ITEM; + return ax::mojom::Role::kTreeItem; case blink::kWebAXRoleUnknown: - return ui::AX_ROLE_UNKNOWN; + return ax::mojom::Role::kUnknown; case blink::kWebAXRoleUserInterfaceTooltip: - return ui::AX_ROLE_TOOLTIP; + return ax::mojom::Role::kTooltip; case blink::kWebAXRoleVideo: - return ui::AX_ROLE_VIDEO; + return ax::mojom::Role::kVideo; case blink::kWebAXRoleWebArea: - return ui::AX_ROLE_ROOT_WEB_AREA; + return ax::mojom::Role::kRootWebArea; case blink::kWebAXRoleLineBreak: - return ui::AX_ROLE_LINE_BREAK; + return ax::mojom::Role::kLineBreak; default: - return ui::AX_ROLE_UNKNOWN; + return ax::mojom::Role::kUnknown; } } -ui::AXEvent AXEventFromBlink(blink::WebAXEvent event) { +ax::mojom::Event AXEventFromBlink(blink::WebAXEvent event) { switch (event) { case blink::kWebAXEventActiveDescendantChanged: - return ui::AX_EVENT_ACTIVEDESCENDANTCHANGED; + return ax::mojom::Event::kActiveDescendantChanged; case blink::kWebAXEventAriaAttributeChanged: - return ui::AX_EVENT_ARIA_ATTRIBUTE_CHANGED; + return ax::mojom::Event::kAriaAttributeChanged; case blink::kWebAXEventAutocorrectionOccured: - return ui::AX_EVENT_AUTOCORRECTION_OCCURED; + return ax::mojom::Event::kAutocorrectionOccured; case blink::kWebAXEventBlur: - return ui::AX_EVENT_BLUR; + return ax::mojom::Event::kBlur; case blink::kWebAXEventCheckedStateChanged: - return ui::AX_EVENT_CHECKED_STATE_CHANGED; + return ax::mojom::Event::kCheckedStateChanged; case blink::kWebAXEventChildrenChanged: - return ui::AX_EVENT_CHILDREN_CHANGED; + return ax::mojom::Event::kChildrenChanged; case blink::kWebAXEventClicked: - return ui::AX_EVENT_CLICKED; + return ax::mojom::Event::kClicked; case blink::kWebAXEventDocumentSelectionChanged: - return ui::AX_EVENT_DOCUMENT_SELECTION_CHANGED; + return ax::mojom::Event::kDocumentSelectionChanged; case blink::kWebAXEventExpandedChanged: - return ui::AX_EVENT_EXPANDED_CHANGED; + return ax::mojom::Event::kExpandedChanged; case blink::kWebAXEventFocus: - return ui::AX_EVENT_FOCUS; + return ax::mojom::Event::kFocus; case blink::kWebAXEventHover: - return ui::AX_EVENT_HOVER; + return ax::mojom::Event::kHover; case blink::kWebAXEventInvalidStatusChanged: - return ui::AX_EVENT_INVALID_STATUS_CHANGED; + return ax::mojom::Event::kInvalidStatusChanged; case blink::kWebAXEventLayoutComplete: - return ui::AX_EVENT_LAYOUT_COMPLETE; + return ax::mojom::Event::kLayoutComplete; case blink::kWebAXEventLiveRegionChanged: - return ui::AX_EVENT_LIVE_REGION_CHANGED; + return ax::mojom::Event::kLiveRegionChanged; case blink::kWebAXEventLoadComplete: - return ui::AX_EVENT_LOAD_COMPLETE; + return ax::mojom::Event::kLoadComplete; case blink::kWebAXEventLocationChanged: - return ui::AX_EVENT_LOCATION_CHANGED; + return ax::mojom::Event::kLocationChanged; case blink::kWebAXEventMenuListItemSelected: - return ui::AX_EVENT_MENU_LIST_ITEM_SELECTED; + return ax::mojom::Event::kMenuListItemSelected; case blink::kWebAXEventMenuListItemUnselected: - return ui::AX_EVENT_MENU_LIST_ITEM_SELECTED; + return ax::mojom::Event::kMenuListItemSelected; case blink::kWebAXEventMenuListValueChanged: - return ui::AX_EVENT_MENU_LIST_VALUE_CHANGED; + return ax::mojom::Event::kMenuListValueChanged; case blink::kWebAXEventRowCollapsed: - return ui::AX_EVENT_ROW_COLLAPSED; + return ax::mojom::Event::kRowCollapsed; case blink::kWebAXEventRowCountChanged: - return ui::AX_EVENT_ROW_COUNT_CHANGED; + return ax::mojom::Event::kRowCountChanged; case blink::kWebAXEventRowExpanded: - return ui::AX_EVENT_ROW_EXPANDED; + return ax::mojom::Event::kRowExpanded; case blink::kWebAXEventScrollPositionChanged: - return ui::AX_EVENT_SCROLL_POSITION_CHANGED; + return ax::mojom::Event::kScrollPositionChanged; case blink::kWebAXEventScrolledToAnchor: - return ui::AX_EVENT_SCROLLED_TO_ANCHOR; + return ax::mojom::Event::kScrolledToAnchor; case blink::kWebAXEventSelectedChildrenChanged: - return ui::AX_EVENT_SELECTED_CHILDREN_CHANGED; + return ax::mojom::Event::kSelectedChildrenChanged; case blink::kWebAXEventSelectedTextChanged: - return ui::AX_EVENT_TEXT_SELECTION_CHANGED; + return ax::mojom::Event::kTextSelectionChanged; case blink::kWebAXEventTextChanged: - return ui::AX_EVENT_TEXT_CHANGED; + return ax::mojom::Event::kTextChanged; case blink::kWebAXEventValueChanged: - return ui::AX_EVENT_VALUE_CHANGED; + return ax::mojom::Event::kValueChanged; default: // We can't add an assertion here, that prevents us // from adding new event enums in Blink. - return ui::AX_EVENT_NONE; + return ax::mojom::Event::kNone; } } -ui::AXDefaultActionVerb AXDefaultActionVerbFromBlink( +ax::mojom::DefaultActionVerb AXDefaultActionVerbFromBlink( blink::WebAXDefaultActionVerb action_verb) { switch (action_verb) { case blink::WebAXDefaultActionVerb::kNone: - return ui::AX_DEFAULT_ACTION_VERB_NONE; + return ax::mojom::DefaultActionVerb::kNone; case blink::WebAXDefaultActionVerb::kActivate: - return ui::AX_DEFAULT_ACTION_VERB_ACTIVATE; + return ax::mojom::DefaultActionVerb::kActivate; case blink::WebAXDefaultActionVerb::kCheck: - return ui::AX_DEFAULT_ACTION_VERB_CHECK; + return ax::mojom::DefaultActionVerb::kCheck; case blink::WebAXDefaultActionVerb::kClick: - return ui::AX_DEFAULT_ACTION_VERB_CLICK; + return ax::mojom::DefaultActionVerb::kClick; case blink::WebAXDefaultActionVerb::kClickAncestor: - return ui::AX_DEFAULT_ACTION_VERB_CLICK_ANCESTOR; + return ax::mojom::DefaultActionVerb::kClickAncestor; case blink::WebAXDefaultActionVerb::kJump: - return ui::AX_DEFAULT_ACTION_VERB_JUMP; + return ax::mojom::DefaultActionVerb::kJump; case blink::WebAXDefaultActionVerb::kOpen: - return ui::AX_DEFAULT_ACTION_VERB_OPEN; + return ax::mojom::DefaultActionVerb::kOpen; case blink::WebAXDefaultActionVerb::kPress: - return ui::AX_DEFAULT_ACTION_VERB_PRESS; + return ax::mojom::DefaultActionVerb::kPress; case blink::WebAXDefaultActionVerb::kSelect: - return ui::AX_DEFAULT_ACTION_VERB_SELECT; + return ax::mojom::DefaultActionVerb::kSelect; case blink::WebAXDefaultActionVerb::kUncheck: - return ui::AX_DEFAULT_ACTION_VERB_UNCHECK; + return ax::mojom::DefaultActionVerb::kUncheck; } NOTREACHED(); - return ui::AX_DEFAULT_ACTION_VERB_NONE; + return ax::mojom::DefaultActionVerb::kNone; } -ui::AXMarkerType AXMarkerTypeFromBlink(blink::WebAXMarkerType marker_type) { +ax::mojom::MarkerType AXMarkerTypeFromBlink( + blink::WebAXMarkerType marker_type) { switch (marker_type) { case blink::kWebAXMarkerTypeSpelling: - return ui::AX_MARKER_TYPE_SPELLING; + return ax::mojom::MarkerType::kSpelling; case blink::kWebAXMarkerTypeGrammar: - return ui::AX_MARKER_TYPE_GRAMMAR; + return ax::mojom::MarkerType::kGrammar; case blink::kWebAXMarkerTypeTextMatch: - return ui::AX_MARKER_TYPE_TEXT_MATCH; + return ax::mojom::MarkerType::kTextMatch; case blink::kWebAXMarkerTypeActiveSuggestion: - return ui::AX_MARKER_TYPE_ACTIVE_SUGGESTION; + return ax::mojom::MarkerType::kActiveSuggestion; case blink::kWebAXMarkerTypeSuggestion: - return ui::AX_MARKER_TYPE_SUGGESTION; + return ax::mojom::MarkerType::kSuggestion; } NOTREACHED(); - return ui::AX_MARKER_TYPE_NONE; + return ax::mojom::MarkerType::kNone; } -ui::AXTextDirection AXTextDirectionFromBlink( +ax::mojom::TextDirection AXTextDirectionFromBlink( blink::WebAXTextDirection text_direction) { switch (text_direction) { case blink::kWebAXTextDirectionLR: - return ui::AX_TEXT_DIRECTION_LTR; + return ax::mojom::TextDirection::kLtr; case blink::kWebAXTextDirectionRL: - return ui::AX_TEXT_DIRECTION_RTL; + return ax::mojom::TextDirection::kRtl; case blink::kWebAXTextDirectionTB: - return ui::AX_TEXT_DIRECTION_TTB; + return ax::mojom::TextDirection::kTtb; case blink::kWebAXTextDirectionBT: - return ui::AX_TEXT_DIRECTION_BTT; + return ax::mojom::TextDirection::kBtt; } NOTREACHED(); - return ui::AX_TEXT_DIRECTION_NONE; + return ax::mojom::TextDirection::kNone; } -ui::AXTextStyle AXTextStyleFromBlink(blink::WebAXTextStyle text_style) { - uint32_t browser_text_style = static_cast(ui::AX_TEXT_STYLE_NONE); +ax::mojom::TextStyle AXTextStyleFromBlink(blink::WebAXTextStyle text_style) { + uint32_t browser_text_style = + static_cast(ax::mojom::TextStyle::kNone); if (text_style & blink::kWebAXTextStyleBold) - browser_text_style |= static_cast(ui::AX_TEXT_STYLE_BOLD); + browser_text_style |= + static_cast(ax::mojom::TextStyle::kTextStyleBold); if (text_style & blink::kWebAXTextStyleItalic) - browser_text_style |= static_cast(ui::AX_TEXT_STYLE_ITALIC); + browser_text_style |= + static_cast(ax::mojom::TextStyle::kTextStyleItalic); if (text_style & blink::kWebAXTextStyleUnderline) - browser_text_style |= static_cast(ui::AX_TEXT_STYLE_UNDERLINE); + browser_text_style |= + static_cast(ax::mojom::TextStyle::kTextStyleUnderline); if (text_style & blink::kWebAXTextStyleLineThrough) - browser_text_style |= static_cast(ui::AX_TEXT_STYLE_LINE_THROUGH); - return static_cast(browser_text_style); + browser_text_style |= + static_cast(ax::mojom::TextStyle::kTextStyleLineThrough); + return static_cast(browser_text_style); } -ui::AXAriaCurrentState AXAriaCurrentStateFromBlink( +ax::mojom::AriaCurrentState AXAriaCurrentStateFromBlink( blink::WebAXAriaCurrentState aria_current_state) { switch (aria_current_state) { case blink::kWebAXAriaCurrentStateUndefined: - return ui::AX_ARIA_CURRENT_STATE_NONE; + return ax::mojom::AriaCurrentState::kNone; case blink::kWebAXAriaCurrentStateFalse: - return ui::AX_ARIA_CURRENT_STATE_FALSE; + return ax::mojom::AriaCurrentState::kFalse; case blink::kWebAXAriaCurrentStateTrue: - return ui::AX_ARIA_CURRENT_STATE_TRUE; + return ax::mojom::AriaCurrentState::kTrue; case blink::kWebAXAriaCurrentStatePage: - return ui::AX_ARIA_CURRENT_STATE_PAGE; + return ax::mojom::AriaCurrentState::kPage; case blink::kWebAXAriaCurrentStateStep: - return ui::AX_ARIA_CURRENT_STATE_STEP; + return ax::mojom::AriaCurrentState::kStep; case blink::kWebAXAriaCurrentStateLocation: - return ui::AX_ARIA_CURRENT_STATE_LOCATION; + return ax::mojom::AriaCurrentState::kLocation; case blink::kWebAXAriaCurrentStateDate: - return ui::AX_ARIA_CURRENT_STATE_DATE; + return ax::mojom::AriaCurrentState::kDate; case blink::kWebAXAriaCurrentStateTime: - return ui::AX_ARIA_CURRENT_STATE_TIME; + return ax::mojom::AriaCurrentState::kTime; } NOTREACHED(); - return ui::AX_ARIA_CURRENT_STATE_NONE; + return ax::mojom::AriaCurrentState::kNone; } -ui::AXInvalidState AXInvalidStateFromBlink( +ax::mojom::InvalidState AXInvalidStateFromBlink( blink::WebAXInvalidState invalid_state) { switch (invalid_state) { case blink::kWebAXInvalidStateUndefined: - return ui::AX_INVALID_STATE_NONE; + return ax::mojom::InvalidState::kNone; case blink::kWebAXInvalidStateFalse: - return ui::AX_INVALID_STATE_FALSE; + return ax::mojom::InvalidState::kFalse; case blink::kWebAXInvalidStateTrue: - return ui::AX_INVALID_STATE_TRUE; + return ax::mojom::InvalidState::kTrue; case blink::kWebAXInvalidStateSpelling: - return ui::AX_INVALID_STATE_SPELLING; + return ax::mojom::InvalidState::kSpelling; case blink::kWebAXInvalidStateGrammar: - return ui::AX_INVALID_STATE_GRAMMAR; + return ax::mojom::InvalidState::kGrammar; case blink::kWebAXInvalidStateOther: - return ui::AX_INVALID_STATE_OTHER; + return ax::mojom::InvalidState::kOther; } NOTREACHED(); - return ui::AX_INVALID_STATE_NONE; + return ax::mojom::InvalidState::kNone; } -ui::AXCheckedState AXCheckedStateFromBlink( +ax::mojom::CheckedState AXCheckedStateFromBlink( blink::WebAXCheckedState checked_state) { switch (checked_state) { case blink::kWebAXCheckedUndefined: - return ui::AX_CHECKED_STATE_NONE; + return ax::mojom::CheckedState::kNone; case blink::kWebAXCheckedTrue: - return ui::AX_CHECKED_STATE_TRUE; + return ax::mojom::CheckedState::kTrue; case blink::kWebAXCheckedMixed: - return ui::AX_CHECKED_STATE_MIXED; + return ax::mojom::CheckedState::kMixed; case blink::kWebAXCheckedFalse: - return ui::AX_CHECKED_STATE_FALSE; + return ax::mojom::CheckedState::kFalse; } NOTREACHED(); - return ui::AX_CHECKED_STATE_NONE; + return ax::mojom::CheckedState::kNone; } -ui::AXSortDirection AXSortDirectionFromBlink( +ax::mojom::SortDirection AXSortDirectionFromBlink( blink::WebAXSortDirection sort_direction) { switch (sort_direction) { case blink::kWebAXSortDirectionUndefined: - return ui::AX_SORT_DIRECTION_NONE; + return ax::mojom::SortDirection::kNone; case blink::kWebAXSortDirectionNone: - return ui::AX_SORT_DIRECTION_UNSORTED; + return ax::mojom::SortDirection::kUnsorted; case blink::kWebAXSortDirectionAscending: - return ui::AX_SORT_DIRECTION_ASCENDING; + return ax::mojom::SortDirection::kAscending; case blink::kWebAXSortDirectionDescending: - return ui::AX_SORT_DIRECTION_DESCENDING; + return ax::mojom::SortDirection::kDescending; case blink::kWebAXSortDirectionOther: - return ui::AX_SORT_DIRECTION_OTHER; + return ax::mojom::SortDirection::kOther; } NOTREACHED(); - return ui::AX_SORT_DIRECTION_NONE; + return ax::mojom::SortDirection::kNone; } -ui::AXNameFrom AXNameFromFromBlink(blink::WebAXNameFrom name_from) { +ax::mojom::NameFrom AXNameFromFromBlink(blink::WebAXNameFrom name_from) { switch (name_from) { case blink::kWebAXNameFromUninitialized: - return ui::AX_NAME_FROM_UNINITIALIZED; + return ax::mojom::NameFrom::kUninitialized; case blink::kWebAXNameFromAttribute: - return ui::AX_NAME_FROM_ATTRIBUTE; + return ax::mojom::NameFrom::kAttribute; case blink::kWebAXNameFromAttributeExplicitlyEmpty: - return ui::AX_NAME_FROM_ATTRIBUTE_EXPLICITLY_EMPTY; + return ax::mojom::NameFrom::kAttributeExplicitlyEmpty; case blink::kWebAXNameFromCaption: - return ui::AX_NAME_FROM_RELATED_ELEMENT; + return ax::mojom::NameFrom::kRelatedElement; case blink::kWebAXNameFromContents: - return ui::AX_NAME_FROM_CONTENTS; + return ax::mojom::NameFrom::kContents; case blink::kWebAXNameFromPlaceholder: - return ui::AX_NAME_FROM_PLACEHOLDER; + return ax::mojom::NameFrom::kPlaceholder; case blink::kWebAXNameFromRelatedElement: - return ui::AX_NAME_FROM_RELATED_ELEMENT; + return ax::mojom::NameFrom::kRelatedElement; case blink::kWebAXNameFromValue: - return ui::AX_NAME_FROM_VALUE; + return ax::mojom::NameFrom::kValue; case blink::kWebAXNameFromTitle: - return ui::AX_NAME_FROM_ATTRIBUTE; + return ax::mojom::NameFrom::kAttribute; } NOTREACHED(); - return ui::AX_NAME_FROM_NONE; + return ax::mojom::NameFrom::kNone; } -ui::AXDescriptionFrom AXDescriptionFromFromBlink( +ax::mojom::DescriptionFrom AXDescriptionFromFromBlink( blink::WebAXDescriptionFrom description_from) { switch (description_from) { case blink::kWebAXDescriptionFromUninitialized: - return ui::AX_DESCRIPTION_FROM_UNINITIALIZED; + return ax::mojom::DescriptionFrom::kUninitialized; case blink::kWebAXDescriptionFromAttribute: - return ui::AX_DESCRIPTION_FROM_ATTRIBUTE; + return ax::mojom::DescriptionFrom::kAttribute; case blink::kWebAXDescriptionFromContents: - return ui::AX_DESCRIPTION_FROM_CONTENTS; + return ax::mojom::DescriptionFrom::kContents; case blink::kWebAXDescriptionFromRelatedElement: - return ui::AX_DESCRIPTION_FROM_RELATED_ELEMENT; + return ax::mojom::DescriptionFrom::kRelatedElement; } NOTREACHED(); - return ui::AX_DESCRIPTION_FROM_NONE; + return ax::mojom::DescriptionFrom::kNone; } -ui::AXTextAffinity AXTextAffinityFromBlink(blink::WebAXTextAffinity affinity) { +ax::mojom::TextAffinity AXTextAffinityFromBlink( + blink::WebAXTextAffinity affinity) { switch (affinity) { case blink::kWebAXTextAffinityUpstream: - return ui::AX_TEXT_AFFINITY_UPSTREAM; + return ax::mojom::TextAffinity::kUpstream; case blink::kWebAXTextAffinityDownstream: - return ui::AX_TEXT_AFFINITY_DOWNSTREAM; + return ax::mojom::TextAffinity::kDownstream; } NOTREACHED(); - return ui::AX_TEXT_AFFINITY_DOWNSTREAM; + return ax::mojom::TextAffinity::kDownstream; } } // namespace content. diff --git a/content/renderer/accessibility/blink_ax_enum_conversion.h b/content/renderer/accessibility/blink_ax_enum_conversion.h index 02023719cdf900..61349c36e35ca5 100644 --- a/content/renderer/accessibility/blink_ax_enum_conversion.h +++ b/content/renderer/accessibility/blink_ax_enum_conversion.h @@ -8,16 +8,17 @@ #include #include "third_party/WebKit/public/web/WebAXObject.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_node_data.h" namespace content { -// Convert a Blink WebAXRole to an AXRole defined in ui/accessibility. -ui::AXRole AXRoleFromBlink(blink::WebAXRole role); +// Convert a Blink WebAXRole to an ax::mojom::Role defined in ui/accessibility. +ax::mojom::Role AXRoleFromBlink(blink::WebAXRole role); -// Convert a Blink WebAXEvent to an AXEvent defined in ui/accessibility. -ui::AXEvent AXEventFromBlink(blink::WebAXEvent event); +// Convert a Blink WebAXEvent to an ax::mojom::Event defined in +// ui/accessibility. +ax::mojom::Event AXEventFromBlink(blink::WebAXEvent event); // Provides a conversion between the WebAXObject state // accessors and a state bitmask stored in an AXNodeData. @@ -25,34 +26,35 @@ ui::AXEvent AXEventFromBlink(blink::WebAXEvent event); // in AXNodeData instead.) void AXStateFromBlink(const blink::WebAXObject& o, ui::AXNodeData* dst); -ui::AXDefaultActionVerb AXDefaultActionVerbFromBlink( +ax::mojom::DefaultActionVerb AXDefaultActionVerbFromBlink( blink::WebAXDefaultActionVerb action_verb); -ui::AXMarkerType AXMarkerTypeFromBlink(blink::WebAXMarkerType marker_type); +ax::mojom::MarkerType AXMarkerTypeFromBlink(blink::WebAXMarkerType marker_type); -ui::AXTextDirection AXTextDirectionFromBlink( +ax::mojom::TextDirection AXTextDirectionFromBlink( blink::WebAXTextDirection text_direction); -ui::AXTextStyle AXTextStyleFromBlink(blink::WebAXTextStyle text_style); +ax::mojom::TextStyle AXTextStyleFromBlink(blink::WebAXTextStyle text_style); -ui::AXAriaCurrentState AXAriaCurrentStateFromBlink( +ax::mojom::AriaCurrentState AXAriaCurrentStateFromBlink( blink::WebAXAriaCurrentState aria_current_state); -ui::AXInvalidState AXInvalidStateFromBlink( +ax::mojom::InvalidState AXInvalidStateFromBlink( blink::WebAXInvalidState invalid_state); -ui::AXCheckedState AXCheckedStateFromBlink( +ax::mojom::CheckedState AXCheckedStateFromBlink( blink::WebAXCheckedState checked_state); -ui::AXSortDirection AXSortDirectionFromBlink( +ax::mojom::SortDirection AXSortDirectionFromBlink( blink::WebAXSortDirection sort_direction); -ui::AXNameFrom AXNameFromFromBlink(blink::WebAXNameFrom name_from); +ax::mojom::NameFrom AXNameFromFromBlink(blink::WebAXNameFrom name_from); -ui::AXDescriptionFrom AXDescriptionFromFromBlink( +ax::mojom::DescriptionFrom AXDescriptionFromFromBlink( blink::WebAXDescriptionFrom description_from); -ui::AXTextAffinity AXTextAffinityFromBlink(blink::WebAXTextAffinity affinity); +ax::mojom::TextAffinity AXTextAffinityFromBlink( + blink::WebAXTextAffinity affinity); } // namespace content diff --git a/content/renderer/accessibility/blink_ax_tree_source.cc b/content/renderer/accessibility/blink_ax_tree_source.cc index fd58820091e5b9..326b5841a84e34 100644 --- a/content/renderer/accessibility/blink_ax_tree_source.cc +++ b/content/renderer/accessibility/blink_ax_tree_source.cc @@ -37,6 +37,7 @@ #include "third_party/WebKit/public/web/WebPlugin.h" #include "third_party/WebKit/public/web/WebPluginContainer.h" #include "third_party/WebKit/public/web/WebView.h" +#include "ui/accessibility/ax_enum_util.h" using base::ASCIIToUTF16; using base::UTF16ToUTF8; @@ -58,7 +59,7 @@ namespace content { namespace { -void AddIntListAttributeFromWebObjects(ui::AXIntListAttribute attr, +void AddIntListAttributeFromWebObjects(ax::mojom::IntListAttribute attr, const WebVector& objects, AXContentNodeData* dst) { std::vector ids; @@ -83,7 +84,7 @@ class AXContentNodeDataSparseAttributeAdapter bool value) override { switch (attribute) { case blink::WebAXBoolAttribute::kAriaBusy: - dst_->AddBoolAttribute(ui::AX_ATTR_BUSY, value); + dst_->AddBoolAttribute(ax::mojom::BoolAttribute::kBusy, value); break; default: NOTREACHED(); @@ -94,10 +95,12 @@ class AXContentNodeDataSparseAttributeAdapter const blink::WebString& value) override { switch (attribute) { case blink::WebAXStringAttribute::kAriaKeyShortcuts: - dst_->AddStringAttribute(ui::AX_ATTR_KEY_SHORTCUTS, value.Utf8()); + dst_->AddStringAttribute(ax::mojom::StringAttribute::kKeyShortcuts, + value.Utf8()); break; case blink::WebAXStringAttribute::kAriaRoleDescription: - dst_->AddStringAttribute(ui::AX_ATTR_ROLE_DESCRIPTION, value.Utf8()); + dst_->AddStringAttribute(ax::mojom::StringAttribute::kRoleDescription, + value.Utf8()); break; default: NOTREACHED(); @@ -112,10 +115,12 @@ class AXContentNodeDataSparseAttributeAdapter // more information than the sparse interface does. break; case WebAXObjectAttribute::kAriaDetails: - dst_->AddIntAttribute(ui::AX_ATTR_DETAILS_ID, value.AxID()); + dst_->AddIntAttribute(ax::mojom::IntAttribute::kDetailsId, + value.AxID()); break; case WebAXObjectAttribute::kAriaErrorMessage: - dst_->AddIntAttribute(ui::AX_ATTR_ERRORMESSAGE_ID, value.AxID()); + dst_->AddIntAttribute(ax::mojom::IntAttribute::kErrormessageId, + value.AxID()); break; default: NOTREACHED(); @@ -127,11 +132,12 @@ class AXContentNodeDataSparseAttributeAdapter const blink::WebVector& value) override { switch (attribute) { case WebAXObjectVectorAttribute::kAriaControls: - AddIntListAttributeFromWebObjects(ui::AX_ATTR_CONTROLS_IDS, value, - dst_); + AddIntListAttributeFromWebObjects( + ax::mojom::IntListAttribute::kControlsIds, value, dst_); break; case WebAXObjectVectorAttribute::kAriaFlowTo: - AddIntListAttributeFromWebObjects(ui::AX_ATTR_FLOWTO_IDS, value, dst_); + AddIntListAttributeFromWebObjects( + ax::mojom::IntListAttribute::kFlowtoIds, value, dst_); break; default: NOTREACHED(); @@ -156,35 +162,35 @@ bool IsParentUnignoredOf(WebAXObject ancestor, return parent.Equals(ancestor); } -std::string GetEquivalentAriaRoleString(const ui::AXRole role) { +std::string GetEquivalentAriaRoleString(const ax::mojom::Role role) { switch (role) { - case ui::AX_ROLE_ARTICLE: + case ax::mojom::Role::kArticle: return "article"; - case ui::AX_ROLE_BANNER: + case ax::mojom::Role::kBanner: return "banner"; - case ui::AX_ROLE_BUTTON: + case ax::mojom::Role::kButton: return "button"; - case ui::AX_ROLE_COMPLEMENTARY: + case ax::mojom::Role::kComplementary: return "complementary"; - case ui::AX_ROLE_FIGURE: + case ax::mojom::Role::kFigure: return "figure"; - case ui::AX_ROLE_FOOTER: + case ax::mojom::Role::kFooter: return "contentinfo"; - case ui::AX_ROLE_HEADING: + case ax::mojom::Role::kHeading: return "heading"; - case ui::AX_ROLE_IMAGE: + case ax::mojom::Role::kImage: return "img"; - case ui::AX_ROLE_MAIN: + case ax::mojom::Role::kMain: return "main"; - case ui::AX_ROLE_NAVIGATION: + case ax::mojom::Role::kNavigation: return "navigation"; - case ui::AX_ROLE_RADIO_BUTTON: + case ax::mojom::Role::kRadioButton: return "radio"; - case ui::AX_ROLE_REGION: + case ax::mojom::Role::kRegion: return "region"; - case ui::AX_ROLE_SLIDER: + case ax::mojom::Role::kSlider: return "slider"; - case ui::AX_ROLE_TIME: + case ax::mojom::Role::kTime: return "time"; default: break; @@ -440,7 +446,7 @@ void BlinkAXTreeSource::SerializeNode(WebAXObject src, if (!offset_container.IsDetached()) dst->offset_container_id = offset_container.AxID(); if (clips_children) - dst->AddBoolAttribute(ui::AX_ATTR_CLIPS_CHILDREN, true); + dst->AddBoolAttribute(ax::mojom::BoolAttribute::kClipsChildren, true); AXContentNodeDataSparseAttributeAdapter sparse_attribute_adapter(dst); src.GetSparseAXAttributes(sparse_attribute_adapter); @@ -450,10 +456,10 @@ void BlinkAXTreeSource::SerializeNode(WebAXObject src, blink::WebString web_name = src.GetName(nameFrom, nameObjects); if ((!web_name.IsEmpty() && !web_name.IsNull()) || nameFrom == blink::kWebAXNameFromAttributeExplicitlyEmpty) { - dst->AddStringAttribute(ui::AX_ATTR_NAME, web_name.Utf8()); + dst->AddStringAttribute(ax::mojom::StringAttribute::kName, web_name.Utf8()); dst->SetNameFrom(AXNameFromFromBlink(nameFrom)); AddIntListAttributeFromWebObjects( - ui::AX_ATTR_LABELLEDBY_IDS, nameObjects, dst); + ax::mojom::IntListAttribute::kLabelledbyIds, nameObjects, dst); } blink::WebAXDescriptionFrom descriptionFrom; @@ -461,35 +467,39 @@ void BlinkAXTreeSource::SerializeNode(WebAXObject src, blink::WebString web_description = src.Description(nameFrom, descriptionFrom, descriptionObjects); if (!web_description.IsEmpty()) { - dst->AddStringAttribute(ui::AX_ATTR_DESCRIPTION, web_description.Utf8()); + dst->AddStringAttribute(ax::mojom::StringAttribute::kDescription, + web_description.Utf8()); dst->AddIntAttribute( - ui::AX_ATTR_DESCRIPTION_FROM, + ax::mojom::IntAttribute::kDescriptionFrom, static_cast(AXDescriptionFromFromBlink(descriptionFrom))); AddIntListAttributeFromWebObjects( - ui::AX_ATTR_DESCRIBEDBY_IDS, descriptionObjects, dst); + ax::mojom::IntListAttribute::kDescribedbyIds, descriptionObjects, dst); } if (src.ValueDescription().length()) { - dst->AddStringAttribute(ui::AX_ATTR_VALUE, src.ValueDescription().Utf8()); + dst->AddStringAttribute(ax::mojom::StringAttribute::kValue, + src.ValueDescription().Utf8()); } else { - dst->AddStringAttribute(ui::AX_ATTR_VALUE, src.StringValue().Utf8()); + dst->AddStringAttribute(ax::mojom::StringAttribute::kValue, + src.StringValue().Utf8()); } switch (src.Restriction()) { case blink::kWebAXRestrictionReadOnly: - dst->SetRestriction(ui::AX_RESTRICTION_READ_ONLY); + dst->SetRestriction(ax::mojom::Restriction::kReadOnly); break; case blink::kWebAXRestrictionDisabled: - dst->SetRestriction(ui::AX_RESTRICTION_DISABLED); + dst->SetRestriction(ax::mojom::Restriction::kDisabled); break; case blink::kWebAXRestrictionNone: if (src.CanSetValueAttribute()) - dst->AddAction(ui::AX_ACTION_SET_VALUE); + dst->AddAction(ax::mojom::Action::kSetValue); break; } if (!src.Url().IsEmpty()) - dst->AddStringAttribute(ui::AX_ATTR_URL, src.Url().GetString().Utf8()); + dst->AddStringAttribute(ax::mojom::StringAttribute::kUrl, + src.Url().GetString().Utf8()); // The following set of attributes are only accessed when the accessibility // mode is set to screen reader mode, otherwise only the more basic @@ -497,44 +507,50 @@ void BlinkAXTreeSource::SerializeNode(WebAXObject src, if (accessibility_mode_.has_mode(ui::AXMode::kScreenReader)) { blink::WebString web_placeholder = src.Placeholder(nameFrom); if (!web_placeholder.IsEmpty()) - dst->AddStringAttribute(ui::AX_ATTR_PLACEHOLDER, web_placeholder.Utf8()); + dst->AddStringAttribute(ax::mojom::StringAttribute::kPlaceholder, + web_placeholder.Utf8()); - if (dst->role == ui::AX_ROLE_COLOR_WELL) - dst->AddIntAttribute(ui::AX_ATTR_COLOR_VALUE, src.ColorValue()); + if (dst->role == ax::mojom::Role::kColorWell) + dst->AddIntAttribute(ax::mojom::IntAttribute::kColorValue, + src.ColorValue()); - if (dst->role == ui::AX_ROLE_LINK) { + if (dst->role == ax::mojom::Role::kLink) { WebAXObject target = src.InPageLinkTarget(); if (!target.IsNull()) { int32_t target_id = target.AxID(); - dst->AddIntAttribute(ui::AX_ATTR_IN_PAGE_LINK_TARGET_ID, target_id); + dst->AddIntAttribute(ax::mojom::IntAttribute::kInPageLinkTargetId, + target_id); } } - if (dst->role == ui::AX_ROLE_RADIO_BUTTON) { - AddIntListAttributeFromWebObjects(ui::AX_ATTR_RADIO_GROUP_IDS, - src.RadioButtonsInGroup(), dst); + if (dst->role == ax::mojom::Role::kRadioButton) { + AddIntListAttributeFromWebObjects( + ax::mojom::IntListAttribute::kRadioGroupIds, + src.RadioButtonsInGroup(), dst); } // Text attributes. if (src.BackgroundColor()) - dst->AddIntAttribute(ui::AX_ATTR_BACKGROUND_COLOR, src.BackgroundColor()); + dst->AddIntAttribute(ax::mojom::IntAttribute::kBackgroundColor, + src.BackgroundColor()); if (src.GetColor()) - dst->AddIntAttribute(ui::AX_ATTR_COLOR, src.GetColor()); + dst->AddIntAttribute(ax::mojom::IntAttribute::kColor, src.GetColor()); WebAXObject parent = ParentObjectUnignored(src); if (src.FontFamily().length()) { if (parent.IsNull() || parent.FontFamily() != src.FontFamily()) - dst->AddStringAttribute(ui::AX_ATTR_FONT_FAMILY, + dst->AddStringAttribute(ax::mojom::StringAttribute::kFontFamily, src.FontFamily().Utf8()); } // Font size is in pixels. if (src.FontSize()) - dst->AddFloatAttribute(ui::AX_ATTR_FONT_SIZE, src.FontSize()); + dst->AddFloatAttribute(ax::mojom::FloatAttribute::kFontSize, + src.FontSize()); if (src.AriaCurrentState()) { - dst->AddIntAttribute(ui::AX_ATTR_ARIA_CURRENT_STATE, + dst->AddIntAttribute(ax::mojom::IntAttribute::kAriaCurrentState, static_cast(AXAriaCurrentStateFromBlink( src.AriaCurrentState()))); } @@ -544,7 +560,7 @@ void BlinkAXTreeSource::SerializeNode(WebAXObject src, } if (src.InvalidState() == blink::kWebAXInvalidStateOther && src.AriaInvalidValue().length()) { - dst->AddStringAttribute(ui::AX_ATTR_ARIA_INVALID_VALUE, + dst->AddStringAttribute(ax::mojom::StringAttribute::kAriaInvalidValue, src.AriaInvalidValue().Utf8()); } @@ -558,18 +574,18 @@ void BlinkAXTreeSource::SerializeNode(WebAXObject src, if (src.TextStyle()) { dst->AddIntAttribute( - ui::AX_ATTR_TEXT_STYLE, + ax::mojom::IntAttribute::kTextStyle, static_cast(AXTextStyleFromBlink(src.TextStyle()))); } - if (dst->role == ui::AX_ROLE_INLINE_TEXT_BOX) { + if (dst->role == ax::mojom::Role::kInlineTextBox) { WebVector src_character_offsets; src.CharacterOffsets(src_character_offsets); std::vector character_offsets; character_offsets.reserve(src_character_offsets.size()); for (size_t i = 0; i < src_character_offsets.size(); ++i) character_offsets.push_back(src_character_offsets[i]); - dst->AddIntListAttribute(ui::AX_ATTR_CHARACTER_OFFSETS, + dst->AddIntListAttribute(ax::mojom::IntListAttribute::kCharacterOffsets, character_offsets); WebVector src_word_starts; @@ -583,16 +599,19 @@ void BlinkAXTreeSource::SerializeNode(WebAXObject src, word_starts.push_back(src_word_starts[i]); word_ends.push_back(src_word_ends[i]); } - dst->AddIntListAttribute(ui::AX_ATTR_WORD_STARTS, word_starts); - dst->AddIntListAttribute(ui::AX_ATTR_WORD_ENDS, word_ends); + dst->AddIntListAttribute(ax::mojom::IntListAttribute::kWordStarts, + word_starts); + dst->AddIntListAttribute(ax::mojom::IntListAttribute::kWordEnds, + word_ends); } if (src.AccessKey().length()) { - dst->AddStringAttribute(ui::AX_ATTR_ACCESS_KEY, src.AccessKey().Utf8()); + dst->AddStringAttribute(ax::mojom::StringAttribute::kAccessKey, + src.AccessKey().Utf8()); } if (src.AriaAutoComplete().length()) { - dst->AddStringAttribute(ui::AX_ATTR_AUTO_COMPLETE, + dst->AddStringAttribute(ax::mojom::StringAttribute::kAutoComplete, src.AriaAutoComplete().Utf8()); } @@ -601,53 +620,55 @@ void BlinkAXTreeSource::SerializeNode(WebAXObject src, } if (src.HasComputedStyle()) { - dst->AddStringAttribute(ui::AX_ATTR_DISPLAY, + dst->AddStringAttribute(ax::mojom::StringAttribute::kDisplay, src.ComputedStyleDisplay().Utf8()); } if (src.Language().length()) { if (parent.IsNull() || parent.Language() != src.Language()) - dst->AddStringAttribute(ui::AX_ATTR_LANGUAGE, src.Language().Utf8()); + dst->AddStringAttribute(ax::mojom::StringAttribute::kLanguage, + src.Language().Utf8()); } if (src.KeyboardShortcut().length() && - !dst->HasStringAttribute(ui::AX_ATTR_KEY_SHORTCUTS)) { - dst->AddStringAttribute(ui::AX_ATTR_KEY_SHORTCUTS, + !dst->HasStringAttribute(ax::mojom::StringAttribute::kKeyShortcuts)) { + dst->AddStringAttribute(ax::mojom::StringAttribute::kKeyShortcuts, src.KeyboardShortcut().Utf8()); } if (!src.NextOnLine().IsDetached()) { - dst->AddIntAttribute(ui::AX_ATTR_NEXT_ON_LINE_ID, + dst->AddIntAttribute(ax::mojom::IntAttribute::kNextOnLineId, src.NextOnLine().AxID()); } if (!src.PreviousOnLine().IsDetached()) { - dst->AddIntAttribute(ui::AX_ATTR_PREVIOUS_ON_LINE_ID, + dst->AddIntAttribute(ax::mojom::IntAttribute::kPreviousOnLineId, src.PreviousOnLine().AxID()); } if (!src.AriaActiveDescendant().IsDetached()) { - dst->AddIntAttribute(ui::AX_ATTR_ACTIVEDESCENDANT_ID, + dst->AddIntAttribute(ax::mojom::IntAttribute::kActivedescendantId, src.AriaActiveDescendant().AxID()); } - if (dst->role == ui::AX_ROLE_HEADING && src.HeadingLevel()) { - dst->AddIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL, src.HeadingLevel()); - } else if ((dst->role == ui::AX_ROLE_TREE_ITEM || - dst->role == ui::AX_ROLE_ROW) && + if (dst->role == ax::mojom::Role::kHeading && src.HeadingLevel()) { + dst->AddIntAttribute(ax::mojom::IntAttribute::kHierarchicalLevel, + src.HeadingLevel()); + } else if ((dst->role == ax::mojom::Role::kTreeItem || + dst->role == ax::mojom::Role::kRow) && src.HierarchicalLevel()) { - dst->AddIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL, + dst->AddIntAttribute(ax::mojom::IntAttribute::kHierarchicalLevel, src.HierarchicalLevel()); } if (src.SetSize()) - dst->AddIntAttribute(ui::AX_ATTR_SET_SIZE, src.SetSize()); + dst->AddIntAttribute(ax::mojom::IntAttribute::kSetSize, src.SetSize()); if (src.PosInSet()) - dst->AddIntAttribute(ui::AX_ATTR_POS_IN_SET, src.PosInSet()); + dst->AddIntAttribute(ax::mojom::IntAttribute::kPosInSet, src.PosInSet()); if (src.CanvasHasFallbackContent()) - dst->AddBoolAttribute(ui::AX_ATTR_CANVAS_HAS_FALLBACK, true); + dst->AddBoolAttribute(ax::mojom::BoolAttribute::kCanvasHasFallback, true); // Spelling, grammar and other document markers. WebVector src_marker_types; @@ -670,71 +691,83 @@ void BlinkAXTreeSource::SerializeNode(WebAXObject src, marker_starts.push_back(src_marker_starts[i]); marker_ends.push_back(src_marker_ends[i]); } - dst->AddIntListAttribute(ui::AX_ATTR_MARKER_TYPES, marker_types); - dst->AddIntListAttribute(ui::AX_ATTR_MARKER_STARTS, marker_starts); - dst->AddIntListAttribute(ui::AX_ATTR_MARKER_ENDS, marker_ends); + dst->AddIntListAttribute(ax::mojom::IntListAttribute::kMarkerTypes, + marker_types); + dst->AddIntListAttribute(ax::mojom::IntListAttribute::kMarkerStarts, + marker_starts); + dst->AddIntListAttribute(ax::mojom::IntListAttribute::kMarkerEnds, + marker_ends); } if (src.IsInLiveRegion()) { - dst->AddBoolAttribute(ui::AX_ATTR_LIVE_ATOMIC, src.LiveRegionAtomic()); + dst->AddBoolAttribute(ax::mojom::BoolAttribute::kLiveAtomic, + src.LiveRegionAtomic()); if (!src.LiveRegionStatus().IsEmpty()) { - dst->AddStringAttribute(ui::AX_ATTR_LIVE_STATUS, + dst->AddStringAttribute(ax::mojom::StringAttribute::kLiveStatus, src.LiveRegionStatus().Utf8()); } - dst->AddStringAttribute(ui::AX_ATTR_LIVE_RELEVANT, + dst->AddStringAttribute(ax::mojom::StringAttribute::kLiveRelevant, src.LiveRegionRelevant().Utf8()); // If we are not at the root of an atomic live region. if (src.ContainerLiveRegionAtomic() && !src.LiveRegionRoot().IsDetached() && !src.LiveRegionAtomic()) { - dst->AddIntAttribute(ui::AX_ATTR_MEMBER_OF_ID, + dst->AddIntAttribute(ax::mojom::IntAttribute::kMemberOfId, src.LiveRegionRoot().AxID()); } - dst->AddBoolAttribute(ui::AX_ATTR_CONTAINER_LIVE_ATOMIC, + dst->AddBoolAttribute(ax::mojom::BoolAttribute::kContainerLiveAtomic, src.ContainerLiveRegionAtomic()); - dst->AddBoolAttribute(ui::AX_ATTR_CONTAINER_LIVE_BUSY, + dst->AddBoolAttribute(ax::mojom::BoolAttribute::kContainerLiveBusy, src.ContainerLiveRegionBusy()); - dst->AddStringAttribute(ui::AX_ATTR_CONTAINER_LIVE_STATUS, + dst->AddStringAttribute(ax::mojom::StringAttribute::kContainerLiveStatus, src.ContainerLiveRegionStatus().Utf8()); - dst->AddStringAttribute(ui::AX_ATTR_CONTAINER_LIVE_RELEVANT, - src.ContainerLiveRegionRelevant().Utf8()); - } - - if (dst->role == ui::AX_ROLE_PROGRESS_INDICATOR || - dst->role == ui::AX_ROLE_METER || dst->role == ui::AX_ROLE_SCROLL_BAR || - dst->role == ui::AX_ROLE_SLIDER || - dst->role == ui::AX_ROLE_SPIN_BUTTON || - (dst->role == ui::AX_ROLE_SPLITTER && src.CanSetFocusAttribute())) { + dst->AddStringAttribute( + ax::mojom::StringAttribute::kContainerLiveRelevant, + src.ContainerLiveRegionRelevant().Utf8()); + } + + if (dst->role == ax::mojom::Role::kProgressIndicator || + dst->role == ax::mojom::Role::kMeter || + dst->role == ax::mojom::Role::kScrollBar || + dst->role == ax::mojom::Role::kSlider || + dst->role == ax::mojom::Role::kSpinButton || + (dst->role == ax::mojom::Role::kSplitter && + src.CanSetFocusAttribute())) { float value; if (src.ValueForRange(&value)) - dst->AddFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, value); + dst->AddFloatAttribute(ax::mojom::FloatAttribute::kValueForRange, + value); float max_value; if (src.MaxValueForRange(&max_value)) { - dst->AddFloatAttribute(ui::AX_ATTR_MAX_VALUE_FOR_RANGE, max_value); + dst->AddFloatAttribute(ax::mojom::FloatAttribute::kMaxValueForRange, + max_value); } float min_value; if (src.MinValueForRange(&min_value)) { - dst->AddFloatAttribute(ui::AX_ATTR_MIN_VALUE_FOR_RANGE, min_value); + dst->AddFloatAttribute(ax::mojom::FloatAttribute::kMinValueForRange, + min_value); } float step_value; if (src.StepValueForRange(&step_value)) { - dst->AddFloatAttribute(ui::AX_ATTR_STEP_VALUE_FOR_RANGE, step_value); + dst->AddFloatAttribute(ax::mojom::FloatAttribute::kStepValueForRange, + step_value); } } - if (dst->role == ui::AX_ROLE_DIALOG || - dst->role == ui::AX_ROLE_ALERT_DIALOG) { - dst->AddBoolAttribute(ui::AX_ATTR_MODAL, src.IsModal()); + if (dst->role == ax::mojom::Role::kDialog || + dst->role == ax::mojom::Role::kAlertDialog) { + dst->AddBoolAttribute(ax::mojom::BoolAttribute::kModal, src.IsModal()); } - if (dst->role == ui::AX_ROLE_ROOT_WEB_AREA) - dst->AddStringAttribute(ui::AX_ATTR_HTML_TAG, "#document"); + if (dst->role == ax::mojom::Role::kRootWebArea) + dst->AddStringAttribute(ax::mojom::StringAttribute::kHtmlTag, + "#document"); - const bool is_table_like_role = dst->role == ui::AX_ROLE_TABLE || - dst->role == ui::AX_ROLE_GRID || - dst->role == ui::AX_ROLE_TREE_GRID; + const bool is_table_like_role = dst->role == ax::mojom::Role::kTable || + dst->role == ax::mojom::Role::kGrid || + dst->role == ax::mojom::Role::kTreeGrid; if (is_table_like_role) { int column_count = src.ColumnCount(); int row_count = src.RowCount(); @@ -742,11 +775,14 @@ void BlinkAXTreeSource::SerializeNode(WebAXObject src, std::set unique_cell_id_set; std::vector cell_ids; std::vector unique_cell_ids; - dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_COUNT, column_count); - dst->AddIntAttribute(ui::AX_ATTR_TABLE_ROW_COUNT, row_count); + dst->AddIntAttribute(ax::mojom::IntAttribute::kTableColumnCount, + column_count); + dst->AddIntAttribute(ax::mojom::IntAttribute::kTableRowCount, + row_count); WebAXObject header = src.HeaderContainerObject(); if (!header.IsDetached()) - dst->AddIntAttribute(ui::AX_ATTR_TABLE_HEADER_ID, header.AxID()); + dst->AddIntAttribute(ax::mojom::IntAttribute::kTableHeaderId, + header.AxID()); for (int i = 0; i < column_count * row_count; ++i) { WebAXObject cell = src.CellForColumnAndRow(i % column_count, i / column_count); @@ -760,64 +796,73 @@ void BlinkAXTreeSource::SerializeNode(WebAXObject src, } cell_ids.push_back(cell_id); } - dst->AddIntListAttribute(ui::AX_ATTR_CELL_IDS, cell_ids); - dst->AddIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS, unique_cell_ids); + dst->AddIntListAttribute(ax::mojom::IntListAttribute::kCellIds, + cell_ids); + dst->AddIntListAttribute(ax::mojom::IntListAttribute::kUniqueCellIds, + unique_cell_ids); } int aria_colcount = src.AriaColumnCount(); if (aria_colcount) - dst->AddIntAttribute(ui::AX_ATTR_ARIA_COLUMN_COUNT, aria_colcount); + dst->AddIntAttribute(ax::mojom::IntAttribute::kAriaColumnCount, + aria_colcount); int aria_rowcount = src.AriaRowCount(); if (aria_rowcount) - dst->AddIntAttribute(ui::AX_ATTR_ARIA_ROW_COUNT, aria_rowcount); + dst->AddIntAttribute(ax::mojom::IntAttribute::kAriaRowCount, + aria_rowcount); } - if (dst->role == ui::AX_ROLE_ROW) { - dst->AddIntAttribute(ui::AX_ATTR_TABLE_ROW_INDEX, src.RowIndex()); + if (dst->role == ax::mojom::Role::kRow) { + dst->AddIntAttribute(ax::mojom::IntAttribute::kTableRowIndex, + src.RowIndex()); WebAXObject header = src.RowHeader(); if (!header.IsDetached()) - dst->AddIntAttribute(ui::AX_ATTR_TABLE_ROW_HEADER_ID, header.AxID()); + dst->AddIntAttribute(ax::mojom::IntAttribute::kTableRowHeaderId, + header.AxID()); } - if (dst->role == ui::AX_ROLE_COLUMN) { - dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_INDEX, src.ColumnIndex()); + if (dst->role == ax::mojom::Role::kColumn) { + dst->AddIntAttribute(ax::mojom::IntAttribute::kTableColumnIndex, + src.ColumnIndex()); WebAXObject header = src.ColumnHeader(); if (!header.IsDetached()) - dst->AddIntAttribute(ui::AX_ATTR_TABLE_COLUMN_HEADER_ID, header.AxID()); + dst->AddIntAttribute(ax::mojom::IntAttribute::kTableColumnHeaderId, + header.AxID()); } - if (dst->role == ui::AX_ROLE_CELL || - dst->role == ui::AX_ROLE_ROW_HEADER || - dst->role == ui::AX_ROLE_COLUMN_HEADER || - dst->role == ui::AX_ROLE_ROW) { - if (dst->role != ui::AX_ROLE_ROW) { - dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX, + if (dst->role == ax::mojom::Role::kCell || + dst->role == ax::mojom::Role::kRowHeader || + dst->role == ax::mojom::Role::kColumnHeader || + dst->role == ax::mojom::Role::kRow) { + if (dst->role != ax::mojom::Role::kRow) { + dst->AddIntAttribute(ax::mojom::IntAttribute::kTableCellColumnIndex, src.CellColumnIndex()); - dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN, + dst->AddIntAttribute(ax::mojom::IntAttribute::kTableCellColumnSpan, src.CellColumnSpan()); - dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX, + dst->AddIntAttribute(ax::mojom::IntAttribute::kTableCellRowIndex, src.CellRowIndex()); - dst->AddIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_SPAN, + dst->AddIntAttribute(ax::mojom::IntAttribute::kTableCellRowSpan, src.CellRowSpan()); int aria_colindex = src.AriaColumnIndex(); if (aria_colindex) { - dst->AddIntAttribute(ui::AX_ATTR_ARIA_CELL_COLUMN_INDEX, + dst->AddIntAttribute(ax::mojom::IntAttribute::kAriaCellColumnIndex, aria_colindex); } } int aria_rowindex = src.AriaRowIndex(); if (aria_rowindex) - dst->AddIntAttribute(ui::AX_ATTR_ARIA_CELL_ROW_INDEX, aria_rowindex); + dst->AddIntAttribute(ax::mojom::IntAttribute::kAriaCellRowIndex, + aria_rowindex); } - if ((dst->role == ui::AX_ROLE_ROW_HEADER || - dst->role == ui::AX_ROLE_COLUMN_HEADER) && + if ((dst->role == ax::mojom::Role::kRowHeader || + dst->role == ax::mojom::Role::kColumnHeader) && src.SortDirection()) { dst->AddIntAttribute( - ui::AX_ATTR_SORT_DIRECTION, + ax::mojom::IntAttribute::kSortDirection, static_cast(AXSortDirectionFromBlink(src.SortDirection()))); } } @@ -836,7 +881,7 @@ void BlinkAXTreeSource::SerializeNode(WebAXObject src, // TODO(ctguil): The tagName in WebKit is lower cased but // HTMLElement::nodeName calls localNameUpper. Consider adding // a WebElement method that returns the original lower cased tagName. - dst->AddStringAttribute(ui::AX_ATTR_HTML_TAG, + dst->AddStringAttribute(ax::mojom::StringAttribute::kHtmlTag, base::ToLowerASCII(element.TagName().Utf8())); for (unsigned i = 0; i < element.AttributeCount(); ++i) { std::string name = @@ -848,8 +893,8 @@ void BlinkAXTreeSource::SerializeNode(WebAXObject src, // TODO(nektar): Turn off kHTMLAccessibilityMode for automation and Mac // and remove ifdef. #if defined(OS_WIN) - if (dst->role == ui::AX_ROLE_MATH && element.InnerHTML().length()) { - dst->AddStringAttribute(ui::AX_ATTR_INNER_HTML, + if (dst->role == ax::mojom::Role::kMath && element.InnerHTML().length()) { + dst->AddStringAttribute(ax::mojom::StringAttribute::kInnerHtml, element.InnerHTML().Utf8()); } #endif @@ -857,12 +902,14 @@ void BlinkAXTreeSource::SerializeNode(WebAXObject src, if (src.IsEditable()) { if (src.IsEditableRoot()) - dst->AddBoolAttribute(ui::AX_ATTR_EDITABLE_ROOT, true); + dst->AddBoolAttribute(ax::mojom::BoolAttribute::kEditableRoot, true); if (src.IsControl() && !src.IsRichlyEditable()) { // Only for simple input controls -- rich editable areas use AXTreeData - dst->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, src.SelectionStart()); - dst->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, src.SelectionEnd()); + dst->AddIntAttribute(ax::mojom::IntAttribute::kTextSelStart, + src.SelectionStart()); + dst->AddIntAttribute(ax::mojom::IntAttribute::kTextSelEnd, + src.SelectionEnd()); } #if defined(OS_CHROMEOS) @@ -874,19 +921,20 @@ void BlinkAXTreeSource::SerializeNode(WebAXObject src, line_breaks.reserve(src_line_breaks.size()); for (size_t i = 0; i < src_line_breaks.size(); ++i) line_breaks.push_back(src_line_breaks[i]); - dst->AddIntListAttribute(ui::AX_ATTR_LINE_BREAKS, line_breaks); + dst->AddIntListAttribute(ax::mojom::IntListAttribute::kLineBreaks, + line_breaks); } #endif // defined OS_CHROMEOS } // ARIA role. if (element.HasAttribute("role")) { - dst->AddStringAttribute(ui::AX_ATTR_ROLE, + dst->AddStringAttribute(ax::mojom::StringAttribute::kRole, element.GetAttribute("role").Utf8()); } else { std::string role = GetEquivalentAriaRoleString(dst->role); if (!role.empty()) - dst->AddStringAttribute(ui::AX_ATTR_ROLE, role); + dst->AddStringAttribute(ax::mojom::StringAttribute::kRole, role); } // Browser plugin (used in a ). @@ -918,26 +966,30 @@ void BlinkAXTreeSource::SerializeNode(WebAXObject src, indirect_child_ids.push_back(child.AxID()); } if (indirect_child_ids.size() > 0) { - dst->AddIntListAttribute(ui::AX_ATTR_INDIRECT_CHILD_IDS, + dst->AddIntListAttribute(ax::mojom::IntListAttribute::kIndirectChildIds, indirect_child_ids); } if (src.IsScrollableContainer()) { const gfx::Point& scrollOffset = src.GetScrollOffset(); - dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X, scrollOffset.x()); - dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y, scrollOffset.y()); + dst->AddIntAttribute(ax::mojom::IntAttribute::kScrollX, scrollOffset.x()); + dst->AddIntAttribute(ax::mojom::IntAttribute::kScrollY, scrollOffset.y()); const gfx::Point& minScrollOffset = src.MinimumScrollOffset(); - dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X_MIN, minScrollOffset.x()); - dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y_MIN, minScrollOffset.y()); + dst->AddIntAttribute(ax::mojom::IntAttribute::kScrollXMin, + minScrollOffset.x()); + dst->AddIntAttribute(ax::mojom::IntAttribute::kScrollYMin, + minScrollOffset.y()); const gfx::Point& maxScrollOffset = src.MaximumScrollOffset(); - dst->AddIntAttribute(ui::AX_ATTR_SCROLL_X_MAX, maxScrollOffset.x()); - dst->AddIntAttribute(ui::AX_ATTR_SCROLL_Y_MAX, maxScrollOffset.y()); + dst->AddIntAttribute(ax::mojom::IntAttribute::kScrollXMax, + maxScrollOffset.x()); + dst->AddIntAttribute(ax::mojom::IntAttribute::kScrollYMax, + maxScrollOffset.y()); } if (dst->id == image_data_node_id_) { - dst->AddStringAttribute(ui::AX_ATTR_IMAGE_DATA_URL, + dst->AddStringAttribute(ax::mojom::StringAttribute::kImageDataUrl, src.ImageDataUrl(max_image_data_size_).Utf8()); } } diff --git a/content/renderer/accessibility/render_accessibility_impl.cc b/content/renderer/accessibility/render_accessibility_impl.cc index 5b205117ea1e94..3005ed0f47ab04 100644 --- a/content/renderer/accessibility/render_accessibility_impl.cc +++ b/content/renderer/accessibility/render_accessibility_impl.cc @@ -28,6 +28,7 @@ #include "third_party/WebKit/public/web/WebSettings.h" #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" #include "third_party/WebKit/public/web/WebView.h" +#include "ui/accessibility/ax_enum_util.h" #include "ui/accessibility/ax_node.h" using blink::WebAXObject; @@ -131,7 +132,7 @@ RenderAccessibilityImpl::RenderAccessibilityImpl(RenderFrameImpl* render_frame, // accessibility being enabled. Initialize the browser's cached // accessibility tree by sending it a notification. HandleAXEvent(WebAXObject::FromWebDocument(document), - ui::AX_EVENT_LAYOUT_COMPLETE); + ax::mojom::Event::kLayoutComplete); } } @@ -171,8 +172,9 @@ void RenderAccessibilityImpl::AccessibilityModeChanged() { // our new event. pending_events_.clear(); auto webax_object = WebAXObject::FromWebDocument(document); - ui::AXEvent event = webax_object.IsLoaded() ? ui::AX_EVENT_LOAD_COMPLETE - : ui::AX_EVENT_LAYOUT_COMPLETE; + ax::mojom::Event event = webax_object.IsLoaded() + ? ax::mojom::Event::kLoadComplete + : ax::mojom::Event::kLayoutComplete; HandleAXEvent(webax_object, event); } } @@ -224,7 +226,8 @@ void RenderAccessibilityImpl::AccessibilityFocusedNodeChanged( if (node.IsNull()) { // When focus is cleared, implicitly focus the document. // TODO(dmazzoni): Make Blink send this notification instead. - HandleAXEvent(WebAXObject::FromWebDocument(document), ui::AX_EVENT_BLUR); + HandleAXEvent(WebAXObject::FromWebDocument(document), + ax::mojom::Event::kBlur); } } @@ -245,7 +248,7 @@ void RenderAccessibilityImpl::DisableAccessibility() { } void RenderAccessibilityImpl::HandleAXEvent(const blink::WebAXObject& obj, - ui::AXEvent event, + ax::mojom::Event event, int action_request_id) { const WebDocument& document = GetMainDocument(); if (document.IsNull()) @@ -262,7 +265,7 @@ void RenderAccessibilityImpl::HandleAXEvent(const blink::WebAXObject& obj, last_scroll_offset_ = scroll_offset; auto webax_object = WebAXObject::FromWebDocument(document); if (!obj.Equals(webax_object)) { - HandleAXEvent(webax_object, ui::AX_EVENT_LAYOUT_COMPLETE); + HandleAXEvent(webax_object, ax::mojom::Event::kLayoutComplete); } } } @@ -270,29 +273,29 @@ void RenderAccessibilityImpl::HandleAXEvent(const blink::WebAXObject& obj, #if defined(OS_ANDROID) // Force the newly focused node to be re-serialized so we include its // inline text boxes. - if (event == ui::AX_EVENT_FOCUS) + if (event == ax::mojom::Event::kFocus) serializer_.DeleteClientSubtree(obj); #endif // If some cell IDs have been added or removed, we need to update the whole // table. if (obj.Role() == blink::kWebAXRoleRow && - event == ui::AX_EVENT_CHILDREN_CHANGED) { + event == ax::mojom::Event::kChildrenChanged) { WebAXObject table_like_object = obj.ParentObject(); if (!table_like_object.IsDetached()) { serializer_.DeleteClientSubtree(table_like_object); - HandleAXEvent(table_like_object, ui::AX_EVENT_CHILDREN_CHANGED); + HandleAXEvent(table_like_object, ax::mojom::Event::kChildrenChanged); } } // If a select tag is opened or closed, all the children must be updated // because their visibility may have changed. if (obj.Role() == blink::kWebAXRoleMenuListPopup && - event == ui::AX_EVENT_CHILDREN_CHANGED) { + event == ax::mojom::Event::kChildrenChanged) { WebAXObject popup_like_object = obj.ParentObject(); if (!popup_like_object.IsDetached()) { serializer_.DeleteClientSubtree(popup_like_object); - HandleAXEvent(popup_like_object, ui::AX_EVENT_CHILDREN_CHANGED); + HandleAXEvent(popup_like_object, ax::mojom::Event::kChildrenChanged); } } @@ -303,11 +306,11 @@ void RenderAccessibilityImpl::HandleAXEvent(const blink::WebAXObject& obj, if (blink::WebUserGestureIndicator::IsProcessingUserGesture( render_frame_->GetWebFrame())) { - acc_event.event_from = ui::AX_EVENT_FROM_USER; + acc_event.event_from = ax::mojom::EventFrom::kUser; } else if (during_action_) { - acc_event.event_from = ui::AX_EVENT_FROM_ACTION; + acc_event.event_from = ax::mojom::EventFrom::kAction; } else { - acc_event.event_from = ui::AX_EVENT_FROM_PAGE; + acc_event.event_from = ax::mojom::EventFrom::kPage; } acc_event.action_request_id = action_request_id; @@ -374,7 +377,7 @@ void RenderAccessibilityImpl::OnPluginRootNodeUpdated() { if (!node.IsNull() && node.IsElementNode()) { WebElement element = node.To(); if (element.HasHTMLTagName("embed")) { - HandleAXEvent(obj, ui::AX_EVENT_CHILDREN_CHANGED); + HandleAXEvent(obj, ax::mojom::Event::kChildrenChanged); break; } } @@ -421,7 +424,7 @@ void RenderAccessibilityImpl::SendPendingAccessibilityEvents() { // Loop over each event and generate an updated event message. for (size_t i = 0; i < src_events.size(); ++i) { AccessibilityHostMsg_EventParams& event = src_events[i]; - if (event.event_type == ui::AX_EVENT_LAYOUT_COMPLETE) + if (event.event_type == ax::mojom::Event::kLayoutComplete) had_layout_complete_messages = true; auto obj = WebAXObject::FromWebDocumentByID(document, event.id); @@ -556,68 +559,68 @@ void RenderAccessibilityImpl::OnPerformAction( auto focus = WebAXObject::FromWebDocumentByID(document, data.focus_node_id); switch (data.action) { - case ui::AX_ACTION_BLUR: + case ax::mojom::Action::kBlur: root.Focus(); break; - case ui::AX_ACTION_DECREMENT: + case ax::mojom::Action::kDecrement: target.Decrement(); break; - case ui::AX_ACTION_DO_DEFAULT: + case ax::mojom::Action::kDoDefault: target.Click(); break; - case ui::AX_ACTION_GET_IMAGE_DATA: + case ax::mojom::Action::kGetImageData: OnGetImageData(target, data.target_rect.size()); break; - case ui::AX_ACTION_HIT_TEST: - DCHECK(data.hit_test_event_to_fire != ui::AX_EVENT_NONE); + case ax::mojom::Action::kHitTest: + DCHECK(data.hit_test_event_to_fire != ax::mojom::Event::kNone); OnHitTest(data.target_point, data.hit_test_event_to_fire, data.request_id); break; - case ui::AX_ACTION_INCREMENT: + case ax::mojom::Action::kIncrement: target.Increment(); break; - case ui::AX_ACTION_SCROLL_TO_MAKE_VISIBLE: + case ax::mojom::Action::kScrollToMakeVisible: target.ScrollToMakeVisibleWithSubFocus( WebRect(data.target_rect.x(), data.target_rect.y(), data.target_rect.width(), data.target_rect.height())); break; - case ui::AX_ACTION_SCROLL_TO_POINT: + case ax::mojom::Action::kScrollToPoint: target.ScrollToGlobalPoint( WebPoint(data.target_point.x(), data.target_point.y())); break; - case ui::AX_ACTION_LOAD_INLINE_TEXT_BOXES: + case ax::mojom::Action::kLoadInlineTextBoxes: OnLoadInlineTextBoxes(target); break; - case ui::AX_ACTION_FOCUS: + case ax::mojom::Action::kFocus: target.Focus(); break; - case ui::AX_ACTION_SET_SCROLL_OFFSET: + case ax::mojom::Action::kSetScrollOffset: target.SetScrollOffset( WebPoint(data.target_point.x(), data.target_point.y())); break; - case ui::AX_ACTION_SET_SELECTION: + case ax::mojom::Action::kSetSelection: anchor.SetSelection(anchor, data.anchor_offset, focus, data.focus_offset); - HandleAXEvent(root, ui::AX_EVENT_LAYOUT_COMPLETE); + HandleAXEvent(root, ax::mojom::Event::kLayoutComplete); break; - case ui::AX_ACTION_SET_SEQUENTIAL_FOCUS_NAVIGATION_STARTING_POINT: + case ax::mojom::Action::kSetSequentialFocusNavigationStartingPoint: target.SetSequentialFocusNavigationStartingPoint(); break; - case ui::AX_ACTION_SET_VALUE: + case ax::mojom::Action::kSetValue: target.SetValue(blink::WebString::FromUTF16(data.value)); - HandleAXEvent(target, ui::AX_EVENT_VALUE_CHANGED); + HandleAXEvent(target, ax::mojom::Event::kValueChanged); break; - case ui::AX_ACTION_SHOW_CONTEXT_MENU: + case ax::mojom::Action::kShowContextMenu: target.ShowContextMenu(); break; - case ui::AX_ACTION_CUSTOM_ACTION: - case ui::AX_ACTION_REPLACE_SELECTED_TEXT: - case ui::AX_ACTION_SCROLL_BACKWARD: - case ui::AX_ACTION_SCROLL_FORWARD: - case ui::AX_ACTION_SCROLL_UP: - case ui::AX_ACTION_SCROLL_DOWN: - case ui::AX_ACTION_SCROLL_LEFT: - case ui::AX_ACTION_SCROLL_RIGHT: - case ui::AX_ACTION_NONE: + case ax::mojom::Action::kCustomAction: + case ax::mojom::Action::kReplaceSelectedText: + case ax::mojom::Action::kScrollBackward: + case ax::mojom::Action::kScrollForward: + case ax::mojom::Action::kScrollUp: + case ax::mojom::Action::kScrollDown: + case ax::mojom::Action::kScrollLeft: + case ax::mojom::Action::kScrollRight: + case ax::mojom::Action::kNone: NOTREACHED(); break; } @@ -638,7 +641,7 @@ void RenderAccessibilityImpl::OnFatalError() { } void RenderAccessibilityImpl::OnHitTest(const gfx::Point& point, - ui::AXEvent event_to_fire, + ax::mojom::Event event_to_fire, int action_request_id) { const WebDocument& document = GetMainDocument(); if (document.IsNull()) @@ -690,7 +693,7 @@ void RenderAccessibilityImpl::OnLoadInlineTextBoxes( serializer_.DeleteClientSubtree(obj); // Explicitly send a tree change update event now. - HandleAXEvent(obj, ui::AX_EVENT_TREE_CHANGED); + HandleAXEvent(obj, ax::mojom::Event::kTreeChanged); } void RenderAccessibilityImpl::OnGetImageData( @@ -707,7 +710,7 @@ void RenderAccessibilityImpl::OnGetImageData( return; serializer_.DeleteClientSubtree(obj); - HandleAXEvent(obj, ui::AX_EVENT_IMAGE_FRAME_UPDATED); + HandleAXEvent(obj, ax::mojom::Event::kImageFrameUpdated); } void RenderAccessibilityImpl::OnReset(int reset_token) { @@ -720,8 +723,9 @@ void RenderAccessibilityImpl::OnReset(int reset_token) { // Tree-only mode gets used by the automation extension API which requires a // load complete event to invoke listener callbacks. auto webax_object = WebAXObject::FromWebDocument(document); - ui::AXEvent evt = webax_object.IsLoaded() ? ui::AX_EVENT_LOAD_COMPLETE - : ui::AX_EVENT_LAYOUT_COMPLETE; + ax::mojom::Event evt = webax_object.IsLoaded() + ? ax::mojom::Event::kLoadComplete + : ax::mojom::Event::kLayoutComplete; HandleAXEvent(webax_object, evt); } } @@ -733,7 +737,7 @@ void RenderAccessibilityImpl::OnDestruct() { void RenderAccessibilityImpl::AddPluginTreeToUpdate( AXContentTreeUpdate* update) { for (size_t i = 0; i < update->nodes.size(); ++i) { - if (update->nodes[i].role == ui::AX_ROLE_EMBEDDED_OBJECT) { + if (update->nodes[i].role == ax::mojom::Role::kEmbeddedObject) { const ui::AXNode* root = plugin_tree_source_->GetRoot(); update->nodes[i].child_ids.push_back(root->id()); diff --git a/content/renderer/accessibility/render_accessibility_impl.h b/content/renderer/accessibility/render_accessibility_impl.h index 9fe919b987a6bb..47f569df527f4d 100644 --- a/content/renderer/accessibility/render_accessibility_impl.h +++ b/content/renderer/accessibility/render_accessibility_impl.h @@ -98,7 +98,7 @@ class CONTENT_EXPORT RenderAccessibilityImpl void DisableAccessibility(); void HandleAXEvent(const blink::WebAXObject& obj, - ui::AXEvent event, + ax::mojom::Event event, int action_request_id = -1); protected: @@ -125,7 +125,7 @@ class CONTENT_EXPORT RenderAccessibilityImpl void OnReset(int reset_token); void OnHitTest(const gfx::Point& point, - ui::AXEvent event_to_fire, + ax::mojom::Event event_to_fire, int action_request_id); void OnLoadInlineTextBoxes(const blink::WebAXObject& obj); void OnGetImageData(const blink::WebAXObject& obj, const gfx::Size& max_size); diff --git a/content/renderer/accessibility/render_accessibility_impl_browsertest.cc b/content/renderer/accessibility/render_accessibility_impl_browsertest.cc index 4da5dec39991a4..a60aaaac420875 100644 --- a/content/renderer/accessibility/render_accessibility_impl_browsertest.cc +++ b/content/renderer/accessibility/render_accessibility_impl_browsertest.cc @@ -125,9 +125,7 @@ TEST_F(RenderAccessibilityImplTest, SendFullAccessibilityTreeOnReload) { sink_->ClearMessages(); WebDocument document = GetMainFrame()->GetDocument(); WebAXObject root_obj = WebAXObject::FromWebDocument(document); - accessibility->HandleAXEvent( - root_obj, - ui::AX_EVENT_LAYOUT_COMPLETE); + accessibility->HandleAXEvent(root_obj, ax::mojom::Event::kLayoutComplete); accessibility->SendPendingAccessibilityEvents(); EXPECT_EQ(1, CountAccessibilityNodesSentToBrowser()); { @@ -144,9 +142,7 @@ TEST_F(RenderAccessibilityImplTest, SendFullAccessibilityTreeOnReload) { document = GetMainFrame()->GetDocument(); root_obj = WebAXObject::FromWebDocument(document); sink_->ClearMessages(); - accessibility->HandleAXEvent( - root_obj, - ui::AX_EVENT_LAYOUT_COMPLETE); + accessibility->HandleAXEvent(root_obj, ax::mojom::Event::kLayoutComplete); accessibility->SendPendingAccessibilityEvents(); EXPECT_EQ(4, CountAccessibilityNodesSentToBrowser()); @@ -158,9 +154,8 @@ TEST_F(RenderAccessibilityImplTest, SendFullAccessibilityTreeOnReload) { root_obj = WebAXObject::FromWebDocument(document); sink_->ClearMessages(); const WebAXObject& first_child = root_obj.ChildAt(0); - accessibility->HandleAXEvent( - first_child, - ui::AX_EVENT_LIVE_REGION_CHANGED); + accessibility->HandleAXEvent(first_child, + ax::mojom::Event::kLiveRegionChanged); accessibility->SendPendingAccessibilityEvents(); EXPECT_EQ(4, CountAccessibilityNodesSentToBrowser()); } @@ -199,9 +194,7 @@ TEST_F(RenderAccessibilityImplTest, HideAccessibilityObject) { // Send a childrenChanged on 'A'. sink_->ClearMessages(); - accessibility->HandleAXEvent( - node_a, - ui::AX_EVENT_CHILDREN_CHANGED); + accessibility->HandleAXEvent(node_a, ax::mojom::Event::kChildrenChanged); accessibility->SendPendingAccessibilityEvents(); AccessibilityHostMsg_EventParams event; @@ -249,9 +242,7 @@ TEST_F(RenderAccessibilityImplTest, ShowAccessibilityObject) { WebAXObject node_b = node_a.ChildAt(0); WebAXObject node_c = node_b.ChildAt(0); - accessibility->HandleAXEvent( - node_a, - ui::AX_EVENT_CHILDREN_CHANGED); + accessibility->HandleAXEvent(node_a, ax::mojom::Event::kChildrenChanged); accessibility->SendPendingAccessibilityEvents(); AccessibilityHostMsg_EventParams event; diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc index d1f0501ac6a799..52a2a4e3e5ec46 100644 --- a/content/renderer/browser_plugin/browser_plugin.cc +++ b/content/renderer/browser_plugin/browser_plugin.cc @@ -204,8 +204,7 @@ void BrowserPlugin::Attach() { blink::WebAXObject ax_element = blink::WebAXObject::FromWebNode(element); if (!ax_element.IsDetached()) { render_frame->render_accessibility()->HandleAXEvent( - ax_element, - ui::AX_EVENT_CHILDREN_CHANGED); + ax_element, ax::mojom::Event::kChildrenChanged); } } diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn index 9aa73b6d5b9047..74feb07cbc4fdb 100644 --- a/content/test/BUILD.gn +++ b/content/test/BUILD.gn @@ -335,7 +335,7 @@ static_library("test_support") { "//testing/gmock", "//testing/gtest", "//tools/v8_context_snapshot:v8_context_snapshot", - "//ui/accessibility:ax_gen", + "//ui/accessibility:ax_enums_mojo", "//ui/base", "//ui/base:test_support", "//ui/base:ui_data_pack", @@ -521,7 +521,7 @@ static_library("browsertest_support") { "//net", "//skia", "//testing/gtest", - "//ui/accessibility:ax_gen", + "//ui/accessibility:ax_enums_mojo", "//ui/base", "//ui/base/ime", ] @@ -603,7 +603,7 @@ static_library("layouttest_support") { "//gpu/ipc/service", "//services/ui/public/cpp/gpu", "//skia", - "//ui/accessibility:ax_gen", + "//ui/accessibility:ax_enums_mojo", "//ui/events/blink", "//ui/gfx:test_support", "//v8", @@ -904,7 +904,7 @@ test("content_browsertests") { "//third_party/mesa:osmesa", "//third_party/zlib", "//ui/accessibility", - "//ui/accessibility:ax_gen", + "//ui/accessibility:ax_enums_mojo", "//ui/base:test_support", "//ui/base/ime", "//ui/compositor", diff --git a/content/test/accessibility_browser_test_utils.cc b/content/test/accessibility_browser_test_utils.cc index 4ceb90e4bcac17..ccb8afaab33dcc 100644 --- a/content/test/accessibility_browser_test_utils.cc +++ b/content/test/accessibility_browser_test_utils.cc @@ -21,7 +21,7 @@ namespace content { AccessibilityNotificationWaiter::AccessibilityNotificationWaiter( WebContents* web_contents) - : event_to_wait_for_(ui::AX_EVENT_NONE), + : event_to_wait_for_(ax::mojom::Event::kNone), loop_runner_(new MessageLoopRunner()), event_target_id_(0), event_render_frame_host_(nullptr), @@ -36,7 +36,7 @@ AccessibilityNotificationWaiter::AccessibilityNotificationWaiter( AccessibilityNotificationWaiter::AccessibilityNotificationWaiter( WebContents* web_contents, ui::AXMode accessibility_mode, - ui::AXEvent event_type) + ax::mojom::Event event_type) : event_to_wait_for_(event_type), loop_runner_(new MessageLoopRunner()), event_target_id_(0), @@ -53,7 +53,7 @@ AccessibilityNotificationWaiter::AccessibilityNotificationWaiter( AccessibilityNotificationWaiter::AccessibilityNotificationWaiter( RenderFrameHostImpl* frame_host, - ui::AXEvent event_type) + ax::mojom::Event event_type) : frame_host_(frame_host), event_to_wait_for_(event_type), loop_runner_(new MessageLoopRunner()), @@ -92,9 +92,9 @@ const ui::AXTree& AccessibilityNotificationWaiter::GetAXTree() const { void AccessibilityNotificationWaiter::OnAccessibilityEvent( RenderFrameHostImpl* rfhi, - ui::AXEvent event_type, + ax::mojom::Event event_type, int event_target_id) { - if (!IsAboutBlank() && (event_to_wait_for_ == ui::AX_EVENT_NONE || + if (!IsAboutBlank() && (event_to_wait_for_ == ax::mojom::Event::kNone || event_to_wait_for_ == event_type)) { event_target_id_ = event_target_id; event_render_frame_host_ = rfhi; diff --git a/content/test/accessibility_browser_test_utils.h b/content/test/accessibility_browser_test_utils.h index b1b35f0c5858af..93e3aaa71f04b5 100644 --- a/content/test/accessibility_browser_test_utils.h +++ b/content/test/accessibility_browser_test_utils.h @@ -27,10 +27,9 @@ class AccessibilityNotificationWaiter { explicit AccessibilityNotificationWaiter(WebContents* web_contents); AccessibilityNotificationWaiter(WebContents* web_contents, ui::AXMode accessibility_mode, - ui::AXEvent event); - AccessibilityNotificationWaiter( - RenderFrameHostImpl* frame_host, - ui::AXEvent event); + ax::mojom::Event event); + AccessibilityNotificationWaiter(RenderFrameHostImpl* frame_host, + ax::mojom::Event event); ~AccessibilityNotificationWaiter(); void ListenToAdditionalFrame(RenderFrameHostImpl* frame_host); @@ -57,7 +56,7 @@ class AccessibilityNotificationWaiter { private: // Callback from RenderViewHostImpl. void OnAccessibilityEvent(content::RenderFrameHostImpl* rfhi, - ui::AXEvent event, + ax::mojom::Event event, int event_target_id); // Helper function to determine if the accessibility tree in @@ -65,7 +64,7 @@ class AccessibilityNotificationWaiter { bool IsAboutBlank(); RenderFrameHostImpl* frame_host_; - ui::AXEvent event_to_wait_for_; + ax::mojom::Event event_to_wait_for_; scoped_refptr loop_runner_; int event_target_id_; RenderFrameHostImpl* event_render_frame_host_; diff --git a/docs/accessibility/overview.md b/docs/accessibility/overview.md index 8faef5c663ce22..36e4b14dad11a9 100644 --- a/docs/accessibility/overview.md +++ b/docs/accessibility/overview.md @@ -294,17 +294,17 @@ is stored in attribute arrays, one for each major data type. ``` struct AXNodeData { int32_t id; - AXRole role; + ax::mojom::Role role; ... - std::vector> string_attributes; - std::vector> int_attributes; + std::vector> string_attributes; + std::vector> int_attributes; ... } ``` So if a text field has a placeholder attribute, we can store that by adding an entry to `string_attributes` with an attribute -of ui::AX_ATTR_PLACEHOLDER and the placeholder string as the value. +of ax::mojom::StringAttribute::kPlaceholder and the placeholder string as the value. ### Incremental tree updates diff --git a/tools/ipc_fuzzer/message_lib/BUILD.gn b/tools/ipc_fuzzer/message_lib/BUILD.gn index ce870ac4ef9026..3852da3f0c52a1 100644 --- a/tools/ipc_fuzzer/message_lib/BUILD.gn +++ b/tools/ipc_fuzzer/message_lib/BUILD.gn @@ -30,7 +30,7 @@ static_library("ipc_message_lib") { "//third_party/WebKit/public:blink_headers", "//third_party/mt19937ar", "//third_party/webrtc_overrides", - "//ui/accessibility:ax_gen", + "//ui/accessibility:ax_enums_mojo", ] sources = [ "all_messages.h", diff --git a/ui/accessibility/BUILD.gn b/ui/accessibility/BUILD.gn index b5a6c772be0de3..d497360d8d81e7 100644 --- a/ui/accessibility/BUILD.gn +++ b/ui/accessibility/BUILD.gn @@ -6,6 +6,7 @@ import("//build/config/linux/gtk/gtk.gni") import("//build/config/linux/pkg_config.gni") import("//build/config/features.gni") import("//build/config/ui.gni") +import("//mojo/public/tools/bindings/mojom.gni") import("//testing/libfuzzer/fuzzer_test.gni") import("//testing/test.gni") import("//tools/json_schema_compiler/json_schema_api.gni") @@ -15,10 +16,18 @@ if (is_android) { import("//build/config/android/rules.gni") } +mojom("ax_enums_mojo") { + sources = [ + "ax_enums.mojom", + ] +} + component("accessibility") { sources = [ "ax_action_data.cc", "ax_action_data.h", + "ax_enum_util.cc", + "ax_enum_util.h", "ax_event_generator.cc", "ax_event_generator.h", "ax_export.h", @@ -81,7 +90,7 @@ component("accessibility") { defines = [ "ACCESSIBILITY_IMPLEMENTATION" ] public_deps = [ - ":ax_gen", + ":ax_enums_mojo", "//base", "//base:i18n", "//ui/base", @@ -134,21 +143,6 @@ component("accessibility") { } } -if (is_android) { - android_library("ui_accessibility_java") { - deps = [ - "//third_party/android_tools:android_support_annotations_java", - ] - srcjar_deps = [ ":ax_enumerations_srcjar" ] - } - - java_cpp_enum("ax_enumerations_srcjar") { - sources = [ - "ax_enums.idl", - ] - } -} - static_library("test_support") { testonly = true sources = [ @@ -186,7 +180,7 @@ test("accessibility_unittests") { deps = [ ":accessibility", - ":ax_gen", + ":ax_enums_mojo", ":test_support", "//base", "//base/test:run_all_unittests", @@ -207,17 +201,6 @@ test("accessibility_unittests") { } } -json_schema_api("ax_gen") { - sources = [ - "ax_enums.idl", - ] - deps = [ - "//base/third_party/dynamic_annotations", - ] - root_namespace = "ui" - schemas = true -} - fuzzer_test("ax_tree_fuzzer") { sources = [ "ax_tree_fuzzer.cc", diff --git a/ui/accessibility/OWNERS b/ui/accessibility/OWNERS index 72709ebff2aa47..bdb5819a93b6fb 100644 --- a/ui/accessibility/OWNERS +++ b/ui/accessibility/OWNERS @@ -5,5 +5,8 @@ nektar@chromium.org dougt@chromium.org aleventhal@chromium.org +per-file *.mojom=set noparent +per-file *.mojom=file://ipc/SECURITY_OWNERS + # TEAM: chromium-accessibility@chromium.org # COMPONENT: Internals>Accessibility diff --git a/ui/accessibility/PRESUBMIT.py b/ui/accessibility/PRESUBMIT.py index f953d4f98a6351..500b1cc607e3ba 100644 --- a/ui/accessibility/PRESUBMIT.py +++ b/ui/accessibility/PRESUBMIT.py @@ -4,9 +4,9 @@ """Presubmit script for ui/accessibility.""" -import os, re +import os, re, json -AX_IDL = 'ui/accessibility/ax_enums.idl' +AX_MOJOM = 'ui/accessibility/ax_enums.mojom' AUTOMATION_IDL = 'chrome/common/extensions/api/automation.idl' AX_JS_FILE = 'content/browser/resources/accessibility/accessibility.js' @@ -16,7 +16,15 @@ def InitialLowerCamelCase(unix_name): words = unix_name.split('_') return words[0] + ''.join(word.capitalize() for word in words[1:]) -# Given a full path to an IDL file containing enum definitions, +def CamelToLowerHacker(str): + out = '' + for i in range(len(str)): + if str[i] >= 'A' and str[i] <= 'Z' and out: + out += '_' + out += str[i] + return out.lower() + +# Given a full path to an IDL or MOJOM file containing enum definitions, # parse the file for enums and return a dict mapping the enum name # to a list of values for that enum. def GetEnumsFromFile(fullpath): @@ -45,7 +53,15 @@ def GetEnumsFromFile(fullpath): m = re.search('([\w]+)', line) if m: enums.setdefault(enum_name, []) - enums[enum_name].append(m.group(1)) + enum_value = m.group(1) + if (enum_value[0] == 'k' and + enum_value[1] == enum_value[1].upper()): + enum_value = CamelToLowerHacker(enum_value[1:]) + if enum_value == 'none' or enum_value == 'last': + continue + if enum_value == 'active_descendant_changed': + enum_value = 'activedescendantchanged' + enums[enum_name].append(enum_value) return enums @@ -57,7 +73,7 @@ def CheckMatchingEnum(ax_enums, output_api): if ax_enum_name not in ax_enums: errs.append(output_api.PresubmitError( - 'Expected %s to have an enum named %s' % (AX_IDL, ax_enum_name))) + 'Expected %s to have an enum named %s' % (AX_MOJOM, ax_enum_name))) return if automation_enum_name not in automation_enums: errs.append(output_api.PresubmitError( @@ -73,7 +89,7 @@ def CheckMatchingEnum(ax_enums, else: errs.append(output_api.PresubmitError( 'Found %s.%s in %s, but did not find %s.%s in %s' % ( - ax_enum_name, value, AX_IDL, + ax_enum_name, value, AX_MOJOM, automation_enum_name, InitialLowerCamelCase(value), AUTOMATION_IDL))) # Should be no remaining items @@ -82,11 +98,11 @@ def CheckMatchingEnum(ax_enums, 'Found %s.%s in %s, but did not find %s.%s in %s' % ( automation_enum_name, value, AUTOMATION_IDL, ax_enum_name, InitialLowerCamelCase(value), - AX_IDL))) + AX_MOJOM))) def CheckEnumsMatch(input_api, output_api): repo_root = input_api.change.RepositoryRoot() - ax_enums = GetEnumsFromFile(os.path.join(repo_root, AX_IDL)) + ax_enums = GetEnumsFromFile(os.path.join(repo_root, AX_MOJOM)) automation_enums = GetEnumsFromFile(os.path.join(repo_root, AUTOMATION_IDL)) # Focused state only exists in automation. @@ -95,15 +111,15 @@ def CheckEnumsMatch(input_api, output_api): automation_enums['StateType'].remove('offscreen') errs = [] - CheckMatchingEnum(ax_enums, 'AXRole', automation_enums, 'RoleType', errs, + CheckMatchingEnum(ax_enums, 'Role', automation_enums, 'RoleType', errs, output_api) - CheckMatchingEnum(ax_enums, 'AXState', automation_enums, 'StateType', errs, + CheckMatchingEnum(ax_enums, 'State', automation_enums, 'StateType', errs, output_api) - CheckMatchingEnum(ax_enums, 'AXEvent', automation_enums, 'EventType', errs, + CheckMatchingEnum(ax_enums, 'Event', automation_enums, 'EventType', errs, output_api) - CheckMatchingEnum(ax_enums, 'AXNameFrom', automation_enums, 'NameFromType', + CheckMatchingEnum(ax_enums, 'NameFrom', automation_enums, 'NameFromType', errs, output_api) - CheckMatchingEnum(ax_enums, 'AXRestriction', automation_enums, + CheckMatchingEnum(ax_enums, 'Restriction', automation_enums, 'Restriction', errs, output_api) return errs @@ -180,7 +196,7 @@ def CheckChangeOnUpload(input_api, output_api): errs = [] for path in input_api.LocalPaths(): path = path.replace('\\', '/') - if AX_IDL == path: + if AX_MOJOM == path: errs.extend(CheckEnumsMatch(input_api, output_api)) if AX_MODE_HEADER == path: @@ -192,10 +208,14 @@ def CheckChangeOnCommit(input_api, output_api): errs = [] for path in input_api.LocalPaths(): path = path.replace('\\', '/') - if AX_IDL == path: + if AX_MOJOM == path: errs.extend(CheckEnumsMatch(input_api, output_api)) if AX_MODE_HEADER == path: errs.extend(CheckModesMatch(input_api, output_api)) return errs + +# Run this script directly to dump its keys, for debugging. +if __name__ == '__main__': + print json.dumps(GetEnumsFromFile(AX_MOJOM), sort_keys=True, indent=4) diff --git a/ui/accessibility/ax_action_data.cc b/ui/accessibility/ax_action_data.cc index f74d7670d51f59..3024f145491538 100644 --- a/ui/accessibility/ax_action_data.cc +++ b/ui/accessibility/ax_action_data.cc @@ -10,6 +10,7 @@ #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" +#include "ui/accessibility/ax_enum_util.h" using base::IntToString; @@ -21,24 +22,25 @@ AXActionData::~AXActionData() = default; namespace { -bool IsFlagSet(uint32_t bitfield, AXActionFlags flag) { +bool IsFlagSet(uint32_t bitfield, ax::mojom::ActionFlags flag) { return 0 != (bitfield & (1 << static_cast(flag))); } } // namespace // Note that this includes an initial space character if nonempty, but -// that works fine because this is normally printed by AXAction::ToString. +// that works fine because this is normally printed by +// ax::mojom::Action::ToString. std::string AXActionData::ToString() const { std::string result = ui::ToString(action); if (target_node_id != -1) result += " target_node_id=" + IntToString(target_node_id); - if (IsFlagSet(flags, AX_ACTION_FLAGS_REQUEST_IMAGES)) + if (IsFlagSet(flags, ax::mojom::ActionFlags::kRequestImages)) result += " flag_request_images"; - if (IsFlagSet(flags, AX_ACTION_FLAGS_REQUEST_INLINE_TEXT_BOXES)) + if (IsFlagSet(flags, ax::mojom::ActionFlags::kRequestInlineTextBoxes)) result += " flag_request_inline_text_boxes"; if (anchor_node_id != -1) { diff --git a/ui/accessibility/ax_action_data.h b/ui/accessibility/ax_action_data.h index 5cd03eed7a3d28..37efaffb9cc41c 100644 --- a/ui/accessibility/ax_action_data.h +++ b/ui/accessibility/ax_action_data.h @@ -6,7 +6,7 @@ #define UI_ACCESSIBILITY_AX_ACTION_DATA_H_ #include "base/strings/string16.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_export.h" #include "ui/gfx/geometry/rect.h" @@ -25,11 +25,11 @@ struct AX_EXPORT AXActionData { // This is a simple serializable struct. All member variables should be // public and copyable. - // See the AXAction enums in ax_enums.idl for explanations of which + // See the ax::mojom::Action enums in ax_enums.idl for explanations of which // parameters apply. // The action to take. - AXAction action = AX_ACTION_NONE; + ax::mojom::Action action = ax::mojom::Action::kNone; // The ID of the tree that this action should be performed on. int target_tree_id = -1; @@ -43,7 +43,7 @@ struct AX_EXPORT AXActionData { // The request id of this action tracked by the client. int request_id = -1; - // Use enums from AXActionFlags + // Use enums from ax::mojom::ActionFlags int flags = 0; // For an action that creates a selection, the selection anchor and focus @@ -67,7 +67,7 @@ struct AX_EXPORT AXActionData { base::string16 value; // The event to fire in response to a HIT_TEST action. - AXEvent hit_test_event_to_fire = AX_EVENT_NONE; + ax::mojom::Event hit_test_event_to_fire = ax::mojom::Event::kNone; }; } // namespace ui diff --git a/ui/accessibility/ax_enum_util.cc b/ui/accessibility/ax_enum_util.cc new file mode 100644 index 00000000000000..78118b583225d2 --- /dev/null +++ b/ui/accessibility/ax_enum_util.cc @@ -0,0 +1,2213 @@ +// Copyright 2018 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 "ui/accessibility/ax_enum_util.h" + +namespace ui { + +const char* ToString(ax::mojom::Event event) { + switch (event) { + case ax::mojom::Event::kNone: + return "none"; + case ax::mojom::Event::kActiveDescendantChanged: + return "activedescendantchanged"; + case ax::mojom::Event::kAlert: + return "alert"; + case ax::mojom::Event::kAriaAttributeChanged: + return "ariaAttributeChanged"; + case ax::mojom::Event::kAutocorrectionOccured: + return "autocorrectionOccured"; + case ax::mojom::Event::kBlur: + return "blur"; + case ax::mojom::Event::kCheckedStateChanged: + return "checkedStateChanged"; + case ax::mojom::Event::kChildrenChanged: + return "childrenChanged"; + case ax::mojom::Event::kClicked: + return "clicked"; + case ax::mojom::Event::kDocumentSelectionChanged: + return "documentSelectionChanged"; + case ax::mojom::Event::kExpandedChanged: + return "expandedChanged"; + case ax::mojom::Event::kFocus: + return "focus"; + case ax::mojom::Event::kHide: + return "hide"; + case ax::mojom::Event::kHitTestResult: + return "hitTestResult"; + case ax::mojom::Event::kHover: + return "hover"; + case ax::mojom::Event::kImageFrameUpdated: + return "imageFrameUpdated"; + case ax::mojom::Event::kInvalidStatusChanged: + return "invalidStatusChanged"; + case ax::mojom::Event::kLayoutComplete: + return "layoutComplete"; + case ax::mojom::Event::kLiveRegionCreated: + return "liveRegionCreated"; + case ax::mojom::Event::kLiveRegionChanged: + return "liveRegionChanged"; + case ax::mojom::Event::kLoadComplete: + return "loadComplete"; + case ax::mojom::Event::kLocationChanged: + return "locationChanged"; + case ax::mojom::Event::kMediaStartedPlaying: + return "mediaStartedPlaying"; + case ax::mojom::Event::kMediaStoppedPlaying: + return "mediaStoppedPlaying"; + case ax::mojom::Event::kMenuEnd: + return "menuEnd"; + case ax::mojom::Event::kMenuListItemSelected: + return "menuListItemSelected"; + case ax::mojom::Event::kMenuListValueChanged: + return "menuListValueChanged"; + case ax::mojom::Event::kMenuPopupEnd: + return "menuPopupEnd"; + case ax::mojom::Event::kMenuPopupStart: + return "menuPopupStart"; + case ax::mojom::Event::kMenuStart: + return "menuStart"; + case ax::mojom::Event::kMouseCanceled: + return "mouseCanceled"; + case ax::mojom::Event::kMouseDragged: + return "mouseDragged"; + case ax::mojom::Event::kMouseMoved: + return "mouseMoved"; + case ax::mojom::Event::kMousePressed: + return "mousePressed"; + case ax::mojom::Event::kMouseReleased: + return "mouseReleased"; + case ax::mojom::Event::kRowCollapsed: + return "rowCollapsed"; + case ax::mojom::Event::kRowCountChanged: + return "rowCountChanged"; + case ax::mojom::Event::kRowExpanded: + return "rowExpanded"; + case ax::mojom::Event::kScrollPositionChanged: + return "scrollPositionChanged"; + case ax::mojom::Event::kScrolledToAnchor: + return "scrolledToAnchor"; + case ax::mojom::Event::kSelectedChildrenChanged: + return "selectedChildrenChanged"; + case ax::mojom::Event::kSelection: + return "selection"; + case ax::mojom::Event::kSelectionAdd: + return "selectionAdd"; + case ax::mojom::Event::kSelectionRemove: + return "selectionRemove"; + case ax::mojom::Event::kShow: + return "show"; + case ax::mojom::Event::kTextChanged: + return "textChanged"; + case ax::mojom::Event::kTextSelectionChanged: + return "textSelectionChanged"; + case ax::mojom::Event::kTreeChanged: + return "treeChanged"; + case ax::mojom::Event::kValueChanged: + return "valueChanged"; + } + + return ""; +} + +ax::mojom::Event ParseEvent(const char* event) { + if (0 == strcmp(event, "none")) + return ax::mojom::Event::kNone; + if (0 == strcmp(event, "activedescendantchanged")) + return ax::mojom::Event::kActiveDescendantChanged; + if (0 == strcmp(event, "alert")) + return ax::mojom::Event::kAlert; + if (0 == strcmp(event, "ariaAttributeChanged")) + return ax::mojom::Event::kAriaAttributeChanged; + if (0 == strcmp(event, "autocorrectionOccured")) + return ax::mojom::Event::kAutocorrectionOccured; + if (0 == strcmp(event, "blur")) + return ax::mojom::Event::kBlur; + if (0 == strcmp(event, "checkedStateChanged")) + return ax::mojom::Event::kCheckedStateChanged; + if (0 == strcmp(event, "childrenChanged")) + return ax::mojom::Event::kChildrenChanged; + if (0 == strcmp(event, "clicked")) + return ax::mojom::Event::kClicked; + if (0 == strcmp(event, "documentSelectionChanged")) + return ax::mojom::Event::kDocumentSelectionChanged; + if (0 == strcmp(event, "expandedChanged")) + return ax::mojom::Event::kExpandedChanged; + if (0 == strcmp(event, "focus")) + return ax::mojom::Event::kFocus; + if (0 == strcmp(event, "hide")) + return ax::mojom::Event::kHide; + if (0 == strcmp(event, "hitTestResult")) + return ax::mojom::Event::kHitTestResult; + if (0 == strcmp(event, "hover")) + return ax::mojom::Event::kHover; + if (0 == strcmp(event, "imageFrameUpdated")) + return ax::mojom::Event::kImageFrameUpdated; + if (0 == strcmp(event, "invalidStatusChanged")) + return ax::mojom::Event::kInvalidStatusChanged; + if (0 == strcmp(event, "layoutComplete")) + return ax::mojom::Event::kLayoutComplete; + if (0 == strcmp(event, "liveRegionCreated")) + return ax::mojom::Event::kLiveRegionCreated; + if (0 == strcmp(event, "liveRegionChanged")) + return ax::mojom::Event::kLiveRegionChanged; + if (0 == strcmp(event, "loadComplete")) + return ax::mojom::Event::kLoadComplete; + if (0 == strcmp(event, "locationChanged")) + return ax::mojom::Event::kLocationChanged; + if (0 == strcmp(event, "mediaStartedPlaying")) + return ax::mojom::Event::kMediaStartedPlaying; + if (0 == strcmp(event, "mediaStoppedPlaying")) + return ax::mojom::Event::kMediaStoppedPlaying; + if (0 == strcmp(event, "menuEnd")) + return ax::mojom::Event::kMenuEnd; + if (0 == strcmp(event, "menuListItemSelected")) + return ax::mojom::Event::kMenuListItemSelected; + if (0 == strcmp(event, "menuListValueChanged")) + return ax::mojom::Event::kMenuListValueChanged; + if (0 == strcmp(event, "menuPopupEnd")) + return ax::mojom::Event::kMenuPopupEnd; + if (0 == strcmp(event, "menuPopupStart")) + return ax::mojom::Event::kMenuPopupStart; + if (0 == strcmp(event, "menuStart")) + return ax::mojom::Event::kMenuStart; + if (0 == strcmp(event, "mouseCanceled")) + return ax::mojom::Event::kMouseCanceled; + if (0 == strcmp(event, "mouseDragged")) + return ax::mojom::Event::kMouseDragged; + if (0 == strcmp(event, "mouseMoved")) + return ax::mojom::Event::kMouseMoved; + if (0 == strcmp(event, "mousePressed")) + return ax::mojom::Event::kMousePressed; + if (0 == strcmp(event, "mouseReleased")) + return ax::mojom::Event::kMouseReleased; + if (0 == strcmp(event, "rowCollapsed")) + return ax::mojom::Event::kRowCollapsed; + if (0 == strcmp(event, "rowCountChanged")) + return ax::mojom::Event::kRowCountChanged; + if (0 == strcmp(event, "rowExpanded")) + return ax::mojom::Event::kRowExpanded; + if (0 == strcmp(event, "scrollPositionChanged")) + return ax::mojom::Event::kScrollPositionChanged; + if (0 == strcmp(event, "scrolledToAnchor")) + return ax::mojom::Event::kScrolledToAnchor; + if (0 == strcmp(event, "selectedChildrenChanged")) + return ax::mojom::Event::kSelectedChildrenChanged; + if (0 == strcmp(event, "selection")) + return ax::mojom::Event::kSelection; + if (0 == strcmp(event, "selectionAdd")) + return ax::mojom::Event::kSelectionAdd; + if (0 == strcmp(event, "selectionRemove")) + return ax::mojom::Event::kSelectionRemove; + if (0 == strcmp(event, "show")) + return ax::mojom::Event::kShow; + if (0 == strcmp(event, "textChanged")) + return ax::mojom::Event::kTextChanged; + if (0 == strcmp(event, "textSelectionChanged")) + return ax::mojom::Event::kTextSelectionChanged; + if (0 == strcmp(event, "treeChanged")) + return ax::mojom::Event::kTreeChanged; + if (0 == strcmp(event, "valueChanged")) + return ax::mojom::Event::kValueChanged; + return ax::mojom::Event::kNone; +} + +const char* ToString(ax::mojom::Role role) { + switch (role) { + case ax::mojom::Role::kNone: + return "none"; + case ax::mojom::Role::kAbbr: + return "abbr"; + case ax::mojom::Role::kAlertDialog: + return "alertDialog"; + case ax::mojom::Role::kAlert: + return "alert"; + case ax::mojom::Role::kAnchor: + return "anchor"; + case ax::mojom::Role::kAnnotation: + return "annotation"; + case ax::mojom::Role::kApplication: + return "application"; + case ax::mojom::Role::kArticle: + return "article"; + case ax::mojom::Role::kAudio: + return "audio"; + case ax::mojom::Role::kBanner: + return "banner"; + case ax::mojom::Role::kBlockquote: + return "blockquote"; + case ax::mojom::Role::kButton: + return "button"; + case ax::mojom::Role::kCanvas: + return "canvas"; + case ax::mojom::Role::kCaption: + return "caption"; + case ax::mojom::Role::kCaret: + return "caret"; + case ax::mojom::Role::kCell: + return "cell"; + case ax::mojom::Role::kCheckBox: + return "checkBox"; + case ax::mojom::Role::kClient: + return "client"; + case ax::mojom::Role::kColorWell: + return "colorWell"; + case ax::mojom::Role::kColumnHeader: + return "columnHeader"; + case ax::mojom::Role::kColumn: + return "column"; + case ax::mojom::Role::kComboBoxGrouping: + return "comboBoxGrouping"; + case ax::mojom::Role::kComboBoxMenuButton: + return "comboBoxMenuButton"; + case ax::mojom::Role::kComplementary: + return "complementary"; + case ax::mojom::Role::kContentInfo: + return "contentInfo"; + case ax::mojom::Role::kDate: + return "date"; + case ax::mojom::Role::kDateTime: + return "dateTime"; + case ax::mojom::Role::kDefinition: + return "definition"; + case ax::mojom::Role::kDescriptionListDetail: + return "descriptionListDetail"; + case ax::mojom::Role::kDescriptionList: + return "descriptionList"; + case ax::mojom::Role::kDescriptionListTerm: + return "descriptionListTerm"; + case ax::mojom::Role::kDesktop: + return "desktop"; + case ax::mojom::Role::kDetails: + return "details"; + case ax::mojom::Role::kDialog: + return "dialog"; + case ax::mojom::Role::kDirectory: + return "directory"; + case ax::mojom::Role::kDisclosureTriangle: + return "disclosureTriangle"; + case ax::mojom::Role::kDocument: + return "document"; + case ax::mojom::Role::kEmbeddedObject: + return "embeddedObject"; + case ax::mojom::Role::kFeed: + return "feed"; + case ax::mojom::Role::kFigcaption: + return "figcaption"; + case ax::mojom::Role::kFigure: + return "figure"; + case ax::mojom::Role::kFooter: + return "footer"; + case ax::mojom::Role::kForm: + return "form"; + case ax::mojom::Role::kGenericContainer: + return "genericContainer"; + case ax::mojom::Role::kGrid: + return "grid"; + case ax::mojom::Role::kGroup: + return "group"; + case ax::mojom::Role::kHeading: + return "heading"; + case ax::mojom::Role::kIframe: + return "iframe"; + case ax::mojom::Role::kIframePresentational: + return "iframePresentational"; + case ax::mojom::Role::kIgnored: + return "ignored"; + case ax::mojom::Role::kImageMap: + return "imageMap"; + case ax::mojom::Role::kImage: + return "image"; + case ax::mojom::Role::kInlineTextBox: + return "inlineTextBox"; + case ax::mojom::Role::kInputTime: + return "inputTime"; + case ax::mojom::Role::kLabelText: + return "labelText"; + case ax::mojom::Role::kLegend: + return "legend"; + case ax::mojom::Role::kLineBreak: + return "lineBreak"; + case ax::mojom::Role::kLink: + return "link"; + case ax::mojom::Role::kListBoxOption: + return "listBoxOption"; + case ax::mojom::Role::kListBox: + return "listBox"; + case ax::mojom::Role::kListItem: + return "listItem"; + case ax::mojom::Role::kListMarker: + return "listMarker"; + case ax::mojom::Role::kList: + return "list"; + case ax::mojom::Role::kLocationBar: + return "locationBar"; + case ax::mojom::Role::kLog: + return "log"; + case ax::mojom::Role::kMain: + return "main"; + case ax::mojom::Role::kMark: + return "mark"; + case ax::mojom::Role::kMarquee: + return "marquee"; + case ax::mojom::Role::kMath: + return "math"; + case ax::mojom::Role::kMenu: + return "menu"; + case ax::mojom::Role::kMenuBar: + return "menuBar"; + case ax::mojom::Role::kMenuButton: + return "menuButton"; + case ax::mojom::Role::kMenuItem: + return "menuItem"; + case ax::mojom::Role::kMenuItemCheckBox: + return "menuItemCheckBox"; + case ax::mojom::Role::kMenuItemRadio: + return "menuItemRadio"; + case ax::mojom::Role::kMenuListOption: + return "menuListOption"; + case ax::mojom::Role::kMenuListPopup: + return "menuListPopup"; + case ax::mojom::Role::kMeter: + return "meter"; + case ax::mojom::Role::kNavigation: + return "navigation"; + case ax::mojom::Role::kNote: + return "note"; + case ax::mojom::Role::kPane: + return "pane"; + case ax::mojom::Role::kParagraph: + return "paragraph"; + case ax::mojom::Role::kPopUpButton: + return "popUpButton"; + case ax::mojom::Role::kPre: + return "pre"; + case ax::mojom::Role::kPresentational: + return "presentational"; + case ax::mojom::Role::kProgressIndicator: + return "progressIndicator"; + case ax::mojom::Role::kRadioButton: + return "radioButton"; + case ax::mojom::Role::kRadioGroup: + return "radioGroup"; + case ax::mojom::Role::kRegion: + return "region"; + case ax::mojom::Role::kRootWebArea: + return "rootWebArea"; + case ax::mojom::Role::kRowHeader: + return "rowHeader"; + case ax::mojom::Role::kRow: + return "row"; + case ax::mojom::Role::kRuby: + return "ruby"; + case ax::mojom::Role::kSvgRoot: + return "svgRoot"; + case ax::mojom::Role::kScrollBar: + return "scrollBar"; + case ax::mojom::Role::kSearch: + return "search"; + case ax::mojom::Role::kSearchBox: + return "searchBox"; + case ax::mojom::Role::kSlider: + return "slider"; + case ax::mojom::Role::kSliderThumb: + return "sliderThumb"; + case ax::mojom::Role::kSpinButtonPart: + return "spinButtonPart"; + case ax::mojom::Role::kSpinButton: + return "spinButton"; + case ax::mojom::Role::kSplitter: + return "splitter"; + case ax::mojom::Role::kStaticText: + return "staticText"; + case ax::mojom::Role::kStatus: + return "status"; + case ax::mojom::Role::kSwitch: + return "switch"; + case ax::mojom::Role::kTabList: + return "tabList"; + case ax::mojom::Role::kTabPanel: + return "tabPanel"; + case ax::mojom::Role::kTab: + return "tab"; + case ax::mojom::Role::kTableHeaderContainer: + return "tableHeaderContainer"; + case ax::mojom::Role::kTable: + return "table"; + case ax::mojom::Role::kTerm: + return "term"; + case ax::mojom::Role::kTextField: + return "textField"; + case ax::mojom::Role::kTextFieldWithComboBox: + return "textFieldWithComboBox"; + case ax::mojom::Role::kTime: + return "time"; + case ax::mojom::Role::kTimer: + return "timer"; + case ax::mojom::Role::kTitleBar: + return "titleBar"; + case ax::mojom::Role::kToggleButton: + return "toggleButton"; + case ax::mojom::Role::kToolbar: + return "toolbar"; + case ax::mojom::Role::kTreeGrid: + return "treeGrid"; + case ax::mojom::Role::kTreeItem: + return "treeItem"; + case ax::mojom::Role::kTree: + return "tree"; + case ax::mojom::Role::kUnknown: + return "unknown"; + case ax::mojom::Role::kTooltip: + return "tooltip"; + case ax::mojom::Role::kVideo: + return "video"; + case ax::mojom::Role::kWebArea: + return "webArea"; + case ax::mojom::Role::kWebView: + return "webView"; + case ax::mojom::Role::kWindow: + return "window"; + } + + return ""; +} + +ax::mojom::Role ParseRole(const char* role) { + if (0 == strcmp(role, "none")) + return ax::mojom::Role::kNone; + if (0 == strcmp(role, "abbr")) + return ax::mojom::Role::kAbbr; + if (0 == strcmp(role, "alertDialog")) + return ax::mojom::Role::kAlertDialog; + if (0 == strcmp(role, "alert")) + return ax::mojom::Role::kAlert; + if (0 == strcmp(role, "anchor")) + return ax::mojom::Role::kAnchor; + if (0 == strcmp(role, "annotation")) + return ax::mojom::Role::kAnnotation; + if (0 == strcmp(role, "application")) + return ax::mojom::Role::kApplication; + if (0 == strcmp(role, "article")) + return ax::mojom::Role::kArticle; + if (0 == strcmp(role, "audio")) + return ax::mojom::Role::kAudio; + if (0 == strcmp(role, "banner")) + return ax::mojom::Role::kBanner; + if (0 == strcmp(role, "blockquote")) + return ax::mojom::Role::kBlockquote; + if (0 == strcmp(role, "button")) + return ax::mojom::Role::kButton; + if (0 == strcmp(role, "canvas")) + return ax::mojom::Role::kCanvas; + if (0 == strcmp(role, "caption")) + return ax::mojom::Role::kCaption; + if (0 == strcmp(role, "caret")) + return ax::mojom::Role::kCaret; + if (0 == strcmp(role, "cell")) + return ax::mojom::Role::kCell; + if (0 == strcmp(role, "checkBox")) + return ax::mojom::Role::kCheckBox; + if (0 == strcmp(role, "client")) + return ax::mojom::Role::kClient; + if (0 == strcmp(role, "colorWell")) + return ax::mojom::Role::kColorWell; + if (0 == strcmp(role, "columnHeader")) + return ax::mojom::Role::kColumnHeader; + if (0 == strcmp(role, "column")) + return ax::mojom::Role::kColumn; + if (0 == strcmp(role, "comboBoxGrouping")) + return ax::mojom::Role::kComboBoxGrouping; + if (0 == strcmp(role, "comboBoxMenuButton")) + return ax::mojom::Role::kComboBoxMenuButton; + if (0 == strcmp(role, "complementary")) + return ax::mojom::Role::kComplementary; + if (0 == strcmp(role, "contentInfo")) + return ax::mojom::Role::kContentInfo; + if (0 == strcmp(role, "date")) + return ax::mojom::Role::kDate; + if (0 == strcmp(role, "dateTime")) + return ax::mojom::Role::kDateTime; + if (0 == strcmp(role, "definition")) + return ax::mojom::Role::kDefinition; + if (0 == strcmp(role, "descriptionListDetail")) + return ax::mojom::Role::kDescriptionListDetail; + if (0 == strcmp(role, "descriptionList")) + return ax::mojom::Role::kDescriptionList; + if (0 == strcmp(role, "descriptionListTerm")) + return ax::mojom::Role::kDescriptionListTerm; + if (0 == strcmp(role, "desktop")) + return ax::mojom::Role::kDesktop; + if (0 == strcmp(role, "details")) + return ax::mojom::Role::kDetails; + if (0 == strcmp(role, "dialog")) + return ax::mojom::Role::kDialog; + if (0 == strcmp(role, "directory")) + return ax::mojom::Role::kDirectory; + if (0 == strcmp(role, "disclosureTriangle")) + return ax::mojom::Role::kDisclosureTriangle; + if (0 == strcmp(role, "document")) + return ax::mojom::Role::kDocument; + if (0 == strcmp(role, "embeddedObject")) + return ax::mojom::Role::kEmbeddedObject; + if (0 == strcmp(role, "feed")) + return ax::mojom::Role::kFeed; + if (0 == strcmp(role, "figcaption")) + return ax::mojom::Role::kFigcaption; + if (0 == strcmp(role, "figure")) + return ax::mojom::Role::kFigure; + if (0 == strcmp(role, "footer")) + return ax::mojom::Role::kFooter; + if (0 == strcmp(role, "form")) + return ax::mojom::Role::kForm; + if (0 == strcmp(role, "genericContainer")) + return ax::mojom::Role::kGenericContainer; + if (0 == strcmp(role, "grid")) + return ax::mojom::Role::kGrid; + if (0 == strcmp(role, "group")) + return ax::mojom::Role::kGroup; + if (0 == strcmp(role, "heading")) + return ax::mojom::Role::kHeading; + if (0 == strcmp(role, "iframe")) + return ax::mojom::Role::kIframe; + if (0 == strcmp(role, "iframePresentational")) + return ax::mojom::Role::kIframePresentational; + if (0 == strcmp(role, "ignored")) + return ax::mojom::Role::kIgnored; + if (0 == strcmp(role, "imageMap")) + return ax::mojom::Role::kImageMap; + if (0 == strcmp(role, "image")) + return ax::mojom::Role::kImage; + if (0 == strcmp(role, "inlineTextBox")) + return ax::mojom::Role::kInlineTextBox; + if (0 == strcmp(role, "inputTime")) + return ax::mojom::Role::kInputTime; + if (0 == strcmp(role, "labelText")) + return ax::mojom::Role::kLabelText; + if (0 == strcmp(role, "legend")) + return ax::mojom::Role::kLegend; + if (0 == strcmp(role, "lineBreak")) + return ax::mojom::Role::kLineBreak; + if (0 == strcmp(role, "link")) + return ax::mojom::Role::kLink; + if (0 == strcmp(role, "listBoxOption")) + return ax::mojom::Role::kListBoxOption; + if (0 == strcmp(role, "listBox")) + return ax::mojom::Role::kListBox; + if (0 == strcmp(role, "listItem")) + return ax::mojom::Role::kListItem; + if (0 == strcmp(role, "listMarker")) + return ax::mojom::Role::kListMarker; + if (0 == strcmp(role, "list")) + return ax::mojom::Role::kList; + if (0 == strcmp(role, "locationBar")) + return ax::mojom::Role::kLocationBar; + if (0 == strcmp(role, "log")) + return ax::mojom::Role::kLog; + if (0 == strcmp(role, "main")) + return ax::mojom::Role::kMain; + if (0 == strcmp(role, "mark")) + return ax::mojom::Role::kMark; + if (0 == strcmp(role, "marquee")) + return ax::mojom::Role::kMarquee; + if (0 == strcmp(role, "math")) + return ax::mojom::Role::kMath; + if (0 == strcmp(role, "menu")) + return ax::mojom::Role::kMenu; + if (0 == strcmp(role, "menuBar")) + return ax::mojom::Role::kMenuBar; + if (0 == strcmp(role, "menuButton")) + return ax::mojom::Role::kMenuButton; + if (0 == strcmp(role, "menuItem")) + return ax::mojom::Role::kMenuItem; + if (0 == strcmp(role, "menuItemCheckBox")) + return ax::mojom::Role::kMenuItemCheckBox; + if (0 == strcmp(role, "menuItemRadio")) + return ax::mojom::Role::kMenuItemRadio; + if (0 == strcmp(role, "menuListOption")) + return ax::mojom::Role::kMenuListOption; + if (0 == strcmp(role, "menuListPopup")) + return ax::mojom::Role::kMenuListPopup; + if (0 == strcmp(role, "meter")) + return ax::mojom::Role::kMeter; + if (0 == strcmp(role, "navigation")) + return ax::mojom::Role::kNavigation; + if (0 == strcmp(role, "note")) + return ax::mojom::Role::kNote; + if (0 == strcmp(role, "pane")) + return ax::mojom::Role::kPane; + if (0 == strcmp(role, "paragraph")) + return ax::mojom::Role::kParagraph; + if (0 == strcmp(role, "popUpButton")) + return ax::mojom::Role::kPopUpButton; + if (0 == strcmp(role, "pre")) + return ax::mojom::Role::kPre; + if (0 == strcmp(role, "presentational")) + return ax::mojom::Role::kPresentational; + if (0 == strcmp(role, "progressIndicator")) + return ax::mojom::Role::kProgressIndicator; + if (0 == strcmp(role, "radioButton")) + return ax::mojom::Role::kRadioButton; + if (0 == strcmp(role, "radioGroup")) + return ax::mojom::Role::kRadioGroup; + if (0 == strcmp(role, "region")) + return ax::mojom::Role::kRegion; + if (0 == strcmp(role, "rootWebArea")) + return ax::mojom::Role::kRootWebArea; + if (0 == strcmp(role, "rowHeader")) + return ax::mojom::Role::kRowHeader; + if (0 == strcmp(role, "row")) + return ax::mojom::Role::kRow; + if (0 == strcmp(role, "ruby")) + return ax::mojom::Role::kRuby; + if (0 == strcmp(role, "svgRoot")) + return ax::mojom::Role::kSvgRoot; + if (0 == strcmp(role, "scrollBar")) + return ax::mojom::Role::kScrollBar; + if (0 == strcmp(role, "search")) + return ax::mojom::Role::kSearch; + if (0 == strcmp(role, "searchBox")) + return ax::mojom::Role::kSearchBox; + if (0 == strcmp(role, "slider")) + return ax::mojom::Role::kSlider; + if (0 == strcmp(role, "sliderThumb")) + return ax::mojom::Role::kSliderThumb; + if (0 == strcmp(role, "spinButtonPart")) + return ax::mojom::Role::kSpinButtonPart; + if (0 == strcmp(role, "spinButton")) + return ax::mojom::Role::kSpinButton; + if (0 == strcmp(role, "splitter")) + return ax::mojom::Role::kSplitter; + if (0 == strcmp(role, "staticText")) + return ax::mojom::Role::kStaticText; + if (0 == strcmp(role, "status")) + return ax::mojom::Role::kStatus; + if (0 == strcmp(role, "switch")) + return ax::mojom::Role::kSwitch; + if (0 == strcmp(role, "tabList")) + return ax::mojom::Role::kTabList; + if (0 == strcmp(role, "tabPanel")) + return ax::mojom::Role::kTabPanel; + if (0 == strcmp(role, "tab")) + return ax::mojom::Role::kTab; + if (0 == strcmp(role, "tableHeaderContainer")) + return ax::mojom::Role::kTableHeaderContainer; + if (0 == strcmp(role, "table")) + return ax::mojom::Role::kTable; + if (0 == strcmp(role, "term")) + return ax::mojom::Role::kTerm; + if (0 == strcmp(role, "textField")) + return ax::mojom::Role::kTextField; + if (0 == strcmp(role, "textFieldWithComboBox")) + return ax::mojom::Role::kTextFieldWithComboBox; + if (0 == strcmp(role, "time")) + return ax::mojom::Role::kTime; + if (0 == strcmp(role, "timer")) + return ax::mojom::Role::kTimer; + if (0 == strcmp(role, "titleBar")) + return ax::mojom::Role::kTitleBar; + if (0 == strcmp(role, "toggleButton")) + return ax::mojom::Role::kToggleButton; + if (0 == strcmp(role, "toolbar")) + return ax::mojom::Role::kToolbar; + if (0 == strcmp(role, "treeGrid")) + return ax::mojom::Role::kTreeGrid; + if (0 == strcmp(role, "treeItem")) + return ax::mojom::Role::kTreeItem; + if (0 == strcmp(role, "tree")) + return ax::mojom::Role::kTree; + if (0 == strcmp(role, "unknown")) + return ax::mojom::Role::kUnknown; + if (0 == strcmp(role, "tooltip")) + return ax::mojom::Role::kTooltip; + if (0 == strcmp(role, "video")) + return ax::mojom::Role::kVideo; + if (0 == strcmp(role, "webArea")) + return ax::mojom::Role::kWebArea; + if (0 == strcmp(role, "webView")) + return ax::mojom::Role::kWebView; + if (0 == strcmp(role, "window")) + return ax::mojom::Role::kWindow; + return ax::mojom::Role::kNone; +} + +const char* ToString(ax::mojom::State state) { + switch (state) { + case ax::mojom::State::kNone: + return "none"; + case ax::mojom::State::kCollapsed: + return "collapsed"; + case ax::mojom::State::kDefault: + return "default"; + case ax::mojom::State::kEditable: + return "editable"; + case ax::mojom::State::kExpanded: + return "expanded"; + case ax::mojom::State::kFocusable: + return "focusable"; + case ax::mojom::State::kHaspopup: + return "haspopup"; + case ax::mojom::State::kHorizontal: + return "horizontal"; + case ax::mojom::State::kHovered: + return "hovered"; + case ax::mojom::State::kInvisible: + return "invisible"; + case ax::mojom::State::kLinked: + return "linked"; + case ax::mojom::State::kMultiline: + return "multiline"; + case ax::mojom::State::kMultiselectable: + return "multiselectable"; + case ax::mojom::State::kProtected: + return "protected"; + case ax::mojom::State::kRequired: + return "required"; + case ax::mojom::State::kRichlyEditable: + return "richlyEditable"; + case ax::mojom::State::kSelectable: + return "selectable"; + case ax::mojom::State::kSelected: + return "selected"; + case ax::mojom::State::kVertical: + return "vertical"; + case ax::mojom::State::kVisited: + return "visited"; + } + + return ""; +} + +ax::mojom::State ParseState(const char* state) { + if (0 == strcmp(state, "none")) + return ax::mojom::State::kNone; + if (0 == strcmp(state, "collapsed")) + return ax::mojom::State::kCollapsed; + if (0 == strcmp(state, "default")) + return ax::mojom::State::kDefault; + if (0 == strcmp(state, "editable")) + return ax::mojom::State::kEditable; + if (0 == strcmp(state, "expanded")) + return ax::mojom::State::kExpanded; + if (0 == strcmp(state, "focusable")) + return ax::mojom::State::kFocusable; + if (0 == strcmp(state, "haspopup")) + return ax::mojom::State::kHaspopup; + if (0 == strcmp(state, "horizontal")) + return ax::mojom::State::kHorizontal; + if (0 == strcmp(state, "hovered")) + return ax::mojom::State::kHovered; + if (0 == strcmp(state, "invisible")) + return ax::mojom::State::kInvisible; + if (0 == strcmp(state, "linked")) + return ax::mojom::State::kLinked; + if (0 == strcmp(state, "multiline")) + return ax::mojom::State::kMultiline; + if (0 == strcmp(state, "multiselectable")) + return ax::mojom::State::kMultiselectable; + if (0 == strcmp(state, "protected")) + return ax::mojom::State::kProtected; + if (0 == strcmp(state, "required")) + return ax::mojom::State::kRequired; + if (0 == strcmp(state, "richlyEditable")) + return ax::mojom::State::kRichlyEditable; + if (0 == strcmp(state, "selectable")) + return ax::mojom::State::kSelectable; + if (0 == strcmp(state, "selected")) + return ax::mojom::State::kSelected; + if (0 == strcmp(state, "vertical")) + return ax::mojom::State::kVertical; + if (0 == strcmp(state, "visited")) + return ax::mojom::State::kVisited; + return ax::mojom::State::kNone; +} + +const char* ToString(ax::mojom::Action action) { + switch (action) { + case ax::mojom::Action::kNone: + return "none"; + case ax::mojom::Action::kBlur: + return "blur"; + case ax::mojom::Action::kCustomAction: + return "customAction"; + case ax::mojom::Action::kDecrement: + return "decrement"; + case ax::mojom::Action::kDoDefault: + return "doDefault"; + case ax::mojom::Action::kFocus: + return "focus"; + case ax::mojom::Action::kGetImageData: + return "getImageData"; + case ax::mojom::Action::kHitTest: + return "hitTest"; + case ax::mojom::Action::kIncrement: + return "increment"; + case ax::mojom::Action::kLoadInlineTextBoxes: + return "loadInlineTextBoxes"; + case ax::mojom::Action::kReplaceSelectedText: + return "replaceSelectedText"; + case ax::mojom::Action::kScrollBackward: + return "scrollBackward"; + case ax::mojom::Action::kScrollForward: + return "scrollForward"; + case ax::mojom::Action::kScrollUp: + return "scrollUp"; + case ax::mojom::Action::kScrollDown: + return "scrollDown"; + case ax::mojom::Action::kScrollLeft: + return "scrollLeft"; + case ax::mojom::Action::kScrollRight: + return "scrollRight"; + case ax::mojom::Action::kScrollToMakeVisible: + return "scrollToMakeVisible"; + case ax::mojom::Action::kScrollToPoint: + return "scrollToPoint"; + case ax::mojom::Action::kSetScrollOffset: + return "setScrollOffset"; + case ax::mojom::Action::kSetSelection: + return "setSelection"; + case ax::mojom::Action::kSetSequentialFocusNavigationStartingPoint: + return "setSequentialFocusNavigationStartingPoint"; + case ax::mojom::Action::kSetValue: + return "setValue"; + case ax::mojom::Action::kShowContextMenu: + return "showContextMenu"; + } + + return ""; +} + +ax::mojom::Action ParseAction(const char* action) { + if (0 == strcmp(action, "none")) + return ax::mojom::Action::kNone; + if (0 == strcmp(action, "blur")) + return ax::mojom::Action::kBlur; + if (0 == strcmp(action, "customAction")) + return ax::mojom::Action::kCustomAction; + if (0 == strcmp(action, "decrement")) + return ax::mojom::Action::kDecrement; + if (0 == strcmp(action, "doDefault")) + return ax::mojom::Action::kDoDefault; + if (0 == strcmp(action, "focus")) + return ax::mojom::Action::kFocus; + if (0 == strcmp(action, "getImageData")) + return ax::mojom::Action::kGetImageData; + if (0 == strcmp(action, "hitTest")) + return ax::mojom::Action::kHitTest; + if (0 == strcmp(action, "increment")) + return ax::mojom::Action::kIncrement; + if (0 == strcmp(action, "loadInlineTextBoxes")) + return ax::mojom::Action::kLoadInlineTextBoxes; + if (0 == strcmp(action, "replaceSelectedText")) + return ax::mojom::Action::kReplaceSelectedText; + if (0 == strcmp(action, "scrollBackward")) + return ax::mojom::Action::kScrollBackward; + if (0 == strcmp(action, "scrollForward")) + return ax::mojom::Action::kScrollForward; + if (0 == strcmp(action, "scrollUp")) + return ax::mojom::Action::kScrollUp; + if (0 == strcmp(action, "scrollDown")) + return ax::mojom::Action::kScrollDown; + if (0 == strcmp(action, "scrollLeft")) + return ax::mojom::Action::kScrollLeft; + if (0 == strcmp(action, "scrollRight")) + return ax::mojom::Action::kScrollRight; + if (0 == strcmp(action, "scrollToMakeVisible")) + return ax::mojom::Action::kScrollToMakeVisible; + if (0 == strcmp(action, "scrollToPoint")) + return ax::mojom::Action::kScrollToPoint; + if (0 == strcmp(action, "setScrollOffset")) + return ax::mojom::Action::kSetScrollOffset; + if (0 == strcmp(action, "setSelection")) + return ax::mojom::Action::kSetSelection; + if (0 == strcmp(action, "setSequentialFocusNavigationStartingPoint")) + return ax::mojom::Action::kSetSequentialFocusNavigationStartingPoint; + if (0 == strcmp(action, "setValue")) + return ax::mojom::Action::kSetValue; + if (0 == strcmp(action, "showContextMenu")) + return ax::mojom::Action::kShowContextMenu; + return ax::mojom::Action::kNone; +} + +const char* ToString(ax::mojom::ActionFlags action_flags) { + switch (action_flags) { + case ax::mojom::ActionFlags::kNone: + return "none"; + case ax::mojom::ActionFlags::kRequestImages: + return "requestImages"; + case ax::mojom::ActionFlags::kRequestInlineTextBoxes: + return "requestInlineTextBoxes"; + } + + return ""; +} + +ax::mojom::ActionFlags ParseActionFlags(const char* action_flags) { + if (0 == strcmp(action_flags, "none")) + return ax::mojom::ActionFlags::kNone; + if (0 == strcmp(action_flags, "requestImages")) + return ax::mojom::ActionFlags::kRequestImages; + if (0 == strcmp(action_flags, "requestInlineTextBoxes")) + return ax::mojom::ActionFlags::kRequestInlineTextBoxes; + return ax::mojom::ActionFlags::kNone; +} + +const char* ToString(ax::mojom::DefaultActionVerb default_action_verb) { + switch (default_action_verb) { + case ax::mojom::DefaultActionVerb::kNone: + return "none"; + case ax::mojom::DefaultActionVerb::kActivate: + return "activate"; + case ax::mojom::DefaultActionVerb::kCheck: + return "check"; + case ax::mojom::DefaultActionVerb::kClick: + return "click"; + case ax::mojom::DefaultActionVerb::kClickAncestor: + return "clickAncestor"; + case ax::mojom::DefaultActionVerb::kJump: + return "jump"; + case ax::mojom::DefaultActionVerb::kOpen: + return "open"; + case ax::mojom::DefaultActionVerb::kPress: + return "press"; + case ax::mojom::DefaultActionVerb::kSelect: + return "select"; + case ax::mojom::DefaultActionVerb::kUncheck: + return "uncheck"; + } + + return ""; +} + +ax::mojom::DefaultActionVerb ParseDefaultActionVerb( + const char* default_action_verb) { + if (0 == strcmp(default_action_verb, "none")) + return ax::mojom::DefaultActionVerb::kNone; + if (0 == strcmp(default_action_verb, "activate")) + return ax::mojom::DefaultActionVerb::kActivate; + if (0 == strcmp(default_action_verb, "check")) + return ax::mojom::DefaultActionVerb::kCheck; + if (0 == strcmp(default_action_verb, "click")) + return ax::mojom::DefaultActionVerb::kClick; + if (0 == strcmp(default_action_verb, "clickAncestor")) + return ax::mojom::DefaultActionVerb::kClickAncestor; + if (0 == strcmp(default_action_verb, "jump")) + return ax::mojom::DefaultActionVerb::kJump; + if (0 == strcmp(default_action_verb, "open")) + return ax::mojom::DefaultActionVerb::kOpen; + if (0 == strcmp(default_action_verb, "press")) + return ax::mojom::DefaultActionVerb::kPress; + if (0 == strcmp(default_action_verb, "select")) + return ax::mojom::DefaultActionVerb::kSelect; + if (0 == strcmp(default_action_verb, "uncheck")) + return ax::mojom::DefaultActionVerb::kUncheck; + return ax::mojom::DefaultActionVerb::kNone; +} + +const char* ToString(ax::mojom::Mutation mutation) { + switch (mutation) { + case ax::mojom::Mutation::kNone: + return "none"; + case ax::mojom::Mutation::kNodeCreated: + return "nodeCreated"; + case ax::mojom::Mutation::kSubtreeCreated: + return "subtreeCreated"; + case ax::mojom::Mutation::kNodeChanged: + return "nodeChanged"; + case ax::mojom::Mutation::kNodeRemoved: + return "nodeRemoved"; + } + + return ""; +} + +ax::mojom::Mutation ParseMutation(const char* mutation) { + if (0 == strcmp(mutation, "none")) + return ax::mojom::Mutation::kNone; + if (0 == strcmp(mutation, "nodeCreated")) + return ax::mojom::Mutation::kNodeCreated; + if (0 == strcmp(mutation, "subtreeCreated")) + return ax::mojom::Mutation::kSubtreeCreated; + if (0 == strcmp(mutation, "nodeChanged")) + return ax::mojom::Mutation::kNodeChanged; + if (0 == strcmp(mutation, "nodeRemoved")) + return ax::mojom::Mutation::kNodeRemoved; + return ax::mojom::Mutation::kNone; +} + +const char* ToString(ax::mojom::StringAttribute string_attribute) { + switch (string_attribute) { + case ax::mojom::StringAttribute::kNone: + return "none"; + case ax::mojom::StringAttribute::kAccessKey: + return "accessKey"; + case ax::mojom::StringAttribute::kAriaInvalidValue: + return "ariaInvalidValue"; + case ax::mojom::StringAttribute::kAutoComplete: + return "autoComplete"; + case ax::mojom::StringAttribute::kChromeChannel: + return "chromeChannel"; + case ax::mojom::StringAttribute::kClassName: + return "className"; + case ax::mojom::StringAttribute::kContainerLiveRelevant: + return "containerLiveRelevant"; + case ax::mojom::StringAttribute::kContainerLiveStatus: + return "containerLiveStatus"; + case ax::mojom::StringAttribute::kDescription: + return "description"; + case ax::mojom::StringAttribute::kDisplay: + return "display"; + case ax::mojom::StringAttribute::kFontFamily: + return "fontFamily"; + case ax::mojom::StringAttribute::kHtmlTag: + return "htmlTag"; + case ax::mojom::StringAttribute::kImageDataUrl: + return "imageDataUrl"; + case ax::mojom::StringAttribute::kInnerHtml: + return "innerHtml"; + case ax::mojom::StringAttribute::kKeyShortcuts: + return "keyShortcuts"; + case ax::mojom::StringAttribute::kLanguage: + return "language"; + case ax::mojom::StringAttribute::kName: + return "name"; + case ax::mojom::StringAttribute::kLiveRelevant: + return "liveRelevant"; + case ax::mojom::StringAttribute::kLiveStatus: + return "liveStatus"; + case ax::mojom::StringAttribute::kPlaceholder: + return "placeholder"; + case ax::mojom::StringAttribute::kRole: + return "role"; + case ax::mojom::StringAttribute::kRoleDescription: + return "roleDescription"; + case ax::mojom::StringAttribute::kUrl: + return "url"; + case ax::mojom::StringAttribute::kValue: + return "value"; + } + + return ""; +} + +ax::mojom::StringAttribute ParseStringAttribute(const char* string_attribute) { + if (0 == strcmp(string_attribute, "none")) + return ax::mojom::StringAttribute::kNone; + if (0 == strcmp(string_attribute, "accessKey")) + return ax::mojom::StringAttribute::kAccessKey; + if (0 == strcmp(string_attribute, "ariaInvalidValue")) + return ax::mojom::StringAttribute::kAriaInvalidValue; + if (0 == strcmp(string_attribute, "autoComplete")) + return ax::mojom::StringAttribute::kAutoComplete; + if (0 == strcmp(string_attribute, "chromeChannel")) + return ax::mojom::StringAttribute::kChromeChannel; + if (0 == strcmp(string_attribute, "className")) + return ax::mojom::StringAttribute::kClassName; + if (0 == strcmp(string_attribute, "containerLiveRelevant")) + return ax::mojom::StringAttribute::kContainerLiveRelevant; + if (0 == strcmp(string_attribute, "containerLiveStatus")) + return ax::mojom::StringAttribute::kContainerLiveStatus; + if (0 == strcmp(string_attribute, "description")) + return ax::mojom::StringAttribute::kDescription; + if (0 == strcmp(string_attribute, "display")) + return ax::mojom::StringAttribute::kDisplay; + if (0 == strcmp(string_attribute, "fontFamily")) + return ax::mojom::StringAttribute::kFontFamily; + if (0 == strcmp(string_attribute, "htmlTag")) + return ax::mojom::StringAttribute::kHtmlTag; + if (0 == strcmp(string_attribute, "imageDataUrl")) + return ax::mojom::StringAttribute::kImageDataUrl; + if (0 == strcmp(string_attribute, "innerHtml")) + return ax::mojom::StringAttribute::kInnerHtml; + if (0 == strcmp(string_attribute, "keyShortcuts")) + return ax::mojom::StringAttribute::kKeyShortcuts; + if (0 == strcmp(string_attribute, "language")) + return ax::mojom::StringAttribute::kLanguage; + if (0 == strcmp(string_attribute, "name")) + return ax::mojom::StringAttribute::kName; + if (0 == strcmp(string_attribute, "liveRelevant")) + return ax::mojom::StringAttribute::kLiveRelevant; + if (0 == strcmp(string_attribute, "liveStatus")) + return ax::mojom::StringAttribute::kLiveStatus; + if (0 == strcmp(string_attribute, "placeholder")) + return ax::mojom::StringAttribute::kPlaceholder; + if (0 == strcmp(string_attribute, "role")) + return ax::mojom::StringAttribute::kRole; + if (0 == strcmp(string_attribute, "roleDescription")) + return ax::mojom::StringAttribute::kRoleDescription; + if (0 == strcmp(string_attribute, "url")) + return ax::mojom::StringAttribute::kUrl; + if (0 == strcmp(string_attribute, "value")) + return ax::mojom::StringAttribute::kValue; + return ax::mojom::StringAttribute::kNone; +} + +const char* ToString(ax::mojom::IntAttribute int_attribute) { + switch (int_attribute) { + case ax::mojom::IntAttribute::kNone: + return "none"; + case ax::mojom::IntAttribute::kDefaultActionVerb: + return "defaultActionVerb"; + case ax::mojom::IntAttribute::kScrollX: + return "scrollX"; + case ax::mojom::IntAttribute::kScrollXMin: + return "scrollXMin"; + case ax::mojom::IntAttribute::kScrollXMax: + return "scrollXMax"; + case ax::mojom::IntAttribute::kScrollY: + return "scrollY"; + case ax::mojom::IntAttribute::kScrollYMin: + return "scrollYMin"; + case ax::mojom::IntAttribute::kScrollYMax: + return "scrollYMax"; + case ax::mojom::IntAttribute::kTextSelStart: + return "textSelStart"; + case ax::mojom::IntAttribute::kTextSelEnd: + return "textSelEnd"; + case ax::mojom::IntAttribute::kAriaColumnCount: + return "ariaColumnCount"; + case ax::mojom::IntAttribute::kAriaCellColumnIndex: + return "ariaCellColumnIndex"; + case ax::mojom::IntAttribute::kAriaRowCount: + return "ariaRowCount"; + case ax::mojom::IntAttribute::kAriaCellRowIndex: + return "ariaCellRowIndex"; + case ax::mojom::IntAttribute::kTableRowCount: + return "tableRowCount"; + case ax::mojom::IntAttribute::kTableColumnCount: + return "tableColumnCount"; + case ax::mojom::IntAttribute::kTableHeaderId: + return "tableHeaderId"; + case ax::mojom::IntAttribute::kTableRowIndex: + return "tableRowIndex"; + case ax::mojom::IntAttribute::kTableRowHeaderId: + return "tableRowHeaderId"; + case ax::mojom::IntAttribute::kTableColumnIndex: + return "tableColumnIndex"; + case ax::mojom::IntAttribute::kTableColumnHeaderId: + return "tableColumnHeaderId"; + case ax::mojom::IntAttribute::kTableCellColumnIndex: + return "tableCellColumnIndex"; + case ax::mojom::IntAttribute::kTableCellColumnSpan: + return "tableCellColumnSpan"; + case ax::mojom::IntAttribute::kTableCellRowIndex: + return "tableCellRowIndex"; + case ax::mojom::IntAttribute::kTableCellRowSpan: + return "tableCellRowSpan"; + case ax::mojom::IntAttribute::kSortDirection: + return "sortDirection"; + case ax::mojom::IntAttribute::kHierarchicalLevel: + return "hierarchicalLevel"; + case ax::mojom::IntAttribute::kNameFrom: + return "nameFrom"; + case ax::mojom::IntAttribute::kDescriptionFrom: + return "descriptionFrom"; + case ax::mojom::IntAttribute::kActivedescendantId: + return "activedescendantId"; + case ax::mojom::IntAttribute::kDetailsId: + return "detailsId"; + case ax::mojom::IntAttribute::kErrormessageId: + return "errormessageId"; + case ax::mojom::IntAttribute::kInPageLinkTargetId: + return "inPageLinkTargetId"; + case ax::mojom::IntAttribute::kMemberOfId: + return "memberOfId"; + case ax::mojom::IntAttribute::kNextOnLineId: + return "nextOnLineId"; + case ax::mojom::IntAttribute::kPreviousOnLineId: + return "previousOnLineId"; + case ax::mojom::IntAttribute::kChildTreeId: + return "childTreeId"; + case ax::mojom::IntAttribute::kRestriction: + return "restriction"; + case ax::mojom::IntAttribute::kSetSize: + return "setSize"; + case ax::mojom::IntAttribute::kPosInSet: + return "posInSet"; + case ax::mojom::IntAttribute::kColorValue: + return "colorValue"; + case ax::mojom::IntAttribute::kAriaCurrentState: + return "ariaCurrentState"; + case ax::mojom::IntAttribute::kBackgroundColor: + return "backgroundColor"; + case ax::mojom::IntAttribute::kColor: + return "color"; + case ax::mojom::IntAttribute::kInvalidState: + return "invalidState"; + case ax::mojom::IntAttribute::kCheckedState: + return "checkedState"; + case ax::mojom::IntAttribute::kTextDirection: + return "textDirection"; + case ax::mojom::IntAttribute::kTextStyle: + return "textStyle"; + case ax::mojom::IntAttribute::kPreviousFocusId: + return "previousFocusId"; + case ax::mojom::IntAttribute::kNextFocusId: + return "nextFocusId"; + } + + return ""; +} + +ax::mojom::IntAttribute ParseIntAttribute(const char* int_attribute) { + if (0 == strcmp(int_attribute, "none")) + return ax::mojom::IntAttribute::kNone; + if (0 == strcmp(int_attribute, "defaultActionVerb")) + return ax::mojom::IntAttribute::kDefaultActionVerb; + if (0 == strcmp(int_attribute, "scrollX")) + return ax::mojom::IntAttribute::kScrollX; + if (0 == strcmp(int_attribute, "scrollXMin")) + return ax::mojom::IntAttribute::kScrollXMin; + if (0 == strcmp(int_attribute, "scrollXMax")) + return ax::mojom::IntAttribute::kScrollXMax; + if (0 == strcmp(int_attribute, "scrollY")) + return ax::mojom::IntAttribute::kScrollY; + if (0 == strcmp(int_attribute, "scrollYMin")) + return ax::mojom::IntAttribute::kScrollYMin; + if (0 == strcmp(int_attribute, "scrollYMax")) + return ax::mojom::IntAttribute::kScrollYMax; + if (0 == strcmp(int_attribute, "textSelStart")) + return ax::mojom::IntAttribute::kTextSelStart; + if (0 == strcmp(int_attribute, "textSelEnd")) + return ax::mojom::IntAttribute::kTextSelEnd; + if (0 == strcmp(int_attribute, "ariaColumnCount")) + return ax::mojom::IntAttribute::kAriaColumnCount; + if (0 == strcmp(int_attribute, "ariaCellColumnIndex")) + return ax::mojom::IntAttribute::kAriaCellColumnIndex; + if (0 == strcmp(int_attribute, "ariaRowCount")) + return ax::mojom::IntAttribute::kAriaRowCount; + if (0 == strcmp(int_attribute, "ariaCellRowIndex")) + return ax::mojom::IntAttribute::kAriaCellRowIndex; + if (0 == strcmp(int_attribute, "tableRowCount")) + return ax::mojom::IntAttribute::kTableRowCount; + if (0 == strcmp(int_attribute, "tableColumnCount")) + return ax::mojom::IntAttribute::kTableColumnCount; + if (0 == strcmp(int_attribute, "tableHeaderId")) + return ax::mojom::IntAttribute::kTableHeaderId; + if (0 == strcmp(int_attribute, "tableRowIndex")) + return ax::mojom::IntAttribute::kTableRowIndex; + if (0 == strcmp(int_attribute, "tableRowHeaderId")) + return ax::mojom::IntAttribute::kTableRowHeaderId; + if (0 == strcmp(int_attribute, "tableColumnIndex")) + return ax::mojom::IntAttribute::kTableColumnIndex; + if (0 == strcmp(int_attribute, "tableColumnHeaderId")) + return ax::mojom::IntAttribute::kTableColumnHeaderId; + if (0 == strcmp(int_attribute, "tableCellColumnIndex")) + return ax::mojom::IntAttribute::kTableCellColumnIndex; + if (0 == strcmp(int_attribute, "tableCellColumnSpan")) + return ax::mojom::IntAttribute::kTableCellColumnSpan; + if (0 == strcmp(int_attribute, "tableCellRowIndex")) + return ax::mojom::IntAttribute::kTableCellRowIndex; + if (0 == strcmp(int_attribute, "tableCellRowSpan")) + return ax::mojom::IntAttribute::kTableCellRowSpan; + if (0 == strcmp(int_attribute, "sortDirection")) + return ax::mojom::IntAttribute::kSortDirection; + if (0 == strcmp(int_attribute, "hierarchicalLevel")) + return ax::mojom::IntAttribute::kHierarchicalLevel; + if (0 == strcmp(int_attribute, "nameFrom")) + return ax::mojom::IntAttribute::kNameFrom; + if (0 == strcmp(int_attribute, "descriptionFrom")) + return ax::mojom::IntAttribute::kDescriptionFrom; + if (0 == strcmp(int_attribute, "activedescendantId")) + return ax::mojom::IntAttribute::kActivedescendantId; + if (0 == strcmp(int_attribute, "detailsId")) + return ax::mojom::IntAttribute::kDetailsId; + if (0 == strcmp(int_attribute, "errormessageId")) + return ax::mojom::IntAttribute::kErrormessageId; + if (0 == strcmp(int_attribute, "inPageLinkTargetId")) + return ax::mojom::IntAttribute::kInPageLinkTargetId; + if (0 == strcmp(int_attribute, "memberOfId")) + return ax::mojom::IntAttribute::kMemberOfId; + if (0 == strcmp(int_attribute, "nextOnLineId")) + return ax::mojom::IntAttribute::kNextOnLineId; + if (0 == strcmp(int_attribute, "previousOnLineId")) + return ax::mojom::IntAttribute::kPreviousOnLineId; + if (0 == strcmp(int_attribute, "childTreeId")) + return ax::mojom::IntAttribute::kChildTreeId; + if (0 == strcmp(int_attribute, "restriction")) + return ax::mojom::IntAttribute::kRestriction; + if (0 == strcmp(int_attribute, "setSize")) + return ax::mojom::IntAttribute::kSetSize; + if (0 == strcmp(int_attribute, "posInSet")) + return ax::mojom::IntAttribute::kPosInSet; + if (0 == strcmp(int_attribute, "colorValue")) + return ax::mojom::IntAttribute::kColorValue; + if (0 == strcmp(int_attribute, "ariaCurrentState")) + return ax::mojom::IntAttribute::kAriaCurrentState; + if (0 == strcmp(int_attribute, "backgroundColor")) + return ax::mojom::IntAttribute::kBackgroundColor; + if (0 == strcmp(int_attribute, "color")) + return ax::mojom::IntAttribute::kColor; + if (0 == strcmp(int_attribute, "invalidState")) + return ax::mojom::IntAttribute::kInvalidState; + if (0 == strcmp(int_attribute, "checkedState")) + return ax::mojom::IntAttribute::kCheckedState; + if (0 == strcmp(int_attribute, "textDirection")) + return ax::mojom::IntAttribute::kTextDirection; + if (0 == strcmp(int_attribute, "textStyle")) + return ax::mojom::IntAttribute::kTextStyle; + if (0 == strcmp(int_attribute, "previousFocusId")) + return ax::mojom::IntAttribute::kPreviousFocusId; + if (0 == strcmp(int_attribute, "nextFocusId")) + return ax::mojom::IntAttribute::kNextFocusId; + return ax::mojom::IntAttribute::kNone; +} + +const char* ToString(ax::mojom::FloatAttribute float_attribute) { + switch (float_attribute) { + case ax::mojom::FloatAttribute::kNone: + return "none"; + case ax::mojom::FloatAttribute::kValueForRange: + return "valueForRange"; + case ax::mojom::FloatAttribute::kMinValueForRange: + return "minValueForRange"; + case ax::mojom::FloatAttribute::kMaxValueForRange: + return "maxValueForRange"; + case ax::mojom::FloatAttribute::kStepValueForRange: + return "stepValueForRange"; + case ax::mojom::FloatAttribute::kFontSize: + return "fontSize"; + } + + return ""; +} + +ax::mojom::FloatAttribute ParseFloatAttribute(const char* float_attribute) { + if (0 == strcmp(float_attribute, "none")) + return ax::mojom::FloatAttribute::kNone; + if (0 == strcmp(float_attribute, "valueForRange")) + return ax::mojom::FloatAttribute::kValueForRange; + if (0 == strcmp(float_attribute, "minValueForRange")) + return ax::mojom::FloatAttribute::kMinValueForRange; + if (0 == strcmp(float_attribute, "maxValueForRange")) + return ax::mojom::FloatAttribute::kMaxValueForRange; + if (0 == strcmp(float_attribute, "stepValueForRange")) + return ax::mojom::FloatAttribute::kStepValueForRange; + if (0 == strcmp(float_attribute, "fontSize")) + return ax::mojom::FloatAttribute::kFontSize; + return ax::mojom::FloatAttribute::kNone; +} + +const char* ToString(ax::mojom::BoolAttribute bool_attribute) { + switch (bool_attribute) { + case ax::mojom::BoolAttribute::kNone: + return "none"; + case ax::mojom::BoolAttribute::kBusy: + return "busy"; + case ax::mojom::BoolAttribute::kEditableRoot: + return "editableRoot"; + case ax::mojom::BoolAttribute::kContainerLiveAtomic: + return "containerLiveAtomic"; + case ax::mojom::BoolAttribute::kContainerLiveBusy: + return "containerLiveBusy"; + case ax::mojom::BoolAttribute::kLiveAtomic: + return "liveAtomic"; + case ax::mojom::BoolAttribute::kModal: + return "modal"; + case ax::mojom::BoolAttribute::kUpdateLocationOnly: + return "updateLocationOnly"; + case ax::mojom::BoolAttribute::kCanvasHasFallback: + return "canvasHasFallback"; + case ax::mojom::BoolAttribute::kScrollable: + return "scrollable"; + case ax::mojom::BoolAttribute::kClickable: + return "clickable"; + case ax::mojom::BoolAttribute::kClipsChildren: + return "clipsChildren"; + } + + return ""; +} + +ax::mojom::BoolAttribute ParseBoolAttribute(const char* bool_attribute) { + if (0 == strcmp(bool_attribute, "none")) + return ax::mojom::BoolAttribute::kNone; + if (0 == strcmp(bool_attribute, "busy")) + return ax::mojom::BoolAttribute::kBusy; + if (0 == strcmp(bool_attribute, "editableRoot")) + return ax::mojom::BoolAttribute::kEditableRoot; + if (0 == strcmp(bool_attribute, "containerLiveAtomic")) + return ax::mojom::BoolAttribute::kContainerLiveAtomic; + if (0 == strcmp(bool_attribute, "containerLiveBusy")) + return ax::mojom::BoolAttribute::kContainerLiveBusy; + if (0 == strcmp(bool_attribute, "liveAtomic")) + return ax::mojom::BoolAttribute::kLiveAtomic; + if (0 == strcmp(bool_attribute, "modal")) + return ax::mojom::BoolAttribute::kModal; + if (0 == strcmp(bool_attribute, "updateLocationOnly")) + return ax::mojom::BoolAttribute::kUpdateLocationOnly; + if (0 == strcmp(bool_attribute, "canvasHasFallback")) + return ax::mojom::BoolAttribute::kCanvasHasFallback; + if (0 == strcmp(bool_attribute, "scrollable")) + return ax::mojom::BoolAttribute::kScrollable; + if (0 == strcmp(bool_attribute, "clickable")) + return ax::mojom::BoolAttribute::kClickable; + if (0 == strcmp(bool_attribute, "clipsChildren")) + return ax::mojom::BoolAttribute::kClipsChildren; + return ax::mojom::BoolAttribute::kNone; +} + +const char* ToString(ax::mojom::IntListAttribute int_list_attribute) { + switch (int_list_attribute) { + case ax::mojom::IntListAttribute::kNone: + return "none"; + case ax::mojom::IntListAttribute::kIndirectChildIds: + return "indirectChildIds"; + case ax::mojom::IntListAttribute::kControlsIds: + return "controlsIds"; + case ax::mojom::IntListAttribute::kDescribedbyIds: + return "describedbyIds"; + case ax::mojom::IntListAttribute::kFlowtoIds: + return "flowtoIds"; + case ax::mojom::IntListAttribute::kLabelledbyIds: + return "labelledbyIds"; + case ax::mojom::IntListAttribute::kRadioGroupIds: + return "radioGroupIds"; + case ax::mojom::IntListAttribute::kLineBreaks: + return "lineBreaks"; + case ax::mojom::IntListAttribute::kMarkerTypes: + return "markerTypes"; + case ax::mojom::IntListAttribute::kMarkerStarts: + return "markerStarts"; + case ax::mojom::IntListAttribute::kMarkerEnds: + return "markerEnds"; + case ax::mojom::IntListAttribute::kCellIds: + return "cellIds"; + case ax::mojom::IntListAttribute::kUniqueCellIds: + return "uniqueCellIds"; + case ax::mojom::IntListAttribute::kCharacterOffsets: + return "characterOffsets"; + case ax::mojom::IntListAttribute::kCachedLineStarts: + return "cachedLineStarts"; + case ax::mojom::IntListAttribute::kWordStarts: + return "wordStarts"; + case ax::mojom::IntListAttribute::kWordEnds: + return "wordEnds"; + case ax::mojom::IntListAttribute::kCustomActionIds: + return "customActionIds"; + } + + return ""; +} + +ax::mojom::IntListAttribute ParseIntListAttribute( + const char* int_list_attribute) { + if (0 == strcmp(int_list_attribute, "none")) + return ax::mojom::IntListAttribute::kNone; + if (0 == strcmp(int_list_attribute, "indirectChildIds")) + return ax::mojom::IntListAttribute::kIndirectChildIds; + if (0 == strcmp(int_list_attribute, "controlsIds")) + return ax::mojom::IntListAttribute::kControlsIds; + if (0 == strcmp(int_list_attribute, "describedbyIds")) + return ax::mojom::IntListAttribute::kDescribedbyIds; + if (0 == strcmp(int_list_attribute, "flowtoIds")) + return ax::mojom::IntListAttribute::kFlowtoIds; + if (0 == strcmp(int_list_attribute, "labelledbyIds")) + return ax::mojom::IntListAttribute::kLabelledbyIds; + if (0 == strcmp(int_list_attribute, "radioGroupIds")) + return ax::mojom::IntListAttribute::kRadioGroupIds; + if (0 == strcmp(int_list_attribute, "lineBreaks")) + return ax::mojom::IntListAttribute::kLineBreaks; + if (0 == strcmp(int_list_attribute, "markerTypes")) + return ax::mojom::IntListAttribute::kMarkerTypes; + if (0 == strcmp(int_list_attribute, "markerStarts")) + return ax::mojom::IntListAttribute::kMarkerStarts; + if (0 == strcmp(int_list_attribute, "markerEnds")) + return ax::mojom::IntListAttribute::kMarkerEnds; + if (0 == strcmp(int_list_attribute, "cellIds")) + return ax::mojom::IntListAttribute::kCellIds; + if (0 == strcmp(int_list_attribute, "uniqueCellIds")) + return ax::mojom::IntListAttribute::kUniqueCellIds; + if (0 == strcmp(int_list_attribute, "characterOffsets")) + return ax::mojom::IntListAttribute::kCharacterOffsets; + if (0 == strcmp(int_list_attribute, "cachedLineStarts")) + return ax::mojom::IntListAttribute::kCachedLineStarts; + if (0 == strcmp(int_list_attribute, "wordStarts")) + return ax::mojom::IntListAttribute::kWordStarts; + if (0 == strcmp(int_list_attribute, "wordEnds")) + return ax::mojom::IntListAttribute::kWordEnds; + if (0 == strcmp(int_list_attribute, "customActionIds")) + return ax::mojom::IntListAttribute::kCustomActionIds; + return ax::mojom::IntListAttribute::kNone; +} + +const char* ToString(ax::mojom::StringListAttribute string_list_attribute) { + switch (string_list_attribute) { + case ax::mojom::StringListAttribute::kNone: + return "none"; + case ax::mojom::StringListAttribute::kCustomActionDescriptions: + return "customActionDescriptions"; + } + + return ""; +} + +ax::mojom::StringListAttribute ParseStringListAttribute( + const char* string_list_attribute) { + if (0 == strcmp(string_list_attribute, "none")) + return ax::mojom::StringListAttribute::kNone; + if (0 == strcmp(string_list_attribute, "customActionDescriptions")) + return ax::mojom::StringListAttribute::kCustomActionDescriptions; + return ax::mojom::StringListAttribute::kNone; +} + +const char* ToString(ax::mojom::MarkerType marker_type) { + switch (marker_type) { + case ax::mojom::MarkerType::kNone: + return "none"; + case ax::mojom::MarkerType::kSpelling: + return "spelling"; + case ax::mojom::MarkerType::kGrammar: + return "grammar"; + case ax::mojom::MarkerType::kSpellingGrammar: + return "spellingGrammar"; + case ax::mojom::MarkerType::kTextMatch: + return "textMatch"; + case ax::mojom::MarkerType::kSpellingTextMatch: + return "spellingTextMatch"; + case ax::mojom::MarkerType::kGrammarTextMatch: + return "grammarTextMatch"; + case ax::mojom::MarkerType::kSpellingGrammarTextMatch: + return "spellingGrammarTextMatch"; + case ax::mojom::MarkerType::kActiveSuggestion: + return "activeSuggestion"; + case ax::mojom::MarkerType::kSpellingActiveSuggestion: + return "spellingActiveSuggestion"; + case ax::mojom::MarkerType::kGrammarActiveSuggestion: + return "grammarActiveSuggestion"; + case ax::mojom::MarkerType::kSpellingGrammarActiveSuggestion: + return "spellingGrammarActiveSuggestion"; + case ax::mojom::MarkerType::kTextMatchActiveSuggestion: + return "textMatchActiveSuggestion"; + case ax::mojom::MarkerType::kSpellingTextMatchActiveSuggestion: + return "spellingTextMatchActiveSuggestion"; + case ax::mojom::MarkerType::kGrammarTextMatchActiveSuggestion: + return "grammarTextMatchActiveSuggestion"; + case ax::mojom::MarkerType::kSpellingGrammarTextMatchActiveSuggestion: + return "spellingGrammarTextMatchActiveSuggestion"; + case ax::mojom::MarkerType::kSuggestion: + return "suggestion"; + case ax::mojom::MarkerType::kSpellingSuggestion: + return "spellingSuggestion"; + case ax::mojom::MarkerType::kGrammarSuggestion: + return "grammarSuggestion"; + case ax::mojom::MarkerType::kSpellingGrammarSuggestion: + return "spellingGrammarSuggestion"; + case ax::mojom::MarkerType::kTextMatchSuggestion: + return "textMatchSuggestion"; + case ax::mojom::MarkerType::kSpellingTextMatchSuggestion: + return "spellingTextMatchSuggestion"; + case ax::mojom::MarkerType::kGrammarTextMatchSuggestion: + return "grammarTextMatchSuggestion"; + case ax::mojom::MarkerType::kSpellingGrammarTextMatchSuggestion: + return "spellingGrammarTextMatchSuggestion"; + case ax::mojom::MarkerType::kActiveSuggestionSuggestion: + return "activeSuggestionSuggestion"; + case ax::mojom::MarkerType::kSpellingActiveSuggestionSuggestion: + return "spellingActiveSuggestionSuggestion"; + case ax::mojom::MarkerType::kGrammarActiveSuggestionSuggestion: + return "grammarActiveSuggestionSuggestion"; + case ax::mojom::MarkerType::kSpellingGrammarActiveSuggestionSuggestion: + return "spellingGrammarActiveSuggestionSuggestion"; + case ax::mojom::MarkerType::kTextMatchActiveSuggestionSuggestion: + return "textMatchActiveSuggestionSuggestion"; + case ax::mojom::MarkerType::kSpellingTextMatchActiveSuggestionSuggestion: + return "spellingTextMatchActiveSuggestionSuggestion"; + case ax::mojom::MarkerType::kGrammarTextMatchActiveSuggestionSuggestion: + return "grammarTextMatchActiveSuggestionSuggestion"; + case ax::mojom::MarkerType:: + kSpellingGrammarTextMatchActiveSuggestionSuggestion: + return "spellingGrammarTextMatchActiveSuggestionSuggestion"; + } + + return ""; +} + +ax::mojom::MarkerType ParseMarkerType(const char* marker_type) { + if (0 == strcmp(marker_type, "none")) + return ax::mojom::MarkerType::kNone; + if (0 == strcmp(marker_type, "spelling")) + return ax::mojom::MarkerType::kSpelling; + if (0 == strcmp(marker_type, "grammar")) + return ax::mojom::MarkerType::kGrammar; + if (0 == strcmp(marker_type, "spellingGrammar")) + return ax::mojom::MarkerType::kSpellingGrammar; + if (0 == strcmp(marker_type, "textMatch")) + return ax::mojom::MarkerType::kTextMatch; + if (0 == strcmp(marker_type, "spellingTextMatch")) + return ax::mojom::MarkerType::kSpellingTextMatch; + if (0 == strcmp(marker_type, "grammarTextMatch")) + return ax::mojom::MarkerType::kGrammarTextMatch; + if (0 == strcmp(marker_type, "spellingGrammarTextMatch")) + return ax::mojom::MarkerType::kSpellingGrammarTextMatch; + if (0 == strcmp(marker_type, "activeSuggestion")) + return ax::mojom::MarkerType::kActiveSuggestion; + if (0 == strcmp(marker_type, "spellingActiveSuggestion")) + return ax::mojom::MarkerType::kSpellingActiveSuggestion; + if (0 == strcmp(marker_type, "grammarActiveSuggestion")) + return ax::mojom::MarkerType::kGrammarActiveSuggestion; + if (0 == strcmp(marker_type, "spellingGrammarActiveSuggestion")) + return ax::mojom::MarkerType::kSpellingGrammarActiveSuggestion; + if (0 == strcmp(marker_type, "textMatchActiveSuggestion")) + return ax::mojom::MarkerType::kTextMatchActiveSuggestion; + if (0 == strcmp(marker_type, "spellingTextMatchActiveSuggestion")) + return ax::mojom::MarkerType::kSpellingTextMatchActiveSuggestion; + if (0 == strcmp(marker_type, "grammarTextMatchActiveSuggestion")) + return ax::mojom::MarkerType::kGrammarTextMatchActiveSuggestion; + if (0 == strcmp(marker_type, "spellingGrammarTextMatchActiveSuggestion")) + return ax::mojom::MarkerType::kSpellingGrammarTextMatchActiveSuggestion; + if (0 == strcmp(marker_type, "suggestion")) + return ax::mojom::MarkerType::kSuggestion; + if (0 == strcmp(marker_type, "spellingSuggestion")) + return ax::mojom::MarkerType::kSpellingSuggestion; + if (0 == strcmp(marker_type, "grammarSuggestion")) + return ax::mojom::MarkerType::kGrammarSuggestion; + if (0 == strcmp(marker_type, "spellingGrammarSuggestion")) + return ax::mojom::MarkerType::kSpellingGrammarSuggestion; + if (0 == strcmp(marker_type, "textMatchSuggestion")) + return ax::mojom::MarkerType::kTextMatchSuggestion; + if (0 == strcmp(marker_type, "spellingTextMatchSuggestion")) + return ax::mojom::MarkerType::kSpellingTextMatchSuggestion; + if (0 == strcmp(marker_type, "grammarTextMatchSuggestion")) + return ax::mojom::MarkerType::kGrammarTextMatchSuggestion; + if (0 == strcmp(marker_type, "spellingGrammarTextMatchSuggestion")) + return ax::mojom::MarkerType::kSpellingGrammarTextMatchSuggestion; + if (0 == strcmp(marker_type, "activeSuggestionSuggestion")) + return ax::mojom::MarkerType::kActiveSuggestionSuggestion; + if (0 == strcmp(marker_type, "spellingActiveSuggestionSuggestion")) + return ax::mojom::MarkerType::kSpellingActiveSuggestionSuggestion; + if (0 == strcmp(marker_type, "grammarActiveSuggestionSuggestion")) + return ax::mojom::MarkerType::kGrammarActiveSuggestionSuggestion; + if (0 == strcmp(marker_type, "spellingGrammarActiveSuggestionSuggestion")) + return ax::mojom::MarkerType::kSpellingGrammarActiveSuggestionSuggestion; + if (0 == strcmp(marker_type, "textMatchActiveSuggestionSuggestion")) + return ax::mojom::MarkerType::kTextMatchActiveSuggestionSuggestion; + if (0 == strcmp(marker_type, "spellingTextMatchActiveSuggestionSuggestion")) + return ax::mojom::MarkerType::kSpellingTextMatchActiveSuggestionSuggestion; + if (0 == strcmp(marker_type, "grammarTextMatchActiveSuggestionSuggestion")) + return ax::mojom::MarkerType::kGrammarTextMatchActiveSuggestionSuggestion; + if (0 == + strcmp(marker_type, "spellingGrammarTextMatchActiveSuggestionSuggestion")) + return ax::mojom::MarkerType:: + kSpellingGrammarTextMatchActiveSuggestionSuggestion; + return ax::mojom::MarkerType::kNone; +} + +const char* ToString(ax::mojom::TextDirection text_direction) { + switch (text_direction) { + case ax::mojom::TextDirection::kNone: + return "none"; + case ax::mojom::TextDirection::kLtr: + return "ltr"; + case ax::mojom::TextDirection::kRtl: + return "rtl"; + case ax::mojom::TextDirection::kTtb: + return "ttb"; + case ax::mojom::TextDirection::kBtt: + return "btt"; + } + + return ""; +} + +ax::mojom::TextDirection ParseTextDirection(const char* text_direction) { + if (0 == strcmp(text_direction, "none")) + return ax::mojom::TextDirection::kNone; + if (0 == strcmp(text_direction, "ltr")) + return ax::mojom::TextDirection::kLtr; + if (0 == strcmp(text_direction, "rtl")) + return ax::mojom::TextDirection::kRtl; + if (0 == strcmp(text_direction, "ttb")) + return ax::mojom::TextDirection::kTtb; + if (0 == strcmp(text_direction, "btt")) + return ax::mojom::TextDirection::kBtt; + return ax::mojom::TextDirection::kNone; +} + +const char* ToString(ax::mojom::TextStyle text_style) { + switch (text_style) { + case ax::mojom::TextStyle::kNone: + return "none"; + case ax::mojom::TextStyle::kTextStyleBold: + return "textStyleBold"; + case ax::mojom::TextStyle::kTextStyleItalic: + return "textStyleItalic"; + case ax::mojom::TextStyle::kTextStyleBoldItalic: + return "textStyleBoldItalic"; + case ax::mojom::TextStyle::kTextStyleUnderline: + return "textStyleUnderline"; + case ax::mojom::TextStyle::kTextStyleBoldUnderline: + return "textStyleBoldUnderline"; + case ax::mojom::TextStyle::kTextStyleItalicUnderline: + return "textStyleItalicUnderline"; + case ax::mojom::TextStyle::kTextStyleBoldItalicUnderline: + return "textStyleBoldItalicUnderline"; + case ax::mojom::TextStyle::kTextStyleLineThrough: + return "textStyleLineThrough"; + case ax::mojom::TextStyle::kTextStyleBoldLineThrough: + return "textStyleBoldLineThrough"; + case ax::mojom::TextStyle::kTextStyleItalicLineThrough: + return "textStyleItalicLineThrough"; + case ax::mojom::TextStyle::kTextStyleBoldItalicLineThrough: + return "textStyleBoldItalicLineThrough"; + case ax::mojom::TextStyle::kTextStyleUnderlineLineThrough: + return "textStyleUnderlineLineThrough"; + case ax::mojom::TextStyle::kTextStyleBoldUnderlineLineThrough: + return "textStyleBoldUnderlineLineThrough"; + case ax::mojom::TextStyle::kTextStyleItalicUnderlineLineThrough: + return "textStyleItalicUnderlineLineThrough"; + case ax::mojom::TextStyle::kTextStyleBoldItalicUnderlineLineThrough: + return "textStyleBoldItalicUnderlineLineThrough"; + } + + return ""; +} + +ax::mojom::TextStyle ParseTextStyle(const char* text_style) { + if (0 == strcmp(text_style, "none")) + return ax::mojom::TextStyle::kNone; + if (0 == strcmp(text_style, "textStyleBold")) + return ax::mojom::TextStyle::kTextStyleBold; + if (0 == strcmp(text_style, "textStyleItalic")) + return ax::mojom::TextStyle::kTextStyleItalic; + if (0 == strcmp(text_style, "textStyleBoldItalic")) + return ax::mojom::TextStyle::kTextStyleBoldItalic; + if (0 == strcmp(text_style, "textStyleUnderline")) + return ax::mojom::TextStyle::kTextStyleUnderline; + if (0 == strcmp(text_style, "textStyleBoldUnderline")) + return ax::mojom::TextStyle::kTextStyleBoldUnderline; + if (0 == strcmp(text_style, "textStyleItalicUnderline")) + return ax::mojom::TextStyle::kTextStyleItalicUnderline; + if (0 == strcmp(text_style, "textStyleBoldItalicUnderline")) + return ax::mojom::TextStyle::kTextStyleBoldItalicUnderline; + if (0 == strcmp(text_style, "textStyleLineThrough")) + return ax::mojom::TextStyle::kTextStyleLineThrough; + if (0 == strcmp(text_style, "textStyleBoldLineThrough")) + return ax::mojom::TextStyle::kTextStyleBoldLineThrough; + if (0 == strcmp(text_style, "textStyleItalicLineThrough")) + return ax::mojom::TextStyle::kTextStyleItalicLineThrough; + if (0 == strcmp(text_style, "textStyleBoldItalicLineThrough")) + return ax::mojom::TextStyle::kTextStyleBoldItalicLineThrough; + if (0 == strcmp(text_style, "textStyleUnderlineLineThrough")) + return ax::mojom::TextStyle::kTextStyleUnderlineLineThrough; + if (0 == strcmp(text_style, "textStyleBoldUnderlineLineThrough")) + return ax::mojom::TextStyle::kTextStyleBoldUnderlineLineThrough; + if (0 == strcmp(text_style, "textStyleItalicUnderlineLineThrough")) + return ax::mojom::TextStyle::kTextStyleItalicUnderlineLineThrough; + if (0 == strcmp(text_style, "textStyleBoldItalicUnderlineLineThrough")) + return ax::mojom::TextStyle::kTextStyleBoldItalicUnderlineLineThrough; + return ax::mojom::TextStyle::kNone; +} + +const char* ToString(ax::mojom::AriaCurrentState aria_current_state) { + switch (aria_current_state) { + case ax::mojom::AriaCurrentState::kNone: + return "none"; + case ax::mojom::AriaCurrentState::kFalse: + return "false"; + case ax::mojom::AriaCurrentState::kTrue: + return "true"; + case ax::mojom::AriaCurrentState::kPage: + return "page"; + case ax::mojom::AriaCurrentState::kStep: + return "step"; + case ax::mojom::AriaCurrentState::kLocation: + return "location"; + case ax::mojom::AriaCurrentState::kUnclippedLocation: + return "unclippedLocation"; + case ax::mojom::AriaCurrentState::kDate: + return "date"; + case ax::mojom::AriaCurrentState::kTime: + return "time"; + } + + return ""; +} + +ax::mojom::AriaCurrentState ParseAriaCurrentState( + const char* aria_current_state) { + if (0 == strcmp(aria_current_state, "none")) + return ax::mojom::AriaCurrentState::kNone; + if (0 == strcmp(aria_current_state, "false")) + return ax::mojom::AriaCurrentState::kFalse; + if (0 == strcmp(aria_current_state, "true")) + return ax::mojom::AriaCurrentState::kTrue; + if (0 == strcmp(aria_current_state, "page")) + return ax::mojom::AriaCurrentState::kPage; + if (0 == strcmp(aria_current_state, "step")) + return ax::mojom::AriaCurrentState::kStep; + if (0 == strcmp(aria_current_state, "location")) + return ax::mojom::AriaCurrentState::kLocation; + if (0 == strcmp(aria_current_state, "unclippedLocation")) + return ax::mojom::AriaCurrentState::kUnclippedLocation; + if (0 == strcmp(aria_current_state, "date")) + return ax::mojom::AriaCurrentState::kDate; + if (0 == strcmp(aria_current_state, "time")) + return ax::mojom::AriaCurrentState::kTime; + return ax::mojom::AriaCurrentState::kNone; +} + +const char* ToString(ax::mojom::InvalidState invalid_state) { + switch (invalid_state) { + case ax::mojom::InvalidState::kNone: + return "none"; + case ax::mojom::InvalidState::kFalse: + return "false"; + case ax::mojom::InvalidState::kTrue: + return "true"; + case ax::mojom::InvalidState::kSpelling: + return "spelling"; + case ax::mojom::InvalidState::kGrammar: + return "grammar"; + case ax::mojom::InvalidState::kOther: + return "other"; + } + + return ""; +} + +ax::mojom::InvalidState ParseInvalidState(const char* invalid_state) { + if (0 == strcmp(invalid_state, "none")) + return ax::mojom::InvalidState::kNone; + if (0 == strcmp(invalid_state, "false")) + return ax::mojom::InvalidState::kFalse; + if (0 == strcmp(invalid_state, "true")) + return ax::mojom::InvalidState::kTrue; + if (0 == strcmp(invalid_state, "spelling")) + return ax::mojom::InvalidState::kSpelling; + if (0 == strcmp(invalid_state, "grammar")) + return ax::mojom::InvalidState::kGrammar; + if (0 == strcmp(invalid_state, "other")) + return ax::mojom::InvalidState::kOther; + return ax::mojom::InvalidState::kNone; +} + +const char* ToString(ax::mojom::Restriction restriction) { + switch (restriction) { + case ax::mojom::Restriction::kNone: + return "none"; + case ax::mojom::Restriction::kReadOnly: + return "readOnly"; + case ax::mojom::Restriction::kDisabled: + return "disabled"; + } + + return ""; +} + +ax::mojom::Restriction ParseRestriction(const char* restriction) { + if (0 == strcmp(restriction, "none")) + return ax::mojom::Restriction::kNone; + if (0 == strcmp(restriction, "readOnly")) + return ax::mojom::Restriction::kReadOnly; + if (0 == strcmp(restriction, "disabled")) + return ax::mojom::Restriction::kDisabled; + return ax::mojom::Restriction::kNone; +} + +const char* ToString(ax::mojom::CheckedState checked_state) { + switch (checked_state) { + case ax::mojom::CheckedState::kNone: + return "none"; + case ax::mojom::CheckedState::kFalse: + return "false"; + case ax::mojom::CheckedState::kTrue: + return "true"; + case ax::mojom::CheckedState::kMixed: + return "mixed"; + } + + return ""; +} + +ax::mojom::CheckedState ParseCheckedState(const char* checked_state) { + if (0 == strcmp(checked_state, "none")) + return ax::mojom::CheckedState::kNone; + if (0 == strcmp(checked_state, "false")) + return ax::mojom::CheckedState::kFalse; + if (0 == strcmp(checked_state, "true")) + return ax::mojom::CheckedState::kTrue; + if (0 == strcmp(checked_state, "mixed")) + return ax::mojom::CheckedState::kMixed; + return ax::mojom::CheckedState::kNone; +} + +const char* ToString(ax::mojom::SortDirection sort_direction) { + switch (sort_direction) { + case ax::mojom::SortDirection::kNone: + return "none"; + case ax::mojom::SortDirection::kUnsorted: + return "unsorted"; + case ax::mojom::SortDirection::kAscending: + return "ascending"; + case ax::mojom::SortDirection::kDescending: + return "descending"; + case ax::mojom::SortDirection::kOther: + return "other"; + } + + return ""; +} + +ax::mojom::SortDirection ParseSortDirection(const char* sort_direction) { + if (0 == strcmp(sort_direction, "none")) + return ax::mojom::SortDirection::kNone; + if (0 == strcmp(sort_direction, "unsorted")) + return ax::mojom::SortDirection::kUnsorted; + if (0 == strcmp(sort_direction, "ascending")) + return ax::mojom::SortDirection::kAscending; + if (0 == strcmp(sort_direction, "descending")) + return ax::mojom::SortDirection::kDescending; + if (0 == strcmp(sort_direction, "other")) + return ax::mojom::SortDirection::kOther; + return ax::mojom::SortDirection::kNone; +} + +const char* ToString(ax::mojom::NameFrom name_from) { + switch (name_from) { + case ax::mojom::NameFrom::kNone: + return "none"; + case ax::mojom::NameFrom::kUninitialized: + return "uninitialized"; + case ax::mojom::NameFrom::kAttribute: + return "attribute"; + case ax::mojom::NameFrom::kAttributeExplicitlyEmpty: + return "attributeExplicitlyEmpty"; + case ax::mojom::NameFrom::kContents: + return "contents"; + case ax::mojom::NameFrom::kPlaceholder: + return "placeholder"; + case ax::mojom::NameFrom::kRelatedElement: + return "relatedElement"; + case ax::mojom::NameFrom::kValue: + return "value"; + } + + return ""; +} + +ax::mojom::NameFrom ParseNameFrom(const char* name_from) { + if (0 == strcmp(name_from, "none")) + return ax::mojom::NameFrom::kNone; + if (0 == strcmp(name_from, "uninitialized")) + return ax::mojom::NameFrom::kUninitialized; + if (0 == strcmp(name_from, "attribute")) + return ax::mojom::NameFrom::kAttribute; + if (0 == strcmp(name_from, "attributeExplicitlyEmpty")) + return ax::mojom::NameFrom::kAttributeExplicitlyEmpty; + if (0 == strcmp(name_from, "contents")) + return ax::mojom::NameFrom::kContents; + if (0 == strcmp(name_from, "placeholder")) + return ax::mojom::NameFrom::kPlaceholder; + if (0 == strcmp(name_from, "relatedElement")) + return ax::mojom::NameFrom::kRelatedElement; + if (0 == strcmp(name_from, "value")) + return ax::mojom::NameFrom::kValue; + return ax::mojom::NameFrom::kNone; +} + +const char* ToString(ax::mojom::DescriptionFrom description_from) { + switch (description_from) { + case ax::mojom::DescriptionFrom::kNone: + return "none"; + case ax::mojom::DescriptionFrom::kUninitialized: + return "uninitialized"; + case ax::mojom::DescriptionFrom::kAttribute: + return "attribute"; + case ax::mojom::DescriptionFrom::kContents: + return "contents"; + case ax::mojom::DescriptionFrom::kPlaceholder: + return "placeholder"; + case ax::mojom::DescriptionFrom::kRelatedElement: + return "relatedElement"; + } + + return ""; +} + +ax::mojom::DescriptionFrom ParseDescriptionFrom(const char* description_from) { + if (0 == strcmp(description_from, "none")) + return ax::mojom::DescriptionFrom::kNone; + if (0 == strcmp(description_from, "uninitialized")) + return ax::mojom::DescriptionFrom::kUninitialized; + if (0 == strcmp(description_from, "attribute")) + return ax::mojom::DescriptionFrom::kAttribute; + if (0 == strcmp(description_from, "contents")) + return ax::mojom::DescriptionFrom::kContents; + if (0 == strcmp(description_from, "placeholder")) + return ax::mojom::DescriptionFrom::kPlaceholder; + if (0 == strcmp(description_from, "relatedElement")) + return ax::mojom::DescriptionFrom::kRelatedElement; + return ax::mojom::DescriptionFrom::kNone; +} + +const char* ToString(ax::mojom::EventFrom event_from) { + switch (event_from) { + case ax::mojom::EventFrom::kNone: + return "none"; + case ax::mojom::EventFrom::kUser: + return "user"; + case ax::mojom::EventFrom::kPage: + return "page"; + case ax::mojom::EventFrom::kAction: + return "action"; + } + + return ""; +} + +ax::mojom::EventFrom ParseEventFrom(const char* event_from) { + if (0 == strcmp(event_from, "none")) + return ax::mojom::EventFrom::kNone; + if (0 == strcmp(event_from, "user")) + return ax::mojom::EventFrom::kUser; + if (0 == strcmp(event_from, "page")) + return ax::mojom::EventFrom::kPage; + if (0 == strcmp(event_from, "action")) + return ax::mojom::EventFrom::kAction; + return ax::mojom::EventFrom::kNone; +} + +const char* ToString(ax::mojom::Gesture gesture) { + switch (gesture) { + case ax::mojom::Gesture::kNone: + return "none"; + case ax::mojom::Gesture::kClick: + return "click"; + case ax::mojom::Gesture::kSwipeLeft1: + return "swipeLeft1"; + case ax::mojom::Gesture::kSwipeUp1: + return "swipeUp1"; + case ax::mojom::Gesture::kSwipeRight1: + return "swipeRight1"; + case ax::mojom::Gesture::kSwipeDown1: + return "swipeDown1"; + case ax::mojom::Gesture::kSwipeLeft2: + return "swipeLeft2"; + case ax::mojom::Gesture::kSwipeUp2: + return "swipeUp2"; + case ax::mojom::Gesture::kSwipeRight2: + return "swipeRight2"; + case ax::mojom::Gesture::kSwipeDown2: + return "swipeDown2"; + case ax::mojom::Gesture::kSwipeLeft3: + return "swipeLeft3"; + case ax::mojom::Gesture::kSwipeUp3: + return "swipeUp3"; + case ax::mojom::Gesture::kSwipeRight3: + return "swipeRight3"; + case ax::mojom::Gesture::kSwipeDown3: + return "swipeDown3"; + case ax::mojom::Gesture::kSwipeLeft4: + return "swipeLeft4"; + case ax::mojom::Gesture::kSwipeUp4: + return "swipeUp4"; + case ax::mojom::Gesture::kSwipeRight4: + return "swipeRight4"; + case ax::mojom::Gesture::kSwipeDown4: + return "swipeDown4"; + case ax::mojom::Gesture::kTap2: + return "tap2"; + } + + return ""; +} + +ax::mojom::Gesture ParseGesture(const char* gesture) { + if (0 == strcmp(gesture, "none")) + return ax::mojom::Gesture::kNone; + if (0 == strcmp(gesture, "click")) + return ax::mojom::Gesture::kClick; + if (0 == strcmp(gesture, "swipeLeft1")) + return ax::mojom::Gesture::kSwipeLeft1; + if (0 == strcmp(gesture, "swipeUp1")) + return ax::mojom::Gesture::kSwipeUp1; + if (0 == strcmp(gesture, "swipeRight1")) + return ax::mojom::Gesture::kSwipeRight1; + if (0 == strcmp(gesture, "swipeDown1")) + return ax::mojom::Gesture::kSwipeDown1; + if (0 == strcmp(gesture, "swipeLeft2")) + return ax::mojom::Gesture::kSwipeLeft2; + if (0 == strcmp(gesture, "swipeUp2")) + return ax::mojom::Gesture::kSwipeUp2; + if (0 == strcmp(gesture, "swipeRight2")) + return ax::mojom::Gesture::kSwipeRight2; + if (0 == strcmp(gesture, "swipeDown2")) + return ax::mojom::Gesture::kSwipeDown2; + if (0 == strcmp(gesture, "swipeLeft3")) + return ax::mojom::Gesture::kSwipeLeft3; + if (0 == strcmp(gesture, "swipeUp3")) + return ax::mojom::Gesture::kSwipeUp3; + if (0 == strcmp(gesture, "swipeRight3")) + return ax::mojom::Gesture::kSwipeRight3; + if (0 == strcmp(gesture, "swipeDown3")) + return ax::mojom::Gesture::kSwipeDown3; + if (0 == strcmp(gesture, "swipeLeft4")) + return ax::mojom::Gesture::kSwipeLeft4; + if (0 == strcmp(gesture, "swipeUp4")) + return ax::mojom::Gesture::kSwipeUp4; + if (0 == strcmp(gesture, "swipeRight4")) + return ax::mojom::Gesture::kSwipeRight4; + if (0 == strcmp(gesture, "swipeDown4")) + return ax::mojom::Gesture::kSwipeDown4; + if (0 == strcmp(gesture, "tap2")) + return ax::mojom::Gesture::kTap2; + return ax::mojom::Gesture::kNone; +} + +const char* ToString(ax::mojom::TextAffinity text_affinity) { + switch (text_affinity) { + case ax::mojom::TextAffinity::kNone: + return "none"; + case ax::mojom::TextAffinity::kDownstream: + return "downstream"; + case ax::mojom::TextAffinity::kUpstream: + return "upstream"; + } + + return ""; +} + +ax::mojom::TextAffinity ParseTextAffinity(const char* text_affinity) { + if (0 == strcmp(text_affinity, "none")) + return ax::mojom::TextAffinity::kNone; + if (0 == strcmp(text_affinity, "downstream")) + return ax::mojom::TextAffinity::kDownstream; + if (0 == strcmp(text_affinity, "upstream")) + return ax::mojom::TextAffinity::kUpstream; + return ax::mojom::TextAffinity::kNone; +} + +const char* ToString(ax::mojom::TreeOrder tree_order) { + switch (tree_order) { + case ax::mojom::TreeOrder::kNone: + return "none"; + case ax::mojom::TreeOrder::kUndefined: + return "undefined"; + case ax::mojom::TreeOrder::kBefore: + return "before"; + case ax::mojom::TreeOrder::kEqual: + return "equal"; + case ax::mojom::TreeOrder::kAfter: + return "after"; + } + + return ""; +} + +ax::mojom::TreeOrder ParseTreeOrder(const char* tree_order) { + if (0 == strcmp(tree_order, "none")) + return ax::mojom::TreeOrder::kNone; + if (0 == strcmp(tree_order, "undefined")) + return ax::mojom::TreeOrder::kUndefined; + if (0 == strcmp(tree_order, "before")) + return ax::mojom::TreeOrder::kBefore; + if (0 == strcmp(tree_order, "equal")) + return ax::mojom::TreeOrder::kEqual; + if (0 == strcmp(tree_order, "after")) + return ax::mojom::TreeOrder::kAfter; + return ax::mojom::TreeOrder::kNone; +} + +} // namespace ui diff --git a/ui/accessibility/ax_enum_util.h b/ui/accessibility/ax_enum_util.h new file mode 100644 index 00000000000000..e331b4ea41abbe --- /dev/null +++ b/ui/accessibility/ax_enum_util.h @@ -0,0 +1,130 @@ +// Copyright 2018 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 "ui/accessibility/ax_enums.mojom.h" +#include "ui/accessibility/ax_export.h" + +namespace ui { + +// ax::mojom::Event +AX_EXPORT const char* ToString(ax::mojom::Event event); +AX_EXPORT ax::mojom::Event ParseEvent(const char* event); + +// ax::mojom::Role +AX_EXPORT const char* ToString(ax::mojom::Role role); +AX_EXPORT ax::mojom::Role ParseRole(const char* role); + +// ax::mojom::State +AX_EXPORT const char* ToString(ax::mojom::State state); +AX_EXPORT ax::mojom::State ParseState(const char* state); + +// ax::mojom::Action +AX_EXPORT const char* ToString(ax::mojom::Action action); +AX_EXPORT ax::mojom::Action ParseAction(const char* action); + +// ax::mojom::ActionFlags +AX_EXPORT const char* ToString(ax::mojom::ActionFlags action_flags); +AX_EXPORT ax::mojom::ActionFlags ParseActionFlags(const char* action_flags); + +// ax::mojom::DefaultActionVerb +AX_EXPORT const char* ToString( + ax::mojom::DefaultActionVerb default_action_verb); +AX_EXPORT ax::mojom::DefaultActionVerb ParseDefaultActionVerb( + const char* default_action_verb); + +// ax::mojom::Mutation +AX_EXPORT const char* ToString(ax::mojom::Mutation mutation); +AX_EXPORT ax::mojom::Mutation ParseMutation(const char* mutation); + +// ax::mojom::StringAttribute +AX_EXPORT const char* ToString(ax::mojom::StringAttribute string_attribute); +AX_EXPORT ax::mojom::StringAttribute ParseStringAttribute( + const char* string_attribute); + +// ax::mojom::IntAttribute +AX_EXPORT const char* ToString(ax::mojom::IntAttribute int_attribute); +AX_EXPORT ax::mojom::IntAttribute ParseIntAttribute(const char* int_attribute); + +// ax::mojom::FloatAttribute +AX_EXPORT const char* ToString(ax::mojom::FloatAttribute float_attribute); +AX_EXPORT ax::mojom::FloatAttribute ParseFloatAttribute( + const char* float_attribute); + +// ax::mojom::BoolAttribute +AX_EXPORT const char* ToString(ax::mojom::BoolAttribute bool_attribute); +AX_EXPORT ax::mojom::BoolAttribute ParseBoolAttribute( + const char* bool_attribute); + +// ax::mojom::IntListAttribute +AX_EXPORT const char* ToString(ax::mojom::IntListAttribute int_list_attribute); +AX_EXPORT ax::mojom::IntListAttribute ParseIntListAttribute( + const char* int_list_attribute); + +// ax::mojom::StringListAttribute +AX_EXPORT const char* ToString( + ax::mojom::StringListAttribute string_list_attribute); +AX_EXPORT ax::mojom::StringListAttribute ParseStringListAttribute( + const char* string_list_attribute); + +// ax::mojom::MarkerType +AX_EXPORT const char* ToString(ax::mojom::MarkerType marker_type); +AX_EXPORT ax::mojom::MarkerType ParseMarkerType(const char* marker_type); + +// ax::mojom::TextDirection +AX_EXPORT const char* ToString(ax::mojom::TextDirection text_direction); +AX_EXPORT ax::mojom::TextDirection ParseTextDirection( + const char* text_direction); + +// ax::mojom::TextStyle +AX_EXPORT const char* ToString(ax::mojom::TextStyle text_style); +AX_EXPORT ax::mojom::TextStyle ParseTextStyle(const char* text_style); + +// ax::mojom::AriaCurrentState +AX_EXPORT const char* ToString(ax::mojom::AriaCurrentState aria_current_state); +AX_EXPORT ax::mojom::AriaCurrentState ParseAriaCurrentState( + const char* aria_current_state); + +// ax::mojom::InvalidState +AX_EXPORT const char* ToString(ax::mojom::InvalidState invalid_state); +AX_EXPORT ax::mojom::InvalidState ParseInvalidState(const char* invalid_state); + +// ax::mojom::Restriction +AX_EXPORT const char* ToString(ax::mojom::Restriction restriction); +AX_EXPORT ax::mojom::Restriction ParseRestriction(const char* restriction); + +// ax::mojom::CheckedState +AX_EXPORT const char* ToString(ax::mojom::CheckedState checked_state); +AX_EXPORT ax::mojom::CheckedState ParseCheckedState(const char* checked_state); + +// ax::mojom::SortDirection +AX_EXPORT const char* ToString(ax::mojom::SortDirection sort_direction); +AX_EXPORT ax::mojom::SortDirection ParseSortDirection( + const char* sort_direction); + +// ax::mojom::NameFrom +AX_EXPORT const char* ToString(ax::mojom::NameFrom name_from); +AX_EXPORT ax::mojom::NameFrom ParseNameFrom(const char* name_from); + +// ax::mojom::DescriptionFrom +AX_EXPORT const char* ToString(ax::mojom::DescriptionFrom description_from); +AX_EXPORT ax::mojom::DescriptionFrom ParseDescriptionFrom( + const char* description_from); + +// ax::mojom::EventFrom +AX_EXPORT const char* ToString(ax::mojom::EventFrom event_from); +AX_EXPORT ax::mojom::EventFrom ParseEventFrom(const char* event_from); + +// ax::mojom::Gesture +AX_EXPORT const char* ToString(ax::mojom::Gesture gesture); +AX_EXPORT ax::mojom::Gesture ParseGesture(const char* gesture); + +// ax::mojom::TextAffinity +AX_EXPORT const char* ToString(ax::mojom::TextAffinity text_affinity); +AX_EXPORT ax::mojom::TextAffinity ParseTextAffinity(const char* text_affinity); + +// ax::mojom::TreeOrder +AX_EXPORT const char* ToString(ax::mojom::TreeOrder tree_order); +AX_EXPORT ax::mojom::TreeOrder ParseTreeOrder(const char* tree_order); + +} // namespace ui diff --git a/ui/accessibility/ax_enums.mojom b/ui/accessibility/ax_enums.mojom new file mode 100644 index 00000000000000..900518df0d1093 --- /dev/null +++ b/ui/accessibility/ax_enums.mojom @@ -0,0 +1,808 @@ +// Copyright 2018 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. + +// TODO(nektar): Migrate entire file to Mojoq. +// Must also be kept in sync with chrome/common/extensions/api/automation.idl. +module ax.mojom; + + // For new entries to the following four enums, also add to + // chrome/common/extensions/api/automation.idl. This is enforced + // by a PRESUBMIT check. + // + // Explanation of the comments next to these events: + // + // Web: this event is only used in web content. Unless a specific platform + // is specified, it fires a native event on multiple platforms. + // + // Native: this event is only used in native UI. + // + // Implicit: it would be cleaner if we just updated the AX node + // and each platform fired the appropriate events to indicate which + // platform-specific attributes changed. + // + // If unspecified, the event is used across web and native on multiple + // platforms. +enum Event { + kNone, + kActiveDescendantChanged, // Web + kAlert, + kAriaAttributeChanged, // Implicit + kAutocorrectionOccured, // Unknown: http://crbug.com/392498 + kBlur, // Remove: http://crbug.com/392502 + kCheckedStateChanged, // Implicit + kChildrenChanged, + kClicked, + kDocumentSelectionChanged, + kExpandedChanged, // Web + kFocus, + kHide, // Remove: http://crbug.com/392502 + kHitTestResult, + kHover, + kImageFrameUpdated, // Web + kInvalidStatusChanged, // Implicit + kLayoutComplete, // Web + kLiveRegionCreated, // Implicit + kLiveRegionChanged, // Web + kLoadComplete, // Web + kLocationChanged, // Web + kMediaStartedPlaying, // Automation + kMediaStoppedPlaying, // Automation + kMenuEnd, // Native / Win + kMenuListItemSelected, // Web + kMenuListValueChanged, // Web + kMenuPopupEnd, // Native / Win + kMenuPopupStart, // Native / Win + kMenuStart, // Native / Win + kMouseCanceled, + kMouseDragged, + kMouseMoved, + kMousePressed, + kMouseReleased, + kRowCollapsed, // Web / Mac + kRowCountChanged, // Web / Mac + kRowExpanded, // Web / Mac + kScrollPositionChanged, // Web + kScrolledToAnchor, // Web + kSelectedChildrenChanged, // Web + kSelection, // Native + kSelectionAdd, // Native + kSelectionRemove, // Native + kShow, // Remove: http://crbug.com/392502 + kTextChanged, + kTextSelectionChanged, + kTreeChanged, // Accessibility tree changed. Don't + // explicitly fire an accessibility event, + // only implicitly due to the change. + kValueChanged, + kLast = kValueChanged, +}; + +enum Role { + kNone, + kAbbr, + kAlertDialog, + kAlert, + kAnchor, + kAnnotation, + kApplication, + kArticle, + kAudio, + kBanner, + kBlockquote, + kButton, + kCanvas, + kCaption, + kCaret, + kCell, + kCheckBox, + kClient, + kColorWell, + kColumnHeader, + kColumn, + kComboBoxGrouping, + kComboBoxMenuButton, + kComplementary, + kContentInfo, + kDate, + kDateTime, + kDefinition, + kDescriptionListDetail, + kDescriptionList, + kDescriptionListTerm, + kDesktop, + kDetails, + kDialog, + kDirectory, + kDisclosureTriangle, + kDocument, + kEmbeddedObject, + kFeed, + kFigcaption, + kFigure, + kFooter, + kForm, + kGenericContainer, + kGrid, + kGroup, + kHeading, + kIframe, + kIframePresentational, + kIgnored, + kImageMap, + kImage, + kInlineTextBox, + kInputTime, + kLabelText, + kLegend, + kLineBreak, + kLink, + kListBoxOption, + kListBox, + kListItem, + kListMarker, + kList, + kLocationBar, + kLog, + kMain, + kMark, + kMarquee, + kMath, + kMenu, + kMenuBar, + kMenuButton, + kMenuItem, + kMenuItemCheckBox, + kMenuItemRadio, + kMenuListOption, + kMenuListPopup, + kMeter, + kNavigation, + kNote, + kPane, + kParagraph, + kPopUpButton, + kPre, + kPresentational, + kProgressIndicator, + kRadioButton, + kRadioGroup, + kRegion, + kRootWebArea, + kRowHeader, + kRow, + kRuby, + kSvgRoot, + kScrollBar, + kSearch, + kSearchBox, + kSlider, + kSliderThumb, + kSpinButtonPart, + kSpinButton, + kSplitter, + kStaticText, + kStatus, + kSwitch, + kTabList, + kTabPanel, + kTab, + kTableHeaderContainer, + kTable, + kTerm, + kTextField, + kTextFieldWithComboBox, + kTime, + kTimer, + kTitleBar, + kToggleButton, + kToolbar, + kTreeGrid, + kTreeItem, + kTree, + kUnknown, + kTooltip, + kVideo, + kWebArea, + kWebView, + kWindow, + kLast = kWindow, +}; + +enum State { + kNone, + kCollapsed, + kDefault, + kEditable, + kExpanded, + kFocusable, + kHaspopup, + // Grows horizontally, e.g. most toolbars and separators. + kHorizontal, + kHovered, + kInvisible, + kLinked, + kMultiline, + kMultiselectable, + kProtected, + kRequired, + kRichlyEditable, + kSelectable, + kSelected, + // Grows vertically, e.g. menu or combo box. + kVertical, + kVisited, + kLast = kVisited, +}; + + // An action to be taken on an accessibility node. + // In contrast to |AXDefaultActionVerb|, these describe what happens to the + // object, e.g. "FOCUS". +enum Action { + kNone, + kBlur, + + kCustomAction, + + // Decrement a slider or range control by one step value. + kDecrement, + + // Do the default action for an object, typically this means "click". + kDoDefault, + + kFocus, + + // Return the content of this image object in the image_data attribute. + kGetImageData, + + // Given a point, find the object it corresponds to and fire a + // |AXActionData.hit_test_event_to_fire| event on it in response. + kHitTest, + + // Increment a slider or range control by one step value. + kIncrement, + + // Load inline text boxes for this subtree, providing information + // about word boundaries, line layout, and individual character + // bounding boxes. + kLoadInlineTextBoxes, + + // Delete any selected text in the control's text value and + // insert |AXActionData::value| in its place, like when typing or pasting. + kReplaceSelectedText, + + // Scrolls by approximately one screen in a specific direction. Should be + // called on a node that has scrollable boolean set to true. + kScrollBackward, + kScrollForward, + kScrollUp, + kScrollDown, + kScrollLeft, + kScrollRight, + + // Scroll any scrollable containers to make the target object visible + // on the screen. Optionally pass a subfocus rect in + // AXActionData.target_rect, in node-local coordinates. + kScrollToMakeVisible, + + // Scroll the given object to a specified point on the screen in + // global screen coordinates. Pass a point in AXActionData.target_point. + kScrollToPoint, + + kSetScrollOffset, + kSetSelection, + + // Don't focus this node, but set it as the sequential focus navigation + // starting point, so that pressing Tab moves to the next element + // following this one, for example. + kSetSequentialFocusNavigationStartingPoint, + + // Replace the value of the control with AXActionData::value and + // reset the selection, if applicable. + kSetValue, + + kShowContextMenu, + kLast = kShowContextMenu, +}; + +enum ActionFlags { + kNone, + kRequestImages, + kRequestInlineTextBoxes, + kLast = kRequestInlineTextBoxes, +}; + + // A list of valid values for the |AXIntAttribute| |default_action_verb|. + // These will describe the action that will be performed on a given node when + // executing the default action, which is a click. + // In contrast to |AXAction|, these describe what the user can do on the + // object, e.g. "PRESS", not what happens to the object as a result. + // Only one verb can be used at a time to describe the default action. +enum DefaultActionVerb { + kNone, + kActivate, + kCheck, + kClick, + + // A click will be performed on one of the node's ancestors. + // This happens when the node itself is not clickable, but one of its + // ancestors has click handlers attached which are able to capture the click + // as it bubbles up. + kClickAncestor, + + kJump, + kOpen, + kPress, + kSelect, + kUncheck, + kLast = kUncheck, +}; + + // A change to the accessibility tree. +enum Mutation { + kNone, + kNodeCreated, + kSubtreeCreated, + kNodeChanged, + kNodeRemoved, + kLast = kNodeRemoved, +}; + +enum StringAttribute { + kNone, + kAccessKey, + // Only used when invalid_state == invalid_state_other. + kAriaInvalidValue, + kAutoComplete, + kChromeChannel, // Automation only. + kClassName, // views and Android + kContainerLiveRelevant, + kContainerLiveStatus, + kDescription, + kDisplay, + // Only present when different from parent. + kFontFamily, + kHtmlTag, + kImageDataUrl, + kInnerHtml, + kKeyShortcuts, + // Only present when different from parent. + kLanguage, + kName, + kLiveRelevant, + kLiveStatus, + kPlaceholder, + kRole, + kRoleDescription, + kUrl, + kValue, + kLast = kValue, +}; + +enum IntAttribute { + kNone, + kDefaultActionVerb, + // Scrollable container attributes. + kScrollX, + kScrollXMin, + kScrollXMax, + kScrollY, + kScrollYMin, + kScrollYMax, + + // Attributes for retrieving the endpoints of a selection. + kTextSelStart, + kTextSelEnd, + + // aria_col* and aria_row* attributes + kAriaColumnCount, + kAriaCellColumnIndex, + kAriaRowCount, + kAriaCellRowIndex, + + // Table attributes. + kTableRowCount, + kTableColumnCount, + kTableHeaderId, + + // Table row attributes. + kTableRowIndex, + kTableRowHeaderId, + + // Table column attributes. + kTableColumnIndex, + kTableColumnHeaderId, + + // Table cell attributes. + kTableCellColumnIndex, + kTableCellColumnSpan, + kTableCellRowIndex, + kTableCellRowSpan, + kSortDirection, + + // Tree control attributes. + kHierarchicalLevel, + + // What information was used to compute the object's name + // (of type AXNameFrom). + kNameFrom, + + // What information was used to compute the object's description + // (of type AXDescriptionFrom). + kDescriptionFrom, + + // Relationships between this element and other elements. + kActivedescendantId, + kDetailsId, + kErrormessageId, + kInPageLinkTargetId, + kMemberOfId, + kNextOnLineId, + kPreviousOnLineId, + + // Identifies a child tree which this node hosts. + kChildTreeId, + + // Input restriction, if any, such as readonly or disabled. + // Of type AXRestriction, see below. + // No value or enabled control or other object that is not disabled. + kRestriction, + + // Position or Number of items in current set of listitems or treeitems + kSetSize, + kPosInSet, + + // In the case of AX_ROLE_COLOR_WELL, specifies the selected color. + kColorValue, + + // Indicates the element that represents the current item within a container + // or set of related elements. + kAriaCurrentState, + + // Text attributes. + + // Foreground and background color in RGBA. + kBackgroundColor, + kColor, + + // Indicates if a form control has invalid input or + // if an element has an aria-invalid attribute. + kInvalidState, + + // Of type AXCheckedState + kCheckedState, + + // Specifies the direction of the text, e.g., right-to-left. + kTextDirection, + + // Bold, italic, underline, etc. + kTextStyle, + + // Focus traversal in views and Android. + kPreviousFocusId, + kNextFocusId, + kLast = kNextFocusId, +}; + +enum FloatAttribute { + kNone, + // Range attributes. + kValueForRange, + kMinValueForRange, + kMaxValueForRange, + kStepValueForRange, + + // Text attributes. + // Font size is in pixels. + kFontSize, + kLast = kFontSize, +}; + +enum BoolAttribute { + kNone, + // Generic busy state, does not have to be on a live region. + kBusy, + // The object is at the root of an editable field, such as a content + // editable. + kEditableRoot, + + // Live region attributes. + kContainerLiveAtomic, + kContainerLiveBusy, + kLiveAtomic, + + // If a dialog box is marked as explicitly modal + kModal, + + // If this is set, all of the other fields in this struct should + // be ignored and only the locations should change. + kUpdateLocationOnly, + + // Set on a canvas element if it has fallback content. + kCanvasHasFallback, + + // Indicates this node is scrollable (Android only). + kScrollable, + + // A hint to clients that the node is clickable. + kClickable, + + // Indicates that this node clips its children, i.e. may have + // overflow: hidden or clip children by default. + kClipsChildren, + kLast = kClipsChildren, +}; + +enum IntListAttribute { + kNone, + // Ids of nodes that are children of this node logically, but are + // not children of this node in the tree structure. As an example, + // a table cell is a child of a row, and an 'indirect' child of a + // column. + kIndirectChildIds, + + // Relationships between this element and other elements. + kControlsIds, + kDescribedbyIds, + kFlowtoIds, + kLabelledbyIds, + kRadioGroupIds, + + // For static text. Character indices where line breaks occur. Note that + // this attribute is only available on Chrome OS and will be deprecated + // soon. + kLineBreaks, + + // For static text. These int lists must be the same size; they represent + // the start and end character offset of each marker. Examples of markers + // include spelling and grammar errors, and find-in-page matches. + kMarkerTypes, + kMarkerStarts, + kMarkerEnds, + + // For a table, the cell ids in row-major order, with duplicate entries + // when there's a rowspan or colspan, and with -1 for missing cells. + // There are always exactly rows * columns entries. + kCellIds, + + // For a table, the unique cell ids in row-major order of their first + // occurrence. + kUniqueCellIds, + + // For inline text. This is the pixel position of the end of this + // character within the bounding rectangle of this object, in the + // direction given by AX_ATTR_TEXT_DIRECTION. For example, for left-to-right + // text, the first offset is the right coordinate of the first character + // within the object's bounds, the second offset is the right coordinate + // of the second character, and so on. + kCharacterOffsets, + + // Used for caching. Do not read directly. Use + // |AXNode::GetOrComputeLineStartOffsets| + // For all text fields and content editable roots: A list of the start + // offsets of each line inside this object. + kCachedLineStarts, + + // For inline text. These int lists must be the same size; they represent + // the start and end character offset of each word within this text. + kWordStarts, + kWordEnds, + + // Used for an UI element to define custom actions for it. For example, a + // list UI will allow a user to reorder items in the list by dragging the + // items. Developer can expose those actions as custom actions. Currently + // custom actions are used only in Android window. + kCustomActionIds, + kLast = kCustomActionIds, +}; + +enum StringListAttribute { + kNone, + // Descriptions for custom actions. This must be aligned with + // custom_action_ids. + kCustomActionDescriptions, + kLast = kCustomActionDescriptions, +}; + + // TODO(dmazzoni, nektar): make this list not grow exponentially as new + // MarkerTypes are added +enum MarkerType { + kNone, + // Assignments are ignored by the parser, but are kept here for clarity. + kSpelling = 1, + kGrammar = 2, + kSpellingGrammar = 3, + kTextMatch = 4, + kSpellingTextMatch = 5, + kGrammarTextMatch = 6, + kSpellingGrammarTextMatch = 7, + // DocumentMarker::MarkerType::Composition = 8 is ignored for accessibility + // purposes + kActiveSuggestion = 16, + kSpellingActiveSuggestion = 17, + kGrammarActiveSuggestion = 18, + kSpellingGrammarActiveSuggestion = 19, + kTextMatchActiveSuggestion = 20, + kSpellingTextMatchActiveSuggestion = 21, + kGrammarTextMatchActiveSuggestion = 22, + kSpellingGrammarTextMatchActiveSuggestion = 23, + kSuggestion = 32, + kSpellingSuggestion = 33, + kGrammarSuggestion = 34, + kSpellingGrammarSuggestion = 35, + kTextMatchSuggestion = 36, + kSpellingTextMatchSuggestion = 37, + kGrammarTextMatchSuggestion = 38, + kSpellingGrammarTextMatchSuggestion = 39, + // We again skip over DocumentMarker::MarkerType::Composition = 8 here + kActiveSuggestionSuggestion = 48, + kSpellingActiveSuggestionSuggestion = 49, + kGrammarActiveSuggestionSuggestion = 50, + kSpellingGrammarActiveSuggestionSuggestion = 51, + kTextMatchActiveSuggestionSuggestion = 52, + kSpellingTextMatchActiveSuggestionSuggestion = 53, + kGrammarTextMatchActiveSuggestionSuggestion = 54, + kSpellingGrammarTextMatchActiveSuggestionSuggestion = 55, + kLast = kSpellingGrammarTextMatchActiveSuggestionSuggestion, +}; + +enum TextDirection { + kNone, + kLtr, + kRtl, + kTtb, + kBtt, + kLast = kBtt, +}; + + // A Java counterpart will be generated for this enum. + // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.ui.accessibility +enum TextStyle { + kNone, + // Assignments are ignored by the parser, but are kept here for clarity. + kTextStyleBold = 1, + kTextStyleItalic = 2, + kTextStyleBoldItalic = 3, + kTextStyleUnderline = 4, + kTextStyleBoldUnderline = 5, + kTextStyleItalicUnderline = 6, + kTextStyleBoldItalicUnderline = 7, + kTextStyleLineThrough = 8, + kTextStyleBoldLineThrough = 9, + kTextStyleItalicLineThrough = 10, + kTextStyleBoldItalicLineThrough = 11, + kTextStyleUnderlineLineThrough = 12, + kTextStyleBoldUnderlineLineThrough = 13, + kTextStyleItalicUnderlineLineThrough = 14, + kTextStyleBoldItalicUnderlineLineThrough = 15, + kLast = kTextStyleBoldItalicUnderlineLineThrough, +}; + +enum AriaCurrentState { + kNone, + kFalse, + kTrue, + kPage, + kStep, + kLocation, + kUnclippedLocation, + kDate, + kTime, + kLast = kTime, +}; + +enum InvalidState { + kNone, + kFalse, + kTrue, + kSpelling, + kGrammar, + kOther, + kLast = kOther, +}; + + // Input restriction associated with an object. + // No value for a control means it is enabled. + // Use read_only for a textbox that allows focus/selection but not input. + // Use disabled for a control or group of controls that disallows input. +enum Restriction { + kNone, + kReadOnly, + kDisabled, + kLast = kDisabled, +}; + +enum CheckedState { + kNone, + kFalse, + kTrue, + kMixed, + kLast = kMixed, +}; + +enum SortDirection { + kNone, + kUnsorted, + kAscending, + kDescending, + kOther, + kLast = kOther, +}; + +enum NameFrom { + kNone, + kUninitialized, + kAttribute, + kAttributeExplicitlyEmpty, + kContents, + kPlaceholder, + kRelatedElement, + kValue, + kLast = kValue, +}; + +enum DescriptionFrom { + kNone, + kUninitialized, + kAttribute, + kContents, + kPlaceholder, + kRelatedElement, + kLast = kRelatedElement, +}; + +enum EventFrom { + kNone, + kUser, + kPage, + kAction, + kLast = kAction, +}; + + // Touch gestures on Chrome OS. +enum Gesture { + kNone, + kClick, + kSwipeLeft1, + kSwipeUp1, + kSwipeRight1, + kSwipeDown1, + kSwipeLeft2, + kSwipeUp2, + kSwipeRight2, + kSwipeDown2, + kSwipeLeft3, + kSwipeUp3, + kSwipeRight3, + kSwipeDown3, + kSwipeLeft4, + kSwipeUp4, + kSwipeRight4, + kSwipeDown4, + kTap2, + kLast = kTap2, +}; + +enum TextAffinity { + kNone, + kDownstream, + kUpstream, + kLast = kUpstream, +}; + + // Compares two nodes in an accessibility tree in pre-order traversal. +enum TreeOrder { + kNone, + // Not in the same tree, or other error. + kUndefined, + + // First node is before the second one. + kBefore, + + // Nodes are the same. + kEqual, + + // First node is after the second one. + kAfter, + kLast = kAfter, +}; diff --git a/ui/accessibility/ax_event_generator.cc b/ui/accessibility/ax_event_generator.cc index caa038435312c9..ace4e83d9b6ae2 100644 --- a/ui/accessibility/ax_event_generator.cc +++ b/ui/accessibility/ax_event_generator.cc @@ -81,7 +81,7 @@ void AXEventGenerator::ClearEvents() { void AXEventGenerator::AddEvent(ui::AXNode* node, AXEventGenerator::Event event) { - if (node->data().role == AX_ROLE_INLINE_TEXT_BOX) + if (node->data().role == ax::mojom::Role::kInlineTextBox) return; // A newly created live region or alert should not *also* fire a @@ -105,7 +105,7 @@ void AXEventGenerator::OnNodeDataWillChange(AXTree* tree, // We don't expose those to platform APIs, though, so suppress // CHILDREN_CHANGED events on static text nodes. if (new_node_data.child_ids != old_node_data.child_ids && - new_node_data.role != ui::AX_ROLE_STATIC_TEXT) { + new_node_data.role != ax::mojom::Role::kStaticText) { AXNode* node = tree_->GetFromId(new_node_data.id); tree_events_[node].insert(Event::CHILDREN_CHANGED); } @@ -113,23 +113,23 @@ void AXEventGenerator::OnNodeDataWillChange(AXTree* tree, void AXEventGenerator::OnRoleChanged(AXTree* tree, AXNode* node, - AXRole old_role, - AXRole new_role) { + ax::mojom::Role old_role, + ax::mojom::Role new_role) { DCHECK_EQ(tree_, tree); AddEvent(node, Event::ROLE_CHANGED); } void AXEventGenerator::OnStateChanged(AXTree* tree, AXNode* node, - AXState state, + ax::mojom::State state, bool new_value) { DCHECK_EQ(tree_, tree); AddEvent(node, Event::STATE_CHANGED); - if (state == ui::AX_STATE_EXPANDED) { + if (state == ax::mojom::State::kExpanded) { AddEvent(node, new_value ? Event::EXPANDED : Event::COLLAPSED); - if (node->data().role == ui::AX_ROLE_ROW || - node->data().role == ui::AX_ROLE_TREE_ITEM) { + if (node->data().role == ax::mojom::Role::kRow || + node->data().role == ax::mojom::Role::kTreeItem) { ui::AXNode* container = node; while (container && !ui::IsRowContainer(container->data().role)) container = container->parent(); @@ -137,7 +137,7 @@ void AXEventGenerator::OnStateChanged(AXTree* tree, AddEvent(container, Event::ROW_COUNT_CHANGED); } } - if (state == ui::AX_STATE_SELECTED) { + if (state == ax::mojom::State::kSelected) { AddEvent(node, Event::SELECTED_CHANGED); ui::AXNode* container = node; while (container && @@ -150,29 +150,30 @@ void AXEventGenerator::OnStateChanged(AXTree* tree, void AXEventGenerator::OnStringAttributeChanged(AXTree* tree, AXNode* node, - AXStringAttribute attr, + ax::mojom::StringAttribute attr, const std::string& old_value, const std::string& new_value) { DCHECK_EQ(tree_, tree); switch (attr) { - case ui::AX_ATTR_NAME: + case ax::mojom::StringAttribute::kName: AddEvent(node, Event::NAME_CHANGED); - if (node->data().HasStringAttribute(ui::AX_ATTR_CONTAINER_LIVE_STATUS)) { + if (node->data().HasStringAttribute( + ax::mojom::StringAttribute::kContainerLiveStatus)) { FireLiveRegionEvents(node); } break; - case ui::AX_ATTR_DESCRIPTION: + case ax::mojom::StringAttribute::kDescription: AddEvent(node, Event::DESCRIPTION_CHANGED); break; - case ui::AX_ATTR_VALUE: + case ax::mojom::StringAttribute::kValue: AddEvent(node, Event::VALUE_CHANGED); break; - case ui::AX_ATTR_ARIA_INVALID_VALUE: + case ax::mojom::StringAttribute::kAriaInvalidValue: AddEvent(node, Event::INVALID_STATUS_CHANGED); break; - case ui::AX_ATTR_LIVE_STATUS: - if (node->data().role != ui::AX_ROLE_ALERT) + case ax::mojom::StringAttribute::kLiveStatus: + if (node->data().role != ax::mojom::Role::kAlert) AddEvent(node, Event::LIVE_REGION_CREATED); break; default: @@ -183,27 +184,27 @@ void AXEventGenerator::OnStringAttributeChanged(AXTree* tree, void AXEventGenerator::OnIntAttributeChanged(AXTree* tree, AXNode* node, - AXIntAttribute attr, + ax::mojom::IntAttribute attr, int32_t old_value, int32_t new_value) { DCHECK_EQ(tree_, tree); switch (attr) { - case ui::AX_ATTR_ACTIVEDESCENDANT_ID: + case ax::mojom::IntAttribute::kActivedescendantId: AddEvent(node, Event::ACTIVE_DESCENDANT_CHANGED); active_descendant_changed_.push_back(node); break; - case ui::AX_ATTR_CHECKED_STATE: + case ax::mojom::IntAttribute::kCheckedState: AddEvent(node, Event::CHECKED_STATE_CHANGED); break; - case ui::AX_ATTR_INVALID_STATE: + case ax::mojom::IntAttribute::kInvalidState: AddEvent(node, Event::INVALID_STATUS_CHANGED); break; - case ui::AX_ATTR_RESTRICTION: + case ax::mojom::IntAttribute::kRestriction: AddEvent(node, Event::STATE_CHANGED); break; - case ui::AX_ATTR_SCROLL_X: - case ui::AX_ATTR_SCROLL_Y: + case ax::mojom::IntAttribute::kScrollX: + case ax::mojom::IntAttribute::kScrollY: AddEvent(node, Event::SCROLL_POSITION_CHANGED); break; default: @@ -214,12 +215,12 @@ void AXEventGenerator::OnIntAttributeChanged(AXTree* tree, void AXEventGenerator::OnFloatAttributeChanged(AXTree* tree, AXNode* node, - AXFloatAttribute attr, + ax::mojom::FloatAttribute attr, float old_value, float new_value) { DCHECK_EQ(tree_, tree); - if (attr == ui::AX_ATTR_VALUE_FOR_RANGE) + if (attr == ax::mojom::FloatAttribute::kValueForRange) AddEvent(node, Event::VALUE_CHANGED); else AddEvent(node, Event::OTHER_ATTRIBUTE_CHANGED); @@ -227,7 +228,7 @@ void AXEventGenerator::OnFloatAttributeChanged(AXTree* tree, void AXEventGenerator::OnBoolAttributeChanged(AXTree* tree, AXNode* node, - AXBoolAttribute attr, + ax::mojom::BoolAttribute attr, bool new_value) { DCHECK_EQ(tree_, tree); @@ -237,7 +238,7 @@ void AXEventGenerator::OnBoolAttributeChanged(AXTree* tree, void AXEventGenerator::OnIntListAttributeChanged( AXTree* tree, AXNode* node, - AXIntListAttribute attr, + ax::mojom::IntListAttribute attr, const std::vector& old_value, const std::vector& new_value) { DCHECK_EQ(tree_, tree); @@ -247,7 +248,7 @@ void AXEventGenerator::OnIntListAttributeChanged( void AXEventGenerator::OnStringListAttributeChanged( AXTree* tree, AXNode* node, - AXStringListAttribute attr, + ax::mojom::StringListAttribute attr, const std::vector& old_value, const std::vector& new_value) { DCHECK_EQ(tree_, tree); @@ -314,14 +315,16 @@ void AXEventGenerator::OnAtomicUpdateFinished( for (const auto& change : changes) { if ((change.type == NODE_CREATED || change.type == SUBTREE_CREATED)) { - if (change.node->data().HasStringAttribute(ui::AX_ATTR_LIVE_STATUS)) { - if (change.node->data().role == ui::AX_ROLE_ALERT) + if (change.node->data().HasStringAttribute( + ax::mojom::StringAttribute::kLiveStatus)) { + if (change.node->data().role == ax::mojom::Role::kAlert) AddEvent(change.node, Event::ALERT); else AddEvent(change.node, Event::LIVE_REGION_CREATED); } else if (change.node->data().HasStringAttribute( - ui::AX_ATTR_CONTAINER_LIVE_STATUS) && - change.node->data().HasStringAttribute(ui::AX_ATTR_NAME)) { + ax::mojom::StringAttribute::kContainerLiveStatus) && + change.node->data().HasStringAttribute( + ax::mojom::StringAttribute::kName)) { FireLiveRegionEvents(change.node); } } @@ -332,13 +335,16 @@ void AXEventGenerator::OnAtomicUpdateFinished( void AXEventGenerator::FireLiveRegionEvents(AXNode* node) { ui::AXNode* live_root = node; - while (live_root && - !live_root->data().HasStringAttribute(ui::AX_ATTR_LIVE_STATUS)) + while (live_root && !live_root->data().HasStringAttribute( + ax::mojom::StringAttribute::kLiveStatus)) live_root = live_root->parent(); - if (live_root && !live_root->data().GetBoolAttribute(ui::AX_ATTR_BUSY)) { + if (live_root && + !live_root->data().GetBoolAttribute(ax::mojom::BoolAttribute::kBusy)) { // Fire LIVE_REGION_NODE_CHANGED on each node that changed. - if (!node->data().GetStringAttribute(ui::AX_ATTR_NAME).empty()) + if (!node->data() + .GetStringAttribute(ax::mojom::StringAttribute::kName) + .empty()) AddEvent(node, Event::LIVE_REGION_NODE_CHANGED); // Fire LIVE_REGION_NODE_CHANGED on the root of the live region. AddEvent(live_root, Event::LIVE_REGION_CHANGED); @@ -347,15 +353,15 @@ void AXEventGenerator::FireLiveRegionEvents(AXNode* node) { void AXEventGenerator::FireActiveDescendantEvents() { for (AXNode* node : active_descendant_changed_) { - AXNode* descendant = tree_->GetFromId( - node->data().GetIntAttribute(ui::AX_ATTR_ACTIVEDESCENDANT_ID)); + AXNode* descendant = tree_->GetFromId(node->data().GetIntAttribute( + ax::mojom::IntAttribute::kActivedescendantId)); if (!descendant) continue; switch (descendant->data().role) { - case ui::AX_ROLE_MENU_ITEM: - case ui::AX_ROLE_MENU_ITEM_CHECK_BOX: - case ui::AX_ROLE_MENU_ITEM_RADIO: - case ui::AX_ROLE_MENU_LIST_OPTION: + case ax::mojom::Role::kMenuItem: + case ax::mojom::Role::kMenuItemCheckBox: + case ax::mojom::Role::kMenuItemRadio: + case ax::mojom::Role::kMenuListOption: AddEvent(descendant, Event::MENU_ITEM_SELECTED); break; default: diff --git a/ui/accessibility/ax_event_generator.h b/ui/accessibility/ax_event_generator.h index f4d9c26efb59a5..dab9d21518de4c 100644 --- a/ui/accessibility/ax_event_generator.h +++ b/ui/accessibility/ax_event_generator.h @@ -115,41 +115,41 @@ class AX_EXPORT AXEventGenerator : public AXTreeDelegate { const AXNodeData& new_node_data) override; void OnRoleChanged(AXTree* tree, AXNode* node, - AXRole old_role, - AXRole new_role) override; + ax::mojom::Role old_role, + ax::mojom::Role new_role) override; void OnStateChanged(AXTree* tree, AXNode* node, - AXState state, + ax::mojom::State state, bool new_value) override; void OnStringAttributeChanged(AXTree* tree, AXNode* node, - AXStringAttribute attr, + ax::mojom::StringAttribute attr, const std::string& old_value, const std::string& new_value) override; void OnIntAttributeChanged(AXTree* tree, AXNode* node, - AXIntAttribute attr, + ax::mojom::IntAttribute attr, int32_t old_value, int32_t new_value) override; void OnFloatAttributeChanged(AXTree* tree, AXNode* node, - AXFloatAttribute attr, + ax::mojom::FloatAttribute attr, float old_value, float new_value) override; void OnBoolAttributeChanged(AXTree* tree, AXNode* node, - AXBoolAttribute attr, + ax::mojom::BoolAttribute attr, bool new_value) override; void OnIntListAttributeChanged( AXTree* tree, AXNode* node, - AXIntListAttribute attr, + ax::mojom::IntListAttribute attr, const std::vector& old_value, const std::vector& new_value) override; void OnStringListAttributeChanged( AXTree* tree, AXNode* node, - AXStringListAttribute attr, + ax::mojom::StringListAttribute attr, const std::vector& old_value, const std::vector& new_value) override; void OnTreeDataChanged(AXTree* tree, diff --git a/ui/accessibility/ax_event_generator_unittest.cc b/ui/accessibility/ax_event_generator_unittest.cc index c184219848ba2d..31abeb02f2fcb2 100644 --- a/ui/accessibility/ax_event_generator_unittest.cc +++ b/ui/accessibility/ax_event_generator_unittest.cc @@ -183,22 +183,22 @@ TEST(AXEventGeneratorTest, ExpandedAndRowCount) { initial_state.root_id = 1; initial_state.nodes.resize(4); initial_state.nodes[0].id = 1; - initial_state.nodes[0].role = ui::AX_ROLE_ROOT_WEB_AREA; + initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea; initial_state.nodes[0].child_ids.push_back(2); initial_state.nodes[0].child_ids.push_back(4); initial_state.nodes[1].id = 2; - initial_state.nodes[1].role = ui::AX_ROLE_TABLE; + initial_state.nodes[1].role = ax::mojom::Role::kTable; initial_state.nodes[1].child_ids.push_back(3); initial_state.nodes[2].id = 3; - initial_state.nodes[2].role = ui::AX_ROLE_ROW; + initial_state.nodes[2].role = ax::mojom::Role::kRow; initial_state.nodes[3].id = 4; - initial_state.nodes[3].role = ui::AX_ROLE_POP_UP_BUTTON; - initial_state.nodes[3].AddState(ui::AX_STATE_EXPANDED); + initial_state.nodes[3].role = ax::mojom::Role::kPopUpButton; + initial_state.nodes[3].AddState(ax::mojom::State::kExpanded); AXTree tree(initial_state); AXEventGenerator event_generator(&tree); AXTreeUpdate update = initial_state; - update.nodes[2].AddState(ui::AX_STATE_EXPANDED); + update.nodes[2].AddState(ax::mojom::State::kExpanded); update.nodes[3].state = 0; EXPECT_TRUE(tree.Unserialize(update)); EXPECT_EQ( @@ -215,22 +215,22 @@ TEST(AXEventGeneratorTest, SelectedAndSelectedChildren) { initial_state.root_id = 1; initial_state.nodes.resize(4); initial_state.nodes[0].id = 1; - initial_state.nodes[0].role = ui::AX_ROLE_ROOT_WEB_AREA; + initial_state.nodes[0].role = ax::mojom::Role::kRootWebArea; initial_state.nodes[0].child_ids.push_back(2); initial_state.nodes[0].child_ids.push_back(4); initial_state.nodes[1].id = 2; - initial_state.nodes[1].role = ui::AX_ROLE_MENU; + initial_state.nodes[1].role = ax::mojom::Role::kMenu; initial_state.nodes[1].child_ids.push_back(3); initial_state.nodes[2].id = 3; - initial_state.nodes[2].role = ui::AX_ROLE_MENU_ITEM; + initial_state.nodes[2].role = ax::mojom::Role::kMenuItem; initial_state.nodes[3].id = 4; - initial_state.nodes[3].role = ui::AX_ROLE_LIST_BOX_OPTION; - initial_state.nodes[3].AddState(ui::AX_STATE_SELECTED); + initial_state.nodes[3].role = ax::mojom::Role::kListBoxOption; + initial_state.nodes[3].AddState(ax::mojom::State::kSelected); AXTree tree(initial_state); AXEventGenerator event_generator(&tree); AXTreeUpdate update = initial_state; - update.nodes[2].AddState(ui::AX_STATE_SELECTED); + update.nodes[2].AddState(ax::mojom::State::kSelected); update.nodes[3].state = 0; EXPECT_TRUE(tree.Unserialize(update)); EXPECT_EQ( @@ -247,14 +247,16 @@ TEST(AXEventGeneratorTest, StringValueChanged) { initial_state.root_id = 1; initial_state.nodes.resize(1); initial_state.nodes[0].id = 1; - initial_state.nodes[0].role = ui::AX_ROLE_TEXT_FIELD; - initial_state.nodes[0].AddStringAttribute(ui::AX_ATTR_VALUE, "Before"); + initial_state.nodes[0].role = ax::mojom::Role::kTextField; + initial_state.nodes[0].AddStringAttribute(ax::mojom::StringAttribute::kValue, + "Before"); AXTree tree(initial_state); AXEventGenerator event_generator(&tree); AXTreeUpdate update = initial_state; update.nodes[0].string_attributes.clear(); - update.nodes[0].AddStringAttribute(ui::AX_ATTR_VALUE, "After"); + update.nodes[0].AddStringAttribute(ax::mojom::StringAttribute::kValue, + "After"); EXPECT_TRUE(tree.Unserialize(update)); EXPECT_EQ("VALUE_CHANGED on 1", DumpEvents(&event_generator)); } @@ -264,14 +266,16 @@ TEST(AXEventGeneratorTest, FloatValueChanged) { initial_state.root_id = 1; initial_state.nodes.resize(1); initial_state.nodes[0].id = 1; - initial_state.nodes[0].role = ui::AX_ROLE_SLIDER; - initial_state.nodes[0].AddFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, 1.0); + initial_state.nodes[0].role = ax::mojom::Role::kSlider; + initial_state.nodes[0].AddFloatAttribute( + ax::mojom::FloatAttribute::kValueForRange, 1.0); AXTree tree(initial_state); AXEventGenerator event_generator(&tree); AXTreeUpdate update = initial_state; update.nodes[0].float_attributes.clear(); - update.nodes[0].AddFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, 2.0); + update.nodes[0].AddFloatAttribute(ax::mojom::FloatAttribute::kValueForRange, + 2.0); EXPECT_TRUE(tree.Unserialize(update)); EXPECT_EQ("VALUE_CHANGED on 1", DumpEvents(&event_generator)); } @@ -281,13 +285,14 @@ TEST(AXEventGeneratorTest, InvalidStatusChanged) { initial_state.root_id = 1; initial_state.nodes.resize(1); initial_state.nodes[0].id = 1; - initial_state.nodes[0].role = ui::AX_ROLE_TEXT_FIELD; - initial_state.nodes[0].AddStringAttribute(ui::AX_ATTR_VALUE, "Text"); + initial_state.nodes[0].role = ax::mojom::Role::kTextField; + initial_state.nodes[0].AddStringAttribute(ax::mojom::StringAttribute::kValue, + "Text"); AXTree tree(initial_state); AXEventGenerator event_generator(&tree); AXTreeUpdate update = initial_state; - update.nodes[0].SetInvalidState(AX_INVALID_STATE_SPELLING); + update.nodes[0].SetInvalidState(ax::mojom::InvalidState::kSpelling); EXPECT_TRUE(tree.Unserialize(update)); EXPECT_EQ("INVALID_STATUS_CHANGED on 1", DumpEvents(&event_generator)); } @@ -301,7 +306,8 @@ TEST(AXEventGeneratorTest, AddLiveRegionAttribute) { AXEventGenerator event_generator(&tree); AXTreeUpdate update = initial_state; - update.nodes[0].AddStringAttribute(ui::AX_ATTR_LIVE_STATUS, "polite"); + update.nodes[0].AddStringAttribute(ax::mojom::StringAttribute::kLiveStatus, + "polite"); EXPECT_TRUE(tree.Unserialize(update)); EXPECT_EQ("LIVE_REGION_CREATED on 1", DumpEvents(&event_generator)); } @@ -311,12 +317,12 @@ TEST(AXEventGeneratorTest, CheckedStateChanged) { initial_state.root_id = 1; initial_state.nodes.resize(1); initial_state.nodes[0].id = 1; - initial_state.nodes[0].role = ui::AX_ROLE_CHECK_BOX; + initial_state.nodes[0].role = ax::mojom::Role::kCheckBox; AXTree tree(initial_state); AXEventGenerator event_generator(&tree); AXTreeUpdate update = initial_state; - update.nodes[0].SetCheckedState(AX_CHECKED_STATE_TRUE); + update.nodes[0].SetCheckedState(ax::mojom::CheckedState::kTrue); EXPECT_TRUE(tree.Unserialize(update)); EXPECT_EQ("CHECKED_STATE_CHANGED on 1", DumpEvents(&event_generator)); } @@ -326,20 +332,22 @@ TEST(AXEventGeneratorTest, ActiveDescendantChanged) { initial_state.root_id = 1; initial_state.nodes.resize(3); initial_state.nodes[0].id = 1; - initial_state.nodes[0].role = ui::AX_ROLE_LIST_BOX; + initial_state.nodes[0].role = ax::mojom::Role::kListBox; initial_state.nodes[0].child_ids.push_back(2); initial_state.nodes[0].child_ids.push_back(3); - initial_state.nodes[0].AddIntAttribute(ui::AX_ATTR_ACTIVEDESCENDANT_ID, 2); + initial_state.nodes[0].AddIntAttribute( + ax::mojom::IntAttribute::kActivedescendantId, 2); initial_state.nodes[1].id = 2; - initial_state.nodes[1].role = ui::AX_ROLE_LIST_BOX_OPTION; + initial_state.nodes[1].role = ax::mojom::Role::kListBoxOption; initial_state.nodes[2].id = 3; - initial_state.nodes[2].role = ui::AX_ROLE_LIST_BOX_OPTION; + initial_state.nodes[2].role = ax::mojom::Role::kListBoxOption; AXTree tree(initial_state); AXEventGenerator event_generator(&tree); AXTreeUpdate update = initial_state; update.nodes[0].int_attributes.clear(); - update.nodes[0].AddIntAttribute(ui::AX_ATTR_ACTIVEDESCENDANT_ID, 3); + update.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kActivedescendantId, + 3); EXPECT_TRUE(tree.Unserialize(update)); EXPECT_EQ("ACTIVE_DESCENDANT_CHANGED on 1", DumpEvents(&event_generator)); } @@ -357,10 +365,12 @@ TEST(AXEventGeneratorTest, CreateAlertAndLiveRegion) { update.nodes[0].child_ids.push_back(2); update.nodes[0].child_ids.push_back(3); update.nodes[1].id = 2; - update.nodes[1].AddStringAttribute(ui::AX_ATTR_LIVE_STATUS, "polite"); + update.nodes[1].AddStringAttribute(ax::mojom::StringAttribute::kLiveStatus, + "polite"); update.nodes[2].id = 3; - update.nodes[2].role = ui::AX_ROLE_ALERT; - update.nodes[2].AddStringAttribute(ui::AX_ATTR_LIVE_STATUS, "polite"); + update.nodes[2].role = ax::mojom::Role::kAlert; + update.nodes[2].AddStringAttribute(ax::mojom::StringAttribute::kLiveStatus, + "polite"); EXPECT_TRUE(tree.Unserialize(update)); EXPECT_EQ( @@ -375,33 +385,38 @@ TEST(AXEventGeneratorTest, LiveRegionChanged) { initial_state.root_id = 1; initial_state.nodes.resize(3); initial_state.nodes[0].id = 1; - initial_state.nodes[0].AddStringAttribute(ui::AX_ATTR_LIVE_STATUS, "polite"); - initial_state.nodes[0].AddStringAttribute(ui::AX_ATTR_CONTAINER_LIVE_STATUS, - "polite"); + initial_state.nodes[0].AddStringAttribute( + ax::mojom::StringAttribute::kLiveStatus, "polite"); + initial_state.nodes[0].AddStringAttribute( + ax::mojom::StringAttribute::kContainerLiveStatus, "polite"); initial_state.nodes[0].child_ids.push_back(2); initial_state.nodes[0].child_ids.push_back(3); initial_state.nodes[1].id = 2; - initial_state.nodes[1].role = ui::AX_ROLE_STATIC_TEXT; - initial_state.nodes[1].AddStringAttribute(ui::AX_ATTR_CONTAINER_LIVE_STATUS, - "polite"); - initial_state.nodes[1].AddStringAttribute(ui::AX_ATTR_NAME, "Before 1"); + initial_state.nodes[1].role = ax::mojom::Role::kStaticText; + initial_state.nodes[1].AddStringAttribute( + ax::mojom::StringAttribute::kContainerLiveStatus, "polite"); + initial_state.nodes[1].AddStringAttribute(ax::mojom::StringAttribute::kName, + "Before 1"); initial_state.nodes[2].id = 3; - initial_state.nodes[2].role = ui::AX_ROLE_STATIC_TEXT; - initial_state.nodes[2].AddStringAttribute(ui::AX_ATTR_CONTAINER_LIVE_STATUS, - "polite"); - initial_state.nodes[2].AddStringAttribute(ui::AX_ATTR_NAME, "Before 2"); + initial_state.nodes[2].role = ax::mojom::Role::kStaticText; + initial_state.nodes[2].AddStringAttribute( + ax::mojom::StringAttribute::kContainerLiveStatus, "polite"); + initial_state.nodes[2].AddStringAttribute(ax::mojom::StringAttribute::kName, + "Before 2"); AXTree tree(initial_state); AXEventGenerator event_generator(&tree); AXTreeUpdate update = initial_state; update.nodes[1].string_attributes.clear(); - update.nodes[1].AddStringAttribute(ui::AX_ATTR_CONTAINER_LIVE_STATUS, - "polite"); - update.nodes[1].AddStringAttribute(ui::AX_ATTR_NAME, "After 1"); + update.nodes[1].AddStringAttribute( + ax::mojom::StringAttribute::kContainerLiveStatus, "polite"); + update.nodes[1].AddStringAttribute(ax::mojom::StringAttribute::kName, + "After 1"); update.nodes[2].string_attributes.clear(); - update.nodes[2].AddStringAttribute(ui::AX_ATTR_CONTAINER_LIVE_STATUS, - "polite"); - update.nodes[2].AddStringAttribute(ui::AX_ATTR_NAME, "After 2"); + update.nodes[2].AddStringAttribute( + ax::mojom::StringAttribute::kContainerLiveStatus, "polite"); + update.nodes[2].AddStringAttribute(ax::mojom::StringAttribute::kName, + "After 2"); EXPECT_TRUE(tree.Unserialize(update)); EXPECT_EQ( @@ -418,27 +433,31 @@ TEST(AXEventGeneratorTest, LiveRegionOnlyTextChanges) { initial_state.root_id = 1; initial_state.nodes.resize(3); initial_state.nodes[0].id = 1; - initial_state.nodes[0].AddStringAttribute(ui::AX_ATTR_LIVE_STATUS, "polite"); - initial_state.nodes[0].AddStringAttribute(ui::AX_ATTR_CONTAINER_LIVE_STATUS, - "polite"); + initial_state.nodes[0].AddStringAttribute( + ax::mojom::StringAttribute::kLiveStatus, "polite"); + initial_state.nodes[0].AddStringAttribute( + ax::mojom::StringAttribute::kContainerLiveStatus, "polite"); initial_state.nodes[0].child_ids.push_back(2); initial_state.nodes[0].child_ids.push_back(3); initial_state.nodes[1].id = 2; - initial_state.nodes[1].role = ui::AX_ROLE_STATIC_TEXT; - initial_state.nodes[1].AddStringAttribute(ui::AX_ATTR_CONTAINER_LIVE_STATUS, - "polite"); - initial_state.nodes[1].AddStringAttribute(ui::AX_ATTR_NAME, "Before 1"); + initial_state.nodes[1].role = ax::mojom::Role::kStaticText; + initial_state.nodes[1].AddStringAttribute( + ax::mojom::StringAttribute::kContainerLiveStatus, "polite"); + initial_state.nodes[1].AddStringAttribute(ax::mojom::StringAttribute::kName, + "Before 1"); initial_state.nodes[2].id = 3; - initial_state.nodes[2].role = ui::AX_ROLE_STATIC_TEXT; - initial_state.nodes[2].AddStringAttribute(ui::AX_ATTR_CONTAINER_LIVE_STATUS, - "polite"); - initial_state.nodes[2].AddStringAttribute(ui::AX_ATTR_NAME, "Before 2"); + initial_state.nodes[2].role = ax::mojom::Role::kStaticText; + initial_state.nodes[2].AddStringAttribute( + ax::mojom::StringAttribute::kContainerLiveStatus, "polite"); + initial_state.nodes[2].AddStringAttribute(ax::mojom::StringAttribute::kName, + "Before 2"); AXTree tree(initial_state); AXEventGenerator event_generator(&tree); AXTreeUpdate update = initial_state; - update.nodes[1].AddStringAttribute(ui::AX_ATTR_DESCRIPTION, "Description 1"); - update.nodes[2].SetCheckedState(AX_CHECKED_STATE_TRUE); + update.nodes[1].AddStringAttribute(ax::mojom::StringAttribute::kDescription, + "Description 1"); + update.nodes[2].SetCheckedState(ax::mojom::CheckedState::kTrue); // Note that we do NOT expect a LIVE_REGION_CHANGED event here, because // the name did not change. @@ -454,34 +473,40 @@ TEST(AXEventGeneratorTest, BusyLiveRegionChanged) { initial_state.root_id = 1; initial_state.nodes.resize(3); initial_state.nodes[0].id = 1; - initial_state.nodes[0].AddStringAttribute(ui::AX_ATTR_LIVE_STATUS, "polite"); - initial_state.nodes[0].AddStringAttribute(ui::AX_ATTR_CONTAINER_LIVE_STATUS, - "polite"); - initial_state.nodes[0].AddBoolAttribute(ui::AX_ATTR_BUSY, true); + initial_state.nodes[0].AddStringAttribute( + ax::mojom::StringAttribute::kLiveStatus, "polite"); + initial_state.nodes[0].AddStringAttribute( + ax::mojom::StringAttribute::kContainerLiveStatus, "polite"); + initial_state.nodes[0].AddBoolAttribute(ax::mojom::BoolAttribute::kBusy, + true); initial_state.nodes[0].child_ids.push_back(2); initial_state.nodes[0].child_ids.push_back(3); initial_state.nodes[1].id = 2; - initial_state.nodes[1].role = ui::AX_ROLE_STATIC_TEXT; - initial_state.nodes[1].AddStringAttribute(ui::AX_ATTR_CONTAINER_LIVE_STATUS, - "polite"); - initial_state.nodes[1].AddStringAttribute(ui::AX_ATTR_NAME, "Before 1"); + initial_state.nodes[1].role = ax::mojom::Role::kStaticText; + initial_state.nodes[1].AddStringAttribute( + ax::mojom::StringAttribute::kContainerLiveStatus, "polite"); + initial_state.nodes[1].AddStringAttribute(ax::mojom::StringAttribute::kName, + "Before 1"); initial_state.nodes[2].id = 3; - initial_state.nodes[2].role = ui::AX_ROLE_STATIC_TEXT; - initial_state.nodes[2].AddStringAttribute(ui::AX_ATTR_CONTAINER_LIVE_STATUS, - "polite"); - initial_state.nodes[2].AddStringAttribute(ui::AX_ATTR_NAME, "Before 2"); + initial_state.nodes[2].role = ax::mojom::Role::kStaticText; + initial_state.nodes[2].AddStringAttribute( + ax::mojom::StringAttribute::kContainerLiveStatus, "polite"); + initial_state.nodes[2].AddStringAttribute(ax::mojom::StringAttribute::kName, + "Before 2"); AXTree tree(initial_state); AXEventGenerator event_generator(&tree); AXTreeUpdate update = initial_state; update.nodes[1].string_attributes.clear(); - update.nodes[1].AddStringAttribute(ui::AX_ATTR_CONTAINER_LIVE_STATUS, - "polite"); - update.nodes[1].AddStringAttribute(ui::AX_ATTR_NAME, "After 1"); + update.nodes[1].AddStringAttribute( + ax::mojom::StringAttribute::kContainerLiveStatus, "polite"); + update.nodes[1].AddStringAttribute(ax::mojom::StringAttribute::kName, + "After 1"); update.nodes[2].string_attributes.clear(); - update.nodes[2].AddStringAttribute(ui::AX_ATTR_CONTAINER_LIVE_STATUS, - "polite"); - update.nodes[2].AddStringAttribute(ui::AX_ATTR_NAME, "After 2"); + update.nodes[2].AddStringAttribute( + ax::mojom::StringAttribute::kContainerLiveStatus, "polite"); + update.nodes[2].AddStringAttribute(ax::mojom::StringAttribute::kName, + "After 2"); EXPECT_TRUE(tree.Unserialize(update)); EXPECT_EQ( @@ -560,7 +585,7 @@ TEST(AXEventGeneratorTest, ScrollPositionChanged) { AXEventGenerator event_generator(&tree); AXTreeUpdate update = initial_state; - update.nodes[0].AddIntAttribute(ui::AX_ATTR_SCROLL_Y, 10); + update.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kScrollY, 10); EXPECT_TRUE(tree.Unserialize(update)); EXPECT_EQ("SCROLL_POSITION_CHANGED on 1", DumpEvents(&event_generator)); } @@ -584,12 +609,16 @@ TEST(AXEventGeneratorTest, OtherAttributeChanged) { AXEventGenerator event_generator(&tree); AXTreeUpdate update = initial_state; - update.nodes[1].AddStringAttribute(ui::AX_ATTR_LANGUAGE, "de"); - update.nodes[2].AddIntAttribute(ui::AX_ATTR_ARIA_CELL_COLUMN_INDEX, 7); - update.nodes[3].AddFloatAttribute(ui::AX_ATTR_FONT_SIZE, 12.0f); - update.nodes[4].AddBoolAttribute(ui::AX_ATTR_MODAL, true); + update.nodes[1].AddStringAttribute(ax::mojom::StringAttribute::kLanguage, + "de"); + update.nodes[2].AddIntAttribute(ax::mojom::IntAttribute::kAriaCellColumnIndex, + 7); + update.nodes[3].AddFloatAttribute(ax::mojom::FloatAttribute::kFontSize, + 12.0f); + update.nodes[4].AddBoolAttribute(ax::mojom::BoolAttribute::kModal, true); std::vector ids = {2}; - update.nodes[5].AddIntListAttribute(ui::AX_ATTR_CONTROLS_IDS, ids); + update.nodes[5].AddIntListAttribute(ax::mojom::IntListAttribute::kControlsIds, + ids); EXPECT_TRUE(tree.Unserialize(update)); EXPECT_EQ( "OTHER_ATTRIBUTE_CHANGED on 2, " @@ -609,7 +638,8 @@ TEST(AXEventGeneratorTest, NameChanged) { AXEventGenerator event_generator(&tree); AXTreeUpdate update = initial_state; - update.nodes[0].AddStringAttribute(ui::AX_ATTR_NAME, "Hello"); + update.nodes[0].AddStringAttribute(ax::mojom::StringAttribute::kName, + "Hello"); EXPECT_TRUE(tree.Unserialize(update)); EXPECT_EQ("NAME_CHANGED on 1", DumpEvents(&event_generator)); } @@ -623,7 +653,8 @@ TEST(AXEventGeneratorTest, DescriptionChanged) { AXEventGenerator event_generator(&tree); AXTreeUpdate update = initial_state; - update.nodes[0].AddStringAttribute(ui::AX_ATTR_DESCRIPTION, "Hello"); + update.nodes[0].AddStringAttribute(ax::mojom::StringAttribute::kDescription, + "Hello"); EXPECT_TRUE(tree.Unserialize(update)); EXPECT_EQ("DESCRIPTION_CHANGED on 1", DumpEvents(&event_generator)); } @@ -637,7 +668,7 @@ TEST(AXEventGeneratorTest, RoleChanged) { AXEventGenerator event_generator(&tree); AXTreeUpdate update = initial_state; - update.nodes[0].role = ui::AX_ROLE_CHECK_BOX; + update.nodes[0].role = ax::mojom::Role::kCheckBox; EXPECT_TRUE(tree.Unserialize(update)); EXPECT_EQ("ROLE_CHANGED on 1", DumpEvents(&event_generator)); } @@ -647,20 +678,22 @@ TEST(AXEventGeneratorTest, MenuItemSelected) { initial_state.root_id = 1; initial_state.nodes.resize(3); initial_state.nodes[0].id = 1; - initial_state.nodes[0].role = ui::AX_ROLE_MENU; + initial_state.nodes[0].role = ax::mojom::Role::kMenu; initial_state.nodes[0].child_ids.push_back(2); initial_state.nodes[0].child_ids.push_back(3); - initial_state.nodes[0].AddIntAttribute(ui::AX_ATTR_ACTIVEDESCENDANT_ID, 2); + initial_state.nodes[0].AddIntAttribute( + ax::mojom::IntAttribute::kActivedescendantId, 2); initial_state.nodes[1].id = 2; - initial_state.nodes[1].role = ui::AX_ROLE_MENU_LIST_OPTION; + initial_state.nodes[1].role = ax::mojom::Role::kMenuListOption; initial_state.nodes[2].id = 3; - initial_state.nodes[2].role = ui::AX_ROLE_MENU_LIST_OPTION; + initial_state.nodes[2].role = ax::mojom::Role::kMenuListOption; AXTree tree(initial_state); AXEventGenerator event_generator(&tree); AXTreeUpdate update = initial_state; update.nodes[0].int_attributes.clear(); - update.nodes[0].AddIntAttribute(ui::AX_ATTR_ACTIVEDESCENDANT_ID, 3); + update.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kActivedescendantId, + 3); EXPECT_TRUE(tree.Unserialize(update)); EXPECT_EQ( "ACTIVE_DESCENDANT_CHANGED on 1, " diff --git a/ui/accessibility/ax_node.cc b/ui/accessibility/ax_node.cc index 8327ccd786e12e..72386b2ea33cdb 100644 --- a/ui/accessibility/ax_node.cc +++ b/ui/accessibility/ax_node.cc @@ -7,7 +7,7 @@ #include #include "base/strings/string16.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/gfx/transform.h" namespace ui { @@ -21,9 +21,9 @@ AXNode::~AXNode() { } bool AXNode::IsTextNode() const { - return data().role == AX_ROLE_STATIC_TEXT || - data().role == AX_ROLE_LINE_BREAK || - data().role == AX_ROLE_INLINE_TEXT_BOX; + return data().role == ax::mojom::Role::kStaticText || + data().role == ax::mojom::Role::kLineBreak || + data().role == ax::mojom::Role::kInlineTextBox; } void AXNode::SetData(const AXNodeData& src) { @@ -64,12 +64,14 @@ bool AXNode::IsDescendantOf(AXNode* ancestor) { std::vector AXNode::GetOrComputeLineStartOffsets() { std::vector line_offsets; - if (data().GetIntListAttribute(AX_ATTR_CACHED_LINE_STARTS, &line_offsets)) + if (data().GetIntListAttribute(ax::mojom::IntListAttribute::kCachedLineStarts, + &line_offsets)) return line_offsets; int start_offset = 0; ComputeLineStartOffsets(&line_offsets, &start_offset); - data_.AddIntListAttribute(AX_ATTR_CACHED_LINE_STARTS, line_offsets); + data_.AddIntListAttribute(ax::mojom::IntListAttribute::kCachedLineStarts, + line_offsets); return line_offsets; } @@ -85,15 +87,16 @@ void AXNode::ComputeLineStartOffsets(std::vector* line_offsets, } // Don't report if the first piece of text starts a new line or not. - if (*start_offset && - !child->data().HasIntAttribute(ui::AX_ATTR_PREVIOUS_ON_LINE_ID)) { + if (*start_offset && !child->data().HasIntAttribute( + ax::mojom::IntAttribute::kPreviousOnLineId)) { // If there are multiple objects with an empty accessible label at the // start of a line, only include a single line start offset. if (line_offsets->empty() || line_offsets->back() != *start_offset) line_offsets->push_back(*start_offset); } - base::string16 text = child->data().GetString16Attribute(ui::AX_ATTR_NAME); + base::string16 text = + child->data().GetString16Attribute(ax::mojom::StringAttribute::kName); *start_offset += static_cast(text.length()); } } diff --git a/ui/accessibility/ax_node_data.cc b/ui/accessibility/ax_node_data.cc index b78f71e40df4ff..ff85ee23a0fab8 100644 --- a/ui/accessibility/ax_node_data.cc +++ b/ui/accessibility/ax_node_data.cc @@ -13,6 +13,7 @@ #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" +#include "ui/accessibility/ax_enum_util.h" #include "ui/accessibility/ax_text_utils.h" #include "ui/gfx/transform.h" @@ -30,20 +31,21 @@ uint32_t ModifyFlag(uint32_t bitfield, uint32_t flag, bool set) { std::string StateBitfieldToString(uint32_t state) { std::string str; - for (uint32_t i = static_cast(AX_STATE_NONE) + 1; - i <= static_cast(AX_STATE_LAST); ++i) { + for (uint32_t i = static_cast(ax::mojom::State::kNone) + 1; + i <= static_cast(ax::mojom::State::kLast); ++i) { if (IsFlagSet(state, i)) - str += " " + base::ToUpperASCII(ui::ToString(static_cast(i))); + str += " " + + base::ToUpperASCII(ui::ToString(static_cast(i))); } return str; } std::string ActionsBitfieldToString(uint32_t actions) { std::string str; - for (uint32_t i = static_cast(AX_ACTION_NONE) + 1; - i <= static_cast(AX_ACTION_LAST); ++i) { + for (uint32_t i = static_cast(ax::mojom::Action::kNone) + 1; + i <= static_cast(ax::mojom::Action::kLast); ++i) { if (IsFlagSet(actions, i)) { - str += ui::ToString(static_cast(i)); + str += ui::ToString(static_cast(i)); actions = ModifyFlag(actions, i, false); str += actions ? "," : ""; } @@ -88,64 +90,64 @@ typename std::vector>::const_iterator // Return true if |attr| is a node ID that would need to be mapped when // renumbering the ids in a combined tree. -bool IsNodeIdIntAttribute(AXIntAttribute attr) { +bool IsNodeIdIntAttribute(ax::mojom::IntAttribute attr) { switch (attr) { - case AX_ATTR_ACTIVEDESCENDANT_ID: - case AX_ATTR_DETAILS_ID: - case AX_ATTR_ERRORMESSAGE_ID: - case AX_ATTR_IN_PAGE_LINK_TARGET_ID: - case AX_ATTR_MEMBER_OF_ID: - case AX_ATTR_NEXT_ON_LINE_ID: - case AX_ATTR_PREVIOUS_ON_LINE_ID: - case AX_ATTR_TABLE_HEADER_ID: - case AX_ATTR_TABLE_COLUMN_HEADER_ID: - case AX_ATTR_TABLE_ROW_HEADER_ID: - case AX_ATTR_NEXT_FOCUS_ID: - case AX_ATTR_PREVIOUS_FOCUS_ID: + case ax::mojom::IntAttribute::kActivedescendantId: + case ax::mojom::IntAttribute::kDetailsId: + case ax::mojom::IntAttribute::kErrormessageId: + case ax::mojom::IntAttribute::kInPageLinkTargetId: + case ax::mojom::IntAttribute::kMemberOfId: + case ax::mojom::IntAttribute::kNextOnLineId: + case ax::mojom::IntAttribute::kPreviousOnLineId: + case ax::mojom::IntAttribute::kTableHeaderId: + case ax::mojom::IntAttribute::kTableColumnHeaderId: + case ax::mojom::IntAttribute::kTableRowHeaderId: + case ax::mojom::IntAttribute::kNextFocusId: + case ax::mojom::IntAttribute::kPreviousFocusId: return true; // Note: all of the attributes are included here explicitly, // rather than using "default:", so that it's a compiler error to // add a new attribute without explicitly considering whether it's // a node id attribute or not. - case AX_INT_ATTRIBUTE_NONE: - case AX_ATTR_DEFAULT_ACTION_VERB: - case AX_ATTR_SCROLL_X: - case AX_ATTR_SCROLL_X_MIN: - case AX_ATTR_SCROLL_X_MAX: - case AX_ATTR_SCROLL_Y: - case AX_ATTR_SCROLL_Y_MIN: - case AX_ATTR_SCROLL_Y_MAX: - case AX_ATTR_TEXT_SEL_START: - case AX_ATTR_TEXT_SEL_END: - case AX_ATTR_TABLE_ROW_COUNT: - case AX_ATTR_TABLE_COLUMN_COUNT: - case AX_ATTR_TABLE_ROW_INDEX: - case AX_ATTR_TABLE_COLUMN_INDEX: - case AX_ATTR_TABLE_CELL_COLUMN_INDEX: - case AX_ATTR_TABLE_CELL_COLUMN_SPAN: - case AX_ATTR_TABLE_CELL_ROW_INDEX: - case AX_ATTR_TABLE_CELL_ROW_SPAN: - case AX_ATTR_SORT_DIRECTION: - case AX_ATTR_HIERARCHICAL_LEVEL: - case AX_ATTR_NAME_FROM: - case AX_ATTR_DESCRIPTION_FROM: - case AX_ATTR_CHILD_TREE_ID: - case AX_ATTR_SET_SIZE: - case AX_ATTR_POS_IN_SET: - case AX_ATTR_COLOR_VALUE: - case AX_ATTR_ARIA_CURRENT_STATE: - case AX_ATTR_BACKGROUND_COLOR: - case AX_ATTR_COLOR: - case AX_ATTR_INVALID_STATE: - case AX_ATTR_CHECKED_STATE: - case AX_ATTR_RESTRICTION: - case AX_ATTR_TEXT_DIRECTION: - case AX_ATTR_TEXT_STYLE: - case AX_ATTR_ARIA_COLUMN_COUNT: - case AX_ATTR_ARIA_CELL_COLUMN_INDEX: - case AX_ATTR_ARIA_ROW_COUNT: - case AX_ATTR_ARIA_CELL_ROW_INDEX: + case ax::mojom::IntAttribute::kNone: + case ax::mojom::IntAttribute::kDefaultActionVerb: + case ax::mojom::IntAttribute::kScrollX: + case ax::mojom::IntAttribute::kScrollXMin: + case ax::mojom::IntAttribute::kScrollXMax: + case ax::mojom::IntAttribute::kScrollY: + case ax::mojom::IntAttribute::kScrollYMin: + case ax::mojom::IntAttribute::kScrollYMax: + case ax::mojom::IntAttribute::kTextSelStart: + case ax::mojom::IntAttribute::kTextSelEnd: + case ax::mojom::IntAttribute::kTableRowCount: + case ax::mojom::IntAttribute::kTableColumnCount: + case ax::mojom::IntAttribute::kTableRowIndex: + case ax::mojom::IntAttribute::kTableColumnIndex: + case ax::mojom::IntAttribute::kTableCellColumnIndex: + case ax::mojom::IntAttribute::kTableCellColumnSpan: + case ax::mojom::IntAttribute::kTableCellRowIndex: + case ax::mojom::IntAttribute::kTableCellRowSpan: + case ax::mojom::IntAttribute::kSortDirection: + case ax::mojom::IntAttribute::kHierarchicalLevel: + case ax::mojom::IntAttribute::kNameFrom: + case ax::mojom::IntAttribute::kDescriptionFrom: + case ax::mojom::IntAttribute::kChildTreeId: + case ax::mojom::IntAttribute::kSetSize: + case ax::mojom::IntAttribute::kPosInSet: + case ax::mojom::IntAttribute::kColorValue: + case ax::mojom::IntAttribute::kAriaCurrentState: + case ax::mojom::IntAttribute::kBackgroundColor: + case ax::mojom::IntAttribute::kColor: + case ax::mojom::IntAttribute::kInvalidState: + case ax::mojom::IntAttribute::kCheckedState: + case ax::mojom::IntAttribute::kRestriction: + case ax::mojom::IntAttribute::kTextDirection: + case ax::mojom::IntAttribute::kTextStyle: + case ax::mojom::IntAttribute::kAriaColumnCount: + case ax::mojom::IntAttribute::kAriaCellColumnIndex: + case ax::mojom::IntAttribute::kAriaRowCount: + case ax::mojom::IntAttribute::kAriaCellRowIndex: return false; } @@ -155,32 +157,32 @@ bool IsNodeIdIntAttribute(AXIntAttribute attr) { // Return true if |attr| contains a vector of node ids that would need // to be mapped when renumbering the ids in a combined tree. -bool IsNodeIdIntListAttribute(AXIntListAttribute attr) { +bool IsNodeIdIntListAttribute(ax::mojom::IntListAttribute attr) { switch (attr) { - case AX_ATTR_CELL_IDS: - case AX_ATTR_CONTROLS_IDS: - case AX_ATTR_DESCRIBEDBY_IDS: - case AX_ATTR_FLOWTO_IDS: - case AX_ATTR_INDIRECT_CHILD_IDS: - case AX_ATTR_LABELLEDBY_IDS: - case AX_ATTR_RADIO_GROUP_IDS: - case AX_ATTR_UNIQUE_CELL_IDS: + case ax::mojom::IntListAttribute::kCellIds: + case ax::mojom::IntListAttribute::kControlsIds: + case ax::mojom::IntListAttribute::kDescribedbyIds: + case ax::mojom::IntListAttribute::kFlowtoIds: + case ax::mojom::IntListAttribute::kIndirectChildIds: + case ax::mojom::IntListAttribute::kLabelledbyIds: + case ax::mojom::IntListAttribute::kRadioGroupIds: + case ax::mojom::IntListAttribute::kUniqueCellIds: return true; // Note: all of the attributes are included here explicitly, // rather than using "default:", so that it's a compiler error to // add a new attribute without explicitly considering whether it's // a node id attribute or not. - case AX_INT_LIST_ATTRIBUTE_NONE: - case AX_ATTR_LINE_BREAKS: - case AX_ATTR_MARKER_TYPES: - case AX_ATTR_MARKER_STARTS: - case AX_ATTR_MARKER_ENDS: - case AX_ATTR_CHARACTER_OFFSETS: - case AX_ATTR_CACHED_LINE_STARTS: - case AX_ATTR_WORD_STARTS: - case AX_ATTR_WORD_ENDS: - case AX_ATTR_CUSTOM_ACTION_IDS: + case ax::mojom::IntListAttribute::kNone: + case ax::mojom::IntListAttribute::kLineBreaks: + case ax::mojom::IntListAttribute::kMarkerTypes: + case ax::mojom::IntListAttribute::kMarkerStarts: + case ax::mojom::IntListAttribute::kMarkerEnds: + case ax::mojom::IntListAttribute::kCharacterOffsets: + case ax::mojom::IntListAttribute::kCachedLineStarts: + case ax::mojom::IntListAttribute::kWordStarts: + case ax::mojom::IntListAttribute::kWordEnds: + case ax::mojom::IntListAttribute::kCustomActionIds: return false; } @@ -232,20 +234,20 @@ AXNodeData& AXNodeData::operator=(AXNodeData other) { return *this; } -bool AXNodeData::HasBoolAttribute(AXBoolAttribute attribute) const { +bool AXNodeData::HasBoolAttribute(ax::mojom::BoolAttribute attribute) const { auto iter = FindInVectorOfPairs(attribute, bool_attributes); return iter != bool_attributes.end(); } -bool AXNodeData::GetBoolAttribute(AXBoolAttribute attribute) const { +bool AXNodeData::GetBoolAttribute(ax::mojom::BoolAttribute attribute) const { bool result; if (GetBoolAttribute(attribute, &result)) return result; return false; } -bool AXNodeData::GetBoolAttribute( - AXBoolAttribute attribute, bool* value) const { +bool AXNodeData::GetBoolAttribute(ax::mojom::BoolAttribute attribute, + bool* value) const { auto iter = FindInVectorOfPairs(attribute, bool_attributes); if (iter != bool_attributes.end()) { *value = iter->second; @@ -255,20 +257,20 @@ bool AXNodeData::GetBoolAttribute( return false; } -bool AXNodeData::HasFloatAttribute(AXFloatAttribute attribute) const { +bool AXNodeData::HasFloatAttribute(ax::mojom::FloatAttribute attribute) const { auto iter = FindInVectorOfPairs(attribute, float_attributes); return iter != float_attributes.end(); } -float AXNodeData::GetFloatAttribute(AXFloatAttribute attribute) const { +float AXNodeData::GetFloatAttribute(ax::mojom::FloatAttribute attribute) const { float result; if (GetFloatAttribute(attribute, &result)) return result; return 0.0; } -bool AXNodeData::GetFloatAttribute( - AXFloatAttribute attribute, float* value) const { +bool AXNodeData::GetFloatAttribute(ax::mojom::FloatAttribute attribute, + float* value) const { auto iter = FindInVectorOfPairs(attribute, float_attributes); if (iter != float_attributes.end()) { *value = iter->second; @@ -278,20 +280,20 @@ bool AXNodeData::GetFloatAttribute( return false; } -bool AXNodeData::HasIntAttribute(AXIntAttribute attribute) const { +bool AXNodeData::HasIntAttribute(ax::mojom::IntAttribute attribute) const { auto iter = FindInVectorOfPairs(attribute, int_attributes); return iter != int_attributes.end(); } -int AXNodeData::GetIntAttribute(AXIntAttribute attribute) const { +int AXNodeData::GetIntAttribute(ax::mojom::IntAttribute attribute) const { int result; if (GetIntAttribute(attribute, &result)) return result; return 0; } -bool AXNodeData::GetIntAttribute( - AXIntAttribute attribute, int* value) const { +bool AXNodeData::GetIntAttribute(ax::mojom::IntAttribute attribute, + int* value) const { auto iter = FindInVectorOfPairs(attribute, int_attributes); if (iter != int_attributes.end()) { *value = iter->second; @@ -301,20 +303,21 @@ bool AXNodeData::GetIntAttribute( return false; } -bool AXNodeData::HasStringAttribute(AXStringAttribute attribute) const { +bool AXNodeData::HasStringAttribute( + ax::mojom::StringAttribute attribute) const { auto iter = FindInVectorOfPairs(attribute, string_attributes); return iter != string_attributes.end(); } const std::string& AXNodeData::GetStringAttribute( - AXStringAttribute attribute) const { + ax::mojom::StringAttribute attribute) const { CR_DEFINE_STATIC_LOCAL(std::string, empty_string, ()); auto iter = FindInVectorOfPairs(attribute, string_attributes); return iter != string_attributes.end() ? iter->second : empty_string; } -bool AXNodeData::GetStringAttribute( - AXStringAttribute attribute, std::string* value) const { +bool AXNodeData::GetStringAttribute(ax::mojom::StringAttribute attribute, + std::string* value) const { auto iter = FindInVectorOfPairs(attribute, string_attributes); if (iter != string_attributes.end()) { *value = iter->second; @@ -325,16 +328,15 @@ bool AXNodeData::GetStringAttribute( } base::string16 AXNodeData::GetString16Attribute( - AXStringAttribute attribute) const { + ax::mojom::StringAttribute attribute) const { std::string value_utf8; if (!GetStringAttribute(attribute, &value_utf8)) return base::string16(); return base::UTF8ToUTF16(value_utf8); } -bool AXNodeData::GetString16Attribute( - AXStringAttribute attribute, - base::string16* value) const { +bool AXNodeData::GetString16Attribute(ax::mojom::StringAttribute attribute, + base::string16* value) const { std::string value_utf8; if (!GetStringAttribute(attribute, &value_utf8)) return false; @@ -342,13 +344,14 @@ bool AXNodeData::GetString16Attribute( return true; } -bool AXNodeData::HasIntListAttribute(AXIntListAttribute attribute) const { +bool AXNodeData::HasIntListAttribute( + ax::mojom::IntListAttribute attribute) const { auto iter = FindInVectorOfPairs(attribute, intlist_attributes); return iter != intlist_attributes.end(); } const std::vector& AXNodeData::GetIntListAttribute( - AXIntListAttribute attribute) const { + ax::mojom::IntListAttribute attribute) const { CR_DEFINE_STATIC_LOCAL(std::vector, empty_vector, ()); auto iter = FindInVectorOfPairs(attribute, intlist_attributes); if (iter != intlist_attributes.end()) @@ -356,7 +359,7 @@ const std::vector& AXNodeData::GetIntListAttribute( return empty_vector; } -bool AXNodeData::GetIntListAttribute(AXIntListAttribute attribute, +bool AXNodeData::GetIntListAttribute(ax::mojom::IntListAttribute attribute, std::vector* value) const { auto iter = FindInVectorOfPairs(attribute, intlist_attributes); if (iter != intlist_attributes.end()) { @@ -367,13 +370,14 @@ bool AXNodeData::GetIntListAttribute(AXIntListAttribute attribute, return false; } -bool AXNodeData::HasStringListAttribute(AXStringListAttribute attribute) const { +bool AXNodeData::HasStringListAttribute( + ax::mojom::StringListAttribute attribute) const { auto iter = FindInVectorOfPairs(attribute, stringlist_attributes); return iter != stringlist_attributes.end(); } const std::vector& AXNodeData::GetStringListAttribute( - AXStringListAttribute attribute) const { + ax::mojom::StringListAttribute attribute) const { CR_DEFINE_STATIC_LOCAL(std::vector, empty_vector, ()); auto iter = FindInVectorOfPairs(attribute, stringlist_attributes); if (iter != stringlist_attributes.end()) @@ -381,8 +385,9 @@ const std::vector& AXNodeData::GetStringListAttribute( return empty_vector; } -bool AXNodeData::GetStringListAttribute(AXStringListAttribute attribute, - std::vector* value) const { +bool AXNodeData::GetStringListAttribute( + ax::mojom::StringListAttribute attribute, + std::vector* value) const { auto iter = FindInVectorOfPairs(attribute, stringlist_attributes); if (iter != stringlist_attributes.end()) { *value = iter->second; @@ -414,45 +419,46 @@ bool AXNodeData::GetHtmlAttribute( return true; } -void AXNodeData::AddStringAttribute( - AXStringAttribute attribute, const std::string& value) { +void AXNodeData::AddStringAttribute(ax::mojom::StringAttribute attribute, + const std::string& value) { string_attributes.push_back(std::make_pair(attribute, value)); } -void AXNodeData::AddIntAttribute( - AXIntAttribute attribute, int value) { +void AXNodeData::AddIntAttribute(ax::mojom::IntAttribute attribute, int value) { int_attributes.push_back(std::make_pair(attribute, value)); } -void AXNodeData::AddFloatAttribute( - AXFloatAttribute attribute, float value) { +void AXNodeData::AddFloatAttribute(ax::mojom::FloatAttribute attribute, + float value) { float_attributes.push_back(std::make_pair(attribute, value)); } -void AXNodeData::AddBoolAttribute( - AXBoolAttribute attribute, bool value) { +void AXNodeData::AddBoolAttribute(ax::mojom::BoolAttribute attribute, + bool value) { bool_attributes.push_back(std::make_pair(attribute, value)); } -void AXNodeData::AddIntListAttribute(AXIntListAttribute attribute, +void AXNodeData::AddIntListAttribute(ax::mojom::IntListAttribute attribute, const std::vector& value) { intlist_attributes.push_back(std::make_pair(attribute, value)); } -void AXNodeData::AddStringListAttribute(AXStringListAttribute attribute, - const std::vector& value) { +void AXNodeData::AddStringListAttribute( + ax::mojom::StringListAttribute attribute, + const std::vector& value) { stringlist_attributes.push_back(std::make_pair(attribute, value)); } void AXNodeData::SetName(const std::string& name) { for (size_t i = 0; i < string_attributes.size(); ++i) { - if (string_attributes[i].first == AX_ATTR_NAME) { + if (string_attributes[i].first == ax::mojom::StringAttribute::kName) { string_attributes[i].second = name; return; } } - string_attributes.push_back(std::make_pair(AX_ATTR_NAME, name)); + string_attributes.push_back( + std::make_pair(ax::mojom::StringAttribute::kName, name)); } void AXNodeData::SetName(const base::string16& name) { @@ -461,35 +467,36 @@ void AXNodeData::SetName(const base::string16& name) { void AXNodeData::SetValue(const std::string& value) { for (size_t i = 0; i < string_attributes.size(); ++i) { - if (string_attributes[i].first == AX_ATTR_VALUE) { + if (string_attributes[i].first == ax::mojom::StringAttribute::kValue) { string_attributes[i].second = value; return; } } - string_attributes.push_back(std::make_pair(AX_ATTR_VALUE, value)); + string_attributes.push_back( + std::make_pair(ax::mojom::StringAttribute::kValue, value)); } void AXNodeData::SetValue(const base::string16& value) { SetValue(base::UTF16ToUTF8(value)); } -bool AXNodeData::HasState(AXState state_enum) const { +bool AXNodeData::HasState(ax::mojom::State state_enum) const { return IsFlagSet(state, static_cast(state_enum)); } -bool AXNodeData::HasAction(AXAction action_enum) const { +bool AXNodeData::HasAction(ax::mojom::Action action_enum) const { return IsFlagSet(actions, static_cast(action_enum)); } -void AXNodeData::AddState(AXState state_enum) { - DCHECK_NE(state_enum, AX_STATE_NONE); +void AXNodeData::AddState(ax::mojom::State state_enum) { + DCHECK_NE(state_enum, ax::mojom::State::kNone); state = ModifyFlag(state, static_cast(state_enum), true); } -void AXNodeData::AddAction(AXAction action_enum) { +void AXNodeData::AddAction(ax::mojom::Action action_enum) { switch (action_enum) { - case AX_ACTION_NONE: + case ax::mojom::Action::kNone: NOTREACHED(); break; @@ -497,33 +504,34 @@ void AXNodeData::AddAction(AXAction action_enum) { // using "default:", so that it's a compiler error to add a new action // without explicitly considering whether there are mutually exclusive // actions that can be performed on a UI control at the same time. - case AX_ACTION_BLUR: - case AX_ACTION_FOCUS: { - AXAction excluded_action = - (action_enum == AX_ACTION_BLUR) ? AX_ACTION_FOCUS : AX_ACTION_BLUR; + case ax::mojom::Action::kBlur: + case ax::mojom::Action::kFocus: { + ax::mojom::Action excluded_action = + (action_enum == ax::mojom::Action::kBlur) ? ax::mojom::Action::kFocus + : ax::mojom::Action::kBlur; DCHECK(HasAction(excluded_action)); } break; - case AX_ACTION_CUSTOM_ACTION: - case AX_ACTION_DECREMENT: - case AX_ACTION_DO_DEFAULT: - case AX_ACTION_GET_IMAGE_DATA: - case AX_ACTION_HIT_TEST: - case AX_ACTION_INCREMENT: - case AX_ACTION_LOAD_INLINE_TEXT_BOXES: - case AX_ACTION_REPLACE_SELECTED_TEXT: - case AX_ACTION_SCROLL_TO_MAKE_VISIBLE: - case AX_ACTION_SCROLL_TO_POINT: - case AX_ACTION_SET_SCROLL_OFFSET: - case AX_ACTION_SET_SELECTION: - case AX_ACTION_SET_SEQUENTIAL_FOCUS_NAVIGATION_STARTING_POINT: - case AX_ACTION_SET_VALUE: - case AX_ACTION_SHOW_CONTEXT_MENU: - case AX_ACTION_SCROLL_BACKWARD: - case AX_ACTION_SCROLL_FORWARD: - case AX_ACTION_SCROLL_UP: - case AX_ACTION_SCROLL_DOWN: - case AX_ACTION_SCROLL_LEFT: - case AX_ACTION_SCROLL_RIGHT: + case ax::mojom::Action::kCustomAction: + case ax::mojom::Action::kDecrement: + case ax::mojom::Action::kDoDefault: + case ax::mojom::Action::kGetImageData: + case ax::mojom::Action::kHitTest: + case ax::mojom::Action::kIncrement: + case ax::mojom::Action::kLoadInlineTextBoxes: + case ax::mojom::Action::kReplaceSelectedText: + case ax::mojom::Action::kScrollToMakeVisible: + case ax::mojom::Action::kScrollToPoint: + case ax::mojom::Action::kSetScrollOffset: + case ax::mojom::Action::kSetSelection: + case ax::mojom::Action::kSetSequentialFocusNavigationStartingPoint: + case ax::mojom::Action::kSetValue: + case ax::mojom::Action::kShowContextMenu: + case ax::mojom::Action::kScrollBackward: + case ax::mojom::Action::kScrollForward: + case ax::mojom::Action::kScrollUp: + case ax::mojom::Action::kScrollDown: + case ax::mojom::Action::kScrollLeft: + case ax::mojom::Action::kScrollRight: break; } @@ -554,269 +562,277 @@ std::string AXNodeData::ToString() const { for (size_t i = 0; i < int_attributes.size(); ++i) { std::string value = base::NumberToString(int_attributes[i].second); switch (int_attributes[i].first) { - case AX_ATTR_DEFAULT_ACTION_VERB: - result += - " action=" + - base::UTF16ToUTF8(ActionVerbToUnlocalizedString( - static_cast(int_attributes[i].second))); + case ax::mojom::IntAttribute::kDefaultActionVerb: + result += " action=" + base::UTF16ToUTF8(ActionVerbToUnlocalizedString( + static_cast( + int_attributes[i].second))); break; - case AX_ATTR_SCROLL_X: + case ax::mojom::IntAttribute::kScrollX: result += " scroll_x=" + value; break; - case AX_ATTR_SCROLL_X_MIN: + case ax::mojom::IntAttribute::kScrollXMin: result += " scroll_x_min=" + value; break; - case AX_ATTR_SCROLL_X_MAX: + case ax::mojom::IntAttribute::kScrollXMax: result += " scroll_x_max=" + value; break; - case AX_ATTR_SCROLL_Y: + case ax::mojom::IntAttribute::kScrollY: result += " scroll_y=" + value; break; - case AX_ATTR_SCROLL_Y_MIN: + case ax::mojom::IntAttribute::kScrollYMin: result += " scroll_y_min=" + value; break; - case AX_ATTR_SCROLL_Y_MAX: + case ax::mojom::IntAttribute::kScrollYMax: result += " scroll_y_max=" + value; break; - case AX_ATTR_HIERARCHICAL_LEVEL: + case ax::mojom::IntAttribute::kHierarchicalLevel: result += " level=" + value; break; - case AX_ATTR_TEXT_SEL_START: + case ax::mojom::IntAttribute::kTextSelStart: result += " sel_start=" + value; break; - case AX_ATTR_TEXT_SEL_END: + case ax::mojom::IntAttribute::kTextSelEnd: result += " sel_end=" + value; break; - case AX_ATTR_ARIA_COLUMN_COUNT: + case ax::mojom::IntAttribute::kAriaColumnCount: result += " aria_column_count=" + value; break; - case AX_ATTR_ARIA_CELL_COLUMN_INDEX: + case ax::mojom::IntAttribute::kAriaCellColumnIndex: result += " aria_cell_column_index=" + value; break; - case AX_ATTR_ARIA_ROW_COUNT: + case ax::mojom::IntAttribute::kAriaRowCount: result += " aria_row_count=" + value; break; - case AX_ATTR_ARIA_CELL_ROW_INDEX: + case ax::mojom::IntAttribute::kAriaCellRowIndex: result += " aria_cell_row_index=" + value; break; - case AX_ATTR_TABLE_ROW_COUNT: + case ax::mojom::IntAttribute::kTableRowCount: result += " rows=" + value; break; - case AX_ATTR_TABLE_COLUMN_COUNT: + case ax::mojom::IntAttribute::kTableColumnCount: result += " cols=" + value; break; - case AX_ATTR_TABLE_CELL_COLUMN_INDEX: + case ax::mojom::IntAttribute::kTableCellColumnIndex: result += " col=" + value; break; - case AX_ATTR_TABLE_CELL_ROW_INDEX: + case ax::mojom::IntAttribute::kTableCellRowIndex: result += " row=" + value; break; - case AX_ATTR_TABLE_CELL_COLUMN_SPAN: + case ax::mojom::IntAttribute::kTableCellColumnSpan: result += " colspan=" + value; break; - case AX_ATTR_TABLE_CELL_ROW_SPAN: + case ax::mojom::IntAttribute::kTableCellRowSpan: result += " rowspan=" + value; break; - case AX_ATTR_TABLE_COLUMN_HEADER_ID: + case ax::mojom::IntAttribute::kTableColumnHeaderId: result += " column_header_id=" + value; break; - case AX_ATTR_TABLE_COLUMN_INDEX: + case ax::mojom::IntAttribute::kTableColumnIndex: result += " column_index=" + value; break; - case AX_ATTR_TABLE_HEADER_ID: + case ax::mojom::IntAttribute::kTableHeaderId: result += " header_id=" + value; break; - case AX_ATTR_TABLE_ROW_HEADER_ID: + case ax::mojom::IntAttribute::kTableRowHeaderId: result += " row_header_id=" + value; break; - case AX_ATTR_TABLE_ROW_INDEX: + case ax::mojom::IntAttribute::kTableRowIndex: result += " row_index=" + value; break; - case AX_ATTR_SORT_DIRECTION: - switch (static_cast(int_attributes[i].second)) { - case AX_SORT_DIRECTION_UNSORTED: + case ax::mojom::IntAttribute::kSortDirection: + switch ( + static_cast(int_attributes[i].second)) { + case ax::mojom::SortDirection::kUnsorted: result += " sort_direction=none"; break; - case AX_SORT_DIRECTION_ASCENDING: + case ax::mojom::SortDirection::kAscending: result += " sort_direction=ascending"; break; - case AX_SORT_DIRECTION_DESCENDING: + case ax::mojom::SortDirection::kDescending: result += " sort_direction=descending"; break; - case AX_SORT_DIRECTION_OTHER: + case ax::mojom::SortDirection::kOther: result += " sort_direction=other"; break; default: break; } break; - case AX_ATTR_NAME_FROM: + case ax::mojom::IntAttribute::kNameFrom: result += " name_from="; - result += - ui::ToString(static_cast(int_attributes[i].second)); + result += ui::ToString( + static_cast(int_attributes[i].second)); break; - case AX_ATTR_DESCRIPTION_FROM: + case ax::mojom::IntAttribute::kDescriptionFrom: result += " description_from="; result += ui::ToString( - static_cast(int_attributes[i].second)); + static_cast(int_attributes[i].second)); break; - case AX_ATTR_ACTIVEDESCENDANT_ID: + case ax::mojom::IntAttribute::kActivedescendantId: result += " activedescendant=" + value; break; - case AX_ATTR_DETAILS_ID: + case ax::mojom::IntAttribute::kDetailsId: result += " details=" + value; break; - case AX_ATTR_ERRORMESSAGE_ID: + case ax::mojom::IntAttribute::kErrormessageId: result += " errormessage=" + value; break; - case AX_ATTR_IN_PAGE_LINK_TARGET_ID: + case ax::mojom::IntAttribute::kInPageLinkTargetId: result += " in_page_link_target_id=" + value; break; - case AX_ATTR_MEMBER_OF_ID: + case ax::mojom::IntAttribute::kMemberOfId: result += " member_of_id=" + value; break; - case AX_ATTR_NEXT_ON_LINE_ID: + case ax::mojom::IntAttribute::kNextOnLineId: result += " next_on_line_id=" + value; break; - case AX_ATTR_PREVIOUS_ON_LINE_ID: + case ax::mojom::IntAttribute::kPreviousOnLineId: result += " previous_on_line_id=" + value; break; - case AX_ATTR_CHILD_TREE_ID: + case ax::mojom::IntAttribute::kChildTreeId: result += " child_tree_id=" + value; break; - case AX_ATTR_COLOR_VALUE: + case ax::mojom::IntAttribute::kColorValue: result += base::StringPrintf(" color_value=&%X", int_attributes[i].second); break; - case AX_ATTR_ARIA_CURRENT_STATE: - switch (static_cast(int_attributes[i].second)) { - case AX_ARIA_CURRENT_STATE_FALSE: + case ax::mojom::IntAttribute::kAriaCurrentState: + switch (static_cast( + int_attributes[i].second)) { + case ax::mojom::AriaCurrentState::kFalse: result += " aria_current_state=false"; break; - case AX_ARIA_CURRENT_STATE_TRUE: + case ax::mojom::AriaCurrentState::kTrue: result += " aria_current_state=true"; break; - case AX_ARIA_CURRENT_STATE_PAGE: + case ax::mojom::AriaCurrentState::kPage: result += " aria_current_state=page"; break; - case AX_ARIA_CURRENT_STATE_STEP: + case ax::mojom::AriaCurrentState::kStep: result += " aria_current_state=step"; break; - case AX_ARIA_CURRENT_STATE_LOCATION: + case ax::mojom::AriaCurrentState::kLocation: result += " aria_current_state=location"; break; - case AX_ARIA_CURRENT_STATE_DATE: + case ax::mojom::AriaCurrentState::kDate: result += " aria_current_state=date"; break; - case AX_ARIA_CURRENT_STATE_TIME: + case ax::mojom::AriaCurrentState::kTime: result += " aria_current_state=time"; break; default: break; } break; - case AX_ATTR_BACKGROUND_COLOR: + case ax::mojom::IntAttribute::kBackgroundColor: result += base::StringPrintf(" background_color=&%X", int_attributes[i].second); break; - case AX_ATTR_COLOR: + case ax::mojom::IntAttribute::kColor: result += base::StringPrintf(" color=&%X", int_attributes[i].second); break; - case AX_ATTR_TEXT_DIRECTION: - switch (static_cast(int_attributes[i].second)) { - case AX_TEXT_DIRECTION_LTR: + case ax::mojom::IntAttribute::kTextDirection: + switch ( + static_cast(int_attributes[i].second)) { + case ax::mojom::TextDirection::kLtr: result += " text_direction=ltr"; break; - case AX_TEXT_DIRECTION_RTL: + case ax::mojom::TextDirection::kRtl: result += " text_direction=rtl"; break; - case AX_TEXT_DIRECTION_TTB: + case ax::mojom::TextDirection::kTtb: result += " text_direction=ttb"; break; - case AX_TEXT_DIRECTION_BTT: + case ax::mojom::TextDirection::kBtt: result += " text_direction=btt"; break; default: break; } break; - case AX_ATTR_TEXT_STYLE: { + case ax::mojom::IntAttribute::kTextStyle: { int32_t text_style = int_attributes[i].second; - if (text_style == static_cast(AX_TEXT_STYLE_NONE)) + if (text_style == static_cast(ax::mojom::TextStyle::kNone)) break; std::string text_style_value(" text_style="); - if (text_style & static_cast(AX_TEXT_STYLE_BOLD)) + if (text_style & + static_cast(ax::mojom::TextStyle::kTextStyleBold)) text_style_value += "bold,"; - if (text_style & static_cast(AX_TEXT_STYLE_ITALIC)) + if (text_style & + static_cast(ax::mojom::TextStyle::kTextStyleItalic)) text_style_value += "italic,"; - if (text_style & static_cast(AX_TEXT_STYLE_UNDERLINE)) + if (text_style & + static_cast(ax::mojom::TextStyle::kTextStyleUnderline)) text_style_value += "underline,"; - if (text_style & static_cast(AX_TEXT_STYLE_LINE_THROUGH)) + if (text_style & + static_cast(ax::mojom::TextStyle::kTextStyleLineThrough)) text_style_value += "line-through,"; result += text_style_value.substr(0, text_style_value.size() - 1); break; } - case AX_ATTR_SET_SIZE: + case ax::mojom::IntAttribute::kSetSize: result += " setsize=" + value; break; - case AX_ATTR_POS_IN_SET: + case ax::mojom::IntAttribute::kPosInSet: result += " posinset=" + value; break; - case AX_ATTR_INVALID_STATE: - switch (static_cast(int_attributes[i].second)) { - case AX_INVALID_STATE_FALSE: + case ax::mojom::IntAttribute::kInvalidState: + switch ( + static_cast(int_attributes[i].second)) { + case ax::mojom::InvalidState::kFalse: result += " invalid_state=false"; break; - case AX_INVALID_STATE_TRUE: + case ax::mojom::InvalidState::kTrue: result += " invalid_state=true"; break; - case AX_INVALID_STATE_SPELLING: + case ax::mojom::InvalidState::kSpelling: result += " invalid_state=spelling"; break; - case AX_INVALID_STATE_GRAMMAR: + case ax::mojom::InvalidState::kGrammar: result += " invalid_state=grammar"; break; - case AX_INVALID_STATE_OTHER: + case ax::mojom::InvalidState::kOther: result += " invalid_state=other"; break; default: break; } break; - case AX_ATTR_CHECKED_STATE: - switch (static_cast(int_attributes[i].second)) { - case AX_CHECKED_STATE_FALSE: + case ax::mojom::IntAttribute::kCheckedState: + switch ( + static_cast(int_attributes[i].second)) { + case ax::mojom::CheckedState::kFalse: result += " checked_state=false"; break; - case AX_CHECKED_STATE_TRUE: + case ax::mojom::CheckedState::kTrue: result += " checked_state=true"; break; - case AX_CHECKED_STATE_MIXED: + case ax::mojom::CheckedState::kMixed: result += " checked_state=mixed"; break; default: break; } break; - case AX_ATTR_RESTRICTION: - switch (static_cast(int_attributes[i].second)) { - case AX_RESTRICTION_READ_ONLY: + case ax::mojom::IntAttribute::kRestriction: + switch (static_cast(int_attributes[i].second)) { + case ax::mojom::Restriction::kReadOnly: result += " restriction=readonly"; break; - case AX_RESTRICTION_DISABLED: + case ax::mojom::Restriction::kDisabled: result += " restriction=disabled"; break; default: break; } break; - case AX_ATTR_NEXT_FOCUS_ID: + case ax::mojom::IntAttribute::kNextFocusId: result += " next_focus_id=" + value; break; - case AX_ATTR_PREVIOUS_FOCUS_ID: + case ax::mojom::IntAttribute::kPreviousFocusId: result += " previous_focus_id=" + value; break; - case AX_INT_ATTRIBUTE_NONE: + case ax::mojom::IntAttribute::kNone: break; } } @@ -824,78 +840,78 @@ std::string AXNodeData::ToString() const { for (size_t i = 0; i < string_attributes.size(); ++i) { std::string value = string_attributes[i].second; switch (string_attributes[i].first) { - case AX_ATTR_ACCESS_KEY: + case ax::mojom::StringAttribute::kAccessKey: result += " access_key=" + value; break; - case AX_ATTR_ARIA_INVALID_VALUE: + case ax::mojom::StringAttribute::kAriaInvalidValue: result += " aria_invalid_value=" + value; break; - case AX_ATTR_AUTO_COMPLETE: + case ax::mojom::StringAttribute::kAutoComplete: result += " autocomplete=" + value; break; - case AX_ATTR_CHROME_CHANNEL: + case ax::mojom::StringAttribute::kChromeChannel: result += " chrome_channel=" + value; break; - case AX_ATTR_CLASS_NAME: + case ax::mojom::StringAttribute::kClassName: result += " class_name=" + value; break; - case AX_ATTR_DESCRIPTION: + case ax::mojom::StringAttribute::kDescription: result += " description=" + value; break; - case AX_ATTR_DISPLAY: + case ax::mojom::StringAttribute::kDisplay: result += " display=" + value; break; - case AX_ATTR_FONT_FAMILY: + case ax::mojom::StringAttribute::kFontFamily: result += " font-family=" + value; break; - case AX_ATTR_HTML_TAG: + case ax::mojom::StringAttribute::kHtmlTag: result += " html_tag=" + value; break; - case AX_ATTR_IMAGE_DATA_URL: + case ax::mojom::StringAttribute::kImageDataUrl: result += " image_data_url=(" + base::NumberToString(static_cast(value.size())) + " bytes)"; break; - case AX_ATTR_INNER_HTML: + case ax::mojom::StringAttribute::kInnerHtml: result += " inner_html=" + value; break; - case AX_ATTR_KEY_SHORTCUTS: + case ax::mojom::StringAttribute::kKeyShortcuts: result += " key_shortcuts=" + value; break; - case AX_ATTR_LANGUAGE: + case ax::mojom::StringAttribute::kLanguage: result += " language=" + value; break; - case AX_ATTR_LIVE_RELEVANT: + case ax::mojom::StringAttribute::kLiveRelevant: result += " relevant=" + value; break; - case AX_ATTR_LIVE_STATUS: + case ax::mojom::StringAttribute::kLiveStatus: result += " live=" + value; break; - case AX_ATTR_CONTAINER_LIVE_RELEVANT: + case ax::mojom::StringAttribute::kContainerLiveRelevant: result += " container_relevant=" + value; break; - case AX_ATTR_CONTAINER_LIVE_STATUS: + case ax::mojom::StringAttribute::kContainerLiveStatus: result += " container_live=" + value; break; - case AX_ATTR_PLACEHOLDER: + case ax::mojom::StringAttribute::kPlaceholder: result += " placeholder=" + value; break; - case AX_ATTR_ROLE: + case ax::mojom::StringAttribute::kRole: result += " role=" + value; break; - case AX_ATTR_ROLE_DESCRIPTION: + case ax::mojom::StringAttribute::kRoleDescription: result += " role_description=" + value; break; - case AX_ATTR_URL: + case ax::mojom::StringAttribute::kUrl: result += " url=" + value; break; - case AX_ATTR_NAME: + case ax::mojom::StringAttribute::kName: result += " name=" + value; break; - case AX_ATTR_VALUE: + case ax::mojom::StringAttribute::kValue: result += " value=" + value; break; - case AX_STRING_ATTRIBUTE_NONE: + case ax::mojom::StringAttribute::kNone: break; } } @@ -903,22 +919,22 @@ std::string AXNodeData::ToString() const { for (size_t i = 0; i < float_attributes.size(); ++i) { std::string value = base::NumberToString(float_attributes[i].second); switch (float_attributes[i].first) { - case AX_ATTR_VALUE_FOR_RANGE: + case ax::mojom::FloatAttribute::kValueForRange: result += " value_for_range=" + value; break; - case AX_ATTR_MAX_VALUE_FOR_RANGE: + case ax::mojom::FloatAttribute::kMaxValueForRange: result += " max_value=" + value; break; - case AX_ATTR_MIN_VALUE_FOR_RANGE: + case ax::mojom::FloatAttribute::kMinValueForRange: result += " min_value=" + value; break; - case AX_ATTR_STEP_VALUE_FOR_RANGE: + case ax::mojom::FloatAttribute::kStepValueForRange: result += " step_value=" + value; break; - case AX_ATTR_FONT_SIZE: + case ax::mojom::FloatAttribute::kFontSize: result += " font_size=" + value; break; - case AX_FLOAT_ATTRIBUTE_NONE: + case ax::mojom::FloatAttribute::kNone: break; } } @@ -926,40 +942,40 @@ std::string AXNodeData::ToString() const { for (size_t i = 0; i < bool_attributes.size(); ++i) { std::string value = bool_attributes[i].second ? "true" : "false"; switch (bool_attributes[i].first) { - case AX_ATTR_EDITABLE_ROOT: + case ax::mojom::BoolAttribute::kEditableRoot: result += " editable_root=" + value; break; - case AX_ATTR_LIVE_ATOMIC: + case ax::mojom::BoolAttribute::kLiveAtomic: result += " atomic=" + value; break; - case AX_ATTR_BUSY: + case ax::mojom::BoolAttribute::kBusy: result += " busy=" + value; break; - case AX_ATTR_CONTAINER_LIVE_ATOMIC: + case ax::mojom::BoolAttribute::kContainerLiveAtomic: result += " container_atomic=" + value; break; - case AX_ATTR_CONTAINER_LIVE_BUSY: + case ax::mojom::BoolAttribute::kContainerLiveBusy: result += " container_busy=" + value; break; - case AX_ATTR_UPDATE_LOCATION_ONLY: + case ax::mojom::BoolAttribute::kUpdateLocationOnly: result += " update_location_only=" + value; break; - case AX_ATTR_CANVAS_HAS_FALLBACK: + case ax::mojom::BoolAttribute::kCanvasHasFallback: result += " has_fallback=" + value; break; - case AX_ATTR_MODAL: + case ax::mojom::BoolAttribute::kModal: result += " modal=" + value; break; - case AX_ATTR_SCROLLABLE: + case ax::mojom::BoolAttribute::kScrollable: result += " scrollable=" + value; break; - case AX_ATTR_CLICKABLE: + case ax::mojom::BoolAttribute::kClickable: result += " clickable=" + value; break; - case AX_ATTR_CLIPS_CHILDREN: + case ax::mojom::BoolAttribute::kClipsChildren: result += " clips_children=" + value; break; - case AX_BOOL_ATTRIBUTE_NONE: + case ax::mojom::BoolAttribute::kNone: break; } } @@ -967,46 +983,47 @@ std::string AXNodeData::ToString() const { for (size_t i = 0; i < intlist_attributes.size(); ++i) { const std::vector& values = intlist_attributes[i].second; switch (intlist_attributes[i].first) { - case AX_ATTR_INDIRECT_CHILD_IDS: + case ax::mojom::IntListAttribute::kIndirectChildIds: result += " indirect_child_ids=" + IntVectorToString(values); break; - case AX_ATTR_CONTROLS_IDS: + case ax::mojom::IntListAttribute::kControlsIds: result += " controls_ids=" + IntVectorToString(values); break; - case AX_ATTR_DESCRIBEDBY_IDS: + case ax::mojom::IntListAttribute::kDescribedbyIds: result += " describedby_ids=" + IntVectorToString(values); break; - case AX_ATTR_FLOWTO_IDS: + case ax::mojom::IntListAttribute::kFlowtoIds: result += " flowto_ids=" + IntVectorToString(values); break; - case AX_ATTR_LABELLEDBY_IDS: + case ax::mojom::IntListAttribute::kLabelledbyIds: result += " labelledby_ids=" + IntVectorToString(values); break; - case AX_ATTR_RADIO_GROUP_IDS: + case ax::mojom::IntListAttribute::kRadioGroupIds: result += " radio_group_ids=" + IntVectorToString(values); break; - case AX_ATTR_LINE_BREAKS: + case ax::mojom::IntListAttribute::kLineBreaks: result += " line_breaks=" + IntVectorToString(values); break; - case AX_ATTR_MARKER_TYPES: { + case ax::mojom::IntListAttribute::kMarkerTypes: { std::string types_str; for (size_t i = 0; i < values.size(); ++i) { int32_t type = values[i]; - if (type == static_cast(AX_MARKER_TYPE_NONE)) + if (type == static_cast(ax::mojom::MarkerType::kNone)) continue; if (i > 0) types_str += ','; - if (type & static_cast(AX_MARKER_TYPE_SPELLING)) + if (type & static_cast(ax::mojom::MarkerType::kSpelling)) types_str += "spelling&"; - if (type & static_cast(AX_MARKER_TYPE_GRAMMAR)) + if (type & static_cast(ax::mojom::MarkerType::kGrammar)) types_str += "grammar&"; - if (type & static_cast(AX_MARKER_TYPE_TEXT_MATCH)) + if (type & static_cast(ax::mojom::MarkerType::kTextMatch)) types_str += "text_match&"; - if (type & static_cast(AX_MARKER_TYPE_ACTIVE_SUGGESTION)) + if (type & + static_cast(ax::mojom::MarkerType::kActiveSuggestion)) types_str += "active_suggestion&"; - if (type & static_cast(AX_MARKER_TYPE_SUGGESTION)) + if (type & static_cast(ax::mojom::MarkerType::kSuggestion)) types_str += "suggestion&"; if (!types_str.empty()) @@ -1017,34 +1034,34 @@ std::string AXNodeData::ToString() const { result += " marker_types=" + types_str; break; } - case AX_ATTR_MARKER_STARTS: + case ax::mojom::IntListAttribute::kMarkerStarts: result += " marker_starts=" + IntVectorToString(values); break; - case AX_ATTR_MARKER_ENDS: + case ax::mojom::IntListAttribute::kMarkerEnds: result += " marker_ends=" + IntVectorToString(values); break; - case AX_ATTR_CELL_IDS: + case ax::mojom::IntListAttribute::kCellIds: result += " cell_ids=" + IntVectorToString(values); break; - case AX_ATTR_UNIQUE_CELL_IDS: + case ax::mojom::IntListAttribute::kUniqueCellIds: result += " unique_cell_ids=" + IntVectorToString(values); break; - case AX_ATTR_CHARACTER_OFFSETS: + case ax::mojom::IntListAttribute::kCharacterOffsets: result += " character_offsets=" + IntVectorToString(values); break; - case AX_ATTR_CACHED_LINE_STARTS: + case ax::mojom::IntListAttribute::kCachedLineStarts: result += " cached_line_start_offsets=" + IntVectorToString(values); break; - case AX_ATTR_WORD_STARTS: + case ax::mojom::IntListAttribute::kWordStarts: result += " word_starts=" + IntVectorToString(values); break; - case AX_ATTR_WORD_ENDS: + case ax::mojom::IntListAttribute::kWordEnds: result += " word_ends=" + IntVectorToString(values); break; - case AX_ATTR_CUSTOM_ACTION_IDS: + case ax::mojom::IntListAttribute::kCustomActionIds: result += " custom_action_ids=" + IntVectorToString(values); break; - case AX_INT_LIST_ATTRIBUTE_NONE: + case ax::mojom::IntListAttribute::kNone: break; } } @@ -1052,11 +1069,11 @@ std::string AXNodeData::ToString() const { for (size_t i = 0; i < stringlist_attributes.size(); ++i) { const std::vector& values = stringlist_attributes[i].second; switch (stringlist_attributes[i].first) { - case AX_ATTR_CUSTOM_ACTION_DESCRIPTIONS: + case ax::mojom::StringListAttribute::kCustomActionDescriptions: result += " custom_action_descriptions: " + base::JoinString(values, ","); break; - case AX_STRING_LIST_ATTRIBUTE_NONE: + case ax::mojom::StringListAttribute::kNone: break; } } diff --git a/ui/accessibility/ax_node_data.h b/ui/accessibility/ax_node_data.h index ae9943deb6e502..6d2dd37af2fac1 100644 --- a/ui/accessibility/ax_node_data.h +++ b/ui/accessibility/ax_node_data.h @@ -14,7 +14,7 @@ #include "base/strings/string16.h" #include "base/strings/string_split.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_export.h" #include "ui/gfx/geometry/rect_f.h" @@ -26,11 +26,11 @@ namespace ui { // Return true if |attr| should be interpreted as the id of another node // in the same tree. -AX_EXPORT bool IsNodeIdIntAttribute(AXIntAttribute attr); +AX_EXPORT bool IsNodeIdIntAttribute(ax::mojom::IntAttribute attr); // Return true if |attr| should be interpreted as a list of ids of // nodes in the same tree. -AX_EXPORT bool IsNodeIdIntListAttribute(AXIntListAttribute attr); +AX_EXPORT bool IsNodeIdIntListAttribute(ax::mojom::IntListAttribute attr); // A compact representation of the accessibility information for a // single accessible object, in a form that can be serialized and sent from @@ -57,53 +57,53 @@ struct AX_EXPORT AXNodeData { // attribute is not present. In addition, strings can be returned as // either std::string or base::string16, for convenience. - bool HasBoolAttribute(AXBoolAttribute attr) const; - bool GetBoolAttribute(AXBoolAttribute attr) const; - bool GetBoolAttribute(AXBoolAttribute attr, bool* value) const; + bool HasBoolAttribute(ax::mojom::BoolAttribute attr) const; + bool GetBoolAttribute(ax::mojom::BoolAttribute attr) const; + bool GetBoolAttribute(ax::mojom::BoolAttribute attr, bool* value) const; - bool HasFloatAttribute(AXFloatAttribute attr) const; - float GetFloatAttribute(AXFloatAttribute attr) const; - bool GetFloatAttribute(AXFloatAttribute attr, float* value) const; + bool HasFloatAttribute(ax::mojom::FloatAttribute attr) const; + float GetFloatAttribute(ax::mojom::FloatAttribute attr) const; + bool GetFloatAttribute(ax::mojom::FloatAttribute attr, float* value) const; - bool HasIntAttribute(AXIntAttribute attribute) const; - int32_t GetIntAttribute(AXIntAttribute attribute) const; - bool GetIntAttribute(AXIntAttribute attribute, int* value) const; + bool HasIntAttribute(ax::mojom::IntAttribute attribute) const; + int32_t GetIntAttribute(ax::mojom::IntAttribute attribute) const; + bool GetIntAttribute(ax::mojom::IntAttribute attribute, int* value) const; - bool HasStringAttribute( - AXStringAttribute attribute) const; - const std::string& GetStringAttribute(AXStringAttribute attribute) const; - bool GetStringAttribute(AXStringAttribute attribute, + bool HasStringAttribute(ax::mojom::StringAttribute attribute) const; + const std::string& GetStringAttribute( + ax::mojom::StringAttribute attribute) const; + bool GetStringAttribute(ax::mojom::StringAttribute attribute, std::string* value) const; - bool GetString16Attribute(AXStringAttribute attribute, + bool GetString16Attribute(ax::mojom::StringAttribute attribute, base::string16* value) const; base::string16 GetString16Attribute( - AXStringAttribute attribute) const; + ax::mojom::StringAttribute attribute) const; - bool HasIntListAttribute(AXIntListAttribute attribute) const; + bool HasIntListAttribute(ax::mojom::IntListAttribute attribute) const; const std::vector& GetIntListAttribute( - AXIntListAttribute attribute) const; - bool GetIntListAttribute(AXIntListAttribute attribute, + ax::mojom::IntListAttribute attribute) const; + bool GetIntListAttribute(ax::mojom::IntListAttribute attribute, std::vector* value) const; - bool HasStringListAttribute(AXStringListAttribute attribute) const; + bool HasStringListAttribute(ax::mojom::StringListAttribute attribute) const; const std::vector& GetStringListAttribute( - AXStringListAttribute attribute) const; - bool GetStringListAttribute(AXStringListAttribute attribute, + ax::mojom::StringListAttribute attribute) const; + bool GetStringListAttribute(ax::mojom::StringListAttribute attribute, std::vector* value) const; bool GetHtmlAttribute(const char* attr, base::string16* value) const; bool GetHtmlAttribute(const char* attr, std::string* value) const; // Setting accessibility attributes. - void AddStringAttribute(AXStringAttribute attribute, + void AddStringAttribute(ax::mojom::StringAttribute attribute, const std::string& value); - void AddIntAttribute(AXIntAttribute attribute, int32_t value); - void AddFloatAttribute(AXFloatAttribute attribute, float value); - void AddBoolAttribute(AXBoolAttribute attribute, bool value); - void AddIntListAttribute(AXIntListAttribute attribute, + void AddIntAttribute(ax::mojom::IntAttribute attribute, int32_t value); + void AddFloatAttribute(ax::mojom::FloatAttribute attribute, float value); + void AddBoolAttribute(ax::mojom::BoolAttribute attribute, bool value); + void AddIntListAttribute(ax::mojom::IntListAttribute attribute, const std::vector& value); - void AddStringListAttribute(AXStringListAttribute attribute, + void AddStringListAttribute(ax::mojom::StringListAttribute attribute, const std::vector& value); // Convenience functions, mainly for writing unit tests. @@ -115,55 +115,63 @@ struct AX_EXPORT AXNodeData { void SetValue(const base::string16& value); // Returns true if the given enum bit is 1. - bool HasState(AXState state_enum) const; - bool HasAction(AXAction state_enum) const; + bool HasState(ax::mojom::State state_enum) const; + bool HasAction(ax::mojom::Action state_enum) const; // Set bits in the given enum's corresponding bitfield. - void AddState(AXState state_enum); - void AddAction(AXAction action_enum); + void AddState(ax::mojom::State state_enum); + void AddAction(ax::mojom::Action action_enum); // Helper functions to get some common int attributes with some specific // enum types: - AXCheckedState GetCheckedState() const { - return static_cast(GetIntAttribute(AX_ATTR_CHECKED_STATE)); + ax::mojom::CheckedState GetCheckedState() const { + return static_cast( + GetIntAttribute(ax::mojom::IntAttribute::kCheckedState)); } - AXDefaultActionVerb GetDefaultActionVerb() const { - return static_cast( - GetIntAttribute(AX_ATTR_DEFAULT_ACTION_VERB)); + ax::mojom::DefaultActionVerb GetDefaultActionVerb() const { + return static_cast( + GetIntAttribute(ax::mojom::IntAttribute::kDefaultActionVerb)); } - AXInvalidState GetInvalidState() const { - return static_cast(GetIntAttribute(AX_ATTR_INVALID_STATE)); + ax::mojom::InvalidState GetInvalidState() const { + return static_cast( + GetIntAttribute(ax::mojom::IntAttribute::kInvalidState)); } - AXNameFrom GetNameFrom() const { - return static_cast(GetIntAttribute(AX_ATTR_NAME_FROM)); + ax::mojom::NameFrom GetNameFrom() const { + return static_cast( + GetIntAttribute(ax::mojom::IntAttribute::kNameFrom)); } - AXRestriction GetRestriction() const { - return static_cast(GetIntAttribute(AX_ATTR_RESTRICTION)); + ax::mojom::Restriction GetRestriction() const { + return static_cast( + GetIntAttribute(ax::mojom::IntAttribute::kRestriction)); } - AXTextDirection GetTextDirection() const { - return static_cast( - GetIntAttribute(AX_ATTR_TEXT_DIRECTION)); + ax::mojom::TextDirection GetTextDirection() const { + return static_cast( + GetIntAttribute(ax::mojom::IntAttribute::kTextDirection)); } // Helper functions to set some common int attributes. - void SetCheckedState(AXCheckedState checked_state) { - AddIntAttribute(AX_ATTR_CHECKED_STATE, static_cast(checked_state)); + void SetCheckedState(ax::mojom::CheckedState checked_state) { + AddIntAttribute(ax::mojom::IntAttribute::kCheckedState, + static_cast(checked_state)); } - void SetDefaultActionVerb(AXDefaultActionVerb default_action_verb) { - AddIntAttribute(AX_ATTR_DEFAULT_ACTION_VERB, + void SetDefaultActionVerb(ax::mojom::DefaultActionVerb default_action_verb) { + AddIntAttribute(ax::mojom::IntAttribute::kDefaultActionVerb, static_cast(default_action_verb)); } - void SetInvalidState(AXInvalidState invalid_state) { - AddIntAttribute(AX_ATTR_INVALID_STATE, static_cast(invalid_state)); + void SetInvalidState(ax::mojom::InvalidState invalid_state) { + AddIntAttribute(ax::mojom::IntAttribute::kInvalidState, + static_cast(invalid_state)); } - void SetNameFrom(AXNameFrom name_from) { - AddIntAttribute(AX_ATTR_NAME_FROM, static_cast(name_from)); + void SetNameFrom(ax::mojom::NameFrom name_from) { + AddIntAttribute(ax::mojom::IntAttribute::kNameFrom, + static_cast(name_from)); } - void SetRestriction(AXRestriction restriction) { - AddIntAttribute(AX_ATTR_RESTRICTION, static_cast(restriction)); + void SetRestriction(ax::mojom::Restriction restriction) { + AddIntAttribute(ax::mojom::IntAttribute::kRestriction, + static_cast(restriction)); } - void SetTextDirection(AXTextDirection text_direction) { - AddIntAttribute(AX_ATTR_TEXT_DIRECTION, + void SetTextDirection(ax::mojom::TextDirection text_direction) { + AddIntAttribute(ax::mojom::IntAttribute::kTextDirection, static_cast(text_direction)); } @@ -173,16 +181,18 @@ struct AX_EXPORT AXNodeData { // As much as possible this should behave as a simple, serializable, // copyable struct. int32_t id = -1; - AXRole role = AX_ROLE_UNKNOWN; - uint32_t state = static_cast(AX_STATE_NONE); - uint32_t actions = static_cast(AX_ACTION_NONE); - std::vector> string_attributes; - std::vector> int_attributes; - std::vector> float_attributes; - std::vector> bool_attributes; - std::vector>> + ax::mojom::Role role = ax::mojom::Role::kUnknown; + uint32_t state = static_cast(ax::mojom::State::kNone); + uint32_t actions = static_cast(ax::mojom::Action::kNone); + std::vector> + string_attributes; + std::vector> int_attributes; + std::vector> float_attributes; + std::vector> bool_attributes; + std::vector>> intlist_attributes; - std::vector>> + std::vector< + std::pair>> stringlist_attributes; base::StringPairs html_attributes; std::vector child_ids; diff --git a/ui/accessibility/ax_node_position.cc b/ui/accessibility/ax_node_position.cc index 95318cc7fb6eca..9711f344677842 100644 --- a/ui/accessibility/ax_node_position.cc +++ b/ui/accessibility/ax_node_position.cc @@ -5,7 +5,7 @@ #include "ui/accessibility/ax_node_position.h" #include "base/strings/string_util.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" namespace ui { @@ -24,11 +24,12 @@ base::string16 AXNodePosition::GetInnerText() const { return base::string16(); DCHECK(GetAnchor()); - base::string16 value = - GetAnchor()->data().GetString16Attribute(AX_ATTR_VALUE); + base::string16 value = GetAnchor()->data().GetString16Attribute( + ax::mojom::StringAttribute::kValue); if (!value.empty()) return value; - return GetAnchor()->data().GetString16Attribute(AX_ATTR_NAME); + return GetAnchor()->data().GetString16Attribute( + ax::mojom::StringAttribute::kName); } void AXNodePosition::AnchorChild(int child_index, @@ -100,14 +101,16 @@ std::vector AXNodePosition::GetWordStartOffsets() const { if (IsNullPosition()) return std::vector(); DCHECK(GetAnchor()); - return GetAnchor()->data().GetIntListAttribute(ui::AX_ATTR_WORD_STARTS); + return GetAnchor()->data().GetIntListAttribute( + ax::mojom::IntListAttribute::kWordStarts); } std::vector AXNodePosition::GetWordEndOffsets() const { if (IsNullPosition()) return std::vector(); DCHECK(GetAnchor()); - return GetAnchor()->data().GetIntListAttribute(ui::AX_ATTR_WORD_ENDS); + return GetAnchor()->data().GetIntListAttribute( + ax::mojom::IntListAttribute::kWordEnds); } int32_t AXNodePosition::GetNextOnLineID(int32_t node_id) const { @@ -115,9 +118,8 @@ int32_t AXNodePosition::GetNextOnLineID(int32_t node_id) const { return INVALID_ANCHOR_ID; AXNode* node = GetNodeInTree(tree_id(), node_id); int next_on_line_id; - if (!node || - !node->data().GetIntAttribute(AX_ATTR_NEXT_ON_LINE_ID, - &next_on_line_id)) { + if (!node || !node->data().GetIntAttribute( + ax::mojom::IntAttribute::kNextOnLineId, &next_on_line_id)) { return INVALID_ANCHOR_ID; } return static_cast(next_on_line_id); @@ -129,7 +131,7 @@ int32_t AXNodePosition::GetPreviousOnLineID(int32_t node_id) const { AXNode* node = GetNodeInTree(tree_id(), node_id); int previous_on_line_id; if (!node || - !node->data().GetIntAttribute(AX_ATTR_PREVIOUS_ON_LINE_ID, + !node->data().GetIntAttribute(ax::mojom::IntAttribute::kPreviousOnLineId, &previous_on_line_id)) { return INVALID_ANCHOR_ID; } diff --git a/ui/accessibility/ax_node_position.h b/ui/accessibility/ax_node_position.h index a7640bfcfcb091..ec8d7715b3eb22 100644 --- a/ui/accessibility/ax_node_position.h +++ b/ui/accessibility/ax_node_position.h @@ -10,6 +10,7 @@ #include #include "base/strings/string16.h" +#include "ui/accessibility/ax_enum_util.h" #include "ui/accessibility/ax_export.h" #include "ui/accessibility/ax_node.h" #include "ui/accessibility/ax_position.h" diff --git a/ui/accessibility/ax_node_position_unittest.cc b/ui/accessibility/ax_node_position_unittest.cc index b4009c16e8d383..243e7f883f7fae 100644 --- a/ui/accessibility/ax_node_position_unittest.cc +++ b/ui/accessibility/ax_node_position_unittest.cc @@ -14,7 +14,7 @@ #include "base/strings/string16.h" #include "base/strings/utf_string_conversions.h" #include "testing/gtest/include/gtest/gtest.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_node.h" #include "ui/accessibility/ax_node_data.h" #include "ui/accessibility/ax_node_position.h" @@ -115,70 +115,78 @@ void AXPositionTest::SetUp() { static_text2_.id = STATIC_TEXT2_ID; inline_box2_.id = INLINE_BOX2_ID; - root_.role = AX_ROLE_DIALOG; - root_.AddState(AX_STATE_FOCUSABLE); + root_.role = ax::mojom::Role::kDialog; + root_.AddState(ax::mojom::State::kFocusable); root_.SetName(std::string("ButtonCheck box") + TEXT_VALUE); root_.location = gfx::RectF(0, 0, 800, 600); - button_.role = AX_ROLE_BUTTON; - button_.AddState(AX_STATE_HASPOPUP); + button_.role = ax::mojom::Role::kButton; + button_.AddState(ax::mojom::State::kHaspopup); button_.SetName("Button"); button_.location = gfx::RectF(20, 20, 200, 30); - button_.AddIntListAttribute(AX_ATTR_WORD_STARTS, std::vector{0}); - button_.AddIntListAttribute(AX_ATTR_WORD_ENDS, std::vector{6}); - button_.AddIntAttribute(AX_ATTR_NEXT_ON_LINE_ID, check_box_.id); + button_.AddIntListAttribute(ax::mojom::IntListAttribute::kWordStarts, + std::vector{0}); + button_.AddIntListAttribute(ax::mojom::IntListAttribute::kWordEnds, + std::vector{6}); + button_.AddIntAttribute(ax::mojom::IntAttribute::kNextOnLineId, + check_box_.id); root_.child_ids.push_back(button_.id); - check_box_.role = AX_ROLE_CHECK_BOX; - check_box_.SetCheckedState(ui::AX_CHECKED_STATE_TRUE); + check_box_.role = ax::mojom::Role::kCheckBox; + check_box_.SetCheckedState(ax::mojom::CheckedState::kTrue); check_box_.SetName("Check box"); check_box_.location = gfx::RectF(20, 50, 200, 30); - check_box_.AddIntListAttribute(AX_ATTR_WORD_STARTS, + check_box_.AddIntListAttribute(ax::mojom::IntListAttribute::kWordStarts, std::vector{0, 6}); - check_box_.AddIntListAttribute(AX_ATTR_WORD_ENDS, std::vector{5, 9}); - check_box_.AddIntAttribute(AX_ATTR_PREVIOUS_ON_LINE_ID, button_.id); + check_box_.AddIntListAttribute(ax::mojom::IntListAttribute::kWordEnds, + std::vector{5, 9}); + check_box_.AddIntAttribute(ax::mojom::IntAttribute::kPreviousOnLineId, + button_.id); root_.child_ids.push_back(check_box_.id); - text_field_.role = AX_ROLE_TEXT_FIELD; - text_field_.AddState(AX_STATE_EDITABLE); + text_field_.role = ax::mojom::Role::kTextField; + text_field_.AddState(ax::mojom::State::kEditable); text_field_.SetValue(TEXT_VALUE); - text_field_.AddIntListAttribute(AX_ATTR_CACHED_LINE_STARTS, - std::vector{0, 7}); + text_field_.AddIntListAttribute( + ax::mojom::IntListAttribute::kCachedLineStarts, + std::vector{0, 7}); text_field_.child_ids.push_back(static_text1_.id); text_field_.child_ids.push_back(line_break_.id); text_field_.child_ids.push_back(static_text2_.id); root_.child_ids.push_back(text_field_.id); - static_text1_.role = AX_ROLE_STATIC_TEXT; - static_text1_.AddState(AX_STATE_EDITABLE); + static_text1_.role = ax::mojom::Role::kStaticText; + static_text1_.AddState(ax::mojom::State::kEditable); static_text1_.SetName("Line 1"); static_text1_.child_ids.push_back(inline_box1_.id); - inline_box1_.role = AX_ROLE_INLINE_TEXT_BOX; - inline_box1_.AddState(AX_STATE_EDITABLE); + inline_box1_.role = ax::mojom::Role::kInlineTextBox; + inline_box1_.AddState(ax::mojom::State::kEditable); inline_box1_.SetName("Line 1"); - inline_box1_.AddIntListAttribute(AX_ATTR_WORD_STARTS, + inline_box1_.AddIntListAttribute(ax::mojom::IntListAttribute::kWordStarts, std::vector{0, 5}); - inline_box1_.AddIntListAttribute(AX_ATTR_WORD_ENDS, + inline_box1_.AddIntListAttribute(ax::mojom::IntListAttribute::kWordEnds, std::vector{4, 6}); - inline_box1_.AddIntAttribute(AX_ATTR_NEXT_ON_LINE_ID, line_break_.id); + inline_box1_.AddIntAttribute(ax::mojom::IntAttribute::kNextOnLineId, + line_break_.id); - line_break_.role = AX_ROLE_LINE_BREAK; - line_break_.AddState(AX_STATE_EDITABLE); + line_break_.role = ax::mojom::Role::kLineBreak; + line_break_.AddState(ax::mojom::State::kEditable); line_break_.SetName("\n"); - line_break_.AddIntAttribute(AX_ATTR_PREVIOUS_ON_LINE_ID, inline_box1_.id); + line_break_.AddIntAttribute(ax::mojom::IntAttribute::kPreviousOnLineId, + inline_box1_.id); - static_text2_.role = AX_ROLE_STATIC_TEXT; - static_text2_.AddState(AX_STATE_EDITABLE); + static_text2_.role = ax::mojom::Role::kStaticText; + static_text2_.AddState(ax::mojom::State::kEditable); static_text2_.SetName("Line 2"); static_text2_.child_ids.push_back(inline_box2_.id); - inline_box2_.role = AX_ROLE_INLINE_TEXT_BOX; - inline_box2_.AddState(AX_STATE_EDITABLE); + inline_box2_.role = ax::mojom::Role::kInlineTextBox; + inline_box2_.AddState(ax::mojom::State::kEditable); inline_box2_.SetName("Line 2"); - inline_box2_.AddIntListAttribute(AX_ATTR_WORD_STARTS, + inline_box2_.AddIntListAttribute(ax::mojom::IntListAttribute::kWordStarts, std::vector{0, 5}); - inline_box2_.AddIntListAttribute(AX_ATTR_WORD_ENDS, + inline_box2_.AddIntListAttribute(ax::mojom::IntListAttribute::kWordEnds, std::vector{4, 6}); AXTreeUpdate initial_state; @@ -242,25 +250,25 @@ TEST_F(AXPositionTest, Clone) { TestPositionType text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, text_field_.id, 1 /* text_offset */, - AX_TEXT_AFFINITY_UPSTREAM); + ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position); copy_position = text_position->Clone(); ASSERT_NE(nullptr, copy_position); EXPECT_TRUE(copy_position->IsTextPosition()); EXPECT_EQ(text_field_.id, copy_position->anchor_id()); EXPECT_EQ(1, copy_position->text_offset()); - EXPECT_EQ(AX_TEXT_AFFINITY_UPSTREAM, copy_position->affinity()); + EXPECT_EQ(ax::mojom::TextAffinity::kUpstream, copy_position->affinity()); text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, text_field_.id, 1 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); copy_position = text_position->Clone(); ASSERT_NE(nullptr, copy_position); EXPECT_TRUE(copy_position->IsTextPosition()); EXPECT_EQ(text_field_.id, copy_position->anchor_id()); EXPECT_EQ(1, copy_position->text_offset()); - EXPECT_EQ(AX_TEXT_AFFINITY_DOWNSTREAM, copy_position->affinity()); + EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, copy_position->affinity()); EXPECT_EQ(AXNodePosition::INVALID_INDEX, copy_position->child_index()); } @@ -302,19 +310,19 @@ TEST_F(AXPositionTest, AtStartOfAnchorWithTreePosition) { TEST_F(AXPositionTest, AtStartOfAnchorWithTextPosition) { TestPositionType text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 0 /* text_offset */, - AX_TEXT_AFFINITY_UPSTREAM); + ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position); EXPECT_TRUE(text_position->AtStartOfAnchor()); text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 1 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); EXPECT_FALSE(text_position->AtStartOfAnchor()); text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 6 /* text_offset */, - AX_TEXT_AFFINITY_UPSTREAM); + ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position); EXPECT_FALSE(text_position->AtStartOfAnchor()); } @@ -345,19 +353,19 @@ TEST_F(AXPositionTest, AtEndOfAnchorWithTreePosition) { TEST_F(AXPositionTest, AtEndOfAnchorWithTextPosition) { TestPositionType text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 6 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); EXPECT_TRUE(text_position->AtEndOfAnchor()); text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 5 /* text_offset */, - AX_TEXT_AFFINITY_UPSTREAM); + ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position); EXPECT_FALSE(text_position->AtEndOfAnchor()); text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 0 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); EXPECT_FALSE(text_position->AtEndOfAnchor()); } @@ -367,19 +375,19 @@ TEST_F(AXPositionTest, AtStartOfLineWithTextPosition) { // line break. TestPositionType text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 0 /* text_offset */, - AX_TEXT_AFFINITY_UPSTREAM); + ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position); EXPECT_TRUE(text_position->AtStartOfLine()); text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 1 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); EXPECT_FALSE(text_position->AtStartOfLine()); text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, line_break_.id, 0 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); EXPECT_FALSE(text_position->AtStartOfLine()); @@ -387,7 +395,7 @@ TEST_F(AXPositionTest, AtStartOfLineWithTextPosition) { // as a text position at the start of the next line. text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, line_break_.id, 1 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); EXPECT_FALSE(text_position->AtStartOfLine()); @@ -395,13 +403,13 @@ TEST_F(AXPositionTest, AtStartOfLineWithTextPosition) { // line break. text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box2_.id, 0 /* text_offset */, - AX_TEXT_AFFINITY_UPSTREAM); + ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position); EXPECT_TRUE(text_position->AtStartOfLine()); text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box2_.id, 1 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); EXPECT_FALSE(text_position->AtStartOfLine()); } @@ -409,13 +417,13 @@ TEST_F(AXPositionTest, AtStartOfLineWithTextPosition) { TEST_F(AXPositionTest, AtEndOfLineWithTextPosition) { TestPositionType text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 5 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); EXPECT_FALSE(text_position->AtEndOfLine()); text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 6 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); EXPECT_TRUE(text_position->AtEndOfLine()); @@ -423,7 +431,7 @@ TEST_F(AXPositionTest, AtEndOfLineWithTextPosition) { // same as a text position at the end of the previous line. text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, line_break_.id, 0 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); EXPECT_TRUE(text_position->AtEndOfLine()); @@ -431,19 +439,19 @@ TEST_F(AXPositionTest, AtEndOfLineWithTextPosition) { // marked as the end of the line. text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, line_break_.id, 1 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); EXPECT_FALSE(text_position->AtEndOfLine()); text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box2_.id, 5 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); EXPECT_FALSE(text_position->AtEndOfLine()); text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box2_.id, 6 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); EXPECT_TRUE(text_position->AtEndOfLine()); } @@ -470,11 +478,11 @@ TEST_F(AXPositionTest, LowestCommonAncestor) { ASSERT_NE(nullptr, static_text2_position); TestPositionType inline_box1_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 0 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, inline_box1_position); TestPositionType inline_box2_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box2_.id, 0 /* text_offset */, - AX_TEXT_AFFINITY_UPSTREAM); + ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, inline_box2_position); TestPositionType test_position = @@ -555,7 +563,7 @@ TEST_F(AXPositionTest, AsTreePositionWithTextPosition) { // Create a text position pointing to the last character in the text field. TestPositionType text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, text_field_.id, 12 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); TestPositionType test_position = text_position->AsTreePosition(); ASSERT_NE(nullptr, test_position); @@ -571,7 +579,7 @@ TEST_F(AXPositionTest, AsTreePositionWithTextPosition) { // Test for a "before text" position. text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box2_.id, 0 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); test_position = text_position->AsTreePosition(); ASSERT_NE(nullptr, test_position); @@ -584,7 +592,7 @@ TEST_F(AXPositionTest, AsTreePositionWithTextPosition) { // Test for an "after text" position. text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box2_.id, 6 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); test_position = text_position->AsTreePosition(); ASSERT_NE(nullptr, test_position); @@ -648,7 +656,7 @@ TEST_F(AXPositionTest, AsTextPositionWithTreePosition) { TEST_F(AXPositionTest, AsTextPositionWithTextPosition) { TestPositionType text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, text_field_.id, 0 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); TestPositionType test_position = text_position->AsTextPosition(); ASSERT_NE(nullptr, test_position); @@ -656,7 +664,7 @@ TEST_F(AXPositionTest, AsTextPositionWithTextPosition) { EXPECT_EQ(tree_.data().tree_id, test_position->tree_id()); EXPECT_EQ(text_field_.id, test_position->anchor_id()); EXPECT_EQ(0, test_position->text_offset()); - EXPECT_EQ(AX_TEXT_AFFINITY_DOWNSTREAM, test_position->affinity()); + EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity()); EXPECT_EQ(AXNodePosition::INVALID_INDEX, test_position->child_index()); } @@ -680,7 +688,7 @@ TEST_F(AXPositionTest, AsLeafTextPositionWithTreePosition) { EXPECT_EQ(tree_.data().tree_id, test_position->tree_id()); EXPECT_EQ(inline_box1_.id, test_position->anchor_id()); EXPECT_EQ(0, test_position->text_offset()); - EXPECT_EQ(AX_TEXT_AFFINITY_DOWNSTREAM, test_position->affinity()); + EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity()); // Create a tree position pointing to the line break node inside the text // field. @@ -693,7 +701,7 @@ TEST_F(AXPositionTest, AsLeafTextPositionWithTreePosition) { EXPECT_EQ(tree_.data().tree_id, test_position->tree_id()); EXPECT_EQ(line_break_.id, test_position->anchor_id()); EXPECT_EQ(0, test_position->text_offset()); - EXPECT_EQ(AX_TEXT_AFFINITY_DOWNSTREAM, test_position->affinity()); + EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity()); // Create a text position pointing to the second static text node inside the // text field. @@ -706,7 +714,7 @@ TEST_F(AXPositionTest, AsLeafTextPositionWithTreePosition) { EXPECT_EQ(tree_.data().tree_id, test_position->tree_id()); EXPECT_EQ(inline_box2_.id, test_position->anchor_id()); EXPECT_EQ(0, test_position->text_offset()); - EXPECT_EQ(AX_TEXT_AFFINITY_DOWNSTREAM, test_position->affinity()); + EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity()); } TEST_F(AXPositionTest, AsLeafTextPositionWithTextPosition) { @@ -714,7 +722,7 @@ TEST_F(AXPositionTest, AsLeafTextPositionWithTextPosition) { // position). TestPositionType text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, root_.id, 28 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); TestPositionType test_position = text_position->AsLeafTextPosition(); ASSERT_NE(nullptr, test_position); @@ -722,11 +730,11 @@ TEST_F(AXPositionTest, AsLeafTextPositionWithTextPosition) { EXPECT_EQ(tree_.data().tree_id, test_position->tree_id()); EXPECT_EQ(inline_box2_.id, test_position->anchor_id()); EXPECT_EQ(6, test_position->text_offset()); - EXPECT_EQ(AX_TEXT_AFFINITY_DOWNSTREAM, test_position->affinity()); + EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity()); text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, text_field_.id, 0 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); test_position = text_position->AsLeafTextPosition(); ASSERT_NE(nullptr, test_position); @@ -734,11 +742,11 @@ TEST_F(AXPositionTest, AsLeafTextPositionWithTextPosition) { EXPECT_EQ(tree_.data().tree_id, test_position->tree_id()); EXPECT_EQ(inline_box1_.id, test_position->anchor_id()); EXPECT_EQ(0, test_position->text_offset()); - EXPECT_EQ(AX_TEXT_AFFINITY_DOWNSTREAM, test_position->affinity()); + EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity()); text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, text_field_.id, 1 /* text_offset */, - AX_TEXT_AFFINITY_UPSTREAM); + ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position); test_position = text_position->AsLeafTextPosition(); ASSERT_NE(nullptr, test_position); @@ -748,7 +756,7 @@ TEST_F(AXPositionTest, AsLeafTextPositionWithTextPosition) { EXPECT_EQ(1, test_position->text_offset()); // Even though upstream affinity doesn't make sense on a leaf node, there is // no need to reset it to downstream. - EXPECT_EQ(AX_TEXT_AFFINITY_UPSTREAM, test_position->affinity()); + EXPECT_EQ(ax::mojom::TextAffinity::kUpstream, test_position->affinity()); // Create a text position on the root, pointing to the line break character // inside the text field but with an upstream affinity which will cause the @@ -756,7 +764,7 @@ TEST_F(AXPositionTest, AsLeafTextPositionWithTextPosition) { // box. text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, root_.id, 21 /* text_offset */, - AX_TEXT_AFFINITY_UPSTREAM); + ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position); test_position = text_position->AsLeafTextPosition(); ASSERT_NE(nullptr, test_position); @@ -766,14 +774,14 @@ TEST_F(AXPositionTest, AsLeafTextPositionWithTextPosition) { EXPECT_EQ(6, test_position->text_offset()); // Even though upstream affinity doesn't make sense on a leaf node, there is // no need to reset it to downstream. - EXPECT_EQ(AX_TEXT_AFFINITY_UPSTREAM, test_position->affinity()); + EXPECT_EQ(ax::mojom::TextAffinity::kUpstream, test_position->affinity()); // Create a text position pointing to the line break character inside the text // field but with an upstream affinity which will cause the leaf text position // to be placed after the text of the first inline text box. text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, text_field_.id, 6 /* text_offset */, - AX_TEXT_AFFINITY_UPSTREAM); + ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position); test_position = text_position->AsLeafTextPosition(); ASSERT_NE(nullptr, test_position); @@ -783,13 +791,13 @@ TEST_F(AXPositionTest, AsLeafTextPositionWithTextPosition) { EXPECT_EQ(6, test_position->text_offset()); // Even though upstream affinity doesn't make sense on a leaf node, there is // no need to reset it to downstream. - EXPECT_EQ(AX_TEXT_AFFINITY_UPSTREAM, test_position->affinity()); + EXPECT_EQ(ax::mojom::TextAffinity::kUpstream, test_position->affinity()); // Create a text position on the root, pointing to the line break character // inside the text field. text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, root_.id, 21 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); test_position = text_position->AsLeafTextPosition(); ASSERT_NE(nullptr, test_position); @@ -797,13 +805,13 @@ TEST_F(AXPositionTest, AsLeafTextPositionWithTextPosition) { EXPECT_EQ(tree_.data().tree_id, test_position->tree_id()); EXPECT_EQ(line_break_.id, test_position->anchor_id()); EXPECT_EQ(0, test_position->text_offset()); - EXPECT_EQ(AX_TEXT_AFFINITY_DOWNSTREAM, test_position->affinity()); + EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity()); // Create a text position pointing to the line break character inside the text // field. text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, text_field_.id, 6 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); test_position = text_position->AsLeafTextPosition(); ASSERT_NE(nullptr, test_position); @@ -811,13 +819,13 @@ TEST_F(AXPositionTest, AsLeafTextPositionWithTextPosition) { EXPECT_EQ(tree_.data().tree_id, test_position->tree_id()); EXPECT_EQ(line_break_.id, test_position->anchor_id()); EXPECT_EQ(0, test_position->text_offset()); - EXPECT_EQ(AX_TEXT_AFFINITY_DOWNSTREAM, test_position->affinity()); + EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity()); // Create a text position pointing to the offset after the last character in // the text field, (an "after text" position). text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, text_field_.id, 13 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); test_position = text_position->AsLeafTextPosition(); ASSERT_NE(nullptr, test_position); @@ -825,7 +833,7 @@ TEST_F(AXPositionTest, AsLeafTextPositionWithTextPosition) { EXPECT_EQ(tree_.data().tree_id, test_position->tree_id()); EXPECT_EQ(inline_box2_.id, test_position->anchor_id()); EXPECT_EQ(6, test_position->text_offset()); - EXPECT_EQ(AX_TEXT_AFFINITY_DOWNSTREAM, test_position->affinity()); + EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity()); } TEST_F(AXPositionTest, CreatePositionAtStartOfAnchorWithNullPosition) { @@ -871,7 +879,7 @@ TEST_F(AXPositionTest, CreatePositionAtStartOfAnchorWithTreePosition) { TEST_F(AXPositionTest, CreatePositionAtStartOfAnchorWithTextPosition) { TestPositionType text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 0 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); TestPositionType test_position = text_position->CreatePositionAtStartOfAnchor(); @@ -879,11 +887,11 @@ TEST_F(AXPositionTest, CreatePositionAtStartOfAnchorWithTextPosition) { EXPECT_TRUE(test_position->IsTextPosition()); EXPECT_EQ(inline_box1_.id, test_position->anchor_id()); EXPECT_EQ(0, test_position->text_offset()); - EXPECT_EQ(AX_TEXT_AFFINITY_DOWNSTREAM, test_position->affinity()); + EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity()); text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 1 /* text_offset */, - AX_TEXT_AFFINITY_UPSTREAM); + ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position); test_position = text_position->CreatePositionAtStartOfAnchor(); EXPECT_NE(nullptr, test_position); @@ -891,7 +899,7 @@ TEST_F(AXPositionTest, CreatePositionAtStartOfAnchorWithTextPosition) { EXPECT_EQ(inline_box1_.id, test_position->anchor_id()); EXPECT_EQ(0, test_position->text_offset()); // Affinity should have been reset to the default value. - EXPECT_EQ(AX_TEXT_AFFINITY_DOWNSTREAM, test_position->affinity()); + EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity()); } TEST_F(AXPositionTest, CreatePositionAtEndOfAnchorWithNullPosition) { @@ -925,18 +933,18 @@ TEST_F(AXPositionTest, CreatePositionAtEndOfAnchorWithTreePosition) { TEST_F(AXPositionTest, CreatePositionAtEndOfAnchorWithTextPosition) { TestPositionType text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 6 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); TestPositionType test_position = text_position->CreatePositionAtEndOfAnchor(); EXPECT_NE(nullptr, test_position); EXPECT_TRUE(test_position->IsTextPosition()); EXPECT_EQ(inline_box1_.id, test_position->anchor_id()); EXPECT_EQ(6, test_position->text_offset()); - EXPECT_EQ(AX_TEXT_AFFINITY_DOWNSTREAM, test_position->affinity()); + EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity()); text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 5 /* text_offset */, - AX_TEXT_AFFINITY_UPSTREAM); + ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position); test_position = text_position->CreatePositionAtEndOfAnchor(); EXPECT_NE(nullptr, test_position); @@ -944,7 +952,7 @@ TEST_F(AXPositionTest, CreatePositionAtEndOfAnchorWithTextPosition) { EXPECT_EQ(inline_box1_.id, test_position->anchor_id()); EXPECT_EQ(6, test_position->text_offset()); // Affinity should have been reset to the default value. - EXPECT_EQ(AX_TEXT_AFFINITY_DOWNSTREAM, test_position->affinity()); + EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity()); } TEST_F(AXPositionTest, CreateChildPositionAtWithNullPosition) { @@ -978,7 +986,7 @@ TEST_F(AXPositionTest, CreateChildPositionAtWithTreePosition) { TEST_F(AXPositionTest, CreateChildPositionAtWithTextPosition) { TestPositionType text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, static_text1_.id, 5 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); TestPositionType test_position = text_position->CreateChildPositionAt(0); EXPECT_NE(nullptr, test_position); @@ -988,7 +996,7 @@ TEST_F(AXPositionTest, CreateChildPositionAtWithTextPosition) { text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, static_text2_.id, 4 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); test_position = text_position->CreateChildPositionAt(1); EXPECT_NE(nullptr, test_position); @@ -1025,7 +1033,7 @@ TEST_F(AXPositionTest, CreateParentPositionWithTreePosition) { TEST_F(AXPositionTest, CreateParentPositionWithTextPosition) { TestPositionType text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box2_.id, 5 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); TestPositionType test_position = text_position->CreateParentPosition(); EXPECT_NE(nullptr, test_position); @@ -1071,7 +1079,7 @@ TEST_F(AXPositionTest, CreateNextTextAnchorPosition) { // box. check_box_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, root_.id, 6 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, check_box_position); test_position = check_box_position->CreateNextTextAnchorPosition(); EXPECT_NE(nullptr, test_position); @@ -1082,7 +1090,7 @@ TEST_F(AXPositionTest, CreateNextTextAnchorPosition) { TestPositionType button_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, button_.id, 1 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, button_position); test_position = button_position->CreateNextTextAnchorPosition(); EXPECT_NE(nullptr, test_position); @@ -1130,7 +1138,7 @@ TEST_F(AXPositionTest, CreateNextTextAnchorPosition) { TEST_F(AXPositionTest, CreatePreviousTextAnchorPosition) { TestPositionType text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box2_.id, 5 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); TestPositionType test_position = text_position->CreatePreviousTextAnchorPosition(); @@ -1190,7 +1198,7 @@ TEST_F(AXPositionTest, CreatePreviousTextAnchorPosition) { // box. TestPositionType check_box_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, check_box_.id, 6 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, check_box_position); test_position = check_box_position->CreatePreviousTextAnchorPosition(); EXPECT_NE(nullptr, test_position); @@ -1216,7 +1224,7 @@ TEST_F(AXPositionTest, CreateNextAndPreviousCharacterPositionWithNullPosition) { TEST_F(AXPositionTest, CreateNextCharacterPosition) { TestPositionType text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 4 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); TestPositionType test_position = text_position->CreateNextCharacterPosition( AXBoundaryBehavior::CrossBoundary); @@ -1227,7 +1235,7 @@ TEST_F(AXPositionTest, CreateNextCharacterPosition) { text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 5 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); test_position = text_position->CreateNextCharacterPosition( AXBoundaryBehavior::StopAtAnchorBoundary); @@ -1264,7 +1272,7 @@ TEST_F(AXPositionTest, CreateNextCharacterPosition) { text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, check_box_.id, 9 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); test_position = text_position->CreateNextCharacterPosition( AXBoundaryBehavior::StopAtAnchorBoundary); @@ -1281,7 +1289,7 @@ TEST_F(AXPositionTest, CreateNextCharacterPosition) { text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, text_field_.id, 0 /* text_offset */, - AX_TEXT_AFFINITY_UPSTREAM); + ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position); test_position = text_position->CreateNextCharacterPosition( AXBoundaryBehavior::CrossBoundary); @@ -1290,13 +1298,13 @@ TEST_F(AXPositionTest, CreateNextCharacterPosition) { EXPECT_EQ(text_field_.id, test_position->anchor_id()); EXPECT_EQ(1, test_position->text_offset()); // Affinity should have been reset to downstream. - EXPECT_EQ(AX_TEXT_AFFINITY_DOWNSTREAM, test_position->affinity()); + EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity()); } TEST_F(AXPositionTest, CreatePreviousCharacterPosition) { TestPositionType text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box2_.id, 5 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); TestPositionType test_position = text_position->CreatePreviousCharacterPosition( @@ -1308,7 +1316,7 @@ TEST_F(AXPositionTest, CreatePreviousCharacterPosition) { text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box2_.id, 0 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); test_position = text_position->CreatePreviousCharacterPosition( AXBoundaryBehavior::StopAtAnchorBoundary); @@ -1345,7 +1353,7 @@ TEST_F(AXPositionTest, CreatePreviousCharacterPosition) { text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 0 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position); test_position = text_position->CreatePreviousCharacterPosition( AXBoundaryBehavior::StopAtAnchorBoundary); @@ -1362,7 +1370,7 @@ TEST_F(AXPositionTest, CreatePreviousCharacterPosition) { text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, text_field_.id, 1 /* text_offset */, - AX_TEXT_AFFINITY_UPSTREAM); + ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position); test_position = text_position->CreatePreviousCharacterPosition( AXBoundaryBehavior::CrossBoundary); @@ -1371,7 +1379,7 @@ TEST_F(AXPositionTest, CreatePreviousCharacterPosition) { EXPECT_EQ(text_field_.id, test_position->anchor_id()); EXPECT_EQ(0, test_position->text_offset()); // Affinity should have been reset to downstream. - EXPECT_EQ(AX_TEXT_AFFINITY_DOWNSTREAM, test_position->affinity()); + EXPECT_EQ(ax::mojom::TextAffinity::kDownstream, test_position->affinity()); } TEST_F(AXPositionTest, CreateNextAndPreviousWordStartPositionWithNullPosition) { @@ -1458,46 +1466,46 @@ TEST_F(AXPositionTest, OperatorEquals) { // positions. TestPositionType text_position1 = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 15 /* text_offset */, - AX_TEXT_AFFINITY_UPSTREAM); + ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position1); TestPositionType text_position2 = AXNodePosition::CreateTextPosition( tree_.data().tree_id, text_field_.id, -1 /* text_offset */, - AX_TEXT_AFFINITY_UPSTREAM); + ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position2); EXPECT_EQ(*text_position1, *text_position2); text_position1 = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 0 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position1); text_position2 = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 0 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position2); EXPECT_EQ(*text_position1, *text_position2); // Affinities should match. text_position2 = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 0 /* text_offset */, - AX_TEXT_AFFINITY_UPSTREAM); + ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position2); EXPECT_NE(*text_position1, *text_position2); // Text offsets should match. text_position1 = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 5 /* text_offset */, - AX_TEXT_AFFINITY_UPSTREAM); + ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position1); EXPECT_NE(*text_position1, *text_position2); // Two "after text" positions on the same node should be equivalent. text_position1 = AXNodePosition::CreateTextPosition( tree_.data().tree_id, line_break_.id, 1 /* text_offset */, - AX_TEXT_AFFINITY_UPSTREAM); + ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position1); text_position2 = AXNodePosition::CreateTextPosition( tree_.data().tree_id, line_break_.id, 1 /* text_offset */, - AX_TEXT_AFFINITY_UPSTREAM); + ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position2); EXPECT_EQ(*text_position1, *text_position2); } @@ -1542,11 +1550,11 @@ TEST_F(AXPositionTest, OperatorsLessThanAndGreaterThan) { TestPositionType text_position1 = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 2 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position1); TestPositionType text_position2 = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 0 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); ASSERT_NE(nullptr, text_position2); EXPECT_GT(*text_position1, *text_position2); EXPECT_LT(*text_position2, *text_position1); @@ -1554,7 +1562,7 @@ TEST_F(AXPositionTest, OperatorsLessThanAndGreaterThan) { // Affinities should not matter. text_position2 = AXNodePosition::CreateTextPosition( tree_.data().tree_id, inline_box1_.id, 0 /* text_offset */, - AX_TEXT_AFFINITY_UPSTREAM); + ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position2); EXPECT_GT(*text_position1, *text_position2); EXPECT_LT(*text_position2, *text_position1); @@ -1562,12 +1570,12 @@ TEST_F(AXPositionTest, OperatorsLessThanAndGreaterThan) { // An "after text" position. text_position1 = AXNodePosition::CreateTextPosition( tree_.data().tree_id, line_break_.id, 1 /* text_offset */, - AX_TEXT_AFFINITY_UPSTREAM); + ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position1); // A "before text" position. text_position2 = AXNodePosition::CreateTextPosition( tree_.data().tree_id, line_break_.id, 0 /* text_offset */, - AX_TEXT_AFFINITY_UPSTREAM); + ax::mojom::TextAffinity::kUpstream); ASSERT_NE(nullptr, text_position2); EXPECT_GT(*text_position1, *text_position2); EXPECT_LT(*text_position2, *text_position1); @@ -1580,7 +1588,7 @@ TEST_F(AXPositionTest, OperatorsLessThanAndGreaterThan) { TEST_P(AXPositionTestWithParam, TraverseTreeStartingWithAffinityDownstream) { TestPositionType text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, GetParam().start_node_id_, GetParam().start_offset_, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); for (const std::string& expectation : GetParam().expectations) { text_position = GetParam().TestMethod.Run(text_position); EXPECT_NE(nullptr, text_position); @@ -1591,7 +1599,7 @@ TEST_P(AXPositionTestWithParam, TraverseTreeStartingWithAffinityDownstream) { TEST_P(AXPositionTestWithParam, TraverseTreeStartingWithAffinityUpstream) { TestPositionType text_position = AXNodePosition::CreateTextPosition( tree_.data().tree_id, GetParam().start_node_id_, GetParam().start_offset_, - AX_TEXT_AFFINITY_UPSTREAM); + ax::mojom::TextAffinity::kUpstream); for (const std::string& expectation : GetParam().expectations) { text_position = GetParam().TestMethod.Run(text_position); EXPECT_NE(nullptr, text_position); @@ -3014,7 +3022,7 @@ TEST_F(AXPositionTest, AXRangeGetTextWithWholeObjects) { tree_.data().tree_id, root_.id, 0 /* child_index */); TestPositionType end = AXNodePosition::CreateTextPosition( tree_.data().tree_id, root_.id, 28 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); AXRange> forward_range(start->Clone(), end->Clone()); EXPECT_EQ(all_text, forward_range.GetText()); @@ -3029,10 +3037,10 @@ TEST_F(AXPositionTest, AXRangeGetTextWithTextOffsets) { // ending two characters before the end of the root. TestPositionType start = AXNodePosition::CreateTextPosition( tree_.data().tree_id, button_.id, 3 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); TestPositionType end = AXNodePosition::CreateTextPosition( tree_.data().tree_id, static_text2_.id, 4 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); AXRange> forward_range(start->Clone(), end->Clone()); EXPECT_EQ(most_text, forward_range.GetText()); diff --git a/ui/accessibility/ax_position.h b/ui/accessibility/ax_position.h index 8c263dff3b37ce..e3ed7ee6a462c3 100644 --- a/ui/accessibility/ax_position.h +++ b/ui/accessibility/ax_position.h @@ -17,7 +17,8 @@ #include "base/strings/string16.h" #include "base/strings/string_number_conversions.h" #include "base/strings/utf_string_conversions.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enum_util.h" +#include "ui/accessibility/ax_enums.mojom.h" namespace ui { @@ -94,7 +95,7 @@ class AXPosition { AXPositionInstance new_position(new AXPositionType()); new_position->Initialize(AXPositionKind::NULL_POSITION, INVALID_TREE_ID, INVALID_ANCHOR_ID, INVALID_INDEX, INVALID_OFFSET, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); return new_position; } @@ -104,14 +105,15 @@ class AXPosition { AXPositionInstance new_position(new AXPositionType()); new_position->Initialize(AXPositionKind::TREE_POSITION, tree_id, anchor_id, child_index, INVALID_OFFSET, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); return new_position; } - static AXPositionInstance CreateTextPosition(int tree_id, - int32_t anchor_id, - int text_offset, - AXTextAffinity affinity) { + static AXPositionInstance CreateTextPosition( + int tree_id, + int32_t anchor_id, + int text_offset, + ax::mojom::TextAffinity affinity) { AXPositionInstance new_position(new AXPositionType()); new_position->Initialize(AXPositionKind::TEXT_POSITION, tree_id, anchor_id, INVALID_INDEX, text_offset, affinity); @@ -150,9 +152,9 @@ class AXPosition { str_text_offset = base::IntToString(text_offset_); } str = "TextPosition tree_id=" + base::IntToString(tree_id_) + - " anchor_id=" + base::IntToString(anchor_id_) + " text_offset=" + - str_text_offset + " affinity=" + - ui::ToString(static_cast(affinity_)); + " anchor_id=" + base::IntToString(anchor_id_) + + " text_offset=" + str_text_offset + " affinity=" + + ui::ToString(static_cast(affinity_)); break; } } @@ -188,7 +190,7 @@ class AXPosition { AXPositionKind kind() const { return kind_; } int child_index() const { return child_index_; } int text_offset() const { return text_offset_; } - AXTextAffinity affinity() const { return affinity_; } + ax::mojom::TextAffinity affinity() const { return affinity_; } bool IsNullPosition() const { return kind_ == AXPositionKind::NULL_POSITION || !GetAnchor(); @@ -376,7 +378,7 @@ class AXPosition { int child_length = child->MaxTextOffsetInParent(); if (copy->text_offset_ >= current_offset && (copy->text_offset_ < (current_offset + child_length) || - (copy->affinity_ == AX_TEXT_AFFINITY_UPSTREAM && + (copy->affinity_ == ax::mojom::TextAffinity::kUpstream && copy->text_offset_ == (current_offset + child_length)))) { copy->child_index_ = i; break; @@ -474,7 +476,7 @@ class AXPosition { return CreateTreePosition(tree_id_, anchor_id_, 0 /* child_index */); case AXPositionKind::TEXT_POSITION: return CreateTextPosition(tree_id_, anchor_id_, 0 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); } return CreateNullPosition(); } @@ -487,7 +489,7 @@ class AXPosition { return CreateTreePosition(tree_id_, anchor_id_, AnchorChildCount()); case AXPositionKind::TEXT_POSITION: return CreateTextPosition(tree_id_, anchor_id_, MaxTextOffset(), - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); } return CreateNullPosition(); } @@ -519,7 +521,7 @@ class AXPosition { } case AXPositionKind::TEXT_POSITION: return CreateTextPosition(tree_id, child_id, 0 /* text_offset */, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); } return CreateNullPosition(); @@ -547,12 +549,12 @@ class AXPosition { // before or after the child and we don't maintain the affinity when the // position is after the child. int parent_offset = AnchorTextOffsetInParent(); - AXTextAffinity parent_affinity = affinity_; + ax::mojom::TextAffinity parent_affinity = affinity_; if (MaxTextOffset() == MaxTextOffsetInParent()) { parent_offset += text_offset_; } else if (text_offset_ > 0) { parent_offset += MaxTextOffsetInParent(); - parent_affinity = AX_TEXT_AFFINITY_DOWNSTREAM; + parent_affinity = ax::mojom::TextAffinity::kDownstream; } return CreateTextPosition(tree_id, parent_id, parent_offset, parent_affinity); @@ -606,7 +608,7 @@ class AXPosition { text_position->text_offset_ += 1; // Even if our affinity was upstream, moving to the next character should // inevitably reset it to downstream. - text_position->affinity_ = AX_TEXT_AFFINITY_DOWNSTREAM; + text_position->affinity_ = ax::mojom::TextAffinity::kDownstream; } else { // Moving to the end of the current anchor first is essential. Otherwise // |CreateNextAnchorPosition| might return our deepest left-most child @@ -639,7 +641,7 @@ class AXPosition { text_position->text_offset_ -= 1; // Even if the new position is at the beginning of the line, the affinity // is defaulted to downstream for simplicity. - text_position->affinity_ = AX_TEXT_AFFINITY_DOWNSTREAM; + text_position->affinity_ = ax::mojom::TextAffinity::kDownstream; } else { text_position = text_position->CreatePreviousTextAnchorPosition(); text_position = text_position->CreatePositionAtEndOfAnchor(); @@ -661,7 +663,7 @@ class AXPosition { if (boundary_behavior == AXBoundaryBehavior::StopIfAlreadyAtBoundary && text_position->AtStartOfWord()) { AXPositionInstance clone = Clone(); - clone->affinity_ = AX_TEXT_AFFINITY_DOWNSTREAM; + clone->affinity_ = ax::mojom::TextAffinity::kDownstream; return clone; } @@ -689,7 +691,7 @@ class AXPosition { text_position->text_offset_ = static_cast(updated_word_starts[0]); } else { text_position->text_offset_ = static_cast(*iterator); - text_position->affinity_ = AX_TEXT_AFFINITY_DOWNSTREAM; + text_position->affinity_ = ax::mojom::TextAffinity::kDownstream; } // If the word boundary is in the same subtree, return a position rooted @@ -716,7 +718,7 @@ class AXPosition { if (boundary_behavior == AXBoundaryBehavior::StopIfAlreadyAtBoundary && text_position->AtStartOfWord()) { AXPositionInstance clone = Clone(); - clone->affinity_ = AX_TEXT_AFFINITY_DOWNSTREAM; + clone->affinity_ = ax::mojom::TextAffinity::kDownstream; return clone; } @@ -755,7 +757,7 @@ class AXPosition { static_cast(*(updated_word_starts.end() - 1)); } else { text_position->text_offset_ = static_cast(*(--iterator)); - text_position->affinity_ = AX_TEXT_AFFINITY_DOWNSTREAM; + text_position->affinity_ = ax::mojom::TextAffinity::kDownstream; } // If the word boundary is in the same subtree, return a position rooted @@ -783,7 +785,7 @@ class AXPosition { if (boundary_behavior == AXBoundaryBehavior::StopIfAlreadyAtBoundary && text_position->AtEndOfWord()) { AXPositionInstance clone = Clone(); - clone->affinity_ = AX_TEXT_AFFINITY_DOWNSTREAM; + clone->affinity_ = ax::mojom::TextAffinity::kDownstream; return clone; } @@ -818,7 +820,7 @@ class AXPosition { text_position->text_offset_ = static_cast(updated_word_ends[0]); } else { text_position->text_offset_ = static_cast(*iterator); - text_position->affinity_ = AX_TEXT_AFFINITY_DOWNSTREAM; + text_position->affinity_ = ax::mojom::TextAffinity::kDownstream; } // If the word boundary is in the same subtree, return a position rooted @@ -846,7 +848,7 @@ class AXPosition { if (boundary_behavior == AXBoundaryBehavior::StopIfAlreadyAtBoundary && text_position->AtEndOfWord()) { AXPositionInstance clone = Clone(); - clone->affinity_ = AX_TEXT_AFFINITY_DOWNSTREAM; + clone->affinity_ = ax::mojom::TextAffinity::kDownstream; return clone; } @@ -884,7 +886,7 @@ class AXPosition { static_cast(*(updated_word_ends.end() - 1)); } else { text_position->text_offset_ = static_cast(*(--iterator)); - text_position->affinity_ = AX_TEXT_AFFINITY_DOWNSTREAM; + text_position->affinity_ = ax::mojom::TextAffinity::kDownstream; } // If the word boundary is in the same subtree, return a position rooted @@ -913,7 +915,7 @@ class AXPosition { if (boundary_behavior == AXBoundaryBehavior::StopIfAlreadyAtBoundary && text_position->AtStartOfLine()) { AXPositionInstance clone = Clone(); - clone->affinity_ = AX_TEXT_AFFINITY_DOWNSTREAM; + clone->affinity_ = ax::mojom::TextAffinity::kDownstream; return clone; } @@ -951,7 +953,7 @@ class AXPosition { if (boundary_behavior == AXBoundaryBehavior::StopIfAlreadyAtBoundary && text_position->AtStartOfLine()) { AXPositionInstance clone = Clone(); - clone->affinity_ = AX_TEXT_AFFINITY_DOWNSTREAM; + clone->affinity_ = ax::mojom::TextAffinity::kDownstream; return clone; } @@ -997,7 +999,7 @@ class AXPosition { if (boundary_behavior == AXBoundaryBehavior::StopIfAlreadyAtBoundary && text_position->AtEndOfLine()) { AXPositionInstance clone = Clone(); - clone->affinity_ = AX_TEXT_AFFINITY_DOWNSTREAM; + clone->affinity_ = ax::mojom::TextAffinity::kDownstream; return clone; } @@ -1048,7 +1050,7 @@ class AXPosition { if (boundary_behavior == AXBoundaryBehavior::StopIfAlreadyAtBoundary && text_position->AtEndOfLine()) { AXPositionInstance clone = Clone(); - clone->affinity_ = AX_TEXT_AFFINITY_DOWNSTREAM; + clone->affinity_ = ax::mojom::TextAffinity::kDownstream; return clone; } @@ -1100,7 +1102,7 @@ class AXPosition { int32_t anchor_id, int child_index, int text_offset, - AXTextAffinity affinity) { + ax::mojom::TextAffinity affinity) { kind_ = kind; tree_id_ = tree_id; anchor_id_ = anchor_id; @@ -1120,7 +1122,7 @@ class AXPosition { anchor_id_ = INVALID_ANCHOR_ID; child_index_ = INVALID_INDEX; text_offset_ = INVALID_OFFSET; - affinity_ = AX_TEXT_AFFINITY_DOWNSTREAM; + affinity_ = ax::mojom::TextAffinity::kDownstream; } } @@ -1241,7 +1243,7 @@ class AXPosition { // TODO(nektar): Get rid of affinity and make Blink handle affinity // internally since inline text objects don't span lines. - AXTextAffinity affinity_; + ax::mojom::TextAffinity affinity_; }; template diff --git a/ui/accessibility/ax_role_properties.cc b/ui/accessibility/ax_role_properties.cc index 7540c674cb6e3a..7dac852f38d908 100644 --- a/ui/accessibility/ax_role_properties.cc +++ b/ui/accessibility/ax_role_properties.cc @@ -6,138 +6,138 @@ namespace ui { -bool IsRoleClickable(AXRole role) { +bool IsRoleClickable(ax::mojom::Role role) { switch (role) { - case AX_ROLE_BUTTON: - case AX_ROLE_CHECK_BOX: - case AX_ROLE_COLOR_WELL: - case AX_ROLE_DISCLOSURE_TRIANGLE: - case AX_ROLE_LINK: - case AX_ROLE_LIST_BOX_OPTION: - case AX_ROLE_MENU_BUTTON: - case AX_ROLE_MENU_ITEM: - case AX_ROLE_MENU_ITEM_CHECK_BOX: - case AX_ROLE_MENU_ITEM_RADIO: - case AX_ROLE_MENU_LIST_OPTION: - case AX_ROLE_MENU_LIST_POPUP: - case AX_ROLE_POP_UP_BUTTON: - case AX_ROLE_RADIO_BUTTON: - case AX_ROLE_SWITCH: - case AX_ROLE_TAB: - case AX_ROLE_TOGGLE_BUTTON: + case ax::mojom::Role::kButton: + case ax::mojom::Role::kCheckBox: + case ax::mojom::Role::kColorWell: + case ax::mojom::Role::kDisclosureTriangle: + case ax::mojom::Role::kLink: + case ax::mojom::Role::kListBoxOption: + case ax::mojom::Role::kMenuButton: + case ax::mojom::Role::kMenuItem: + case ax::mojom::Role::kMenuItemCheckBox: + case ax::mojom::Role::kMenuItemRadio: + case ax::mojom::Role::kMenuListOption: + case ax::mojom::Role::kMenuListPopup: + case ax::mojom::Role::kPopUpButton: + case ax::mojom::Role::kRadioButton: + case ax::mojom::Role::kSwitch: + case ax::mojom::Role::kTab: + case ax::mojom::Role::kToggleButton: return true; default: return false; } } -bool IsDocument(ui::AXRole role) { +bool IsDocument(ax::mojom::Role role) { switch (role) { - case ui::AX_ROLE_ROOT_WEB_AREA: - case ui::AX_ROLE_WEB_AREA: + case ax::mojom::Role::kRootWebArea: + case ax::mojom::Role::kWebArea: return true; default: return false; } } -bool IsCellOrTableHeaderRole(ui::AXRole role) { +bool IsCellOrTableHeaderRole(ax::mojom::Role role) { switch (role) { - case ui::AX_ROLE_CELL: - case ui::AX_ROLE_COLUMN_HEADER: - case ui::AX_ROLE_ROW_HEADER: + case ax::mojom::Role::kCell: + case ax::mojom::Role::kColumnHeader: + case ax::mojom::Role::kRowHeader: return true; default: return false; } } -bool IsTableLikeRole(ui::AXRole role) { +bool IsTableLikeRole(ax::mojom::Role role) { switch (role) { - case ui::AX_ROLE_TABLE: - case ui::AX_ROLE_GRID: - case ui::AX_ROLE_TREE_GRID: + case ax::mojom::Role::kTable: + case ax::mojom::Role::kGrid: + case ax::mojom::Role::kTreeGrid: return true; default: return false; } } -bool IsContainerWithSelectableChildrenRole(ui::AXRole role) { +bool IsContainerWithSelectableChildrenRole(ax::mojom::Role role) { switch (role) { - case ui::AX_ROLE_COMBO_BOX_GROUPING: - case ui::AX_ROLE_COMBO_BOX_MENU_BUTTON: - case ui::AX_ROLE_GRID: - case ui::AX_ROLE_LIST_BOX: - case ui::AX_ROLE_MENU: - case ui::AX_ROLE_MENU_BAR: - case ui::AX_ROLE_RADIO_GROUP: - case ui::AX_ROLE_TAB_LIST: - case ui::AX_ROLE_TOOLBAR: - case ui::AX_ROLE_TREE: - case ui::AX_ROLE_TREE_GRID: + case ax::mojom::Role::kComboBoxGrouping: + case ax::mojom::Role::kComboBoxMenuButton: + case ax::mojom::Role::kGrid: + case ax::mojom::Role::kListBox: + case ax::mojom::Role::kMenu: + case ax::mojom::Role::kMenuBar: + case ax::mojom::Role::kRadioGroup: + case ax::mojom::Role::kTabList: + case ax::mojom::Role::kToolbar: + case ax::mojom::Role::kTree: + case ax::mojom::Role::kTreeGrid: return true; default: return false; } } -bool IsRowContainer(ui::AXRole role) { +bool IsRowContainer(ax::mojom::Role role) { switch (role) { - case ui::AX_ROLE_TREE: - case ui::AX_ROLE_TREE_GRID: - case ui::AX_ROLE_GRID: - case ui::AX_ROLE_TABLE: + case ax::mojom::Role::kTree: + case ax::mojom::Role::kTreeGrid: + case ax::mojom::Role::kGrid: + case ax::mojom::Role::kTable: return true; default: return false; } } -bool IsControl(ui::AXRole role) { +bool IsControl(ax::mojom::Role role) { switch (role) { - case ui::AX_ROLE_BUTTON: - case ui::AX_ROLE_CHECK_BOX: - case ui::AX_ROLE_COLOR_WELL: - case ui::AX_ROLE_COMBO_BOX_MENU_BUTTON: - case ui::AX_ROLE_DISCLOSURE_TRIANGLE: - case ui::AX_ROLE_LIST_BOX: - case ui::AX_ROLE_MENU: - case ui::AX_ROLE_MENU_BAR: - case ui::AX_ROLE_MENU_BUTTON: - case ui::AX_ROLE_MENU_ITEM: - case ui::AX_ROLE_MENU_ITEM_CHECK_BOX: - case ui::AX_ROLE_MENU_ITEM_RADIO: - case ui::AX_ROLE_MENU_LIST_OPTION: - case ui::AX_ROLE_MENU_LIST_POPUP: - case ui::AX_ROLE_POP_UP_BUTTON: - case ui::AX_ROLE_RADIO_BUTTON: - case ui::AX_ROLE_SCROLL_BAR: - case ui::AX_ROLE_SEARCH_BOX: - case ui::AX_ROLE_SLIDER: - case ui::AX_ROLE_SPIN_BUTTON: - case ui::AX_ROLE_SWITCH: - case ui::AX_ROLE_TAB: - case ui::AX_ROLE_TEXT_FIELD: - case ui::AX_ROLE_TEXT_FIELD_WITH_COMBO_BOX: - case ui::AX_ROLE_TOGGLE_BUTTON: - case ui::AX_ROLE_TREE: + case ax::mojom::Role::kButton: + case ax::mojom::Role::kCheckBox: + case ax::mojom::Role::kColorWell: + case ax::mojom::Role::kComboBoxMenuButton: + case ax::mojom::Role::kDisclosureTriangle: + case ax::mojom::Role::kListBox: + case ax::mojom::Role::kMenu: + case ax::mojom::Role::kMenuBar: + case ax::mojom::Role::kMenuButton: + case ax::mojom::Role::kMenuItem: + case ax::mojom::Role::kMenuItemCheckBox: + case ax::mojom::Role::kMenuItemRadio: + case ax::mojom::Role::kMenuListOption: + case ax::mojom::Role::kMenuListPopup: + case ax::mojom::Role::kPopUpButton: + case ax::mojom::Role::kRadioButton: + case ax::mojom::Role::kScrollBar: + case ax::mojom::Role::kSearchBox: + case ax::mojom::Role::kSlider: + case ax::mojom::Role::kSpinButton: + case ax::mojom::Role::kSwitch: + case ax::mojom::Role::kTab: + case ax::mojom::Role::kTextField: + case ax::mojom::Role::kTextFieldWithComboBox: + case ax::mojom::Role::kToggleButton: + case ax::mojom::Role::kTree: return true; default: return false; } } -bool IsMenuRelated(ui::AXRole role) { +bool IsMenuRelated(ax::mojom::Role role) { switch (role) { - case ui::AX_ROLE_MENU: - case ui::AX_ROLE_MENU_BAR: - case ui::AX_ROLE_MENU_BUTTON: - case ui::AX_ROLE_MENU_ITEM: - case ui::AX_ROLE_MENU_ITEM_CHECK_BOX: - case ui::AX_ROLE_MENU_ITEM_RADIO: - case ui::AX_ROLE_MENU_LIST_OPTION: - case ui::AX_ROLE_MENU_LIST_POPUP: + case ax::mojom::Role::kMenu: + case ax::mojom::Role::kMenuBar: + case ax::mojom::Role::kMenuButton: + case ax::mojom::Role::kMenuItem: + case ax::mojom::Role::kMenuItemCheckBox: + case ax::mojom::Role::kMenuItemRadio: + case ax::mojom::Role::kMenuListOption: + case ax::mojom::Role::kMenuListPopup: return true; default: return false; diff --git a/ui/accessibility/ax_role_properties.h b/ui/accessibility/ax_role_properties.h index 81893bcf87c6df..40311329b0f7bb 100644 --- a/ui/accessibility/ax_role_properties.h +++ b/ui/accessibility/ax_role_properties.h @@ -5,35 +5,35 @@ #ifndef UI_ACCESSIBILITY_AX_ROLE_PROPERTIES_H_ #define UI_ACCESSIBILITY_AX_ROLE_PROPERTIES_H_ -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_export.h" namespace ui { // Checks if the given role should belong to a control that can respond to // clicks. -AX_EXPORT bool IsRoleClickable(AXRole role); +AX_EXPORT bool IsRoleClickable(ax::mojom::Role role); // Returns true if this node is a document -AX_EXPORT bool IsDocument(ui::AXRole role); +AX_EXPORT bool IsDocument(ax::mojom::Role role); // Returns true if this node is a cell or a table header. -AX_EXPORT bool IsCellOrTableHeaderRole(AXRole role); +AX_EXPORT bool IsCellOrTableHeaderRole(ax::mojom::Role role); // Returns true if this node is a table, a grid or a treegrid. -AX_EXPORT bool IsTableLikeRole(AXRole role); +AX_EXPORT bool IsTableLikeRole(ax::mojom::Role role); // Returns true if this node is a container with selectable children. -AX_EXPORT bool IsContainerWithSelectableChildrenRole(ui::AXRole role); +AX_EXPORT bool IsContainerWithSelectableChildrenRole(ax::mojom::Role role); // Returns true if this node is a row container. -AX_EXPORT bool IsRowContainer(ui::AXRole role); +AX_EXPORT bool IsRowContainer(ax::mojom::Role role); // Returns true if this node is a control. -AX_EXPORT bool IsControl(ui::AXRole role); +AX_EXPORT bool IsControl(ax::mojom::Role role); // Returns true if this node is a menu or related role. -AX_EXPORT bool IsMenuRelated(ui::AXRole role); +AX_EXPORT bool IsMenuRelated(ax::mojom::Role role); } // namespace ui diff --git a/ui/accessibility/ax_text_utils.cc b/ui/accessibility/ax_text_utils.cc index fd0457763f455f..d2d9ffef3ad2aa 100644 --- a/ui/accessibility/ax_text_utils.cc +++ b/ui/accessibility/ax_text_utils.cc @@ -21,7 +21,7 @@ size_t FindAccessibleTextBoundary(const base::string16& text, TextBoundaryType boundary, size_t start_offset, TextBoundaryDirection direction, - AXTextAffinity affinity) { + ax::mojom::TextAffinity affinity) { size_t text_size = text.size(); DCHECK_LE(start_offset, text_size); @@ -43,20 +43,20 @@ size_t FindAccessibleTextBoundary(const base::string16& text, if (direction == FORWARDS_DIRECTION) { for (size_t j = 0; j < line_breaks.size(); ++j) { size_t line_break = line_breaks[j] >= 0 ? line_breaks[j] : 0; - if ((affinity == AX_TEXT_AFFINITY_DOWNSTREAM && - line_break > start_offset) || - (affinity == AX_TEXT_AFFINITY_UPSTREAM && - line_break >= start_offset)) { - return line_break; + if ((affinity == ax::mojom::TextAffinity::kDownstream && + line_break > start_offset) || + (affinity == ax::mojom::TextAffinity::kUpstream && + line_break >= start_offset)) { + return line_break; } } return text_size; } else { for (size_t j = line_breaks.size(); j != 0; --j) { size_t line_break = line_breaks[j - 1] >= 0 ? line_breaks[j - 1] : 0; - if ((affinity == AX_TEXT_AFFINITY_DOWNSTREAM && + if ((affinity == ax::mojom::TextAffinity::kDownstream && line_break <= start_offset) || - (affinity == AX_TEXT_AFFINITY_UPSTREAM && + (affinity == ax::mojom::TextAffinity::kUpstream && line_break < start_offset)) { return line_break; } @@ -116,27 +116,27 @@ size_t FindAccessibleTextBoundary(const base::string16& text, } base::string16 ActionVerbToLocalizedString( - const AXDefaultActionVerb action_verb) { + const ax::mojom::DefaultActionVerb action_verb) { switch (action_verb) { - case AX_DEFAULT_ACTION_VERB_NONE: + case ax::mojom::DefaultActionVerb::kNone: return base::string16(); - case AX_DEFAULT_ACTION_VERB_ACTIVATE: + case ax::mojom::DefaultActionVerb::kActivate: return l10n_util::GetStringUTF16(IDS_AX_ACTIVATE_ACTION_VERB); - case AX_DEFAULT_ACTION_VERB_CHECK: + case ax::mojom::DefaultActionVerb::kCheck: return l10n_util::GetStringUTF16(IDS_AX_CHECK_ACTION_VERB); - case AX_DEFAULT_ACTION_VERB_CLICK: + case ax::mojom::DefaultActionVerb::kClick: return l10n_util::GetStringUTF16(IDS_AX_CLICK_ACTION_VERB); - case AX_DEFAULT_ACTION_VERB_CLICK_ANCESTOR: + case ax::mojom::DefaultActionVerb::kClickAncestor: return l10n_util::GetStringUTF16(IDS_AX_CLICK_ANCESTOR_ACTION_VERB); - case AX_DEFAULT_ACTION_VERB_JUMP: + case ax::mojom::DefaultActionVerb::kJump: return l10n_util::GetStringUTF16(IDS_AX_JUMP_ACTION_VERB); - case AX_DEFAULT_ACTION_VERB_OPEN: + case ax::mojom::DefaultActionVerb::kOpen: return l10n_util::GetStringUTF16(IDS_AX_OPEN_ACTION_VERB); - case AX_DEFAULT_ACTION_VERB_PRESS: + case ax::mojom::DefaultActionVerb::kPress: return l10n_util::GetStringUTF16(IDS_AX_PRESS_ACTION_VERB); - case AX_DEFAULT_ACTION_VERB_SELECT: + case ax::mojom::DefaultActionVerb::kSelect: return l10n_util::GetStringUTF16(IDS_AX_SELECT_ACTION_VERB); - case AX_DEFAULT_ACTION_VERB_UNCHECK: + case ax::mojom::DefaultActionVerb::kUncheck: return l10n_util::GetStringUTF16(IDS_AX_UNCHECK_ACTION_VERB); } NOTREACHED(); @@ -145,27 +145,27 @@ base::string16 ActionVerbToLocalizedString( // Some APIs on Linux and Windows need to return non-localized action names. base::string16 ActionVerbToUnlocalizedString( - const AXDefaultActionVerb action_verb) { + const ax::mojom::DefaultActionVerb action_verb) { switch (action_verb) { - case ui::AX_DEFAULT_ACTION_VERB_NONE: + case ax::mojom::DefaultActionVerb::kNone: return base::UTF8ToUTF16("none"); - case ui::AX_DEFAULT_ACTION_VERB_ACTIVATE: + case ax::mojom::DefaultActionVerb::kActivate: return base::UTF8ToUTF16("activate"); - case ui::AX_DEFAULT_ACTION_VERB_CHECK: + case ax::mojom::DefaultActionVerb::kCheck: return base::UTF8ToUTF16("check"); - case ui::AX_DEFAULT_ACTION_VERB_CLICK: + case ax::mojom::DefaultActionVerb::kClick: return base::UTF8ToUTF16("click"); - case ui::AX_DEFAULT_ACTION_VERB_CLICK_ANCESTOR: + case ax::mojom::DefaultActionVerb::kClickAncestor: return base::UTF8ToUTF16("click-ancestor"); - case ui::AX_DEFAULT_ACTION_VERB_JUMP: + case ax::mojom::DefaultActionVerb::kJump: return base::UTF8ToUTF16("jump"); - case ui::AX_DEFAULT_ACTION_VERB_OPEN: + case ax::mojom::DefaultActionVerb::kOpen: return base::UTF8ToUTF16("open"); - case ui::AX_DEFAULT_ACTION_VERB_PRESS: + case ax::mojom::DefaultActionVerb::kPress: return base::UTF8ToUTF16("press"); - case ui::AX_DEFAULT_ACTION_VERB_SELECT: + case ax::mojom::DefaultActionVerb::kSelect: return base::UTF8ToUTF16("select"); - case ui::AX_DEFAULT_ACTION_VERB_UNCHECK: + case ax::mojom::DefaultActionVerb::kUncheck: return base::UTF8ToUTF16("uncheck"); } NOTREACHED(); diff --git a/ui/accessibility/ax_text_utils.h b/ui/accessibility/ax_text_utils.h index 5a4c07178709db..3b9a78fdcf8f86 100644 --- a/ui/accessibility/ax_text_utils.h +++ b/ui/accessibility/ax_text_utils.h @@ -10,7 +10,7 @@ #include #include "base/strings/string16.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_export.h" namespace ui { @@ -44,22 +44,21 @@ enum TextBoundaryDirection { // (depending on |direction|) from the given |start_offset| until the // given boundary is found, and return the offset of that boundary, // using the vector of line break character offsets in |line_breaks|. -size_t AX_EXPORT - FindAccessibleTextBoundary(const base::string16& text, - const std::vector& line_breaks, - TextBoundaryType boundary, - size_t start_offset, - TextBoundaryDirection direction, - AXTextAffinity affinity); +size_t AX_EXPORT FindAccessibleTextBoundary(const base::string16& text, + const std::vector& line_breaks, + TextBoundaryType boundary, + size_t start_offset, + TextBoundaryDirection direction, + ax::mojom::TextAffinity affinity); // Returns a string ID that corresponds to the name of the given action. base::string16 AX_EXPORT -ActionVerbToLocalizedString(const AXDefaultActionVerb action_verb); +ActionVerbToLocalizedString(const ax::mojom::DefaultActionVerb action_verb); // Returns the non-localized string representation of a supported action. // Some APIs on Linux and Windows need to return non-localized action names. base::string16 AX_EXPORT -ActionVerbToUnlocalizedString(const AXDefaultActionVerb action_verb); +ActionVerbToUnlocalizedString(const ax::mojom::DefaultActionVerb action_verb); } // namespace ui diff --git a/ui/accessibility/ax_text_utils_unittest.cc b/ui/accessibility/ax_text_utils_unittest.cc index 0f1ad1de714bbe..7915cdd24ccb6d 100644 --- a/ui/accessibility/ax_text_utils_unittest.cc +++ b/ui/accessibility/ax_text_utils_unittest.cc @@ -6,7 +6,7 @@ #include "base/strings/utf_string_conversions.h" #include "testing/gtest/include/gtest/gtest.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_text_utils.h" namespace ui { @@ -21,47 +21,47 @@ TEST(AXTextUtils, FindAccessibleTextBoundaryWord) { result = FindAccessibleTextBoundary(text, line_start_offsets, WORD_BOUNDARY, 0, FORWARDS_DIRECTION, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); EXPECT_EQ(6UL, result); result = FindAccessibleTextBoundary(text, line_start_offsets, WORD_BOUNDARY, 5, BACKWARDS_DIRECTION, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); EXPECT_EQ(0UL, result); result = FindAccessibleTextBoundary(text, line_start_offsets, WORD_BOUNDARY, 6, FORWARDS_DIRECTION, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); EXPECT_EQ(12UL, result); result = FindAccessibleTextBoundary(text, line_start_offsets, WORD_BOUNDARY, 11, BACKWARDS_DIRECTION, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); EXPECT_EQ(6UL, result); result = FindAccessibleTextBoundary(text, line_start_offsets, WORD_BOUNDARY, 12, BACKWARDS_DIRECTION, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); EXPECT_EQ(12UL, result); result = FindAccessibleTextBoundary(text, line_start_offsets, WORD_BOUNDARY, 15, FORWARDS_DIRECTION, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); EXPECT_EQ(17UL, result); result = FindAccessibleTextBoundary(text, line_start_offsets, WORD_BOUNDARY, 15, BACKWARDS_DIRECTION, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); EXPECT_EQ(12UL, result); result = FindAccessibleTextBoundary(text, line_start_offsets, WORD_BOUNDARY, 16, FORWARDS_DIRECTION, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); EXPECT_EQ(17UL, result); result = FindAccessibleTextBoundary(text, line_start_offsets, WORD_BOUNDARY, 17, FORWARDS_DIRECTION, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); EXPECT_EQ(20UL, result); result = FindAccessibleTextBoundary(text, line_start_offsets, WORD_BOUNDARY, 20, FORWARDS_DIRECTION, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); EXPECT_EQ(text_length, result); result = FindAccessibleTextBoundary(text, line_start_offsets, WORD_BOUNDARY, text_length, BACKWARDS_DIRECTION, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); EXPECT_EQ(20UL, result); } @@ -76,56 +76,56 @@ TEST(AXTextUtils, FindAccessibleTextBoundaryLine) { // Basic cases. result = FindAccessibleTextBoundary(text, line_start_offsets, LINE_BOUNDARY, 5, FORWARDS_DIRECTION, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); EXPECT_EQ(8UL, result); result = FindAccessibleTextBoundary(text, line_start_offsets, LINE_BOUNDARY, 9, BACKWARDS_DIRECTION, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); EXPECT_EQ(8UL, result); result = FindAccessibleTextBoundary(text, line_start_offsets, LINE_BOUNDARY, 10, FORWARDS_DIRECTION, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); EXPECT_EQ(15UL, result); // Edge cases. result = FindAccessibleTextBoundary(text, line_start_offsets, LINE_BOUNDARY, text_length, BACKWARDS_DIRECTION, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); EXPECT_EQ(15UL, result); // When the start_offset is at the start of the next line and we are searching // backwards, it should not move. result = FindAccessibleTextBoundary(text, line_start_offsets, LINE_BOUNDARY, 15, BACKWARDS_DIRECTION, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); EXPECT_EQ(15UL, result); // When the start_offset is at a hard line break and we are searching // backwards, it should return the start of the previous line. result = FindAccessibleTextBoundary(text, line_start_offsets, LINE_BOUNDARY, 14, BACKWARDS_DIRECTION, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); EXPECT_EQ(8UL, result); // When the start_offset is at the start of a line and we are searching // forwards, it should return the start of the next line. result = FindAccessibleTextBoundary(text, line_start_offsets, LINE_BOUNDARY, 8, FORWARDS_DIRECTION, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); EXPECT_EQ(15UL, result); // When there is no previous line break and we are searching backwards, // it should return 0. result = FindAccessibleTextBoundary(text, line_start_offsets, LINE_BOUNDARY, 4, BACKWARDS_DIRECTION, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); EXPECT_EQ(0UL, result); // When we are at the start of the last line and we are searching forwards. // it should return the text length. result = FindAccessibleTextBoundary(text, line_start_offsets, LINE_BOUNDARY, 15, FORWARDS_DIRECTION, - AX_TEXT_AFFINITY_DOWNSTREAM); + ax::mojom::TextAffinity::kDownstream); EXPECT_EQ(text_length, result); } diff --git a/ui/accessibility/ax_tree.cc b/ui/accessibility/ax_tree.cc index ad7fd28ecdc3d3..65532d2ced397f 100644 --- a/ui/accessibility/ax_tree.cc +++ b/ui/accessibility/ax_tree.cc @@ -219,8 +219,10 @@ gfx::RectF AXTree::RelativeToTreeBounds(const AXNode* node, int scroll_x = 0; int scroll_y = 0; - if (container->data().GetIntAttribute(ui::AX_ATTR_SCROLL_X, &scroll_x) && - container->data().GetIntAttribute(ui::AX_ATTR_SCROLL_Y, &scroll_y)) { + if (container->data().GetIntAttribute(ax::mojom::IntAttribute::kScrollX, + &scroll_x) && + container->data().GetIntAttribute(ax::mojom::IntAttribute::kScrollY, + &scroll_y)) { bounds.Offset(-scroll_x, -scroll_y); } @@ -231,7 +233,8 @@ gfx::RectF AXTree::RelativeToTreeBounds(const AXNode* node, // Calculate the clipped bounds to determine offscreen state. gfx::RectF clipped = bounds; // If this is the root web area, make sure we clip the node to fit. - if (container->data().GetBoolAttribute(ui::AX_ATTR_CLIPS_CHILDREN)) { + if (container->data().GetBoolAttribute( + ax::mojom::BoolAttribute::kClipsChildren)) { if (!intersection.IsEmpty()) { // We can simply clip it to the container. clipped = intersection; @@ -258,7 +261,8 @@ gfx::RectF AXTree::RelativeToTreeBounds(const AXNode* node, if (clip_bounds) bounds = clipped; - if (container->data().GetBoolAttribute(ui::AX_ATTR_CLIPS_CHILDREN) && + if (container->data().GetBoolAttribute( + ax::mojom::BoolAttribute::kClipsChildren) && intersection.IsEmpty() && !clipped.IsEmpty()) { // If it is offscreen with respect to its parent, and the node itself is // not empty, label it offscreen. @@ -283,7 +287,7 @@ gfx::RectF AXTree::GetTreeBounds(const AXNode* node, return RelativeToTreeBounds(node, gfx::RectF(), offscreen, clip_bounds); } -std::set AXTree::GetReverseRelations(AXIntAttribute attr, +std::set AXTree::GetReverseRelations(ax::mojom::IntAttribute attr, int32_t dst_id) const { DCHECK(IsNodeIdIntAttribute(attr)); @@ -298,7 +302,7 @@ std::set AXTree::GetReverseRelations(AXIntAttribute attr, return std::set(); } -std::set AXTree::GetReverseRelations(AXIntListAttribute attr, +std::set AXTree::GetReverseRelations(ax::mojom::IntListAttribute attr, int32_t dst_id) const { DCHECK(IsNodeIdIntListAttribute(attr)); @@ -535,15 +539,15 @@ void AXTree::CallNodeChangeCallbacks(AXNode* node, const AXNodeData& new_data) { delegate_->OnRoleChanged(this, node, old_data.role, new_data.role); if (old_data.state != new_data.state) { - for (int32_t i = static_cast(AX_STATE_NONE) + 1; - i <= static_cast(AX_STATE_LAST); ++i) { - AXState state = static_cast(i); + for (int32_t i = static_cast(ax::mojom::State::kNone) + 1; + i <= static_cast(ax::mojom::State::kLast); ++i) { + ax::mojom::State state = static_cast(i); if (old_data.HasState(state) != new_data.HasState(state)) delegate_->OnStateChanged(this, node, state, new_data.HasState(state)); } } - auto string_callback = [this, node](AXStringAttribute attr, + auto string_callback = [this, node](ax::mojom::StringAttribute attr, const std::string& old_string, const std::string& new_string) { delegate_->OnStringAttributeChanged(this, node, attr, old_string, @@ -553,14 +557,15 @@ void AXTree::CallNodeChangeCallbacks(AXNode* node, const AXNodeData& new_data) { new_data.string_attributes, std::string(), string_callback); - auto bool_callback = [this, node](AXBoolAttribute attr, const bool& old_bool, + auto bool_callback = [this, node](ax::mojom::BoolAttribute attr, + const bool& old_bool, const bool& new_bool) { delegate_->OnBoolAttributeChanged(this, node, attr, new_bool); }; CallIfAttributeValuesChanged(old_data.bool_attributes, new_data.bool_attributes, false, bool_callback); - auto float_callback = [this, node](AXFloatAttribute attr, + auto float_callback = [this, node](ax::mojom::FloatAttribute attr, const float& old_float, const float& new_float) { delegate_->OnFloatAttributeChanged(this, node, attr, old_float, new_float); @@ -568,15 +573,15 @@ void AXTree::CallNodeChangeCallbacks(AXNode* node, const AXNodeData& new_data) { CallIfAttributeValuesChanged(old_data.float_attributes, new_data.float_attributes, 0.0f, float_callback); - auto int_callback = [this, node](AXIntAttribute attr, const int& old_int, - const int& new_int) { + auto int_callback = [this, node](ax::mojom::IntAttribute attr, + const int& old_int, const int& new_int) { delegate_->OnIntAttributeChanged(this, node, attr, old_int, new_int); }; CallIfAttributeValuesChanged(old_data.int_attributes, new_data.int_attributes, 0, int_callback); auto intlist_callback = [this, node]( - AXIntListAttribute attr, + ax::mojom::IntListAttribute attr, const std::vector& old_intlist, const std::vector& new_intlist) { delegate_->OnIntListAttributeChanged(this, node, attr, old_intlist, @@ -587,7 +592,7 @@ void AXTree::CallNodeChangeCallbacks(AXNode* node, const AXNodeData& new_data) { std::vector(), intlist_callback); auto stringlist_callback = - [this, node](AXStringListAttribute attr, + [this, node](ax::mojom::StringListAttribute attr, const std::vector& old_stringlist, const std::vector& new_stringlist) { delegate_->OnStringListAttributeChanged(this, node, attr, @@ -601,8 +606,8 @@ void AXTree::CallNodeChangeCallbacks(AXNode* node, const AXNodeData& new_data) { void AXTree::UpdateReverseRelations(AXNode* node, const AXNodeData& new_data) { const AXNodeData& old_data = node->data(); int id = new_data.id; - auto int_callback = [this, node, id](AXIntAttribute attr, const int& old_int, - const int& new_int) { + auto int_callback = [this, node, id](ax::mojom::IntAttribute attr, + const int& old_int, const int& new_int) { if (!IsNodeIdIntAttribute(attr)) return; @@ -613,7 +618,7 @@ void AXTree::UpdateReverseRelations(AXNode* node, const AXNodeData& new_data) { 0, int_callback); auto intlist_callback = [this, node, id]( - AXIntListAttribute attr, + ax::mojom::IntListAttribute attr, const std::vector& old_intlist, const std::vector& new_intlist) { if (!IsNodeIdIntListAttribute(attr)) diff --git a/ui/accessibility/ax_tree.h b/ui/accessibility/ax_tree.h index d733df9fd1dd30..5604178495c4ee 100644 --- a/ui/accessibility/ax_tree.h +++ b/ui/accessibility/ax_tree.h @@ -52,41 +52,41 @@ class AX_EXPORT AXTreeDelegate { // Individual callbacks for every attribute of AXNodeData that can change. virtual void OnRoleChanged(AXTree* tree, AXNode* node, - AXRole old_role, - AXRole new_role) {} + ax::mojom::Role old_role, + ax::mojom::Role new_role) {} virtual void OnStateChanged(AXTree* tree, AXNode* node, - AXState state, + ax::mojom::State state, bool new_value) {} virtual void OnStringAttributeChanged(AXTree* tree, AXNode* node, - AXStringAttribute attr, + ax::mojom::StringAttribute attr, const std::string& old_value, const std::string& new_value) {} virtual void OnIntAttributeChanged(AXTree* tree, AXNode* node, - AXIntAttribute attr, + ax::mojom::IntAttribute attr, int32_t old_value, int32_t new_value) {} virtual void OnFloatAttributeChanged(AXTree* tree, AXNode* node, - AXFloatAttribute attr, + ax::mojom::FloatAttribute attr, float old_value, float new_value) {} virtual void OnBoolAttributeChanged(AXTree* tree, AXNode* node, - AXBoolAttribute attr, + ax::mojom::BoolAttribute attr, bool new_value) {} virtual void OnIntListAttributeChanged( AXTree* tree, AXNode* node, - AXIntListAttribute attr, + ax::mojom::IntListAttribute attr, const std::vector& old_value, const std::vector& new_value) {} virtual void OnStringListAttributeChanged( AXTree* tree, AXNode* node, - AXStringListAttribute attr, + ax::mojom::StringListAttribute attr, const std::vector& old_value, const std::vector& new_value) {} @@ -204,14 +204,14 @@ class AX_EXPORT AXTree { // Given a node ID attribute (one where IsNodeIdIntAttribute is true), // and a destination node ID, return a set of all source node IDs that // have that relationship attribute between them and the destination. - std::set GetReverseRelations(AXIntAttribute attr, + std::set GetReverseRelations(ax::mojom::IntAttribute attr, int32_t dst_id) const; // Given a node ID list attribute (one where // IsNodeIdIntListAttribute is true), and a destination node ID, // return a set of all source node IDs that have that relationship // attribute between them and the destination. - std::set GetReverseRelations(AXIntListAttribute attr, + std::set GetReverseRelations(ax::mojom::IntListAttribute attr, int32_t dst_id) const; // Return a multi-line indented string representation, for logging. @@ -273,11 +273,11 @@ class AX_EXPORT AXTree { // Map from an int attribute (if IsNodeIdIntAttribute is true) to // a reverse mapping from target nodes to source nodes. - std::map>> + std::map>> int_reverse_relations_; // Map from an int list attribute (if IsNodeIdIntListAttribute is true) to // a reverse mapping from target nodes to source nodes. - std::map>> + std::map>> intlist_reverse_relations_; }; diff --git a/ui/accessibility/ax_tree_combiner.cc b/ui/accessibility/ax_tree_combiner.cc index 68a9c8b22ac633..06a6ac157260e8 100644 --- a/ui/accessibility/ax_tree_combiner.cc +++ b/ui/accessibility/ax_tree_combiner.cc @@ -80,7 +80,8 @@ void AXTreeCombiner::ProcessTree(const AXTreeUpdate* tree) { int32_t tree_id = tree->tree_data.tree_id; for (size_t i = 0; i < tree->nodes.size(); ++i) { AXNodeData node = tree->nodes[i]; - int32_t child_tree_id = node.GetIntAttribute(AX_ATTR_CHILD_TREE_ID); + int32_t child_tree_id = + node.GetIntAttribute(ax::mojom::IntAttribute::kChildTreeId); // Map the node's ID. node.id = MapId(tree_id, node.id); @@ -94,13 +95,13 @@ void AXTreeCombiner::ProcessTree(const AXTreeUpdate* tree) { node.offset_container_id = MapId(tree_id, node.offset_container_id); // Map other int attributes that refer to node IDs, and remove the - // AX_ATTR_CHILD_TREE_ID attribute. + // ax::mojom::IntAttribute::kChildTreeId attribute. for (size_t j = 0; j < node.int_attributes.size(); ++j) { auto& attr = node.int_attributes[j]; if (IsNodeIdIntAttribute(attr.first)) attr.second = MapId(tree_id, attr.second); - if (attr.first == AX_ATTR_CHILD_TREE_ID) { - attr.first = AX_INT_ATTRIBUTE_NONE; + if (attr.first == ax::mojom::IntAttribute::kChildTreeId) { + attr.first = ax::mojom::IntAttribute::kNone; attr.second = 0; } } diff --git a/ui/accessibility/ax_tree_combiner_unittest.cc b/ui/accessibility/ax_tree_combiner_unittest.cc index 70f861c0966c7f..6e0aaf498fc05f 100644 --- a/ui/accessibility/ax_tree_combiner_unittest.cc +++ b/ui/accessibility/ax_tree_combiner_unittest.cc @@ -45,10 +45,11 @@ TEST(CombineAXTreesTest, EmbedChildTree) { parent_tree.nodes[0].child_ids.push_back(2); parent_tree.nodes[0].child_ids.push_back(3); parent_tree.nodes[1].id = 2; - parent_tree.nodes[1].role = AX_ROLE_BUTTON; + parent_tree.nodes[1].role = ax::mojom::Role::kButton; parent_tree.nodes[2].id = 3; - parent_tree.nodes[2].role = AX_ROLE_IFRAME; - parent_tree.nodes[2].AddIntAttribute(AX_ATTR_CHILD_TREE_ID, 2); + parent_tree.nodes[2].role = ax::mojom::Role::kIframe; + parent_tree.nodes[2].AddIntAttribute(ax::mojom::IntAttribute::kChildTreeId, + 2); AXTreeUpdate child_tree; child_tree.root_id = 1; @@ -60,9 +61,9 @@ TEST(CombineAXTreesTest, EmbedChildTree) { child_tree.nodes[0].child_ids.push_back(2); child_tree.nodes[0].child_ids.push_back(3); child_tree.nodes[1].id = 2; - child_tree.nodes[1].role = AX_ROLE_CHECK_BOX; + child_tree.nodes[1].role = ax::mojom::Role::kCheckBox; child_tree.nodes[2].id = 3; - child_tree.nodes[2].role = AX_ROLE_RADIO_BUTTON; + child_tree.nodes[2].role = ax::mojom::Role::kRadioButton; AXTreeCombiner combiner; combiner.AddTree(parent_tree, true); @@ -78,16 +79,16 @@ TEST(CombineAXTreesTest, EmbedChildTree) { EXPECT_EQ(2, combined.nodes[0].child_ids[0]); EXPECT_EQ(3, combined.nodes[0].child_ids[1]); EXPECT_EQ(2, combined.nodes[1].id); - EXPECT_EQ(AX_ROLE_BUTTON, combined.nodes[1].role); + EXPECT_EQ(ax::mojom::Role::kButton, combined.nodes[1].role); EXPECT_EQ(3, combined.nodes[2].id); - EXPECT_EQ(AX_ROLE_IFRAME, combined.nodes[2].role); + EXPECT_EQ(ax::mojom::Role::kIframe, combined.nodes[2].role); EXPECT_EQ(1U, combined.nodes[2].child_ids.size()); EXPECT_EQ(4, combined.nodes[2].child_ids[0]); EXPECT_EQ(4, combined.nodes[3].id); EXPECT_EQ(5, combined.nodes[4].id); - EXPECT_EQ(AX_ROLE_CHECK_BOX, combined.nodes[4].role); + EXPECT_EQ(ax::mojom::Role::kCheckBox, combined.nodes[4].role); EXPECT_EQ(6, combined.nodes[5].id); - EXPECT_EQ(AX_ROLE_RADIO_BUTTON, combined.nodes[5].role); + EXPECT_EQ(ax::mojom::Role::kRadioButton, combined.nodes[5].role); } TEST(CombineAXTreesTest, MapAllIdAttributes) { @@ -101,18 +102,26 @@ TEST(CombineAXTreesTest, MapAllIdAttributes) { tree.nodes.resize(2); tree.nodes[0].id = 11; tree.nodes[0].child_ids.push_back(22); - tree.nodes[0].AddIntAttribute(AX_ATTR_TABLE_HEADER_ID, 22); - tree.nodes[0].AddIntAttribute(AX_ATTR_TABLE_ROW_HEADER_ID, 22); - tree.nodes[0].AddIntAttribute(AX_ATTR_TABLE_COLUMN_HEADER_ID, 22); - tree.nodes[0].AddIntAttribute(AX_ATTR_ACTIVEDESCENDANT_ID, 22); + tree.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kTableHeaderId, 22); + tree.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kTableRowHeaderId, 22); + tree.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kTableColumnHeaderId, + 22); + tree.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kActivedescendantId, + 22); std::vector ids { 22 }; - tree.nodes[0].AddIntListAttribute(AX_ATTR_INDIRECT_CHILD_IDS, ids); - tree.nodes[0].AddIntListAttribute(AX_ATTR_CONTROLS_IDS, ids); - tree.nodes[0].AddIntListAttribute(AX_ATTR_DESCRIBEDBY_IDS, ids); - tree.nodes[0].AddIntListAttribute(AX_ATTR_FLOWTO_IDS, ids); - tree.nodes[0].AddIntListAttribute(AX_ATTR_LABELLEDBY_IDS, ids); - tree.nodes[0].AddIntListAttribute(AX_ATTR_CELL_IDS, ids); - tree.nodes[0].AddIntListAttribute(AX_ATTR_UNIQUE_CELL_IDS, ids); + tree.nodes[0].AddIntListAttribute( + ax::mojom::IntListAttribute::kIndirectChildIds, ids); + tree.nodes[0].AddIntListAttribute(ax::mojom::IntListAttribute::kControlsIds, + ids); + tree.nodes[0].AddIntListAttribute( + ax::mojom::IntListAttribute::kDescribedbyIds, ids); + tree.nodes[0].AddIntListAttribute(ax::mojom::IntListAttribute::kFlowtoIds, + ids); + tree.nodes[0].AddIntListAttribute(ax::mojom::IntListAttribute::kLabelledbyIds, + ids); + tree.nodes[0].AddIntListAttribute(ax::mojom::IntListAttribute::kCellIds, ids); + tree.nodes[0].AddIntListAttribute(ax::mojom::IntListAttribute::kUniqueCellIds, + ids); tree.nodes[1].id = 22; AXTreeCombiner combiner; @@ -128,25 +137,28 @@ TEST(CombineAXTreesTest, MapAllIdAttributes) { EXPECT_EQ(2, combined.nodes[0].child_ids[0]); EXPECT_EQ(2, combined.nodes[1].id); - EXPECT_EQ(2, combined.nodes[0].GetIntAttribute(AX_ATTR_TABLE_HEADER_ID)); - EXPECT_EQ(2, combined.nodes[0].GetIntAttribute(AX_ATTR_TABLE_ROW_HEADER_ID)); EXPECT_EQ(2, combined.nodes[0].GetIntAttribute( - AX_ATTR_TABLE_COLUMN_HEADER_ID)); - EXPECT_EQ(2, combined.nodes[0].GetIntAttribute(AX_ATTR_ACTIVEDESCENDANT_ID)); + ax::mojom::IntAttribute::kTableHeaderId)); + EXPECT_EQ(2, combined.nodes[0].GetIntAttribute( + ax::mojom::IntAttribute::kTableRowHeaderId)); + EXPECT_EQ(2, combined.nodes[0].GetIntAttribute( + ax::mojom::IntAttribute::kTableColumnHeaderId)); + EXPECT_EQ(2, combined.nodes[0].GetIntAttribute( + ax::mojom::IntAttribute::kActivedescendantId)); EXPECT_EQ(2, combined.nodes[0].GetIntListAttribute( - AX_ATTR_INDIRECT_CHILD_IDS)[0]); + ax::mojom::IntListAttribute::kIndirectChildIds)[0]); EXPECT_EQ(2, combined.nodes[0].GetIntListAttribute( - AX_ATTR_CONTROLS_IDS)[0]); + ax::mojom::IntListAttribute::kControlsIds)[0]); EXPECT_EQ(2, combined.nodes[0].GetIntListAttribute( - AX_ATTR_DESCRIBEDBY_IDS)[0]); + ax::mojom::IntListAttribute::kDescribedbyIds)[0]); EXPECT_EQ(2, combined.nodes[0].GetIntListAttribute( - AX_ATTR_FLOWTO_IDS)[0]); + ax::mojom::IntListAttribute::kFlowtoIds)[0]); EXPECT_EQ(2, combined.nodes[0].GetIntListAttribute( - AX_ATTR_LABELLEDBY_IDS)[0]); + ax::mojom::IntListAttribute::kLabelledbyIds)[0]); EXPECT_EQ(2, combined.nodes[0].GetIntListAttribute( - AX_ATTR_CELL_IDS)[0]); + ax::mojom::IntListAttribute::kCellIds)[0]); EXPECT_EQ(2, combined.nodes[0].GetIntListAttribute( - AX_ATTR_UNIQUE_CELL_IDS)[0]); + ax::mojom::IntListAttribute::kUniqueCellIds)[0]); } TEST(CombineAXTreesTest, FocusedTree) { @@ -161,10 +173,11 @@ TEST(CombineAXTreesTest, FocusedTree) { parent_tree.nodes[0].child_ids.push_back(2); parent_tree.nodes[0].child_ids.push_back(3); parent_tree.nodes[1].id = 2; - parent_tree.nodes[1].role = AX_ROLE_BUTTON; + parent_tree.nodes[1].role = ax::mojom::Role::kButton; parent_tree.nodes[2].id = 3; - parent_tree.nodes[2].role = AX_ROLE_IFRAME; - parent_tree.nodes[2].AddIntAttribute(AX_ATTR_CHILD_TREE_ID, 2); + parent_tree.nodes[2].role = ax::mojom::Role::kIframe; + parent_tree.nodes[2].AddIntAttribute(ax::mojom::IntAttribute::kChildTreeId, + 2); AXTreeUpdate child_tree; child_tree.has_tree_data = true; @@ -177,9 +190,9 @@ TEST(CombineAXTreesTest, FocusedTree) { child_tree.nodes[0].child_ids.push_back(2); child_tree.nodes[0].child_ids.push_back(3); child_tree.nodes[1].id = 2; - child_tree.nodes[1].role = AX_ROLE_CHECK_BOX; + child_tree.nodes[1].role = ax::mojom::Role::kCheckBox; child_tree.nodes[2].id = 3; - child_tree.nodes[2].role = AX_ROLE_RADIO_BUTTON; + child_tree.nodes[2].role = ax::mojom::Role::kRadioButton; AXTreeCombiner combiner; combiner.AddTree(parent_tree, true); diff --git a/ui/accessibility/ax_tree_data.cc b/ui/accessibility/ax_tree_data.cc index 3639b8dbebf973..20e5f1ccce8dc9 100644 --- a/ui/accessibility/ax_tree_data.cc +++ b/ui/accessibility/ax_tree_data.cc @@ -10,6 +10,7 @@ #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" +#include "ui/accessibility/ax_enum_util.h" namespace ui { diff --git a/ui/accessibility/ax_tree_data.h b/ui/accessibility/ax_tree_data.h index d637bf2b45d74e..0233764b109e96 100644 --- a/ui/accessibility/ax_tree_data.h +++ b/ui/accessibility/ax_tree_data.h @@ -13,7 +13,7 @@ #include "base/strings/string16.h" #include "base/strings/string_split.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_export.h" #include "ui/gfx/geometry/rect.h" @@ -61,10 +61,12 @@ struct AX_EXPORT AXTreeData { // line, otherwise it's on the second line. int32_t sel_anchor_object_id = -1; int32_t sel_anchor_offset = -1; - ui::AXTextAffinity sel_anchor_affinity = AX_TEXT_AFFINITY_UPSTREAM; + ax::mojom::TextAffinity sel_anchor_affinity = + ax::mojom::TextAffinity::kUpstream; int32_t sel_focus_object_id = -1; int32_t sel_focus_offset = -1; - ui::AXTextAffinity sel_focus_affinity = AX_TEXT_AFFINITY_DOWNSTREAM; + ax::mojom::TextAffinity sel_focus_affinity = + ax::mojom::TextAffinity::kDownstream; }; AX_EXPORT bool operator==(const AXTreeData& lhs, const AXTreeData& rhs); diff --git a/ui/accessibility/ax_tree_unittest.cc b/ui/accessibility/ax_tree_unittest.cc index b7dd78139189bc..06d0a25cd7ec93 100644 --- a/ui/accessibility/ax_tree_unittest.cc +++ b/ui/accessibility/ax_tree_unittest.cc @@ -14,6 +14,7 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" #include "testing/gtest/include/gtest/gtest.h" +#include "ui/accessibility/ax_enum_util.h" #include "ui/accessibility/ax_node.h" #include "ui/accessibility/ax_serializable_tree.h" #include "ui/accessibility/ax_tree_serializer.h" @@ -119,15 +120,15 @@ class FakeAXTreeDelegate : public AXTreeDelegate { void OnRoleChanged(AXTree* tree, AXNode* node, - AXRole old_role, - AXRole new_role) override { + ax::mojom::Role old_role, + ax::mojom::Role new_role) override { attribute_change_log_.push_back(base::StringPrintf( "Role changed from %s to %s", ToString(old_role), ToString(new_role))); } void OnStateChanged(AXTree* tree, AXNode* node, - AXState state, + ax::mojom::State state, bool new_value) override { attribute_change_log_.push_back(base::StringPrintf( "%s changed to %s", ToString(state), new_value ? "true" : "false")); @@ -135,7 +136,7 @@ class FakeAXTreeDelegate : public AXTreeDelegate { void OnStringAttributeChanged(AXTree* tree, AXNode* node, - AXStringAttribute attr, + ax::mojom::StringAttribute attr, const std::string& old_value, const std::string& new_value) override { attribute_change_log_.push_back( @@ -145,7 +146,7 @@ class FakeAXTreeDelegate : public AXTreeDelegate { void OnIntAttributeChanged(AXTree* tree, AXNode* node, - AXIntAttribute attr, + ax::mojom::IntAttribute attr, int32_t old_value, int32_t new_value) override { attribute_change_log_.push_back(base::StringPrintf( @@ -154,7 +155,7 @@ class FakeAXTreeDelegate : public AXTreeDelegate { void OnFloatAttributeChanged(AXTree* tree, AXNode* node, - AXFloatAttribute attr, + ax::mojom::FloatAttribute attr, float old_value, float new_value) override { attribute_change_log_.push_back( @@ -165,7 +166,7 @@ class FakeAXTreeDelegate : public AXTreeDelegate { void OnBoolAttributeChanged(AXTree* tree, AXNode* node, - AXBoolAttribute attr, + ax::mojom::BoolAttribute attr, bool new_value) override { attribute_change_log_.push_back(base::StringPrintf( "%s changed to %s", ToString(attr), new_value ? "true" : "false")); @@ -174,7 +175,7 @@ class FakeAXTreeDelegate : public AXTreeDelegate { void OnIntListAttributeChanged( AXTree* tree, AXNode* node, - AXIntListAttribute attr, + ax::mojom::IntListAttribute attr, const std::vector& old_value, const std::vector& new_value) override { attribute_change_log_.push_back( @@ -229,20 +230,20 @@ class FakeAXTreeDelegate : public AXTreeDelegate { TEST(AXTreeTest, SerializeSimpleAXTree) { AXNodeData root; root.id = 1; - root.role = AX_ROLE_DIALOG; - root.AddState(AX_STATE_FOCUSABLE); + root.role = ax::mojom::Role::kDialog; + root.AddState(ax::mojom::State::kFocusable); root.location = gfx::RectF(0, 0, 800, 600); root.child_ids.push_back(2); root.child_ids.push_back(3); AXNodeData button; button.id = 2; - button.role = AX_ROLE_BUTTON; + button.role = ax::mojom::Role::kButton; button.location = gfx::RectF(20, 20, 200, 30); AXNodeData checkbox; checkbox.id = 3; - checkbox.role = AX_ROLE_CHECK_BOX; + checkbox.role = ax::mojom::Role::kCheckBox; checkbox.location = gfx::RectF(20, 50, 200, 30); AXTreeUpdate initial_state; @@ -290,22 +291,22 @@ TEST(AXTreeTest, SerializeSimpleAXTree) { TEST(AXTreeTest, SerializeAXTreeUpdate) { AXNodeData list; list.id = 3; - list.role = AX_ROLE_LIST; + list.role = ax::mojom::Role::kList; list.child_ids.push_back(4); list.child_ids.push_back(5); list.child_ids.push_back(6); AXNodeData list_item_2; list_item_2.id = 5; - list_item_2.role = AX_ROLE_LIST_ITEM; + list_item_2.role = ax::mojom::Role::kListItem; AXNodeData list_item_3; list_item_3.id = 6; - list_item_3.role = AX_ROLE_LIST_ITEM; + list_item_3.role = ax::mojom::Role::kListItem; AXNodeData button; button.id = 7; - button.role = AX_ROLE_BUTTON; + button.role = ax::mojom::Role::kButton; AXTreeUpdate update; update.root_id = 3; @@ -742,9 +743,9 @@ TEST(AXTreeTest, RoleAndStateChangeCallbacks) { initial_state.root_id = 1; initial_state.nodes.resize(1); initial_state.nodes[0].id = 1; - initial_state.nodes[0].role = AX_ROLE_BUTTON; - initial_state.nodes[0].SetCheckedState(AX_CHECKED_STATE_TRUE); - initial_state.nodes[0].AddState(AX_STATE_FOCUSABLE); + initial_state.nodes[0].role = ax::mojom::Role::kButton; + initial_state.nodes[0].SetCheckedState(ax::mojom::CheckedState::kTrue); + initial_state.nodes[0].AddState(ax::mojom::State::kFocusable); AXTree tree(initial_state); FakeAXTreeDelegate fake_delegate; @@ -755,10 +756,10 @@ TEST(AXTreeTest, RoleAndStateChangeCallbacks) { update.root_id = 1; update.nodes.resize(1); update.nodes[0].id = 1; - update.nodes[0].role = AX_ROLE_CHECK_BOX; - update.nodes[0].SetCheckedState(AX_CHECKED_STATE_FALSE); - update.nodes[0].AddState(AX_STATE_FOCUSABLE); - update.nodes[0].AddState(AX_STATE_VISITED); + update.nodes[0].role = ax::mojom::Role::kCheckBox; + update.nodes[0].SetCheckedState(ax::mojom::CheckedState::kFalse); + update.nodes[0].AddState(ax::mojom::State::kFocusable); + update.nodes[0].AddState(ax::mojom::State::kVisited); EXPECT_TRUE(tree.Unserialize(update)); const std::vector& change_log = @@ -776,15 +777,23 @@ TEST(AXTreeTest, AttributeChangeCallbacks) { initial_state.root_id = 1; initial_state.nodes.resize(1); initial_state.nodes[0].id = 1; - initial_state.nodes[0].AddStringAttribute(AX_ATTR_NAME, "N1"); - initial_state.nodes[0].AddStringAttribute(AX_ATTR_DESCRIPTION, "D1"); - initial_state.nodes[0].AddBoolAttribute(AX_ATTR_LIVE_ATOMIC, true); - initial_state.nodes[0].AddBoolAttribute(AX_ATTR_BUSY, false); - initial_state.nodes[0].AddFloatAttribute(AX_ATTR_MIN_VALUE_FOR_RANGE, 1.0); - initial_state.nodes[0].AddFloatAttribute(AX_ATTR_MAX_VALUE_FOR_RANGE, 10.0); - initial_state.nodes[0].AddFloatAttribute(AX_ATTR_STEP_VALUE_FOR_RANGE, 3.0); - initial_state.nodes[0].AddIntAttribute(AX_ATTR_SCROLL_X, 5); - initial_state.nodes[0].AddIntAttribute(AX_ATTR_SCROLL_X_MIN, 1); + initial_state.nodes[0].AddStringAttribute(ax::mojom::StringAttribute::kName, + "N1"); + initial_state.nodes[0].AddStringAttribute( + ax::mojom::StringAttribute::kDescription, "D1"); + initial_state.nodes[0].AddBoolAttribute(ax::mojom::BoolAttribute::kLiveAtomic, + true); + initial_state.nodes[0].AddBoolAttribute(ax::mojom::BoolAttribute::kBusy, + false); + initial_state.nodes[0].AddFloatAttribute( + ax::mojom::FloatAttribute::kMinValueForRange, 1.0); + initial_state.nodes[0].AddFloatAttribute( + ax::mojom::FloatAttribute::kMaxValueForRange, 10.0); + initial_state.nodes[0].AddFloatAttribute( + ax::mojom::FloatAttribute::kStepValueForRange, 3.0); + initial_state.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kScrollX, 5); + initial_state.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kScrollXMin, + 1); AXTree tree(initial_state); FakeAXTreeDelegate fake_delegate; @@ -795,15 +804,20 @@ TEST(AXTreeTest, AttributeChangeCallbacks) { update0.root_id = 1; update0.nodes.resize(1); update0.nodes[0].id = 1; - update0.nodes[0].AddStringAttribute(AX_ATTR_NAME, "N2"); - update0.nodes[0].AddStringAttribute(AX_ATTR_DESCRIPTION, "D2"); - update0.nodes[0].AddBoolAttribute(AX_ATTR_LIVE_ATOMIC, false); - update0.nodes[0].AddBoolAttribute(AX_ATTR_BUSY, true); - update0.nodes[0].AddFloatAttribute(AX_ATTR_MIN_VALUE_FOR_RANGE, 2.0); - update0.nodes[0].AddFloatAttribute(AX_ATTR_MAX_VALUE_FOR_RANGE, 9.0); - update0.nodes[0].AddFloatAttribute(AX_ATTR_STEP_VALUE_FOR_RANGE, 0.5); - update0.nodes[0].AddIntAttribute(AX_ATTR_SCROLL_X, 6); - update0.nodes[0].AddIntAttribute(AX_ATTR_SCROLL_X_MIN, 2); + update0.nodes[0].AddStringAttribute(ax::mojom::StringAttribute::kName, "N2"); + update0.nodes[0].AddStringAttribute(ax::mojom::StringAttribute::kDescription, + "D2"); + update0.nodes[0].AddBoolAttribute(ax::mojom::BoolAttribute::kLiveAtomic, + false); + update0.nodes[0].AddBoolAttribute(ax::mojom::BoolAttribute::kBusy, true); + update0.nodes[0].AddFloatAttribute( + ax::mojom::FloatAttribute::kMinValueForRange, 2.0); + update0.nodes[0].AddFloatAttribute( + ax::mojom::FloatAttribute::kMaxValueForRange, 9.0); + update0.nodes[0].AddFloatAttribute( + ax::mojom::FloatAttribute::kStepValueForRange, 0.5); + update0.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kScrollX, 6); + update0.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kScrollXMin, 2); EXPECT_TRUE(tree.Unserialize(update0)); const std::vector& change_log = @@ -827,13 +841,16 @@ TEST(AXTreeTest, AttributeChangeCallbacks) { update1.root_id = 1; update1.nodes.resize(1); update1.nodes[0].id = 1; - update1.nodes[0].AddStringAttribute(AX_ATTR_DESCRIPTION, "D3"); - update1.nodes[0].AddStringAttribute(AX_ATTR_VALUE, "V3"); - update1.nodes[0].AddBoolAttribute(AX_ATTR_MODAL, true); - update1.nodes[0].AddFloatAttribute(AX_ATTR_VALUE_FOR_RANGE, 5.0); - update1.nodes[0].AddFloatAttribute(AX_ATTR_MAX_VALUE_FOR_RANGE, 9.0); - update1.nodes[0].AddIntAttribute(AX_ATTR_SCROLL_X, 7); - update1.nodes[0].AddIntAttribute(AX_ATTR_SCROLL_X_MAX, 10); + update1.nodes[0].AddStringAttribute(ax::mojom::StringAttribute::kDescription, + "D3"); + update1.nodes[0].AddStringAttribute(ax::mojom::StringAttribute::kValue, "V3"); + update1.nodes[0].AddBoolAttribute(ax::mojom::BoolAttribute::kModal, true); + update1.nodes[0].AddFloatAttribute(ax::mojom::FloatAttribute::kValueForRange, + 5.0); + update1.nodes[0].AddFloatAttribute( + ax::mojom::FloatAttribute::kMaxValueForRange, 9.0); + update1.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kScrollX, 7); + update1.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kScrollXMax, 10); EXPECT_TRUE(tree.Unserialize(update1)); const std::vector& change_log2 = @@ -869,8 +886,10 @@ TEST(AXTreeTest, IntListChangeCallbacks) { initial_state.root_id = 1; initial_state.nodes.resize(1); initial_state.nodes[0].id = 1; - initial_state.nodes[0].AddIntListAttribute(AX_ATTR_CONTROLS_IDS, one); - initial_state.nodes[0].AddIntListAttribute(AX_ATTR_RADIO_GROUP_IDS, two); + initial_state.nodes[0].AddIntListAttribute( + ax::mojom::IntListAttribute::kControlsIds, one); + initial_state.nodes[0].AddIntListAttribute( + ax::mojom::IntListAttribute::kRadioGroupIds, two); AXTree tree(initial_state); FakeAXTreeDelegate fake_delegate; @@ -881,8 +900,10 @@ TEST(AXTreeTest, IntListChangeCallbacks) { update0.root_id = 1; update0.nodes.resize(1); update0.nodes[0].id = 1; - update0.nodes[0].AddIntListAttribute(AX_ATTR_CONTROLS_IDS, two); - update0.nodes[0].AddIntListAttribute(AX_ATTR_RADIO_GROUP_IDS, three); + update0.nodes[0].AddIntListAttribute( + ax::mojom::IntListAttribute::kControlsIds, two); + update0.nodes[0].AddIntListAttribute( + ax::mojom::IntListAttribute::kRadioGroupIds, three); EXPECT_TRUE(tree.Unserialize(update0)); const std::vector& change_log = @@ -899,8 +920,10 @@ TEST(AXTreeTest, IntListChangeCallbacks) { update1.root_id = 1; update1.nodes.resize(1); update1.nodes[0].id = 1; - update1.nodes[0].AddIntListAttribute(AX_ATTR_RADIO_GROUP_IDS, two); - update1.nodes[0].AddIntListAttribute(AX_ATTR_FLOWTO_IDS, three); + update1.nodes[0].AddIntListAttribute( + ax::mojom::IntListAttribute::kRadioGroupIds, two); + update1.nodes[0].AddIntListAttribute(ax::mojom::IntListAttribute::kFlowtoIds, + three); EXPECT_TRUE(tree.Unserialize(update1)); const std::vector& change_log2 = @@ -960,8 +983,9 @@ TEST(AXTreeTest, EmptyNodeNotOffscreenEvenIfAllChildrenOffscreen) { tree_update.nodes.resize(4); tree_update.nodes[0].id = 1; tree_update.nodes[0].location = gfx::RectF(0, 0, 800, 600); - tree_update.nodes[0].role = AX_ROLE_ROOT_WEB_AREA; - tree_update.nodes[0].AddBoolAttribute(ui::AX_ATTR_CLIPS_CHILDREN, true); + tree_update.nodes[0].role = ax::mojom::Role::kRootWebArea; + tree_update.nodes[0].AddBoolAttribute( + ax::mojom::BoolAttribute::kClipsChildren, true); tree_update.nodes[0].child_ids.push_back(2); tree_update.nodes[1].id = 2; tree_update.nodes[1].location = gfx::RectF(); // Deliberately empty. @@ -1038,8 +1062,8 @@ TEST(AXTreeTest, GetBoundsWithScrolling) { tree_update.nodes[0].child_ids.push_back(2); tree_update.nodes[1].id = 2; tree_update.nodes[1].location = gfx::RectF(100, 50, 600, 500); - tree_update.nodes[1].AddIntAttribute(ui::AX_ATTR_SCROLL_X, 5); - tree_update.nodes[1].AddIntAttribute(ui::AX_ATTR_SCROLL_Y, 10); + tree_update.nodes[1].AddIntAttribute(ax::mojom::IntAttribute::kScrollX, 5); + tree_update.nodes[1].AddIntAttribute(ax::mojom::IntAttribute::kScrollY, 10); tree_update.nodes[1].child_ids.push_back(3); tree_update.nodes[2].id = 3; tree_update.nodes[2].offset_container_id = 2; @@ -1055,7 +1079,8 @@ TEST(AXTreeTest, GetBoundsEmptyBoundsInheritsFromParent) { tree_update.nodes.resize(3); tree_update.nodes[0].id = 1; tree_update.nodes[0].location = gfx::RectF(0, 0, 800, 600); - tree_update.nodes[1].AddBoolAttribute(ui::AX_ATTR_CLIPS_CHILDREN, true); + tree_update.nodes[1].AddBoolAttribute( + ax::mojom::BoolAttribute::kClipsChildren, true); tree_update.nodes[0].child_ids.push_back(2); tree_update.nodes[1].id = 2; tree_update.nodes[1].location = gfx::RectF(300, 200, 100, 100); @@ -1081,7 +1106,8 @@ TEST(AXTreeTest, GetBoundsCropsChildToRoot) { tree_update.nodes.resize(5); tree_update.nodes[0].id = 1; tree_update.nodes[0].location = gfx::RectF(0, 0, 800, 600); - tree_update.nodes[0].AddBoolAttribute(ui::AX_ATTR_CLIPS_CHILDREN, true); + tree_update.nodes[0].AddBoolAttribute( + ax::mojom::BoolAttribute::kClipsChildren, true); tree_update.nodes[0].child_ids.push_back(2); tree_update.nodes[0].child_ids.push_back(3); tree_update.nodes[0].child_ids.push_back(4); @@ -1119,13 +1145,15 @@ TEST(AXTreeTest, GetBoundsSetsOffscreenIfClipsChildren) { tree_update.nodes.resize(5); tree_update.nodes[0].id = 1; tree_update.nodes[0].location = gfx::RectF(0, 0, 800, 600); - tree_update.nodes[0].AddBoolAttribute(ui::AX_ATTR_CLIPS_CHILDREN, true); + tree_update.nodes[0].AddBoolAttribute( + ax::mojom::BoolAttribute::kClipsChildren, true); tree_update.nodes[0].child_ids.push_back(2); tree_update.nodes[0].child_ids.push_back(3); tree_update.nodes[1].id = 2; tree_update.nodes[1].location = gfx::RectF(0, 0, 200, 200); - tree_update.nodes[1].AddBoolAttribute(ui::AX_ATTR_CLIPS_CHILDREN, true); + tree_update.nodes[1].AddBoolAttribute( + ax::mojom::BoolAttribute::kClipsChildren, true); tree_update.nodes[1].child_ids.push_back(4); tree_update.nodes[2].id = 3; @@ -1154,8 +1182,9 @@ TEST(AXTreeTest, GetBoundsUpdatesOffscreen) { tree_update.nodes.resize(5); tree_update.nodes[0].id = 1; tree_update.nodes[0].location = gfx::RectF(0, 0, 800, 600); - tree_update.nodes[0].role = AX_ROLE_ROOT_WEB_AREA; - tree_update.nodes[0].AddBoolAttribute(ui::AX_ATTR_CLIPS_CHILDREN, true); + tree_update.nodes[0].role = ax::mojom::Role::kRootWebArea; + tree_update.nodes[0].AddBoolAttribute( + ax::mojom::BoolAttribute::kClipsChildren, true); tree_update.nodes[0].child_ids.push_back(2); tree_update.nodes[0].child_ids.push_back(3); tree_update.nodes[0].child_ids.push_back(4); @@ -1185,32 +1214,35 @@ TEST(AXTreeTest, IntReverseRelations) { initial_state.root_id = 1; initial_state.nodes.resize(4); initial_state.nodes[0].id = 1; - initial_state.nodes[0].AddIntAttribute(AX_ATTR_ACTIVEDESCENDANT_ID, 2); + initial_state.nodes[0].AddIntAttribute( + ax::mojom::IntAttribute::kActivedescendantId, 2); initial_state.nodes[0].child_ids.push_back(2); initial_state.nodes[0].child_ids.push_back(3); initial_state.nodes[0].child_ids.push_back(4); initial_state.nodes[1].id = 2; initial_state.nodes[2].id = 3; - initial_state.nodes[2].AddIntAttribute(AX_ATTR_MEMBER_OF_ID, 1); + initial_state.nodes[2].AddIntAttribute(ax::mojom::IntAttribute::kMemberOfId, + 1); initial_state.nodes[3].id = 4; - initial_state.nodes[3].AddIntAttribute(AX_ATTR_MEMBER_OF_ID, 1); + initial_state.nodes[3].AddIntAttribute(ax::mojom::IntAttribute::kMemberOfId, + 1); AXTree tree(initial_state); auto reverse_active_descendant = - tree.GetReverseRelations(ui::AX_ATTR_ACTIVEDESCENDANT_ID, 2); + tree.GetReverseRelations(ax::mojom::IntAttribute::kActivedescendantId, 2); ASSERT_EQ(1U, reverse_active_descendant.size()); EXPECT_TRUE(base::ContainsKey(reverse_active_descendant, 1)); reverse_active_descendant = - tree.GetReverseRelations(ui::AX_ATTR_ACTIVEDESCENDANT_ID, 1); + tree.GetReverseRelations(ax::mojom::IntAttribute::kActivedescendantId, 1); ASSERT_EQ(0U, reverse_active_descendant.size()); auto reverse_errormessage = - tree.GetReverseRelations(ui::AX_ATTR_ERRORMESSAGE_ID, 1); + tree.GetReverseRelations(ax::mojom::IntAttribute::kErrormessageId, 1); ASSERT_EQ(0U, reverse_errormessage.size()); auto reverse_member_of = - tree.GetReverseRelations(ui::AX_ATTR_MEMBER_OF_ID, 1); + tree.GetReverseRelations(ax::mojom::IntAttribute::kMemberOfId, 1); ASSERT_EQ(2U, reverse_member_of.size()); EXPECT_TRUE(base::ContainsKey(reverse_member_of, 3)); EXPECT_TRUE(base::ContainsKey(reverse_member_of, 4)); @@ -1218,24 +1250,26 @@ TEST(AXTreeTest, IntReverseRelations) { AXTreeUpdate update = initial_state; update.nodes.resize(5); update.nodes[0].int_attributes.clear(); - update.nodes[0].AddIntAttribute(AX_ATTR_ACTIVEDESCENDANT_ID, 5); + update.nodes[0].AddIntAttribute(ax::mojom::IntAttribute::kActivedescendantId, + 5); update.nodes[0].child_ids.push_back(5); update.nodes[2].int_attributes.clear(); update.nodes[4].id = 5; - update.nodes[4].AddIntAttribute(AX_ATTR_MEMBER_OF_ID, 1); + update.nodes[4].AddIntAttribute(ax::mojom::IntAttribute::kMemberOfId, 1); EXPECT_TRUE(tree.Unserialize(update)); reverse_active_descendant = - tree.GetReverseRelations(ui::AX_ATTR_ACTIVEDESCENDANT_ID, 2); + tree.GetReverseRelations(ax::mojom::IntAttribute::kActivedescendantId, 2); ASSERT_EQ(0U, reverse_active_descendant.size()); reverse_active_descendant = - tree.GetReverseRelations(ui::AX_ATTR_ACTIVEDESCENDANT_ID, 5); + tree.GetReverseRelations(ax::mojom::IntAttribute::kActivedescendantId, 5); ASSERT_EQ(1U, reverse_active_descendant.size()); EXPECT_TRUE(base::ContainsKey(reverse_active_descendant, 1)); - reverse_member_of = tree.GetReverseRelations(ui::AX_ATTR_MEMBER_OF_ID, 1); + reverse_member_of = + tree.GetReverseRelations(ax::mojom::IntAttribute::kMemberOfId, 1); ASSERT_EQ(2U, reverse_member_of.size()); EXPECT_TRUE(base::ContainsKey(reverse_member_of, 4)); EXPECT_TRUE(base::ContainsKey(reverse_member_of, 5)); @@ -1253,7 +1287,8 @@ TEST(AXTreeTest, IntListReverseRelations) { initial_state.root_id = 1; initial_state.nodes.resize(3); initial_state.nodes[0].id = 1; - initial_state.nodes[0].AddIntListAttribute(AX_ATTR_LABELLEDBY_IDS, node_two); + initial_state.nodes[0].AddIntListAttribute( + ax::mojom::IntListAttribute::kLabelledbyIds, node_two); initial_state.nodes[0].child_ids.push_back(2); initial_state.nodes[0].child_ids.push_back(3); initial_state.nodes[1].id = 2; @@ -1262,20 +1297,23 @@ TEST(AXTreeTest, IntListReverseRelations) { AXTree tree(initial_state); auto reverse_labelled_by = - tree.GetReverseRelations(ui::AX_ATTR_LABELLEDBY_IDS, 2); + tree.GetReverseRelations(ax::mojom::IntListAttribute::kLabelledbyIds, 2); ASSERT_EQ(1U, reverse_labelled_by.size()); EXPECT_TRUE(base::ContainsKey(reverse_labelled_by, 1)); - reverse_labelled_by = tree.GetReverseRelations(ui::AX_ATTR_LABELLEDBY_IDS, 3); + reverse_labelled_by = + tree.GetReverseRelations(ax::mojom::IntListAttribute::kLabelledbyIds, 3); ASSERT_EQ(0U, reverse_labelled_by.size()); // Change existing attributes. AXTreeUpdate update = initial_state; update.nodes[0].intlist_attributes.clear(); - update.nodes[0].AddIntListAttribute(AX_ATTR_LABELLEDBY_IDS, nodes_two_three); + update.nodes[0].AddIntListAttribute( + ax::mojom::IntListAttribute::kLabelledbyIds, nodes_two_three); EXPECT_TRUE(tree.Unserialize(update)); - reverse_labelled_by = tree.GetReverseRelations(ui::AX_ATTR_LABELLEDBY_IDS, 3); + reverse_labelled_by = + tree.GetReverseRelations(ax::mojom::IntListAttribute::kLabelledbyIds, 3); ASSERT_EQ(1U, reverse_labelled_by.size()); EXPECT_TRUE(base::ContainsKey(reverse_labelled_by, 1)); } diff --git a/ui/accessibility/platform/aura_window_properties.cc b/ui/accessibility/platform/aura_window_properties.cc index 20775b9ff1ad45..e72b2d26e9adf3 100644 --- a/ui/accessibility/platform/aura_window_properties.cc +++ b/ui/accessibility/platform/aura_window_properties.cc @@ -6,7 +6,7 @@ #include "ui/base/class_property.h" -DEFINE_EXPORTED_UI_CLASS_PROPERTY_TYPE(AX_EXPORT, AXRole) +DEFINE_EXPORTED_UI_CLASS_PROPERTY_TYPE(AX_EXPORT, ax::mojom::Role) namespace ui { @@ -14,6 +14,8 @@ DEFINE_UI_CLASS_PROPERTY_KEY(AXTreeIDRegistry::AXTreeID, kChildAXTreeID, AXTreeIDRegistry::kNoAXTreeID); -DEFINE_UI_CLASS_PROPERTY_KEY(AXRole, kAXRoleOverride, ui::AX_ROLE_NONE); +DEFINE_UI_CLASS_PROPERTY_KEY(ax::mojom::Role, + kAXRoleOverride, + ax::mojom::Role::kNone); } // namespace ui diff --git a/ui/accessibility/platform/aura_window_properties.h b/ui/accessibility/platform/aura_window_properties.h index 5f25a8e5c187d1..c78850da22fc64 100644 --- a/ui/accessibility/platform/aura_window_properties.h +++ b/ui/accessibility/platform/aura_window_properties.h @@ -5,7 +5,7 @@ #ifndef UI_ACCESSIBILITY_PLATFORM_AURA_WINDOW_PROPERTIES_H_ #define UI_ACCESSIBILITY_PLATFORM_AURA_WINDOW_PROPERTIES_H_ -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_export.h" #include "ui/accessibility/ax_tree_id_registry.h" #include "ui/aura/window.h" @@ -15,7 +15,8 @@ namespace ui { AX_EXPORT extern const aura::WindowProperty* const kChildAXTreeID; -AX_EXPORT extern const aura::WindowProperty* const kAXRoleOverride; +AX_EXPORT extern const aura::WindowProperty* const + kAXRoleOverride; } // namespace ui diff --git a/ui/accessibility/platform/ax_platform_atk_hyperlink.cc b/ui/accessibility/platform/ax_platform_atk_hyperlink.cc index 3a66c1d7141f6e..c13f6dbdf5dc85 100644 --- a/ui/accessibility/platform/ax_platform_atk_hyperlink.cc +++ b/ui/accessibility/platform/ax_platform_atk_hyperlink.cc @@ -35,7 +35,8 @@ static gchar* ax_platform_atk_hyperlink_get_uri(AtkHyperlink* atk_hyperlink, if (index != 0) return nullptr; - return g_strdup(obj->GetStringAttribute(ui::AX_ATTR_URL).c_str()); + return g_strdup( + obj->GetStringAttribute(ax::mojom::StringAttribute::kUrl).c_str()); } static AtkObject* ax_platform_atk_hyperlink_get_object( @@ -155,7 +156,8 @@ static const gchar* ax_platform_atk_hyperlink_get_keybinding(AtkAction* action, if (!obj) return nullptr; - return obj->GetStringAttribute(ui::AX_ATTR_ACCESS_KEY).c_str(); + return obj->GetStringAttribute(ax::mojom::StringAttribute::kAccessKey) + .c_str(); } static const gchar* ax_platform_atk_hyperlink_get_name(AtkAction* atk_action, @@ -169,10 +171,11 @@ static const gchar* ax_platform_atk_hyperlink_get_name(AtkAction* atk_action, return nullptr; int action; - if (!obj->GetIntAttribute(ui::AX_ATTR_DEFAULT_ACTION_VERB, &action)) + if (!obj->GetIntAttribute(ax::mojom::IntAttribute::kDefaultActionVerb, + &action)) return nullptr; base::string16 action_verb = ui::ActionVerbToUnlocalizedString( - static_cast(action)); + static_cast(action)); ATK_AURALINUX_RETURN_STRING(base::UTF16ToUTF8(action_verb)); } @@ -188,10 +191,11 @@ static const gchar* ax_platform_atk_hyperlink_get_localized_name( return nullptr; int action; - if (!obj->GetIntAttribute(ui::AX_ATTR_DEFAULT_ACTION_VERB, &action)) + if (!obj->GetIntAttribute(ax::mojom::IntAttribute::kDefaultActionVerb, + &action)) return nullptr; base::string16 action_verb = ui::ActionVerbToLocalizedString( - static_cast(action)); + static_cast(action)); ATK_AURALINUX_RETURN_STRING(base::UTF16ToUTF8(action_verb)); } diff --git a/ui/accessibility/platform/ax_platform_node.h b/ui/accessibility/platform/ax_platform_node.h index f2e7e7a05567e9..f723bf064c466a 100644 --- a/ui/accessibility/platform/ax_platform_node.h +++ b/ui/accessibility/platform/ax_platform_node.h @@ -9,7 +9,7 @@ #include "base/lazy_instance.h" #include "base/observer_list.h" #include "build/build_config.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_export.h" #include "ui/accessibility/ax_mode_observer.h" #include "ui/gfx/native_widget_types.h" @@ -64,7 +64,7 @@ class AX_EXPORT AXPlatformNode { // Fire a platform-specific notification that an event has occurred on // this object. - virtual void NotifyAccessibilityEvent(AXEvent event_type) = 0; + virtual void NotifyAccessibilityEvent(ax::mojom::Event event_type) = 0; // Return this object's delegate. virtual AXPlatformNodeDelegate* GetDelegate() const = 0; diff --git a/ui/accessibility/platform/ax_platform_node_auralinux.cc b/ui/accessibility/platform/ax_platform_node_auralinux.cc index 3adf398945b6ed..775db1bcc4e214 100644 --- a/ui/accessibility/platform/ax_platform_node_auralinux.cc +++ b/ui/accessibility/platform/ax_platform_node_auralinux.cc @@ -80,12 +80,12 @@ static const gchar* ax_platform_node_auralinux_get_name(AtkObject* atk_object) { if (!obj) return nullptr; - ui::AXNameFrom name_from = obj->GetData().GetNameFrom(); - if (obj->GetStringAttribute(ui::AX_ATTR_NAME).empty() && - name_from != ui::AX_NAME_FROM_ATTRIBUTE_EXPLICITLY_EMPTY) + ax::mojom::NameFrom name_from = obj->GetData().GetNameFrom(); + if (obj->GetStringAttribute(ax::mojom::StringAttribute::kName).empty() && + name_from != ax::mojom::NameFrom::kAttributeExplicitlyEmpty) return nullptr; - return obj->GetStringAttribute(ui::AX_ATTR_NAME).c_str(); + return obj->GetStringAttribute(ax::mojom::StringAttribute::kName).c_str(); } static const gchar* ax_platform_node_auralinux_get_description( @@ -95,8 +95,8 @@ static const gchar* ax_platform_node_auralinux_get_description( if (!obj) return nullptr; - return obj->GetStringAttribute( - ui::AX_ATTR_DESCRIPTION).c_str(); + return obj->GetStringAttribute(ax::mojom::StringAttribute::kDescription) + .c_str(); } static gint ax_platform_node_auralinux_get_index_in_parent( @@ -374,7 +374,8 @@ static const gchar* ax_platform_node_auralinux_get_action_keybinding( if (!obj) return nullptr; - return obj->GetStringAttribute(ui::AX_ATTR_ACCESS_KEY).c_str(); + return obj->GetStringAttribute(ax::mojom::StringAttribute::kAccessKey) + .c_str(); } void ax_action_interface_base_init(AtkActionIface* iface) { @@ -459,7 +460,8 @@ static const gchar* ax_platform_node_auralinux_get_image_description( if (!obj) return nullptr; - return obj->GetStringAttribute(ui::AX_ATTR_DESCRIPTION).c_str(); + return obj->GetStringAttribute(ax::mojom::StringAttribute::kDescription) + .c_str(); } static void ax_platform_node_auralinux_get_image_size(AtkImage* atk_img, @@ -501,7 +503,8 @@ static void ax_platform_node_auralinux_get_current_value(AtkValue* atk_value, if (!obj) return; - obj->GetFloatAttributeInGValue(ui::AX_ATTR_VALUE_FOR_RANGE, value); + obj->GetFloatAttributeInGValue(ax::mojom::FloatAttribute::kValueForRange, + value); } static void ax_platform_node_auralinux_get_minimum_value(AtkValue* atk_value, @@ -514,7 +517,8 @@ static void ax_platform_node_auralinux_get_minimum_value(AtkValue* atk_value, if (!obj) return; - obj->GetFloatAttributeInGValue(ui::AX_ATTR_MIN_VALUE_FOR_RANGE, value); + obj->GetFloatAttributeInGValue(ax::mojom::FloatAttribute::kMinValueForRange, + value); } static void ax_platform_node_auralinux_get_maximum_value(AtkValue* atk_value, @@ -527,7 +531,8 @@ static void ax_platform_node_auralinux_get_maximum_value(AtkValue* atk_value, if (!obj) return; - obj->GetFloatAttributeInGValue(ui::AX_ATTR_MAX_VALUE_FOR_RANGE, value); + obj->GetFloatAttributeInGValue(ax::mojom::FloatAttribute::kMaxValueForRange, + value); } static void ax_platform_node_auralinux_get_minimum_increment( @@ -541,7 +546,8 @@ static void ax_platform_node_auralinux_get_minimum_increment( if (!obj) return; - obj->GetFloatAttributeInGValue(ui::AX_ATTR_STEP_VALUE_FOR_RANGE, value); + obj->GetFloatAttributeInGValue(ax::mojom::FloatAttribute::kStepValueForRange, + value); } static void ax_value_interface_base_init(AtkValueIface* iface) { @@ -810,13 +816,13 @@ void AXPlatformNodeAuraLinux::StaticInitialize() { AtkRole AXPlatformNodeAuraLinux::GetAtkRole() { switch (GetData().role) { - case ui::AX_ROLE_ALERT: + case ax::mojom::Role::kAlert: return ATK_ROLE_ALERT; - case ui::AX_ROLE_ALERT_DIALOG: + case ax::mojom::Role::kAlertDialog: return ATK_ROLE_ALERT; - case ui::AX_ROLE_APPLICATION: + case ax::mojom::Role::kApplication: return ATK_ROLE_APPLICATION; - case ui::AX_ROLE_AUDIO: + case ax::mojom::Role::kAudio: #if defined(ATK_CHECK_VERSION) #if ATK_CHECK_VERSION(2, 12, 0) return ATK_ROLE_AUDIO; @@ -826,53 +832,53 @@ AtkRole AXPlatformNodeAuraLinux::GetAtkRole() { #else return ATK_ROLE_SECTION; #endif - case ui::AX_ROLE_BUTTON: + case ax::mojom::Role::kButton: return ATK_ROLE_PUSH_BUTTON; - case ui::AX_ROLE_CANVAS: + case ax::mojom::Role::kCanvas: return ATK_ROLE_CANVAS; - case ui::AX_ROLE_CAPTION: + case ax::mojom::Role::kCaption: return ATK_ROLE_CAPTION; - case ui::AX_ROLE_CHECK_BOX: + case ax::mojom::Role::kCheckBox: return ATK_ROLE_CHECK_BOX; - case ui::AX_ROLE_COLOR_WELL: + case ax::mojom::Role::kColorWell: return ATK_ROLE_COLOR_CHOOSER; - case ui::AX_ROLE_COLUMN_HEADER: + case ax::mojom::Role::kColumnHeader: return ATK_ROLE_COLUMN_HEADER; - case ui::AX_ROLE_COMBO_BOX_GROUPING: + case ax::mojom::Role::kComboBoxGrouping: return ATK_ROLE_COMBO_BOX; - case ui::AX_ROLE_COMBO_BOX_MENU_BUTTON: + case ax::mojom::Role::kComboBoxMenuButton: return ATK_ROLE_COMBO_BOX; - case ui::AX_ROLE_DATE: + case ax::mojom::Role::kDate: return ATK_ROLE_DATE_EDITOR; - case ui::AX_ROLE_DATE_TIME: + case ax::mojom::Role::kDateTime: return ATK_ROLE_DATE_EDITOR; - case ui::AX_ROLE_DIALOG: + case ax::mojom::Role::kDialog: return ATK_ROLE_DIALOG; - case ui::AX_ROLE_DOCUMENT: + case ax::mojom::Role::kDocument: return ATK_ROLE_DOCUMENT_WEB; - case ui::AX_ROLE_FORM: + case ax::mojom::Role::kForm: return ATK_ROLE_FORM; - case ui::AX_ROLE_GENERIC_CONTAINER: + case ax::mojom::Role::kGenericContainer: return ATK_ROLE_PANEL; - case ui::AX_ROLE_GROUP: + case ax::mojom::Role::kGroup: return ATK_ROLE_PANEL; - case ui::AX_ROLE_IGNORED: + case ax::mojom::Role::kIgnored: return ATK_ROLE_REDUNDANT_OBJECT; - case ui::AX_ROLE_IMAGE: + case ax::mojom::Role::kImage: return ATK_ROLE_IMAGE; - case ui::AX_ROLE_IMAGE_MAP: + case ax::mojom::Role::kImageMap: return ATK_ROLE_IMAGE_MAP; - case ui::AX_ROLE_LABEL_TEXT: + case ax::mojom::Role::kLabelText: return ATK_ROLE_LABEL; - case ui::AX_ROLE_LINK: + case ax::mojom::Role::kLink: return ATK_ROLE_LINK; - case ui::AX_ROLE_LIST: + case ax::mojom::Role::kList: return ATK_ROLE_LIST; - case ui::AX_ROLE_LIST_BOX: + case ax::mojom::Role::kListBox: return ATK_ROLE_LIST_BOX; - case ui::AX_ROLE_LIST_ITEM: + case ax::mojom::Role::kListItem: return ATK_ROLE_LIST_ITEM; - case ui::AX_ROLE_MATH: + case ax::mojom::Role::kMath: #if defined(ATK_CHECK_VERSION) #if ATK_CHECK_VERSION(2, 12, 0) return ATK_ROLE_MATH; @@ -882,61 +888,61 @@ AtkRole AXPlatformNodeAuraLinux::GetAtkRole() { #else return ATK_ROLE_TEXT; #endif - case ui::AX_ROLE_MENU: + case ax::mojom::Role::kMenu: return ATK_ROLE_MENU; - case ui::AX_ROLE_MENU_BAR: + case ax::mojom::Role::kMenuBar: return ATK_ROLE_MENU_BAR; - case ui::AX_ROLE_MENU_ITEM: + case ax::mojom::Role::kMenuItem: return ATK_ROLE_MENU_ITEM; - case ui::AX_ROLE_MENU_ITEM_CHECK_BOX: + case ax::mojom::Role::kMenuItemCheckBox: return ATK_ROLE_CHECK_MENU_ITEM; - case ui::AX_ROLE_MENU_ITEM_RADIO: + case ax::mojom::Role::kMenuItemRadio: return ATK_ROLE_RADIO_MENU_ITEM; - case ui::AX_ROLE_METER: + case ax::mojom::Role::kMeter: return ATK_ROLE_PROGRESS_BAR; - case ui::AX_ROLE_PARAGRAPH: + case ax::mojom::Role::kParagraph: return ATK_ROLE_PARAGRAPH; - case ui::AX_ROLE_RADIO_BUTTON: + case ax::mojom::Role::kRadioButton: return ATK_ROLE_RADIO_BUTTON; - case ui::AX_ROLE_ROW_HEADER: + case ax::mojom::Role::kRowHeader: return ATK_ROLE_ROW_HEADER; - case ui::AX_ROLE_ROOT_WEB_AREA: + case ax::mojom::Role::kRootWebArea: return ATK_ROLE_DOCUMENT_WEB; - case ui::AX_ROLE_SCROLL_BAR: + case ax::mojom::Role::kScrollBar: return ATK_ROLE_SCROLL_BAR; - case ui::AX_ROLE_SLIDER: + case ax::mojom::Role::kSlider: return ATK_ROLE_SLIDER; - case ui::AX_ROLE_SPIN_BUTTON: + case ax::mojom::Role::kSpinButton: return ATK_ROLE_SPIN_BUTTON; - case ui::AX_ROLE_SPLITTER: + case ax::mojom::Role::kSplitter: return ATK_ROLE_SEPARATOR; - case ui::AX_ROLE_STATIC_TEXT: + case ax::mojom::Role::kStaticText: return ATK_ROLE_TEXT; - case ui::AX_ROLE_STATUS: + case ax::mojom::Role::kStatus: return ATK_ROLE_STATUSBAR; - case ui::AX_ROLE_TAB: + case ax::mojom::Role::kTab: return ATK_ROLE_PAGE_TAB; - case ui::AX_ROLE_TABLE: + case ax::mojom::Role::kTable: return ATK_ROLE_TABLE; - case ui::AX_ROLE_TAB_LIST: + case ax::mojom::Role::kTabList: return ATK_ROLE_PAGE_TAB_LIST; - case ui::AX_ROLE_TEXT_FIELD: + case ax::mojom::Role::kTextField: return ATK_ROLE_ENTRY; - case ui::AX_ROLE_TEXT_FIELD_WITH_COMBO_BOX: + case ax::mojom::Role::kTextFieldWithComboBox: return ATK_ROLE_COMBO_BOX; - case ui::AX_ROLE_TOGGLE_BUTTON: + case ax::mojom::Role::kToggleButton: return ATK_ROLE_TOGGLE_BUTTON; - case ui::AX_ROLE_TOOLBAR: + case ax::mojom::Role::kToolbar: return ATK_ROLE_TOOL_BAR; - case ui::AX_ROLE_TOOLTIP: + case ax::mojom::Role::kTooltip: return ATK_ROLE_TOOL_TIP; - case ui::AX_ROLE_TREE: + case ax::mojom::Role::kTree: return ATK_ROLE_TREE; - case ui::AX_ROLE_TREE_ITEM: + case ax::mojom::Role::kTreeItem: return ATK_ROLE_TREE_ITEM; - case ui::AX_ROLE_TREE_GRID: + case ax::mojom::Role::kTreeGrid: return ATK_ROLE_TREE_TABLE; - case ui::AX_ROLE_VIDEO: + case ax::mojom::Role::kVideo: #if defined(ATK_CHECK_VERSION) #if ATK_CHECK_VERSION(2, 12, 0) return ATK_ROLE_VIDEO; @@ -946,9 +952,9 @@ AtkRole AXPlatformNodeAuraLinux::GetAtkRole() { #else return ATK_ROLE_SECTION; #endif - case ui::AX_ROLE_WEB_AREA: + case ax::mojom::Role::kWebArea: return ATK_ROLE_DOCUMENT_WEB; - case ui::AX_ROLE_WINDOW: + case ax::mojom::Role::kWindow: return ATK_ROLE_WINDOW; default: return ATK_ROLE_UNKNOWN; @@ -957,34 +963,34 @@ AtkRole AXPlatformNodeAuraLinux::GetAtkRole() { void AXPlatformNodeAuraLinux::GetAtkState(AtkStateSet* atk_state_set) { AXNodeData data = GetData(); - if (data.HasState(ui::AX_STATE_DEFAULT)) + if (data.HasState(ax::mojom::State::kDefault)) atk_state_set_add_state(atk_state_set, ATK_STATE_DEFAULT); - if (data.HasState(ui::AX_STATE_EDITABLE)) + if (data.HasState(ax::mojom::State::kEditable)) atk_state_set_add_state(atk_state_set, ATK_STATE_EDITABLE); - if (data.HasState(ui::AX_STATE_EXPANDED)) + if (data.HasState(ax::mojom::State::kExpanded)) atk_state_set_add_state(atk_state_set, ATK_STATE_EXPANDED); - if (data.HasState(ui::AX_STATE_FOCUSABLE)) + if (data.HasState(ax::mojom::State::kFocusable)) atk_state_set_add_state(atk_state_set, ATK_STATE_FOCUSABLE); #if defined(ATK_CHECK_VERSION) #if ATK_CHECK_VERSION(2, 11, 2) - if (data.HasState(ui::AX_STATE_HASPOPUP)) + if (data.HasState(ax::mojom::State::kHaspopup)) atk_state_set_add_state(atk_state_set, ATK_STATE_HAS_POPUP); #endif #endif - if (data.HasState(ui::AX_STATE_SELECTED)) + if (data.HasState(ax::mojom::State::kSelected)) atk_state_set_add_state(atk_state_set, ATK_STATE_SELECTED); - if (data.HasState(ui::AX_STATE_SELECTABLE)) + if (data.HasState(ax::mojom::State::kSelectable)) atk_state_set_add_state(atk_state_set, ATK_STATE_SELECTABLE); // Checked state const auto checked_state = GetData().GetCheckedState(); switch (checked_state) { - case ui::AX_CHECKED_STATE_MIXED: + case ax::mojom::CheckedState::kMixed: atk_state_set_add_state(atk_state_set, ATK_STATE_INDETERMINATE); break; - case ui::AX_CHECKED_STATE_TRUE: + case ax::mojom::CheckedState::kTrue: atk_state_set_add_state(atk_state_set, - data.role == ui::AX_ROLE_TOGGLE_BUTTON + data.role == ax::mojom::Role::kToggleButton ? ATK_STATE_PRESSED : ATK_STATE_CHECKED); break; @@ -993,10 +999,10 @@ void AXPlatformNodeAuraLinux::GetAtkState(AtkStateSet* atk_state_set) { } switch (GetData().GetRestriction()) { - case ui::AX_RESTRICTION_NONE: + case ax::mojom::Restriction::kNone: atk_state_set_add_state(atk_state_set, ATK_STATE_ENABLED); break; - case ui::AX_RESTRICTION_READ_ONLY: + case ax::mojom::Restriction::kReadOnly: #if defined(ATK_CHECK_VERSION) #if ATK_CHECK_VERSION(2, 16, 0) atk_state_set_add_state(atk_state_set, ATK_STATE_READ_ONLY); @@ -1094,9 +1100,10 @@ void AXPlatformNodeAuraLinux::OnFocused() { true); } -void AXPlatformNodeAuraLinux::NotifyAccessibilityEvent(ui::AXEvent event_type) { +void AXPlatformNodeAuraLinux::NotifyAccessibilityEvent( + ax::mojom::Event event_type) { switch (event_type) { - case AX_EVENT_FOCUS: + case ax::mojom::Event::kFocus: OnFocused(); break; default: @@ -1173,23 +1180,23 @@ AXPlatformNodeAuraLinux::HitTestSync(gint x, gint y, AtkCoordType coord_type) { bool AXPlatformNodeAuraLinux::GrabFocus() { AXActionData action_data; - action_data.action = AX_ACTION_FOCUS; + action_data.action = ax::mojom::Action::kFocus; return delegate_->AccessibilityPerformAction(action_data); } bool AXPlatformNodeAuraLinux::DoDefaultAction() { AXActionData action_data; - action_data.action = AX_ACTION_DO_DEFAULT; + action_data.action = ax::mojom::Action::kDoDefault; return delegate_->AccessibilityPerformAction(action_data); } const gchar* AXPlatformNodeAuraLinux::GetDefaultActionName() { int action; - if (!GetIntAttribute(ui::AX_ATTR_DEFAULT_ACTION_VERB, &action)) + if (!GetIntAttribute(ax::mojom::IntAttribute::kDefaultActionVerb, &action)) return nullptr; base::string16 action_verb = ui::ActionVerbToUnlocalizedString( - static_cast(action)); + static_cast(action)); ATK_AURALINUX_RETURN_STRING(base::UTF16ToUTF8(action_verb)); } @@ -1251,8 +1258,9 @@ AtkHyperlink* AXPlatformNodeAuraLinux::GetAtkHyperlink() { // Misc helpers // -void AXPlatformNodeAuraLinux::GetFloatAttributeInGValue(AXFloatAttribute attr, - GValue* value) { +void AXPlatformNodeAuraLinux::GetFloatAttributeInGValue( + ax::mojom::FloatAttribute attr, + GValue* value) { float float_val; if (GetFloatAttribute(attr, &float_val)) { memset(value, 0, sizeof(*value)); diff --git a/ui/accessibility/platform/ax_platform_node_auralinux.h b/ui/accessibility/platform/ax_platform_node_auralinux.h index 6eaa14ab84f677..e0c31e920003ed 100644 --- a/ui/accessibility/platform/ax_platform_node_auralinux.h +++ b/ui/accessibility/platform/ax_platform_node_auralinux.h @@ -70,14 +70,14 @@ class AXPlatformNodeAuraLinux : public AXPlatformNodeBase { AtkHyperlink* GetAtkHyperlink(); // Misc helpers - void GetFloatAttributeInGValue(AXFloatAttribute attr, GValue* value); + void GetFloatAttributeInGValue(ax::mojom::FloatAttribute attr, GValue* value); // Event helpers void OnFocused(); // AXPlatformNode overrides. gfx::NativeViewAccessible GetNativeViewAccessible() override; - void NotifyAccessibilityEvent(ui::AXEvent event_type) override; + void NotifyAccessibilityEvent(ax::mojom::Event event_type) override; // AXPlatformNodeBase overrides. void Init(AXPlatformNodeDelegate* delegate) override; diff --git a/ui/accessibility/platform/ax_platform_node_auralinux_unittest.cc b/ui/accessibility/platform/ax_platform_node_auralinux_unittest.cc index e20de0f8cdda10..b9714a2b866f5e 100644 --- a/ui/accessibility/platform/ax_platform_node_auralinux_unittest.cc +++ b/ui/accessibility/platform/ax_platform_node_auralinux_unittest.cc @@ -87,7 +87,8 @@ TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkObjectName) { TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkObjectDescription) { AXNodeData root; root.id = 1; - root.AddStringAttribute(AX_ATTR_DESCRIPTION, "Description"); + root.AddStringAttribute(ax::mojom::StringAttribute::kDescription, + "Description"); Init(root); AtkObject* root_obj(GetRootAtkObject()); @@ -111,7 +112,7 @@ TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkObjectRole) { Init(root, child); AXNode* child_node = GetRootNode()->children()[0]; - child.role = AX_ROLE_ALERT; + child.role = ax::mojom::Role::kAlert; child_node->SetData(child); AtkObject* child_obj(AtkObjectFromNode(child_node)); ASSERT_TRUE(ATK_IS_OBJECT(child_obj)); @@ -119,7 +120,7 @@ TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkObjectRole) { EXPECT_EQ(ATK_ROLE_ALERT, atk_object_get_role(child_obj)); g_object_unref(child_obj); - child.role = AX_ROLE_BUTTON; + child.role = ax::mojom::Role::kButton; child_node->SetData(child); child_obj = AtkObjectFromNode(child_node); ASSERT_TRUE(ATK_IS_OBJECT(child_obj)); @@ -127,7 +128,7 @@ TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkObjectRole) { EXPECT_EQ(ATK_ROLE_PUSH_BUTTON, atk_object_get_role(child_obj)); g_object_unref(child_obj); - child.role = AX_ROLE_CANVAS; + child.role = ax::mojom::Role::kCanvas; child_node->SetData(child); child_obj = AtkObjectFromNode(child_node); ASSERT_TRUE(ATK_IS_OBJECT(child_obj)); @@ -139,8 +140,8 @@ TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkObjectRole) { TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkObjectState) { AXNodeData root; root.id = 1; - root.AddState(AX_STATE_DEFAULT); - root.AddState(AX_STATE_EXPANDED); + root.AddState(ax::mojom::State::kDefault); + root.AddState(ax::mojom::State::kExpanded); Init(root); @@ -165,11 +166,11 @@ TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkObjectChildAndParent) { root.child_ids.push_back(3); AXNodeData button; - button.role = AX_ROLE_BUTTON; + button.role = ax::mojom::Role::kButton; button.id = 2; AXNodeData checkbox; - checkbox.role = AX_ROLE_CHECK_BOX; + checkbox.role = ax::mojom::Role::kCheckBox; checkbox.id = 3; Init(root, button, checkbox); @@ -291,7 +292,7 @@ TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkComponentRefAtPoint) { TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkComponentsGetExtentsPositionSize) { AXNodeData root; root.id = 1; - root.role = AX_ROLE_WINDOW; + root.role = ax::mojom::Role::kWindow; root.location = gfx::RectF(10, 40, 800, 600); root.child_ids.push_back(2); @@ -380,8 +381,8 @@ TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkComponentsGetExtentsPositionSize) { TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkValueGetCurrentValue) { AXNodeData root; root.id = 1; - root.role = AX_ROLE_SLIDER; - root.AddFloatAttribute(AX_ATTR_VALUE_FOR_RANGE, 5.0); + root.role = ax::mojom::Role::kSlider; + root.AddFloatAttribute(ax::mojom::FloatAttribute::kValueForRange, 5.0); Init(root); AtkObject* root_obj(GetRootAtkObject()); @@ -402,8 +403,8 @@ TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkValueGetCurrentValue) { TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkValueGetMaximumValue) { AXNodeData root; root.id = 1; - root.role = AX_ROLE_SLIDER; - root.AddFloatAttribute(AX_ATTR_MAX_VALUE_FOR_RANGE, 5.0); + root.role = ax::mojom::Role::kSlider; + root.AddFloatAttribute(ax::mojom::FloatAttribute::kMaxValueForRange, 5.0); Init(root); AtkObject* root_obj(GetRootAtkObject()); @@ -424,8 +425,8 @@ TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkValueGetMaximumValue) { TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkValueGetMinimumValue) { AXNodeData root; root.id = 1; - root.role = AX_ROLE_SLIDER; - root.AddFloatAttribute(AX_ATTR_MIN_VALUE_FOR_RANGE, 5.0); + root.role = ax::mojom::Role::kSlider; + root.AddFloatAttribute(ax::mojom::FloatAttribute::kMinValueForRange, 5.0); Init(root); AtkObject* root_obj(GetRootAtkObject()); @@ -446,8 +447,8 @@ TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkValueGetMinimumValue) { TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkValueGetMinimumIncrement) { AXNodeData root; root.id = 1; - root.role = AX_ROLE_SLIDER; - root.AddFloatAttribute(AX_ATTR_STEP_VALUE_FOR_RANGE, 5.0); + root.role = ax::mojom::Role::kSlider; + root.AddFloatAttribute(ax::mojom::FloatAttribute::kStepValueForRange, 5.0); Init(root); AtkObject* root_obj(GetRootAtkObject()); @@ -472,8 +473,8 @@ TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkValueGetMinimumIncrement) { TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkHyperlink) { AXNodeData root; root.id = 1; - root.role = AX_ROLE_LINK; - root.AddStringAttribute(AX_ATTR_URL, "http://foo.com"); + root.role = ax::mojom::Role::kLink; + root.AddStringAttribute(ax::mojom::StringAttribute::kUrl, "http://foo.com"); Init(root); AtkObject* root_obj(GetRootAtkObject()); diff --git a/ui/accessibility/platform/ax_platform_node_base.cc b/ui/accessibility/platform/ax_platform_node_base.cc index 97afb682632c3b..b0889abf5f4bbd 100644 --- a/ui/accessibility/platform/ax_platform_node_base.cc +++ b/ui/accessibility/platform/ax_platform_node_base.cc @@ -116,107 +116,116 @@ bool AXPlatformNodeBase::IsDescendant(AXPlatformNodeBase* node) { return IsDescendant(parent); } -bool AXPlatformNodeBase::HasBoolAttribute(AXBoolAttribute attribute) const { +bool AXPlatformNodeBase::HasBoolAttribute( + ax::mojom::BoolAttribute attribute) const { if (!delegate_) return false; return GetData().HasBoolAttribute(attribute); } -bool AXPlatformNodeBase::GetBoolAttribute(AXBoolAttribute attribute) const { +bool AXPlatformNodeBase::GetBoolAttribute( + ax::mojom::BoolAttribute attribute) const { if (!delegate_) return false; return GetData().GetBoolAttribute(attribute); } -bool AXPlatformNodeBase::GetBoolAttribute(AXBoolAttribute attribute, +bool AXPlatformNodeBase::GetBoolAttribute(ax::mojom::BoolAttribute attribute, bool* value) const { if (!delegate_) return false; return GetData().GetBoolAttribute(attribute, value); } -bool AXPlatformNodeBase::HasFloatAttribute(AXFloatAttribute attribute) const { +bool AXPlatformNodeBase::HasFloatAttribute( + ax::mojom::FloatAttribute attribute) const { if (!delegate_) return false; return GetData().HasFloatAttribute(attribute); } -float AXPlatformNodeBase::GetFloatAttribute(AXFloatAttribute attribute) const { +float AXPlatformNodeBase::GetFloatAttribute( + ax::mojom::FloatAttribute attribute) const { if (!delegate_) return false; return GetData().GetFloatAttribute(attribute); } -bool AXPlatformNodeBase::GetFloatAttribute(AXFloatAttribute attribute, +bool AXPlatformNodeBase::GetFloatAttribute(ax::mojom::FloatAttribute attribute, float* value) const { if (!delegate_) return false; return GetData().GetFloatAttribute(attribute, value); } -bool AXPlatformNodeBase::HasIntAttribute(AXIntAttribute attribute) const { +bool AXPlatformNodeBase::HasIntAttribute( + ax::mojom::IntAttribute attribute) const { if (!delegate_) return false; return GetData().HasIntAttribute(attribute); } -int AXPlatformNodeBase::GetIntAttribute(AXIntAttribute attribute) const { +int AXPlatformNodeBase::GetIntAttribute( + ax::mojom::IntAttribute attribute) const { if (!delegate_) return false; return GetData().GetIntAttribute(attribute); } -bool AXPlatformNodeBase::GetIntAttribute(AXIntAttribute attribute, +bool AXPlatformNodeBase::GetIntAttribute(ax::mojom::IntAttribute attribute, int* value) const { if (!delegate_) return false; return GetData().GetIntAttribute(attribute, value); } -bool AXPlatformNodeBase::HasStringAttribute(AXStringAttribute attribute) const { +bool AXPlatformNodeBase::HasStringAttribute( + ax::mojom::StringAttribute attribute) const { if (!delegate_) return false; return GetData().HasStringAttribute(attribute); } const std::string& AXPlatformNodeBase::GetStringAttribute( - AXStringAttribute attribute) const { + ax::mojom::StringAttribute attribute) const { CR_DEFINE_STATIC_LOCAL(std::string, empty_data, ()); if (!delegate_) return empty_data; return GetData().GetStringAttribute(attribute); } -bool AXPlatformNodeBase::GetStringAttribute(AXStringAttribute attribute, - std::string* value) const { +bool AXPlatformNodeBase::GetStringAttribute( + ax::mojom::StringAttribute attribute, + std::string* value) const { if (!delegate_) return false; return GetData().GetStringAttribute(attribute, value); } base::string16 AXPlatformNodeBase::GetString16Attribute( - AXStringAttribute attribute) const { + ax::mojom::StringAttribute attribute) const { if (!delegate_) return base::string16(); return GetData().GetString16Attribute(attribute); } -bool AXPlatformNodeBase::GetString16Attribute(AXStringAttribute attribute, - base::string16* value) const { +bool AXPlatformNodeBase::GetString16Attribute( + ax::mojom::StringAttribute attribute, + base::string16* value) const { if (!delegate_) return false; return GetData().GetString16Attribute(attribute, value); } bool AXPlatformNodeBase::HasIntListAttribute( - AXIntListAttribute attribute) const { + ax::mojom::IntListAttribute attribute) const { if (!delegate_) return false; return GetData().HasIntListAttribute(attribute); } const std::vector& AXPlatformNodeBase::GetIntListAttribute( - AXIntListAttribute attribute) const { + ax::mojom::IntListAttribute attribute) const { CR_DEFINE_STATIC_LOCAL(std::vector, empty_data, ()); if (!delegate_) return empty_data; @@ -224,7 +233,7 @@ const std::vector& AXPlatformNodeBase::GetIntListAttribute( } bool AXPlatformNodeBase::GetIntListAttribute( - AXIntListAttribute attribute, + ax::mojom::IntListAttribute attribute, std::vector* value) const { if (!delegate_) return false; @@ -246,7 +255,7 @@ AXPlatformNodeBase* AXPlatformNodeBase::FromNativeViewAccessible( bool AXPlatformNodeBase::SetTextSelection(int start_offset, int end_offset) { AXActionData action_data; - action_data.action = AX_ACTION_SET_SELECTION; + action_data.action = ax::mojom::Action::kSetSelection; action_data.anchor_node_id = action_data.focus_node_id = GetData().id; action_data.anchor_offset = start_offset; action_data.focus_offset = end_offset; @@ -257,30 +266,30 @@ bool AXPlatformNodeBase::SetTextSelection(int start_offset, int end_offset) { } bool AXPlatformNodeBase::IsTextOnlyObject() const { - return GetData().role == AX_ROLE_STATIC_TEXT || - GetData().role == AX_ROLE_LINE_BREAK || - GetData().role == AX_ROLE_INLINE_TEXT_BOX; + return GetData().role == ax::mojom::Role::kStaticText || + GetData().role == ax::mojom::Role::kLineBreak || + GetData().role == ax::mojom::Role::kInlineTextBox; } bool AXPlatformNodeBase::IsPlainTextField() const { // We need to check both the role and editable state, because some ARIA text // fields may in fact not be editable, whilst some editable fields might not // have the role. - return !GetData().HasState(AX_STATE_RICHLY_EDITABLE) && - (GetData().role == AX_ROLE_TEXT_FIELD || - GetData().role == AX_ROLE_TEXT_FIELD_WITH_COMBO_BOX || - GetData().role == AX_ROLE_SEARCH_BOX || - GetBoolAttribute(AX_ATTR_EDITABLE_ROOT)); + return !GetData().HasState(ax::mojom::State::kRichlyEditable) && + (GetData().role == ax::mojom::Role::kTextField || + GetData().role == ax::mojom::Role::kTextFieldWithComboBox || + GetData().role == ax::mojom::Role::kSearchBox || + GetBoolAttribute(ax::mojom::BoolAttribute::kEditableRoot)); } bool AXPlatformNodeBase::IsRichTextField() const { - return GetBoolAttribute(AX_ATTR_EDITABLE_ROOT) && - GetData().HasState(AX_STATE_RICHLY_EDITABLE); + return GetBoolAttribute(ax::mojom::BoolAttribute::kEditableRoot) && + GetData().HasState(ax::mojom::State::kRichlyEditable); } base::string16 AXPlatformNodeBase::GetInnerText() { if (IsTextOnlyObject()) - return GetString16Attribute(AX_ATTR_NAME); + return GetString16Attribute(ax::mojom::StringAttribute::kName); base::string16 text; for (int i = 0; i < GetChildCount(); ++i) { @@ -296,14 +305,14 @@ base::string16 AXPlatformNodeBase::GetInnerText() { bool AXPlatformNodeBase::IsRangeValueSupported() const { switch (GetData().role) { - case AX_ROLE_METER: - case AX_ROLE_PROGRESS_INDICATOR: - case AX_ROLE_SLIDER: - case AX_ROLE_SPIN_BUTTON: - case AX_ROLE_SCROLL_BAR: + case ax::mojom::Role::kMeter: + case ax::mojom::Role::kProgressIndicator: + case ax::mojom::Role::kSlider: + case ax::mojom::Role::kSpinButton: + case ax::mojom::Role::kScrollBar: return true; - case AX_ROLE_SPLITTER: - return GetData().HasState(AX_STATE_FOCUSABLE); + case ax::mojom::Role::kSplitter: + return GetData().HasState(ax::mojom::State::kFocusable); default: return false; } @@ -311,9 +320,11 @@ bool AXPlatformNodeBase::IsRangeValueSupported() const { base::string16 AXPlatformNodeBase::GetRangeValueText() { float fval; - base::string16 value = GetString16Attribute(AX_ATTR_VALUE); + base::string16 value = + GetString16Attribute(ax::mojom::StringAttribute::kValue); - if (value.empty() && GetFloatAttribute(AX_ATTR_VALUE_FOR_RANGE, &fval)) { + if (value.empty() && + GetFloatAttribute(ax::mojom::FloatAttribute::kValueForRange, &fval)) { value = base::NumberToString16(fval); } return value; @@ -343,7 +354,7 @@ AXPlatformNodeBase* AXPlatformNodeBase::GetTableCell(int index) const { if (!table) return nullptr; const std::vector& unique_cell_ids = - table->GetIntListAttribute(AX_ATTR_UNIQUE_CELL_IDS); + table->GetIntListAttribute(ax::mojom::IntListAttribute::kUniqueCellIds); if (index < 0 || index >= static_cast(unique_cell_ids.size())) return nullptr; @@ -369,7 +380,7 @@ AXPlatformNodeBase* AXPlatformNodeBase::GetTableCell(int row, // In contrast to unique cell IDs, these are duplicated whenever a cell spans // multiple columns or rows. const std::vector& cell_ids = - table->GetIntListAttribute(AX_ATTR_CELL_IDS); + table->GetIntListAttribute(ax::mojom::IntListAttribute::kCellIds); DCHECK_EQ(GetTableRowCount() * GetTableColumnCount(), static_cast(cell_ids.size())); int position = row * GetTableColumnCount() + column; @@ -389,7 +400,7 @@ int AXPlatformNodeBase::GetTableCellIndex() const { return -1; const std::vector& unique_cell_ids = - table->GetIntListAttribute(AX_ATTR_UNIQUE_CELL_IDS); + table->GetIntListAttribute(ax::mojom::IntListAttribute::kUniqueCellIds); auto iter = std::find(unique_cell_ids.begin(), unique_cell_ids.end(), GetData().id); if (iter == unique_cell_ids.end()) @@ -399,7 +410,7 @@ int AXPlatformNodeBase::GetTableCellIndex() const { } int AXPlatformNodeBase::GetTableColumn() const { - return GetIntAttribute(AX_ATTR_TABLE_CELL_COLUMN_INDEX); + return GetIntAttribute(ax::mojom::IntAttribute::kTableCellColumnIndex); } int AXPlatformNodeBase::GetTableColumnCount() const { @@ -407,7 +418,7 @@ int AXPlatformNodeBase::GetTableColumnCount() const { if (!table) return 0; - return table->GetIntAttribute(AX_ATTR_TABLE_COLUMN_COUNT); + return table->GetIntAttribute(ax::mojom::IntAttribute::kTableColumnCount); } int AXPlatformNodeBase::GetTableColumnSpan() const { @@ -415,13 +426,14 @@ int AXPlatformNodeBase::GetTableColumnSpan() const { return 0; int column_span; - if (GetIntAttribute(AX_ATTR_TABLE_CELL_COLUMN_SPAN, &column_span)) + if (GetIntAttribute(ax::mojom::IntAttribute::kTableCellColumnSpan, + &column_span)) return column_span; return 1; } int AXPlatformNodeBase::GetTableRow() const { - return GetIntAttribute(AX_ATTR_TABLE_CELL_ROW_INDEX); + return GetIntAttribute(ax::mojom::IntAttribute::kTableCellRowIndex); } int AXPlatformNodeBase::GetTableRowCount() const { @@ -429,7 +441,7 @@ int AXPlatformNodeBase::GetTableRowCount() const { if (!table) return 0; - return table->GetIntAttribute(AX_ATTR_TABLE_ROW_COUNT); + return table->GetIntAttribute(ax::mojom::IntAttribute::kTableRowCount); } int AXPlatformNodeBase::GetTableRowSpan() const { @@ -437,14 +449,15 @@ int AXPlatformNodeBase::GetTableRowSpan() const { return 0; int row_span; - if (GetIntAttribute(AX_ATTR_TABLE_CELL_ROW_SPAN, &row_span)) + if (GetIntAttribute(ax::mojom::IntAttribute::kTableCellRowSpan, &row_span)) return row_span; return 1; } bool AXPlatformNodeBase::HasCaret() { - if (IsPlainTextField() && HasIntAttribute(ui::AX_ATTR_TEXT_SEL_START) && - HasIntAttribute(ui::AX_ATTR_TEXT_SEL_END)) { + if (IsPlainTextField() && + HasIntAttribute(ax::mojom::IntAttribute::kTextSelStart) && + HasIntAttribute(ax::mojom::IntAttribute::kTextSelEnd)) { return true; } @@ -489,12 +502,12 @@ bool AXPlatformNodeBase::IsLeaf() { // (Note that whilst ARIA buttons can have only presentational children, HTML5 // buttons are allowed to have content.) switch (GetData().role) { - case ui::AX_ROLE_IMAGE: - case ui::AX_ROLE_METER: - case ui::AX_ROLE_SCROLL_BAR: - case ui::AX_ROLE_SLIDER: - case ui::AX_ROLE_SPLITTER: - case ui::AX_ROLE_PROGRESS_INDICATOR: + case ax::mojom::Role::kImage: + case ax::mojom::Role::kMeter: + case ax::mojom::Role::kScrollBar: + case ax::mojom::Role::kSlider: + case ax::mojom::Role::kSplitter: + case ax::mojom::Role::kProgressIndicator: return true; default: return false; @@ -525,7 +538,8 @@ base::string16 AXPlatformNodeBase::GetValue() { // On Windows, the value of a document should be its URL. return base::UTF8ToUTF16(delegate_->GetTreeData().url); } - base::string16 value = GetString16Attribute(ui::AX_ATTR_VALUE); + base::string16 value = + GetString16Attribute(ax::mojom::StringAttribute::kValue); // Some screen readers like Jaws and VoiceOver require a // value to be set in text fields with rich content, even though the same diff --git a/ui/accessibility/platform/ax_platform_node_base.h b/ui/accessibility/platform/ax_platform_node_base.h index 7a3a93f7cc5607..fd94d13acb5053 100644 --- a/ui/accessibility/platform/ax_platform_node_base.h +++ b/ui/accessibility/platform/ax_platform_node_base.h @@ -6,7 +6,7 @@ #define UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_BASE_H_ #include "base/macros.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/platform/ax_platform_node.h" #include "ui/gfx/geometry/rect.h" #include "ui/gfx/native_widget_types.h" @@ -40,31 +40,33 @@ class AX_EXPORT AXPlatformNodeBase : public AXPlatformNode { AXPlatformNodeBase* GetNextSibling(); bool IsDescendant(AXPlatformNodeBase* descendant); - bool HasBoolAttribute(AXBoolAttribute attr) const; - bool GetBoolAttribute(AXBoolAttribute attr) const; - bool GetBoolAttribute(AXBoolAttribute attr, bool* value) const; + bool HasBoolAttribute(ax::mojom::BoolAttribute attr) const; + bool GetBoolAttribute(ax::mojom::BoolAttribute attr) const; + bool GetBoolAttribute(ax::mojom::BoolAttribute attr, bool* value) const; - bool HasFloatAttribute(AXFloatAttribute attr) const; - float GetFloatAttribute(AXFloatAttribute attr) const; - bool GetFloatAttribute(AXFloatAttribute attr, float* value) const; + bool HasFloatAttribute(ax::mojom::FloatAttribute attr) const; + float GetFloatAttribute(ax::mojom::FloatAttribute attr) const; + bool GetFloatAttribute(ax::mojom::FloatAttribute attr, float* value) const; - bool HasIntAttribute(AXIntAttribute attribute) const; - int GetIntAttribute(AXIntAttribute attribute) const; - bool GetIntAttribute(AXIntAttribute attribute, int* value) const; + bool HasIntAttribute(ax::mojom::IntAttribute attribute) const; + int GetIntAttribute(ax::mojom::IntAttribute attribute) const; + bool GetIntAttribute(ax::mojom::IntAttribute attribute, int* value) const; - bool HasStringAttribute(AXStringAttribute attribute) const; - const std::string& GetStringAttribute(AXStringAttribute attribute) const; - bool GetStringAttribute(AXStringAttribute attribute, + bool HasStringAttribute(ax::mojom::StringAttribute attribute) const; + const std::string& GetStringAttribute( + ax::mojom::StringAttribute attribute) const; + bool GetStringAttribute(ax::mojom::StringAttribute attribute, std::string* value) const; - bool GetString16Attribute(AXStringAttribute attribute, + bool GetString16Attribute(ax::mojom::StringAttribute attribute, base::string16* value) const; - base::string16 GetString16Attribute(AXStringAttribute attribute) const; + base::string16 GetString16Attribute( + ax::mojom::StringAttribute attribute) const; - bool HasIntListAttribute(AXIntListAttribute attribute) const; + bool HasIntListAttribute(ax::mojom::IntListAttribute attribute) const; const std::vector& GetIntListAttribute( - AXIntListAttribute attribute) const; + ax::mojom::IntListAttribute attribute) const; - bool GetIntListAttribute(AXIntListAttribute attribute, + bool GetIntListAttribute(ax::mojom::IntListAttribute attribute, std::vector* value) const; // Returns the table or ARIA grid if inside one. diff --git a/ui/accessibility/platform/ax_platform_node_delegate.h b/ui/accessibility/platform/ax_platform_node_delegate.h index 704bc5e9a4c5c6..ae69d56b8a5750 100644 --- a/ui/accessibility/platform/ax_platform_node_delegate.h +++ b/ui/accessibility/platform/ax_platform_node_delegate.h @@ -7,7 +7,7 @@ #include -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_export.h" #include "ui/accessibility/platform/ax_unique_id.h" #include "ui/gfx/geometry/vector2d.h" @@ -87,15 +87,16 @@ class AX_EXPORT AXPlatformNodeDelegate { // Given a node ID attribute (one where IsNodeIdIntAttribute is true), // and a destination node ID, return a set of all source node IDs that // have that relationship attribute between them and the destination. - virtual std::set GetReverseRelations(AXIntAttribute attr, + virtual std::set GetReverseRelations(ax::mojom::IntAttribute attr, int32_t dst_id) = 0; // Given a node ID list attribute (one where // IsNodeIdIntListAttribute is true), and a destination node ID, // return a set of all source node IDs that have that relationship // attribute between them and the destination. - virtual std::set GetReverseRelations(AXIntListAttribute attr, - int32_t dst_id) = 0; + virtual std::set GetReverseRelations( + ax::mojom::IntListAttribute attr, + int32_t dst_id) = 0; virtual const AXUniqueId& GetUniqueId() const = 0; @@ -111,7 +112,7 @@ class AX_EXPORT AXPlatformNodeDelegate { // Actions. // - // Perform an accessibility action, switching on the AXAction + // Perform an accessibility action, switching on the ax::mojom::Action // provided in |data|. virtual bool AccessibilityPerformAction(const AXActionData& data) = 0; diff --git a/ui/accessibility/platform/ax_platform_node_mac.h b/ui/accessibility/platform/ax_platform_node_mac.h index 36ee00335e21ea..0ae797818b043b 100644 --- a/ui/accessibility/platform/ax_platform_node_mac.h +++ b/ui/accessibility/platform/ax_platform_node_mac.h @@ -22,7 +22,7 @@ class AXPlatformNodeMac : public AXPlatformNodeBase { // AXPlatformNode. gfx::NativeViewAccessible GetNativeViewAccessible() override; - void NotifyAccessibilityEvent(ui::AXEvent event_type) override; + void NotifyAccessibilityEvent(ax::mojom::Event event_type) override; // AXPlatformNodeBase. void Destroy() override; @@ -38,7 +38,7 @@ class AXPlatformNodeMac : public AXPlatformNodeBase { // Convenience function to determine whether an internal object role should // expose its accessible name in AXValue (as opposed to AXTitle/AXDescription). -AX_EXPORT bool IsNameExposedInAXValueForRole(AXRole role); +AX_EXPORT bool IsNameExposedInAXValueForRole(ax::mojom::Role role); } // namespace ui @@ -47,13 +47,13 @@ AX_EXPORT // Maps AX roles to native roles. Returns NSAccessibilityUnknownRole if not // found. -+ (NSString*)nativeRoleFromAXRole:(ui::AXRole)role; ++ (NSString*)nativeRoleFromAXRole:(ax::mojom::Role)role; // Maps AX roles to native subroles. Returns nil if not found. -+ (NSString*)nativeSubroleFromAXRole:(ui::AXRole)role; ++ (NSString*)nativeSubroleFromAXRole:(ax::mojom::Role)role; // Maps AX events to native notifications. Returns nil if not found. -+ (NSString*)nativeNotificationFromAXEvent:(ui::AXEvent)event; ++ (NSString*)nativeNotificationFromAXEvent:(ax::mojom::Event)event; - (instancetype)initWithNode:(ui::AXPlatformNodeBase*)node; - (void)detach; diff --git a/ui/accessibility/platform/ax_platform_node_mac.mm b/ui/accessibility/platform/ax_platform_node_mac.mm index 331874fe8e74bf..45c9e5e725b4d3 100644 --- a/ui/accessibility/platform/ax_platform_node_mac.mm +++ b/ui/accessibility/platform/ax_platform_node_mac.mm @@ -20,133 +20,134 @@ namespace { -using RoleMap = std::map; -using EventMap = std::map; -using ActionList = std::vector>; +using RoleMap = std::map; +using EventMap = std::map; +using ActionList = std::vector>; RoleMap BuildRoleMap() { const RoleMap::value_type roles[] = { - {ui::AX_ROLE_ABBR, NSAccessibilityGroupRole}, - {ui::AX_ROLE_ALERT, NSAccessibilityGroupRole}, - {ui::AX_ROLE_ALERT_DIALOG, NSAccessibilityGroupRole}, - {ui::AX_ROLE_ANCHOR, NSAccessibilityGroupRole}, - {ui::AX_ROLE_ANNOTATION, NSAccessibilityUnknownRole}, - {ui::AX_ROLE_APPLICATION, NSAccessibilityGroupRole}, - {ui::AX_ROLE_ARTICLE, NSAccessibilityGroupRole}, - {ui::AX_ROLE_AUDIO, NSAccessibilityGroupRole}, - {ui::AX_ROLE_BANNER, NSAccessibilityGroupRole}, - {ui::AX_ROLE_BLOCKQUOTE, NSAccessibilityGroupRole}, - {ui::AX_ROLE_BUTTON, NSAccessibilityButtonRole}, - {ui::AX_ROLE_CANVAS, NSAccessibilityImageRole}, - {ui::AX_ROLE_CAPTION, NSAccessibilityGroupRole}, - {ui::AX_ROLE_CELL, @"AXCell"}, - {ui::AX_ROLE_CHECK_BOX, NSAccessibilityCheckBoxRole}, - {ui::AX_ROLE_COLOR_WELL, NSAccessibilityColorWellRole}, - {ui::AX_ROLE_COLUMN, NSAccessibilityColumnRole}, - {ui::AX_ROLE_COLUMN_HEADER, @"AXCell"}, - {ui::AX_ROLE_COMBO_BOX_GROUPING, NSAccessibilityGroupRole}, - {ui::AX_ROLE_COMBO_BOX_MENU_BUTTON, NSAccessibilityButtonRole}, - {ui::AX_ROLE_COMPLEMENTARY, NSAccessibilityGroupRole}, - {ui::AX_ROLE_CONTENT_INFO, NSAccessibilityGroupRole}, - {ui::AX_ROLE_DATE, @"AXDateField"}, - {ui::AX_ROLE_DATE_TIME, @"AXDateField"}, - {ui::AX_ROLE_DEFINITION, NSAccessibilityGroupRole}, - {ui::AX_ROLE_DESCRIPTION_LIST_DETAIL, NSAccessibilityGroupRole}, - {ui::AX_ROLE_DESCRIPTION_LIST, NSAccessibilityListRole}, - {ui::AX_ROLE_DESCRIPTION_LIST_TERM, NSAccessibilityGroupRole}, - {ui::AX_ROLE_DIALOG, NSAccessibilityGroupRole}, - {ui::AX_ROLE_DETAILS, NSAccessibilityGroupRole}, - {ui::AX_ROLE_DIRECTORY, NSAccessibilityListRole}, + {ax::mojom::Role::kAbbr, NSAccessibilityGroupRole}, + {ax::mojom::Role::kAlert, NSAccessibilityGroupRole}, + {ax::mojom::Role::kAlertDialog, NSAccessibilityGroupRole}, + {ax::mojom::Role::kAnchor, NSAccessibilityGroupRole}, + {ax::mojom::Role::kAnnotation, NSAccessibilityUnknownRole}, + {ax::mojom::Role::kApplication, NSAccessibilityGroupRole}, + {ax::mojom::Role::kArticle, NSAccessibilityGroupRole}, + {ax::mojom::Role::kAudio, NSAccessibilityGroupRole}, + {ax::mojom::Role::kBanner, NSAccessibilityGroupRole}, + {ax::mojom::Role::kBlockquote, NSAccessibilityGroupRole}, + {ax::mojom::Role::kButton, NSAccessibilityButtonRole}, + {ax::mojom::Role::kCanvas, NSAccessibilityImageRole}, + {ax::mojom::Role::kCaption, NSAccessibilityGroupRole}, + {ax::mojom::Role::kCell, @"AXCell"}, + {ax::mojom::Role::kCheckBox, NSAccessibilityCheckBoxRole}, + {ax::mojom::Role::kColorWell, NSAccessibilityColorWellRole}, + {ax::mojom::Role::kColumn, NSAccessibilityColumnRole}, + {ax::mojom::Role::kColumnHeader, @"AXCell"}, + {ax::mojom::Role::kComboBoxGrouping, NSAccessibilityGroupRole}, + {ax::mojom::Role::kComboBoxMenuButton, NSAccessibilityButtonRole}, + {ax::mojom::Role::kComplementary, NSAccessibilityGroupRole}, + {ax::mojom::Role::kContentInfo, NSAccessibilityGroupRole}, + {ax::mojom::Role::kDate, @"AXDateField"}, + {ax::mojom::Role::kDateTime, @"AXDateField"}, + {ax::mojom::Role::kDefinition, NSAccessibilityGroupRole}, + {ax::mojom::Role::kDescriptionListDetail, NSAccessibilityGroupRole}, + {ax::mojom::Role::kDescriptionList, NSAccessibilityListRole}, + {ax::mojom::Role::kDescriptionListTerm, NSAccessibilityGroupRole}, + {ax::mojom::Role::kDialog, NSAccessibilityGroupRole}, + {ax::mojom::Role::kDetails, NSAccessibilityGroupRole}, + {ax::mojom::Role::kDirectory, NSAccessibilityListRole}, // If Mac supports AXExpandedChanged event with // NSAccessibilityDisclosureTriangleRole, We should update - // AX_ROLE_DISCLOSURE_TRIANGLE mapping to + // ax::mojom::Role::kDisclosureTriangle mapping to // NSAccessibilityDisclosureTriangleRole. http://crbug.com/558324 - {ui::AX_ROLE_DISCLOSURE_TRIANGLE, NSAccessibilityButtonRole}, - {ui::AX_ROLE_DOCUMENT, NSAccessibilityGroupRole}, - {ui::AX_ROLE_EMBEDDED_OBJECT, NSAccessibilityGroupRole}, - {ui::AX_ROLE_FIGCAPTION, NSAccessibilityGroupRole}, - {ui::AX_ROLE_FIGURE, NSAccessibilityGroupRole}, - {ui::AX_ROLE_FOOTER, NSAccessibilityGroupRole}, - {ui::AX_ROLE_FORM, NSAccessibilityGroupRole}, - {ui::AX_ROLE_GENERIC_CONTAINER, NSAccessibilityGroupRole}, + {ax::mojom::Role::kDisclosureTriangle, NSAccessibilityButtonRole}, + {ax::mojom::Role::kDocument, NSAccessibilityGroupRole}, + {ax::mojom::Role::kEmbeddedObject, NSAccessibilityGroupRole}, + {ax::mojom::Role::kFigcaption, NSAccessibilityGroupRole}, + {ax::mojom::Role::kFigure, NSAccessibilityGroupRole}, + {ax::mojom::Role::kFooter, NSAccessibilityGroupRole}, + {ax::mojom::Role::kForm, NSAccessibilityGroupRole}, + {ax::mojom::Role::kGenericContainer, NSAccessibilityGroupRole}, // Should be NSAccessibilityGridRole but VoiceOver treating it like // a list as of 10.12.6, so following WebKit and using table role: - {ui::AX_ROLE_GRID, NSAccessibilityTableRole}, // crbug.com/753925 - {ui::AX_ROLE_GROUP, NSAccessibilityGroupRole}, - {ui::AX_ROLE_HEADING, @"AXHeading"}, - {ui::AX_ROLE_IFRAME, NSAccessibilityGroupRole}, - {ui::AX_ROLE_IFRAME_PRESENTATIONAL, NSAccessibilityGroupRole}, - {ui::AX_ROLE_IGNORED, NSAccessibilityUnknownRole}, - {ui::AX_ROLE_IMAGE, NSAccessibilityImageRole}, - {ui::AX_ROLE_IMAGE_MAP, NSAccessibilityGroupRole}, - {ui::AX_ROLE_INPUT_TIME, @"AXTimeField"}, - {ui::AX_ROLE_LABEL_TEXT, NSAccessibilityGroupRole}, - {ui::AX_ROLE_LEGEND, NSAccessibilityGroupRole}, - {ui::AX_ROLE_LINE_BREAK, NSAccessibilityGroupRole}, - {ui::AX_ROLE_LINK, NSAccessibilityLinkRole}, - {ui::AX_ROLE_LIST, NSAccessibilityListRole}, - {ui::AX_ROLE_LIST_BOX, NSAccessibilityListRole}, - {ui::AX_ROLE_LIST_BOX_OPTION, NSAccessibilityStaticTextRole}, - {ui::AX_ROLE_LIST_ITEM, NSAccessibilityGroupRole}, - {ui::AX_ROLE_LIST_MARKER, @"AXListMarker"}, - {ui::AX_ROLE_LOG, NSAccessibilityGroupRole}, - {ui::AX_ROLE_MAIN, NSAccessibilityGroupRole}, - {ui::AX_ROLE_MARK, NSAccessibilityGroupRole}, - {ui::AX_ROLE_MARQUEE, NSAccessibilityGroupRole}, - {ui::AX_ROLE_MATH, NSAccessibilityGroupRole}, - {ui::AX_ROLE_MENU, NSAccessibilityMenuRole}, - {ui::AX_ROLE_MENU_BAR, NSAccessibilityMenuBarRole}, - {ui::AX_ROLE_MENU_BUTTON, NSAccessibilityButtonRole}, - {ui::AX_ROLE_MENU_ITEM, NSAccessibilityMenuItemRole}, - {ui::AX_ROLE_MENU_ITEM_CHECK_BOX, NSAccessibilityMenuItemRole}, - {ui::AX_ROLE_MENU_ITEM_RADIO, NSAccessibilityMenuItemRole}, - {ui::AX_ROLE_MENU_LIST_OPTION, NSAccessibilityMenuItemRole}, - {ui::AX_ROLE_MENU_LIST_POPUP, NSAccessibilityUnknownRole}, - {ui::AX_ROLE_METER, NSAccessibilityProgressIndicatorRole}, - {ui::AX_ROLE_NAVIGATION, NSAccessibilityGroupRole}, - {ui::AX_ROLE_NONE, NSAccessibilityGroupRole}, - {ui::AX_ROLE_NOTE, NSAccessibilityGroupRole}, - {ui::AX_ROLE_PARAGRAPH, NSAccessibilityGroupRole}, - {ui::AX_ROLE_POP_UP_BUTTON, NSAccessibilityPopUpButtonRole}, - {ui::AX_ROLE_PRE, NSAccessibilityGroupRole}, - {ui::AX_ROLE_PRESENTATIONAL, NSAccessibilityGroupRole}, - {ui::AX_ROLE_PROGRESS_INDICATOR, NSAccessibilityProgressIndicatorRole}, - {ui::AX_ROLE_RADIO_BUTTON, NSAccessibilityRadioButtonRole}, - {ui::AX_ROLE_RADIO_GROUP, NSAccessibilityRadioGroupRole}, - {ui::AX_ROLE_REGION, NSAccessibilityGroupRole}, - {ui::AX_ROLE_ROOT_WEB_AREA, @"AXWebArea"}, - {ui::AX_ROLE_ROW, NSAccessibilityRowRole}, - {ui::AX_ROLE_ROW_HEADER, @"AXCell"}, - {ui::AX_ROLE_SCROLL_BAR, NSAccessibilityScrollBarRole}, - {ui::AX_ROLE_SEARCH, NSAccessibilityGroupRole}, - {ui::AX_ROLE_SEARCH_BOX, NSAccessibilityTextFieldRole}, - {ui::AX_ROLE_SLIDER, NSAccessibilitySliderRole}, - {ui::AX_ROLE_SLIDER_THUMB, NSAccessibilityValueIndicatorRole}, - {ui::AX_ROLE_SPIN_BUTTON, NSAccessibilityIncrementorRole}, - {ui::AX_ROLE_SPLITTER, NSAccessibilitySplitterRole}, - {ui::AX_ROLE_STATIC_TEXT, NSAccessibilityStaticTextRole}, - {ui::AX_ROLE_STATUS, NSAccessibilityGroupRole}, - {ui::AX_ROLE_SVG_ROOT, NSAccessibilityGroupRole}, - {ui::AX_ROLE_SWITCH, NSAccessibilityCheckBoxRole}, - {ui::AX_ROLE_TAB, NSAccessibilityRadioButtonRole}, - {ui::AX_ROLE_TABLE, NSAccessibilityTableRole}, - {ui::AX_ROLE_TABLE_HEADER_CONTAINER, NSAccessibilityGroupRole}, - {ui::AX_ROLE_TAB_LIST, NSAccessibilityTabGroupRole}, - {ui::AX_ROLE_TAB_PANEL, NSAccessibilityGroupRole}, - {ui::AX_ROLE_TERM, NSAccessibilityGroupRole}, - {ui::AX_ROLE_TEXT_FIELD, NSAccessibilityTextFieldRole}, - {ui::AX_ROLE_TEXT_FIELD_WITH_COMBO_BOX, NSAccessibilityComboBoxRole}, - {ui::AX_ROLE_TIME, NSAccessibilityGroupRole}, - {ui::AX_ROLE_TIMER, NSAccessibilityGroupRole}, - {ui::AX_ROLE_TOGGLE_BUTTON, NSAccessibilityCheckBoxRole}, - {ui::AX_ROLE_TOOLBAR, NSAccessibilityToolbarRole}, - {ui::AX_ROLE_TOOLTIP, NSAccessibilityGroupRole}, - {ui::AX_ROLE_TREE, NSAccessibilityOutlineRole}, - {ui::AX_ROLE_TREE_GRID, NSAccessibilityTableRole}, - {ui::AX_ROLE_TREE_ITEM, NSAccessibilityRowRole}, - {ui::AX_ROLE_VIDEO, NSAccessibilityGroupRole}, - {ui::AX_ROLE_WEB_AREA, @"AXWebArea"}, - {ui::AX_ROLE_WINDOW, NSAccessibilityWindowRole}, + {ax::mojom::Role::kGrid, NSAccessibilityTableRole}, // crbug.com/753925 + {ax::mojom::Role::kGroup, NSAccessibilityGroupRole}, + {ax::mojom::Role::kHeading, @"AXHeading"}, + {ax::mojom::Role::kIframe, NSAccessibilityGroupRole}, + {ax::mojom::Role::kIframePresentational, NSAccessibilityGroupRole}, + {ax::mojom::Role::kIgnored, NSAccessibilityUnknownRole}, + {ax::mojom::Role::kImage, NSAccessibilityImageRole}, + {ax::mojom::Role::kImageMap, NSAccessibilityGroupRole}, + {ax::mojom::Role::kInputTime, @"AXTimeField"}, + {ax::mojom::Role::kLabelText, NSAccessibilityGroupRole}, + {ax::mojom::Role::kLegend, NSAccessibilityGroupRole}, + {ax::mojom::Role::kLineBreak, NSAccessibilityGroupRole}, + {ax::mojom::Role::kLink, NSAccessibilityLinkRole}, + {ax::mojom::Role::kList, NSAccessibilityListRole}, + {ax::mojom::Role::kListBox, NSAccessibilityListRole}, + {ax::mojom::Role::kListBoxOption, NSAccessibilityStaticTextRole}, + {ax::mojom::Role::kListItem, NSAccessibilityGroupRole}, + {ax::mojom::Role::kListMarker, @"AXListMarker"}, + {ax::mojom::Role::kLog, NSAccessibilityGroupRole}, + {ax::mojom::Role::kMain, NSAccessibilityGroupRole}, + {ax::mojom::Role::kMark, NSAccessibilityGroupRole}, + {ax::mojom::Role::kMarquee, NSAccessibilityGroupRole}, + {ax::mojom::Role::kMath, NSAccessibilityGroupRole}, + {ax::mojom::Role::kMenu, NSAccessibilityMenuRole}, + {ax::mojom::Role::kMenuBar, NSAccessibilityMenuBarRole}, + {ax::mojom::Role::kMenuButton, NSAccessibilityButtonRole}, + {ax::mojom::Role::kMenuItem, NSAccessibilityMenuItemRole}, + {ax::mojom::Role::kMenuItemCheckBox, NSAccessibilityMenuItemRole}, + {ax::mojom::Role::kMenuItemRadio, NSAccessibilityMenuItemRole}, + {ax::mojom::Role::kMenuListOption, NSAccessibilityMenuItemRole}, + {ax::mojom::Role::kMenuListPopup, NSAccessibilityUnknownRole}, + {ax::mojom::Role::kMeter, NSAccessibilityProgressIndicatorRole}, + {ax::mojom::Role::kNavigation, NSAccessibilityGroupRole}, + {ax::mojom::Role::kNone, NSAccessibilityGroupRole}, + {ax::mojom::Role::kNote, NSAccessibilityGroupRole}, + {ax::mojom::Role::kParagraph, NSAccessibilityGroupRole}, + {ax::mojom::Role::kPopUpButton, NSAccessibilityPopUpButtonRole}, + {ax::mojom::Role::kPre, NSAccessibilityGroupRole}, + {ax::mojom::Role::kPresentational, NSAccessibilityGroupRole}, + {ax::mojom::Role::kProgressIndicator, + NSAccessibilityProgressIndicatorRole}, + {ax::mojom::Role::kRadioButton, NSAccessibilityRadioButtonRole}, + {ax::mojom::Role::kRadioGroup, NSAccessibilityRadioGroupRole}, + {ax::mojom::Role::kRegion, NSAccessibilityGroupRole}, + {ax::mojom::Role::kRootWebArea, @"AXWebArea"}, + {ax::mojom::Role::kRow, NSAccessibilityRowRole}, + {ax::mojom::Role::kRowHeader, @"AXCell"}, + {ax::mojom::Role::kScrollBar, NSAccessibilityScrollBarRole}, + {ax::mojom::Role::kSearch, NSAccessibilityGroupRole}, + {ax::mojom::Role::kSearchBox, NSAccessibilityTextFieldRole}, + {ax::mojom::Role::kSlider, NSAccessibilitySliderRole}, + {ax::mojom::Role::kSliderThumb, NSAccessibilityValueIndicatorRole}, + {ax::mojom::Role::kSpinButton, NSAccessibilityIncrementorRole}, + {ax::mojom::Role::kSplitter, NSAccessibilitySplitterRole}, + {ax::mojom::Role::kStaticText, NSAccessibilityStaticTextRole}, + {ax::mojom::Role::kStatus, NSAccessibilityGroupRole}, + {ax::mojom::Role::kSvgRoot, NSAccessibilityGroupRole}, + {ax::mojom::Role::kSwitch, NSAccessibilityCheckBoxRole}, + {ax::mojom::Role::kTab, NSAccessibilityRadioButtonRole}, + {ax::mojom::Role::kTable, NSAccessibilityTableRole}, + {ax::mojom::Role::kTableHeaderContainer, NSAccessibilityGroupRole}, + {ax::mojom::Role::kTabList, NSAccessibilityTabGroupRole}, + {ax::mojom::Role::kTabPanel, NSAccessibilityGroupRole}, + {ax::mojom::Role::kTerm, NSAccessibilityGroupRole}, + {ax::mojom::Role::kTextField, NSAccessibilityTextFieldRole}, + {ax::mojom::Role::kTextFieldWithComboBox, NSAccessibilityComboBoxRole}, + {ax::mojom::Role::kTime, NSAccessibilityGroupRole}, + {ax::mojom::Role::kTimer, NSAccessibilityGroupRole}, + {ax::mojom::Role::kToggleButton, NSAccessibilityCheckBoxRole}, + {ax::mojom::Role::kToolbar, NSAccessibilityToolbarRole}, + {ax::mojom::Role::kTooltip, NSAccessibilityGroupRole}, + {ax::mojom::Role::kTree, NSAccessibilityOutlineRole}, + {ax::mojom::Role::kTreeGrid, NSAccessibilityTableRole}, + {ax::mojom::Role::kTreeItem, NSAccessibilityRowRole}, + {ax::mojom::Role::kVideo, NSAccessibilityGroupRole}, + {ax::mojom::Role::kWebArea, @"AXWebArea"}, + {ax::mojom::Role::kWindow, NSAccessibilityWindowRole}, }; return RoleMap(begin(roles), end(roles)); @@ -154,37 +155,37 @@ RoleMap BuildRoleMap() { RoleMap BuildSubroleMap() { const RoleMap::value_type subroles[] = { - {ui::AX_ROLE_ALERT, @"AXApplicationAlert"}, - {ui::AX_ROLE_ALERT_DIALOG, @"AXApplicationAlertDialog"}, - {ui::AX_ROLE_APPLICATION, @"AXLandmarkApplication"}, - {ui::AX_ROLE_ARTICLE, @"AXDocumentArticle"}, - {ui::AX_ROLE_BANNER, @"AXLandmarkBanner"}, - {ui::AX_ROLE_COMPLEMENTARY, @"AXLandmarkComplementary"}, - {ui::AX_ROLE_CONTENT_INFO, @"AXLandmarkContentInfo"}, - {ui::AX_ROLE_DEFINITION, @"AXDefinition"}, - {ui::AX_ROLE_DESCRIPTION_LIST_DETAIL, @"AXDefinition"}, - {ui::AX_ROLE_DESCRIPTION_LIST_TERM, @"AXTerm"}, - {ui::AX_ROLE_DIALOG, @"AXApplicationDialog"}, - {ui::AX_ROLE_DOCUMENT, @"AXDocument"}, - {ui::AX_ROLE_FOOTER, @"AXLandmarkContentInfo"}, - {ui::AX_ROLE_FORM, @"AXLandmarkForm"}, - {ui::AX_ROLE_LOG, @"AXApplicationLog"}, - {ui::AX_ROLE_MAIN, @"AXLandmarkMain"}, - {ui::AX_ROLE_MARQUEE, @"AXApplicationMarquee"}, - {ui::AX_ROLE_MATH, @"AXDocumentMath"}, - {ui::AX_ROLE_NAVIGATION, @"AXLandmarkNavigation"}, - {ui::AX_ROLE_NOTE, @"AXDocumentNote"}, - {ui::AX_ROLE_REGION, @"AXDocumentRegion"}, - {ui::AX_ROLE_SEARCH, @"AXLandmarkSearch"}, - {ui::AX_ROLE_SEARCH_BOX, @"AXSearchField"}, - {ui::AX_ROLE_STATUS, @"AXApplicationStatus"}, - {ui::AX_ROLE_SWITCH, @"AXSwitch"}, - {ui::AX_ROLE_TAB_PANEL, @"AXTabPanel"}, - {ui::AX_ROLE_TERM, @"AXTerm"}, - {ui::AX_ROLE_TIMER, @"AXApplicationTimer"}, - {ui::AX_ROLE_TOGGLE_BUTTON, @"AXToggleButton"}, - {ui::AX_ROLE_TOOLTIP, @"AXUserInterfaceTooltip"}, - {ui::AX_ROLE_TREE_ITEM, NSAccessibilityOutlineRowSubrole}, + {ax::mojom::Role::kAlert, @"AXApplicationAlert"}, + {ax::mojom::Role::kAlertDialog, @"AXApplicationAlertDialog"}, + {ax::mojom::Role::kApplication, @"AXLandmarkApplication"}, + {ax::mojom::Role::kArticle, @"AXDocumentArticle"}, + {ax::mojom::Role::kBanner, @"AXLandmarkBanner"}, + {ax::mojom::Role::kComplementary, @"AXLandmarkComplementary"}, + {ax::mojom::Role::kContentInfo, @"AXLandmarkContentInfo"}, + {ax::mojom::Role::kDefinition, @"AXDefinition"}, + {ax::mojom::Role::kDescriptionListDetail, @"AXDefinition"}, + {ax::mojom::Role::kDescriptionListTerm, @"AXTerm"}, + {ax::mojom::Role::kDialog, @"AXApplicationDialog"}, + {ax::mojom::Role::kDocument, @"AXDocument"}, + {ax::mojom::Role::kFooter, @"AXLandmarkContentInfo"}, + {ax::mojom::Role::kForm, @"AXLandmarkForm"}, + {ax::mojom::Role::kLog, @"AXApplicationLog"}, + {ax::mojom::Role::kMain, @"AXLandmarkMain"}, + {ax::mojom::Role::kMarquee, @"AXApplicationMarquee"}, + {ax::mojom::Role::kMath, @"AXDocumentMath"}, + {ax::mojom::Role::kNavigation, @"AXLandmarkNavigation"}, + {ax::mojom::Role::kNote, @"AXDocumentNote"}, + {ax::mojom::Role::kRegion, @"AXDocumentRegion"}, + {ax::mojom::Role::kSearch, @"AXLandmarkSearch"}, + {ax::mojom::Role::kSearchBox, @"AXSearchField"}, + {ax::mojom::Role::kStatus, @"AXApplicationStatus"}, + {ax::mojom::Role::kSwitch, @"AXSwitch"}, + {ax::mojom::Role::kTabPanel, @"AXTabPanel"}, + {ax::mojom::Role::kTerm, @"AXTerm"}, + {ax::mojom::Role::kTimer, @"AXApplicationTimer"}, + {ax::mojom::Role::kToggleButton, @"AXToggleButton"}, + {ax::mojom::Role::kTooltip, @"AXUserInterfaceTooltip"}, + {ax::mojom::Role::kTreeItem, NSAccessibilityOutlineRowSubrole}, }; return RoleMap(begin(subroles), end(subroles)); @@ -192,10 +193,12 @@ RoleMap BuildSubroleMap() { EventMap BuildEventMap() { const EventMap::value_type events[] = { - {ui::AX_EVENT_FOCUS, NSAccessibilityFocusedUIElementChangedNotification}, - {ui::AX_EVENT_TEXT_CHANGED, NSAccessibilityTitleChangedNotification}, - {ui::AX_EVENT_VALUE_CHANGED, NSAccessibilityValueChangedNotification}, - {ui::AX_EVENT_TEXT_SELECTION_CHANGED, + {ax::mojom::Event::kFocus, + NSAccessibilityFocusedUIElementChangedNotification}, + {ax::mojom::Event::kTextChanged, NSAccessibilityTitleChangedNotification}, + {ax::mojom::Event::kValueChanged, + NSAccessibilityValueChangedNotification}, + {ax::mojom::Event::kTextSelectionChanged, NSAccessibilitySelectedTextChangedNotification}, // TODO(patricialor): Add more events. }; @@ -206,11 +209,11 @@ EventMap BuildEventMap() { ActionList BuildActionList() { const ActionList::value_type entries[] = { // NSAccessibilityPressAction must come first in this list. - {ui::AX_ACTION_DO_DEFAULT, NSAccessibilityPressAction}, + {ax::mojom::Action::kDoDefault, NSAccessibilityPressAction}, - {ui::AX_ACTION_DECREMENT, NSAccessibilityDecrementAction}, - {ui::AX_ACTION_INCREMENT, NSAccessibilityIncrementAction}, - {ui::AX_ACTION_SHOW_CONTEXT_MENU, NSAccessibilityShowMenuAction}, + {ax::mojom::Action::kDecrement, NSAccessibilityDecrementAction}, + {ax::mojom::Action::kIncrement, NSAccessibilityIncrementAction}, + {ax::mojom::Action::kShowContextMenu, NSAccessibilityShowMenuAction}, }; return ActionList(begin(entries), end(entries)); } @@ -220,30 +223,31 @@ ActionList BuildActionList() { return action_map; } -void NotifyMacEvent(AXPlatformNodeCocoa* target, ui::AXEvent event_type) { +void NotifyMacEvent(AXPlatformNodeCocoa* target, ax::mojom::Event event_type) { NSAccessibilityPostNotification( target, [AXPlatformNodeCocoa nativeNotificationFromAXEvent:event_type]); } // Returns true if |action| should be added implicitly for |data|. -bool HasImplicitAction(const ui::AXNodeData& data, ui::AXAction action) { - return action == ui::AX_ACTION_DO_DEFAULT && ui::IsRoleClickable(data.role); +bool HasImplicitAction(const ui::AXNodeData& data, ax::mojom::Action action) { + return action == ax::mojom::Action::kDoDefault && + ui::IsRoleClickable(data.role); } // For roles that show a menu for the default action, ensure "show menu" also // appears in available actions, but only if that's not already used for a // context menu. It will be mapped back to the default action when performed. bool AlsoUseShowMenuActionForDefaultAction(const ui::AXNodeData& data) { - return HasImplicitAction(data, ui::AX_ACTION_DO_DEFAULT) && - !data.HasAction(ui::AX_ACTION_SHOW_CONTEXT_MENU) && - data.role == ui::AX_ROLE_POP_UP_BUTTON; + return HasImplicitAction(data, ax::mojom::Action::kDoDefault) && + !data.HasAction(ax::mojom::Action::kShowContextMenu) && + data.role == ax::mojom::Role::kPopUpButton; } } // namespace @interface AXPlatformNodeCocoa () // Helper function for string attributes that don't require extra processing. -- (NSString*)getStringAttribute:(ui::AXStringAttribute)attribute; +- (NSString*)getStringAttribute:(ax::mojom::StringAttribute)attribute; // Returns AXValue, or nil if AXValue isn't an NSString. - (NSString*)getAXValueAsString; @end @@ -254,19 +258,19 @@ @implementation AXPlatformNodeCocoa { @synthesize node = node_; -+ (NSString*)nativeRoleFromAXRole:(ui::AXRole)role { ++ (NSString*)nativeRoleFromAXRole:(ax::mojom::Role)role { CR_DEFINE_STATIC_LOCAL(const RoleMap, role_map, (BuildRoleMap())); RoleMap::const_iterator it = role_map.find(role); return it != role_map.end() ? it->second : NSAccessibilityUnknownRole; } -+ (NSString*)nativeSubroleFromAXRole:(ui::AXRole)role { ++ (NSString*)nativeSubroleFromAXRole:(ax::mojom::Role)role { CR_DEFINE_STATIC_LOCAL(const RoleMap, subrole_map, (BuildSubroleMap())); RoleMap::const_iterator it = subrole_map.find(role); return it != subrole_map.end() ? it->second : nil; } -+ (NSString*)nativeNotificationFromAXEvent:(ui::AXEvent)event { ++ (NSString*)nativeNotificationFromAXEvent:(ax::mojom::Event)event { CR_DEFINE_STATIC_LOCAL(const EventMap, event_map, (BuildEventMap())); EventMap::const_iterator it = event_map.find(event); return it != event_map.end() ? it->second : nil; @@ -293,7 +297,7 @@ - (NSRect)boundsInScreen { return gfx::ScreenRectToNSRect(node_->GetBoundsInScreen()); } -- (NSString*)getStringAttribute:(ui::AXStringAttribute)attribute { +- (NSString*)getStringAttribute:(ax::mojom::StringAttribute)attribute { std::string attributeValue; if (node_->GetStringAttribute(attribute, &attributeValue)) return base::SysUTF8ToNSString(attributeValue); @@ -312,7 +316,7 @@ - (BOOL)accessibilityIsIgnored { return YES; return [[self AXRole] isEqualToString:NSAccessibilityUnknownRole] || - node_->GetData().HasState(ui::AX_STATE_INVISIBLE); + node_->GetData().HasState(ax::mojom::State::kInvisible); } - (id)accessibilityHitTest:(NSPoint)point { @@ -366,7 +370,7 @@ - (void)accessibilityPerformAction:(NSString*)action { ui::AXActionData data; if ([action isEqualToString:NSAccessibilityShowMenuAction] && AlsoUseShowMenuActionForDefaultAction(node_->GetData())) { - data.action = ui::AX_ACTION_DO_DEFAULT; + data.action = ax::mojom::Action::kDoDefault; } else { for (const ActionList::value_type& entry : GetActionList()) { if ([action isEqualToString:entry.second]) { @@ -380,7 +384,7 @@ - (void)accessibilityPerformAction:(NSString*)action { // are already implemented in -accessibilitySetValue:forAttribute:, so ignore // those here. - if (data.action != ui::AX_ACTION_NONE) + if (data.action != ax::mojom::Action::kNone) node_->GetDelegate()->AccessibilityPerformAction(data); } @@ -431,22 +435,22 @@ - (NSArray*)accessibilityAttributeNames { [axAttributes addObjectsFromArray:kAllRoleAttributes]; switch (node_->GetData().role) { - case ui::AX_ROLE_TEXT_FIELD: - case ui::AX_ROLE_TEXT_FIELD_WITH_COMBO_BOX: - case ui::AX_ROLE_STATIC_TEXT: + case ax::mojom::Role::kTextField: + case ax::mojom::Role::kTextFieldWithComboBox: + case ax::mojom::Role::kStaticText: [axAttributes addObject:kTextAttributes]; - if (!node_->GetData().HasState(ui::AX_STATE_PROTECTED)) + if (!node_->GetData().HasState(ax::mojom::State::kProtected)) [axAttributes addObjectsFromArray:kUnprotectedTextAttributes]; // Fallthrough. - case ui::AX_ROLE_CHECK_BOX: - case ui::AX_ROLE_COMBO_BOX_MENU_BUTTON: - case ui::AX_ROLE_MENU_ITEM_CHECK_BOX: - case ui::AX_ROLE_MENU_ITEM_RADIO: - case ui::AX_ROLE_RADIO_BUTTON: - case ui::AX_ROLE_SEARCH_BOX: - case ui::AX_ROLE_SLIDER: - case ui::AX_ROLE_SLIDER_THUMB: - case ui::AX_ROLE_TOGGLE_BUTTON: + case ax::mojom::Role::kCheckBox: + case ax::mojom::Role::kComboBoxMenuButton: + case ax::mojom::Role::kMenuItemCheckBox: + case ax::mojom::Role::kMenuItemRadio: + case ax::mojom::Role::kRadioButton: + case ax::mojom::Role::kSearchBox: + case ax::mojom::Role::kSlider: + case ax::mojom::Role::kSliderThumb: + case ax::mojom::Role::kToggleButton: [axAttributes addObjectsFromArray:kValueAttributes]; break; // TODO(tapted): Add additional attributes based on role. @@ -473,8 +477,8 @@ - (NSArray*)accessibilityParameterizedAttributeNames { ] retain]; switch (node_->GetData().role) { - case ui::AX_ROLE_TEXT_FIELD: - case ui::AX_ROLE_STATIC_TEXT: + case ax::mojom::Role::kTextField: + case ax::mojom::Role::kStaticText: return kSelectableTextAttributes; default: break; @@ -486,8 +490,8 @@ - (BOOL)accessibilityIsAttributeSettable:(NSString*)attributeName { if (!node_) return NO; - const ui::AXRestriction restriction = node_->GetData().GetRestriction(); - if (restriction == ui::AX_RESTRICTION_DISABLED) + const ax::mojom::Restriction restriction = node_->GetData().GetRestriction(); + if (restriction == ax::mojom::Restriction::kDisabled) return NO; // Allow certain attributes to be written via an accessibility client. A @@ -503,10 +507,10 @@ - (BOOL)accessibilityIsAttributeSettable:(NSString*)attributeName { if ([attributeName isEqualToString:NSAccessibilityValueAttribute]) { // Since tabs use the Radio Button role on Mac, the standard way to set // them is via the value attribute rather than the selected attribute. - if (node_->GetData().role == ui::AX_ROLE_TAB) - return !node_->GetData().HasState(ui::AX_STATE_SELECTED); + if (node_->GetData().role == ax::mojom::Role::kTab) + return !node_->GetData().HasState(ax::mojom::State::kSelected); - return restriction != ui::AX_RESTRICTION_READ_ONLY; + return restriction != ax::mojom::Restriction::kReadOnly; } // Readonly fields and selected text operations: @@ -516,10 +520,10 @@ - (BOOL)accessibilityIsAttributeSettable:(NSString*)attributeName { // NSAccessibilitySelectedTextAttribute is prevented, which is correct. if ([attributeName isEqualToString:NSAccessibilitySelectedTextAttribute] || [attributeName isEqualToString:NSAccessibilitySelectedTextRangeAttribute]) - return restriction != ui::AX_RESTRICTION_READ_ONLY; + return restriction != ax::mojom::Restriction::kReadOnly; if ([attributeName isEqualToString:NSAccessibilityFocusedAttribute]) { - return node_->GetData().HasState(ui::AX_STATE_FOCUSABLE); + return node_->GetData().HasState(ax::mojom::State::kFocusable); } // TODO(patricialor): Add callbacks for updating the above attributes except @@ -536,32 +540,32 @@ - (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute { // Check for attributes first. Only the |data.action| should be set here - any // type-specific information, if needed, should be set below. if ([attribute isEqualToString:NSAccessibilityValueAttribute]) { - data.action = node_->GetData().role == ui::AX_ROLE_TAB - ? ui::AX_ACTION_SET_SELECTION - : ui::AX_ACTION_SET_VALUE; + data.action = node_->GetData().role == ax::mojom::Role::kTab + ? ax::mojom::Action::kSetSelection + : ax::mojom::Action::kSetValue; } else if ([attribute isEqualToString:NSAccessibilitySelectedTextAttribute]) { - data.action = ui::AX_ACTION_REPLACE_SELECTED_TEXT; + data.action = ax::mojom::Action::kReplaceSelectedText; } else if ([attribute isEqualToString:NSAccessibilitySelectedTextRangeAttribute]) { - data.action = ui::AX_ACTION_SET_SELECTION; + data.action = ax::mojom::Action::kSetSelection; } else if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) { if ([value isKindOfClass:[NSNumber class]]) { - data.action = - [value boolValue] ? ui::AX_ACTION_FOCUS : ui::AX_ACTION_BLUR; + data.action = [value boolValue] ? ax::mojom::Action::kFocus + : ax::mojom::Action::kBlur; } } // Set type-specific information as necessary for actions set above. if ([value isKindOfClass:[NSString class]]) { data.value = base::SysNSStringToUTF16(value); - } else if (data.action == ui::AX_ACTION_SET_SELECTION && + } else if (data.action == ax::mojom::Action::kSetSelection && [value isKindOfClass:[NSValue class]]) { NSRange range = [value rangeValue]; data.anchor_offset = range.location; data.focus_offset = NSMaxRange(range); } - if (data.action != ui::AX_ACTION_NONE) + if (data.action != ax::mojom::Action::kNone) node_->GetDelegate()->AccessibilityPerformAction(data); // TODO(patricialor): Plumb through all the other writable attributes as @@ -570,7 +574,7 @@ - (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute { - (id)accessibilityAttributeValue:(NSString*)attribute { if (!node_) - return nil; // Return nil when detached. Even for AXRole. + return nil; // Return nil when detached. Even for ax::mojom::Role. SEL selector = NSSelectorFromString(attribute); if ([self respondsToSelector:selector]) @@ -601,12 +605,12 @@ - (NSString*)AXRole { - (NSString*)AXRoleDescription { switch (node_->GetData().role) { - case ui::AX_ROLE_TAB: + case ax::mojom::Role::kTab: // There is no NSAccessibilityTabRole or similar (AXRadioButton is used // instead). Do the same as NSTabView and put "tab" in the description. return [l10n_util::GetNSStringWithFixup(IDS_ACCNAME_TAB_ROLE_DESCRIPTION) lowercaseString]; - case ui::AX_ROLE_DISCLOSURE_TRIANGLE: + case ax::mojom::Role::kDisclosureTriangle: return [l10n_util::GetNSStringWithFixup( IDS_ACCNAME_DISCLOSURE_TRIANGLE_ROLE_DESCRIPTION) lowercaseString]; default: @@ -616,10 +620,10 @@ - (NSString*)AXRoleDescription { } - (NSString*)AXSubrole { - ui::AXRole role = node_->GetData().role; + ax::mojom::Role role = node_->GetData().role; switch (role) { - case ui::AX_ROLE_TEXT_FIELD: - if (node_->GetData().HasState(ui::AX_STATE_PROTECTED)) + case ax::mojom::Role::kTextField: + if (node_->GetData().HasState(ax::mojom::State::kProtected)) return NSAccessibilitySecureTextFieldSubrole; break; default: @@ -632,8 +636,10 @@ - (NSString*)AXHelp { // TODO(aleventhal) Key shortcuts attribute should eventually get // its own field. Follow what WebKit does for aria-keyshortcuts, see // https://bugs.webkit.org/show_bug.cgi?id=159215 (WebKit bug). - NSString* desc = [self getStringAttribute:ui::AX_ATTR_DESCRIPTION]; - NSString* key = [self getStringAttribute:ui::AX_ATTR_KEY_SHORTCUTS]; + NSString* desc = + [self getStringAttribute:ax::mojom::StringAttribute::kDescription]; + NSString* key = + [self getStringAttribute:ax::mojom::StringAttribute::kKeyShortcuts]; if (!desc.length) return key.length ? key : @""; if (!key.length) @@ -642,22 +648,23 @@ - (NSString*)AXHelp { } - (id)AXValue { - ui::AXRole role = node_->GetData().role; - if (role == ui::AX_ROLE_TAB) + ax::mojom::Role role = node_->GetData().role; + if (role == ax::mojom::Role::kTab) return [self AXSelected]; if (ui::IsNameExposedInAXValueForRole(role)) - return [self getStringAttribute:ui::AX_ATTR_NAME]; + return [self getStringAttribute:ax::mojom::StringAttribute::kName]; - return [self getStringAttribute:ui::AX_ATTR_VALUE]; + return [self getStringAttribute:ax::mojom::StringAttribute::kValue]; } - (NSNumber*)AXEnabled { - return @(node_->GetData().GetRestriction() != ui::AX_RESTRICTION_DISABLED); + return + @(node_->GetData().GetRestriction() != ax::mojom::Restriction::kDisabled); } - (NSNumber*)AXFocused { - if (node_->GetData().HasState(ui::AX_STATE_FOCUSABLE)) + if (node_->GetData().HasState(ax::mojom::State::kFocusable)) return @(node_->GetDelegate()->GetFocus() == node_->GetNativeViewAccessible()); return @NO; @@ -700,17 +707,17 @@ - (NSString*)AXTitle { if (ui::IsNameExposedInAXValueForRole(node_->GetData().role)) return @""; - return [self getStringAttribute:ui::AX_ATTR_NAME]; + return [self getStringAttribute:ax::mojom::StringAttribute::kName]; } // Misc attributes. - (NSNumber*)AXSelected { - return @(node_->GetData().HasState(ui::AX_STATE_SELECTED)); + return @(node_->GetData().HasState(ax::mojom::State::kSelected)); } - (NSString*)AXPlaceholderValue { - return [self getStringAttribute:ui::AX_ATTR_PLACEHOLDER]; + return [self getStringAttribute:ax::mojom::StringAttribute::kPlaceholder]; } // Text-specific attributes. @@ -724,8 +731,8 @@ - (NSString*)AXSelectedText { - (NSValue*)AXSelectedTextRange { // Selection might not be supported. Return (NSRange){0,0} in that case. int start = 0, end = 0; - node_->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, &start); - node_->GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, &end); + node_->GetIntAttribute(ax::mojom::IntAttribute::kTextSelStart, &start); + node_->GetIntAttribute(ax::mojom::IntAttribute::kTextSelEnd, &end); // NSRange cannot represent the direction the text was selected in. return [NSValue valueWithRange:{std::min(start, end), abs(end - start)}]; @@ -844,15 +851,16 @@ - (id)AXAttributedStringForRange:(id)parameter { return native_node_.get(); } -void AXPlatformNodeMac::NotifyAccessibilityEvent(ui::AXEvent event_type) { +void AXPlatformNodeMac::NotifyAccessibilityEvent(ax::mojom::Event event_type) { GetNativeViewAccessible(); - // Add mappings between ui::AXEvent and NSAccessibility notifications using - // the EventMap above. This switch contains exceptions to those mappings. + // Add mappings between ax::mojom::Event and NSAccessibility notifications + // using the EventMap above. This switch contains exceptions to those + // mappings. switch (event_type) { - case ui::AX_EVENT_TEXT_CHANGED: + case ax::mojom::Event::kTextChanged: // If the view is a user-editable textfield, this should change the value. - if (GetData().role == ui::AX_ROLE_TEXT_FIELD) { - NotifyMacEvent(native_node_, ui::AX_EVENT_VALUE_CHANGED); + if (GetData().role == ax::mojom::Role::kTextField) { + NotifyMacEvent(native_node_, ax::mojom::Event::kValueChanged); return; } break; @@ -867,12 +875,12 @@ - (id)AXAttributedStringForRange:(id)parameter { return -1; } -bool IsNameExposedInAXValueForRole(AXRole role) { +bool IsNameExposedInAXValueForRole(ax::mojom::Role role) { switch (role) { - case AX_ROLE_LIST_BOX_OPTION: - case AX_ROLE_LIST_MARKER: - case AX_ROLE_MENU_LIST_OPTION: - case AX_ROLE_STATIC_TEXT: + case ax::mojom::Role::kListBoxOption: + case ax::mojom::Role::kListMarker: + case ax::mojom::Role::kMenuListOption: + case ax::mojom::Role::kStaticText: return true; default: return false; diff --git a/ui/accessibility/platform/ax_platform_node_unittest.cc b/ui/accessibility/platform/ax_platform_node_unittest.cc index de424716d222d9..9cb8b4428a3bb5 100644 --- a/ui/accessibility/platform/ax_platform_node_unittest.cc +++ b/ui/accessibility/platform/ax_platform_node_unittest.cc @@ -57,8 +57,8 @@ void AXPlatformNodeTest::Init(const AXNodeData& node1, AXTreeUpdate AXPlatformNodeTest::BuildTextField() { AXNodeData text_field_node; text_field_node.id = 1; - text_field_node.role = AX_ROLE_TEXT_FIELD; - text_field_node.AddState(AX_STATE_EDITABLE); + text_field_node.role = ax::mojom::Role::kTextField; + text_field_node.AddState(ax::mojom::State::kEditable); text_field_node.SetValue("How now brown cow."); AXTreeUpdate update; @@ -72,11 +72,12 @@ AXTreeUpdate AXPlatformNodeTest::BuildTextFieldWithSelectionRange( int32_t stop) { AXNodeData text_field_node; text_field_node.id = 1; - text_field_node.role = AX_ROLE_TEXT_FIELD; - text_field_node.AddState(AX_STATE_EDITABLE); - text_field_node.AddState(AX_STATE_SELECTED); - text_field_node.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, start); - text_field_node.AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, stop); + text_field_node.role = ax::mojom::Role::kTextField; + text_field_node.AddState(ax::mojom::State::kEditable); + text_field_node.AddState(ax::mojom::State::kSelected); + text_field_node.AddIntAttribute(ax::mojom::IntAttribute::kTextSelStart, + start); + text_field_node.AddIntAttribute(ax::mojom::IntAttribute::kTextSelEnd, stop); text_field_node.SetValue("How now brown cow."); AXTreeUpdate update; @@ -88,9 +89,10 @@ AXTreeUpdate AXPlatformNodeTest::BuildTextFieldWithSelectionRange( AXTreeUpdate AXPlatformNodeTest::BuildContentEditable() { AXNodeData content_editable_node; content_editable_node.id = 1; - content_editable_node.role = AX_ROLE_GROUP; - content_editable_node.AddState(AX_STATE_RICHLY_EDITABLE); - content_editable_node.AddBoolAttribute(ui::AX_ATTR_EDITABLE_ROOT, true); + content_editable_node.role = ax::mojom::Role::kGroup; + content_editable_node.AddState(ax::mojom::State::kRichlyEditable); + content_editable_node.AddBoolAttribute( + ax::mojom::BoolAttribute::kEditableRoot, true); content_editable_node.SetValue("How now brown cow."); AXTreeUpdate update; @@ -104,10 +106,11 @@ AXTreeUpdate AXPlatformNodeTest::BuildContentEditableWithSelectionRange( int32_t end) { AXNodeData content_editable_node; content_editable_node.id = 1; - content_editable_node.role = AX_ROLE_GROUP; - content_editable_node.AddState(AX_STATE_RICHLY_EDITABLE); - content_editable_node.AddState(AX_STATE_SELECTED); - content_editable_node.AddBoolAttribute(ui::AX_ATTR_EDITABLE_ROOT, true); + content_editable_node.role = ax::mojom::Role::kGroup; + content_editable_node.AddState(ax::mojom::State::kRichlyEditable); + content_editable_node.AddState(ax::mojom::State::kSelected); + content_editable_node.AddBoolAttribute( + ax::mojom::BoolAttribute::kEditableRoot, true); content_editable_node.SetValue("How now brown cow."); AXTreeUpdate update; @@ -138,18 +141,18 @@ AXTreeUpdate AXPlatformNodeTest::AXPlatformNodeTest::Build3X3Table() { AXNodeData table; table.id = 0; - table.role = AX_ROLE_TABLE; + table.role = ax::mojom::Role::kTable; - table.AddIntAttribute(AX_ATTR_TABLE_ROW_COUNT, 3); - table.AddIntAttribute(AX_ATTR_TABLE_COLUMN_COUNT, 3); + table.AddIntAttribute(ax::mojom::IntAttribute::kTableRowCount, 3); + table.AddIntAttribute(ax::mojom::IntAttribute::kTableColumnCount, 3); // Ordering in this list matters. It is used in the calculation // of where cells are by the following: // int position = row * GetTableColumnCount() + column; std::vector ids{51, 52, 53, 2, 3, 4, 11, 12, 13}; - table.AddIntListAttribute(AX_ATTR_CELL_IDS, ids); - table.AddIntListAttribute(AX_ATTR_UNIQUE_CELL_IDS, ids); + table.AddIntListAttribute(ax::mojom::IntListAttribute::kCellIds, ids); + table.AddIntListAttribute(ax::mojom::IntListAttribute::kUniqueCellIds, ids); table.child_ids.push_back(50); // Header table.child_ids.push_back(1); // Row 1 @@ -158,74 +161,75 @@ AXTreeUpdate AXPlatformNodeTest::AXPlatformNodeTest::Build3X3Table() { // Table column header AXNodeData table_row_header; table_row_header.id = 50; - table_row_header.role = AX_ROLE_ROW; + table_row_header.role = ax::mojom::Role::kRow; table_row_header.child_ids.push_back(51); table_row_header.child_ids.push_back(52); table_row_header.child_ids.push_back(53); AXNodeData table_column_header_1; table_column_header_1.id = 51; - table_column_header_1.role = AX_ROLE_COLUMN_HEADER; + table_column_header_1.role = ax::mojom::Role::kColumnHeader; AXNodeData table_column_header_2; table_column_header_2.id = 52; - table_column_header_2.role = AX_ROLE_COLUMN_HEADER; + table_column_header_2.role = ax::mojom::Role::kColumnHeader; table_column_header_2.SetName("column header 1"); AXNodeData table_column_header_3; table_column_header_3.id = 53; - table_column_header_3.role = AX_ROLE_COLUMN_HEADER; - // Either AX_ATTR_NAME -or- AX_ATTR_DESCRIPTION is acceptable for a - // description - table_column_header_3.AddStringAttribute(AX_ATTR_DESCRIPTION, - "column header 2"); + table_column_header_3.role = ax::mojom::Role::kColumnHeader; + // Either ax::mojom::StringAttribute::kName -or- + // ax::mojom::StringAttribute::kDescription is acceptable for a description + table_column_header_3.AddStringAttribute( + ax::mojom::StringAttribute::kDescription, "column header 2"); // Row 1 AXNodeData table_row_1; table_row_1.id = 1; - table_row_1.role = AX_ROLE_ROW; + table_row_1.role = ax::mojom::Role::kRow; table_row_1.child_ids.push_back(2); table_row_1.child_ids.push_back(3); table_row_1.child_ids.push_back(4); AXNodeData table_row_header_1; table_row_header_1.id = 2; - table_row_header_1.role = AX_ROLE_ROW_HEADER; + table_row_header_1.role = ax::mojom::Role::kRowHeader; table_row_header_1.SetName("row header 1"); AXNodeData table_cell_1; table_cell_1.id = 3; - table_cell_1.role = AX_ROLE_CELL; + table_cell_1.role = ax::mojom::Role::kCell; table_cell_1.SetName("1"); AXNodeData table_cell_2; table_cell_2.id = 4; - table_cell_2.role = AX_ROLE_CELL; + table_cell_2.role = ax::mojom::Role::kCell; table_cell_2.SetName("2"); // Row 2 AXNodeData table_row_2; table_row_2.id = 10; - table_row_2.role = AX_ROLE_ROW; + table_row_2.role = ax::mojom::Role::kRow; table_row_2.child_ids.push_back(11); table_row_2.child_ids.push_back(12); table_row_2.child_ids.push_back(13); AXNodeData table_row_header_2; table_row_header_2.id = 11; - table_row_header_2.role = AX_ROLE_ROW_HEADER; - // Either AX_ATTR_NAME -or- AX_ATTR_DESCRIPTION is acceptable for a - // description - table_row_header_2.AddStringAttribute(AX_ATTR_DESCRIPTION, "row header 2"); + table_row_header_2.role = ax::mojom::Role::kRowHeader; + // Either ax::mojom::StringAttribute::kName -or- + // ax::mojom::StringAttribute::kDescription is acceptable for a description + table_row_header_2.AddStringAttribute( + ax::mojom::StringAttribute::kDescription, "row header 2"); AXNodeData table_cell_3; table_cell_3.id = 12; - table_cell_3.role = AX_ROLE_CELL; + table_cell_3.role = ax::mojom::Role::kCell; table_cell_3.SetName("3"); AXNodeData table_cell_4; table_cell_4.id = 13; - table_cell_4.role = AX_ROLE_CELL; + table_cell_4.role = ax::mojom::Role::kCell; table_cell_4.SetName("4"); AXTreeUpdate update; diff --git a/ui/accessibility/platform/ax_platform_node_win.cc b/ui/accessibility/platform/ax_platform_node_win.cc index 3e5dd60a73347f..60ff90b26b0e36 100644 --- a/ui/accessibility/platform/ax_platform_node_win.cc +++ b/ui/accessibility/platform/ax_platform_node_win.cc @@ -283,7 +283,7 @@ void AXPlatformNodeWin::SanitizeStringAttributeForIA2( void AXPlatformNodeWin::StringAttributeToIA2( std::vector& attributes, - AXStringAttribute attribute, + ax::mojom::StringAttribute attribute, const char* ia2_attr) { base::string16 value; if (GetString16Attribute(attribute, &value)) { @@ -294,7 +294,7 @@ void AXPlatformNodeWin::StringAttributeToIA2( void AXPlatformNodeWin::BoolAttributeToIA2( std::vector& attributes, - AXBoolAttribute attribute, + ax::mojom::BoolAttribute attribute, const char* ia2_attr) { bool value; if (GetBoolAttribute(attribute, &value)) { @@ -305,7 +305,7 @@ void AXPlatformNodeWin::BoolAttributeToIA2( void AXPlatformNodeWin::IntAttributeToIA2( std::vector& attributes, - AXIntAttribute attribute, + ax::mojom::IntAttribute attribute, const char* ia2_attr) { int value; if (GetIntAttribute(attribute, &value)) { @@ -340,15 +340,16 @@ gfx::NativeViewAccessible AXPlatformNodeWin::GetNativeViewAccessible() { return this; } -void AXPlatformNodeWin::NotifyAccessibilityEvent(AXEvent event_type) { +void AXPlatformNodeWin::NotifyAccessibilityEvent(ax::mojom::Event event_type) { HWND hwnd = delegate_->GetTargetForNativeAccessibilityEvent(); if (!hwnd) return; // Menu items fire selection events but Windows screen readers work reliably // with focus events. Remap here. - if (event_type == AX_EVENT_SELECTION && GetData().role == AX_ROLE_MENU_ITEM) - event_type = AX_EVENT_FOCUS; + if (event_type == ax::mojom::Event::kSelection && + GetData().role == ax::mojom::Role::kMenuItem) + event_type = ax::mojom::Event::kFocus; int native_event = MSAAEvent(event_type); if (native_event < EVENT_MIN) @@ -357,7 +358,7 @@ void AXPlatformNodeWin::NotifyAccessibilityEvent(AXEvent event_type) { ::NotifyWinEvent(native_event, hwnd, OBJID_CLIENT, -GetUniqueId()); // Keep track of objects that are a target of an alert event. - if (event_type == AX_EVENT_ALERT) + if (event_type == ax::mojom::Event::kAlert) AddAlertTarget(); } @@ -446,7 +447,7 @@ HRESULT AXPlatformNodeWin::accDoDefaultAction(VARIANT var_id) { AXPlatformNodeWin* target; COM_OBJECT_VALIDATE_VAR_ID_AND_GET_TARGET(var_id, target); AXActionData data; - data.action = AX_ACTION_DO_DEFAULT; + data.action = ax::mojom::Action::kDoDefault; if (target->delegate_->AccessibilityPerformAction(data)) return S_OK; @@ -612,13 +613,14 @@ STDMETHODIMP AXPlatformNodeWin::get_accDefaultAction( AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes); int action; - if (!target->GetIntAttribute(AX_ATTR_DEFAULT_ACTION_VERB, &action)) { + if (!target->GetIntAttribute(ax::mojom::IntAttribute::kDefaultActionVerb, + &action)) { *def_action = nullptr; return S_FALSE; } - base::string16 action_verb = - ActionVerbToLocalizedString(static_cast(action)); + base::string16 action_verb = ActionVerbToLocalizedString( + static_cast(action)); if (action_verb.empty()) { *def_action = nullptr; return S_FALSE; @@ -635,7 +637,8 @@ STDMETHODIMP AXPlatformNodeWin::get_accDescription( AXPlatformNodeWin* target; COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, desc, target); - return target->GetStringAttributeAsBstr(AX_ATTR_DESCRIPTION, desc); + return target->GetStringAttributeAsBstr( + ax::mojom::StringAttribute::kDescription, desc); } STDMETHODIMP AXPlatformNodeWin::get_accFocus(VARIANT* focus_child) { @@ -663,7 +666,8 @@ STDMETHODIMP AXPlatformNodeWin::get_accKeyboardShortcut( AXPlatformNodeWin* target; COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, acc_key, target); - return target->GetStringAttributeAsBstr(AX_ATTR_KEY_SHORTCUTS, acc_key); + return target->GetStringAttributeAsBstr( + ax::mojom::StringAttribute::kKeyShortcuts, acc_key); } STDMETHODIMP AXPlatformNodeWin::get_accName( @@ -672,7 +676,8 @@ STDMETHODIMP AXPlatformNodeWin::get_accName( AXPlatformNodeWin* target; COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, name, target); - HRESULT result = target->GetStringAttributeAsBstr(AX_ATTR_NAME, name); + HRESULT result = + target->GetStringAttributeAsBstr(ax::mojom::StringAttribute::kName, name); if (FAILED(result) && MSAARole() == ROLE_SYSTEM_DOCUMENT && GetParent()) { // Hack: Some versions of JAWS crash if they get an empty name on // a document that's the child of an iframe, so always return a @@ -747,19 +752,20 @@ STDMETHODIMP AXPlatformNodeWin::get_accValue(VARIANT var_id, BSTR* value) { // get_accValue() has two sets of special cases depending on the node's role. // The first set apply without regard for the nodes |value| attribute. That is // the nodes value attribute isn't consider for the first set of special - // cases. For example, if the node role is AX_ROLE_COLOR_WELL, we do not care - // at all about the node's AX_ATTR_VALUE attribute. The second set of special - // cases only apply if the value attribute for the node is empty. That is, if - // AX_ATTR_VALUE is empty, we do something special. + // cases. For example, if the node role is ax::mojom::Role::kColorWell, we do + // not care at all about the node's ax::mojom::StringAttribute::kValue + // attribute. The second set of special cases only apply if the value + // attribute for the node is empty. That is, if + // ax::mojom::StringAttribute::kValue is empty, we do something special. base::string16 result; // - // Color Well special case (Use AX_ATTR_COLOR_VALUE) + // Color Well special case (Use ax::mojom::IntAttribute::kColorValue) // - if (target->GetData().role == AX_ROLE_COLOR_WELL) { + if (target->GetData().role == ax::mojom::Role::kColorWell) { unsigned int color = static_cast(target->GetIntAttribute( - AX_ATTR_COLOR_VALUE)); // todo, why the static cast? + ax::mojom::IntAttribute::kColorValue)); // todo, why the static cast? unsigned int red = SkColorGetR(color); unsigned int green = SkColorGetG(color); @@ -776,8 +782,8 @@ STDMETHODIMP AXPlatformNodeWin::get_accValue(VARIANT var_id, BSTR* value) { // // Document special case (Use the document's URL) // - if (target->GetData().role == AX_ROLE_ROOT_WEB_AREA || - target->GetData().role == AX_ROLE_WEB_AREA) { + if (target->GetData().role == ax::mojom::Role::kRootWebArea || + target->GetData().role == ax::mojom::Role::kWebArea) { result = base::UTF8ToUTF16(target->delegate_->GetTreeData().url); *value = SysAllocString(result.c_str()); DCHECK(*value); @@ -785,10 +791,10 @@ STDMETHODIMP AXPlatformNodeWin::get_accValue(VARIANT var_id, BSTR* value) { } // - // Links (Use AX_ATTR_URL) + // Links (Use ax::mojom::StringAttribute::kUrl) // - if (target->GetData().role == AX_ROLE_LINK) { - result = target->GetString16Attribute(AX_ATTR_URL); + if (target->GetData().role == ax::mojom::Role::kLink) { + result = target->GetString16Attribute(ax::mojom::StringAttribute::kUrl); *value = SysAllocString(result.c_str()); DCHECK(*value); return S_OK; @@ -797,11 +803,12 @@ STDMETHODIMP AXPlatformNodeWin::get_accValue(VARIANT var_id, BSTR* value) { // For range controls, e.g. sliders and spin buttons, |ax_attr_value| holds // the aria-valuetext if present but not the inner text. The actual value, // provided either via aria-valuenow or the actual control's value is held in - // |AX_ATTR_VALUE_FOR_RANGE|. - result = target->GetString16Attribute(AX_ATTR_VALUE); + // |ax::mojom::FloatAttribute::kValueForRange|. + result = target->GetString16Attribute(ax::mojom::StringAttribute::kValue); if (result.empty() && target->IsRangeValueSupported()) { float fval; - if (target->GetFloatAttribute(AX_ATTR_VALUE_FOR_RANGE, &fval)) { + if (target->GetFloatAttribute(ax::mojom::FloatAttribute::kValueForRange, + &fval)) { result = base::NumberToString16(fval); *value = SysAllocString(result.c_str()); DCHECK(*value); @@ -823,7 +830,7 @@ STDMETHODIMP AXPlatformNodeWin::put_accValue(VARIANT var_id, COM_OBJECT_VALIDATE_VAR_ID_AND_GET_TARGET(var_id, target); AXActionData data; - data.action = AX_ACTION_SET_VALUE; + data.action = ax::mojom::Action::kSetValue; data.value = new_value; if (target->delegate_->AccessibilityPerformAction(data)) return S_OK; @@ -837,7 +844,7 @@ STDMETHODIMP AXPlatformNodeWin::get_accSelection(VARIANT* selected) { for (int i = 0; i < delegate_->GetChildCount(); ++i) { auto* node = static_cast( FromNativeViewAccessible(delegate_->ChildAtIndex(i))); - if (node && node->GetData().HasState(AX_STATE_SELECTED)) + if (node && node->GetData().HasState(ax::mojom::State::kSelected)) selected_nodes.emplace_back(node); } @@ -874,7 +881,7 @@ STDMETHODIMP AXPlatformNodeWin::accSelect( if (flagsSelect & SELFLAG_TAKEFOCUS) { AXActionData action_data; - action_data.action = AX_ACTION_FOCUS; + action_data.action = ax::mojom::Action::kFocus; target->delegate_->AccessibilityPerformAction(action_data); return S_OK; } @@ -1120,9 +1127,9 @@ STDMETHODIMP AXPlatformNodeWin::get_groupPosition(LONG* group_level, position_in_group); AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes); - *group_level = GetIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL); - *similar_items_in_group = GetIntAttribute(ui::AX_ATTR_SET_SIZE); - *position_in_group = GetIntAttribute(ui::AX_ATTR_POS_IN_SET); + *group_level = GetIntAttribute(ax::mojom::IntAttribute::kHierarchicalLevel); + *similar_items_in_group = GetIntAttribute(ax::mojom::IntAttribute::kSetSize); + *position_in_group = GetIntAttribute(ax::mojom::IntAttribute::kPosInSet); if (!*group_level && !*similar_items_in_group && !*position_in_group) return S_FALSE; @@ -1135,7 +1142,7 @@ STDMETHODIMP AXPlatformNodeWin::get_localizedExtendedRole( COM_OBJECT_VALIDATE_1_ARG(localized_extended_role); AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes); - return GetStringAttributeAsBstr(ui::AX_ATTR_ROLE_DESCRIPTION, + return GetStringAttributeAsBstr(ax::mojom::StringAttribute::kRoleDescription, localized_extended_role); } @@ -1154,7 +1161,8 @@ STDMETHODIMP AXPlatformNodeWin::scrollTo(enum IA2ScrollType scroll_type) { COM_OBJECT_VALIDATE(); WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IA2_SCROLL_TO); - // AX_ACTION_SCROLL_TO_MAKE_VISIBLE wants a target rect in *local* coords. + // ax::mojom::Action::kScrollToMakeVisible wants a target rect in *local* + // coords. gfx::Rect r = gfx::ToEnclosingRect(GetData().location); r.Offset(-r.OffsetFromOrigin()); switch (scroll_type) { @@ -1183,7 +1191,7 @@ STDMETHODIMP AXPlatformNodeWin::scrollTo(enum IA2ScrollType scroll_type) { ui::AXActionData action_data; action_data.target_node_id = GetData().id; - action_data.action = ui::AX_ACTION_SCROLL_TO_MAKE_VISIBLE; + action_data.action = ax::mojom::Action::kScrollToMakeVisible; action_data.target_rect = r; delegate_->AccessibilityPerformAction(action_data); return S_OK; @@ -1212,7 +1220,7 @@ STDMETHODIMP AXPlatformNodeWin::scrollToPoint( ui::AXActionData action_data; action_data.target_node_id = GetData().id; - action_data.action = ui::AX_ACTION_SCROLL_TO_POINT; + action_data.action = ax::mojom::Action::kScrollToPoint; action_data.target_point = scroll_to; delegate_->AccessibilityPerformAction(action_data); return S_OK; @@ -1328,14 +1336,16 @@ STDMETHODIMP AXPlatformNodeWin::get_columnDescription(LONG column, for (int r = 0; r < rows; ++r) { AXPlatformNodeBase* cell = GetTableCell(r, column); - if (cell && cell->GetData().role == AX_ROLE_COLUMN_HEADER) { - base::string16 cell_name = cell->GetString16Attribute(AX_ATTR_NAME); + if (cell && cell->GetData().role == ax::mojom::Role::kColumnHeader) { + base::string16 cell_name = + cell->GetString16Attribute(ax::mojom::StringAttribute::kName); if (cell_name.size() > 0) { *description = SysAllocString(cell_name.c_str()); return S_OK; } - cell_name = cell->GetString16Attribute(AX_ATTR_DESCRIPTION); + cell_name = + cell->GetString16Attribute(ax::mojom::StringAttribute::kDescription); if (cell_name.size() > 0) { *description = SysAllocString(cell_name.c_str()); return S_OK; @@ -1429,7 +1439,7 @@ STDMETHODIMP AXPlatformNodeWin::get_nSelectedChildren(LONG* cell_count) { for (int r = 0; r < rows; ++r) { for (int c = 0; c < columns; ++c) { AXPlatformNodeBase* cell = GetTableCell(r, c); - if (cell && cell->GetData().HasState(AX_STATE_SELECTED)) + if (cell && cell->GetData().HasState(ax::mojom::State::kSelected)) result++; } } @@ -1456,7 +1466,7 @@ STDMETHODIMP AXPlatformNodeWin::get_nSelectedColumns(LONG* column_count) { bool selected = true; for (int r = 0; r < rows && selected == true; ++r) { AXPlatformNodeBase* cell = GetTableCell(r, c); - if (!cell || !(cell->GetData().HasState(AX_STATE_SELECTED))) + if (!cell || !(cell->GetData().HasState(ax::mojom::State::kSelected))) selected = false; } if (selected) @@ -1486,7 +1496,7 @@ STDMETHODIMP AXPlatformNodeWin::get_nSelectedRows(LONG* row_count) { bool selected = true; for (int c = 0; c < columns && selected == true; ++c) { AXPlatformNodeBase* cell = GetTableCell(r, c); - if (!cell || !(cell->GetData().HasState(AX_STATE_SELECTED))) + if (!cell || !(cell->GetData().HasState(ax::mojom::State::kSelected))) selected = false; } if (selected) @@ -1516,13 +1526,15 @@ STDMETHODIMP AXPlatformNodeWin::get_rowDescription(LONG row, for (int c = 0; c < columns; ++c) { AXPlatformNodeBase* cell = GetTableCell(row, c); - if (cell && cell->GetData().role == AX_ROLE_ROW_HEADER) { - base::string16 cell_name = cell->GetString16Attribute(AX_ATTR_NAME); + if (cell && cell->GetData().role == ax::mojom::Role::kRowHeader) { + base::string16 cell_name = + cell->GetString16Attribute(ax::mojom::StringAttribute::kName); if (cell_name.size() > 0) { *description = SysAllocString(cell_name.c_str()); return S_OK; } - cell_name = cell->GetString16Attribute(AX_ATTR_DESCRIPTION); + cell_name = + cell->GetString16Attribute(ax::mojom::StringAttribute::kDescription); if (cell_name.size() > 0) { *description = SysAllocString(cell_name.c_str()); return S_OK; @@ -1594,7 +1606,7 @@ STDMETHODIMP AXPlatformNodeWin::get_selectedChildren(LONG max_children, for (int r = 0; r < rows; ++r) { for (int c = 0; c < columns; ++c) { AXPlatformNodeBase* cell = GetTableCell(r, c); - if (cell && cell->GetData().HasState(AX_STATE_SELECTED)) + if (cell && cell->GetData().HasState(ax::mojom::State::kSelected)) // index is row index * column count + column index. results.push_back(r * columns + c); } @@ -1623,7 +1635,7 @@ STDMETHODIMP AXPlatformNodeWin::get_selectedColumns(LONG max_columns, bool selected = true; for (int r = 0; r < row_count && selected == true; ++r) { AXPlatformNodeBase* cell = GetTableCell(r, c); - if (!cell || !(cell->GetData().HasState(AX_STATE_SELECTED))) + if (!cell || !(cell->GetData().HasState(ax::mojom::State::kSelected))) selected = false; } if (selected) @@ -1651,7 +1663,7 @@ STDMETHODIMP AXPlatformNodeWin::get_selectedRows(LONG max_rows, bool selected = true; for (int c = 0; c < column_count && selected == true; ++c) { AXPlatformNodeBase* cell = GetTableCell(r, c); - if (!cell || !(cell->GetData().HasState(AX_STATE_SELECTED))) + if (!cell || !(cell->GetData().HasState(ax::mojom::State::kSelected))) selected = false; } if (selected) @@ -1688,7 +1700,7 @@ STDMETHODIMP AXPlatformNodeWin::get_isColumnSelected(LONG column, for (int r = 0; r < rows; ++r) { AXPlatformNodeBase* cell = GetTableCell(r, column); - if (!cell || !(cell->GetData().HasState(AX_STATE_SELECTED))) + if (!cell || !(cell->GetData().HasState(ax::mojom::State::kSelected))) return S_OK; } @@ -1711,7 +1723,7 @@ STDMETHODIMP AXPlatformNodeWin::get_isRowSelected(LONG row, for (int c = 0; c < columns; ++c) { AXPlatformNodeBase* cell = GetTableCell(row, c); - if (!cell || !(cell->GetData().HasState(AX_STATE_SELECTED))) + if (!cell || !(cell->GetData().HasState(ax::mojom::State::kSelected))) return S_OK; } @@ -1735,7 +1747,7 @@ STDMETHODIMP AXPlatformNodeWin::get_isSelected(LONG row, return S_FALSE; AXPlatformNodeBase* cell = GetTableCell(row, column); - if (cell && cell->GetData().HasState(AX_STATE_SELECTED)) + if (cell && cell->GetData().HasState(ax::mojom::State::kSelected)) *is_selected = true; return S_OK; @@ -1852,7 +1864,7 @@ STDMETHODIMP AXPlatformNodeWin::get_selectedCells(IUnknown*** cells, for (int r = 0; r < rows; ++r) { for (int c = 0; c < columns; ++c) { AXPlatformNodeBase* cell = GetTableCell(r, c); - if (cell && cell->GetData().HasState(AX_STATE_SELECTED)) + if (cell && cell->GetData().HasState(ax::mojom::State::kSelected)) selected.push_back(cell); } } @@ -1901,7 +1913,7 @@ STDMETHODIMP AXPlatformNodeWin::get_columnHeaderCells( return E_INVALIDARG; *n_column_header_cells = 0; - if (GetData().role != AX_ROLE_CELL) + if (GetData().role != ax::mojom::Role::kCell) return S_FALSE; AXPlatformNodeBase* table = GetTable(); @@ -1917,7 +1929,7 @@ STDMETHODIMP AXPlatformNodeWin::get_columnHeaderCells( for (int r = 0; r < rows; ++r) { AXPlatformNodeBase* cell = GetTableCell(r, column); - if (cell && cell->GetData().role == AX_ROLE_COLUMN_HEADER) + if (cell && cell->GetData().role == ax::mojom::Role::kColumnHeader) (*n_column_header_cells)++; } @@ -1926,7 +1938,7 @@ STDMETHODIMP AXPlatformNodeWin::get_columnHeaderCells( int index = 0; for (int r = 0; r < rows; ++r) { AXPlatformNodeBase* cell = GetTableCell(r, column); - if (cell && cell->GetData().role == AX_ROLE_COLUMN_HEADER) { + if (cell && cell->GetData().role == ax::mojom::Role::kColumnHeader) { auto* node_win = static_cast(cell); node_win->AddRef(); @@ -1969,7 +1981,7 @@ STDMETHODIMP AXPlatformNodeWin::get_rowHeaderCells(IUnknown*** cell_accessibles, return E_INVALIDARG; *n_row_header_cells = 0; - if (GetData().role != AX_ROLE_CELL) + if (GetData().role != ax::mojom::Role::kCell) return S_FALSE; AXPlatformNodeBase* table = GetTable(); @@ -1985,7 +1997,7 @@ STDMETHODIMP AXPlatformNodeWin::get_rowHeaderCells(IUnknown*** cell_accessibles, for (int c = 0; c < columns; ++c) { AXPlatformNodeBase* cell = GetTableCell(row, c); - if (cell && cell->GetData().role == AX_ROLE_ROW_HEADER) + if (cell && cell->GetData().role == ax::mojom::Role::kRowHeader) (*n_row_header_cells)++; } @@ -1994,7 +2006,7 @@ STDMETHODIMP AXPlatformNodeWin::get_rowHeaderCells(IUnknown*** cell_accessibles, int index = 0; for (int c = 0; c < columns; ++c) { AXPlatformNodeBase* cell = GetTableCell(row, c); - if (cell && cell->GetData().role == AX_ROLE_ROW_HEADER) { + if (cell && cell->GetData().role == ax::mojom::Role::kRowHeader) { auto* node_win = static_cast(cell); node_win->AddRef(); @@ -2284,7 +2296,7 @@ STDMETHODIMP AXPlatformNodeWin::removeSelection(LONG selection_index) { return E_INVALIDARG; // Simply collapse the selection to the position of the caret if a caret is // visible, otherwise set the selection to 0. - return setCaretOffset(GetIntAttribute(AX_ATTR_TEXT_SEL_END)); + return setCaretOffset(GetIntAttribute(ax::mojom::IntAttribute::kTextSelEnd)); } STDMETHODIMP AXPlatformNodeWin::setCaretOffset(LONG offset) { @@ -2394,314 +2406,316 @@ int AXPlatformNodeWin::MSAARole() { return ROLE_SYSTEM_GROUPING; switch (GetData().role) { - case AX_ROLE_ALERT: + case ax::mojom::Role::kAlert: return ROLE_SYSTEM_ALERT; - case AX_ROLE_ALERT_DIALOG: + case ax::mojom::Role::kAlertDialog: return ROLE_SYSTEM_DIALOG; - case AX_ROLE_ANCHOR: + case ax::mojom::Role::kAnchor: return ROLE_SYSTEM_LINK; - case AX_ROLE_APPLICATION: + case ax::mojom::Role::kApplication: return ROLE_SYSTEM_APPLICATION; - case AX_ROLE_ARTICLE: + case ax::mojom::Role::kArticle: return ROLE_SYSTEM_DOCUMENT; - case AX_ROLE_AUDIO: + case ax::mojom::Role::kAudio: return ROLE_SYSTEM_GROUPING; - case AX_ROLE_BANNER: + case ax::mojom::Role::kBanner: return ROLE_SYSTEM_GROUPING; - case AX_ROLE_BUTTON: + case ax::mojom::Role::kButton: return ROLE_SYSTEM_PUSHBUTTON; - case AX_ROLE_CANVAS: + case ax::mojom::Role::kCanvas: return ROLE_SYSTEM_GRAPHIC; - case AX_ROLE_CAPTION: + case ax::mojom::Role::kCaption: return ROLE_SYSTEM_TEXT; - case AX_ROLE_CELL: + case ax::mojom::Role::kCell: return ROLE_SYSTEM_CELL; - case AX_ROLE_CHECK_BOX: + case ax::mojom::Role::kCheckBox: return ROLE_SYSTEM_CHECKBUTTON; - case AX_ROLE_COLOR_WELL: + case ax::mojom::Role::kColorWell: return ROLE_SYSTEM_TEXT; - case AX_ROLE_COLUMN: + case ax::mojom::Role::kColumn: return ROLE_SYSTEM_COLUMN; - case AX_ROLE_COLUMN_HEADER: + case ax::mojom::Role::kColumnHeader: return ROLE_SYSTEM_COLUMNHEADER; - case AX_ROLE_COMBO_BOX_GROUPING: - case AX_ROLE_COMBO_BOX_MENU_BUTTON: + case ax::mojom::Role::kComboBoxGrouping: + case ax::mojom::Role::kComboBoxMenuButton: return ROLE_SYSTEM_COMBOBOX; - case AX_ROLE_COMPLEMENTARY: + case ax::mojom::Role::kComplementary: return ROLE_SYSTEM_GROUPING; - case AX_ROLE_CONTENT_INFO: + case ax::mojom::Role::kContentInfo: return ROLE_SYSTEM_TEXT; - case AX_ROLE_DATE: - case AX_ROLE_DATE_TIME: + case ax::mojom::Role::kDate: + case ax::mojom::Role::kDateTime: return ROLE_SYSTEM_DROPLIST; - case AX_ROLE_DESCRIPTION_LIST_DETAIL: + case ax::mojom::Role::kDescriptionListDetail: return ROLE_SYSTEM_TEXT; - case AX_ROLE_DESCRIPTION_LIST: + case ax::mojom::Role::kDescriptionList: return ROLE_SYSTEM_LIST; - case AX_ROLE_DESCRIPTION_LIST_TERM: + case ax::mojom::Role::kDescriptionListTerm: return ROLE_SYSTEM_LISTITEM; - case AX_ROLE_DETAILS: + case ax::mojom::Role::kDetails: return ROLE_SYSTEM_GROUPING; - case AX_ROLE_DIALOG: + case ax::mojom::Role::kDialog: return ROLE_SYSTEM_DIALOG; - case AX_ROLE_DISCLOSURE_TRIANGLE: + case ax::mojom::Role::kDisclosureTriangle: return ROLE_SYSTEM_PUSHBUTTON; - case AX_ROLE_DOCUMENT: - case AX_ROLE_ROOT_WEB_AREA: - case AX_ROLE_WEB_AREA: + case ax::mojom::Role::kDocument: + case ax::mojom::Role::kRootWebArea: + case ax::mojom::Role::kWebArea: return ROLE_SYSTEM_DOCUMENT; - case AX_ROLE_EMBEDDED_OBJECT: + case ax::mojom::Role::kEmbeddedObject: if (delegate_->GetChildCount()) { return ROLE_SYSTEM_GROUPING; } else { return ROLE_SYSTEM_CLIENT; } - case AX_ROLE_FIGURE: + case ax::mojom::Role::kFigure: return ROLE_SYSTEM_GROUPING; - case AX_ROLE_FEED: + case ax::mojom::Role::kFeed: return ROLE_SYSTEM_GROUPING; - case AX_ROLE_GENERIC_CONTAINER: + case ax::mojom::Role::kGenericContainer: return ROLE_SYSTEM_GROUPING; - case AX_ROLE_GRID: + case ax::mojom::Role::kGrid: return ROLE_SYSTEM_TABLE; - case AX_ROLE_GROUP: + case ax::mojom::Role::kGroup: return ROLE_SYSTEM_GROUPING; - case AX_ROLE_HEADING: + case ax::mojom::Role::kHeading: return ROLE_SYSTEM_GROUPING; - case AX_ROLE_IFRAME: + case ax::mojom::Role::kIframe: return ROLE_SYSTEM_DOCUMENT; - case AX_ROLE_IFRAME_PRESENTATIONAL: + case ax::mojom::Role::kIframePresentational: return ROLE_SYSTEM_GROUPING; - case AX_ROLE_IMAGE: + case ax::mojom::Role::kImage: return ROLE_SYSTEM_GRAPHIC; - case AX_ROLE_INPUT_TIME: + case ax::mojom::Role::kInputTime: return ROLE_SYSTEM_GROUPING; - case AX_ROLE_LABEL_TEXT: - case AX_ROLE_LEGEND: + case ax::mojom::Role::kLabelText: + case ax::mojom::Role::kLegend: return ROLE_SYSTEM_TEXT; - case AX_ROLE_LINK: + case ax::mojom::Role::kLink: return ROLE_SYSTEM_LINK; - case AX_ROLE_LIST: + case ax::mojom::Role::kList: return ROLE_SYSTEM_LIST; - case AX_ROLE_LIST_BOX: + case ax::mojom::Role::kListBox: return ROLE_SYSTEM_LIST; - case AX_ROLE_LIST_BOX_OPTION: + case ax::mojom::Role::kListBoxOption: return ROLE_SYSTEM_LISTITEM; - case AX_ROLE_LIST_ITEM: + case ax::mojom::Role::kListItem: return ROLE_SYSTEM_LISTITEM; - case AX_ROLE_MAIN: + case ax::mojom::Role::kMain: return ROLE_SYSTEM_GROUPING; - case AX_ROLE_MARK: + case ax::mojom::Role::kMark: return ROLE_SYSTEM_TEXT; - case AX_ROLE_MARQUEE: + case ax::mojom::Role::kMarquee: return ROLE_SYSTEM_ANIMATION; - case AX_ROLE_MATH: + case ax::mojom::Role::kMath: return ROLE_SYSTEM_EQUATION; - case AX_ROLE_MENU: - case AX_ROLE_MENU_BUTTON: + case ax::mojom::Role::kMenu: + case ax::mojom::Role::kMenuButton: return ROLE_SYSTEM_MENUPOPUP; - case AX_ROLE_MENU_BAR: + case ax::mojom::Role::kMenuBar: return ROLE_SYSTEM_MENUBAR; - case AX_ROLE_MENU_ITEM: + case ax::mojom::Role::kMenuItem: return ROLE_SYSTEM_MENUITEM; - case AX_ROLE_MENU_ITEM_CHECK_BOX: + case ax::mojom::Role::kMenuItemCheckBox: return ROLE_SYSTEM_MENUITEM; - case AX_ROLE_MENU_ITEM_RADIO: + case ax::mojom::Role::kMenuItemRadio: return ROLE_SYSTEM_MENUITEM; - case ui::AX_ROLE_MENU_LIST_POPUP: + case ax::mojom::Role::kMenuListPopup: if (IsAncestorComboBox()) return ROLE_SYSTEM_LIST; return ROLE_SYSTEM_MENUPOPUP; - case ui::AX_ROLE_MENU_LIST_OPTION: + case ax::mojom::Role::kMenuListOption: if (IsAncestorComboBox()) return ROLE_SYSTEM_LISTITEM; return ROLE_SYSTEM_MENUITEM; - case AX_ROLE_METER: + case ax::mojom::Role::kMeter: return ROLE_SYSTEM_PROGRESSBAR; - case AX_ROLE_NAVIGATION: + case ax::mojom::Role::kNavigation: return ROLE_SYSTEM_GROUPING; - case AX_ROLE_NOTE: + case ax::mojom::Role::kNote: return ROLE_SYSTEM_GROUPING; - case AX_ROLE_POP_UP_BUTTON: { - std::string html_tag = GetData().GetStringAttribute(AX_ATTR_HTML_TAG); + case ax::mojom::Role::kPopUpButton: { + std::string html_tag = + GetData().GetStringAttribute(ax::mojom::StringAttribute::kHtmlTag); if (html_tag == "select") return ROLE_SYSTEM_COMBOBOX; return ROLE_SYSTEM_BUTTONMENU; } - case AX_ROLE_PRE: + case ax::mojom::Role::kPre: return ROLE_SYSTEM_TEXT; - case AX_ROLE_PROGRESS_INDICATOR: + case ax::mojom::Role::kProgressIndicator: return ROLE_SYSTEM_PROGRESSBAR; - case AX_ROLE_RADIO_BUTTON: + case ax::mojom::Role::kRadioButton: return ROLE_SYSTEM_RADIOBUTTON; - case AX_ROLE_RADIO_GROUP: + case ax::mojom::Role::kRadioGroup: return ROLE_SYSTEM_GROUPING; - case AX_ROLE_REGION: { - std::string html_tag = GetData().GetStringAttribute(AX_ATTR_HTML_TAG); + case ax::mojom::Role::kRegion: { + std::string html_tag = + GetData().GetStringAttribute(ax::mojom::StringAttribute::kHtmlTag); if (html_tag == "section") return ROLE_SYSTEM_GROUPING; return ROLE_SYSTEM_PANE; } - case AX_ROLE_ROW: { + case ax::mojom::Role::kRow: { // Role changes depending on whether row is inside a treegrid // https://www.w3.org/TR/core-aam-1.1/#role-map-row return IsInTreeGrid() ? ROLE_SYSTEM_OUTLINEITEM : ROLE_SYSTEM_ROW; } - case AX_ROLE_ROW_HEADER: + case ax::mojom::Role::kRowHeader: return ROLE_SYSTEM_ROWHEADER; - case AX_ROLE_RUBY: + case ax::mojom::Role::kRuby: return ROLE_SYSTEM_TEXT; - case AX_ROLE_SCROLL_BAR: + case ax::mojom::Role::kScrollBar: return ROLE_SYSTEM_SCROLLBAR; - case AX_ROLE_SEARCH: + case ax::mojom::Role::kSearch: return ROLE_SYSTEM_GROUPING; - case AX_ROLE_SLIDER: + case ax::mojom::Role::kSlider: return ROLE_SYSTEM_SLIDER; - case AX_ROLE_SPIN_BUTTON: + case ax::mojom::Role::kSpinButton: return ROLE_SYSTEM_SPINBUTTON; - case AX_ROLE_SPIN_BUTTON_PART: + case ax::mojom::Role::kSpinButtonPart: return ROLE_SYSTEM_PUSHBUTTON; - case AX_ROLE_ANNOTATION: - case AX_ROLE_LIST_MARKER: - case AX_ROLE_STATIC_TEXT: + case ax::mojom::Role::kAnnotation: + case ax::mojom::Role::kListMarker: + case ax::mojom::Role::kStaticText: return ROLE_SYSTEM_STATICTEXT; - case AX_ROLE_STATUS: + case ax::mojom::Role::kStatus: return ROLE_SYSTEM_STATUSBAR; - case AX_ROLE_SPLITTER: + case ax::mojom::Role::kSplitter: return ROLE_SYSTEM_SEPARATOR; - case AX_ROLE_SVG_ROOT: + case ax::mojom::Role::kSvgRoot: return ROLE_SYSTEM_GRAPHIC; - case AX_ROLE_TAB: + case ax::mojom::Role::kTab: return ROLE_SYSTEM_PAGETAB; - case AX_ROLE_TABLE: + case ax::mojom::Role::kTable: return ROLE_SYSTEM_TABLE; - case AX_ROLE_TABLE_HEADER_CONTAINER: + case ax::mojom::Role::kTableHeaderContainer: return ROLE_SYSTEM_GROUPING; - case AX_ROLE_TAB_LIST: + case ax::mojom::Role::kTabList: return ROLE_SYSTEM_PAGETABLIST; - case AX_ROLE_TAB_PANEL: + case ax::mojom::Role::kTabPanel: return ROLE_SYSTEM_PROPERTYPAGE; - case AX_ROLE_TERM: + case ax::mojom::Role::kTerm: return ROLE_SYSTEM_LISTITEM; - case AX_ROLE_TOGGLE_BUTTON: + case ax::mojom::Role::kToggleButton: return ROLE_SYSTEM_PUSHBUTTON; - case AX_ROLE_TEXT_FIELD: - case AX_ROLE_SEARCH_BOX: + case ax::mojom::Role::kTextField: + case ax::mojom::Role::kSearchBox: return ROLE_SYSTEM_TEXT; - case AX_ROLE_TEXT_FIELD_WITH_COMBO_BOX: + case ax::mojom::Role::kTextFieldWithComboBox: return ROLE_SYSTEM_COMBOBOX; - case AX_ROLE_ABBR: - case AX_ROLE_TIME: + case ax::mojom::Role::kAbbr: + case ax::mojom::Role::kTime: return ROLE_SYSTEM_TEXT; - case AX_ROLE_TIMER: + case ax::mojom::Role::kTimer: return ROLE_SYSTEM_CLOCK; - case AX_ROLE_TOOLBAR: + case ax::mojom::Role::kToolbar: return ROLE_SYSTEM_TOOLBAR; - case AX_ROLE_TOOLTIP: + case ax::mojom::Role::kTooltip: return ROLE_SYSTEM_TOOLTIP; - case AX_ROLE_TREE: + case ax::mojom::Role::kTree: return ROLE_SYSTEM_OUTLINE; - case AX_ROLE_TREE_GRID: + case ax::mojom::Role::kTreeGrid: return ROLE_SYSTEM_OUTLINE; - case AX_ROLE_TREE_ITEM: + case ax::mojom::Role::kTreeItem: return ROLE_SYSTEM_OUTLINEITEM; - case AX_ROLE_LINE_BREAK: + case ax::mojom::Role::kLineBreak: return ROLE_SYSTEM_WHITESPACE; - case AX_ROLE_VIDEO: + case ax::mojom::Role::kVideo: return ROLE_SYSTEM_GROUPING; - case AX_ROLE_WINDOW: + case ax::mojom::Role::kWindow: // Do not return ROLE_SYSTEM_WINDOW as that is a special MSAA system role // used to indicate a real native window object. It is automatically // created by oleacc.dll as a parent of the root of our hierarchy, @@ -2709,29 +2723,29 @@ int AXPlatformNodeWin::MSAARole() { return ROLE_SYSTEM_PANE; // TODO(dmazzoni): figure out the proper MSAA role for roles listed below. - case AX_ROLE_BLOCKQUOTE: - case AX_ROLE_CARET: - case AX_ROLE_CLIENT: - case AX_ROLE_DEFINITION: - case AX_ROLE_DESKTOP: - case AX_ROLE_DIRECTORY: - case AX_ROLE_FIGCAPTION: - case AX_ROLE_FOOTER: - case AX_ROLE_FORM: - case AX_ROLE_IGNORED: - case AX_ROLE_IMAGE_MAP: - case AX_ROLE_INLINE_TEXT_BOX: - case AX_ROLE_LOCATION_BAR: - case AX_ROLE_LOG: - case AX_ROLE_NONE: - case AX_ROLE_PANE: - case AX_ROLE_PARAGRAPH: - case AX_ROLE_PRESENTATIONAL: - case AX_ROLE_SLIDER_THUMB: - case AX_ROLE_SWITCH: - case AX_ROLE_TITLE_BAR: - case AX_ROLE_UNKNOWN: - case AX_ROLE_WEB_VIEW: + case ax::mojom::Role::kBlockquote: + case ax::mojom::Role::kCaret: + case ax::mojom::Role::kClient: + case ax::mojom::Role::kDefinition: + case ax::mojom::Role::kDesktop: + case ax::mojom::Role::kDirectory: + case ax::mojom::Role::kFigcaption: + case ax::mojom::Role::kFooter: + case ax::mojom::Role::kForm: + case ax::mojom::Role::kIgnored: + case ax::mojom::Role::kImageMap: + case ax::mojom::Role::kInlineTextBox: + case ax::mojom::Role::kLocationBar: + case ax::mojom::Role::kLog: + case ax::mojom::Role::kNone: + case ax::mojom::Role::kPane: + case ax::mojom::Role::kParagraph: + case ax::mojom::Role::kPresentational: + case ax::mojom::Role::kSliderThumb: + case ax::mojom::Role::kSwitch: + case ax::mojom::Role::kTitleBar: + case ax::mojom::Role::kUnknown: + case ax::mojom::Role::kWebView: return ROLE_SYSTEM_CLIENT; } @@ -2740,40 +2754,42 @@ int AXPlatformNodeWin::MSAARole() { } std::string AXPlatformNodeWin::StringOverrideForMSAARole() { - std::string html_tag = GetData().GetStringAttribute(AX_ATTR_HTML_TAG); + std::string html_tag = + GetData().GetStringAttribute(ax::mojom::StringAttribute::kHtmlTag); switch (GetData().role) { - case AX_ROLE_BLOCKQUOTE: - case AX_ROLE_DEFINITION: - case AX_ROLE_IMAGE_MAP: + case ax::mojom::Role::kBlockquote: + case ax::mojom::Role::kDefinition: + case ax::mojom::Role::kImageMap: return html_tag; - case AX_ROLE_CANVAS: - if (GetData().GetBoolAttribute(AX_ATTR_CANVAS_HAS_FALLBACK)) { + case ax::mojom::Role::kCanvas: + if (GetData().GetBoolAttribute( + ax::mojom::BoolAttribute::kCanvasHasFallback)) { return html_tag; } break; - case AX_ROLE_FORM: + case ax::mojom::Role::kForm: // This could be a div with the role of form // so we return just the string "form". return "form"; - case AX_ROLE_HEADING: + case ax::mojom::Role::kHeading: if (!html_tag.empty()) return html_tag; break; - case AX_ROLE_PARAGRAPH: + case ax::mojom::Role::kParagraph: return html_tag; - case AX_ROLE_GENERIC_CONTAINER: + case ax::mojom::Role::kGenericContainer: // TODO(dougt) why can't we always use div in this case? if (html_tag.empty()) return "div"; return html_tag; - case AX_ROLE_SWITCH: + case ax::mojom::Role::kSwitch: return "switch"; default: @@ -2784,8 +2800,8 @@ std::string AXPlatformNodeWin::StringOverrideForMSAARole() { } bool AXPlatformNodeWin::IsWebAreaForPresentationalIframe() { - if (GetData().role != AX_ROLE_WEB_AREA && - GetData().role != AX_ROLE_ROOT_WEB_AREA) { + if (GetData().role != ax::mojom::Role::kWebArea && + GetData().role != ax::mojom::Role::kRootWebArea) { return false; } @@ -2793,7 +2809,7 @@ bool AXPlatformNodeWin::IsWebAreaForPresentationalIframe() { if (!parent) return false; - return parent->GetData().role == AX_ROLE_IFRAME_PRESENTATIONAL; + return parent->GetData().role == ax::mojom::Role::kIframePresentational; } int32_t AXPlatformNodeWin::ComputeIA2State() { @@ -2801,26 +2817,26 @@ int32_t AXPlatformNodeWin::ComputeIA2State() { int32_t ia2_state = IA2_STATE_OPAQUE; const auto checked_state = data.GetCheckedState(); - if (checked_state != ui::AX_CHECKED_STATE_NONE) { + if (checked_state != ax::mojom::CheckedState::kNone) { ia2_state |= IA2_STATE_CHECKABLE; } - if (HasIntAttribute(AX_ATTR_INVALID_STATE) && - GetIntAttribute(AX_ATTR_INVALID_STATE) != - static_cast(AX_INVALID_STATE_FALSE)) + if (HasIntAttribute(ax::mojom::IntAttribute::kInvalidState) && + GetIntAttribute(ax::mojom::IntAttribute::kInvalidState) != + static_cast(ax::mojom::InvalidState::kFalse)) ia2_state |= IA2_STATE_INVALID_ENTRY; - if (data.HasState(AX_STATE_REQUIRED)) + if (data.HasState(ax::mojom::State::kRequired)) ia2_state |= IA2_STATE_REQUIRED; - if (data.HasState(AX_STATE_VERTICAL)) + if (data.HasState(ax::mojom::State::kVertical)) ia2_state |= IA2_STATE_VERTICAL; - if (data.HasState(AX_STATE_HORIZONTAL)) + if (data.HasState(ax::mojom::State::kHorizontal)) ia2_state |= IA2_STATE_HORIZONTAL; - if (data.HasState(AX_STATE_EDITABLE)) + if (data.HasState(ax::mojom::State::kEditable)) ia2_state |= IA2_STATE_EDITABLE; if (IsPlainTextField() || IsRichTextField()) { - if (data.HasState(AX_STATE_MULTILINE)) { + if (data.HasState(ax::mojom::State::kMultiline)) { ia2_state |= IA2_STATE_MULTI_LINE; } else { ia2_state |= IA2_STATE_SINGLE_LINE; @@ -2828,15 +2844,15 @@ int32_t AXPlatformNodeWin::ComputeIA2State() { ia2_state |= IA2_STATE_SELECTABLE_TEXT; } - if (!GetStringAttribute(AX_ATTR_AUTO_COMPLETE).empty()) + if (!GetStringAttribute(ax::mojom::StringAttribute::kAutoComplete).empty()) ia2_state |= IA2_STATE_SUPPORTS_AUTOCOMPLETION; - if (GetBoolAttribute(AX_ATTR_MODAL)) + if (GetBoolAttribute(ax::mojom::BoolAttribute::kModal)) ia2_state |= IA2_STATE_MODAL; switch (data.role) { - case AX_ROLE_MENU_LIST_POPUP: - case AX_ROLE_MENU_LIST_OPTION: + case ax::mojom::Role::kMenuListPopup: + case ax::mojom::Role::kMenuListOption: ia2_state &= ~(IA2_STATE_EDITABLE); break; default: @@ -2858,117 +2874,118 @@ int32_t AXPlatformNodeWin::ComputeIA2Role() { int32_t ia2_role = 0; switch (GetData().role) { - case AX_ROLE_BANNER: + case ax::mojom::Role::kBanner: ia2_role = IA2_ROLE_HEADER; break; - case AX_ROLE_BLOCKQUOTE: + case ax::mojom::Role::kBlockquote: ia2_role = IA2_ROLE_SECTION; break; - case AX_ROLE_CANVAS: - if (GetBoolAttribute(AX_ATTR_CANVAS_HAS_FALLBACK)) { + case ax::mojom::Role::kCanvas: + if (GetBoolAttribute(ax::mojom::BoolAttribute::kCanvasHasFallback)) { ia2_role = IA2_ROLE_CANVAS; } break; - case AX_ROLE_CAPTION: + case ax::mojom::Role::kCaption: ia2_role = IA2_ROLE_CAPTION; break; - case AX_ROLE_COLOR_WELL: + case ax::mojom::Role::kColorWell: ia2_role = IA2_ROLE_COLOR_CHOOSER; break; - case AX_ROLE_COMPLEMENTARY: + case ax::mojom::Role::kComplementary: ia2_role = IA2_ROLE_NOTE; break; - case AX_ROLE_CONTENT_INFO: + case ax::mojom::Role::kContentInfo: ia2_role = IA2_ROLE_PARAGRAPH; break; - case AX_ROLE_DATE: - case AX_ROLE_DATE_TIME: + case ax::mojom::Role::kDate: + case ax::mojom::Role::kDateTime: ia2_role = IA2_ROLE_DATE_EDITOR; break; - case AX_ROLE_DEFINITION: + case ax::mojom::Role::kDefinition: ia2_role = IA2_ROLE_PARAGRAPH; break; - case AX_ROLE_DESCRIPTION_LIST_DETAIL: + case ax::mojom::Role::kDescriptionListDetail: ia2_role = IA2_ROLE_PARAGRAPH; break; - case AX_ROLE_EMBEDDED_OBJECT: + case ax::mojom::Role::kEmbeddedObject: if (!delegate_->GetChildCount()) { ia2_role = IA2_ROLE_EMBEDDED_OBJECT; } break; - case AX_ROLE_FIGCAPTION: + case ax::mojom::Role::kFigcaption: ia2_role = IA2_ROLE_CAPTION; break; - case AX_ROLE_FORM: + case ax::mojom::Role::kForm: ia2_role = IA2_ROLE_FORM; break; - case AX_ROLE_FOOTER: + case ax::mojom::Role::kFooter: ia2_role = IA2_ROLE_FOOTER; break; - case AX_ROLE_GENERIC_CONTAINER: + case ax::mojom::Role::kGenericContainer: ia2_role = IA2_ROLE_SECTION; break; - case AX_ROLE_HEADING: + case ax::mojom::Role::kHeading: ia2_role = IA2_ROLE_HEADING; break; - case AX_ROLE_IFRAME: + case ax::mojom::Role::kIframe: ia2_role = IA2_ROLE_INTERNAL_FRAME; break; - case AX_ROLE_IMAGE_MAP: + case ax::mojom::Role::kImageMap: ia2_role = IA2_ROLE_IMAGE_MAP; break; - case AX_ROLE_LABEL_TEXT: - case AX_ROLE_LEGEND: + case ax::mojom::Role::kLabelText: + case ax::mojom::Role::kLegend: ia2_role = IA2_ROLE_LABEL; break; - case AX_ROLE_MAIN: + case ax::mojom::Role::kMain: ia2_role = IA2_ROLE_PARAGRAPH; break; - case AX_ROLE_MARK: + case ax::mojom::Role::kMark: ia2_role = IA2_ROLE_TEXT_FRAME; break; - case AX_ROLE_MENU_ITEM_CHECK_BOX: + case ax::mojom::Role::kMenuItemCheckBox: ia2_role = IA2_ROLE_CHECK_MENU_ITEM; break; - case AX_ROLE_MENU_ITEM_RADIO: + case ax::mojom::Role::kMenuItemRadio: ia2_role = IA2_ROLE_RADIO_MENU_ITEM; break; - case AX_ROLE_NAVIGATION: + case ax::mojom::Role::kNavigation: ia2_role = IA2_ROLE_SECTION; break; - case AX_ROLE_NOTE: + case ax::mojom::Role::kNote: ia2_role = IA2_ROLE_NOTE; break; - case AX_ROLE_PARAGRAPH: + case ax::mojom::Role::kParagraph: ia2_role = IA2_ROLE_PARAGRAPH; break; - case AX_ROLE_PRE: + case ax::mojom::Role::kPre: ia2_role = IA2_ROLE_PARAGRAPH; break; - case AX_ROLE_REGION: { - base::string16 html_tag = GetString16Attribute(AX_ATTR_HTML_TAG); + case ax::mojom::Role::kRegion: { + base::string16 html_tag = + GetString16Attribute(ax::mojom::StringAttribute::kHtmlTag); if (html_tag == L"section") { ia2_role = IA2_ROLE_SECTION; } } break; - case AX_ROLE_RUBY: + case ax::mojom::Role::kRuby: ia2_role = IA2_ROLE_TEXT_FRAME; break; - case AX_ROLE_SEARCH: + case ax::mojom::Role::kSearch: ia2_role = IA2_ROLE_SECTION; break; - case AX_ROLE_SWITCH: + case ax::mojom::Role::kSwitch: ia2_role = IA2_ROLE_TOGGLE_BUTTON; break; - case AX_ROLE_TABLE_HEADER_CONTAINER: + case ax::mojom::Role::kTableHeaderContainer: ia2_role = IA2_ROLE_SECTION; break; - case AX_ROLE_TOGGLE_BUTTON: + case ax::mojom::Role::kToggleButton: ia2_role = IA2_ROLE_TOGGLE_BUTTON; break; - case AX_ROLE_ABBR: - case AX_ROLE_TIME: + case ax::mojom::Role::kAbbr: + case ax::mojom::Role::kTime: ia2_role = IA2_ROLE_TEXT_FRAME; break; default: @@ -2984,71 +3001,82 @@ std::vector AXPlatformNodeWin::ComputeIA2Attributes() { // historical reasons. Aside from that virtually every ARIA attribute // is exposed in a really straightforward way, i.e. "aria-foo" is exposed // as "foo". - StringAttributeToIA2(result, AX_ATTR_DISPLAY, "display"); - StringAttributeToIA2(result, AX_ATTR_HTML_TAG, "tag"); - StringAttributeToIA2(result, AX_ATTR_ROLE, "xml-roles"); - StringAttributeToIA2(result, AX_ATTR_PLACEHOLDER, "placeholder"); - - StringAttributeToIA2(result, AX_ATTR_AUTO_COMPLETE, "autocomplete"); - StringAttributeToIA2(result, AX_ATTR_ROLE_DESCRIPTION, "roledescription"); - StringAttributeToIA2(result, AX_ATTR_KEY_SHORTCUTS, "keyshortcuts"); - - IntAttributeToIA2(result, AX_ATTR_HIERARCHICAL_LEVEL, "level"); - IntAttributeToIA2(result, AX_ATTR_SET_SIZE, "setsize"); - IntAttributeToIA2(result, AX_ATTR_POS_IN_SET, "posinset"); - - if (HasIntAttribute(AX_ATTR_CHECKED_STATE)) + StringAttributeToIA2(result, ax::mojom::StringAttribute::kDisplay, "display"); + StringAttributeToIA2(result, ax::mojom::StringAttribute::kHtmlTag, "tag"); + StringAttributeToIA2(result, ax::mojom::StringAttribute::kRole, "xml-roles"); + StringAttributeToIA2(result, ax::mojom::StringAttribute::kPlaceholder, + "placeholder"); + + StringAttributeToIA2(result, ax::mojom::StringAttribute::kAutoComplete, + "autocomplete"); + StringAttributeToIA2(result, ax::mojom::StringAttribute::kRoleDescription, + "roledescription"); + StringAttributeToIA2(result, ax::mojom::StringAttribute::kKeyShortcuts, + "keyshortcuts"); + + IntAttributeToIA2(result, ax::mojom::IntAttribute::kHierarchicalLevel, + "level"); + IntAttributeToIA2(result, ax::mojom::IntAttribute::kSetSize, "setsize"); + IntAttributeToIA2(result, ax::mojom::IntAttribute::kPosInSet, "posinset"); + + if (HasIntAttribute(ax::mojom::IntAttribute::kCheckedState)) result.push_back(L"checkable:true"); // Expose live region attributes. - StringAttributeToIA2(result, AX_ATTR_LIVE_STATUS, "live"); - StringAttributeToIA2(result, AX_ATTR_LIVE_RELEVANT, "relevant"); - BoolAttributeToIA2(result, AX_ATTR_LIVE_ATOMIC, "atomic"); + StringAttributeToIA2(result, ax::mojom::StringAttribute::kLiveStatus, "live"); + StringAttributeToIA2(result, ax::mojom::StringAttribute::kLiveRelevant, + "relevant"); + BoolAttributeToIA2(result, ax::mojom::BoolAttribute::kLiveAtomic, "atomic"); // Busy is usually associated with live regions but can occur anywhere: - BoolAttributeToIA2(result, AX_ATTR_BUSY, "busy"); + BoolAttributeToIA2(result, ax::mojom::BoolAttribute::kBusy, "busy"); // Expose container live region attributes. - StringAttributeToIA2(result, AX_ATTR_CONTAINER_LIVE_STATUS, "container-live"); - StringAttributeToIA2(result, AX_ATTR_CONTAINER_LIVE_RELEVANT, + StringAttributeToIA2(result, ax::mojom::StringAttribute::kContainerLiveStatus, + "container-live"); + StringAttributeToIA2(result, + ax::mojom::StringAttribute::kContainerLiveRelevant, "container-relevant"); - BoolAttributeToIA2(result, AX_ATTR_CONTAINER_LIVE_ATOMIC, "container-atomic"); - BoolAttributeToIA2(result, AX_ATTR_CONTAINER_LIVE_BUSY, "container-busy"); + BoolAttributeToIA2(result, ax::mojom::BoolAttribute::kContainerLiveAtomic, + "container-atomic"); + BoolAttributeToIA2(result, ax::mojom::BoolAttribute::kContainerLiveBusy, + "container-busy"); // Expose the non-standard explicit-name IA2 attribute. int name_from; - if (GetIntAttribute(AX_ATTR_NAME_FROM, &name_from) && - name_from != static_cast(AX_NAME_FROM_CONTENTS)) { + if (GetIntAttribute(ax::mojom::IntAttribute::kNameFrom, &name_from) && + name_from != static_cast(ax::mojom::NameFrom::kContents)) { result.push_back(L"explicit-name:true"); } // Expose the aria-current attribute. int32_t aria_current_state; - if (GetIntAttribute(AX_ATTR_ARIA_CURRENT_STATE, &aria_current_state)) { - switch (static_cast(aria_current_state)) { - case AX_ARIA_CURRENT_STATE_NONE: + if (GetIntAttribute(ax::mojom::IntAttribute::kAriaCurrentState, + &aria_current_state)) { + switch (static_cast(aria_current_state)) { + case ax::mojom::AriaCurrentState::kNone: break; - case AX_ARIA_CURRENT_STATE_FALSE: + case ax::mojom::AriaCurrentState::kFalse: result.push_back(L"current:false"); break; - case AX_ARIA_CURRENT_STATE_TRUE: + case ax::mojom::AriaCurrentState::kTrue: result.push_back(L"current:true"); break; - case AX_ARIA_CURRENT_STATE_PAGE: + case ax::mojom::AriaCurrentState::kPage: result.push_back(L"current:page"); break; - case AX_ARIA_CURRENT_STATE_STEP: + case ax::mojom::AriaCurrentState::kStep: result.push_back(L"current:step"); break; - case AX_ARIA_CURRENT_STATE_LOCATION: + case ax::mojom::AriaCurrentState::kLocation: result.push_back(L"current:location"); break; - case AX_ARIA_CURRENT_STATE_UNCLIPPED_LOCATION: + case ax::mojom::AriaCurrentState::kUnclippedLocation: result.push_back(L"current:unclippedLocation"); break; - case AX_ARIA_CURRENT_STATE_DATE: + case ax::mojom::AriaCurrentState::kDate: result.push_back(L"current:date"); break; - case AX_ARIA_CURRENT_STATE_TIME: + case ax::mojom::AriaCurrentState::kTime: result.push_back(L"current:time"); break; } @@ -3062,8 +3090,8 @@ std::vector AXPlatformNodeWin::ComputeIA2Attributes() { table = FromNativeViewAccessible(table->GetParent()); if (table) { - const std::vector& unique_cell_ids = - table->GetIntListAttribute(AX_ATTR_UNIQUE_CELL_IDS); + const std::vector& unique_cell_ids = table->GetIntListAttribute( + ax::mojom::IntListAttribute::kUniqueCellIds); for (size_t i = 0; i < unique_cell_ids.size(); ++i) { if (unique_cell_ids[i] == GetData().id) { result.push_back(base::string16(L"table-cell-index:") + @@ -3075,16 +3103,20 @@ std::vector AXPlatformNodeWin::ComputeIA2Attributes() { // Expose aria-colcount and aria-rowcount in a table, grid or treegrid. if (IsTableLikeRole(GetData().role)) { - IntAttributeToIA2(result, AX_ATTR_ARIA_COLUMN_COUNT, "colcount"); - IntAttributeToIA2(result, AX_ATTR_ARIA_ROW_COUNT, "rowcount"); + IntAttributeToIA2(result, ax::mojom::IntAttribute::kAriaColumnCount, + "colcount"); + IntAttributeToIA2(result, ax::mojom::IntAttribute::kAriaRowCount, + "rowcount"); } // Expose aria-colindex and aria-rowindex in a cell or row. if (IsCellOrTableHeaderRole(GetData().role) || - GetData().role == AX_ROLE_ROW) { - if (GetData().role != AX_ROLE_ROW) - IntAttributeToIA2(result, AX_ATTR_ARIA_CELL_COLUMN_INDEX, "colindex"); - IntAttributeToIA2(result, AX_ATTR_ARIA_CELL_ROW_INDEX, "rowindex"); + GetData().role == ax::mojom::Role::kRow) { + if (GetData().role != ax::mojom::Role::kRow) + IntAttributeToIA2(result, ax::mojom::IntAttribute::kAriaCellColumnIndex, + "colindex"); + IntAttributeToIA2(result, ax::mojom::IntAttribute::kAriaCellRowIndex, + "rowindex"); // Experimental: expose aria-rowtext / aria-coltext. Not standardized // yet, but obscure enough that it's safe to expose. @@ -3107,20 +3139,21 @@ std::vector AXPlatformNodeWin::ComputeIA2Attributes() { int32_t sort_direction; if ((MSAARole() == ROLE_SYSTEM_COLUMNHEADER || MSAARole() == ROLE_SYSTEM_ROWHEADER) && - GetIntAttribute(AX_ATTR_SORT_DIRECTION, &sort_direction)) { - switch (static_cast(sort_direction)) { - case AX_SORT_DIRECTION_NONE: + GetIntAttribute(ax::mojom::IntAttribute::kSortDirection, + &sort_direction)) { + switch (static_cast(sort_direction)) { + case ax::mojom::SortDirection::kNone: break; - case AX_SORT_DIRECTION_UNSORTED: + case ax::mojom::SortDirection::kUnsorted: result.push_back(L"sort:none"); break; - case AX_SORT_DIRECTION_ASCENDING: + case ax::mojom::SortDirection::kAscending: result.push_back(L"sort:ascending"); break; - case AX_SORT_DIRECTION_DESCENDING: + case ax::mojom::SortDirection::kDescending: result.push_back(L"sort:descending"); break; - case AX_SORT_DIRECTION_OTHER: + case ax::mojom::SortDirection::kOther: result.push_back(L"sort:other"); break; } @@ -3172,7 +3205,7 @@ std::vector AXPlatformNodeWin::ComputeIA2Attributes() { // Expose datetime attribute. base::string16 datetime; - if (GetData().role == AX_ROLE_TIME && + if (GetData().role == ax::mojom::Role::kTime && GetData().GetHtmlAttribute("datetime", &datetime)) { SanitizeStringAttributeForIA2(datetime, &datetime); result.push_back(L"datetime:" + datetime); @@ -3187,7 +3220,7 @@ std::vector AXPlatformNodeWin::ComputeIA2Attributes() { // Expose src attribute. base::string16 src; - if (GetData().role == AX_ROLE_IMAGE && + if (GetData().role == ax::mojom::Role::kImage && GetData().GetHtmlAttribute("src", &src)) { SanitizeStringAttributeForIA2(src, &src); result.push_back(L"src:" + src); @@ -3203,7 +3236,8 @@ std::vector AXPlatformNodeWin::ComputeIA2Attributes() { // Expose input-text type attribute. base::string16 type; - base::string16 html_tag = GetString16Attribute(AX_ATTR_HTML_TAG); + base::string16 html_tag = + GetString16Attribute(ax::mojom::StringAttribute::kHtmlTag); if (IsPlainTextField() && html_tag == L"input" && GetData().GetHtmlAttribute("type", &type)) { SanitizeStringAttributeForIA2(type, &type); @@ -3222,7 +3256,7 @@ base::string16 AXPlatformNodeWin::GetValue() { // TODO(dougt): Look into ensuring that on click handlers correctly provide // a value here. if (value.empty() && (MSAAState() & STATE_SYSTEM_LINKED)) - value = GetString16Attribute(ui::AX_ATTR_URL); + value = GetString16Attribute(ax::mojom::StringAttribute::kUrl); return value; } @@ -3242,7 +3276,7 @@ AXHypertext AXPlatformNodeWin::ComputeHypertext() { // We don't want to expose any associated label in IA2 Hypertext. return result; } - result.hypertext = GetString16Attribute(ui::AX_ATTR_NAME); + result.hypertext = GetString16Attribute(ax::mojom::StringAttribute::kName); return result; } @@ -3259,7 +3293,8 @@ AXHypertext AXPlatformNodeWin::ComputeHypertext() { DCHECK(child); // Similar to Firefox, we don't expose text-only objects in IA2 hypertext. if (child->IsTextOnlyObject()) { - hypertext += child->GetString16Attribute(ui::AX_ATTR_NAME); + hypertext += + child->GetString16Attribute(ax::mojom::StringAttribute::kName); } else { int32_t char_offset = static_cast(hypertext.size()); int32_t child_unique_id = child->GetUniqueId(); @@ -3276,26 +3311,26 @@ AXHypertext AXPlatformNodeWin::ComputeHypertext() { bool AXPlatformNodeWin::ShouldNodeHaveReadonlyStateByDefault( const AXNodeData& data) const { switch (data.role) { - case AX_ROLE_ARTICLE: - case AX_ROLE_DEFINITION: - case AX_ROLE_DESCRIPTION_LIST: - case AX_ROLE_DESCRIPTION_LIST_TERM: - case AX_ROLE_DOCUMENT: - case AX_ROLE_IFRAME: - case AX_ROLE_IMAGE: - case AX_ROLE_IMAGE_MAP: - case AX_ROLE_LIST: - case AX_ROLE_LIST_ITEM: - case AX_ROLE_PROGRESS_INDICATOR: - case AX_ROLE_ROOT_WEB_AREA: - case AX_ROLE_TERM: - case AX_ROLE_TIMER: - case AX_ROLE_TOOLBAR: - case AX_ROLE_TOOLTIP: - case AX_ROLE_WEB_AREA: + case ax::mojom::Role::kArticle: + case ax::mojom::Role::kDefinition: + case ax::mojom::Role::kDescriptionList: + case ax::mojom::Role::kDescriptionListTerm: + case ax::mojom::Role::kDocument: + case ax::mojom::Role::kIframe: + case ax::mojom::Role::kImage: + case ax::mojom::Role::kImageMap: + case ax::mojom::Role::kList: + case ax::mojom::Role::kListItem: + case ax::mojom::Role::kProgressIndicator: + case ax::mojom::Role::kRootWebArea: + case ax::mojom::Role::kTerm: + case ax::mojom::Role::kTimer: + case ax::mojom::Role::kToolbar: + case ax::mojom::Role::kTooltip: + case ax::mojom::Role::kWebArea: return true; - case AX_ROLE_GRID: + case ax::mojom::Role::kGrid: // TODO(aleventhal) this changed between ARIA 1.0 and 1.1, // need to determine whether grids/treegrids should really be readonly // or editable by default @@ -3311,56 +3346,56 @@ bool AXPlatformNodeWin::ShouldNodeHaveReadonlyStateByDefault( bool AXPlatformNodeWin::ShouldNodeHaveFocusableState( const AXNodeData& data) const { switch (data.role) { - case AX_ROLE_DOCUMENT: - case AX_ROLE_ROOT_WEB_AREA: - case AX_ROLE_WEB_AREA: + case ax::mojom::Role::kDocument: + case ax::mojom::Role::kRootWebArea: + case ax::mojom::Role::kWebArea: return true; - case AX_ROLE_IFRAME: + case ax::mojom::Role::kIframe: return false; - case AX_ROLE_LIST_BOX_OPTION: - case AX_ROLE_MENU_LIST_OPTION: - if (data.HasState(AX_STATE_SELECTABLE)) + case ax::mojom::Role::kListBoxOption: + case ax::mojom::Role::kMenuListOption: + if (data.HasState(ax::mojom::State::kSelectable)) return true; default: break; } - return data.HasState(AX_STATE_FOCUSABLE); + return data.HasState(ax::mojom::State::kFocusable); } int AXPlatformNodeWin::MSAAState() { const AXNodeData& data = GetData(); int msaa_state = 0; - // Map the AXState to MSAA state. Note that some of the states are not - // currently handled. + // Map the ax::mojom::State to MSAA state. Note that some of the states are + // not currently handled. - if (data.GetBoolAttribute(AX_ATTR_BUSY)) + if (data.GetBoolAttribute(ax::mojom::BoolAttribute::kBusy)) msaa_state |= STATE_SYSTEM_BUSY; - if (data.HasState(AX_STATE_COLLAPSED)) + if (data.HasState(ax::mojom::State::kCollapsed)) msaa_state |= STATE_SYSTEM_COLLAPSED; - if (data.HasState(AX_STATE_DEFAULT)) + if (data.HasState(ax::mojom::State::kDefault)) msaa_state |= STATE_SYSTEM_DEFAULT; - // TODO(dougt) unhandled ux::AX_STATE_EDITABLE + // TODO(dougt) unhandled ux::ax::mojom::State::kEditable - if (data.HasState(AX_STATE_EXPANDED)) + if (data.HasState(ax::mojom::State::kExpanded)) msaa_state |= STATE_SYSTEM_EXPANDED; if (ShouldNodeHaveFocusableState(data)) msaa_state |= STATE_SYSTEM_FOCUSABLE; - if (data.HasState(AX_STATE_HASPOPUP)) + if (data.HasState(ax::mojom::State::kHaspopup)) msaa_state |= STATE_SYSTEM_HASPOPUP; - // TODO(dougt) unhandled ux::AX_STATE_HORIZONTAL + // TODO(dougt) unhandled ux::ax::mojom::State::kHorizontal - if (data.HasState(AX_STATE_HOVERED)) { + if (data.HasState(ax::mojom::State::kHovered)) { // Expose whether or not the mouse is over an element, but suppress // this for tests because it can make the test results flaky depending // on the position of the mouse. @@ -3370,15 +3405,16 @@ int AXPlatformNodeWin::MSAAState() { // If the role is IGNORED, we want these elements to be invisible so that // these nodes are hidden from the screen reader. - if (data.HasState(AX_STATE_INVISIBLE) || GetData().role == AX_ROLE_IGNORED) { + if (data.HasState(ax::mojom::State::kInvisible) || + GetData().role == ax::mojom::Role::kIgnored) { msaa_state |= STATE_SYSTEM_INVISIBLE; } - if (data.HasState(AX_STATE_LINKED)) + if (data.HasState(ax::mojom::State::kLinked)) msaa_state |= STATE_SYSTEM_LINKED; - // TODO(dougt) unhandled ux::AX_STATE_MULTILINE + // TODO(dougt) unhandled ux::ax::mojom::State::kMultiline - if (data.HasState(AX_STATE_MULTISELECTABLE)) { + if (data.HasState(ax::mojom::State::kMultiselectable)) { msaa_state |= STATE_SYSTEM_EXTSELECTABLE; msaa_state |= STATE_SYSTEM_MULTISELECTABLE; } @@ -3386,47 +3422,48 @@ int AXPlatformNodeWin::MSAAState() { if (delegate_->IsOffscreen()) msaa_state |= STATE_SYSTEM_OFFSCREEN; - if (data.HasState(AX_STATE_PROTECTED)) + if (data.HasState(ax::mojom::State::kProtected)) msaa_state |= STATE_SYSTEM_PROTECTED; - // TODO(dougt) unhandled ux::AX_STATE_REQUIRED - // TODO(dougt) unhandled ux::AX_STATE_RICHLY_EDITABLE + // TODO(dougt) unhandled ux::ax::mojom::State::kRequired + // TODO(dougt) unhandled ux::ax::mojom::State::kRichlyEditable - if (data.HasState(AX_STATE_SELECTABLE)) + if (data.HasState(ax::mojom::State::kSelectable)) msaa_state |= STATE_SYSTEM_SELECTABLE; - if (data.HasState(AX_STATE_SELECTED)) + if (data.HasState(ax::mojom::State::kSelected)) msaa_state |= STATE_SYSTEM_SELECTED; // TODO(dougt) unhandled VERTICAL - if (data.HasState(AX_STATE_VISITED)) + if (data.HasState(ax::mojom::State::kVisited)) msaa_state |= STATE_SYSTEM_TRAVERSED; // // Checked state // - const auto checked_state = - static_cast(GetIntAttribute(AX_ATTR_CHECKED_STATE)); + const auto checked_state = static_cast( + GetIntAttribute(ax::mojom::IntAttribute::kCheckedState)); switch (checked_state) { - case AX_CHECKED_STATE_TRUE: - msaa_state |= data.role == AX_ROLE_TOGGLE_BUTTON ? STATE_SYSTEM_PRESSED - : STATE_SYSTEM_CHECKED; + case ax::mojom::CheckedState::kTrue: + msaa_state |= data.role == ax::mojom::Role::kToggleButton + ? STATE_SYSTEM_PRESSED + : STATE_SYSTEM_CHECKED; break; - case AX_CHECKED_STATE_MIXED: + case ax::mojom::CheckedState::kMixed: msaa_state |= STATE_SYSTEM_MIXED; break; default: break; } - const auto restriction = - static_cast(GetIntAttribute(AX_ATTR_RESTRICTION)); + const auto restriction = static_cast( + GetIntAttribute(ax::mojom::IntAttribute::kRestriction)); switch (restriction) { - case AX_RESTRICTION_DISABLED: + case ax::mojom::Restriction::kDisabled: msaa_state |= STATE_SYSTEM_UNAVAILABLE; break; - case AX_RESTRICTION_READ_ONLY: + case ax::mojom::Restriction::kReadOnly: msaa_state |= STATE_SYSTEM_READONLY; break; default: @@ -3434,7 +3471,7 @@ int AXPlatformNodeWin::MSAAState() { // on *some* document structure roles such as paragraph, heading or list // even if the node data isn't marked as read only, as long as the // node is not editable. - if (!data.HasState(AX_STATE_RICHLY_EDITABLE) && + if (!data.HasState(ax::mojom::State::kRichlyEditable) && ShouldNodeHaveReadonlyStateByDefault(data)) msaa_state |= STATE_SYSTEM_READONLY; break; @@ -3453,57 +3490,59 @@ int AXPlatformNodeWin::MSAAState() { // TODO(dmazzoni): this should probably check if focus is actually inside // the menu bar, but we don't currently track focus inside menu pop-ups, // and Chrome only has one menu visible at a time so this works for now. - if (data.role == AX_ROLE_MENU_BAR && !(data.HasState(AX_STATE_INVISIBLE))) { + if (data.role == ax::mojom::Role::kMenuBar && + !(data.HasState(ax::mojom::State::kInvisible))) { msaa_state |= STATE_SYSTEM_FOCUSED; } // Handle STATE_SYSTEM_LINKED - if (GetData().role == AX_ROLE_LINK) + if (GetData().role == ax::mojom::Role::kLink) msaa_state |= STATE_SYSTEM_LINKED; // Special case for indeterminate progressbar. - if (GetData().role == AX_ROLE_PROGRESS_INDICATOR && - !HasFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE)) + if (GetData().role == ax::mojom::Role::kProgressIndicator && + !HasFloatAttribute(ax::mojom::FloatAttribute::kValueForRange)) msaa_state |= STATE_SYSTEM_MIXED; return msaa_state; } -int AXPlatformNodeWin::MSAAEvent(AXEvent event) { +int AXPlatformNodeWin::MSAAEvent(ax::mojom::Event event) { switch (event) { - case AX_EVENT_ALERT: + case ax::mojom::Event::kAlert: return EVENT_SYSTEM_ALERT; - case AX_EVENT_EXPANDED_CHANGED: + case ax::mojom::Event::kExpandedChanged: return EVENT_OBJECT_STATECHANGE; - case AX_EVENT_FOCUS: + case ax::mojom::Event::kFocus: return EVENT_OBJECT_FOCUS; - case AX_EVENT_MENU_START: + case ax::mojom::Event::kMenuStart: return EVENT_SYSTEM_MENUSTART; - case AX_EVENT_MENU_END: + case ax::mojom::Event::kMenuEnd: return EVENT_SYSTEM_MENUEND; - case AX_EVENT_MENU_POPUP_START: + case ax::mojom::Event::kMenuPopupStart: return EVENT_SYSTEM_MENUPOPUPSTART; - case AX_EVENT_MENU_POPUP_END: + case ax::mojom::Event::kMenuPopupEnd: return EVENT_SYSTEM_MENUPOPUPEND; - case AX_EVENT_SELECTION: + case ax::mojom::Event::kSelection: return EVENT_OBJECT_SELECTION; - case AX_EVENT_SELECTION_ADD: + case ax::mojom::Event::kSelectionAdd: return EVENT_OBJECT_SELECTIONADD; - case AX_EVENT_SELECTION_REMOVE: + case ax::mojom::Event::kSelectionRemove: return EVENT_OBJECT_SELECTIONREMOVE; - case AX_EVENT_TEXT_CHANGED: + case ax::mojom::Event::kTextChanged: return EVENT_OBJECT_NAMECHANGE; - case AX_EVENT_TEXT_SELECTION_CHANGED: + case ax::mojom::Event::kTextSelectionChanged: return IA2_EVENT_TEXT_CARET_MOVED; - case AX_EVENT_VALUE_CHANGED: + case ax::mojom::Event::kValueChanged: return EVENT_OBJECT_VALUECHANGE; default: return -1; } } -HRESULT AXPlatformNodeWin::GetStringAttributeAsBstr(AXStringAttribute attribute, - BSTR* value_bstr) const { +HRESULT AXPlatformNodeWin::GetStringAttributeAsBstr( + ax::mojom::StringAttribute attribute, + BSTR* value_bstr) const { base::string16 str; if (!GetString16Attribute(attribute, &str)) @@ -3527,7 +3566,7 @@ void AXPlatformNodeWin::RemoveAlertTarget() { base::string16 AXPlatformNodeWin::TextForIAccessibleText() { // Special case allows us to get text even in non-HTML case, e.g. browser UI. if (IsPlainTextField()) - return GetString16Attribute(AX_ATTR_VALUE); + return GetString16Attribute(ax::mojom::StringAttribute::kValue); return GetText(); } @@ -3571,9 +3610,9 @@ LONG AXPlatformNodeWin::FindBoundary(const base::string16& text, HandleSpecialTextOffset(&start_offset); TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); std::vector line_breaks; - return static_cast( - FindAccessibleTextBoundary(text, line_breaks, boundary, start_offset, - direction, AX_TEXT_AFFINITY_DOWNSTREAM)); + return static_cast(FindAccessibleTextBoundary( + text, line_breaks, boundary, start_offset, direction, + ax::mojom::TextAffinity::kDownstream)); } AXPlatformNodeWin* AXPlatformNodeWin::GetTargetFromChildID( @@ -3613,13 +3652,13 @@ bool AXPlatformNodeWin::IsInTreeGrid() { AXPlatformNodeBase* container = FromNativeViewAccessible(GetParent()); // If parent was a rowgroup, we need to look at the grandparent - if (container && container->GetData().role == AX_ROLE_GROUP) + if (container && container->GetData().role == ax::mojom::Role::kGroup) container = FromNativeViewAccessible(container->GetParent()); if (!container) return false; - return container->GetData().role == AX_ROLE_TREE_GRID; + return container->GetData().role == ax::mojom::Role::kTreeGrid; } HRESULT AXPlatformNodeWin::AllocateComArrayFromVector( @@ -3924,8 +3963,9 @@ void AXPlatformNodeWin::GetSelectionOffsets(int* selection_start, DCHECK(selection_start && selection_end); if (IsPlainTextField() && - GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START, selection_start) && - GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END, selection_end)) { + GetIntAttribute(ax::mojom::IntAttribute::kTextSelStart, + selection_start) && + GetIntAttribute(ax::mojom::IntAttribute::kTextSelEnd, selection_end)) { return; } diff --git a/ui/accessibility/platform/ax_platform_node_win.h b/ui/accessibility/platform/ax_platform_node_win.h index 7b49fa9b316c89..4efab44077ad6a 100644 --- a/ui/accessibility/platform/ax_platform_node_win.h +++ b/ui/accessibility/platform/ax_platform_node_win.h @@ -270,7 +270,7 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2")) // AXPlatformNode overrides. gfx::NativeViewAccessible GetNativeViewAccessible() override; - void NotifyAccessibilityEvent(AXEvent event_type) override; + void NotifyAccessibilityEvent(ax::mojom::Event event_type) override; // AXPlatformNodeBase overrides. void Destroy() override; @@ -708,12 +708,12 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2")) TextBoundaryType IA2TextBoundaryToTextBoundary(IA2TextBoundaryType type); private: - int MSAAEvent(AXEvent event); + int MSAAEvent(ax::mojom::Event event); bool IsWebAreaForPresentationalIframe(); bool ShouldNodeHaveReadonlyStateByDefault(const AXNodeData& data) const; bool ShouldNodeHaveFocusableState(const AXNodeData& data) const; - HRESULT GetStringAttributeAsBstr(AXStringAttribute attribute, + HRESULT GetStringAttributeAsBstr(ax::mojom::StringAttribute attribute, BSTR* value_bstr) const; // Escapes characters in string attributes as required by the IA2 Spec. @@ -727,19 +727,19 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2")) // If the string attribute |attribute| is present, add its value as an // IAccessible2 attribute with the name |ia2_attr|. void StringAttributeToIA2(std::vector& attributes, - AXStringAttribute attribute, + ax::mojom::StringAttribute attribute, const char* ia2_attr); // If the bool attribute |attribute| is present, add its value as an // IAccessible2 attribute with the name |ia2_attr|. void BoolAttributeToIA2(std::vector& attributes, - AXBoolAttribute attribute, + ax::mojom::BoolAttribute attribute, const char* ia2_attr); // If the int attribute |attribute| is present, add its value as an // IAccessible2 attribute with the name |ia2_attr|. void IntAttributeToIA2(std::vector& attributes, - AXIntAttribute attribute, + ax::mojom::IntAttribute attribute, const char* ia2_attr); void AddAlertTarget(); diff --git a/ui/accessibility/platform/ax_platform_node_win_unittest.cc b/ui/accessibility/platform/ax_platform_node_win_unittest.cc index 7a7ea0db3e1b39..20de83957ca8fc 100644 --- a/ui/accessibility/platform/ax_platform_node_win_unittest.cc +++ b/ui/accessibility/platform/ax_platform_node_win_unittest.cc @@ -206,7 +206,8 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleName) { TEST_F(AXPlatformNodeWinTest, TestIAccessibleDescription) { AXNodeData root; root.id = 1; - root.AddStringAttribute(AX_ATTR_DESCRIPTION, "Description"); + root.AddStringAttribute(ax::mojom::StringAttribute::kDescription, + "Description"); Init(root); ComPtr root_obj(GetRootIAccessible()); @@ -223,7 +224,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleDescription) { TEST_F(AXPlatformNodeWinTest, TestIAccessibleValue) { AXNodeData root; root.id = 1; - root.AddStringAttribute(AX_ATTR_VALUE, "Value"); + root.AddStringAttribute(ax::mojom::StringAttribute::kValue, "Value"); Init(root); ComPtr root_obj(GetRootIAccessible()); @@ -240,7 +241,8 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleValue) { TEST_F(AXPlatformNodeWinTest, TestIAccessibleShortcut) { AXNodeData root; root.id = 1; - root.AddStringAttribute(AX_ATTR_KEY_SHORTCUTS, "Shortcut"); + root.AddStringAttribute(ax::mojom::StringAttribute::kKeyShortcuts, + "Shortcut"); Init(root); ComPtr root_obj(GetRootIAccessible()); @@ -259,16 +261,16 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleSelectionListBoxOptionNothingSelected) { AXNodeData list; list.id = 0; - list.role = AX_ROLE_LIST_BOX; + list.role = ax::mojom::Role::kListBox; AXNodeData list_item_1; list_item_1.id = 1; - list_item_1.role = AX_ROLE_LIST_BOX_OPTION; + list_item_1.role = ax::mojom::Role::kListBoxOption; list_item_1.SetName("Name1"); AXNodeData list_item_2; list_item_2.id = 2; - list_item_2.role = AX_ROLE_LIST_BOX_OPTION; + list_item_2.role = ax::mojom::Role::kListBoxOption; list_item_2.SetName("Name2"); list.child_ids.push_back(list_item_1.id); @@ -288,17 +290,17 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleSelectionListBoxOptionOneSelected) { AXNodeData list; list.id = 0; - list.role = AX_ROLE_LIST_BOX; + list.role = ax::mojom::Role::kListBox; AXNodeData list_item_1; list_item_1.id = 1; - list_item_1.role = AX_ROLE_LIST_BOX_OPTION; - list_item_1.AddState(AX_STATE_SELECTED); + list_item_1.role = ax::mojom::Role::kListBoxOption; + list_item_1.AddState(ax::mojom::State::kSelected); list_item_1.SetName("Name1"); AXNodeData list_item_2; list_item_2.id = 2; - list_item_2.role = AX_ROLE_LIST_BOX_OPTION; + list_item_2.role = ax::mojom::Role::kListBoxOption; list_item_2.SetName("Name2"); list.child_ids.push_back(list_item_1.id); @@ -320,23 +322,23 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleSelectionListBoxOptionMultipleSelected) { AXNodeData list; list.id = 0; - list.role = AX_ROLE_LIST_BOX; + list.role = ax::mojom::Role::kListBox; AXNodeData list_item_1; list_item_1.id = 1; - list_item_1.role = AX_ROLE_LIST_BOX_OPTION; - list_item_1.AddState(AX_STATE_SELECTED); + list_item_1.role = ax::mojom::Role::kListBoxOption; + list_item_1.AddState(ax::mojom::State::kSelected); list_item_1.SetName("Name1"); AXNodeData list_item_2; list_item_2.id = 2; - list_item_2.role = AX_ROLE_LIST_BOX_OPTION; - list_item_2.AddState(AX_STATE_SELECTED); + list_item_2.role = ax::mojom::Role::kListBoxOption; + list_item_2.AddState(ax::mojom::State::kSelected); list_item_2.SetName("Name2"); AXNodeData list_item_3; list_item_3.id = 3; - list_item_3.role = AX_ROLE_LIST_BOX_OPTION; + list_item_3.role = ax::mojom::Role::kListBoxOption; list_item_3.SetName("Name3"); list.child_ids.push_back(list_item_1.id); @@ -413,7 +415,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleSelectionTableRowOneSelected) { AXTreeUpdate update = Build3X3Table(); // 5 == table_row_1 - update.nodes[5].AddState(AX_STATE_SELECTED); + update.nodes[5].AddState(ax::mojom::State::kSelected); Init(update); @@ -441,8 +443,8 @@ TEST_F(AXPlatformNodeWinTest, // 5 == table_row_1 // 9 == table_row_2 - update.nodes[5].AddState(AX_STATE_SELECTED); - update.nodes[9].AddState(AX_STATE_SELECTED); + update.nodes[5].AddState(ax::mojom::State::kSelected); + update.nodes[9].AddState(ax::mojom::State::kSelected); Init(update); @@ -503,7 +505,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleSelectionTableCellOneSelected) { AXTreeUpdate update = Build3X3Table(); // 7 == table_cell_1 - update.nodes[7].AddState(AX_STATE_SELECTED); + update.nodes[7].AddState(ax::mojom::State::kSelected); Init(update); @@ -541,8 +543,8 @@ TEST_F(AXPlatformNodeWinTest, // 11 == table_cell_3 // 12 == table_cell_4 - update.nodes[11].AddState(AX_STATE_SELECTED); - update.nodes[12].AddState(AX_STATE_SELECTED); + update.nodes[11].AddState(ax::mojom::State::kSelected); + update.nodes[12].AddState(ax::mojom::State::kSelected); Init(update); @@ -619,17 +621,17 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleRole) { ScopedVariant role; - child.role = AX_ROLE_ALERT; + child.role = ax::mojom::Role::kAlert; child_node->SetData(child); EXPECT_EQ(S_OK, child_iaccessible->get_accRole(SELF, role.Receive())); EXPECT_EQ(ROLE_SYSTEM_ALERT, V_I4(role.ptr())); - child.role = AX_ROLE_BUTTON; + child.role = ax::mojom::Role::kButton; child_node->SetData(child); EXPECT_EQ(S_OK, child_iaccessible->get_accRole(SELF, role.Receive())); EXPECT_EQ(ROLE_SYSTEM_PUSHBUTTON, V_I4(role.ptr())); - child.role = AX_ROLE_POP_UP_BUTTON; + child.role = ax::mojom::Role::kPopUpButton; child_node->SetData(child); EXPECT_EQ(S_OK, child_iaccessible->get_accRole(SELF, role.Receive())); EXPECT_EQ(ROLE_SYSTEM_BUTTONMENU, V_I4(role.ptr())); @@ -676,11 +678,11 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleChildAndParent) { root.child_ids.push_back(3); AXNodeData button; - button.role = AX_ROLE_BUTTON; + button.role = ax::mojom::Role::kButton; button.id = 2; AXNodeData checkbox; - checkbox.role = AX_ROLE_CHECK_BOX; + checkbox.role = ax::mojom::Role::kCheckBox; checkbox.id = 3; Init(root, button, checkbox); @@ -809,16 +811,16 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessible2IndexInParent) { TEST_F(AXPlatformNodeWinTest, TestAccNavigate) { AXNodeData root; root.id = 1; - root.role = AX_ROLE_ROOT_WEB_AREA; + root.role = ax::mojom::Role::kRootWebArea; AXNodeData child1; child1.id = 2; - child1.role = AX_ROLE_STATIC_TEXT; + child1.role = ax::mojom::Role::kStaticText; root.child_ids.push_back(2); AXNodeData child2; child2.id = 3; - child2.role = AX_ROLE_STATIC_TEXT; + child2.role = ax::mojom::Role::kStaticText; root.child_ids.push_back(3); Init(root, child1, child2); @@ -1003,12 +1005,12 @@ TEST_F(AXPlatformNodeWinTest, TEST_F(AXPlatformNodeWinTest, TestIAccessible2ScrollToPoint) { AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; + root.role = ax::mojom::Role::kRootWebArea; root.location = gfx::RectF(0, 0, 2000, 2000); AXNodeData child1; child1.id = 2; - child1.role = AX_ROLE_STATIC_TEXT; + child1.role = ax::mojom::Role::kStaticText; child1.location = gfx::RectF(10, 10, 10, 10); root.child_ids.push_back(2); @@ -1055,12 +1057,12 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessible2ScrollToPoint) { TEST_F(AXPlatformNodeWinTest, TestIAccessible2ScrollTo) { AXNodeData root; root.id = 1; - root.role = ui::AX_ROLE_ROOT_WEB_AREA; + root.role = ax::mojom::Role::kRootWebArea; root.location = gfx::RectF(0, 0, 2000, 2000); AXNodeData child1; child1.id = 2; - child1.role = AX_ROLE_STATIC_TEXT; + child1.role = ax::mojom::Role::kStaticText; child1.location = gfx::RectF(10, 10, 10, 10); root.child_ids.push_back(2); @@ -1373,8 +1375,8 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetRowHeaderCells) { long number_cells; EXPECT_EQ(S_OK, cell->get_rowHeaderCells(&cell_accessibles, &number_cells)); - // Since we do not have AX_ATTR_TABLE_CELL_ROW_INDEX set, the evaluated row - // will be 0. In this case, we do not expect any row headers. + // Since we do not have ax::mojom::IntAttribute::kTableCellRowIndex set, the + // evaluated row will be 0. In this case, we do not expect any row headers. EXPECT_EQ(number_cells, 0); } @@ -1430,20 +1432,21 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessible2GetNRelations) { // specific COM/BrowserAccessibility knowledge. AXNodeData root; root.id = 1; - root.role = AX_ROLE_ROOT_WEB_AREA; + root.role = ax::mojom::Role::kRootWebArea; std::vector describedby_ids = {1, 2, 3}; - root.AddIntListAttribute(AX_ATTR_DESCRIBEDBY_IDS, describedby_ids); + root.AddIntListAttribute(ax::mojom::IntListAttribute::kDescribedbyIds, + describedby_ids); AXNodeData child1; child1.id = 2; - child1.role = AX_ROLE_STATIC_TEXT; + child1.role = ax::mojom::Role::kStaticText; root.child_ids.push_back(2); AXNodeData child2; child2.id = 3; - child2.role = AX_ROLE_STATIC_TEXT; + child2.role = ax::mojom::Role::kStaticText; root.child_ids.push_back(3); @@ -1538,27 +1541,28 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessible2GetNRelations) { TEST_F(AXPlatformNodeWinTest, TestRelationTargetsOfType) { AXNodeData root; root.id = 1; - root.role = AX_ROLE_ROOT_WEB_AREA; - root.AddIntAttribute(AX_ATTR_DETAILS_ID, 2); + root.role = ax::mojom::Role::kRootWebArea; + root.AddIntAttribute(ax::mojom::IntAttribute::kDetailsId, 2); AXNodeData child1; child1.id = 2; - child1.role = AX_ROLE_STATIC_TEXT; + child1.role = ax::mojom::Role::kStaticText; root.child_ids.push_back(2); AXNodeData child2; child2.id = 3; - child2.role = AX_ROLE_STATIC_TEXT; + child2.role = ax::mojom::Role::kStaticText; std::vector labelledby_ids = {1, 4}; - child2.AddIntListAttribute(AX_ATTR_LABELLEDBY_IDS, labelledby_ids); + child2.AddIntListAttribute(ax::mojom::IntListAttribute::kLabelledbyIds, + labelledby_ids); root.child_ids.push_back(3); AXNodeData child3; child3.id = 4; - child3.role = AX_ROLE_STATIC_TEXT; - child3.AddIntAttribute(AX_ATTR_DETAILS_ID, 2); + child3.role = ax::mojom::Role::kStaticText; + child3.AddIntAttribute(ax::mojom::IntAttribute::kDetailsId, 2); root.child_ids.push_back(4); @@ -1643,7 +1647,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedChildrenOne) { AXTreeUpdate update = Build3X3Table(); // 7 == table_cell_1 - update.nodes[7].AddState(AX_STATE_SELECTED); + update.nodes[7].AddState(ax::mojom::State::kSelected); Init(update); ComPtr cell = GetCellInTable(); @@ -1668,10 +1672,10 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedChildrenMany) { // 8 == table_cell_2 // 11 == table_cell_3 // 12 == table_cell_4 - update.nodes[7].AddState(AX_STATE_SELECTED); - update.nodes[8].AddState(AX_STATE_SELECTED); - update.nodes[11].AddState(AX_STATE_SELECTED); - update.nodes[12].AddState(AX_STATE_SELECTED); + update.nodes[7].AddState(ax::mojom::State::kSelected); + update.nodes[8].AddState(ax::mojom::State::kSelected); + update.nodes[11].AddState(ax::mojom::State::kSelected); + update.nodes[12].AddState(ax::mojom::State::kSelected); Init(update); @@ -1714,9 +1718,9 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedColumnsOne) { // 3 == table_column_header_2 // 7 == table_cell_1 // 11 == table_cell_3 - update.nodes[3].AddState(AX_STATE_SELECTED); - update.nodes[7].AddState(AX_STATE_SELECTED); - update.nodes[11].AddState(AX_STATE_SELECTED); + update.nodes[3].AddState(ax::mojom::State::kSelected); + update.nodes[7].AddState(ax::mojom::State::kSelected); + update.nodes[11].AddState(ax::mojom::State::kSelected); Init(update); @@ -1741,16 +1745,16 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedColumnsMany) { // 3 == table_column_header_2 // 7 == table_cell_1 // 11 == table_cell_3 - update.nodes[3].AddState(AX_STATE_SELECTED); - update.nodes[7].AddState(AX_STATE_SELECTED); - update.nodes[11].AddState(AX_STATE_SELECTED); + update.nodes[3].AddState(ax::mojom::State::kSelected); + update.nodes[7].AddState(ax::mojom::State::kSelected); + update.nodes[11].AddState(ax::mojom::State::kSelected); // 4 == table_column_header_3 // 8 == table_cell_2 // 12 == table_cell_4 - update.nodes[4].AddState(AX_STATE_SELECTED); - update.nodes[8].AddState(AX_STATE_SELECTED); - update.nodes[12].AddState(AX_STATE_SELECTED); + update.nodes[4].AddState(ax::mojom::State::kSelected); + update.nodes[8].AddState(ax::mojom::State::kSelected); + update.nodes[12].AddState(ax::mojom::State::kSelected); Init(update); @@ -1793,9 +1797,9 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedRowsOne) { // 6 == table_row_header_1 // 7 == table_cell_1 // 8 == table_cell_2 - update.nodes[6].AddState(AX_STATE_SELECTED); - update.nodes[7].AddState(AX_STATE_SELECTED); - update.nodes[8].AddState(AX_STATE_SELECTED); + update.nodes[6].AddState(ax::mojom::State::kSelected); + update.nodes[7].AddState(ax::mojom::State::kSelected); + update.nodes[8].AddState(ax::mojom::State::kSelected); Init(update); @@ -1820,16 +1824,16 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedRowsMany) { // 6 == table_row_header_3 // 7 == table_cell_1 // 8 == table_cell_2 - update.nodes[6].AddState(AX_STATE_SELECTED); - update.nodes[7].AddState(AX_STATE_SELECTED); - update.nodes[8].AddState(AX_STATE_SELECTED); + update.nodes[6].AddState(ax::mojom::State::kSelected); + update.nodes[7].AddState(ax::mojom::State::kSelected); + update.nodes[8].AddState(ax::mojom::State::kSelected); // 10 == table_row_header_3 // 11 == table_cell_1 // 12 == table_cell_2 - update.nodes[10].AddState(AX_STATE_SELECTED); - update.nodes[11].AddState(AX_STATE_SELECTED); - update.nodes[12].AddState(AX_STATE_SELECTED); + update.nodes[10].AddState(ax::mojom::State::kSelected); + update.nodes[11].AddState(ax::mojom::State::kSelected); + update.nodes[12].AddState(ax::mojom::State::kSelected); Init(update); @@ -1853,8 +1857,8 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedChildren) { // 7 == table_cell_1 // 12 == table_cell_4 - update.nodes[7].AddState(AX_STATE_SELECTED); - update.nodes[12].AddState(AX_STATE_SELECTED); + update.nodes[7].AddState(ax::mojom::State::kSelected); + update.nodes[12].AddState(ax::mojom::State::kSelected); Init(update); @@ -1882,8 +1886,8 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedChildrenZeroMax) { // 7 == table_cell_1 // 12 == table_cell_4 - update.nodes[7].AddState(AX_STATE_SELECTED); - update.nodes[12].AddState(AX_STATE_SELECTED); + update.nodes[7].AddState(ax::mojom::State::kSelected); + update.nodes[12].AddState(ax::mojom::State::kSelected); Init(update); @@ -1907,8 +1911,8 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedColumnsZero) { // 7 == table_cell_1 // 11 == table_cell_3 - update.nodes[7].AddState(AX_STATE_SELECTED); - update.nodes[11].AddState(AX_STATE_SELECTED); + update.nodes[7].AddState(ax::mojom::State::kSelected); + update.nodes[11].AddState(ax::mojom::State::kSelected); Init(update); @@ -1936,9 +1940,9 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedColumnsOne) { // 3 == table_column_header_2 // 7 == table_cell_1 // 11 == table_cell_3 - update.nodes[3].AddState(AX_STATE_SELECTED); - update.nodes[7].AddState(AX_STATE_SELECTED); - update.nodes[11].AddState(AX_STATE_SELECTED); + update.nodes[3].AddState(ax::mojom::State::kSelected); + update.nodes[7].AddState(ax::mojom::State::kSelected); + update.nodes[11].AddState(ax::mojom::State::kSelected); Init(update); @@ -1967,16 +1971,16 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedColumnsMany) { // 3 == table_column_header_2 // 7 == table_cell_1 // 11 == table_cell_3 - update.nodes[3].AddState(AX_STATE_SELECTED); - update.nodes[7].AddState(AX_STATE_SELECTED); - update.nodes[11].AddState(AX_STATE_SELECTED); + update.nodes[3].AddState(ax::mojom::State::kSelected); + update.nodes[7].AddState(ax::mojom::State::kSelected); + update.nodes[11].AddState(ax::mojom::State::kSelected); // 4 == table_column_header_3 // 8 == table_cell_2 // 12 == table_cell_4 - update.nodes[4].AddState(AX_STATE_SELECTED); - update.nodes[8].AddState(AX_STATE_SELECTED); - update.nodes[12].AddState(AX_STATE_SELECTED); + update.nodes[4].AddState(ax::mojom::State::kSelected); + update.nodes[8].AddState(ax::mojom::State::kSelected); + update.nodes[12].AddState(ax::mojom::State::kSelected); Init(update); @@ -2026,9 +2030,9 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedRowsOne) { // 6 == table_row_header_1 // 7 == table_cell_1 // 8 == table_cell_2 - update.nodes[6].AddState(AX_STATE_SELECTED); - update.nodes[7].AddState(AX_STATE_SELECTED); - update.nodes[8].AddState(AX_STATE_SELECTED); + update.nodes[6].AddState(ax::mojom::State::kSelected); + update.nodes[7].AddState(ax::mojom::State::kSelected); + update.nodes[8].AddState(ax::mojom::State::kSelected); Init(update); @@ -2056,16 +2060,16 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedRowsMany) { // 6 == table_row_header_3 // 7 == table_cell_1 // 8 == table_cell_2 - update.nodes[6].AddState(AX_STATE_SELECTED); - update.nodes[7].AddState(AX_STATE_SELECTED); - update.nodes[8].AddState(AX_STATE_SELECTED); + update.nodes[6].AddState(ax::mojom::State::kSelected); + update.nodes[7].AddState(ax::mojom::State::kSelected); + update.nodes[8].AddState(ax::mojom::State::kSelected); // 10 == table_row_header_3 // 11 == table_cell_1 // 12 == table_cell_2 - update.nodes[10].AddState(AX_STATE_SELECTED); - update.nodes[11].AddState(AX_STATE_SELECTED); - update.nodes[12].AddState(AX_STATE_SELECTED); + update.nodes[10].AddState(ax::mojom::State::kSelected); + update.nodes[11].AddState(ax::mojom::State::kSelected); + update.nodes[12].AddState(ax::mojom::State::kSelected); Init(update); @@ -2094,9 +2098,9 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableIsColumnSelected) { // 3 == table_column_header_2 // 7 == table_cell_1 // 11 == table_cell_3 - update.nodes[3].AddState(AX_STATE_SELECTED); - update.nodes[7].AddState(AX_STATE_SELECTED); - update.nodes[11].AddState(AX_STATE_SELECTED); + update.nodes[3].AddState(ax::mojom::State::kSelected); + update.nodes[7].AddState(ax::mojom::State::kSelected); + update.nodes[11].AddState(ax::mojom::State::kSelected); Init(update); @@ -2130,9 +2134,9 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableIsRowSelected) { // 6 == table_row_header_3 // 7 == table_cell_1 // 8 == table_cell_2 - update.nodes[6].AddState(AX_STATE_SELECTED); - update.nodes[7].AddState(AX_STATE_SELECTED); - update.nodes[8].AddState(AX_STATE_SELECTED); + update.nodes[6].AddState(ax::mojom::State::kSelected); + update.nodes[7].AddState(ax::mojom::State::kSelected); + update.nodes[8].AddState(ax::mojom::State::kSelected); Init(update); @@ -2166,9 +2170,9 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableIsSelected) { // 6 == table_row_header_3 // 7 == table_cell_1 // 8 == table_cell_2 - update.nodes[6].AddState(AX_STATE_SELECTED); - update.nodes[7].AddState(AX_STATE_SELECTED); - update.nodes[8].AddState(AX_STATE_SELECTED); + update.nodes[6].AddState(ax::mojom::State::kSelected); + update.nodes[7].AddState(ax::mojom::State::kSelected); + update.nodes[8].AddState(ax::mojom::State::kSelected); Init(update); @@ -2231,8 +2235,8 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTable2GetSelectedChildren) { // 7 == table_cell_1 // 12 == table_cell_4 - update.nodes[7].AddState(AX_STATE_SELECTED); - update.nodes[12].AddState(AX_STATE_SELECTED); + update.nodes[7].AddState(ax::mojom::State::kSelected); + update.nodes[12].AddState(ax::mojom::State::kSelected); Init(update); @@ -2261,9 +2265,9 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTable2GetSelectedChildren) { TEST_F(AXPlatformNodeWinTest, TestIAccessible2GetGroupPosition) { AXNodeData root; root.id = 1; - root.AddIntAttribute(AX_ATTR_HIERARCHICAL_LEVEL, 1); - root.AddIntAttribute(AX_ATTR_SET_SIZE, 1); - root.AddIntAttribute(AX_ATTR_POS_IN_SET, 1); + root.AddIntAttribute(ax::mojom::IntAttribute::kHierarchicalLevel, 1); + root.AddIntAttribute(ax::mojom::IntAttribute::kSetSize, 1); + root.AddIntAttribute(ax::mojom::IntAttribute::kPosInSet, 1); Init(root); ComPtr root_obj(GetRootIAccessible()); @@ -2281,7 +2285,8 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessible2GetGroupPosition) { TEST_F(AXPlatformNodeWinTest, TestIAccessible2GetLocalizedExtendedRole) { AXNodeData root; root.id = 1; - root.AddStringAttribute(AX_ATTR_ROLE_DESCRIPTION, "extended role"); + root.AddStringAttribute(ax::mojom::StringAttribute::kRoleDescription, + "extended role"); Init(root); ComPtr root_obj(GetRootIAccessible()); @@ -2294,12 +2299,12 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessible2GetLocalizedExtendedRole) { TEST_F(AXPlatformNodeWinTest, TestIAccessibleTextGetNCharacters) { AXNodeData root; root.id = 0; - root.role = AX_ROLE_STATIC_TEXT; + root.role = ax::mojom::Role::kStaticText; root.child_ids.push_back(1); AXNodeData node; node.id = 1; - node.role = AX_ROLE_STATIC_TEXT; + node.role = ax::mojom::Role::kStaticText; node.SetName("Name"); Init(root, node); diff --git a/ui/accessibility/platform/ax_platform_relation_win.cc b/ui/accessibility/platform/ax_platform_relation_win.cc index ed1e87b6268b79..803fc97e4d809a 100644 --- a/ui/accessibility/platform/ax_platform_relation_win.cc +++ b/ui/accessibility/platform/ax_platform_relation_win.cc @@ -41,13 +41,13 @@ AXPlatformRelationWin::AXPlatformRelationWin() { AXPlatformRelationWin::~AXPlatformRelationWin() {} -base::string16 GetIA2RelationFromIntAttr(ui::AXIntAttribute attribute) { +base::string16 GetIA2RelationFromIntAttr(ax::mojom::IntAttribute attribute) { switch (attribute) { - case AX_ATTR_DETAILS_ID: + case ax::mojom::IntAttribute::kDetailsId: return IA2_RELATION_DETAILS; - case AX_ATTR_MEMBER_OF_ID: + case ax::mojom::IntAttribute::kMemberOfId: return IA2_RELATION_MEMBER_OF; - case AX_ATTR_ERRORMESSAGE_ID: + case ax::mojom::IntAttribute::kErrormessageId: return IA2_RELATION_ERROR_MESSAGE; default: break; @@ -55,15 +55,16 @@ base::string16 GetIA2RelationFromIntAttr(ui::AXIntAttribute attribute) { return base::string16(); } -base::string16 GetIA2RelationFromIntListAttr(ui::AXIntListAttribute attribute) { +base::string16 GetIA2RelationFromIntListAttr( + ax::mojom::IntListAttribute attribute) { switch (attribute) { - case AX_ATTR_CONTROLS_IDS: + case ax::mojom::IntListAttribute::kControlsIds: return IA2_RELATION_CONTROLLER_FOR; - case AX_ATTR_DESCRIBEDBY_IDS: + case ax::mojom::IntListAttribute::kDescribedbyIds: return IA2_RELATION_DESCRIBED_BY; - case AX_ATTR_FLOWTO_IDS: + case ax::mojom::IntListAttribute::kFlowtoIds: return IA2_RELATION_FLOWS_TO; - case AX_ATTR_LABELLEDBY_IDS: + case ax::mojom::IntListAttribute::kLabelledbyIds: return IA2_RELATION_LABELLED_BY; default: break; @@ -71,9 +72,10 @@ base::string16 GetIA2RelationFromIntListAttr(ui::AXIntListAttribute attribute) { return base::string16(); } -base::string16 GetIA2ReverseRelationFromIntAttr(ui::AXIntAttribute attribute) { +base::string16 GetIA2ReverseRelationFromIntAttr( + ax::mojom::IntAttribute attribute) { switch (attribute) { - case AX_ATTR_DETAILS_ID: + case ax::mojom::IntAttribute::kDetailsId: return IA2_RELATION_DETAILS_FOR; default: break; @@ -82,15 +84,15 @@ base::string16 GetIA2ReverseRelationFromIntAttr(ui::AXIntAttribute attribute) { } base::string16 GetIA2ReverseRelationFromIntListAttr( - ui::AXIntListAttribute attribute) { + ax::mojom::IntListAttribute attribute) { switch (attribute) { - case AX_ATTR_CONTROLS_IDS: + case ax::mojom::IntListAttribute::kControlsIds: return IA2_RELATION_CONTROLLED_BY; - case AX_ATTR_DESCRIBEDBY_IDS: + case ax::mojom::IntListAttribute::kDescribedbyIds: return IA2_RELATION_DESCRIPTION_FOR; - case AX_ATTR_FLOWTO_IDS: + case ax::mojom::IntListAttribute::kFlowtoIds: return IA2_RELATION_FLOWS_FROM; - case AX_ATTR_LABELLEDBY_IDS: + case ax::mojom::IntListAttribute::kLabelledbyIds: return IA2_RELATION_LABEL_FOR; default: break; @@ -112,22 +114,25 @@ int AXPlatformRelationWin::EnumerateRelationships( // GetIA2ReverseRelationFrom{Int|IntList}Attr on every possible attribute // simplifies the work needed to support an additional relation // attribute in the future. - static std::vector int_attributes_with_reverse_relations; - static std::vector + static std::vector + int_attributes_with_reverse_relations; + static std::vector intlist_attributes_with_reverse_relations; static bool first_time = true; if (first_time) { - for (int32_t attr_index = static_cast(AX_INT_ATTRIBUTE_NONE); - attr_index <= static_cast(AX_INT_ATTRIBUTE_LAST); + for (int32_t attr_index = + static_cast(ax::mojom::IntAttribute::kNone); + attr_index <= static_cast(ax::mojom::IntAttribute::kLast); ++attr_index) { - auto attr = static_cast(attr_index); + auto attr = static_cast(attr_index); if (!GetIA2ReverseRelationFromIntAttr(attr).empty()) int_attributes_with_reverse_relations.push_back(attr); } - for (int32_t attr_index = static_cast(AX_INT_LIST_ATTRIBUTE_NONE); - attr_index <= static_cast(AX_INT_LIST_ATTRIBUTE_LAST); + for (int32_t attr_index = + static_cast(ax::mojom::IntListAttribute::kNone); + attr_index <= static_cast(ax::mojom::IntListAttribute::kLast); ++attr_index) { - auto attr = static_cast(attr_index); + auto attr = static_cast(attr_index); if (!GetIA2ReverseRelationFromIntListAttr(attr).empty()) intlist_attributes_with_reverse_relations.push_back(attr); } @@ -144,7 +149,7 @@ int AXPlatformRelationWin::EnumerateRelationships( // Iterate over all int attributes on this node to check the ones // that correspond to IAccessible2 relations. for (size_t i = 0; i < node_data.int_attributes.size(); ++i) { - AXIntAttribute int_attribute = node_data.int_attributes[i].first; + ax::mojom::IntAttribute int_attribute = node_data.int_attributes[i].first; base::string16 relation = GetIA2RelationFromIntAttr(int_attribute); if (!relation.empty() && (desired_ia2_relation.empty() || desired_ia2_relation == relation)) { @@ -162,7 +167,8 @@ int AXPlatformRelationWin::EnumerateRelationships( // Iterate over all of the int attributes that have reverse relations // in IAccessible2, and query AXTree to see if the reverse relation exists. - for (AXIntAttribute int_attribute : int_attributes_with_reverse_relations) { + for (ax::mojom::IntAttribute int_attribute : + int_attributes_with_reverse_relations) { base::string16 relation = GetIA2ReverseRelationFromIntAttr(int_attribute); std::set targets = delegate->GetReverseRelations(int_attribute, node_data.id); @@ -184,7 +190,7 @@ int AXPlatformRelationWin::EnumerateRelationships( // Iterate over all intlist attributes on this node to check the ones // that correspond to IAccessible2 relations. for (size_t i = 0; i < node_data.intlist_attributes.size(); ++i) { - AXIntListAttribute intlist_attribute = + ax::mojom::IntListAttribute intlist_attribute = node_data.intlist_attributes[i].first; base::string16 relation = GetIA2RelationFromIntListAttr(intlist_attribute); if (!relation.empty() && @@ -207,7 +213,7 @@ int AXPlatformRelationWin::EnumerateRelationships( // Iterate over all of the intlist attributes that have reverse relations // in IAccessible2, and query AXTree to see if the reverse relation exists. - for (AXIntListAttribute intlist_attribute : + for (ax::mojom::IntListAttribute intlist_attribute : intlist_attributes_with_reverse_relations) { base::string16 relation = GetIA2ReverseRelationFromIntListAttr(intlist_attribute); diff --git a/ui/accessibility/platform/ax_snapshot_node_android_platform.cc b/ui/accessibility/platform/ax_snapshot_node_android_platform.cc index 291f814a701eb2..998ae65757c597 100644 --- a/ui/accessibility/platform/ax_snapshot_node_android_platform.cc +++ b/ui/accessibility/platform/ax_snapshot_node_android_platform.cc @@ -10,7 +10,7 @@ #include "base/memory/ptr_util.h" #include "base/strings/stringprintf.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.h" #include "ui/accessibility/ax_role_properties.h" #include "ui/accessibility/ax_serializable_tree.h" @@ -24,7 +24,7 @@ namespace { bool HasFocusableChild(const AXNode* node) { for (auto* child : node->children()) { - if (child->data().HasState(AX_STATE_FOCUSABLE) || + if (child->data().HasState(ax::mojom::State::kFocusable) || HasFocusableChild(child)) { return true; } @@ -42,22 +42,24 @@ bool HasOnlyTextChildren(const AXNode* node) { // TODO(muyuanli): share with BrowserAccessibility. bool IsSimpleTextControl(const AXNode* node, uint32_t state) { - return (node->data().role == AX_ROLE_TEXT_FIELD || - node->data().role == AX_ROLE_TEXT_FIELD_WITH_COMBO_BOX || - node->data().role == AX_ROLE_SEARCH_BOX || - node->data().HasBoolAttribute(AX_ATTR_EDITABLE_ROOT)) && - !node->data().HasState(AX_STATE_RICHLY_EDITABLE); + return (node->data().role == ax::mojom::Role::kTextField || + node->data().role == ax::mojom::Role::kTextFieldWithComboBox || + node->data().role == ax::mojom::Role::kSearchBox || + node->data().HasBoolAttribute( + ax::mojom::BoolAttribute::kEditableRoot)) && + !node->data().HasState(ax::mojom::State::kRichlyEditable); } bool IsRichTextEditable(const AXNode* node) { const AXNode* parent = node->parent(); - return node->data().HasState(AX_STATE_RICHLY_EDITABLE) && - (!parent || !parent->data().HasState(AX_STATE_RICHLY_EDITABLE)); + return node->data().HasState(ax::mojom::State::kRichlyEditable) && + (!parent || + !parent->data().HasState(ax::mojom::State::kRichlyEditable)); } bool IsNativeTextControl(const AXNode* node) { const std::string& html_tag = - node->data().GetStringAttribute(AX_ATTR_HTML_TAG); + node->data().GetStringAttribute(ax::mojom::StringAttribute::kHtmlTag); if (html_tag == "input") { std::string input_type; if (!node->data().GetHtmlAttribute("type", &input_type)) @@ -79,15 +81,15 @@ bool IsLeaf(const AXNode* node) { } switch (node->data().role) { - case AX_ROLE_IMAGE: - case AX_ROLE_METER: - case AX_ROLE_SCROLL_BAR: - case AX_ROLE_SLIDER: - case AX_ROLE_SPLITTER: - case AX_ROLE_PROGRESS_INDICATOR: - case AX_ROLE_DATE: - case AX_ROLE_DATE_TIME: - case AX_ROLE_INPUT_TIME: + case ax::mojom::Role::kImage: + case ax::mojom::Role::kMeter: + case ax::mojom::Role::kScrollBar: + case ax::mojom::Role::kSlider: + case ax::mojom::Role::kSplitter: + case ax::mojom::Role::kProgressIndicator: + case ax::mojom::Role::kDate: + case ax::mojom::Role::kDateTime: + case ax::mojom::Role::kInputTime: return true; default: return false; @@ -96,7 +98,7 @@ bool IsLeaf(const AXNode* node) { base::string16 GetInnerText(const AXNode* node) { if (node->IsTextNode()) { - return node->data().GetString16Attribute(AX_ATTR_NAME); + return node->data().GetString16Attribute(ax::mojom::StringAttribute::kName); } base::string16 text; for (auto* child : node->children()) { @@ -106,7 +108,8 @@ base::string16 GetInnerText(const AXNode* node) { } base::string16 GetValue(const AXNode* node, bool show_password) { - base::string16 value = node->data().GetString16Attribute(AX_ATTR_VALUE); + base::string16 value = + node->data().GetString16Attribute(ax::mojom::StringAttribute::kValue); if (value.empty() && (IsSimpleTextControl(node, node->data().state) || @@ -115,7 +118,7 @@ base::string16 GetValue(const AXNode* node, bool show_password) { value = GetInnerText(node); } - if (node->data().HasState(AX_STATE_PROTECTED)) { + if (node->data().HasState(ax::mojom::State::kProtected)) { if (!show_password) { value = base::string16(value.size(), kSecurePasswordBullet); } @@ -126,8 +129,8 @@ base::string16 GetValue(const AXNode* node, bool show_password) { bool HasOnlyTextAndImageChildren(const AXNode* node) { for (auto* child : node->children()) { - if (child->data().role != AX_ROLE_STATIC_TEXT && - child->data().role != AX_ROLE_IMAGE) { + if (child->data().role != ax::mojom::Role::kStaticText && + child->data().role != ax::mojom::Role::kImage) { return false; } } @@ -135,25 +138,25 @@ bool HasOnlyTextAndImageChildren(const AXNode* node) { } bool IsFocusable(const AXNode* node) { - if (node->data().role == AX_ROLE_IFRAME || - node->data().role == AX_ROLE_IFRAME_PRESENTATIONAL || - (node->data().role == AX_ROLE_ROOT_WEB_AREA && node->parent())) { - return node->data().HasStringAttribute(AX_ATTR_NAME); + if (node->data().role == ax::mojom::Role::kIframe || + node->data().role == ax::mojom::Role::kIframePresentational || + (node->data().role == ax::mojom::Role::kRootWebArea && node->parent())) { + return node->data().HasStringAttribute(ax::mojom::StringAttribute::kName); } - return node->data().HasState(AX_STATE_FOCUSABLE); + return node->data().HasState(ax::mojom::State::kFocusable); } base::string16 GetText(const AXNode* node, bool show_password) { - if (node->data().role == AX_ROLE_WEB_AREA || - node->data().role == AX_ROLE_IFRAME || - node->data().role == AX_ROLE_IFRAME_PRESENTATIONAL) { + if (node->data().role == ax::mojom::Role::kWebArea || + node->data().role == ax::mojom::Role::kIframe || + node->data().role == ax::mojom::Role::kIframePresentational) { return base::string16(); } - ui::AXNameFrom name_from = static_cast( - node->data().GetIntAttribute(AX_ATTR_NAME_FROM)); - if (node->data().role == AX_ROLE_LIST_ITEM && - name_from == AX_NAME_FROM_CONTENTS) { + ax::mojom::NameFrom name_from = static_cast( + node->data().GetIntAttribute(ax::mojom::IntAttribute::kNameFrom)); + if (node->data().role == ax::mojom::Role::kListItem && + name_from == ax::mojom::NameFrom::kContents) { if (node->child_count() > 0 && !HasOnlyTextChildren(node)) return base::string16(); } @@ -161,23 +164,23 @@ base::string16 GetText(const AXNode* node, bool show_password) { base::string16 value = GetValue(node, show_password); if (!value.empty()) { - if (node->data().HasState(AX_STATE_EDITABLE)) + if (node->data().HasState(ax::mojom::State::kEditable)) return value; switch (node->data().role) { - case AX_ROLE_COMBO_BOX_MENU_BUTTON: - case AX_ROLE_TEXT_FIELD_WITH_COMBO_BOX: - case AX_ROLE_POP_UP_BUTTON: - case AX_ROLE_TEXT_FIELD: + case ax::mojom::Role::kComboBoxMenuButton: + case ax::mojom::Role::kTextFieldWithComboBox: + case ax::mojom::Role::kPopUpButton: + case ax::mojom::Role::kTextField: return value; default: break; } } - if (node->data().role == AX_ROLE_COLOR_WELL) { + if (node->data().role == ax::mojom::Role::kColorWell) { unsigned int color = static_cast( - node->data().GetIntAttribute(AX_ATTR_COLOR_VALUE)); + node->data().GetIntAttribute(ax::mojom::IntAttribute::kColorValue)); unsigned int red = color >> 16 & 0xFF; unsigned int green = color >> 8 & 0xFF; unsigned int blue = color >> 0 & 0xFF; @@ -185,9 +188,10 @@ base::string16 GetText(const AXNode* node, bool show_password) { base::StringPrintf("#%02X%02X%02X", red, green, blue)); } - base::string16 text = node->data().GetString16Attribute(AX_ATTR_NAME); - base::string16 description = - node->data().GetString16Attribute(AX_ATTR_DESCRIPTION); + base::string16 text = + node->data().GetString16Attribute(ax::mojom::StringAttribute::kName); + base::string16 description = node->data().GetString16Attribute( + ax::mojom::StringAttribute::kDescription); if (!description.empty()) { if (!text.empty()) text += base::ASCIIToUTF16(" "); @@ -197,7 +201,7 @@ base::string16 GetText(const AXNode* node, bool show_password) { if (text.empty()) text = value; - if (node->data().role == AX_ROLE_ROOT_WEB_AREA) + if (node->data().role == ax::mojom::Role::kRootWebArea) return text; if (text.empty() && @@ -209,51 +213,52 @@ base::string16 GetText(const AXNode* node, bool show_password) { } if (text.empty() && (AXSnapshotNodeAndroid::AXRoleIsLink(node->data().role) || - node->data().role == AX_ROLE_IMAGE)) { - base::string16 url = node->data().GetString16Attribute(AX_ATTR_URL); + node->data().role == ax::mojom::Role::kImage)) { + base::string16 url = + node->data().GetString16Attribute(ax::mojom::StringAttribute::kUrl); text = AXSnapshotNodeAndroid::AXUrlBaseText(url); } return text; } -// Get string representation of AXRole. We are not using ToString() in +// Get string representation of ax::mojom::Role. We are not using ToString() in // ax_enums.h since the names are subject to change in the future and // we are only interested in a subset of the roles. -base::Optional AXRoleToString(AXRole role) { +base::Optional AXRoleToString(ax::mojom::Role role) { switch (role) { - case AX_ROLE_ARTICLE: + case ax::mojom::Role::kArticle: return base::Optional("article"); - case AX_ROLE_BANNER: + case ax::mojom::Role::kBanner: return base::Optional("banner"); - case AX_ROLE_CAPTION: + case ax::mojom::Role::kCaption: return base::Optional("caption"); - case AX_ROLE_COMPLEMENTARY: + case ax::mojom::Role::kComplementary: return base::Optional("complementary"); - case AX_ROLE_DATE: + case ax::mojom::Role::kDate: return base::Optional("date"); - case AX_ROLE_DATE_TIME: + case ax::mojom::Role::kDateTime: return base::Optional("date_time"); - case AX_ROLE_DEFINITION: + case ax::mojom::Role::kDefinition: return base::Optional("definition"); - case AX_ROLE_DETAILS: + case ax::mojom::Role::kDetails: return base::Optional("details"); - case AX_ROLE_DOCUMENT: + case ax::mojom::Role::kDocument: return base::Optional("document"); - case AX_ROLE_FEED: + case ax::mojom::Role::kFeed: return base::Optional("feed"); - case AX_ROLE_HEADING: + case ax::mojom::Role::kHeading: return base::Optional("heading"); - case AX_ROLE_IFRAME: + case ax::mojom::Role::kIframe: return base::Optional("iframe"); - case AX_ROLE_IFRAME_PRESENTATIONAL: + case ax::mojom::Role::kIframePresentational: return base::Optional("iframe_presentational"); - case AX_ROLE_LIST: + case ax::mojom::Role::kList: return base::Optional("list"); - case AX_ROLE_LIST_ITEM: + case ax::mojom::Role::kListItem: return base::Optional("list_item"); - case AX_ROLE_MAIN: + case ax::mojom::Role::kMain: return base::Optional("main"); - case AX_ROLE_PARAGRAPH: + case ax::mojom::Role::kParagraph: return base::Optional("paragraph"); default: return base::Optional(); @@ -283,8 +288,8 @@ AX_EXPORT std::unique_ptr AXSnapshotNodeAndroid::Create( } // static -AX_EXPORT bool AXSnapshotNodeAndroid::AXRoleIsLink(AXRole role) { - return role == AX_ROLE_LINK; +AX_EXPORT bool AXSnapshotNodeAndroid::AXRoleIsLink(ax::mojom::Role role) { + return role == ax::mojom::Role::kLink; } // static @@ -310,56 +315,56 @@ AX_EXPORT base::string16 AXSnapshotNodeAndroid::AXUrlBaseText( // static AX_EXPORT const char* AXSnapshotNodeAndroid::AXRoleToAndroidClassName( - AXRole role, + ax::mojom::Role role, bool has_parent) { switch (role) { - case AX_ROLE_SEARCH_BOX: - case AX_ROLE_SPIN_BUTTON: - case AX_ROLE_TEXT_FIELD: - case AX_ROLE_TEXT_FIELD_WITH_COMBO_BOX: + case ax::mojom::Role::kSearchBox: + case ax::mojom::Role::kSpinButton: + case ax::mojom::Role::kTextField: + case ax::mojom::Role::kTextFieldWithComboBox: return kAXEditTextClassname; - case AX_ROLE_SLIDER: + case ax::mojom::Role::kSlider: return kAXSeekBarClassname; - case AX_ROLE_COLOR_WELL: - case AX_ROLE_COMBO_BOX_MENU_BUTTON: - case AX_ROLE_DATE: - case AX_ROLE_POP_UP_BUTTON: - case AX_ROLE_INPUT_TIME: + case ax::mojom::Role::kColorWell: + case ax::mojom::Role::kComboBoxMenuButton: + case ax::mojom::Role::kDate: + case ax::mojom::Role::kPopUpButton: + case ax::mojom::Role::kInputTime: return kAXSpinnerClassname; - case AX_ROLE_BUTTON: - case AX_ROLE_MENU_BUTTON: + case ax::mojom::Role::kButton: + case ax::mojom::Role::kMenuButton: return kAXButtonClassname; - case AX_ROLE_CHECK_BOX: - case AX_ROLE_SWITCH: + case ax::mojom::Role::kCheckBox: + case ax::mojom::Role::kSwitch: return kAXCheckBoxClassname; - case AX_ROLE_RADIO_BUTTON: + case ax::mojom::Role::kRadioButton: return kAXRadioButtonClassname; - case AX_ROLE_TOGGLE_BUTTON: + case ax::mojom::Role::kToggleButton: return kAXToggleButtonClassname; - case AX_ROLE_CANVAS: - case AX_ROLE_IMAGE: - case AX_ROLE_SVG_ROOT: + case ax::mojom::Role::kCanvas: + case ax::mojom::Role::kImage: + case ax::mojom::Role::kSvgRoot: return kAXImageClassname; - case AX_ROLE_METER: - case AX_ROLE_PROGRESS_INDICATOR: + case ax::mojom::Role::kMeter: + case ax::mojom::Role::kProgressIndicator: return kAXProgressBarClassname; - case AX_ROLE_TAB_LIST: + case ax::mojom::Role::kTabList: return kAXTabWidgetClassname; - case AX_ROLE_GRID: - case AX_ROLE_TREE_GRID: - case AX_ROLE_TABLE: + case ax::mojom::Role::kGrid: + case ax::mojom::Role::kTreeGrid: + case ax::mojom::Role::kTable: return kAXGridViewClassname; - case AX_ROLE_LIST: - case AX_ROLE_LIST_BOX: - case AX_ROLE_DESCRIPTION_LIST: + case ax::mojom::Role::kList: + case ax::mojom::Role::kListBox: + case ax::mojom::Role::kDescriptionList: return kAXListViewClassname; - case AX_ROLE_DIALOG: + case ax::mojom::Role::kDialog: return kAXDialogClassname; - case AX_ROLE_ROOT_WEB_AREA: + case ax::mojom::Role::kRootWebArea: return has_parent ? kAXViewClassname : kAXWebViewClassname; - case AX_ROLE_MENU_ITEM: - case AX_ROLE_MENU_ITEM_CHECK_BOX: - case AX_ROLE_MENU_ITEM_RADIO: + case ax::mojom::Role::kMenuItem: + case ax::mojom::Role::kMenuItemCheckBox: + case ax::mojom::Role::kMenuItemRadio: return kAXMenuItemClassname; default: return kAXViewClassname; @@ -389,23 +394,32 @@ AXSnapshotNodeAndroid::WalkAXTreeDepthFirst( result->line_through = 0; result->underline = 0; - if (node->data().HasFloatAttribute(AX_ATTR_FONT_SIZE)) { + if (node->data().HasFloatAttribute(ax::mojom::FloatAttribute::kFontSize)) { gfx::RectF text_size_rect( - 0, 0, 1, node->data().GetFloatAttribute(AX_ATTR_FONT_SIZE)); + 0, 0, 1, + node->data().GetFloatAttribute(ax::mojom::FloatAttribute::kFontSize)); gfx::Rect scaled_text_size_rect = gfx::ToEnclosingRect(tree->RelativeToTreeBounds(node, text_size_rect)); result->text_size = scaled_text_size_rect.height(); - const int32_t text_style = node->data().GetIntAttribute(AX_ATTR_TEXT_STYLE); - result->color = node->data().GetIntAttribute(AX_ATTR_COLOR); - result->bgcolor = node->data().GetIntAttribute(AX_ATTR_BACKGROUND_COLOR); - result->bold = (text_style & static_cast(AX_TEXT_STYLE_BOLD)) != 0; + const int32_t text_style = + node->data().GetIntAttribute(ax::mojom::IntAttribute::kTextStyle); + result->color = + node->data().GetIntAttribute(ax::mojom::IntAttribute::kColor); + result->bgcolor = + node->data().GetIntAttribute(ax::mojom::IntAttribute::kBackgroundColor); + result->bold = + (text_style & + static_cast(ax::mojom::TextStyle::kTextStyleBold)) != 0; result->italic = - (text_style & static_cast(AX_TEXT_STYLE_ITALIC)) != 0; + (text_style & + static_cast(ax::mojom::TextStyle::kTextStyleItalic)) != 0; result->line_through = - (text_style & static_cast(AX_TEXT_STYLE_LINE_THROUGH)) != 0; + (text_style & static_cast( + ax::mojom::TextStyle::kTextStyleLineThrough)) != 0; result->underline = - (text_style & static_cast(AX_TEXT_STYLE_UNDERLINE)) != 0; + (text_style & + static_cast(ax::mojom::TextStyle::kTextStyleUnderline)) != 0; } const gfx::Rect& absolute_rect = diff --git a/ui/accessibility/platform/ax_snapshot_node_android_platform.h b/ui/accessibility/platform/ax_snapshot_node_android_platform.h index be01b51bcee991..f5502219fd5f6b 100644 --- a/ui/accessibility/platform/ax_snapshot_node_android_platform.h +++ b/ui/accessibility/platform/ax_snapshot_node_android_platform.h @@ -11,7 +11,7 @@ #include "base/optional.h" #include "base/strings/string16.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_export.h" #include "ui/accessibility/ax_tree_update.h" #include "ui/gfx/geometry/rect.h" @@ -32,11 +32,11 @@ struct AXSnapshotNodeAndroid { bool show_password); // Returns a fake Android view class that is a closest - // approximation of the AXRole. - AX_EXPORT static const char* AXRoleToAndroidClassName(AXRole role, + // approximation of the ax::mojom::Role. + AX_EXPORT static const char* AXRoleToAndroidClassName(ax::mojom::Role role, bool has_parent); - AX_EXPORT static bool AXRoleIsLink(AXRole role); + AX_EXPORT static bool AXRoleIsLink(ax::mojom::Role role); AX_EXPORT static base::string16 AXUrlBaseText(base::string16 url); diff --git a/ui/accessibility/platform/ax_system_caret_win.cc b/ui/accessibility/platform/ax_system_caret_win.cc index 7547cd669a9c52..571c0e19b69cdf 100644 --- a/ui/accessibility/platform/ax_system_caret_win.cc +++ b/ui/accessibility/platform/ax_system_caret_win.cc @@ -7,7 +7,7 @@ #include #include "base/logging.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/platform/ax_platform_node_win.h" #include "ui/gfx/geometry/rect_conversions.h" #include "ui/gfx/geometry/rect_f.h" @@ -21,7 +21,7 @@ AXSystemCaretWin::AXSystemCaretWin(gfx::AcceleratedWidget event_target) // a node ID. A globally unique ID is used when firing Win events, retrieved // via |unique_id|. data_.id = -1; - data_.role = AX_ROLE_CARET; + data_.role = ax::mojom::Role::kCaret; // |get_accState| should return 0 which means that the caret is visible. data_.state = 0; // According to MSDN, "Edit" should be the name of the caret object. @@ -133,13 +133,15 @@ bool AXSystemCaretWin::IsOffscreen() const { return false; } -std::set AXSystemCaretWin::GetReverseRelations(AXIntAttribute attr, - int32_t dst_id) { +std::set AXSystemCaretWin::GetReverseRelations( + ax::mojom::IntAttribute attr, + int32_t dst_id) { return std::set(); } -std::set AXSystemCaretWin::GetReverseRelations(AXIntListAttribute attr, - int32_t dst_id) { +std::set AXSystemCaretWin::GetReverseRelations( + ax::mojom::IntListAttribute attr, + int32_t dst_id) { return std::set(); } diff --git a/ui/accessibility/platform/ax_system_caret_win.h b/ui/accessibility/platform/ax_system_caret_win.h index 6a4ec9686ee8fb..2479ee3b15dcce 100644 --- a/ui/accessibility/platform/ax_system_caret_win.h +++ b/ui/accessibility/platform/ax_system_caret_win.h @@ -50,9 +50,9 @@ class AX_EXPORT AXSystemCaretWin : private AXPlatformNodeDelegate { bool ShouldIgnoreHoveredStateForTesting() override; bool IsOffscreen() const override; const ui::AXUniqueId& GetUniqueId() const override; - std::set GetReverseRelations(AXIntAttribute attr, + std::set GetReverseRelations(ax::mojom::IntAttribute attr, int32_t dst_id) override; - std::set GetReverseRelations(AXIntListAttribute attr, + std::set GetReverseRelations(ax::mojom::IntListAttribute attr, int32_t dst_id) override; AXPlatformNodeWin* caret_; diff --git a/ui/accessibility/platform/test_ax_node_wrapper.cc b/ui/accessibility/platform/test_ax_node_wrapper.cc index 045e04cef2bd85..6e8c1fa057728a 100644 --- a/ui/accessibility/platform/test_ax_node_wrapper.cc +++ b/ui/accessibility/platform/test_ax_node_wrapper.cc @@ -176,7 +176,7 @@ TestAXNodeWrapper::GetTargetForNativeAccessibilityEvent() { } void TestAXNodeWrapper::ReplaceIntAttribute(int32_t node_id, - AXIntAttribute attribute, + ax::mojom::IntAttribute attribute, int32_t value) { if (!tree_) return; @@ -186,7 +186,7 @@ void TestAXNodeWrapper::ReplaceIntAttribute(int32_t node_id, return; AXNodeData new_data = node->data(); - std::vector>& attributes = + std::vector>& attributes = new_data.int_attributes; auto deleted = std::remove_if( @@ -200,21 +200,23 @@ void TestAXNodeWrapper::ReplaceIntAttribute(int32_t node_id, bool TestAXNodeWrapper::AccessibilityPerformAction( const ui::AXActionData& data) { - if (data.action == ui::AX_ACTION_SCROLL_TO_POINT) { + if (data.action == ax::mojom::Action::kScrollToPoint) { g_offset = gfx::Vector2d(data.target_point.x(), data.target_point.y()); return true; } - if (data.action == ui::AX_ACTION_SCROLL_TO_MAKE_VISIBLE) { + if (data.action == ax::mojom::Action::kScrollToMakeVisible) { auto offset = node_->data().location.OffsetFromOrigin(); g_offset = gfx::Vector2d(-offset.x(), -offset.y()); return true; } - if (data.action == ui::AX_ACTION_SET_SELECTION) { - ReplaceIntAttribute(data.anchor_node_id, AX_ATTR_TEXT_SEL_START, + if (data.action == ax::mojom::Action::kSetSelection) { + ReplaceIntAttribute(data.anchor_node_id, + ax::mojom::IntAttribute::kTextSelStart, data.anchor_offset); - ReplaceIntAttribute(data.anchor_node_id, AX_ATTR_TEXT_SEL_END, + ReplaceIntAttribute(data.anchor_node_id, + ax::mojom::IntAttribute::kTextSelEnd, data.focus_offset); return true; } @@ -230,13 +232,14 @@ bool TestAXNodeWrapper::IsOffscreen() const { return false; } -std::set TestAXNodeWrapper::GetReverseRelations(AXIntAttribute attr, - int32_t dst_id) { +std::set TestAXNodeWrapper::GetReverseRelations( + ax::mojom::IntAttribute attr, + int32_t dst_id) { return tree_->GetReverseRelations(attr, dst_id); } std::set TestAXNodeWrapper::GetReverseRelations( - AXIntListAttribute attr, + ax::mojom::IntListAttribute attr, int32_t dst_id) { return tree_->GetReverseRelations(attr, dst_id); } diff --git a/ui/accessibility/platform/test_ax_node_wrapper.h b/ui/accessibility/platform/test_ax_node_wrapper.h index 4327748de82c3c..bb30f86868424a 100644 --- a/ui/accessibility/platform/test_ax_node_wrapper.h +++ b/ui/accessibility/platform/test_ax_node_wrapper.h @@ -47,15 +47,15 @@ class TestAXNodeWrapper : public AXPlatformNodeDelegate { bool ShouldIgnoreHoveredStateForTesting() override; bool IsOffscreen() const override; const ui::AXUniqueId& GetUniqueId() const override; - std::set GetReverseRelations(AXIntAttribute attr, + std::set GetReverseRelations(ax::mojom::IntAttribute attr, int32_t dst_id) override; - std::set GetReverseRelations(AXIntListAttribute attr, + std::set GetReverseRelations(ax::mojom::IntListAttribute attr, int32_t dst_id) override; private: TestAXNodeWrapper(AXTree* tree, AXNode* node); void ReplaceIntAttribute(int32_t node_id, - AXIntAttribute attribute, + ax::mojom::IntAttribute attribute, int32_t value); TestAXNodeWrapper* HitTestSyncInternal(int x, int y); diff --git a/ui/app_list/presenter/BUILD.gn b/ui/app_list/presenter/BUILD.gn index 58cc1463e8337c..82d6dae01c9567 100644 --- a/ui/app_list/presenter/BUILD.gn +++ b/ui/app_list/presenter/BUILD.gn @@ -51,7 +51,7 @@ component("presenter") { # Temporary dependency to fix compile flake in http://crbug.com/611898. # TODO(tapted): Remove once http://crbug.com/612382 is fixed. - "//ui/accessibility:ax_gen", + "//ui/accessibility:ax_enums_mojo", ] } @@ -66,7 +66,7 @@ static_library("test_support") { # Temporary dependency to fix compile flake in http://crbug.com/611898. # TODO(tapted): Remove once http://crbug.com/612382 is fixed. - "//ui/accessibility:ax_gen", + "//ui/accessibility:ax_enums_mojo", ] public_deps = [ @@ -105,7 +105,7 @@ test("app_list_presenter_unittests") { # Temporary dependency to fix compile flake in http://crbug.com/611898. # TODO(tapted): Remove once http://crbug.com/612382 is fixed. - "//ui/accessibility:ax_gen", + "//ui/accessibility:ax_enums_mojo", ] data_deps = [ diff --git a/ui/app_list/views/app_list_folder_view.cc b/ui/app_list/views/app_list_folder_view.cc index 8d64c348e1fb98..af4aeb38307e5e 100644 --- a/ui/app_list/views/app_list_folder_view.cc +++ b/ui/app_list/views/app_list_folder_view.cc @@ -115,7 +115,7 @@ AppListFolderView::~AppListFolderView() { void AppListFolderView::SetAppListFolderItem(AppListFolderItem* folder) { accessible_name_ = ui::ResourceBundle::GetSharedInstance().GetLocalizedString( IDS_APP_LIST_FOLDER_OPEN_FOLDER_ACCESSIBILE_NAME); - NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); + NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true); folder_item_ = folder; items_grid_view_->SetItemList(folder_item_->item_list()); @@ -317,7 +317,7 @@ void AppListFolderView::HideViewImmediately() { void AppListFolderView::CloseFolderPage() { accessible_name_ = ui::ResourceBundle::GetSharedInstance().GetLocalizedString( IDS_APP_LIST_FOLDER_CLOSE_FOLDER_ACCESSIBILE_NAME); - NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); + NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true); GiveBackFocusToSearchBox(); if (items_grid_view()->dragging()) @@ -335,7 +335,7 @@ void AppListFolderView::SetRootLevelDragViewVisible(bool visible) { } void AppListFolderView::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_GENERIC_CONTAINER; + node_data->role = ax::mojom::Role::kGenericContainer; node_data->SetName(accessible_name_); } diff --git a/ui/app_list/views/app_list_view.cc b/ui/app_list/views/app_list_view.cc index 9424d7c463b97f..2b98b560ea1a53 100644 --- a/ui/app_list/views/app_list_view.cc +++ b/ui/app_list/views/app_list_view.cc @@ -430,7 +430,8 @@ void AppListView::InitChildWidgets() { // that hitting search+right could move ChromeVox focus across search box to // other elements in app list view. search_box_widget_->GetNativeWindow()->SetProperty( - ui::kAXRoleOverride, static_cast(ui::AX_ROLE_GROUP)); + ui::kAXRoleOverride, + static_cast(ax::mojom::Role::kGroup)); // The search box will not naturally receive focus by itself (because it is in // a separate widget). Create this SearchBoxFocusHost in the main widget to @@ -769,7 +770,7 @@ void AppListView::MaybeCreateAccessibilityEvent(AppListViewState new_state) { state_announcement_ = l10n_util::GetStringUTF16( IDS_APP_LIST_ALL_APPS_ACCESSIBILITY_ANNOUNCEMENT); } - NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); + NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true); state_announcement_ = base::string16(); } @@ -946,11 +947,11 @@ void AppListView::OnGestureEvent(ui::GestureEvent* event) { } } -ui::AXRole AppListView::GetAccessibleWindowRole() const { - // Default role of root view is AX_ROLE_WINDOW which traps ChromeVox focus - // within the root view. Assign AX_ROLE_GROUP here to allow the focus to move - // from elements in app list view to search box. - return ui::AX_ROLE_GROUP; +ax::mojom::Role AppListView::GetAccessibleWindowRole() const { + // Default role of root view is ax::mojom::Role::kWindow which traps ChromeVox + // focus within the root view. Assign ax::mojom::Role::kGroup here to allow + // the focus to move from elements in app list view to search box. + return ax::mojom::Role::kGroup; } bool AppListView::AcceleratorPressed(const ui::Accelerator& accelerator) { @@ -984,7 +985,7 @@ void AppListView::Layout() { void AppListView::GetAccessibleNodeData(ui::AXNodeData* node_data) { node_data->SetName(state_announcement_); - node_data->role = ui::AX_ROLE_DESKTOP; + node_data->role = ax::mojom::Role::kDesktop; } void AppListView::OnKeyEvent(ui::KeyEvent* event) { diff --git a/ui/app_list/views/app_list_view.h b/ui/app_list/views/app_list_view.h index 4524adf95cb195..fdb9b718b83c98 100644 --- a/ui/app_list/views/app_list_view.h +++ b/ui/app_list/views/app_list_view.h @@ -130,7 +130,7 @@ class APP_LIST_EXPORT AppListView : public views::WidgetDelegateView, // WidgetDelegate overrides: bool ShouldHandleSystemCommands() const override; - ui::AXRole GetAccessibleWindowRole() const override; + ax::mojom::Role GetAccessibleWindowRole() const override; // Overridden from views::View: bool AcceleratorPressed(const ui::Accelerator& accelerator) override; diff --git a/ui/app_list/views/apps_grid_view.cc b/ui/app_list/views/apps_grid_view.cc index 382be07402afbc..dc36586eee1131 100644 --- a/ui/app_list/views/apps_grid_view.cc +++ b/ui/app_list/views/apps_grid_view.cc @@ -1114,7 +1114,7 @@ void AppsGridView::SetSelectedItemByIndex(const Index& index) { selected_view_ = new_selection; selected_view_->SetTitleSubpixelAA(); selected_view_->SchedulePaint(); - selected_view_->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); + selected_view_->NotifyAccessibilityEvent(ax::mojom::Event::kSelection, true); } bool AppsGridView::IsValidIndex(const Index& index) const { diff --git a/ui/app_list/views/page_switcher.cc b/ui/app_list/views/page_switcher.cc index c14d7c7ba5ee9b..76f6cfd5f27e48 100644 --- a/ui/app_list/views/page_switcher.cc +++ b/ui/app_list/views/page_switcher.cc @@ -74,7 +74,7 @@ class PageSwitcherButton : public views::Button { selected_ = selected; SchedulePaint(); if (selected) - NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); + NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true); } // Overridden from views::View: diff --git a/ui/app_list/views/search_box_view.cc b/ui/app_list/views/search_box_view.cc index 47591184b2b6b9..b9c41dc62d0da4 100644 --- a/ui/app_list/views/search_box_view.cc +++ b/ui/app_list/views/search_box_view.cc @@ -445,11 +445,11 @@ void SearchBoxView::OnKeyEvent(ui::KeyEvent* event) { event->SetHandled(); } -ui::AXRole SearchBoxView::GetAccessibleWindowRole() const { - // Default role of root view is AX_ROLE_WINDOW which traps ChromeVox focus - // within the root view. Assign AX_ROLE_GROUP here to allow the focus to move - // from elements in search box to app list view. - return ui::AX_ROLE_GROUP; +ax::mojom::Role SearchBoxView::GetAccessibleWindowRole() const { + // Default role of root view is ax::mojom::Role::kWindow which traps ChromeVox + // focus within the root view. Assign ax::mojom::Role::kGroup here to allow + // the focus to move from elements in search box to app list view. + return ax::mojom::Role::kGroup; } bool SearchBoxView::ShouldAdvanceFocusToTopLevelWidget() const { diff --git a/ui/app_list/views/search_box_view.h b/ui/app_list/views/search_box_view.h index 11e0f4f76c0baa..0662570d6be5aa 100644 --- a/ui/app_list/views/search_box_view.h +++ b/ui/app_list/views/search_box_view.h @@ -98,7 +98,7 @@ class APP_LIST_EXPORT SearchBoxView : public views::WidgetDelegateView, void OnKeyEvent(ui::KeyEvent* evetn) override; // Overridden from views::WidgetDelegate: - ui::AXRole GetAccessibleWindowRole() const override; + ax::mojom::Role GetAccessibleWindowRole() const override; bool ShouldAdvanceFocusToTopLevelWidget() const override; // Overridden from views::ButtonListener: diff --git a/ui/app_list/views/search_result_actions_view.cc b/ui/app_list/views/search_result_actions_view.cc index ef36bb1ce53db0..9331e90fc60c78 100644 --- a/ui/app_list/views/search_result_actions_view.cc +++ b/ui/app_list/views/search_result_actions_view.cc @@ -56,7 +56,7 @@ void SearchResultActionsView::SetSelectedAction(int action_index) { if (IsValidActionIndex(selected_action_)) { child_at(selected_action_) - ->NotifyAccessibilityEvent(ui::AX_EVENT_HOVER, true); + ->NotifyAccessibilityEvent(ax::mojom::Event::kHover, true); } } diff --git a/ui/app_list/views/search_result_answer_card_view.cc b/ui/app_list/views/search_result_answer_card_view.cc index 50cda6c6f2a270..65e10f442381ce 100644 --- a/ui/app_list/views/search_result_answer_card_view.cc +++ b/ui/app_list/views/search_result_answer_card_view.cc @@ -94,7 +94,7 @@ class SearchResultAnswerCardView::SearchAnswerContainerView void OnFocus() override { SetSelected(true); - NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); + NotifyAccessibilityEvent(ax::mojom::Event::kSelection, true); Button::OnFocus(); } @@ -110,7 +110,7 @@ class SearchResultAnswerCardView::SearchAnswerContainerView void GetAccessibleNodeData(ui::AXNodeData* node_data) override { // Default button role is atomic for ChromeVox, so assign a generic // container role to allow accessibility focus to get into this view. - node_data->role = ui::AX_ROLE_GENERIC_CONTAINER; + node_data->role = ax::mojom::Role::kGenericContainer; node_data->SetName(accessible_name()); } @@ -186,7 +186,7 @@ int SearchResultAnswerCardView::DoUpdate() { set_container_score(have_result ? display_results.front()->relevance() : 0); if (title_changed && search_answer_container_view_->selected()) search_answer_container_view_->NotifyAccessibilityEvent( - ui::AX_EVENT_SELECTION, true); + ax::mojom::Event::kSelection, true); return have_result ? 1 : 0; } @@ -199,7 +199,7 @@ void SearchResultAnswerCardView::UpdateSelectedIndex(int old_selected, search_answer_container_view_->SetSelected(is_selected); if (is_selected) search_answer_container_view_->NotifyAccessibilityEvent( - ui::AX_EVENT_SELECTION, true); + ax::mojom::Event::kSelection, true); } bool SearchResultAnswerCardView::OnKeyPressed(const ui::KeyEvent& event) { diff --git a/ui/app_list/views/search_result_answer_card_view_unittest.cc b/ui/app_list/views/search_result_answer_card_view_unittest.cc index 5b10d55b206751..5292409c8a7b19 100644 --- a/ui/app_list/views/search_result_answer_card_view_unittest.cc +++ b/ui/app_list/views/search_result_answer_card_view_unittest.cc @@ -160,8 +160,9 @@ TEST_F(SearchResultAnswerCardViewTest, KeyboardEvents) { TEST_F(SearchResultAnswerCardViewTest, SpokenFeedback) { ui::AXNodeData node_data; GetAccessibleNodeData(&node_data); - EXPECT_EQ(ui::AX_ROLE_GENERIC_CONTAINER, node_data.role); - EXPECT_EQ(kResultTitle, node_data.GetStringAttribute(ui::AX_ATTR_NAME)); + EXPECT_EQ(ax::mojom::Role::kGenericContainer, node_data.role); + EXPECT_EQ(kResultTitle, + node_data.GetStringAttribute(ax::mojom::StringAttribute::kName)); } TEST_F(SearchResultAnswerCardViewTest, DeleteResult) { diff --git a/ui/app_list/views/search_result_list_view.cc b/ui/app_list/views/search_result_list_view.cc index 5ff6e34b0bd6da..cf3bc1a38a6207 100644 --- a/ui/app_list/views/search_result_list_view.cc +++ b/ui/app_list/views/search_result_list_view.cc @@ -143,7 +143,7 @@ void SearchResultListView::UpdateSelectedIndex(int old_selected, ScrollRectToVisible(selected_view->bounds()); selected_view->ClearSelectedAction(); selected_view->SchedulePaint(); - selected_view->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); + selected_view->NotifyAccessibilityEvent(ax::mojom::Event::kSelection, true); } } diff --git a/ui/app_list/views/search_result_tile_item_list_view_unittest.cc b/ui/app_list/views/search_result_tile_item_list_view_unittest.cc index 2065a0c0911e6d..56c92b5131d414 100644 --- a/ui/app_list/views/search_result_tile_item_list_view_unittest.cc +++ b/ui/app_list/views/search_result_tile_item_list_view_unittest.cc @@ -153,9 +153,9 @@ TEST_P(SearchResultTileItemListViewTest, Basic) { view() ->child_at(first_child + i * child_step) ->GetAccessibleNodeData(&node_data); - EXPECT_EQ(ui::AX_ROLE_BUTTON, node_data.role); + EXPECT_EQ(ax::mojom::Role::kButton, node_data.role); EXPECT_EQ(base::StringPrintf("InstalledApp %d", i), - node_data.GetStringAttribute(ui::AX_ATTR_NAME)); + node_data.GetStringAttribute(ax::mojom::StringAttribute::kName)); } for (int i = kInstalledApps; i < expected_results; ++i) { @@ -163,11 +163,11 @@ TEST_P(SearchResultTileItemListViewTest, Basic) { view() ->child_at(first_child + i * child_step) ->GetAccessibleNodeData(&node_data); - EXPECT_EQ(ui::AX_ROLE_BUTTON, node_data.role); + EXPECT_EQ(ax::mojom::Role::kButton, node_data.role); EXPECT_EQ(base::StringPrintf("PlayStoreApp %d, Star rating %d.0, Price %d", i - kInstalledApps, i + 1 - kInstalledApps, i - kInstalledApps), - node_data.GetStringAttribute(ui::AX_ATTR_NAME)); + node_data.GetStringAttribute(ax::mojom::StringAttribute::kName)); } ResetOpenResultCount(); diff --git a/ui/app_list/views/search_result_tile_item_view.cc b/ui/app_list/views/search_result_tile_item_view.cc index 8a8a4e674fb9ec..5321146074e88b 100644 --- a/ui/app_list/views/search_result_tile_item_view.cc +++ b/ui/app_list/views/search_result_tile_item_view.cc @@ -267,19 +267,19 @@ void SearchResultTileItemView::ButtonPressed(views::Button* sender, void SearchResultTileItemView::GetAccessibleNodeData( ui::AXNodeData* node_data) { views::Button::GetAccessibleNodeData(node_data); - // Specify |ui::AX_ATTR_DESCRIPTION| with an empty string, so that long - // truncated names are not read twice. - // Details of this issue: - // - The Play Store app's name is shown in a label |title_|. - // - If the name is too long, it'll get truncated and the full name will + // Specify |ax::mojom::StringAttribute::kDescription| with an empty string, so + // that long truncated names are not read twice. Details of this issue: - The + // Play Store app's name is shown in a label |title_|. - If the name is too + // long, it'll get truncated and the full name will // go to the label's tooltip. // - SearchResultTileItemView uses that label's tooltip as its tooltip. - // - If a view doesn't have |ui::AX_ATTR_DESCRIPTION| defined in the + // - If a view doesn't have |ax::mojom::StringAttribute::kDescription| defined + // in the // |AXNodeData|, |AXViewObjWrapper::Serialize| will use the tooltip text // as its description. // - We're customizing this view's accessible name, so it get focused // ChromeVox will read its accessible name and then its description. - node_data->AddStringAttribute(ui::AX_ATTR_DESCRIPTION, ""); + node_data->AddStringAttribute(ax::mojom::StringAttribute::kDescription, ""); } bool SearchResultTileItemView::OnKeyPressed(const ui::KeyEvent& event) { diff --git a/ui/app_list/views/search_result_view.cc b/ui/app_list/views/search_result_view.cc index 6cbbf784e35658..178d47e40a0745 100644 --- a/ui/app_list/views/search_result_view.cc +++ b/ui/app_list/views/search_result_view.cc @@ -141,7 +141,7 @@ void SearchResultView::SetSelected(bool selected) { if (selected_) { ScrollRectToVisible(GetLocalBounds()); - NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); + NotifyAccessibilityEvent(ax::mojom::Event::kSelection, true); } SchedulePaint(); } diff --git a/ui/app_list/views/suggestions_container_view.cc b/ui/app_list/views/suggestions_container_view.cc index b01e8f89d258cd..e06badac3b8257 100644 --- a/ui/app_list/views/suggestions_container_view.cc +++ b/ui/app_list/views/suggestions_container_view.cc @@ -65,7 +65,7 @@ int SuggestionsContainerView::DoUpdate() { // Notify text change after accessible name is updated and the tile view // is re-enabled, so that ChromeVox will announce the updated text. search_result_tile_views_[i]->NotifyAccessibilityEvent( - ui::AX_EVENT_TEXT_CHANGED, true); + ax::mojom::Event::kTextChanged, true); } parent()->Layout(); diff --git a/ui/arc/notification/arc_notification_content_view.cc b/ui/arc/notification/arc_notification_content_view.cc index 214f35bda01384..1b4c780dba74ac 100644 --- a/ui/arc/notification/arc_notification_content_view.cc +++ b/ui/arc/notification/arc_notification_content_view.cc @@ -701,7 +701,7 @@ views::FocusTraversable* ArcNotificationContentView::GetFocusTraversable() { bool ArcNotificationContentView::HandleAccessibleAction( const ui::AXActionData& action_data) { - if (item_ && action_data.action == ui::AX_ACTION_DO_DEFAULT) { + if (item_ && action_data.action == ax::mojom::Action::kDoDefault) { item_->ToggleExpansion(); return true; } @@ -711,13 +711,13 @@ bool ArcNotificationContentView::HandleAccessibleAction( void ArcNotificationContentView::GetAccessibleNodeData( ui::AXNodeData* node_data) { if (surface_ && surface_->GetAXTreeId() != -1) { - node_data->role = ui::AX_ROLE_CLIENT; - node_data->AddIntAttribute(ui::AX_ATTR_CHILD_TREE_ID, + node_data->role = ax::mojom::Role::kClient; + node_data->AddIntAttribute(ax::mojom::IntAttribute::kChildTreeId, surface_->GetAXTreeId()); } else { - node_data->role = ui::AX_ROLE_BUTTON; + node_data->role = ax::mojom::Role::kButton; node_data->AddStringAttribute( - ui::AX_ATTR_ROLE_DESCRIPTION, + ax::mojom::StringAttribute::kRoleDescription, l10n_util::GetStringUTF8( IDS_MESSAGE_NOTIFICATION_SETTINGS_BUTTON_ACCESSIBLE_NAME)); } @@ -766,11 +766,11 @@ void ArcNotificationContentView::OnNotificationSurfaceAdded( SetSurface(surface); - // Notify AX_EVENT_CHILDREN_CHANGED to force AXNodeData of this view updated. - // As order of OnNotificationSurfaceAdded call is not guaranteed, we are - // dispatching the event in both ArcNotificationContentView and + // Notify ax::mojom::Event::kChildrenChanged to force AXNodeData of this view + // updated. As order of OnNotificationSurfaceAdded call is not guaranteed, we + // are dispatching the event in both ArcNotificationContentView and // ArcAccessibilityHelperBridge. - NotifyAccessibilityEvent(ui::AX_EVENT_CHILDREN_CHANGED, false); + NotifyAccessibilityEvent(ax::mojom::Event::kChildrenChanged, false); } void ArcNotificationContentView::OnNotificationSurfaceRemoved( diff --git a/ui/chromeos/touch_exploration_controller.cc b/ui/chromeos/touch_exploration_controller.cc index 338a33bd67362a..6484ffc492aebf 100644 --- a/ui/chromeos/touch_exploration_controller.cc +++ b/ui/chromeos/touch_exploration_controller.cc @@ -8,7 +8,7 @@ #include "base/logging.h" #include "base/strings/string_number_conversions.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/aura/client/cursor_client.h" #include "ui/aura/window.h" #include "ui/aura/window_event_dispatcher.h" @@ -675,7 +675,7 @@ void TouchExplorationController::SendSimulatedClickOrTap() { // If we got an anchor point from ChromeVox, send a double-tap gesture // and let ChromeVox handle the click. if (anchor_point_state_ == ANCHOR_POINT_EXPLICITLY_SET) { - delegate_->HandleAccessibilityGesture(ui::AX_GESTURE_CLICK); + delegate_->HandleAccessibilityGesture(ax::mojom::Gesture::kClick); return; } SendSimulatedTap(); @@ -784,7 +784,7 @@ ui::EventRewriteStatus TouchExplorationController::InTwoFingerTap( return ui::EVENT_REWRITE_DISCARD; if (type == ui::ET_TOUCH_RELEASED) { - delegate_->HandleAccessibilityGesture(ui::AX_GESTURE_TAP_2); + delegate_->HandleAccessibilityGesture(ax::mojom::Gesture::kTap2); SET_STATE(NO_FINGERS_DOWN); return ui::EVENT_REWRITE_DISCARD; } @@ -966,20 +966,20 @@ void TouchExplorationController::OnSwipeEvent(ui::GestureEvent* swipe_gesture) { if (VLOG_on_) VLOG(1) << "\nSwipe with " << num_fingers << " fingers."; - ui::AXGesture gesture = ui::AX_GESTURE_NONE; + ax::mojom::Gesture gesture = ax::mojom::Gesture::kNone; if (event_details.swipe_left()) { switch (num_fingers) { case 1: - gesture = ui::AX_GESTURE_SWIPE_LEFT_1; + gesture = ax::mojom::Gesture::kSwipeLeft1; break; case 2: - gesture = ui::AX_GESTURE_SWIPE_LEFT_2; + gesture = ax::mojom::Gesture::kSwipeLeft2; break; case 3: - gesture = ui::AX_GESTURE_SWIPE_LEFT_3; + gesture = ax::mojom::Gesture::kSwipeLeft3; break; case 4: - gesture = ui::AX_GESTURE_SWIPE_LEFT_4; + gesture = ax::mojom::Gesture::kSwipeLeft4; break; default: break; @@ -987,16 +987,16 @@ void TouchExplorationController::OnSwipeEvent(ui::GestureEvent* swipe_gesture) { } else if (event_details.swipe_up()) { switch (num_fingers) { case 1: - gesture = ui::AX_GESTURE_SWIPE_UP_1; + gesture = ax::mojom::Gesture::kSwipeUp1; break; case 2: - gesture = ui::AX_GESTURE_SWIPE_UP_2; + gesture = ax::mojom::Gesture::kSwipeUp2; break; case 3: - gesture = ui::AX_GESTURE_SWIPE_UP_3; + gesture = ax::mojom::Gesture::kSwipeUp3; break; case 4: - gesture = ui::AX_GESTURE_SWIPE_UP_4; + gesture = ax::mojom::Gesture::kSwipeUp4; break; default: break; @@ -1004,16 +1004,16 @@ void TouchExplorationController::OnSwipeEvent(ui::GestureEvent* swipe_gesture) { } else if (event_details.swipe_right()) { switch (num_fingers) { case 1: - gesture = ui::AX_GESTURE_SWIPE_RIGHT_1; + gesture = ax::mojom::Gesture::kSwipeRight1; break; case 2: - gesture = ui::AX_GESTURE_SWIPE_RIGHT_2; + gesture = ax::mojom::Gesture::kSwipeRight2; break; case 3: - gesture = ui::AX_GESTURE_SWIPE_RIGHT_3; + gesture = ax::mojom::Gesture::kSwipeRight3; break; case 4: - gesture = ui::AX_GESTURE_SWIPE_RIGHT_4; + gesture = ax::mojom::Gesture::kSwipeRight4; break; default: break; @@ -1021,23 +1021,23 @@ void TouchExplorationController::OnSwipeEvent(ui::GestureEvent* swipe_gesture) { } else if (event_details.swipe_down()) { switch (num_fingers) { case 1: - gesture = ui::AX_GESTURE_SWIPE_DOWN_1; + gesture = ax::mojom::Gesture::kSwipeDown1; break; case 2: - gesture = ui::AX_GESTURE_SWIPE_DOWN_2; + gesture = ax::mojom::Gesture::kSwipeDown2; break; case 3: - gesture = ui::AX_GESTURE_SWIPE_DOWN_3; + gesture = ax::mojom::Gesture::kSwipeDown3; break; case 4: - gesture = ui::AX_GESTURE_SWIPE_DOWN_4; + gesture = ax::mojom::Gesture::kSwipeDown4; break; default: break; } } - if (gesture != ui::AX_GESTURE_NONE) + if (gesture != ax::mojom::Gesture::kNone) delegate_->HandleAccessibilityGesture(gesture); } diff --git a/ui/chromeos/touch_exploration_controller.h b/ui/chromeos/touch_exploration_controller.h index 2decd403949fc4..4244c0f241f033 100644 --- a/ui/chromeos/touch_exploration_controller.h +++ b/ui/chromeos/touch_exploration_controller.h @@ -9,7 +9,7 @@ #include "base/memory/weak_ptr.h" #include "base/timer/timer.h" #include "base/values.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/chromeos/ui_chromeos_export.h" #include "ui/events/event.h" #include "ui/events/event_rewriter.h" @@ -64,7 +64,7 @@ class TouchExplorationControllerDelegate { // Called when the user performed an accessibility gesture while in touch // accessibility mode, that should be forwarded to ChromeVox. - virtual void HandleAccessibilityGesture(ui::AXGesture gesture) = 0; + virtual void HandleAccessibilityGesture(ax::mojom::Gesture gesture) = 0; }; // TouchExplorationController is used in tandem with "Spoken Feedback" to diff --git a/ui/chromeos/touch_exploration_controller_unittest.cc b/ui/chromeos/touch_exploration_controller_unittest.cc index 714a45e9121250..51fccf9ad29ff3 100644 --- a/ui/chromeos/touch_exploration_controller_unittest.cc +++ b/ui/chromeos/touch_exploration_controller_unittest.cc @@ -86,7 +86,7 @@ class MockTouchExplorationControllerDelegate void PlayExitScreenEarcon() override { ++num_times_exit_screen_played_; } void PlayEnterScreenEarcon() override { ++num_times_enter_screen_played_; } void PlayTouchTypeEarcon() override { ++num_times_touch_type_sound_played_; } - void HandleAccessibilityGesture(ui::AXGesture gesture) override { + void HandleAccessibilityGesture(ax::mojom::Gesture gesture) override { last_gesture_ = gesture; } @@ -98,7 +98,7 @@ class MockTouchExplorationControllerDelegate size_t NumTouchTypeSounds() const { return num_times_touch_type_sound_played_; } - ui::AXGesture GetLastGesture() const { return last_gesture_; } + ax::mojom::Gesture GetLastGesture() const { return last_gesture_; } void ResetCountersToZero() { num_times_adjust_sound_played_ = 0; @@ -115,7 +115,7 @@ class MockTouchExplorationControllerDelegate size_t num_times_exit_screen_played_ = 0; size_t num_times_enter_screen_played_ = 0; size_t num_times_touch_type_sound_played_ = 0; - ui::AXGesture last_gesture_ = ui::AX_GESTURE_NONE; + ax::mojom::Gesture last_gesture_ = ax::mojom::Gesture::kNone; }; } // namespace @@ -779,7 +779,7 @@ TEST_F(TouchExplorationTest, DoubleTapTiming) { std::vector captured_events = GetCapturedLocatedEvents(); ASSERT_EQ(0U, captured_events.size()); - EXPECT_EQ(ui::AX_GESTURE_CLICK, delegate_.GetLastGesture()); + EXPECT_EQ(ax::mojom::Gesture::kClick, delegate_.GetLastGesture()); } // If an explicit anchor point is set during touch exploration, double-tapping @@ -818,7 +818,7 @@ TEST_F(TouchExplorationTest, DoubleTapWithExplicitAnchorPoint) { std::vector captured_events = GetCapturedLocatedEvents(); ASSERT_EQ(0U, captured_events.size()); EXPECT_TRUE(IsInNoFingersDownState()); - EXPECT_EQ(ui::AX_GESTURE_CLICK, delegate_.GetLastGesture()); + EXPECT_EQ(ax::mojom::Gesture::kClick, delegate_.GetLastGesture()); } // Double-tapping where the user holds their finger down for the second time @@ -1314,24 +1314,24 @@ TEST_F(TouchExplorationTest, GestureSwipe) { int move_x; int move_y; int num_fingers; - ui::AXGesture expected_gesture; + ax::mojom::Gesture expected_gesture; } gestures_to_test[] = { - {-1, 0, 1, ui::AX_GESTURE_SWIPE_LEFT_1}, - {0, -1, 1, ui::AX_GESTURE_SWIPE_UP_1}, - {1, 0, 1, ui::AX_GESTURE_SWIPE_RIGHT_1}, - {0, 1, 1, ui::AX_GESTURE_SWIPE_DOWN_1}, - {-1, 0, 2, ui::AX_GESTURE_SWIPE_LEFT_2}, - {0, -1, 2, ui::AX_GESTURE_SWIPE_UP_2}, - {1, 0, 2, ui::AX_GESTURE_SWIPE_RIGHT_2}, - {0, 1, 2, ui::AX_GESTURE_SWIPE_DOWN_2}, - {-1, 0, 3, ui::AX_GESTURE_SWIPE_LEFT_3}, - {0, -1, 3, ui::AX_GESTURE_SWIPE_UP_3}, - {1, 0, 3, ui::AX_GESTURE_SWIPE_RIGHT_3}, - {0, 1, 3, ui::AX_GESTURE_SWIPE_DOWN_3}, - {-1, 0, 4, ui::AX_GESTURE_SWIPE_LEFT_4}, - {0, -1, 4, ui::AX_GESTURE_SWIPE_UP_4}, - {1, 0, 4, ui::AX_GESTURE_SWIPE_RIGHT_4}, - {0, 1, 4, ui::AX_GESTURE_SWIPE_DOWN_4}, + {-1, 0, 1, ax::mojom::Gesture::kSwipeLeft1}, + {0, -1, 1, ax::mojom::Gesture::kSwipeUp1}, + {1, 0, 1, ax::mojom::Gesture::kSwipeRight1}, + {0, 1, 1, ax::mojom::Gesture::kSwipeDown1}, + {-1, 0, 2, ax::mojom::Gesture::kSwipeLeft2}, + {0, -1, 2, ax::mojom::Gesture::kSwipeUp2}, + {1, 0, 2, ax::mojom::Gesture::kSwipeRight2}, + {0, 1, 2, ax::mojom::Gesture::kSwipeDown2}, + {-1, 0, 3, ax::mojom::Gesture::kSwipeLeft3}, + {0, -1, 3, ax::mojom::Gesture::kSwipeUp3}, + {1, 0, 3, ax::mojom::Gesture::kSwipeRight3}, + {0, 1, 3, ax::mojom::Gesture::kSwipeDown3}, + {-1, 0, 4, ax::mojom::Gesture::kSwipeLeft4}, + {0, -1, 4, ax::mojom::Gesture::kSwipeUp4}, + {1, 0, 4, ax::mojom::Gesture::kSwipeRight4}, + {0, 1, 4, ax::mojom::Gesture::kSwipeDown4}, }; // This value was taken from gesture_recognizer_unittest.cc in a swipe @@ -1343,7 +1343,7 @@ TEST_F(TouchExplorationTest, GestureSwipe) { int move_x = gestures_to_test[i].move_x * distance; int move_y = gestures_to_test[i].move_y * distance; int num_fingers = gestures_to_test[i].num_fingers; - ui::AXGesture expected_gesture = gestures_to_test[i].expected_gesture; + ax::mojom::Gesture expected_gesture = gestures_to_test[i].expected_gesture; std::vector start_points; for (int j = 0; j < num_fingers; j++) { @@ -1742,7 +1742,7 @@ TEST_F(TouchExplorationTest, TwoFingerTap) { generator_->ReleaseTouchId(2); EXPECT_EQ(0U, captured_events.size()); - ASSERT_EQ(ui::AX_GESTURE_TAP_2, delegate_.GetLastGesture()); + ASSERT_EQ(ax::mojom::Gesture::kTap2, delegate_.GetLastGesture()); } // If the fingers are not released before the tap timer runs out, a control diff --git a/ui/message_center/views/message_popup_collection.cc b/ui/message_center/views/message_popup_collection.cc index e411a819703dae..2e645d4a92e16d 100644 --- a/ui/message_center/views/message_popup_collection.cc +++ b/ui/message_center/views/message_popup_collection.cc @@ -13,7 +13,7 @@ #include "base/run_loop.h" #include "base/time/time.h" #include "base/timer/timer.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/gfx/animation/animation_delegate.h" #include "ui/gfx/animation/slide_animation.h" #include "ui/message_center/message_center.h" @@ -194,7 +194,7 @@ void MessagePopupCollection::UpdateWidgets() { if (views::ViewsDelegate::GetInstance()) { views::ViewsDelegate::GetInstance()->NotifyAccessibilityEvent( - toast, ui::AX_EVENT_ALERT); + toast, ax::mojom::Event::kAlert); } message_center_->DisplayedNotification( diff --git a/ui/message_center/views/message_view.cc b/ui/message_center/views/message_view.cc index b28d507896755c..0981083bfb1289 100644 --- a/ui/message_center/views/message_view.cc +++ b/ui/message_center/views/message_view.cc @@ -148,9 +148,9 @@ void MessageView::OnContainerAnimationEnded() { } void MessageView::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_BUTTON; + node_data->role = ax::mojom::Role::kButton; node_data->AddStringAttribute( - ui::AX_ATTR_ROLE_DESCRIPTION, + ax::mojom::StringAttribute::kRoleDescription, l10n_util::GetStringUTF8( IDS_MESSAGE_NOTIFICATION_SETTINGS_BUTTON_ACCESSIBLE_NAME)); node_data->SetName(accessible_name_); diff --git a/ui/message_center/views/notification_header_view.cc b/ui/message_center/views/notification_header_view.cc index d6f7a7e5f20b2d..588a910ea076ff 100644 --- a/ui/message_center/views/notification_header_view.cc +++ b/ui/message_center/views/notification_header_view.cc @@ -115,7 +115,7 @@ void ExpandButton::OnBlur() { } void ExpandButton::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_BUTTON; + node_data->role = ax::mojom::Role::kButton; node_data->SetName(views::ImageView::GetTooltipText()); } diff --git a/ui/message_center/views/toast_contents_view.cc b/ui/message_center/views/toast_contents_view.cc index 151715785a79bd..fc0018f342cf01 100644 --- a/ui/message_center/views/toast_contents_view.cc +++ b/ui/message_center/views/toast_contents_view.cc @@ -93,7 +93,7 @@ void ToastContentsView::SetContents(MessageView* view, // The notification type should be ALERT, otherwise the accessibility message // won't be read for this view which returns ROLE_WINDOW. if (already_has_contents && a11y_feedback_for_updates) - NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, false); + NotifyAccessibilityEvent(ax::mojom::Event::kAlert, false); } void ToastContentsView::UpdateContents(const Notification& notification, @@ -103,7 +103,7 @@ void ToastContentsView::UpdateContents(const Notification& notification, message_view->UpdateWithNotification(notification); UpdatePreferredSize(); if (a11y_feedback_for_updates) - NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, false); + NotifyAccessibilityEvent(ax::mojom::Event::kAlert, false); } void ToastContentsView::RevealWithAnimation(gfx::Point origin) { @@ -331,7 +331,7 @@ void ToastContentsView::UpdatePreferredSize() { void ToastContentsView::GetAccessibleNodeData(ui::AXNodeData* node_data) { if (child_count() > 0) child_at(0)->GetAccessibleNodeData(node_data); - node_data->role = ui::AX_ROLE_WINDOW; + node_data->role = ax::mojom::Role::kWindow; } const char* ToastContentsView::GetClassName() const { diff --git a/ui/views/BUILD.gn b/ui/views/BUILD.gn index c8293025cf2e72..0d9790d8b8934f 100644 --- a/ui/views/BUILD.gn +++ b/ui/views/BUILD.gn @@ -464,7 +464,7 @@ jumbo_component("views") { ":views_vector_icons", "//base", "//components/vector_icons", - "//ui/accessibility:ax_gen", + "//ui/accessibility:ax_enums_mojo", "//ui/base", "//ui/base/ime", "//ui/compositor", diff --git a/ui/views/accessibility/ax_aura_obj_cache.cc b/ui/views/accessibility/ax_aura_obj_cache.cc index 1372dd28de59bd..3fc1975935b107 100644 --- a/ui/views/accessibility/ax_aura_obj_cache.cc +++ b/ui/views/accessibility/ax_aura_obj_cache.cc @@ -118,11 +118,11 @@ AXAuraObjWrapper* AXAuraObjCache::GetFocus() { void AXAuraObjCache::OnFocusedViewChanged() { View* view = GetFocusedView(); if (view) - view->NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, true); + view->NotifyAccessibilityEvent(ax::mojom::Event::kFocus, true); } void AXAuraObjCache::FireEvent(AXAuraObjWrapper* aura_obj, - ui::AXEvent event_type) { + ax::mojom::Event event_type) { if (delegate_) delegate_->OnEvent(aura_obj, event_type); } diff --git a/ui/views/accessibility/ax_aura_obj_cache.h b/ui/views/accessibility/ax_aura_obj_cache.h index 69958c3d0483c5..48be286a40c08d 100644 --- a/ui/views/accessibility/ax_aura_obj_cache.h +++ b/ui/views/accessibility/ax_aura_obj_cache.h @@ -13,7 +13,7 @@ #include #include "base/macros.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/aura/client/focus_change_observer.h" #include "ui/views/views_export.h" @@ -40,7 +40,7 @@ class VIEWS_EXPORT AXAuraObjCache : public aura::client::FocusChangeObserver { public: virtual void OnChildWindowRemoved(AXAuraObjWrapper* parent) = 0; virtual void OnEvent(AXAuraObjWrapper* aura_obj, - ui::AXEvent event_type) = 0; + ax::mojom::Event event_type) = 0; }; // Get or create an entry in the cache based on an Aura view. @@ -80,7 +80,7 @@ class VIEWS_EXPORT AXAuraObjCache : public aura::client::FocusChangeObserver { void OnFocusedViewChanged(); // Tell our delegate to fire an event on a given object. - void FireEvent(AXAuraObjWrapper* aura_obj, ui::AXEvent event_type); + void FireEvent(AXAuraObjWrapper* aura_obj, ax::mojom::Event event_type); // Indicates if this object's currently being destroyed. bool is_destroying() { return is_destroying_; } diff --git a/ui/views/accessibility/ax_widget_obj_wrapper.cc b/ui/views/accessibility/ax_widget_obj_wrapper.cc index bfb5725e752295..43eb649aa24847 100644 --- a/ui/views/accessibility/ax_widget_obj_wrapper.cc +++ b/ui/views/accessibility/ax_widget_obj_wrapper.cc @@ -46,7 +46,7 @@ void AXWidgetObjWrapper::Serialize(ui::AXNodeData* out_node_data) { out_node_data->id = GetUniqueId().Get(); out_node_data->role = widget_->widget_delegate()->GetAccessibleWindowRole(); out_node_data->AddStringAttribute( - ui::AX_ATTR_NAME, + ax::mojom::StringAttribute::kName, base::UTF16ToUTF8( widget_->widget_delegate()->GetAccessibleWindowTitle())); out_node_data->location = gfx::RectF(widget_->GetWindowBoundsInScreen()); diff --git a/ui/views/accessibility/ax_window_obj_wrapper.cc b/ui/views/accessibility/ax_window_obj_wrapper.cc index ab604049070678..a1e1290dd9c1a4 100644 --- a/ui/views/accessibility/ax_window_obj_wrapper.cc +++ b/ui/views/accessibility/ax_window_obj_wrapper.cc @@ -7,7 +7,7 @@ #include #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/accessibility/platform/aura_window_properties.h" #include "ui/accessibility/platform/ax_unique_id.h" @@ -59,15 +59,16 @@ void AXWindowObjWrapper::GetChildren( void AXWindowObjWrapper::Serialize(ui::AXNodeData* out_node_data) { out_node_data->id = GetUniqueId().Get(); - ui::AXRole role = window_->GetProperty(ui::kAXRoleOverride); - if (role != ui::AX_ROLE_NONE) + ax::mojom::Role role = window_->GetProperty(ui::kAXRoleOverride); + if (role != ax::mojom::Role::kNone) out_node_data->role = role; else - out_node_data->role = is_alert_ ? ui::AX_ROLE_ALERT : ui::AX_ROLE_WINDOW; - out_node_data->AddStringAttribute(ui::AX_ATTR_NAME, + out_node_data->role = + is_alert_ ? ax::mojom::Role::kAlert : ax::mojom::Role::kWindow; + out_node_data->AddStringAttribute(ax::mojom::StringAttribute::kName, base::UTF16ToUTF8(window_->GetTitle())); if (!window_->IsVisible()) - out_node_data->AddState(ui::AX_STATE_INVISIBLE); + out_node_data->AddState(ax::mojom::State::kInvisible); out_node_data->location = gfx::RectF(window_->bounds()); if (window_->parent()) { @@ -89,7 +90,8 @@ void AXWindowObjWrapper::Serialize(ui::AXNodeData* out_node_data) { return; } - out_node_data->AddIntAttribute(ui::AX_ATTR_CHILD_TREE_ID, child_ax_tree_id); + out_node_data->AddIntAttribute(ax::mojom::IntAttribute::kChildTreeId, + child_ax_tree_id); } } @@ -121,17 +123,19 @@ void AXWindowObjWrapper::OnWindowBoundsChanged( if (window != window_) return; - AXAuraObjCache::GetInstance()->FireEvent(this, ui::AX_EVENT_LOCATION_CHANGED); + AXAuraObjCache::GetInstance()->FireEvent(this, + ax::mojom::Event::kLocationChanged); Widget* widget = Widget::GetWidgetForNativeView(window); if (widget) { AXAuraObjCache::GetInstance()->FireEvent( AXAuraObjCache::GetInstance()->GetOrCreate(widget), - ui::AX_EVENT_LOCATION_CHANGED); + ax::mojom::Event::kLocationChanged); views::View* root_view = widget->GetRootView(); if (root_view) - root_view->NotifyAccessibilityEvent(ui::AX_EVENT_LOCATION_CHANGED, true); + root_view->NotifyAccessibilityEvent(ax::mojom::Event::kLocationChanged, + true); } } @@ -139,8 +143,8 @@ void AXWindowObjWrapper::OnWindowPropertyChanged(aura::Window* window, const void* key, intptr_t old) { if (window == window_ && key == ui::kChildAXTreeID) { - AXAuraObjCache::GetInstance()->FireEvent(this, - ui::AX_EVENT_CHILDREN_CHANGED); + AXAuraObjCache::GetInstance()->FireEvent( + this, ax::mojom::Event::kChildrenChanged); } } diff --git a/ui/views/accessibility/native_view_accessibility.h b/ui/views/accessibility/native_view_accessibility.h index 803db433932cb9..d2ed8c176f9349 100644 --- a/ui/views/accessibility/native_view_accessibility.h +++ b/ui/views/accessibility/native_view_accessibility.h @@ -8,7 +8,7 @@ #include #include "base/macros.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/gfx/native_widget_types.h" #include "ui/views/views_export.h" @@ -25,7 +25,7 @@ class VIEWS_EXPORT NativeViewAccessibility { virtual ~NativeViewAccessibility() {} virtual gfx::NativeViewAccessible GetNativeObject() = 0; - virtual void NotifyAccessibilityEvent(ui::AXEvent event_type) = 0; + virtual void NotifyAccessibilityEvent(ax::mojom::Event event_type) = 0; protected: NativeViewAccessibility() {} diff --git a/ui/views/accessibility/native_view_accessibility_auralinux.cc b/ui/views/accessibility/native_view_accessibility_auralinux.cc index 7fbbca936cfb92..d13fca54996bb2 100644 --- a/ui/views/accessibility/native_view_accessibility_auralinux.cc +++ b/ui/views/accessibility/native_view_accessibility_auralinux.cc @@ -13,7 +13,7 @@ #include "base/memory/singleton.h" #include "base/stl_util.h" #include "ui/accessibility/ax_action_data.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_node_data.h" #include "ui/accessibility/platform/ax_platform_node_auralinux.h" #include "ui/accessibility/platform/ax_platform_node_delegate.h" @@ -127,12 +127,12 @@ class AuraLinuxApplication bool ShouldIgnoreHoveredStateForTesting() override { return false; } - std::set GetReverseRelations(ui::AXIntAttribute attr, + std::set GetReverseRelations(ax::mojom::IntAttribute attr, int32_t dst_id) override { return std::set(); } - std::set GetReverseRelations(ui::AXIntListAttribute attr, + std::set GetReverseRelations(ax::mojom::IntListAttribute attr, int32_t dst_id) override { return std::set(); } @@ -141,11 +141,11 @@ class AuraLinuxApplication friend struct base::DefaultSingletonTraits; AuraLinuxApplication() { - data_.role = ui::AX_ROLE_APPLICATION; + data_.role = ax::mojom::Role::kApplication; platform_node_ = ui::AXPlatformNode::Create(this); if (ViewsDelegate::GetInstance()) { data_.AddStringAttribute( - ui::AX_ATTR_NAME, + ax::mojom::StringAttribute::kName, ViewsDelegate::GetInstance()->GetApplicationName()); } ui::AXPlatformNodeAuraLinux::SetApplication(platform_node_); diff --git a/ui/views/accessibility/native_view_accessibility_base.cc b/ui/views/accessibility/native_view_accessibility_base.cc index d26a9ec8cee8eb..1031a2cf5aefd8 100644 --- a/ui/views/accessibility/native_view_accessibility_base.cc +++ b/ui/views/accessibility/native_view_accessibility_base.cc @@ -77,7 +77,7 @@ gfx::NativeViewAccessible NativeViewAccessibilityBase::GetNativeObject() { } void NativeViewAccessibilityBase::NotifyAccessibilityEvent( - ui::AXEvent event_type) { + ax::mojom::Event event_type) { ax_node_->NotifyAccessibilityEvent(event_type); } @@ -95,7 +95,7 @@ const ui::AXNodeData& NativeViewAccessibilityBase::GetData() const { // This will require ensuring that Chrome OS invalidates the whole // subtree when a View changes its visibility state. if (!view()->IsDrawn()) - data_.AddState(ui::AX_STATE_INVISIBLE); + data_.AddState(ax::mojom::State::kInvisible); // Make sure this element is excluded from the a11y tree if there's a // focusable parent. All keyboard focusable elements should be leaf nodes. @@ -106,7 +106,7 @@ const ui::AXNodeData& NativeViewAccessibilityBase::GetData() const { // accessibility tree. We need to replace this with a cross-platform // solution that works for ChromeVox, too, and move it to ViewAccessibility. if (IsViewUnfocusableChildOfFocusableAncestor(view())) - data_.role = ui::AX_ROLE_IGNORED; + data_.role = ax::mojom::Role::kIgnored; return data_; } @@ -239,13 +239,13 @@ bool NativeViewAccessibilityBase::IsOffscreen() const { } std::set NativeViewAccessibilityBase::GetReverseRelations( - ui::AXIntAttribute attr, + ax::mojom::IntAttribute attr, int32_t dst_id) { return std::set(); } std::set NativeViewAccessibilityBase::GetReverseRelations( - ui::AXIntListAttribute attr, + ax::mojom::IntListAttribute attr, int32_t dst_id) { return std::set(); } diff --git a/ui/views/accessibility/native_view_accessibility_base.h b/ui/views/accessibility/native_view_accessibility_base.h index 413a3a32af9482..019ace675e8971 100644 --- a/ui/views/accessibility/native_view_accessibility_base.h +++ b/ui/views/accessibility/native_view_accessibility_base.h @@ -36,7 +36,7 @@ class VIEWS_EXPORT NativeViewAccessibilityBase // ViewAccessibility: gfx::NativeViewAccessible GetNativeObject() override; - void NotifyAccessibilityEvent(ui::AXEvent event_type) override; + void NotifyAccessibilityEvent(ax::mojom::Event event_type) override; // ui::AXPlatformNodeDelegate const ui::AXNodeData& GetData() const override; @@ -56,9 +56,9 @@ class VIEWS_EXPORT NativeViewAccessibilityBase bool IsOffscreen() const override; const ui::AXUniqueId& GetUniqueId() const override; // Also in ViewAccessibility - std::set GetReverseRelations(ui::AXIntAttribute attr, + std::set GetReverseRelations(ax::mojom::IntAttribute attr, int32_t dst_id) override; - std::set GetReverseRelations(ui::AXIntListAttribute attr, + std::set GetReverseRelations(ax::mojom::IntListAttribute attr, int32_t dst_id) override; protected: diff --git a/ui/views/accessibility/native_view_accessibility_unittest.cc b/ui/views/accessibility/native_view_accessibility_unittest.cc index 5bf1eaaf746d2e..adcd5275fd2d28 100644 --- a/ui/views/accessibility/native_view_accessibility_unittest.cc +++ b/ui/views/accessibility/native_view_accessibility_unittest.cc @@ -71,7 +71,8 @@ class NativeViewAccessibilityTest : public ViewsTestBase { bool SetFocused(NativeViewAccessibilityBase* view_accessibility, bool focused) { ui::AXActionData data; - data.action = focused ? ui::AX_ACTION_FOCUS : ui::AX_ACTION_BLUR; + data.action = + focused ? ax::mojom::Action::kFocus : ax::mojom::Action::kBlur; return view_accessibility->AccessibilityPerformAction(data); } @@ -84,16 +85,17 @@ class NativeViewAccessibilityTest : public ViewsTestBase { }; TEST_F(NativeViewAccessibilityTest, RoleShouldMatch) { - EXPECT_EQ(ui::AX_ROLE_BUTTON, button_accessibility()->GetData().role); + EXPECT_EQ(ax::mojom::Role::kButton, button_accessibility()->GetData().role); // Since the label is a subview of |button_|, and the button is keyboard // focusable, the label is assumed to form part of the button and not have a // role of its own. - EXPECT_EQ(ui::AX_ROLE_IGNORED, label_accessibility()->GetData().role); + EXPECT_EQ(ax::mojom::Role::kIgnored, label_accessibility()->GetData().role); // This will happen for all potentially keyboard-focusable Views with // non-keyboard-focusable children, so if we make the button unfocusable, the // label will be allowed to have its own role again. button_->SetFocusBehavior(View::FocusBehavior::NEVER); - EXPECT_EQ(ui::AX_ROLE_STATIC_TEXT, label_accessibility()->GetData().role); + EXPECT_EQ(ax::mojom::Role::kStaticText, + label_accessibility()->GetData().role); } TEST_F(NativeViewAccessibilityTest, BoundsShouldMatch) { @@ -111,7 +113,7 @@ TEST_F(NativeViewAccessibilityTest, LabelIsChildOfButton) { EXPECT_EQ(1, button_accessibility()->GetChildCount()); EXPECT_EQ(button_->GetNativeViewAccessible(), label_accessibility()->GetParent()); - EXPECT_EQ(ui::AX_ROLE_IGNORED, label_accessibility()->GetData().role); + EXPECT_EQ(ax::mojom::Role::kIgnored, label_accessibility()->GetData().role); // If |button_| is no longer focusable, |label_| should show up again. button_->SetFocusBehavior(View::FocusBehavior::NEVER); @@ -120,21 +122,21 @@ TEST_F(NativeViewAccessibilityTest, LabelIsChildOfButton) { button_accessibility()->ChildAtIndex(0)); EXPECT_EQ(button_->GetNativeViewAccessible(), label_accessibility()->GetParent()); - EXPECT_NE(ui::AX_ROLE_IGNORED, label_accessibility()->GetData().role); + EXPECT_NE(ax::mojom::Role::kIgnored, label_accessibility()->GetData().role); } -// Verify Views with invisible ancestors have AX_STATE_INVISIBLE. +// Verify Views with invisible ancestors have ax::mojom::State::kInvisible. TEST_F(NativeViewAccessibilityTest, InvisibleViews) { EXPECT_TRUE(widget_->IsVisible()); EXPECT_FALSE( - button_accessibility()->GetData().HasState(ui::AX_STATE_INVISIBLE)); + button_accessibility()->GetData().HasState(ax::mojom::State::kInvisible)); EXPECT_FALSE( - label_accessibility()->GetData().HasState(ui::AX_STATE_INVISIBLE)); + label_accessibility()->GetData().HasState(ax::mojom::State::kInvisible)); button_->SetVisible(false); EXPECT_TRUE( - button_accessibility()->GetData().HasState(ui::AX_STATE_INVISIBLE)); + button_accessibility()->GetData().HasState(ax::mojom::State::kInvisible)); EXPECT_TRUE( - label_accessibility()->GetData().HasState(ui::AX_STATE_INVISIBLE)); + label_accessibility()->GetData().HasState(ax::mojom::State::kInvisible)); } TEST_F(NativeViewAccessibilityTest, WritableFocus) { @@ -178,7 +180,8 @@ class AxTestViewsDelegate : public TestViewsDelegate { AxTestViewsDelegate() {} ~AxTestViewsDelegate() override {} - void NotifyAccessibilityEvent(View* view, ui::AXEvent event_type) override { + void NotifyAccessibilityEvent(View* view, + ax::mojom::Event event_type) override { AXAuraObjCache* ax = AXAuraObjCache::GetInstance(); std::vector out_children; AXAuraObjWrapper* ax_obj = ax->GetOrCreate(view->GetWidget()); diff --git a/ui/views/accessibility/native_view_accessibility_win.cc b/ui/views/accessibility/native_view_accessibility_win.cc index 9fe2082cc0d64e..eefa12209a6c4d 100644 --- a/ui/views/accessibility/native_view_accessibility_win.cc +++ b/ui/views/accessibility/native_view_accessibility_win.cc @@ -15,7 +15,7 @@ #include "base/strings/utf_string_conversions.h" #include "base/win/windows_version.h" #include "third_party/iaccessible2/ia2_api_all.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_node_data.h" #include "ui/accessibility/ax_text_utils.h" #include "ui/aura/window.h" diff --git a/ui/views/accessibility/native_view_accessibility_win_unittest.cc b/ui/views/accessibility/native_view_accessibility_win_unittest.cc index 4856452a07fa50..b19072c3cd1038 100644 --- a/ui/views/accessibility/native_view_accessibility_win_unittest.cc +++ b/ui/views/accessibility/native_view_accessibility_win_unittest.cc @@ -237,8 +237,8 @@ TEST_F(NativeViewAccessibilityWinTest, DISABLED_RetrieveAllAlerts) { ASSERT_EQ(0, n_targets); // Fire alert events on the infobars. - infobar->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); - infobar2->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); + infobar->NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true); + infobar2->NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true); // Now calling get_relationTargetsOfType should retrieve the alerts. ASSERT_EQ(S_OK, root_view_accessible->get_relationTargetsOfType( diff --git a/ui/views/accessibility/view_accessibility.cc b/ui/views/accessibility/view_accessibility.cc index 980184f7644e12..8321c86e03ef60 100644 --- a/ui/views/accessibility/view_accessibility.cc +++ b/ui/views/accessibility/view_accessibility.cc @@ -13,16 +13,16 @@ namespace views { namespace { -bool IsValidRoleForViews(ui::AXRole role) { +bool IsValidRoleForViews(ax::mojom::Role role) { switch (role) { // These roles all have special meaning and shouldn't ever be // set on a View. - case ui::AX_ROLE_DESKTOP: - case ui::AX_ROLE_NONE: - case ui::AX_ROLE_ROOT_WEB_AREA: - case ui::AX_ROLE_SVG_ROOT: - case ui::AX_ROLE_UNKNOWN: - case ui::AX_ROLE_WEB_AREA: + case ax::mojom::Role::kDesktop: + case ax::mojom::Role::kNone: + case ax::mojom::Role::kRootWebArea: + case ax::mojom::Role::kSvgRoot: + case ax::mojom::Role::kUnknown: + case ax::mojom::Role::kWebArea: return false; default: @@ -51,46 +51,44 @@ void ViewAccessibility::GetAccessibleNodeData(ui::AXNodeData* data) const { // Views may misbehave if their widget is closed; return an unknown role // rather than possibly crashing. if (!owner_view_->GetWidget() || owner_view_->GetWidget()->IsClosed()) { - data->role = ui::AX_ROLE_UNKNOWN; - data->SetRestriction(ui::AX_RESTRICTION_DISABLED); + data->role = ax::mojom::Role::kUnknown; + data->SetRestriction(ax::mojom::Restriction::kDisabled); return; } owner_view_->GetAccessibleNodeData(data); - if (custom_data_.role != ui::AX_ROLE_UNKNOWN) + if (custom_data_.role != ax::mojom::Role::kUnknown) data->role = custom_data_.role; - if (custom_data_.HasStringAttribute(ui::AX_ATTR_NAME)) - data->SetName(custom_data_.GetStringAttribute(ui::AX_ATTR_NAME)); - if (custom_data_.HasStringAttribute(ui::AX_ATTR_DESCRIPTION)) { - data->AddStringAttribute( - ui::AX_ATTR_DESCRIPTION, - custom_data_.GetStringAttribute(ui::AX_ATTR_DESCRIPTION)); + if (custom_data_.HasStringAttribute(ax::mojom::StringAttribute::kName)) { + data->SetName( + custom_data_.GetStringAttribute(ax::mojom::StringAttribute::kName)); } data->location = gfx::RectF(owner_view_->GetBoundsInScreen()); - if (!data->HasStringAttribute(ui::AX_ATTR_DESCRIPTION)) { + if (!data->HasStringAttribute(ax::mojom::StringAttribute::kDescription)) { base::string16 description; owner_view_->GetTooltipText(gfx::Point(), &description); - data->AddStringAttribute(ui::AX_ATTR_DESCRIPTION, + data->AddStringAttribute(ax::mojom::StringAttribute::kDescription, base::UTF16ToUTF8(description)); } - data->AddStringAttribute(ui::AX_ATTR_CLASS_NAME, owner_view_->GetClassName()); + data->AddStringAttribute(ax::mojom::StringAttribute::kClassName, + owner_view_->GetClassName()); if (owner_view_->IsAccessibilityFocusable()) - data->AddState(ui::AX_STATE_FOCUSABLE); + data->AddState(ax::mojom::State::kFocusable); if (!owner_view_->enabled()) - data->SetRestriction(ui::AX_RESTRICTION_DISABLED); + data->SetRestriction(ax::mojom::Restriction::kDisabled); if (!owner_view_->visible()) - data->AddState(ui::AX_STATE_INVISIBLE); + data->AddState(ax::mojom::State::kInvisible); if (owner_view_->context_menu_controller()) - data->AddAction(ui::AX_ACTION_SHOW_CONTEXT_MENU); + data->AddAction(ax::mojom::Action::kShowContextMenu); } -void ViewAccessibility::OverrideRole(ui::AXRole role) { +void ViewAccessibility::OverrideRole(ax::mojom::Role role) { DCHECK(IsValidRoleForViews(role)); custom_data_.role = role; @@ -105,8 +103,10 @@ void ViewAccessibility::OverrideName(const base::string16& name) { } void ViewAccessibility::OverrideDescription(const std::string& description) { - DCHECK(!custom_data_.HasStringAttribute(ui::AX_ATTR_DESCRIPTION)); - custom_data_.AddStringAttribute(ui::AX_ATTR_DESCRIPTION, description); + DCHECK(!custom_data_.HasStringAttribute( + ax::mojom::StringAttribute::kDescription)); + custom_data_.AddStringAttribute(ax::mojom::StringAttribute::kDescription, + description); } gfx::NativeViewAccessible ViewAccessibility::GetNativeObject() { diff --git a/ui/views/accessibility/view_accessibility.h b/ui/views/accessibility/view_accessibility.h index a548bbb669eb4b..6ff1d678644a22 100644 --- a/ui/views/accessibility/view_accessibility.h +++ b/ui/views/accessibility/view_accessibility.h @@ -8,7 +8,7 @@ #include #include "base/macros.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_node_data.h" #include "ui/accessibility/platform/ax_unique_id.h" #include "ui/gfx/native_widget_types.h" @@ -44,13 +44,13 @@ class VIEWS_EXPORT ViewAccessibility { // Note that string attributes are only used if non-empty, so you can't // override a string with the empty string. // - void OverrideRole(ui::AXRole role); + void OverrideRole(ax::mojom::Role role); void OverrideName(const std::string& name); void OverrideName(const base::string16& name); void OverrideDescription(const std::string& description); virtual gfx::NativeViewAccessible GetNativeObject(); - virtual void NotifyAccessibilityEvent(ui::AXEvent event_type) {} + virtual void NotifyAccessibilityEvent(ax::mojom::Event event_type) {} virtual const ui::AXUniqueId& GetUniqueId() const; diff --git a/ui/views/accessible_pane_view.cc b/ui/views/accessible_pane_view.cc index 2be372d535506e..a22b6967a34e73 100644 --- a/ui/views/accessible_pane_view.cc +++ b/ui/views/accessible_pane_view.cc @@ -205,7 +205,7 @@ void AccessiblePaneView::SetVisible(bool flag) { } void AccessiblePaneView::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_PANE; + node_data->role = ax::mojom::Role::kPane; } void AccessiblePaneView::RequestFocus() { diff --git a/ui/views/bubble/bubble_dialog_delegate.cc b/ui/views/bubble/bubble_dialog_delegate.cc index aa98ca418f73b4..9f766e721007cb 100644 --- a/ui/views/bubble/bubble_dialog_delegate.cc +++ b/ui/views/bubble/bubble_dialog_delegate.cc @@ -320,13 +320,14 @@ void BubbleDialogDelegateView::HandleVisibilityChanged(Widget* widget, anchor_widget()->GetTopLevelWidget()->SetAlwaysRenderAsActive(visible); } - // Fire AX_EVENT_ALERT for bubbles marked as AX_ROLE_ALERT_DIALOG; this - // instructs accessibility tools to read the bubble in its entirety rather - // than just its title and initially focused view. See - // http://crbug.com/474622 for details. + // Fire ax::mojom::Event::kAlert for bubbles marked as + // ax::mojom::Role::kAlertDialog; this instructs accessibility tools to read + // the bubble in its entirety rather than just its title and initially focused + // view. See http://crbug.com/474622 for details. if (widget == GetWidget() && visible) { - if (GetAccessibleWindowRole() == ui::AX_ROLE_ALERT_DIALOG) - widget->GetRootView()->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); + if (GetAccessibleWindowRole() == ax::mojom::Role::kAlertDialog) + widget->GetRootView()->NotifyAccessibilityEvent(ax::mojom::Event::kAlert, + true); } } diff --git a/ui/views/bubble/tooltip_icon.cc b/ui/views/bubble/tooltip_icon.cc index b3a5ca6e8f7b3d..de30b6dcc6237f 100644 --- a/ui/views/bubble/tooltip_icon.cc +++ b/ui/views/bubble/tooltip_icon.cc @@ -55,7 +55,7 @@ void TooltipIcon::OnGestureEvent(ui::GestureEvent* event) { } void TooltipIcon::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_TOOLTIP; + node_data->role = ax::mojom::Role::kTooltip; node_data->SetName(tooltip_); } diff --git a/ui/views/bubble/tray_bubble_view.cc b/ui/views/bubble/tray_bubble_view.cc index 6e32c7940b6f0a..c773cf93be1c42 100644 --- a/ui/views/bubble/tray_bubble_view.cc +++ b/ui/views/bubble/tray_bubble_view.cc @@ -424,7 +424,7 @@ void TrayBubbleView::OnMouseExited(const ui::MouseEvent& event) { void TrayBubbleView::GetAccessibleNodeData(ui::AXNodeData* node_data) { if (delegate_ && CanActivate()) { - node_data->role = ui::AX_ROLE_WINDOW; + node_data->role = ax::mojom::Role::kWindow; node_data->SetName(delegate_->GetAccessibleNameForBubble()); } } diff --git a/ui/views/controls/button/button.cc b/ui/views/controls/button/button.cc index e18822848b93e6..894848264e8b27 100644 --- a/ui/views/controls/button/button.cc +++ b/ui/views/controls/button/button.cc @@ -97,7 +97,7 @@ void Button::SetTooltipText(const base::string16& tooltip_text) { void Button::SetAccessibleName(const base::string16& name) { accessible_name_ = name; - NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_CHANGED, true); + NotifyAccessibilityEvent(ax::mojom::Event::kTextChanged, true); } void Button::SetState(ButtonState state) { @@ -152,7 +152,7 @@ void Button::SetHotTracked(bool is_hot_tracked) { SetState(is_hot_tracked ? STATE_HOVERED : STATE_NORMAL); if (is_hot_tracked) - NotifyAccessibilityEvent(ui::AX_EVENT_HOVER, true); + NotifyAccessibilityEvent(ax::mojom::Event::kHover, true); } bool Button::IsHotTracked() const { @@ -385,20 +385,20 @@ void Button::OnPaint(gfx::Canvas* canvas) { } void Button::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_BUTTON; + node_data->role = ax::mojom::Role::kButton; node_data->SetName(accessible_name_); if (!enabled()) - node_data->SetRestriction(ui::AX_RESTRICTION_DISABLED); + node_data->SetRestriction(ax::mojom::Restriction::kDisabled); switch (state_) { case STATE_HOVERED: - node_data->AddState(ui::AX_STATE_HOVERED); + node_data->AddState(ax::mojom::State::kHovered); break; case STATE_PRESSED: - node_data->SetCheckedState(ui::AX_CHECKED_STATE_TRUE); + node_data->SetCheckedState(ax::mojom::CheckedState::kTrue); break; case STATE_DISABLED: - node_data->SetRestriction(ui::AX_RESTRICTION_DISABLED); + node_data->SetRestriction(ax::mojom::Restriction::kDisabled); break; case STATE_NORMAL: case STATE_COUNT: @@ -406,7 +406,7 @@ void Button::GetAccessibleNodeData(ui::AXNodeData* node_data) { break; } if (enabled()) - node_data->SetDefaultActionVerb(ui::AX_DEFAULT_ACTION_VERB_PRESS); + node_data->SetDefaultActionVerb(ax::mojom::DefaultActionVerb::kPress); } void Button::VisibilityChanged(View* starting_from, bool visible) { diff --git a/ui/views/controls/button/checkbox.cc b/ui/views/controls/button/checkbox.cc index 454f5ea6093faf..1373c43c0bf003 100644 --- a/ui/views/controls/button/checkbox.cc +++ b/ui/views/controls/button/checkbox.cc @@ -163,15 +163,16 @@ const char* Checkbox::GetClassName() const { void Checkbox::GetAccessibleNodeData(ui::AXNodeData* node_data) { LabelButton::GetAccessibleNodeData(node_data); - node_data->role = ui::AX_ROLE_CHECK_BOX; - const ui::AXCheckedState checked_state = - checked() ? ui::AX_CHECKED_STATE_TRUE : ui::AX_CHECKED_STATE_FALSE; + node_data->role = ax::mojom::Role::kCheckBox; + const ax::mojom::CheckedState checked_state = + checked() ? ax::mojom::CheckedState::kTrue + : ax::mojom::CheckedState::kFalse; node_data->SetCheckedState(checked_state); if (enabled()) { if (checked()) { - node_data->SetDefaultActionVerb(ui::AX_DEFAULT_ACTION_VERB_UNCHECK); + node_data->SetDefaultActionVerb(ax::mojom::DefaultActionVerb::kUncheck); } else { - node_data->SetDefaultActionVerb(ui::AX_DEFAULT_ACTION_VERB_CHECK); + node_data->SetDefaultActionVerb(ax::mojom::DefaultActionVerb::kCheck); } } } diff --git a/ui/views/controls/button/image_button.cc b/ui/views/controls/button/image_button.cc index fc9fe32623f2b9..6d945e4579c7ba 100644 --- a/ui/views/controls/button/image_button.cc +++ b/ui/views/controls/button/image_button.cc @@ -217,7 +217,7 @@ void ToggleImageButton::SetToggled(bool toggled) { toggled_ = toggled; SchedulePaint(); - NotifyAccessibilityEvent(ui::AX_EVENT_ARIA_ATTRIBUTE_CHANGED, true); + NotifyAccessibilityEvent(ax::mojom::Event::kAriaAttributeChanged, true); } void ToggleImageButton::SetToggledImage(ButtonState image_state, @@ -279,9 +279,9 @@ void ToggleImageButton::GetAccessibleNodeData(ui::AXNodeData* node_data) { // accessible toggle button. if ((toggled_ && !images_[ButtonState::STATE_NORMAL].isNull()) || (!toggled_ && !alternate_images_[ButtonState::STATE_NORMAL].isNull())) { - node_data->role = ui::AX_ROLE_TOGGLE_BUTTON; - node_data->SetCheckedState(toggled_ ? ui::AX_CHECKED_STATE_TRUE - : ui::AX_CHECKED_STATE_FALSE); + node_data->role = ax::mojom::Role::kToggleButton; + node_data->SetCheckedState(toggled_ ? ax::mojom::CheckedState::kTrue + : ax::mojom::CheckedState::kFalse); } } diff --git a/ui/views/controls/button/label_button_unittest.cc b/ui/views/controls/button/label_button_unittest.cc index 5b974bc209d9be..4a1ac7683d68cd 100644 --- a/ui/views/controls/button/label_button_unittest.cc +++ b/ui/views/controls/button/label_button_unittest.cc @@ -135,8 +135,9 @@ TEST_F(LabelButtonTest, Init) { ui::AXNodeData accessible_node_data; button.GetAccessibleNodeData(&accessible_node_data); - EXPECT_EQ(ui::AX_ROLE_BUTTON, accessible_node_data.role); - EXPECT_EQ(text, accessible_node_data.GetString16Attribute(ui::AX_ATTR_NAME)); + EXPECT_EQ(ax::mojom::Role::kButton, accessible_node_data.role); + EXPECT_EQ(text, accessible_node_data.GetString16Attribute( + ax::mojom::StringAttribute::kName)); EXPECT_FALSE(button.is_default()); EXPECT_EQ(button.style(), Button::STYLE_TEXTBUTTON); @@ -185,25 +186,25 @@ TEST_F(LabelButtonTest, AccessibleState) { ui::AXNodeData accessible_node_data; button_->GetAccessibleNodeData(&accessible_node_data); - EXPECT_EQ(ui::AX_ROLE_BUTTON, accessible_node_data.role); - EXPECT_EQ(base::string16(), - accessible_node_data.GetString16Attribute(ui::AX_ATTR_NAME)); + EXPECT_EQ(ax::mojom::Role::kButton, accessible_node_data.role); + EXPECT_EQ(base::string16(), accessible_node_data.GetString16Attribute( + ax::mojom::StringAttribute::kName)); // Without a label (e.g. image-only), the accessible name should automatically // be set from the tooltip. const base::string16 tooltip_text = ASCIIToUTF16("abc"); button_->SetTooltipText(tooltip_text); button_->GetAccessibleNodeData(&accessible_node_data); - EXPECT_EQ(tooltip_text, - accessible_node_data.GetString16Attribute(ui::AX_ATTR_NAME)); + EXPECT_EQ(tooltip_text, accessible_node_data.GetString16Attribute( + ax::mojom::StringAttribute::kName)); EXPECT_EQ(base::string16(), button_->GetText()); // Setting a label overrides the tooltip text. const base::string16 label_text = ASCIIToUTF16("def"); button_->SetText(label_text); button_->GetAccessibleNodeData(&accessible_node_data); - EXPECT_EQ(label_text, - accessible_node_data.GetString16Attribute(ui::AX_ATTR_NAME)); + EXPECT_EQ(label_text, accessible_node_data.GetString16Attribute( + ax::mojom::StringAttribute::kName)); EXPECT_EQ(label_text, button_->GetText()); base::string16 tooltip; diff --git a/ui/views/controls/button/menu_button.cc b/ui/views/controls/button/menu_button.cc index 3f6959d1bdb0eb..8fb021b9e58908 100644 --- a/ui/views/controls/button/menu_button.cc +++ b/ui/views/controls/button/menu_button.cc @@ -285,10 +285,10 @@ bool MenuButton::OnKeyReleased(const ui::KeyEvent& event) { void MenuButton::GetAccessibleNodeData(ui::AXNodeData* node_data) { Button::GetAccessibleNodeData(node_data); - node_data->role = ui::AX_ROLE_POP_UP_BUTTON; - node_data->AddState(ui::AX_STATE_HASPOPUP); + node_data->role = ax::mojom::Role::kPopUpButton; + node_data->AddState(ax::mojom::State::kHaspopup); if (enabled()) - node_data->SetDefaultActionVerb(ui::AX_DEFAULT_ACTION_VERB_OPEN); + node_data->SetDefaultActionVerb(ax::mojom::DefaultActionVerb::kOpen); } void MenuButton::PaintMenuMarker(gfx::Canvas* canvas) { diff --git a/ui/views/controls/button/radio_button.cc b/ui/views/controls/button/radio_button.cc index bfe433636f3157..e8499db3311a6d 100644 --- a/ui/views/controls/button/radio_button.cc +++ b/ui/views/controls/button/radio_button.cc @@ -75,7 +75,7 @@ const char* RadioButton::GetClassName() const { void RadioButton::GetAccessibleNodeData(ui::AXNodeData* node_data) { Checkbox::GetAccessibleNodeData(node_data); - node_data->role = ui::AX_ROLE_RADIO_BUTTON; + node_data->role = ax::mojom::Role::kRadioButton; } View* RadioButton::GetSelectedViewForGroup(int group) { diff --git a/ui/views/controls/button/toggle_button.cc b/ui/views/controls/button/toggle_button.cc index 6879925757aebf..f17b36dd17cc14 100644 --- a/ui/views/controls/button/toggle_button.cc +++ b/ui/views/controls/button/toggle_button.cc @@ -197,9 +197,9 @@ void ToggleButton::OnNativeThemeChanged(const ui::NativeTheme* theme) { void ToggleButton::GetAccessibleNodeData(ui::AXNodeData* node_data) { Button::GetAccessibleNodeData(node_data); - node_data->role = ui::AX_ROLE_SWITCH; - node_data->SetCheckedState(is_on_ ? ui::AX_CHECKED_STATE_TRUE - : ui::AX_CHECKED_STATE_FALSE); + node_data->role = ax::mojom::Role::kSwitch; + node_data->SetCheckedState(is_on_ ? ax::mojom::CheckedState::kTrue + : ax::mojom::CheckedState::kFalse); } void ToggleButton::OnFocus() { diff --git a/ui/views/controls/combobox/combobox.cc b/ui/views/controls/combobox/combobox.cc index a875e09d89e443..fa7046bda3d9b7 100644 --- a/ui/views/controls/combobox/combobox.cc +++ b/ui/views/controls/combobox/combobox.cc @@ -767,27 +767,30 @@ void Combobox::OnBlur() { void Combobox::GetAccessibleNodeData(ui::AXNodeData* node_data) { // AX_ROLE_COMBO_BOX is for UI elements with a dropdown and an editable text - // field, which views::Combobox does not have. Use AX_ROLE_POP_UP_BUTTON to - // match an HTML element. + node_data->role = ax::mojom::Role::kPopUpButton; node_data->SetName(accessible_name_); node_data->SetValue(model_->GetItemAt(selected_index_)); if (enabled()) { - node_data->SetDefaultActionVerb(ui::AX_DEFAULT_ACTION_VERB_OPEN); + node_data->SetDefaultActionVerb(ax::mojom::DefaultActionVerb::kOpen); } - node_data->AddIntAttribute(ui::AX_ATTR_POS_IN_SET, selected_index_); - node_data->AddIntAttribute(ui::AX_ATTR_SET_SIZE, model_->GetItemCount()); + node_data->AddIntAttribute(ax::mojom::IntAttribute::kPosInSet, + selected_index_); + node_data->AddIntAttribute(ax::mojom::IntAttribute::kSetSize, + model_->GetItemCount()); } bool Combobox::HandleAccessibleAction(const ui::AXActionData& action_data) { // The action handling in View would generate a mouse event and send it to // |this|. However, mouse events for Combobox are handled by |arrow_button_|, // which is hidden from the a11y tree (so can't expose actions). Rather than - // forwarding AX_ACTION_DO_DEFAULT to View and then forwarding the mouse event - // it generates to |arrow_button_| to have it forward back to |this| (as its - // ButtonListener), just handle the action explicitly here and bypass View. - if (enabled() && action_data.action == ui::AX_ACTION_DO_DEFAULT) { + // forwarding ax::mojom::Action::kDoDefault to View and then forwarding the + // mouse event it generates to |arrow_button_| to have it forward back to + // |this| (as its ButtonListener), just handle the action explicitly here and + // bypass View. + if (enabled() && action_data.action == ax::mojom::Action::kDoDefault) { ShowDropDownMenu(ui::MENU_SOURCE_KEYBOARD); return true; } @@ -995,7 +998,7 @@ void Combobox::OnMenuClosed(Button::ButtonState original_button_state) { } void Combobox::OnPerformAction() { - NotifyAccessibilityEvent(ui::AX_EVENT_VALUE_CHANGED, true); + NotifyAccessibilityEvent(ax::mojom::Event::kValueChanged, true); SchedulePaint(); // This combobox may be deleted by the listener. diff --git a/ui/views/controls/combobox/combobox_unittest.cc b/ui/views/controls/combobox/combobox_unittest.cc index 4134a21e34bae9..5c32debbaf9981 100644 --- a/ui/views/controls/combobox/combobox_unittest.cc +++ b/ui/views/controls/combobox/combobox_unittest.cc @@ -648,19 +648,19 @@ TEST_F(ComboboxTest, ShowViaAccessibleAction) { InitCombobox(nullptr, Combobox::STYLE_NORMAL); ui::AXActionData data; - data.action = ui::AX_ACTION_DO_DEFAULT; + data.action = ax::mojom::Action::kDoDefault; EXPECT_EQ(0, menu_show_count_); combobox_->HandleAccessibleAction(data); EXPECT_EQ(1, menu_show_count_); - // AX_ACTION_SHOW_CONTEXT_MENU is specifically for a context menu (e.g. right- - // click). Combobox should ignore it. - data.action = ui::AX_ACTION_SHOW_CONTEXT_MENU; + // ax::mojom::Action::kShowContextMenu is specifically for a context menu + // (e.g. right- click). Combobox should ignore it. + data.action = ax::mojom::Action::kShowContextMenu; combobox_->HandleAccessibleAction(data); EXPECT_EQ(1, menu_show_count_); // No change. - data.action = ui::AX_ACTION_BLUR; + data.action = ax::mojom::Action::kBlur; combobox_->HandleAccessibleAction(data); EXPECT_EQ(1, menu_show_count_); // No change. @@ -668,7 +668,7 @@ TEST_F(ComboboxTest, ShowViaAccessibleAction) { combobox_->HandleAccessibleAction(data); EXPECT_EQ(1, menu_show_count_); // No change. - data.action = ui::AX_ACTION_SHOW_CONTEXT_MENU; + data.action = ax::mojom::Action::kShowContextMenu; combobox_->HandleAccessibleAction(data); EXPECT_EQ(1, menu_show_count_); // No change. } diff --git a/ui/views/controls/image_view.cc b/ui/views/controls/image_view.cc index bc748e3552df1c..710b4f0f405b41 100644 --- a/ui/views/controls/image_view.cc +++ b/ui/views/controls/image_view.cc @@ -127,7 +127,7 @@ void ImageView::OnPaint(gfx::Canvas* canvas) { } void ImageView::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_IMAGE; + node_data->role = ax::mojom::Role::kImage; node_data->SetName(tooltip_text_); } diff --git a/ui/views/controls/label.cc b/ui/views/controls/label.cc index 5fb2a8667c811c..3d61227190e59c 100644 --- a/ui/views/controls/label.cc +++ b/ui/views/controls/label.cc @@ -410,7 +410,7 @@ WordLookupClient* Label::GetWordLookupClient() { } void Label::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_STATIC_TEXT; + node_data->role = ax::mojom::Role::kStaticText; node_data->SetName(full_text_->GetDisplayText()); } diff --git a/ui/views/controls/label_unittest.cc b/ui/views/controls/label_unittest.cc index e777d54face33d..54654acf8663f7 100644 --- a/ui/views/controls/label_unittest.cc +++ b/ui/views/controls/label_unittest.cc @@ -567,9 +567,11 @@ TEST_F(LabelTest, Accessibility) { ui::AXNodeData node_data; label()->GetAccessibleNodeData(&node_data); - EXPECT_EQ(ui::AX_ROLE_STATIC_TEXT, node_data.role); - EXPECT_EQ(label()->text(), node_data.GetString16Attribute(ui::AX_ATTR_NAME)); - EXPECT_FALSE(node_data.HasIntAttribute(ui::AX_ATTR_RESTRICTION)); + EXPECT_EQ(ax::mojom::Role::kStaticText, node_data.role); + EXPECT_EQ(label()->text(), + node_data.GetString16Attribute(ax::mojom::StringAttribute::kName)); + EXPECT_FALSE( + node_data.HasIntAttribute(ax::mojom::IntAttribute::kRestriction)); } TEST_F(LabelTest, TextChangeWithoutLayout) { diff --git a/ui/views/controls/link.cc b/ui/views/controls/link.cc index 1cc2e1faf5e348..f4e605aaedbf65 100644 --- a/ui/views/controls/link.cc +++ b/ui/views/controls/link.cc @@ -163,7 +163,7 @@ bool Link::SkipDefaultKeyEventProcessing(const ui::KeyEvent& event) { void Link::GetAccessibleNodeData(ui::AXNodeData* node_data) { Label::GetAccessibleNodeData(node_data); - node_data->role = ui::AX_ROLE_LINK; + node_data->role = ax::mojom::Role::kLink; } void Link::OnEnabledChanged() { diff --git a/ui/views/controls/menu/menu_controller.cc b/ui/views/controls/menu/menu_controller.cc index 9389f25f034d13..31530263a847d2 100644 --- a/ui/views/controls/menu/menu_controller.cc +++ b/ui/views/controls/menu/menu_controller.cc @@ -1200,8 +1200,7 @@ void MenuController::SetSelection(MenuItemView* menu_item, if (menu_item && (MenuDepth(menu_item) != 1 || menu_item->GetType() != MenuItemView::SUBMENU)) { - menu_item->NotifyAccessibilityEvent( - ui::AX_EVENT_SELECTION, true); + menu_item->NotifyAccessibilityEvent(ax::mojom::Event::kSelection, true); } } @@ -2697,7 +2696,7 @@ void MenuController::SetHotTrackedButton(Button* hot_button) { // Hot-tracked state may change outside of the MenuController. Correct it. if (hot_button && !hot_button->IsHotTracked()) { hot_button->SetHotTracked(true); - hot_button->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); + hot_button->NotifyAccessibilityEvent(ax::mojom::Event::kSelection, true); } return; } @@ -2706,7 +2705,7 @@ void MenuController::SetHotTrackedButton(Button* hot_button) { hot_button_ = hot_button; if (hot_button) { hot_button->SetHotTracked(true); - hot_button->NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); + hot_button->NotifyAccessibilityEvent(ax::mojom::Event::kSelection, true); } } diff --git a/ui/views/controls/menu/menu_item_view.cc b/ui/views/controls/menu/menu_item_view.cc index 439f1c7da9c1a8..5a973fb28101a5 100644 --- a/ui/views/controls/menu/menu_item_view.cc +++ b/ui/views/controls/menu/menu_item_view.cc @@ -152,7 +152,7 @@ bool MenuItemView::GetTooltipText(const gfx::Point& p, } void MenuItemView::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_MENU_ITEM; + node_data->role = ax::mojom::Role::kMenuItem; base::string16 item_text; if (IsContainer()) { @@ -161,7 +161,8 @@ void MenuItemView::GetAccessibleNodeData(ui::AXNodeData* node_data) { View* child = child_at(0); ui::AXNodeData node_data; child->GetAccessibleNodeData(&node_data); - item_text = node_data.GetString16Attribute(ui::AX_ATTR_NAME); + item_text = + node_data.GetString16Attribute(ax::mojom::StringAttribute::kName); } else { item_text = title_; } @@ -169,13 +170,13 @@ void MenuItemView::GetAccessibleNodeData(ui::AXNodeData* node_data) { switch (GetType()) { case SUBMENU: - node_data->AddState(ui::AX_STATE_HASPOPUP); + node_data->AddState(ax::mojom::State::kHaspopup); break; case CHECKBOX: case RADIO: { const bool is_checked = GetDelegate()->IsItemChecked(GetCommand()); - node_data->SetCheckedState(is_checked ? ui::AX_CHECKED_STATE_TRUE - : ui::AX_CHECKED_STATE_FALSE); + node_data->SetCheckedState(is_checked ? ax::mojom::CheckedState::kTrue + : ax::mojom::CheckedState::kFalse); } break; case NORMAL: case SEPARATOR: @@ -187,7 +188,7 @@ void MenuItemView::GetAccessibleNodeData(ui::AXNodeData* node_data) { base::char16 mnemonic = GetMnemonic(); if (mnemonic != '\0') { node_data->AddStringAttribute( - ui::AX_ATTR_KEY_SHORTCUTS, + ax::mojom::StringAttribute::kKeyShortcuts, base::UTF16ToUTF8(base::string16(1, mnemonic))); } } diff --git a/ui/views/controls/menu/menu_scroll_view_container.cc b/ui/views/controls/menu/menu_scroll_view_container.cc index fc9e3426f7c6a2..01069fe8680b48 100644 --- a/ui/views/controls/menu/menu_scroll_view_container.cc +++ b/ui/views/controls/menu/menu_scroll_view_container.cc @@ -259,7 +259,7 @@ void MenuScrollViewContainer::OnPaintBackground(gfx::Canvas* canvas) { void MenuScrollViewContainer::GetAccessibleNodeData(ui::AXNodeData* node_data) { // Get the name from the submenu view. content_view_->GetAccessibleNodeData(node_data); - node_data->role = ui::AX_ROLE_MENU_BAR; + node_data->role = ax::mojom::Role::kMenuBar; } void MenuScrollViewContainer::OnBoundsChanged( diff --git a/ui/views/controls/menu/submenu_view.cc b/ui/views/controls/menu/submenu_view.cc index f7a75314ec4de3..b8926dedbdcb11 100644 --- a/ui/views/controls/menu/submenu_view.cc +++ b/ui/views/controls/menu/submenu_view.cc @@ -194,9 +194,9 @@ void SubmenuView::GetAccessibleNodeData(ui::AXNodeData* node_data) { // the orientation. if (GetMenuItem()) GetMenuItem()->GetAccessibleNodeData(node_data); - node_data->role = ui::AX_ROLE_MENU_LIST_POPUP; + node_data->role = ax::mojom::Role::kMenuListPopup; // Menus in Chrome are always traversed in a vertical direction. - node_data->AddState(ui::AX_STATE_VERTICAL); + node_data->AddState(ax::mojom::State::kVertical); } void SubmenuView::PaintChildren(const PaintInfo& paint_info) { @@ -389,11 +389,8 @@ void SubmenuView::ShowAt(Widget* parent, } GetScrollViewContainer()->NotifyAccessibilityEvent( - ui::AX_EVENT_MENU_START, - true); - NotifyAccessibilityEvent( - ui::AX_EVENT_MENU_POPUP_START, - true); + ax::mojom::Event::kMenuStart, true); + NotifyAccessibilityEvent(ax::mojom::Event::kMenuPopupStart, true); } void SubmenuView::Reposition(const gfx::Rect& bounds) { @@ -403,9 +400,9 @@ void SubmenuView::Reposition(const gfx::Rect& bounds) { void SubmenuView::Close() { if (host_) { - NotifyAccessibilityEvent(ui::AX_EVENT_MENU_POPUP_END, true); + NotifyAccessibilityEvent(ax::mojom::Event::kMenuPopupEnd, true); GetScrollViewContainer()->NotifyAccessibilityEvent( - ui::AX_EVENT_MENU_END, true); + ax::mojom::Event::kMenuEnd, true); host_->DestroyMenuHost(); host_ = NULL; diff --git a/ui/views/controls/message_box_view.cc b/ui/views/controls/message_box_view.cc index 087c94001c5285..fbb2dfb02c82fc 100644 --- a/ui/views/controls/message_box_view.cc +++ b/ui/views/controls/message_box_view.cc @@ -136,7 +136,7 @@ void MessageBoxView::SetLink(const base::string16& text, } void MessageBoxView::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_ALERT; + node_data->role = ax::mojom::Role::kAlert; } /////////////////////////////////////////////////////////////////////////////// @@ -148,7 +148,7 @@ void MessageBoxView::ViewHierarchyChanged( if (prompt_field_) prompt_field_->SelectAll(true); - NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); + NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true); } } diff --git a/ui/views/controls/native/native_view_host.cc b/ui/views/controls/native/native_view_host.cc index 2c5016d5d5ddee..df116d35b8a426 100644 --- a/ui/views/controls/native/native_view_host.cc +++ b/ui/views/controls/native/native_view_host.cc @@ -185,7 +185,7 @@ const char* NativeViewHost::GetClassName() const { void NativeViewHost::OnFocus() { if (native_view_) native_wrapper_->SetFocus(); - NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, true); + NotifyAccessibilityEvent(ax::mojom::Event::kFocus, true); } gfx::NativeViewAccessible NativeViewHost::GetNativeViewAccessible() { diff --git a/ui/views/controls/progress_bar.cc b/ui/views/controls/progress_bar.cc index f0b0ade79da3a7..2a5bbfd9a64948 100644 --- a/ui/views/controls/progress_bar.cc +++ b/ui/views/controls/progress_bar.cc @@ -54,7 +54,7 @@ ProgressBar::~ProgressBar() { } void ProgressBar::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_PROGRESS_INDICATOR; + node_data->role = ax::mojom::Role::kProgressIndicator; } gfx::Size ProgressBar::CalculatePreferredSize() const { diff --git a/ui/views/controls/progress_bar_unittest.cc b/ui/views/controls/progress_bar_unittest.cc index 2fe8ba943b21dc..6eddafe318bdb8 100644 --- a/ui/views/controls/progress_bar_unittest.cc +++ b/ui/views/controls/progress_bar_unittest.cc @@ -18,9 +18,11 @@ TEST(ProgressBarTest, Accessibility) { ui::AXNodeData node_data; bar.GetAccessibleNodeData(&node_data); - EXPECT_EQ(ui::AX_ROLE_PROGRESS_INDICATOR, node_data.role); - EXPECT_EQ(base::string16(), node_data.GetString16Attribute(ui::AX_ATTR_NAME)); - EXPECT_FALSE(node_data.HasIntAttribute(ui::AX_ATTR_RESTRICTION)); + EXPECT_EQ(ax::mojom::Role::kProgressIndicator, node_data.role); + EXPECT_EQ(base::string16(), + node_data.GetString16Attribute(ax::mojom::StringAttribute::kName)); + EXPECT_FALSE( + node_data.HasIntAttribute(ax::mojom::IntAttribute::kRestriction)); } // Test that default colors can be overridden. Used by Chromecast. diff --git a/ui/views/controls/resize_area.cc b/ui/views/controls/resize_area.cc index 06c0325fea38f8..6601ad28224b8c 100644 --- a/ui/views/controls/resize_area.cc +++ b/ui/views/controls/resize_area.cc @@ -70,7 +70,7 @@ void ResizeArea::OnMouseCaptureLost() { } void ResizeArea::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_SPLITTER; + node_data->role = ax::mojom::Role::kSplitter; } void ResizeArea::ReportResizeAmount(int resize_amount, bool last_update) { diff --git a/ui/views/controls/scrollbar/scroll_bar.cc b/ui/views/controls/scrollbar/scroll_bar.cc index 67146933197876..be7c83eec68617 100644 --- a/ui/views/controls/scrollbar/scroll_bar.cc +++ b/ui/views/controls/scrollbar/scroll_bar.cc @@ -12,7 +12,7 @@ ScrollBar::~ScrollBar() { } void ScrollBar::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_SCROLL_BAR; + node_data->role = ax::mojom::Role::kScrollBar; } bool ScrollBar::IsHorizontal() const { diff --git a/ui/views/controls/separator.cc b/ui/views/controls/separator.cc index 82a6cabbd71453..8be91e790d273f 100644 --- a/ui/views/controls/separator.cc +++ b/ui/views/controls/separator.cc @@ -41,7 +41,7 @@ gfx::Size Separator::CalculatePreferredSize() const { } void Separator::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_SPLITTER; + node_data->role = ax::mojom::Role::kSplitter; } void Separator::OnPaint(gfx::Canvas* canvas) { diff --git a/ui/views/controls/slider.cc b/ui/views/controls/slider.cc index 72a09cd26274a5..55c916ced826bf 100644 --- a/ui/views/controls/slider.cc +++ b/ui/views/controls/slider.cc @@ -154,7 +154,7 @@ void Slider::SetValueInternal(float value, SliderChangeReason reason) { if (accessibility_events_enabled_) { if (GetWidget() && GetWidget()->IsVisible()) { DCHECK(!pending_accessibility_value_change_); - NotifyAccessibilityEvent(ui::AX_EVENT_VALUE_CHANGED, true); + NotifyAccessibilityEvent(ax::mojom::Event::kValueChanged, true); } else { pending_accessibility_value_change_ = true; } @@ -254,7 +254,7 @@ bool Slider::OnKeyPressed(const ui::KeyEvent& event) { } void Slider::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_SLIDER; + node_data->role = ax::mojom::Role::kSlider; node_data->SetValue(base::UTF8ToUTF16( base::StringPrintf("%d%%", static_cast(value_ * 100 + 0.5)))); } @@ -336,7 +336,7 @@ void Slider::NotifyPendingAccessibilityValueChanged() { if (!pending_accessibility_value_change_) return; - NotifyAccessibilityEvent(ui::AX_EVENT_VALUE_CHANGED, true); + NotifyAccessibilityEvent(ax::mojom::Event::kValueChanged, true); pending_accessibility_value_change_ = false; } diff --git a/ui/views/controls/slider_unittest.cc b/ui/views/controls/slider_unittest.cc index 46ee5fd2aca941..5ce176bd1130fb 100644 --- a/ui/views/controls/slider_unittest.cc +++ b/ui/views/controls/slider_unittest.cc @@ -129,8 +129,9 @@ class SliderTest : public views::ViewsTestBase { bool has_value_changed() { return has_value_changed_; } private: - void NotifyAccessibilityEvent(View* view, ui::AXEvent event_type) override { - if (event_type == ui::AX_EVENT_VALUE_CHANGED) + void NotifyAccessibilityEvent(View* view, + ax::mojom::Event event_type) override { + if (event_type == ax::mojom::Event::kValueChanged) has_value_changed_ = true; } diff --git a/ui/views/controls/tabbed_pane/tabbed_pane.cc b/ui/views/controls/tabbed_pane/tabbed_pane.cc index 45d824937407b7..50cd83e894b1f2 100644 --- a/ui/views/controls/tabbed_pane/tabbed_pane.cc +++ b/ui/views/controls/tabbed_pane/tabbed_pane.cc @@ -62,7 +62,7 @@ class TabLabel : public Label { // ignored, but Tabs only mark the currently selected tab as // keyboard-focusable. This means all unselected Tabs expose their children // to the a11y tree. To fix, manually ignore the children. - data->role = ui::AX_ROLE_IGNORED; + data->role = ax::mojom::Role::kIgnored; } }; @@ -231,19 +231,19 @@ void Tab::SetState(TabState tab_state) { } void Tab::GetAccessibleNodeData(ui::AXNodeData* data) { - data->role = ui::AX_ROLE_TAB; + data->role = ax::mojom::Role::kTab; data->SetName(title()->text()); - data->AddState(ui::AX_STATE_SELECTABLE); + data->AddState(ax::mojom::State::kSelectable); if (selected()) - data->AddState(ui::AX_STATE_SELECTED); + data->AddState(ax::mojom::State::kSelected); } bool Tab::HandleAccessibleAction(const ui::AXActionData& action_data) { - if (action_data.action != ui::AX_ACTION_SET_SELECTION || !enabled()) + if (action_data.action != ax::mojom::Action::kSetSelection || !enabled()) return false; // It's not clear what should happen if a tab is 'deselected', so the - // AX_ACTION_SET_SELECTION action will always select the tab. + // ax::mojom::Action::kSetSelection action will always select the tab. tabbed_pane_->SelectTab(this); return true; } @@ -252,10 +252,10 @@ void Tab::OnFocus() { OnStateChanged(); // When the tab gains focus, send an accessibility event indicating that the // contents are focused. When the tab loses focus, whichever new View ends up - // with focus will send an AX_EVENT_FOCUS of its own, so there's no need to - // send one in OnBlur(). + // with focus will send an ax::mojom::Event::kFocus of its own, so there's no + // need to send one in OnBlur(). if (contents()) - contents()->NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, true); + contents()->NotifyAccessibilityEvent(ax::mojom::Event::kFocus, true); SchedulePaint(); } @@ -716,7 +716,7 @@ const char* TabbedPane::GetClassName() const { } void TabbedPane::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_TAB_LIST; + node_data->role = ax::mojom::Role::kTabList; } } // namespace views diff --git a/ui/views/controls/tabbed_pane/tabbed_pane_unittest.cc b/ui/views/controls/tabbed_pane/tabbed_pane_unittest.cc index 98de10ba661f76..d172e66efdf990 100644 --- a/ui/views/controls/tabbed_pane/tabbed_pane_unittest.cc +++ b/ui/views/controls/tabbed_pane/tabbed_pane_unittest.cc @@ -11,7 +11,7 @@ #include "base/strings/utf_string_conversions.h" #include "testing/gtest/include/gtest/gtest.h" #include "ui/accessibility/ax_action_data.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_node_data.h" #include "ui/events/keycodes/keyboard_code_conversion.h" #include "ui/views/test/test_views.h" @@ -207,14 +207,15 @@ TEST_F(TabbedPaneTest, SelectTabWithAccessibleAction) { ui::AXNodeData data; GetTabAt(i)->GetAccessibleNodeData(&data); SCOPED_TRACE(testing::Message() << "Tab at index: " << i); - EXPECT_EQ(ui::AX_ROLE_TAB, data.role); - EXPECT_EQ(DefaultTabTitle(), data.GetString16Attribute(ui::AX_ATTR_NAME)); - EXPECT_TRUE(data.HasState(ui::AX_STATE_SELECTABLE)); - EXPECT_EQ(i == 0, data.HasState(ui::AX_STATE_SELECTED)); + EXPECT_EQ(ax::mojom::Role::kTab, data.role); + EXPECT_EQ(DefaultTabTitle(), + data.GetString16Attribute(ax::mojom::StringAttribute::kName)); + EXPECT_TRUE(data.HasState(ax::mojom::State::kSelectable)); + EXPECT_EQ(i == 0, data.HasState(ax::mojom::State::kSelected)); } ui::AXActionData action; - action.action = ui::AX_ACTION_SET_SELECTION; + action.action = ax::mojom::Action::kSetSelection; // Select the first tab. GetTabAt(0)->HandleAccessibleAction(action); diff --git a/ui/views/controls/table/table_view.cc b/ui/views/controls/table/table_view.cc index 9caa9d2d3cd210..bb5962a6908a35 100644 --- a/ui/views/controls/table/table_view.cc +++ b/ui/views/controls/table/table_view.cc @@ -447,18 +447,18 @@ bool TableView::GetTooltipTextOrigin(const gfx::Point& p, } void TableView::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_TABLE; - node_data->SetRestriction(ui::AX_RESTRICTION_READ_ONLY); - node_data->AddIntAttribute(ui::AX_ATTR_SET_SIZE, RowCount()); + node_data->role = ax::mojom::Role::kTable; + node_data->SetRestriction(ax::mojom::Restriction::kReadOnly); + node_data->AddIntAttribute(ax::mojom::IntAttribute::kSetSize, RowCount()); if (selection_model_.active() != ui::ListSelectionModel::kUnselectedIndex) { // Get information about the active item, this is not the same as the set // of selected items (of which there could be more than one). - node_data->role = ui::AX_ROLE_ROW; - node_data->AddIntAttribute(ui::AX_ATTR_POS_IN_SET, + node_data->role = ax::mojom::Role::kRow; + node_data->AddIntAttribute(ax::mojom::IntAttribute::kPosInSet, selection_model_.active()); if (selection_model_.IsSelected(selection_model_.active())) { - node_data->AddState(ui::AX_STATE_SELECTED); + node_data->AddState(ax::mojom::State::kSelected); } std::vector name_parts; @@ -647,7 +647,7 @@ void TableView::OnFocus() { scroll_view->SetHasFocusIndicator(true); SchedulePaintForSelection(); - NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, true); + NotifyAccessibilityEvent(ax::mojom::Event::kFocus, true); } void TableView::OnBlur() { @@ -872,7 +872,7 @@ void TableView::SetSelectionModel(ui::ListSelectionModel new_selection) { if (observer_) observer_->OnSelectionChanged(); - NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, true); + NotifyAccessibilityEvent(ax::mojom::Event::kFocus, true); } void TableView::AdvanceSelection(AdvanceDirection direction) { diff --git a/ui/views/controls/textfield/textfield.cc b/ui/views/controls/textfield/textfield.cc index 18ddd04712a1e9..ba87e8d54a537b 100644 --- a/ui/views/controls/textfield/textfield.cc +++ b/ui/views/controls/textfield/textfield.cc @@ -344,7 +344,7 @@ void Textfield::SetText(const base::string16& new_text) { UpdateCursorViewPosition(); UpdateCursorVisibility(); SchedulePaint(); - NotifyAccessibilityEvent(ui::AX_EVENT_VALUE_CHANGED, true); + NotifyAccessibilityEvent(ax::mojom::Event::kValueChanged, true); } void Textfield::AppendText(const base::string16& new_text) { @@ -353,7 +353,7 @@ void Textfield::AppendText(const base::string16& new_text) { model_->Append(new_text); OnCaretBoundsChanged(); SchedulePaint(); - NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_CHANGED, true); + NotifyAccessibilityEvent(ax::mojom::Event::kTextChanged, true); } void Textfield::InsertOrReplaceText(const base::string16& new_text) { @@ -934,34 +934,35 @@ void Textfield::OnDragDone() { } void Textfield::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_TEXT_FIELD; + node_data->role = ax::mojom::Role::kTextField; node_data->SetName(accessible_name_); // Editable state indicates support of editable interface, and is always set // for a textfield, even if disabled or readonly. - node_data->AddState(ui::AX_STATE_EDITABLE); + node_data->AddState(ax::mojom::State::kEditable); if (enabled()) { - node_data->SetDefaultActionVerb(ui::AX_DEFAULT_ACTION_VERB_ACTIVATE); + node_data->SetDefaultActionVerb(ax::mojom::DefaultActionVerb::kActivate); // Only readonly if enabled. Don't overwrite the disabled restriction. if (read_only()) - node_data->SetRestriction(ui::AX_RESTRICTION_READ_ONLY); + node_data->SetRestriction(ax::mojom::Restriction::kReadOnly); } if (text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD) { - node_data->AddState(ui::AX_STATE_PROTECTED); + node_data->AddState(ax::mojom::State::kProtected); node_data->SetValue(base::string16( text().size(), gfx::RenderText::kPasswordReplacementChar)); } else { node_data->SetValue(text()); } - node_data->AddStringAttribute(ui::AX_ATTR_PLACEHOLDER, + node_data->AddStringAttribute(ax::mojom::StringAttribute::kPlaceholder, base::UTF16ToUTF8(GetPlaceholderText())); const gfx::Range range = GetSelectedRange(); - node_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, range.start()); - node_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, range.end()); + node_data->AddIntAttribute(ax::mojom::IntAttribute::kTextSelStart, + range.start()); + node_data->AddIntAttribute(ax::mojom::IntAttribute::kTextSelEnd, range.end()); } bool Textfield::HandleAccessibleAction(const ui::AXActionData& action_data) { - if (action_data.action == ui::AX_ACTION_SET_SELECTION) { + if (action_data.action == ax::mojom::Action::kSetSelection) { if (action_data.anchor_node_id != action_data.focus_node_id) return false; // TODO(nektar): Check that the focus_node_id matches the ID of this node. @@ -973,11 +974,11 @@ bool Textfield::HandleAccessibleAction(const ui::AXActionData& action_data) { if (read_only()) return View::HandleAccessibleAction(action_data); - if (action_data.action == ui::AX_ACTION_SET_VALUE) { + if (action_data.action == ax::mojom::Action::kSetValue) { SetText(action_data.value); ClearSelection(); return true; - } else if (action_data.action == ui::AX_ACTION_REPLACE_SELECTED_TEXT) { + } else if (action_data.action == ax::mojom::Action::kReplaceSelectedText) { InsertOrReplaceText(action_data.value); ClearSelection(); return true; @@ -1980,7 +1981,7 @@ void Textfield::UpdateAfterChange(bool text_changed, bool cursor_changed) { if (text_changed) { if (controller_) controller_->ContentsChanged(this, text()); - NotifyAccessibilityEvent(ui::AX_EVENT_VALUE_CHANGED, true); + NotifyAccessibilityEvent(ax::mojom::Event::kValueChanged, true); } if (cursor_changed) { UpdateCursorViewPosition(); @@ -2060,7 +2061,7 @@ void Textfield::OnCaretBoundsChanged() { GetInputMethod()->OnCaretBoundsChanged(this); if (touch_selection_controller_) touch_selection_controller_->SelectionChanged(); - NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_SELECTION_CHANGED, true); + NotifyAccessibilityEvent(ax::mojom::Event::kTextSelectionChanged, true); } void Textfield::OnBeforeUserAction() { diff --git a/ui/views/controls/textfield/textfield_unittest.cc b/ui/views/controls/textfield/textfield_unittest.cc index 4ee16e76284079..e11c0cf382197e 100644 --- a/ui/views/controls/textfield/textfield_unittest.cc +++ b/ui/views/controls/textfield/textfield_unittest.cc @@ -3214,18 +3214,18 @@ TEST_F(TextfieldTest, AccessiblePasswordTest) { ui::AXNodeData node_data_regular; textfield_->GetAccessibleNodeData(&node_data_regular); - EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, node_data_regular.role); - EXPECT_EQ(ASCIIToUTF16("password"), - node_data_regular.GetString16Attribute(ui::AX_ATTR_VALUE)); - EXPECT_FALSE(node_data_regular.HasState(ui::AX_STATE_PROTECTED)); + EXPECT_EQ(ax::mojom::Role::kTextField, node_data_regular.role); + EXPECT_EQ(ASCIIToUTF16("password"), node_data_regular.GetString16Attribute( + ax::mojom::StringAttribute::kValue)); + EXPECT_FALSE(node_data_regular.HasState(ax::mojom::State::kProtected)); textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); ui::AXNodeData node_data_protected; textfield_->GetAccessibleNodeData(&node_data_protected); - EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, node_data_protected.role); - EXPECT_EQ(UTF8ToUTF16("••••••••"), - node_data_protected.GetString16Attribute(ui::AX_ATTR_VALUE)); - EXPECT_TRUE(node_data_protected.HasState(ui::AX_STATE_PROTECTED)); + EXPECT_EQ(ax::mojom::Role::kTextField, node_data_protected.role); + EXPECT_EQ(UTF8ToUTF16("••••••••"), node_data_protected.GetString16Attribute( + ax::mojom::StringAttribute::kValue)); + EXPECT_TRUE(node_data_protected.HasState(ax::mojom::State::kProtected)); } // Verify that cursor visibility is controlled by SetCursorEnabled. diff --git a/ui/views/controls/tree/tree_view.cc b/ui/views/controls/tree/tree_view.cc index e9d65d7d836d5c..f5709270c99863 100644 --- a/ui/views/controls/tree/tree_view.cc +++ b/ui/views/controls/tree/tree_view.cc @@ -272,8 +272,8 @@ void TreeView::SetSelectedNode(TreeModelNode* model_node) { controller_->OnTreeViewSelectionChanged(this); if (changed) { - NotifyAccessibilityEvent(ui::AX_EVENT_TEXT_CHANGED, true); - NotifyAccessibilityEvent(ui::AX_EVENT_SELECTION, true); + NotifyAccessibilityEvent(ax::mojom::Event::kTextChanged, true); + NotifyAccessibilityEvent(ax::mojom::Event::kSelection, true); } } @@ -425,13 +425,13 @@ void TreeView::ShowContextMenu(const gfx::Point& p, } void TreeView::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_TREE; - node_data->SetRestriction(ui::AX_RESTRICTION_READ_ONLY); + node_data->role = ax::mojom::Role::kTree; + node_data->SetRestriction(ax::mojom::Restriction::kReadOnly); if (!selected_node_) return; // Get selected item info. - node_data->role = ui::AX_ROLE_TREE_ITEM; + node_data->role = ax::mojom::Role::kTreeItem; node_data->SetName(selected_node_->model_node()->GetTitle()); } diff --git a/ui/views/controls/webview/webview.cc b/ui/views/controls/webview/webview.cc index b65a9e4cbbe13c..84b0514b3cb44e 100644 --- a/ui/views/controls/webview/webview.cc +++ b/ui/views/controls/webview/webview.cc @@ -14,7 +14,7 @@ #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/web_contents.h" #include "ipc/ipc_message.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_node_data.h" #include "ui/events/event.h" #include "ui/views/controls/native/native_view_host.h" @@ -191,7 +191,7 @@ void WebView::AboutToRequestFocusFromTabTraversal(bool reverse) { } void WebView::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_WEB_VIEW; + node_data->role = ax::mojom::Role::kWebView; } gfx::NativeViewAccessible WebView::GetNativeViewAccessible() { @@ -319,7 +319,7 @@ void WebView::ReattachForFullscreenChange(bool enter_fullscreen) { void WebView::NotifyAccessibilityWebContentsChanged() { if (web_contents()) - NotifyAccessibilityEvent(ui::AX_EVENT_CHILDREN_CHANGED, false); + NotifyAccessibilityEvent(ax::mojom::Event::kChildrenChanged, false); } content::WebContents* WebView::CreateWebContents( diff --git a/ui/views/view.cc b/ui/views/view.cc index e114a6f37be6b8..2387e7d523e2ff 100644 --- a/ui/views/view.cc +++ b/ui/views/view.cc @@ -21,7 +21,7 @@ #include "build/build_config.h" #include "third_party/skia/include/core/SkRect.h" #include "ui/accessibility/ax_action_data.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/base/cursor/cursor.h" #include "ui/base/dragdrop/drag_drop_types.h" #include "ui/base/ime/input_method.h" @@ -467,7 +467,8 @@ void View::SetVisible(bool visible) { // Notify the parent. if (parent_) { parent_->ChildVisibilityChanged(this); - parent_->NotifyAccessibilityEvent(ui::AX_EVENT_CHILDREN_CHANGED, false); + parent_->NotifyAccessibilityEvent(ax::mojom::Event::kChildrenChanged, + false); } for (ViewObserver& observer : observers_) @@ -1112,7 +1113,7 @@ void View::OnMouseEvent(ui::MouseEvent* event) { case ui::ET_MOUSE_ENTERED: if (event->flags() & ui::EF_TOUCH_ACCESSIBILITY) - NotifyAccessibilityEvent(ui::AX_EVENT_HOVER, true); + NotifyAccessibilityEvent(ax::mojom::Event::kHover, true); OnMouseEntered(*event); break; @@ -1408,13 +1409,13 @@ ViewAccessibility& View::GetViewAccessibility() { bool View::HandleAccessibleAction(const ui::AXActionData& action_data) { switch (action_data.action) { - case ui::AX_ACTION_BLUR: + case ax::mojom::Action::kBlur: if (HasFocus()) { GetFocusManager()->ClearFocus(); return true; } break; - case ui::AX_ACTION_DO_DEFAULT: { + case ax::mojom::Action::kDoDefault: { const gfx::Point center = GetLocalBounds().CenterPoint(); OnMousePressed(ui::MouseEvent( ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), @@ -1424,16 +1425,16 @@ bool View::HandleAccessibleAction(const ui::AXActionData& action_data) { ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); return true; } - case ui::AX_ACTION_FOCUS: + case ax::mojom::Action::kFocus: if (IsAccessibilityFocusable()) { RequestFocus(); return true; } break; - case ui::AX_ACTION_SCROLL_TO_MAKE_VISIBLE: + case ax::mojom::Action::kScrollToMakeVisible: ScrollRectToVisible(GetLocalBounds()); return true; - case ui::AX_ACTION_SHOW_CONTEXT_MENU: + case ax::mojom::Action::kShowContextMenu: ShowContextMenu(GetBoundsInScreen().CenterPoint(), ui::MENU_SOURCE_KEYBOARD); return true; @@ -1449,9 +1450,8 @@ gfx::NativeViewAccessible View::GetNativeViewAccessible() { return GetViewAccessibility().GetNativeObject(); } -void View::NotifyAccessibilityEvent( - ui::AXEvent event_type, - bool send_native_event) { +void View::NotifyAccessibilityEvent(ax::mojom::Event event_type, + bool send_native_event) { if (ViewsDelegate::GetInstance()) ViewsDelegate::GetInstance()->NotifyAccessibilityEvent(this, event_type); @@ -1461,7 +1461,7 @@ void View::NotifyAccessibilityEvent( OnAccessibilityEvent(event_type); } -void View::OnAccessibilityEvent(ui::AXEvent event_type) {} +void View::OnAccessibilityEvent(ax::mojom::Event event_type) {} // Scrolling ------------------------------------------------------------------- @@ -1792,7 +1792,7 @@ void View::OnFocus() { // TODO(beng): Investigate whether it's possible for us to move this to // Focus(). // Notify assistive technologies of the focus change. - NotifyAccessibilityEvent(ui::AX_EVENT_FOCUS, true); + NotifyAccessibilityEvent(ax::mojom::Event::kFocus, true); } void View::OnBlur() { @@ -2281,7 +2281,7 @@ void View::BoundsChanged(const gfx::Rect& previous_bounds) { OnBoundsChanged(previous_bounds); if (bounds_ != previous_bounds) - NotifyAccessibilityEvent(ui::AX_EVENT_LOCATION_CHANGED, false); + NotifyAccessibilityEvent(ax::mojom::Event::kLocationChanged, false); if (needs_layout_ || previous_bounds.size() != size()) { needs_layout_ = false; diff --git a/ui/views/view.h b/ui/views/view.h index f3075731dd614c..345d3d0ebd6c80 100644 --- a/ui/views/view.h +++ b/ui/views/view.h @@ -19,7 +19,7 @@ #include "base/logging.h" #include "base/macros.h" #include "build/build_config.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/base/accelerators/accelerator.h" #include "ui/base/class_property.h" #include "ui/base/dragdrop/drag_drop_types.h" @@ -1115,12 +1115,12 @@ class VIEWS_EXPORT View : public ui::LayerDelegate, // cases where the view is a native control that's already sending a // native accessibility event and the duplicate event would cause // problems. - void NotifyAccessibilityEvent(ui::AXEvent event_type, + void NotifyAccessibilityEvent(ax::mojom::Event event_type, bool send_native_event); // Views may override this function to know when an accessibility // event is fired. This will be called by NotifyAccessibilityEvent. - virtual void OnAccessibilityEvent(ui::AXEvent event_type); + virtual void OnAccessibilityEvent(ax::mojom::Event event_type); // Scrolling ----------------------------------------------------------------- // TODO(beng): Figure out if this can live somewhere other than View, i.e. diff --git a/ui/views/view_unittest.cc b/ui/views/view_unittest.cc index 38a0c05b4cfe32..8d5548f304b8ba 100644 --- a/ui/views/view_unittest.cc +++ b/ui/views/view_unittest.cc @@ -262,7 +262,7 @@ class TestView : public View { void OnNativeThemeChanged(const ui::NativeTheme* native_theme) override; - void OnAccessibilityEvent(ui::AXEvent event_type) override; + void OnAccessibilityEvent(ax::mojom::Event event_type) override; // OnBoundsChanged. bool did_change_bounds_; @@ -292,7 +292,7 @@ class TestView : public View { bool can_process_events_within_subtree_; // Accessibility events - ui::AXEvent last_a11y_event_; + ax::mojom::Event last_a11y_event_; }; //////////////////////////////////////////////////////////////////////////////// @@ -328,7 +328,7 @@ TEST_F(ViewTest, LayoutCalledInvalidateAndOriginChanges) { // OnBoundsChanged //////////////////////////////////////////////////////////////////////////////// -void TestView::OnAccessibilityEvent(ui::AXEvent event_type) { +void TestView::OnAccessibilityEvent(ax::mojom::Event event_type) { last_a11y_event_ = event_type; } @@ -340,17 +340,17 @@ TEST_F(ViewTest, OnBoundsChangedFiresA11yEvent) { gfx::Rect scaled(0, 0, 250, 250); gfx::Rect moved(100, 100, 250, 250); - v.last_a11y_event_ = ui::AX_EVENT_NONE; + v.last_a11y_event_ = ax::mojom::Event::kNone; v.SetBoundsRect(initial); - EXPECT_EQ(v.last_a11y_event_, ui::AX_EVENT_LOCATION_CHANGED); + EXPECT_EQ(v.last_a11y_event_, ax::mojom::Event::kLocationChanged); - v.last_a11y_event_ = ui::AX_EVENT_NONE; + v.last_a11y_event_ = ax::mojom::Event::kNone; v.SetBoundsRect(scaled); - EXPECT_EQ(v.last_a11y_event_, ui::AX_EVENT_LOCATION_CHANGED); + EXPECT_EQ(v.last_a11y_event_, ax::mojom::Event::kLocationChanged); - v.last_a11y_event_ = ui::AX_EVENT_NONE; + v.last_a11y_event_ = ax::mojom::Event::kNone; v.SetBoundsRect(moved); - EXPECT_EQ(v.last_a11y_event_, ui::AX_EVENT_LOCATION_CHANGED); + EXPECT_EQ(v.last_a11y_event_, ax::mojom::Event::kLocationChanged); } void TestView::OnBoundsChanged(const gfx::Rect& previous_bounds) { diff --git a/ui/views/views_delegate.cc b/ui/views/views_delegate.cc index 1f7068795ff6a3..964f1390be047c 100644 --- a/ui/views/views_delegate.cc +++ b/ui/views/views_delegate.cc @@ -61,8 +61,7 @@ bool ViewsDelegate::GetSavedWindowPlacement( } void ViewsDelegate::NotifyAccessibilityEvent(View* view, - ui::AXEvent event_type) { -} + ax::mojom::Event event_type) {} void ViewsDelegate::NotifyMenuItemFocused(const base::string16& menu_name, const base::string16& menu_item_name, diff --git a/ui/views/views_delegate.h b/ui/views/views_delegate.h index aed6c6eeff03c5..cfaf7b0dd8a47a 100644 --- a/ui/views/views_delegate.h +++ b/ui/views/views_delegate.h @@ -17,7 +17,7 @@ #include "base/macros.h" #include "base/strings/string16.h" #include "build/build_config.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/base/ui_base_types.h" #include "ui/gfx/native_widget_types.h" #include "ui/views/views_export.h" @@ -135,7 +135,8 @@ class VIEWS_EXPORT ViewsDelegate { gfx::Rect* bounds, ui::WindowShowState* show_state) const; - virtual void NotifyAccessibilityEvent(View* view, ui::AXEvent event_type); + virtual void NotifyAccessibilityEvent(View* view, + ax::mojom::Event event_type); // For accessibility, notify the delegate that a menu item was focused // so that alternate feedback (speech / magnified text) can be provided. diff --git a/ui/views/widget/native_widget_mac_accessibility_unittest.mm b/ui/views/widget/native_widget_mac_accessibility_unittest.mm index 23ab9fb0eb240b..a39e80690e31df 100644 --- a/ui/views/widget/native_widget_mac_accessibility_unittest.mm +++ b/ui/views/widget/native_widget_mac_accessibility_unittest.mm @@ -12,7 +12,7 @@ #include "base/strings/sys_string_conversions.h" #include "base/strings/utf_string_conversions.h" #import "testing/gtest_mac.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_node_data.h" #import "ui/accessibility/platform/ax_platform_node_mac.h" #include "ui/base/ime/text_input_type.h" @@ -36,8 +36,8 @@ class FlexibleRoleTestView : public View { public: - explicit FlexibleRoleTestView(ui::AXRole role) : role_(role) {} - void set_role(ui::AXRole role) { role_ = role; } + explicit FlexibleRoleTestView(ax::mojom::Role role) : role_(role) {} + void set_role(ax::mojom::Role role) { role_ = role; } // Add a child view and resize to fit the child. void FitBoundsToNewChild(View* view) { @@ -60,7 +60,7 @@ bool OnMousePressed(const ui::MouseEvent& event) override { } private: - ui::AXRole role_; + ax::mojom::Role role_; bool mouse_was_pressed_ = false; DISALLOW_COPY_AND_ASSIGN(FlexibleRoleTestView); @@ -133,7 +133,7 @@ id AttributeValueAtMidpoint(NSString* attribute) { } // Shorthand helpers to get a11y properties from A11yElementAtMidpoint(). - NSString* AXRole() { + NSString* AXRoleString() { return AttributeValueAtMidpoint(NSAccessibilityRoleAttribute); } id AXParent() { @@ -292,7 +292,7 @@ id AXValue() { TestLabelButton* button = new TestLabelButton(); button->SetSize(widget()->GetContentsView()->size()); widget()->GetContentsView()->AddChildView(button); - EXPECT_NSEQ(NSAccessibilityButtonRole, AXRole()); + EXPECT_NSEQ(NSAccessibilityButtonRole, AXRoleString()); EXPECT_EQ( 0u, [[button->GetNativeViewAccessible() @@ -339,7 +339,7 @@ id AXValue() { // Check ignored children don't show up in the accessibility tree. widget()->GetContentsView()->AddChildView( - new FlexibleRoleTestView(ui::AX_ROLE_IGNORED)); + new FlexibleRoleTestView(ax::mojom::Role::kIgnored)); EXPECT_EQ(kNumChildren, [AttributeValueAtMidpoint(NSAccessibilityChildrenAttribute) count]); } @@ -356,7 +356,8 @@ id AXValue() { // Views with non-Widget parents will have the role of the parent view. widget()->GetContentsView()->RemoveChildView(child); - FlexibleRoleTestView* parent = new FlexibleRoleTestView(ui::AX_ROLE_GROUP); + FlexibleRoleTestView* parent = + new FlexibleRoleTestView(ax::mojom::Role::kGroup); parent->FitBoundsToNewChild(child); widget()->GetContentsView()->AddChildView(parent); EXPECT_NSEQ( @@ -364,7 +365,7 @@ id AXValue() { [AXParent() accessibilityAttributeValue:NSAccessibilityRoleAttribute]); // Test an ignored role parent is skipped in favor of the grandparent. - parent->set_role(ui::AX_ROLE_IGNORED); + parent->set_role(ax::mojom::Role::kIgnored); EXPECT_NSEQ( NSAccessibilityWindowRole, [AXParent() accessibilityAttributeValue:NSAccessibilityRoleAttribute]); @@ -402,11 +403,12 @@ id AXValue() { // Test view properties that should report the native NSWindow, and test // specific properties on that NSWindow. TEST_F(NativeWidgetMacAccessibilityTest, NativeWindowProperties) { - FlexibleRoleTestView* view = new FlexibleRoleTestView(ui::AX_ROLE_GROUP); + FlexibleRoleTestView* view = + new FlexibleRoleTestView(ax::mojom::Role::kGroup); view->SetSize(GetWidgetBounds().size()); widget()->GetContentsView()->AddChildView(view); // Make sure it's |view| in the hit test by checking its accessibility role. - EXPECT_EQ(NSAccessibilityGroupRole, AXRole()); + EXPECT_EQ(NSAccessibilityGroupRole, AXRoleString()); NSWindow* window = widget()->GetNativeWindow(); EXPECT_NSEQ(window, AttributeValueAtMidpoint(NSAccessibilityWindowAttribute)); @@ -439,7 +441,7 @@ id AXValue() { boolValue]); // NSAccessibilityTitleAttribute. - EXPECT_NSEQ(NSAccessibilityTextFieldRole, AXRole()); + EXPECT_NSEQ(NSAccessibilityTextFieldRole, AXRoleString()); EXPECT_NSEQ(kTestTitle, AXTitle()); EXPECT_NSEQ(kTestStringValue, AXValue()); @@ -538,14 +540,15 @@ id AXValue() { // Test writing accessibility attributes via an accessibility client for normal // Views. TEST_F(NativeWidgetMacAccessibilityTest, ViewWritableAttributes) { - FlexibleRoleTestView* view = new FlexibleRoleTestView(ui::AX_ROLE_GROUP); + FlexibleRoleTestView* view = + new FlexibleRoleTestView(ax::mojom::Role::kGroup); view->SetSize(GetWidgetBounds().size()); widget()->GetContentsView()->AddChildView(view); // Make sure the accessibility object tested is the correct one. id ax_node = A11yElementAtMidpoint(); EXPECT_TRUE(ax_node); - EXPECT_NSEQ(NSAccessibilityGroupRole, AXRole()); + EXPECT_NSEQ(NSAccessibilityGroupRole, AXRoleString()); // Make sure |view| is focusable, then focus/unfocus it. view->SetFocusBehavior(View::FocusBehavior::ALWAYS); @@ -721,12 +724,13 @@ id AXValue() { // Test performing a 'click' on Views with clickable roles work. TEST_F(NativeWidgetMacAccessibilityTest, PressAction) { - FlexibleRoleTestView* view = new FlexibleRoleTestView(ui::AX_ROLE_BUTTON); + FlexibleRoleTestView* view = + new FlexibleRoleTestView(ax::mojom::Role::kButton); widget()->GetContentsView()->AddChildView(view); view->SetSize(GetWidgetBounds().size()); id ax_node = A11yElementAtMidpoint(); - EXPECT_NSEQ(NSAccessibilityButtonRole, AXRole()); + EXPECT_NSEQ(NSAccessibilityButtonRole, AXRoleString()); EXPECT_TRUE([[ax_node accessibilityActionNames] containsObject:NSAccessibilityPressAction]); @@ -789,7 +793,7 @@ id AXValue() { // Explicit checks done without comparing to NSTextField. EXPECT_TRUE( [ax_node accessibilityIsAttributeSettable:NSAccessibilityValueAttribute]); - EXPECT_NSEQ(NSAccessibilityTextFieldRole, AXRole()); + EXPECT_NSEQ(NSAccessibilityTextFieldRole, AXRoleString()); NSString* kShownValue = @"•" @"••••••••••••••••"; @@ -831,7 +835,7 @@ id AXValue() { id ax_node = A11yElementAtMidpoint(); EXPECT_TRUE(ax_node); - EXPECT_NSEQ(NSAccessibilityStaticTextRole, AXRole()); + EXPECT_NSEQ(NSAccessibilityStaticTextRole, AXRoleString()); EXPECT_NSEQ(kTestStringValue, AXValue()); // Title and description for StaticTextRole should always be empty. @@ -891,7 +895,7 @@ id AXValue() { id ax_node = A11yElementAtMidpoint(); EXPECT_TRUE(ax_node); - EXPECT_NSEQ(NSAccessibilityPopUpButtonRole, AXRole()); + EXPECT_NSEQ(NSAccessibilityPopUpButtonRole, AXRoleString()); // The initial value should be the first item in the menu. EXPECT_NSEQ(kTestStringValue, AXValue()); diff --git a/ui/views/widget/widget_delegate.cc b/ui/views/widget/widget_delegate.cc index a7696103df3117..f0c7ffb60dab39 100644 --- a/ui/views/widget/widget_delegate.cc +++ b/ui/views/widget/widget_delegate.cc @@ -74,8 +74,8 @@ ui::ModalType WidgetDelegate::GetModalType() const { return ui::MODAL_TYPE_NONE; } -ui::AXRole WidgetDelegate::GetAccessibleWindowRole() const { - return ui::AX_ROLE_WINDOW; +ax::mojom::Role WidgetDelegate::GetAccessibleWindowRole() const { + return ax::mojom::Role::kWindow; } base::string16 WidgetDelegate::GetAccessibleWindowTitle() const { diff --git a/ui/views/widget/widget_delegate.h b/ui/views/widget/widget_delegate.h index bd4d8a7a1de290..ed365e99b8f874 100644 --- a/ui/views/widget/widget_delegate.h +++ b/ui/views/widget/widget_delegate.h @@ -9,7 +9,7 @@ #include #include "base/macros.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/base/ui_base_types.h" #include "ui/views/view.h" @@ -72,7 +72,7 @@ class VIEWS_EXPORT WidgetDelegate { // ui::MODAL_TYPE_NONE (not modal). virtual ui::ModalType GetModalType() const; - virtual ui::AXRole GetAccessibleWindowRole() const; + virtual ax::mojom::Role GetAccessibleWindowRole() const; // Returns the title to be read with screen readers. virtual base::string16 GetAccessibleWindowTitle() const; diff --git a/ui/views/win/hwnd_message_handler.h b/ui/views/win/hwnd_message_handler.h index ad432b4d9ac65e..004cee20738f2e 100644 --- a/ui/views/win/hwnd_message_handler.h +++ b/ui/views/win/hwnd_message_handler.h @@ -20,7 +20,7 @@ #include "base/strings/string16.h" #include "base/win/scoped_gdi_object.h" #include "base/win/win_util.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/base/ime/input_method_observer.h" #include "ui/base/ui_base_types.h" #include "ui/base/win/window_event_target.h" diff --git a/ui/views/window/client_view.cc b/ui/views/window/client_view.cc index 2f080badef5cf8..2b6a99a020caec 100644 --- a/ui/views/window/client_view.cc +++ b/ui/views/window/client_view.cc @@ -75,7 +75,7 @@ const char* ClientView::GetClassName() const { } void ClientView::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_CLIENT; + node_data->role = ax::mojom::Role::kClient; } void ClientView::OnBoundsChanged(const gfx::Rect& previous_bounds) { diff --git a/ui/views/window/dialog_delegate.cc b/ui/views/window/dialog_delegate.cc index a741a22ad4273b..3e88b8db4c85a8 100644 --- a/ui/views/window/dialog_delegate.cc +++ b/ui/views/window/dialog_delegate.cc @@ -249,8 +249,8 @@ void DialogDelegate::DialogModelChanged() { observer.OnDialogModelChanged(); } -ui::AXRole DialogDelegate::GetAccessibleWindowRole() const { - return ui::AX_ROLE_DIALOG; +ax::mojom::Role DialogDelegate::GetAccessibleWindowRole() const { + return ax::mojom::Role::kDialog; } //////////////////////////////////////////////////////////////////////////////// @@ -283,7 +283,7 @@ View* DialogDelegateView::GetContentsView() { void DialogDelegateView::ViewHierarchyChanged( const ViewHierarchyChangedDetails& details) { if (details.is_add && details.child == this && GetWidget()) - NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); + NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true); } } // namespace views diff --git a/ui/views/window/dialog_delegate.h b/ui/views/window/dialog_delegate.h index 8061f68022076e..69add25e1a0f1b 100644 --- a/ui/views/window/dialog_delegate.h +++ b/ui/views/window/dialog_delegate.h @@ -9,7 +9,7 @@ #include "base/macros.h" #include "base/strings/string16.h" #include "base/time/time.h" -#include "ui/accessibility/ax_enums.h" +#include "ui/accessibility/ax_enums.mojom.h" #include "ui/base/models/dialog_model.h" #include "ui/base/ui_base_types.h" #include "ui/views/widget/widget.h" @@ -130,7 +130,7 @@ class VIEWS_EXPORT DialogDelegate : public ui::DialogModel, protected: // Overridden from WidgetDelegate: - ui::AXRole GetAccessibleWindowRole() const override; + ax::mojom::Role GetAccessibleWindowRole() const override; private: // A flag indicating whether this dialog is able to use the custom frame diff --git a/ui/views/window/non_client_view.cc b/ui/views/window/non_client_view.cc index 2d20a34cae23b2..1dbbeb4f839485 100644 --- a/ui/views/window/non_client_view.cc +++ b/ui/views/window/non_client_view.cc @@ -201,7 +201,7 @@ void NonClientView::ViewHierarchyChanged( } void NonClientView::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_CLIENT; + node_data->role = ax::mojom::Role::kClient; node_data->SetName(accessible_name_); } @@ -319,7 +319,7 @@ void NonClientFrameView::ActivationChanged(bool active) { } void NonClientFrameView::GetAccessibleNodeData(ui::AXNodeData* node_data) { - node_data->role = ui::AX_ROLE_CLIENT; + node_data->role = ax::mojom::Role::kClient; } const char* NonClientFrameView::GetClassName() const {