0

Rename WidgetDelegate::SetAccessibleRole to SetAccessibleWindowRole

* The getter's name is GetAccessibleWindowRole. This makes things more
  consistent.
* This makes it possible to create View::SetAccessibleRole without
  competing property names. The creation of View::SetAccessibleRole will
  make it possible to have View::GetAccessibleNodeData do the work
  currently being done by a number of subclasses (i.e. just setting
  AXNodeData's name and role)

AX-Relnotes: n/a
Change-Id: Iafa8108c92933186b84ec91e72c33f2cf18fe857
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4030442
Reviewed-by: Mitsuru Oshima <oshima@chromium.org>
Reviewed-by: Allen Bauer <kylixrd@chromium.org>
Commit-Queue: Joanmarie Diggs <jdiggs@igalia.com>
Reviewed-by: Peter Boström <pbos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1090760}
This commit is contained in:
Joanmarie Diggs
2023-01-10 10:29:25 +00:00
committed by Chromium LUCI CQ
parent 0f01d2593c
commit a1a0324968
26 changed files with 28 additions and 28 deletions

@ -324,7 +324,7 @@ AppListView::AppListView(AppListViewDelegate* delegate)
// to allow the focus to move from elements in app list view to search box.
// TODO(pbos): Should this be necessary with the OverrideNextFocus() used
// below?
SetAccessibleRole(ax::mojom::Role::kGroup);
SetAccessibleWindowRole(ax::mojom::Role::kGroup);
}
AppListView::~AppListView() {

@ -151,7 +151,7 @@ ArcSplashScreenDialogView::ArcSplashScreenDialogView(
SetAnchorView(anchor_);
SetTitle(l10n_util::GetStringUTF16(IDS_ARC_COMPAT_MODE_SPLASH_SCREEN_TITLE));
SetShowTitle(false);
SetAccessibleRole(ax::mojom::Role::kDialog);
SetAccessibleWindowRole(ax::mojom::Role::kDialog);
// For handling the case when Esc key is pressed.
SetCancelCallback(
base::BindOnce(&ArcSplashScreenDialogView::OnCloseButtonClicked,

@ -253,7 +253,7 @@ ResizeToggleMenu::MakeBubbleDelegateView(
delegate_view->SetTitle(
l10n_util::GetStringUTF16(IDS_ARC_COMPAT_MODE_RESIZE_TOGGLE_MENU_TITLE));
delegate_view->SetShowTitle(false);
delegate_view->SetAccessibleRole(ax::mojom::Role::kMenu);
delegate_view->SetAccessibleWindowRole(ax::mojom::Role::kMenu);
// Setup view.
auto* const provider = views::LayoutProvider::Get();

@ -60,7 +60,7 @@ ImeModeIndicatorView::ImeModeIndicatorView(const gfx::Rect& cursor_bounds,
set_shadow(views::BubbleBorder::STANDARD_SHADOW);
SetArrow(views::BubbleBorder::TOP_CENTER);
// Ignore this view for accessibility purposes.
SetAccessibleRole(ax::mojom::Role::kNone);
SetAccessibleWindowRole(ax::mojom::Role::kNone);
}
ImeModeIndicatorView::~ImeModeIndicatorView() = default;

@ -48,7 +48,7 @@ ShelfBubble::ShelfBubble(views::View* anchor, ShelfAlignment alignment)
// We override the role because the base class sets it to alert dialog,
// which results in each tooltip title being announced twice on screen
// readers each time it is shown.
SetAccessibleRole(ax::mojom::Role::kDialog);
SetAccessibleWindowRole(ax::mojom::Role::kDialog);
}
ShelfBubble::~ShelfBubble() {

@ -255,7 +255,7 @@ TrayBubbleView::TrayBubbleView(const InitParams& init_params)
// We set the dialog role because views::BubbleDialogDelegate defaults this to
// an alert dialog. This would make screen readers announce the whole of the
// system tray which is undesirable.
SetAccessibleRole(ax::mojom::Role::kDialog);
SetAccessibleWindowRole(ax::mojom::Role::kDialog);
// We force to create contents background since the bubble border background
// is not shown in this view.
if (features::IsDarkLightModeEnabled())

@ -23,7 +23,7 @@ BaseDialogDelegateView::BaseDialogDelegateView(views::View* anchor_view)
set_adjust_if_offscreen(true);
set_close_on_deactivate(false);
SetModalType(ui::MODAL_TYPE_CHILD);
SetAccessibleRole(ax::mojom::Role::kDialog);
SetAccessibleWindowRole(ax::mojom::Role::kDialog);
SetLayoutManager(std::make_unique<views::FlexLayout>())
->SetOrientation(views::LayoutOrientation::kVertical)
.SetInteriorMargin(

@ -176,7 +176,7 @@ CandidateWindowView::CandidateWindowView(gfx::NativeView parent)
set_parent_window(parent);
set_margins(gfx::Insets());
// Ignore this role for accessibility purposes.
SetAccessibleRole(ax::mojom::Role::kNone);
SetAccessibleWindowRole(ax::mojom::Role::kNone);
// When BubbleDialogDelegateView creates its frame view it will create a
// bubble border with a non-zero corner radius by default.

@ -172,7 +172,7 @@ SuggestionWindowView::SuggestionWindowView(gfx::NativeView parent,
// AccessibleRole determines whether the content is announced on pop-up.
// Inner content should not be announced when the window appears since this
// is handled by AssistiveAccessibilityView to announce a custom string.
SetAccessibleRole(ax::mojom::Role::kNone);
SetAccessibleWindowRole(ax::mojom::Role::kNone);
SetButtons(ui::DIALOG_BUTTON_NONE);
SetCanActivate(false);
set_parent_window(parent);

@ -482,7 +482,7 @@ void SharesheetBubbleView::SetUpDialog() {
// We set the dialog role because views::BubbleDialogDelegate defaults this to
// an alert dialog. This would make screen readers announce all of this dialog
// which is undesirable.
SetAccessibleRole(ax::mojom::Role::kDialog);
SetAccessibleWindowRole(ax::mojom::Role::kDialog);
SetAccessibleTitle(l10n_util::GetStringUTF16(IDS_SHARESHEET_TITLE_LABEL));
AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE));
}

@ -129,7 +129,7 @@ FindBarHost::FindBarHost(BrowserView* browser_view)
DropdownBarHostDelegate* find_bar_delegate = find_bar_view.get();
Init(browser_view->find_bar_host_view(), std::move(find_bar_view),
find_bar_delegate);
SetAccessibleRole(ax::mojom::Role::kDialog);
SetAccessibleWindowRole(ax::mojom::Role::kDialog);
}
FindBarHost::~FindBarHost() {

@ -59,7 +59,7 @@ FlyingIndicator::FlyingIndicator(const gfx::VectorIcon& icon,
color_provider->GetColor(kColorFlyingIndicatorBackground);
// Set the bubble properties.
bubble_view->SetAccessibleRole(ax::mojom::Role::kNone);
bubble_view->SetAccessibleWindowRole(ax::mojom::Role::kNone);
bubble_view->SetButtons(ui::DIALOG_BUTTON_NONE);
bubble_view->set_margins(gfx::Insets());
bubble_view->SetCanActivate(false);

@ -97,7 +97,7 @@ LocationBarBubbleDelegateView::LocationBarBubbleDelegateView(
// really wrong. If we need the accessible role before ShowForReason() we
// can't rely on DisplayReason in there. It also really seems like this dialog
// role should not depend on if it's showing in the foreground or not.
SetAccessibleRole(GetAccessibleRoleForReason(display_reason_));
SetAccessibleWindowRole(GetAccessibleRoleForReason(display_reason_));
}
LocationBarBubbleDelegateView::~LocationBarBubbleDelegateView() {
@ -107,7 +107,7 @@ LocationBarBubbleDelegateView::~LocationBarBubbleDelegateView() {
void LocationBarBubbleDelegateView::ShowForReason(DisplayReason reason,
bool allow_refocus_alert) {
display_reason_ = reason;
SetAccessibleRole(GetAccessibleRoleForReason(reason));
SetAccessibleWindowRole(GetAccessibleRoleForReason(reason));
// These bubbles all anchor to the location bar or toolbar. We selectively
// anchor location bar bubbles to one end or the other of the toolbar based on

@ -111,7 +111,7 @@ IN_PROC_BROWSER_TEST_P(PasswordBubbleBrowserTest, AlertAccessibleEvent) {
EXPECT_EQ(0, counter.GetCount(ax::mojom::Event::kAlert));
// This needs to show a password bubble that does not trigger as a user
// gesture in order to fire an alert event. See
// LocationBarBubbleDelegateView's calls to SetAccessibleRole().
// LocationBarBubbleDelegateView's calls to SetAccessibleWindowRole().
ShowUi("AutomaticPasswordBubble");
EXPECT_EQ(1, counter.GetCount(ax::mojom::Event::kAlert));
}

@ -532,7 +532,7 @@ ProfileMenuViewBase::ProfileMenuViewBase(views::Button* anchor_button,
SetEnableArrowKeyTraversal(true);
// TODO(crbug.com/1341017): Using `SetAccessibleRole(kMenu)` here will
// TODO(crbug.com/1341017): Using `SetAccessibleWindowRole(kMenu)` here will
// result in screenreader to announce the menu having only one item. This is
// probably because this API sets the a11y role for the widget, but not root
// view in it. This is confusing and prone to misuse. We should unify the two

@ -754,7 +754,7 @@ TabHoverCardBubbleView::TabHoverCardBubbleView(Tab* tab)
// Remove the accessible role so that hover cards are not read when they
// appear because tabs handle accessibility text.
SetAccessibleRole(ax::mojom::Role::kNone);
SetAccessibleWindowRole(ax::mojom::Role::kNone);
// We'll do all of our own layout inside the bubble, so no need to inset this
// view inside the client view.

@ -104,7 +104,7 @@ ChromeLabsBubbleView::ChromeLabsBubbleView(ChromeLabsButton* anchor_view)
// `kAlertDialog` which would tell screen readers to announce all contents of
// the bubble when it opens and previous accessibility feedback said that
// behavior was confusing.
SetAccessibleRole(ax::mojom::Role::kDialog);
SetAccessibleWindowRole(ax::mojom::Role::kDialog);
// TODO(crbug.com/1259763): Currently basing this off what extension menu uses
// for sizing as suggested as an initial fix by UI. Discuss a more formal

@ -249,7 +249,7 @@ ToolbarActionHoverCardBubbleView::ToolbarActionHoverCardBubbleView(
// Remove the accessible role so that hover cards are not read when they
// appear because tabs handle accessibility text.
SetAccessibleRole(ax::mojom::Role::kNone);
SetAccessibleWindowRole(ax::mojom::Role::kNone);
// We'll do all of our own layout inside the bubble, so no need to inset this
// view inside the client view.

@ -322,7 +322,7 @@ HelpBubbleView::HelpBubbleView(const HelpBubbleDelegate* delegate,
// Since we don't have any controls for the user to interact with (we're just
// an information bubble), override our role to kAlert.
SetAccessibleRole(ax::mojom::Role::kAlert);
SetAccessibleWindowRole(ax::mojom::Role::kAlert);
// Layout structure:
//

@ -496,7 +496,7 @@ class VIEWS_EXPORT BubbleDialogDelegateView : public BubbleDialogDelegate,
};
BEGIN_VIEW_BUILDER(VIEWS_EXPORT, BubbleDialogDelegateView, View)
VIEW_BUILDER_PROPERTY(ax::mojom::Role, AccessibleRole)
VIEW_BUILDER_PROPERTY(ax::mojom::Role, AccessibleWindowRole)
VIEW_BUILDER_PROPERTY(std::u16string, AccessibleTitle)
VIEW_BUILDER_PROPERTY(bool, CanMaximize)
VIEW_BUILDER_PROPERTY(bool, CanMinimize)

@ -113,7 +113,7 @@ class TestAlertBubbleDialogDelegateView : public TestBubbleDialogDelegateView {
public:
explicit TestAlertBubbleDialogDelegateView(View* anchor_view)
: TestBubbleDialogDelegateView(anchor_view) {
SetAccessibleRole(ax::mojom::Role::kAlertDialog);
SetAccessibleWindowRole(ax::mojom::Role::kAlertDialog);
}
~TestAlertBubbleDialogDelegateView() override = default;
};

@ -445,9 +445,9 @@ BubbleDialogModelHost::BubbleDialogModelHost(
// TODO(accessibility): review the role mappings for alerts and dialogs,
// making sure they are translated to the best candidate in each flatform
// without resorting to hacks like this.
SetAccessibleRole(ax::mojom::Role::kAlert);
SetAccessibleWindowRole(ax::mojom::Role::kAlert);
#else
SetAccessibleRole(ax::mojom::Role::kAlertDialog);
SetAccessibleWindowRole(ax::mojom::Role::kAlertDialog);
#endif
}

@ -59,7 +59,7 @@ InfoBubble::InfoBubble(View* anchor,
set_margins(LayoutProvider::Get()->GetInsetsMetric(
InsetsMetric::INSETS_TOOLTIP_BUBBLE));
SetCanActivate(false);
SetAccessibleRole(ax::mojom::Role::kAlertDialog);
SetAccessibleWindowRole(ax::mojom::Role::kAlertDialog);
// TODO(pbos): This hacks around a bug where focus order in the parent dialog
// breaks because it tries to focus InfoBubble without anything focusable in
// it. FocusSearch should handle this case and this should be removable.

@ -310,7 +310,7 @@ bool WidgetDelegate::ShouldDescendIntoChildForEventHandling(
return true;
}
void WidgetDelegate::SetAccessibleRole(ax::mojom::Role role) {
void WidgetDelegate::SetAccessibleWindowRole(ax::mojom::Role role) {
params_.accessible_role = role;
}

@ -325,7 +325,7 @@ class VIEWS_EXPORT WidgetDelegate
// Setters for data parameters of the WidgetDelegate. If you use these
// setters, there is no need to override the corresponding virtual getters.
void SetAccessibleRole(ax::mojom::Role role);
void SetAccessibleWindowRole(ax::mojom::Role role);
void SetAccessibleTitle(std::u16string title);
void SetCanMaximize(bool can_maximize);
void SetCanMinimize(bool can_minimize);

@ -401,7 +401,7 @@ template View* DialogDelegate::SetExtraView<View>(std::unique_ptr<View>);
template View* DialogDelegate::SetFootnoteView<View>(std::unique_ptr<View>);
BEGIN_VIEW_BUILDER(VIEWS_EXPORT, DialogDelegateView, View)
VIEW_BUILDER_PROPERTY(ax::mojom::Role, AccessibleRole)
VIEW_BUILDER_PROPERTY(ax::mojom::Role, AccessibleWindowRole)
VIEW_BUILDER_PROPERTY(std::u16string, AccessibleTitle)
VIEW_BUILDER_PROPERTY(bool, CanMaximize)
VIEW_BUILDER_PROPERTY(bool, CanMinimize)