Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(952)

Unified Diff: chrome/browser/ui/views/find_bar_view.cc

Issue 1660273003: Keep focus on Find-In-Page buttons when using the keyboard to navigate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove viewIDs for findbar and add them to the exception list. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/find_bar_view.cc
diff --git a/chrome/browser/ui/views/find_bar_view.cc b/chrome/browser/ui/views/find_bar_view.cc
index dbfa65b73c2a8a65e1b298f11b74a490232cf401..7cf53c30ff5457947fd74990d30f6ce57e8b1039 100644
--- a/chrome/browser/ui/views/find_bar_view.cc
+++ b/chrome/browser/ui/views/find_bar_view.cc
@@ -152,7 +152,7 @@ FindBarView::FindBarView(FindBarHost* host)
close_button_ = new views::ImageButton(this);
}
- find_previous_button_->set_tag(FIND_PREVIOUS_TAG);
+ find_previous_button_->set_id(VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON);
find_previous_button_->SetFocusable(true);
find_previous_button_->set_request_focus_on_press(false);
find_previous_button_->SetTooltipText(
@@ -161,7 +161,7 @@ FindBarView::FindBarView(FindBarHost* host)
l10n_util::GetStringUTF16(IDS_ACCNAME_PREVIOUS));
AddChildView(find_previous_button_);
- find_next_button_->set_tag(FIND_NEXT_TAG);
+ find_next_button_->set_id(VIEW_ID_FIND_IN_PAGE_NEXT_BUTTON);
find_next_button_->SetFocusable(true);
find_next_button_->set_request_focus_on_press(false);
find_next_button_->SetTooltipText(
@@ -170,7 +170,7 @@ FindBarView::FindBarView(FindBarHost* host)
l10n_util::GetStringUTF16(IDS_ACCNAME_NEXT));
AddChildView(find_next_button_);
- close_button_->set_tag(CLOSE_TAG);
+ close_button_->set_id(VIEW_ID_FIND_IN_PAGE_CLOSE_BUTTON);
close_button_->SetFocusable(true);
close_button_->set_request_focus_on_press(false);
close_button_->SetTooltipText(
@@ -422,20 +422,24 @@ gfx::Size FindBarView::GetPreferredSize() const {
void FindBarView::ButtonPressed(
views::Button* sender, const ui::Event& event) {
- switch (sender->tag()) {
- case FIND_PREVIOUS_TAG:
- case FIND_NEXT_TAG:
+ switch (sender->id()) {
+ case VIEW_ID_FIND_IN_PAGE_PREVIOUS_BUTTON:
+ case VIEW_ID_FIND_IN_PAGE_NEXT_BUTTON:
if (!find_text_->text().empty()) {
FindTabHelper* find_tab_helper = FindTabHelper::FromWebContents(
find_bar_host()->GetFindBarController()->web_contents());
- find_tab_helper->StartFinding(find_text_->text(),
- sender->tag() == FIND_NEXT_TAG,
- false); // Not case sensitive.
+ find_tab_helper->StartFinding(
+ find_text_->text(),
+ sender->id() == VIEW_ID_FIND_IN_PAGE_NEXT_BUTTON,
+ false); // Not case sensitive.
+ }
+
+ if (event.IsMouseEvent()) {
+ // Move focus to the find textfield.
+ find_text_->RequestFocus();
}
- // Move focus to the find textfield.
- find_text_->RequestFocus();
break;
- case CLOSE_TAG:
+ case VIEW_ID_FIND_IN_PAGE_CLOSE_BUTTON:
find_bar_host()->GetFindBarController()->EndFindSession(
FindBarController::kKeepSelectionOnPage,
FindBarController::kKeepResultsInFindBox);
@@ -601,7 +605,9 @@ void FindBarView::Find(const base::string16& search_text) {
}
void FindBarView::UpdateMatchCountAppearance(bool no_match) {
- bool enable_buttons = !match_count_text_->text().empty() && !no_match;
+ // Enable the buttons if there is a match or if there is a match count text
+ // set (from a prepopulated view).
+ bool enable_buttons = !match_count_text_->text().empty() || !no_match;
find_previous_button_->SetEnabled(enable_buttons);
find_next_button_->SetEnabled(enable_buttons);
« no previous file with comments | « chrome/browser/ui/views/find_bar_view.h ('k') | chrome/browser/ui/views/find_bar_views_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698