Commit 87546492 authored by Jacobo Aragunde Pérez's avatar Jacobo Aragunde Pérez Committed by Commit Bot

Use display reason to decide accessible role for location bar bubbles.

Bubbles that extend LocationBarBubbleDelegateView have the member
function ShowForReason, which may show them in an inactive way when
they are not displayed as a result of direct user action.

Bubbles displayed in an active way would get focus and ATs would
immediately read them, so their role would be a dialog. Likewise,
bubbles that show inactive would not get focus and we need them to
behave like alert dialogs so ATs can announce them properly.

This fixes several bugs:

* crbug.com/1119367: the save credit card bubble was not announced
  because it didn't have the alert dialog role.

* crbug.com/1119734: the translate page bubble was not announced
  because it didn't have the alert dialog role.

* crbug.com/1132318: the password bubble was read twice because it was
  getting focus in addition to sending an alert event.

             properly announce save credit card bubble, properly
             announce translate page bubble.

Bug: 1119367, 1119734, 1132318
Change-Id: I1c46d65ec2a47a25947f6a75a8935595d974bfa1
AX-relnotes: Do not read password bubble twice when explictly opened,
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2431526Reviewed-by: default avatarAllen Bauer <kylixrd@chromium.org>
Commit-Queue: Jacobo Aragunde Pérez <jaragunde@igalia.com>
Cr-Commit-Position: refs/heads/master@{#815038}
parent 8b2c2887
......@@ -65,6 +65,8 @@ LocationBarBubbleDelegateView::~LocationBarBubbleDelegateView() = default;
void LocationBarBubbleDelegateView::ShowForReason(DisplayReason reason,
bool allow_refocus_alert) {
display_reason_ = 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
// whether their normal anchor point is visible. However, if part or all of
......@@ -96,6 +98,13 @@ void LocationBarBubbleDelegateView::ShowForReason(DisplayReason reason,
}
}
ax::mojom::Role LocationBarBubbleDelegateView::GetAccessibleWindowRole() {
if (display_reason_ == USER_GESTURE)
return ax::mojom::Role::kDialog;
return ax::mojom::Role::kAlertDialog;
}
void LocationBarBubbleDelegateView::OnFullscreenStateChanged() {
GetWidget()->SetVisibilityAnimationTransition(views::Widget::ANIMATE_NONE);
CloseBubble();
......
......@@ -65,6 +65,7 @@ class LocationBarBubbleDelegateView : public views::BubbleDialogDelegateView,
content::NavigationHandle* navigation_handle) override;
// views::BubbleDialogDelegateView:
ax::mojom::Role GetAccessibleWindowRole() override;
gfx::Rect GetAnchorBoundsInScreen() const override;
// If the bubble is not anchored to a view, places the bubble in the top right
......@@ -109,6 +110,8 @@ class LocationBarBubbleDelegateView : public views::BubbleDialogDelegateView,
// different origin.
bool close_on_main_frame_origin_navigation_ = false;
DisplayReason display_reason_ = AUTOMATIC;
DISALLOW_COPY_AND_ASSIGN(LocationBarBubbleDelegateView);
};
......
......@@ -156,14 +156,6 @@ void PasswordBubbleViewBase::Init() {
SetShowTitle(!controller->GetTitle().empty());
}
ax::mojom::Role PasswordBubbleViewBase::GetAccessibleWindowRole() {
// This bubble is displayed as non-modal when users finish typing their
// password. In absence of a focus change event, ATs will not notice the
// bubble unless an alert event is emitted, so we need it to have an
// alert role.
return ax::mojom::Role::kAlertDialog;
}
void PasswordBubbleViewBase::OnWidgetClosing(views::Widget* widget) {
LocationBarBubbleDelegateView::OnWidgetClosing(widget);
if (widget != GetWidget())
......
......@@ -66,9 +66,6 @@ class PasswordBubbleViewBase : public LocationBarBubbleDelegateView {
~PasswordBubbleViewBase() override;
// views::BubbleDialogDelegateView:
ax::mojom::Role GetAccessibleWindowRole() override;
private:
// views::BubbleDialogDelegateView:
void Init() override;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment