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

Unified Diff: chrome/browser/ui/views/omnibox/omnibox_view_win.cc

Issue 18543012: Don't mess with omnibox selection on update when the omnibox doesn't have focus. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 6 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
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/omnibox/omnibox_view_win.cc
===================================================================
--- chrome/browser/ui/views/omnibox/omnibox_view_win.cc (revision 209724)
+++ chrome/browser/ui/views/omnibox/omnibox_view_win.cc (working copy)
@@ -646,14 +646,20 @@
// as they'd intended.
CHARRANGE sel;
GetSelection(sel);
- const bool was_reversed = (sel.cpMin > sel.cpMax);
- const bool was_select_all = (sel.cpMin != sel.cpMax) &&
- IsSelectAllForRange(sel);
+ const bool was_select_all = IsSelectAllForRange(sel);
RevertAll();
- if (was_select_all)
- SelectAll(was_reversed);
+ // Only select all when we have focus. If we don't have focus, selecting
+ // all is unnecessary since the selection will change on regaining focus,
+ // and can in fact cause artifacts, e.g. if the user is on the NTP and
+ // clicks a link to navigate, causing |was_select_all| to be vacuously true
+ // for the empty omnibox, and we then select all here, leading to the
+ // trailing portion of a long URL being scrolled into view. We could try
+ // and address cases like this, but it seems better to just not muck with
+ // things when the omnibox isn't focused to begin with.
+ if (was_select_all && model()->has_focus())
+ SelectAll(sel.cpMin > sel.cpMax);
} else if (changed_security_level) {
// Only the security style changed, nothing else. Redraw our text using it.
EmphasizeURLComponents();
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698