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,15 +498,29 @@ bool FindBarView::FocusForwarderView::OnMousePressed(
return true;
}
FindBarView::SearchTextfieldView::SearchTextfieldView() {}
FindBarView::SearchTextfieldView::SearchTextfieldView()
: select_all_on_focus_(true) {}
FindBarView::SearchTextfieldView::~SearchTextfieldView() {}
void FindBarView::SearchTextfieldView::RequestFocus() {
if (HasFocus())
return;
views::View::RequestFocus();
SelectAll(true);
bool FindBarView::SearchTextfieldView::OnMousePressed(
const ui::MouseEvent& event) {
// Avoid temporarily selecting all the text on focus from a mouse press; this
// 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);
}
FindBarHost* FindBarView::find_bar_host() const {
......
......@@ -87,7 +87,7 @@ class FindBarView : public DropdownBarView,
// Update the appearance for the match count label.
void UpdateMatchCountAppearance(bool no_match);
// Overridden from views::View.
// views::View:
virtual void OnThemeChanged() OVERRIDE;
// We use a hidden view to grab mouse clicks and bring focus to the find
......@@ -117,9 +117,16 @@ class FindBarView : public DropdownBarView,
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:
bool select_all_on_focus_;
DISALLOW_COPY_AND_ASSIGN(SearchTextfieldView);
};
......
......@@ -726,7 +726,7 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
virtual const FocusManager* GetFocusManager() const;
// 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
// 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