Commit 1725f96b authored by Kevin Bailey's avatar Kevin Bailey Committed by Commit Bot

[omnibox] Provide hint to tab switch button when "focused"

The tab switch button isn't ever truly focused, since focus remains with
the Omnibox. Thus, it never gets an accessibility event. This change
causes an accessibility event to be generated when we trigger a
simulated focus of the button.

Bug: 853929
Change-Id: I7db6a8bd906a1785f047dc62b2beb03f14e22114
Reviewed-on: https://chromium-review.googlesource.com/1157071
Commit-Queue: Kevin Bailey <krb@chromium.org>
Reviewed-by: default avatarJustin Donnelly <jdonnelly@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580231}
parent 72313098
...@@ -476,6 +476,11 @@ void OmniboxPopupContentsView::OnDragCanceled() { ...@@ -476,6 +476,11 @@ void OmniboxPopupContentsView::OnDragCanceled() {
SetMouseHandler(nullptr); SetMouseHandler(nullptr);
} }
void OmniboxPopupContentsView::ProvideButtonFocusHint(size_t line) {
OmniboxResultView* result = result_view_at(line);
result->ProvideButtonFocusHint();
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// OmniboxPopupContentsView, views::View overrides: // OmniboxPopupContentsView, views::View overrides:
......
...@@ -58,6 +58,9 @@ class OmniboxPopupContentsView : public views::View, public OmniboxPopupView { ...@@ -58,6 +58,9 @@ class OmniboxPopupContentsView : public views::View, public OmniboxPopupView {
// Called by the active result view to inform model (due to mouse event). // Called by the active result view to inform model (due to mouse event).
void UnselectButton(); void UnselectButton();
// Called to inform result view of button focus.
void ProvideButtonFocusHint(size_t line);
// OmniboxPopupView: // OmniboxPopupView:
bool IsOpen() const override; bool IsOpen() const override;
void InvalidateLine(size_t line) override; void InvalidateLine(size_t line) override;
......
...@@ -366,6 +366,10 @@ void OmniboxResultView::OnNativeThemeChanged(const ui::NativeTheme* theme) { ...@@ -366,6 +366,10 @@ void OmniboxResultView::OnNativeThemeChanged(const ui::NativeTheme* theme) {
SchedulePaint(); SchedulePaint();
} }
void OmniboxResultView::ProvideButtonFocusHint() {
suggestion_tab_switch_button_->ProvideFocusHint();
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// OmniboxResultView, private: // OmniboxResultView, private:
......
...@@ -70,6 +70,9 @@ class OmniboxResultView : public views::View, ...@@ -70,6 +70,9 @@ class OmniboxResultView : public views::View,
// Called when tab switch button pressed, due to being a listener. // Called when tab switch button pressed, due to being a listener.
void ButtonPressed(views::Button* sender, const ui::Event& event) override; void ButtonPressed(views::Button* sender, const ui::Event& event) override;
// Called to indicate tab switch button has been focused.
void ProvideButtonFocusHint();
// views::View: // views::View:
void Layout() override; void Layout() override;
bool OnMousePressed(const ui::MouseEvent& event) override; bool OnMousePressed(const ui::MouseEvent& event) override;
......
...@@ -143,6 +143,10 @@ void OmniboxTabSwitchButton::ProvideWidthHint(size_t parent_width) { ...@@ -143,6 +143,10 @@ void OmniboxTabSwitchButton::ProvideWidthHint(size_t parent_width) {
} }
} }
void OmniboxTabSwitchButton::ProvideFocusHint() {
NotifyAccessibilityEvent(ax::mojom::Event::kHover, true);
}
bool OmniboxTabSwitchButton::IsSelected() const { bool OmniboxTabSwitchButton::IsSelected() const {
return model_->IsButtonSelected(); return model_->IsButtonSelected();
} }
......
...@@ -40,6 +40,9 @@ class OmniboxTabSwitchButton : public views::MdTextButton { ...@@ -40,6 +40,9 @@ class OmniboxTabSwitchButton : public views::MdTextButton {
// so the button can adjust its size or even presence. // so the button can adjust its size or even presence.
void ProvideWidthHint(size_t width); void ProvideWidthHint(size_t width);
// Called to indicate button has been focused.
void ProvideFocusHint();
private: private:
// Consults the parent views to see if the button is selected. // Consults the parent views to see if the button is selected.
bool IsSelected() const; bool IsSelected() const;
......
...@@ -482,6 +482,8 @@ bool OmniboxViewViews::HandleEarlyTabActions(const ui::KeyEvent& event) { ...@@ -482,6 +482,8 @@ bool OmniboxViewViews::HandleEarlyTabActions(const ui::KeyEvent& event) {
OmniboxPopupModel::NORMAL && OmniboxPopupModel::NORMAL &&
!event.IsShiftDown()) { !event.IsShiftDown()) {
model()->popup_model()->SetSelectedLineState(OmniboxPopupModel::TAB_SWITCH); model()->popup_model()->SetSelectedLineState(OmniboxPopupModel::TAB_SWITCH);
popup_view_->ProvideButtonFocusHint(
model()->popup_model()->selected_line());
return true; return true;
} }
...@@ -506,6 +508,8 @@ bool OmniboxViewViews::HandleEarlyTabActions(const ui::KeyEvent& event) { ...@@ -506,6 +508,8 @@ bool OmniboxViewViews::HandleEarlyTabActions(const ui::KeyEvent& event) {
if (event.IsShiftDown() && if (event.IsShiftDown() &&
model()->popup_model()->SelectedLineHasTabMatch()) { model()->popup_model()->SelectedLineHasTabMatch()) {
model()->popup_model()->SetSelectedLineState(OmniboxPopupModel::TAB_SWITCH); model()->popup_model()->SetSelectedLineState(OmniboxPopupModel::TAB_SWITCH);
popup_view_->ProvideButtonFocusHint(
model()->popup_model()->selected_line());
} }
return true; return true;
......
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