Commit c0bc5bbb authored by Peter Boström's avatar Peter Boström Committed by Commit Bot

Use platform focus behavior for close-x buttons

This makes the close-x keyboard focusable in most cases. This serves
a11y users who can detect its presence and use it, like other buttons,
without the Esc shortcut.

Adds the Close accessibility name back under Windows where the tooltip
is removed in favor of ones generated by the platform from HTCLOSE.

Bug: chromium:1019873, chromium:1049667, chromium:1049722
Change-Id: Ib33b992c1085d9368cc7573785b21e1ff05a9a3a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2047454
Commit-Queue: Peter Boström <pbos@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#740499}
parent 7aca4eb8
...@@ -93,6 +93,8 @@ BubbleFrameView::BubbleFrameView(const gfx::Insets& title_margins, ...@@ -93,6 +93,8 @@ BubbleFrameView::BubbleFrameView(const gfx::Insets& title_margins,
// Windows will automatically create a tooltip for the close button based on // Windows will automatically create a tooltip for the close button based on
// the HTCLOSE result from NonClientHitTest(). // the HTCLOSE result from NonClientHitTest().
close->SetTooltipText(base::string16()); close->SetTooltipText(base::string16());
// Specify accessible name instead for screen readers.
close->SetAccessibleName(l10n_util::GetStringUTF16(IDS_APP_CLOSE));
#endif #endif
close_ = AddChildView(std::move(close)); close_ = AddChildView(std::move(close));
...@@ -126,14 +128,10 @@ std::unique_ptr<Button> BubbleFrameView::CreateCloseButton( ...@@ -126,14 +128,10 @@ std::unique_ptr<Button> BubbleFrameView::CreateCloseButton(
: gfx::kGoogleGrey700); : gfx::kGoogleGrey700);
close_button->SetTooltipText(l10n_util::GetStringUTF16(IDS_APP_CLOSE)); close_button->SetTooltipText(l10n_util::GetStringUTF16(IDS_APP_CLOSE));
close_button->SizeToPreferredSize(); close_button->SizeToPreferredSize();
close_button->SetFocusForPlatform();
InstallCircleHighlightPathGenerator(close_button.get()); InstallCircleHighlightPathGenerator(close_button.get());
// Remove the close button from tab traversal on all platforms. Note this does
// not affect screen readers' ability to focus the close button. Keyboard
// access to the close button when not using a screen reader is done via the
// ESC key handler in DialogClientView.
close_button->SetFocusBehavior(View::FocusBehavior::NEVER);
return close_button; return close_button;
} }
......
...@@ -420,6 +420,10 @@ void EditableCombobox::GetAccessibleNodeData(ui::AXNodeData* node_data) { ...@@ -420,6 +420,10 @@ void EditableCombobox::GetAccessibleNodeData(ui::AXNodeData* node_data) {
node_data->SetValue(GetText()); node_data->SetValue(GetText());
} }
void EditableCombobox::RequestFocus() {
textfield_->RequestFocus();
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// EditableCombobox, TextfieldController overrides: // EditableCombobox, TextfieldController overrides:
......
...@@ -123,6 +123,7 @@ class VIEWS_EXPORT EditableCombobox : public View, ...@@ -123,6 +123,7 @@ class VIEWS_EXPORT EditableCombobox : public View,
void Layout() override; void Layout() override;
void OnThemeChanged() override; void OnThemeChanged() override;
void GetAccessibleNodeData(ui::AXNodeData* node_data) override; void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
void RequestFocus() override;
// Overridden from TextfieldController: // Overridden from TextfieldController:
void ContentsChanged(Textfield* sender, void ContentsChanged(Textfield* sender,
......
...@@ -416,6 +416,8 @@ TEST_F(DialogTest, UnfocusableInitialFocus) { ...@@ -416,6 +416,8 @@ TEST_F(DialogTest, UnfocusableInitialFocus) {
// This achieves the same effect as disabling full keyboard access. // This achieves the same effect as disabling full keyboard access.
dialog->GetOkButton()->SetFocusBehavior(View::FocusBehavior::NEVER); dialog->GetOkButton()->SetFocusBehavior(View::FocusBehavior::NEVER);
dialog->GetCancelButton()->SetFocusBehavior(View::FocusBehavior::NEVER); dialog->GetCancelButton()->SetFocusBehavior(View::FocusBehavior::NEVER);
dialog->GetBubbleFrameView()->GetCloseButtonForTesting()->SetFocusBehavior(
View::FocusBehavior::NEVER);
#endif #endif
// On showing the dialog, the initially focused View will be the OK button. // On showing the dialog, the initially focused View will be the OK button.
......
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