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

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

Issue 11369137: Implement {Start,Stop}CapturingKeyStrokes for Instant. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Restore caret visibility differently. 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 94a93c12ce9687e8fb8519dc54b6f1b606317b60..4d4606bd0277b5c3e7337569cff5eb72d3366df5 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
@@ -224,7 +224,8 @@ OmniboxViewViews::OmniboxViewViews(OmniboxEditController* controller,
delete_at_end_pressed_(false),
location_bar_view_(location_bar),
ime_candidate_window_open_(false),
- select_all_on_mouse_release_(false) {
+ select_all_on_mouse_release_(false),
+ visible_caret_color_(SK_ColorBLACK) {
}
OmniboxViewViews::~OmniboxViewViews() {
@@ -368,6 +369,10 @@ 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 HandleFocusIn() because when clicking while the
+ // omnibox has invisible focus does not trigger a new HandleFocusIn() call.
+ model()->SetCaretVisibility(true);
}
void OmniboxViewViews::HandleMouseDragEvent(const ui::MouseEvent& event) {
@@ -385,6 +390,8 @@ void OmniboxViewViews::HandleMouseReleaseEvent(const ui::MouseEvent& event) {
}
void OmniboxViewViews::HandleFocusIn() {
+ // Restore caret visibility whenever the user focuses back into the omnibox.
+ model()->SetCaretVisibility(true);
Peter Kasting 2012/12/04 22:55:49 Now that we've moved this to a function that uncon
samarth 2012/12/04 23:13:32 Done.
// TODO(oshima): Get control key state.
model()->OnSetFocus(false);
// Don't call controller()->OnSetFocus as this view has already
@@ -406,6 +413,7 @@ void OmniboxViewViews::HandleFocusOut() {
// Close the popup.
CloseOmniboxPopup();
// Tell the model to reset itself.
+ model()->SetCaretVisibility(true);
Peter Kasting 2012/12/04 22:55:49 Why is this necessary if we set this on HandleFocu
samarth 2012/12/04 23:13:32 We'd added it out of paranoia before, but not nece
model()->OnKillFocus();
controller()->OnKillFocus();
}
@@ -445,7 +453,7 @@ void OmniboxViewViews::OnBoundsChanged(const gfx::Rect& previous_bounds) {
}
////////////////////////////////////////////////////////////////////////////////
-// OmniboxViewViews, AutocopmleteEditView implementation:
+// OmniboxViewViews, OmniboxView implementation:
void OmniboxViewViews::SaveStateToTab(WebContents* tab) {
DCHECK(tab);
@@ -578,6 +586,15 @@ void OmniboxViewViews::SetFocus() {
textfield_->RequestFocus();
}
+void OmniboxViewViews::ApplyCaretVisibility() {
+ if (textfield_->cursor_color() != textfield_->background_color())
+ visible_caret_color_ = textfield_->cursor_color();
+ // Setting the color of the text cursor (caret) to the background color
+ // effectively hides it.
+ textfield_->SetCursorColor(model()->is_caret_visible() ?
+ visible_caret_color_ : textfield_->background_color());
+}
+
void OmniboxViewViews::OnTemporaryTextMaybeChanged(
const string16& display_text,
bool save_original_selection) {
@@ -631,6 +648,11 @@ bool OmniboxViewViews::OnAfterPossibleChange() {
(text_before_change_.length() > new_text.length()) &&
(new_sel.start() <= sel_before_change_.GetMin());
+ // Restore caret visibility whenever the user enters text or changes selection
+ // in the omnibox.
Peter Kasting 2012/12/04 22:55:49 I was hoping to put this in the model's OnAfterPos
samarth 2012/12/04 23:13:32 Done.
+ if (text_changed || selection_differs)
+ model()->SetCaretVisibility(true);
+
const bool something_changed = model()->OnAfterPossibleChange(
text_before_change_, new_text, new_sel.start(), new_sel.end(),
selection_differs, text_changed, just_deleted_text,
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views.h ('k') | chrome/browser/ui/views/omnibox/omnibox_view_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698