Index: chrome/browser/ui/views/omnibox/omnibox_view_win.cc |
=================================================================== |
--- chrome/browser/ui/views/omnibox/omnibox_view_win.cc (revision 210454) |
+++ 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(); |