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

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

Issue 11418144: [Search] Implementation of the invisible focus on Windows (Closed) Base URL: http://git.chromium.org/chromium/src.git@samarthlatest
Patch Set: Rebased to master instead of other change Created 8 years, 1 month 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.h ('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_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 76c7453d52281e7fb2c4f4c2b2c1d68aca638a8b..44f1fef67baab2f4114ae97535b137ac2e694475 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_views.cc
@@ -444,7 +444,7 @@ void OmniboxViewViews::OnBoundsChanged(const gfx::Rect& previous_bounds) {
}
////////////////////////////////////////////////////////////////////////////////
-// OmniboxViewViews, AutocopmleteEditView implementation:
+// OmniboxViewViews, AutocompleteEditView implementation:
void OmniboxViewViews::SaveStateToTab(WebContents* tab) {
DCHECK(tab);
@@ -484,6 +484,7 @@ void OmniboxViewViews::Update(const WebContents* contents) {
contents->GetUserData(&kAutocompleteEditStateKey));
if (state) {
model()->RestoreState(state->model_state);
+ ApplyFocusVisibility();
// Move the marks for the cursor and the other end of the selection to
// the previously-saved offsets (but preserve PRIMARY).
@@ -573,6 +574,16 @@ void OmniboxViewViews::UpdatePopup() {
}
void OmniboxViewViews::SetFocus() {
+ model()->set_is_focus_visible(true);
+ ApplyFocusVisibility();
+ // In views-implementation, the focus is on textfield rather than OmniboxView.
+ textfield_->RequestFocus();
+}
+
+void OmniboxViewViews::SetInvisibleFocus() {
+ DLOG(0) << "SetInvisibleFocus";
+ model()->set_is_focus_visible(false);
+ ApplyFocusVisibility();
// In views-implementation, the focus is on textfield rather than OmniboxView.
textfield_->RequestFocus();
}
@@ -603,6 +614,10 @@ void OmniboxViewViews::OnRevertTemporaryText() {
}
void OmniboxViewViews::OnBeforePossibleChange() {
+ // Since this is called when the user directly clicks on the omnibox
+ // regardless of its focus state, we reset the focus to visible.
+ model()->set_is_focus_visible(true);
+ ApplyFocusVisibility();
// Record our state.
text_before_change_ = GetText();
textfield_->GetSelectedRange(&sel_before_change_);
@@ -940,3 +955,9 @@ void OmniboxViewViews::OnPaste() {
textfield_->ReplaceSelection(text);
}
}
+
+void OmniboxViewViews::ApplyFocusVisibility() {
+ textfield_->SetCursorColor(model()->is_focus_visible() ?
+ SK_ColorBLACK : textfield_->background_color());
samarth 2012/11/28 17:43:54 Is BLACK always correct? If not, we may need to s
Mathieu 2012/11/28 21:03:06 Thanks for the comment. I've changed the logic so
+}
+
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698