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

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

Issue 11413217: Instant API: tell page whether the browser is capturing key strokes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@focus
Patch Set: Fixed comments, mouse handling logic. Created 8 years 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
Index: chrome/browser/ui/views/omnibox/omnibox_view_views.cc
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
index bda1e48da0c8e4ddd594b08a7ef90de6b80b935c..923d8560d51a1ea4c58ab138b33b3f823fa2fa0d 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
@@ -368,11 +368,13 @@ bool OmniboxViewViews::HandleKeyReleaseEvent(const ui::KeyEvent& event) {
void OmniboxViewViews::HandleMousePressEvent(const ui::MouseEvent& event) {
select_all_on_mouse_release_ =
(event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton()) &&
- !textfield_->HasFocus();
- // Restore caret visibility whenever the user clicks in the the omnibox. This
- // is not always covered by OnSetFocus() because when clicking while the
- // omnibox has invisible focus does not trigger a new OnSetFocus() call.
- model()->SetCaretVisibility(true);
+ (!textfield_->HasFocus() || !model()->is_caret_visible());
+ // Restore caret visibility whenever the user clicks in the omnibox in a way
+ // that would give it focus. We must handle this case separately here because
+ // if the omnibox currently has invisible focus, the mouse event won't trigger
+ // either SetFocus() or OmniboxEditModel::OnSetFocus().
+ if (select_all_on_mouse_release_)
+ model()->SetCaretVisibility(true);
}
void OmniboxViewViews::HandleMouseDragEvent(const ui::MouseEvent& event) {
@@ -579,14 +581,14 @@ void OmniboxViewViews::UpdatePopup() {
}
void OmniboxViewViews::SetFocus() {
- // Restore caret visibility if focused explicitly. We need to do this here
- // because if we already have invisible focus, the RequestFocus() call below
- // will short-circuit, preventing us from reaching
- // OmniboxEditModel::OnSetFocus(), which handles restoring visibility when we
- // didn't previously have focus.
- model()->SetCaretVisibility(true);
// In views-implementation, the focus is on textfield rather than OmniboxView.
textfield_->RequestFocus();
+ // Restore caret visibility if focus is explicitly requested. This is
+ // necessary because if we already have invisible focus, the RequestFocus()
+ // call above will short-circuit, preventing us from reaching
+ // OmniboxEditModel::OnSetFocus(), which handles restoring visibility when the
+ // omnibox regains focus after losing focus.
+ model()->SetCaretVisibility(true);
}
void OmniboxViewViews::ApplyCaretVisibility() {

Powered by Google App Engine
This is Rietveld 408576698