diff options
-rw-r--r-- | chrome/browser/gtk/find_bar_gtk.cc | 6 | ||||
-rw-r--r-- | chrome/browser/views/find_bar_view.cc | 41 | ||||
-rw-r--r-- | chrome/browser/views/find_bar_view.h | 4 |
3 files changed, 18 insertions, 33 deletions
diff --git a/chrome/browser/gtk/find_bar_gtk.cc b/chrome/browser/gtk/find_bar_gtk.cc index fb2fa9b..e3ddeb8 100644 --- a/chrome/browser/gtk/find_bar_gtk.cc +++ b/chrome/browser/gtk/find_bar_gtk.cc @@ -372,16 +372,14 @@ void FindBarGtk::UpdateUIForFindResult(const FindNotificationDetails& result, l10n_util::GetStringFUTF8(IDS_FIND_IN_PAGE_COUNT, IntToString16(result.active_match_ordinal()), IntToString16(result.number_of_matches())).c_str()); - UpdateMatchLabelAppearance(result.number_of_matches() == 0); + UpdateMatchLabelAppearance(result.number_of_matches() == 0 && + result.final_update()); } else { // If there was no text entered, we don't show anything in the result count // area. gtk_label_set_text(GTK_LABEL(match_count_label_), ""); UpdateMatchLabelAppearance(false); } - - // TODO(brettw) enable or disable the find next/previous buttons depending - // on whether any matches were found. } void FindBarGtk::AudibleAlert() { diff --git a/chrome/browser/views/find_bar_view.cc b/chrome/browser/views/find_bar_view.cc index 0c57f32..8eb432d 100644 --- a/chrome/browser/views/find_bar_view.cc +++ b/chrome/browser/views/find_bar_view.cc @@ -106,7 +106,6 @@ FindBarView::FindBarView(FindBarHost* host) find_previous_button_ = new views::ImageButton(this); find_previous_button_->set_tag(FIND_PREVIOUS_TAG); - find_previous_button_->SetEnabled(false); find_previous_button_->SetFocusable(true); find_previous_button_->SetImage(views::CustomButton::BS_NORMAL, rb.GetBitmapNamed(IDR_FINDINPAGE_PREV)); @@ -120,7 +119,6 @@ FindBarView::FindBarView(FindBarHost* host) find_next_button_ = new views::ImageButton(this); find_next_button_->set_tag(FIND_NEXT_TAG); - find_next_button_->SetEnabled(false); find_next_button_->SetFocusable(true); find_next_button_->SetImage(views::CustomButton::BS_NORMAL, rb.GetBitmapNamed(IDR_FINDINPAGE_NEXT)); @@ -182,30 +180,17 @@ void FindBarView::UpdateForResult(const FindNotificationDetails& result, l10n_util::GetStringF(IDS_FIND_IN_PAGE_COUNT, IntToWString(result.active_match_ordinal()), IntToWString(result.number_of_matches()))); + + UpdateMatchCountAppearance(result.number_of_matches() == 0 && + result.final_update()); } else { // If there was no text entered, we don't show anything in the result count // area. match_count_text_->SetText(std::wstring()); - } - if (find_text.empty() || result.number_of_matches() > 0 || - !have_valid_range) { - // If there was no text entered or there were results, the match_count label - // should have a normal background color. We also reset the background if - // we don't have_valid_range, so that the text field will not show red - // background when reopened after an unsuccessful find. - ResetMatchCountBackground(); - } else if (result.final_update()) { - // Otherwise we show an error background behind the match_count label. - match_count_text_->set_background( - views::Background::CreateSolidBackground(kBackgroundColorNoMatch)); - match_count_text_->SetColor(kTextColorNoMatch); + UpdateMatchCountAppearance(false); } - // Make sure Find Next and Find Previous are enabled if we found any matches. - find_previous_button_->SetEnabled(result.number_of_matches() > 0); - find_next_button_->SetEnabled(result.number_of_matches() > 0); - // The match_count label may have increased/decreased in size so we need to // do a layout and repaint the dialog so that the find text field doesn't // partially overlap the match-count label when it increases on no matches. @@ -215,12 +200,8 @@ void FindBarView::UpdateForResult(const FindNotificationDetails& result, void FindBarView::SetFocusAndSelection() { find_text_->RequestFocus(); - if (!find_text_->text().empty()) { + if (!find_text_->text().empty()) find_text_->SelectAll(); - - find_previous_button_->SetEnabled(true); - find_next_button_->SetEnabled(true); - } } /////////////////////////////////////////////////////////////////////////////// @@ -483,10 +464,16 @@ bool FindBarView::HandleKeystroke(views::Textfield* sender, return false; } -void FindBarView::ResetMatchCountBackground() { - match_count_text_->set_background( +void FindBarView::UpdateMatchCountAppearance(bool no_match) { + if (no_match) { + match_count_text_->set_background( + views::Background::CreateSolidBackground(kBackgroundColorNoMatch)); + match_count_text_->SetColor(kTextColorNoMatch); + } else { + match_count_text_->set_background( views::Background::CreateSolidBackground(kBackgroundColorMatch)); - match_count_text_->SetColor(kTextColorMatchCount); + match_count_text_->SetColor(kTextColorMatchCount); + } } bool FindBarView::FocusForwarderView::OnMousePressed( diff --git a/chrome/browser/views/find_bar_view.h b/chrome/browser/views/find_bar_view.h index f3757f9..c57aa16 100644 --- a/chrome/browser/views/find_bar_view.h +++ b/chrome/browser/views/find_bar_view.h @@ -69,8 +69,8 @@ class FindBarView : public DropdownBarView, const views::Textfield::Keystroke& key); private: - // Resets the background for the match count label. - void ResetMatchCountBackground(); + // Update the appearance for the match count label. + void UpdateMatchCountAppearance(bool no_match); // Overridden from views::View. virtual void ThemeChanged(); |