From 4198875dbfac06ef6b4d3578bb856344c1ac02cd Mon Sep 17 00:00:00 2001 From: "msw@chromium.org" Date: Thu, 6 Feb 2014 03:33:29 +0000 Subject: [PATCH] Views Omnibox: tolerate minor click-to-select-all dragging. Add protected Textfield::last_click_location() helper. Use this in assessing when to cancel Omnibox select-all. BUG=341100 TEST=Minor mouse dragging won't stop the Omnibox from selecting-all on a focusing click. R=pkasting@chromium.org Review URL: https://codereview.chromium.org/149123006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@249253 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/ui/views/omnibox/omnibox_view_views.cc | 3 ++- ui/views/controls/textfield/textfield.h | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc index dc8c957f5d0c..90c929014859 100644 --- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc +++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc @@ -239,7 +239,8 @@ bool OmniboxViewViews::OnMousePressed(const ui::MouseEvent& event) { } bool OmniboxViewViews::OnMouseDragged(const ui::MouseEvent& event) { - select_all_on_mouse_release_ = false; + if (ExceededDragThreshold(event.location() - last_click_location())) + select_all_on_mouse_release_ = false; return views::Textfield::OnMouseDragged(event); } diff --git a/ui/views/controls/textfield/textfield.h b/ui/views/controls/textfield/textfield.h index ba9d53b9a330..57a044fff1f9 100644 --- a/ui/views/controls/textfield/textfield.h +++ b/ui/views/controls/textfield/textfield.h @@ -280,8 +280,10 @@ class VIEWS_EXPORT Textfield : public View, virtual void OnCandidateWindowHidden() OVERRIDE; protected: - // Returns the TextfieldModel's text/cursor/selection rendering model. - gfx::RenderText* GetRenderText() const; + // Returns the TextfieldModel's text/cursor/selection rendering model. + gfx::RenderText* GetRenderText() const; + + gfx::Point last_click_location() const { return last_click_location_; } // Get the text from the selection clipboard. virtual base::string16 GetSelectionClipboardText() const; -- 2.11.4.GIT