Commit 9029e6e3 authored by Orin Jaworski's avatar Orin Jaworski Committed by Commit Bot

[omnibox] Add focus rings for button row buttons

This CL adds focus rings that are only used when button row is enabled.

Bug: 1046523
Change-Id: I679cd08c0199eb5de5ac5577a49ef9ce5fdd7b5a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2140309Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Commit-Queue: Orin Jaworski <orinj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757204}
parent 0d1936e5
...@@ -118,6 +118,24 @@ OmniboxResultView::OmniboxResultView( ...@@ -118,6 +118,24 @@ OmniboxResultView::OmniboxResultView(
// TODO(orinj): Use the real translated string table values here instead. // TODO(orinj): Use the real translated string table values here instead.
tab_switch_button_ = tab_switch_button_ =
CreatePillButton(button_row_, this, "Switch to this tab"); CreatePillButton(button_row_, this, "Switch to this tab");
const auto make_predicate = [=](auto state) {
return [=](View* view) {
return view->GetVisible() &&
popup_contents_view_->model()->selection() ==
OmniboxPopupModel::Selection(model_index_, state);
};
};
keyword_button_focus_ring_ = views::FocusRing::Install(keyword_button_);
keyword_button_focus_ring_->SetHasFocusPredicate(
make_predicate(OmniboxPopupModel::FOCUSED_BUTTON_KEYWORD));
pedal_button_focus_ring_ = views::FocusRing::Install(pedal_button_);
pedal_button_focus_ring_->SetHasFocusPredicate(
make_predicate(OmniboxPopupModel::FOCUSED_BUTTON_PEDAL));
tab_switch_button_focus_ring_ =
views::FocusRing::Install(tab_switch_button_);
tab_switch_button_focus_ring_->SetHasFocusPredicate(
make_predicate(OmniboxPopupModel::FOCUSED_BUTTON_TAB_SWITCH));
} }
keyword_view_ = AddChildView(std::make_unique<OmniboxMatchCellView>(this)); keyword_view_ = AddChildView(std::make_unique<OmniboxMatchCellView>(this));
...@@ -232,6 +250,12 @@ void OmniboxResultView::ApplyThemeAndRefreshIcons(bool force_reapply_styles) { ...@@ -232,6 +250,12 @@ void OmniboxResultView::ApplyThemeAndRefreshIcons(bool force_reapply_styles) {
keyword_view_->description()->ApplyTextColor( keyword_view_->description()->ApplyTextColor(
OmniboxPart::RESULTS_TEXT_DIMMED); OmniboxPart::RESULTS_TEXT_DIMMED);
} }
if (OmniboxFieldTrial::IsSuggestionButtonRowEnabled()) {
keyword_button_focus_ring_->SchedulePaint();
pedal_button_focus_ring_->SchedulePaint();
tab_switch_button_focus_ring_->SchedulePaint();
}
} }
void OmniboxResultView::OnSelectionStateChanged() { void OmniboxResultView::OnSelectionStateChanged() {
......
...@@ -169,6 +169,9 @@ class OmniboxResultView : public views::View, ...@@ -169,6 +169,9 @@ class OmniboxResultView : public views::View,
views::MdTextButton* keyword_button_ = nullptr; views::MdTextButton* keyword_button_ = nullptr;
views::MdTextButton* pedal_button_ = nullptr; views::MdTextButton* pedal_button_ = nullptr;
views::MdTextButton* tab_switch_button_ = nullptr; views::MdTextButton* tab_switch_button_ = nullptr;
std::unique_ptr<views::FocusRing> keyword_button_focus_ring_;
std::unique_ptr<views::FocusRing> pedal_button_focus_ring_;
std::unique_ptr<views::FocusRing> tab_switch_button_focus_ring_;
// The "X" button at the end of the match cell, used to remove suggestions. // The "X" button at the end of the match cell, used to remove suggestions.
views::ImageButton* remove_suggestion_button_; views::ImageButton* remove_suggestion_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