Commit e8b51952 authored by msw@chromium.org's avatar msw@chromium.org

Replace find bar RequestFocus override with OnFocus.

Make View::RequestFocus non-virtual; replace override.
Also add mouse-press/release inhibiting of select-all.
(this prevents a flash of all text selected on click)

BUG=232290
TEST=No find bar focus-related behavior/appearance regressions; switching back to a tab that had the find bar focused (from a tab that didn't have the find bar focused) restores find bar focus and selects the entire text content; clicking the find bar doesn't flash all the text selected before placing the cursor or starting a drag.
R=ben@chromium.org

Review URL: https://chromiumcodereview.appspot.com/13852009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195028 0039d316-1c4b-4281-b951-d872f2087c98
parent 57fb61f9
...@@ -498,14 +498,28 @@ bool FindBarView::FocusForwarderView::OnMousePressed( ...@@ -498,14 +498,28 @@ bool FindBarView::FocusForwarderView::OnMousePressed(
return true; return true;
} }
FindBarView::SearchTextfieldView::SearchTextfieldView() {} FindBarView::SearchTextfieldView::SearchTextfieldView()
: select_all_on_focus_(true) {}
FindBarView::SearchTextfieldView::~SearchTextfieldView() {} FindBarView::SearchTextfieldView::~SearchTextfieldView() {}
void FindBarView::SearchTextfieldView::RequestFocus() { bool FindBarView::SearchTextfieldView::OnMousePressed(
if (HasFocus()) const ui::MouseEvent& event) {
return; // Avoid temporarily selecting all the text on focus from a mouse press; this
views::View::RequestFocus(); // prevents flickering before setting a cursor or dragging to select text.
select_all_on_focus_ = false;
return views::Textfield::OnMousePressed(event);
}
void FindBarView::SearchTextfieldView::OnMouseReleased(
const ui::MouseEvent& event) {
views::Textfield::OnMouseReleased(event);
select_all_on_focus_ = true;
}
void FindBarView::SearchTextfieldView::OnFocus() {
views::Textfield::OnFocus();
if (select_all_on_focus_)
SelectAll(true); SelectAll(true);
} }
......
...@@ -87,7 +87,7 @@ class FindBarView : public DropdownBarView, ...@@ -87,7 +87,7 @@ class FindBarView : public DropdownBarView,
// Update the appearance for the match count label. // Update the appearance for the match count label.
void UpdateMatchCountAppearance(bool no_match); void UpdateMatchCountAppearance(bool no_match);
// Overridden from views::View. // views::View:
virtual void OnThemeChanged() OVERRIDE; virtual void OnThemeChanged() OVERRIDE;
// We use a hidden view to grab mouse clicks and bring focus to the find // We use a hidden view to grab mouse clicks and bring focus to the find
...@@ -117,9 +117,16 @@ class FindBarView : public DropdownBarView, ...@@ -117,9 +117,16 @@ class FindBarView : public DropdownBarView,
SearchTextfieldView(); SearchTextfieldView();
virtual ~SearchTextfieldView(); virtual ~SearchTextfieldView();
virtual void RequestFocus() OVERRIDE; // views::View:
virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
// views::Textfield:
virtual void OnFocus() OVERRIDE;
private: private:
bool select_all_on_focus_;
DISALLOW_COPY_AND_ASSIGN(SearchTextfieldView); DISALLOW_COPY_AND_ASSIGN(SearchTextfieldView);
}; };
......
...@@ -726,7 +726,7 @@ class VIEWS_EXPORT View : public ui::LayerDelegate, ...@@ -726,7 +726,7 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
virtual const FocusManager* GetFocusManager() const; virtual const FocusManager* GetFocusManager() const;
// Request keyboard focus. The receiving view will become the focused view. // Request keyboard focus. The receiving view will become the focused view.
virtual void RequestFocus(); void RequestFocus();
// Invoked when a view is about to be requested for focus due to the focus // Invoked when a view is about to be requested for focus due to the focus
// traversal. Reverse is this request was generated going backward // traversal. Reverse is this request was generated going backward
......
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