Chromium Code Reviews| Index: chrome/browser/ui/views/omnibox/omnibox_view_win.cc |
| diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc |
| index 9e182989d2bdd0ff756e523be7dbbf2bd9de40c3..17e57e064029254abdb7d6868973e707c75db039 100644 |
| --- a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc |
| +++ b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc |
| @@ -466,6 +466,7 @@ OmniboxViewWin::OmniboxViewWin(OmniboxEditController* controller, |
| tracking_double_click_(false), |
| double_click_time_(0), |
| can_discard_mousemove_(false), |
| + caret_height_(0), |
|
Peter Kasting
2012/12/01 01:48:31
Probably unnecessary, see below.
Mathieu
2012/12/03 02:29:04
Done.
|
| ignore_ime_messages_(false), |
| delete_at_end_pressed_(false), |
| font_(parent_view->font()), |
| @@ -606,6 +607,7 @@ void OmniboxViewWin::Update(const WebContents* tab_for_state_restoring) { |
| tab_for_state_restoring->GetUserData(&kAutocompleteEditStateKey)); |
| if (state) { |
| model()->RestoreState(state->model_state); |
| + ApplyFocusVisibility(); |
| // Restore user's selection. We do this after restoring the user_text |
| // above so we're selecting in the correct string. |
| @@ -760,6 +762,14 @@ void OmniboxViewWin::UpdatePopup() { |
| void OmniboxViewWin::SetFocus() { |
| ::SetFocus(m_hWnd); |
| + model()->set_is_focus_visible(true); |
| + ApplyFocusVisibility(); |
|
Peter Kasting
2012/12/01 01:48:31
Rather than calling this unconditionally, we shoul
Mathieu
2012/12/03 02:29:04
Good idea. Done.
|
| +} |
| + |
| +void OmniboxViewWin::SetInvisibleFocus() { |
| + ::SetFocus(m_hWnd); |
| + model()->set_is_focus_visible(false); |
| + ApplyFocusVisibility(); |
| } |
| void OmniboxViewWin::SetDropHighlightPosition(int position) { |
| @@ -844,6 +854,8 @@ void OmniboxViewWin::OnRevertTemporaryText() { |
| } |
| void OmniboxViewWin::OnBeforePossibleChange() { |
| + model()->set_is_focus_visible(true); |
| + ApplyFocusVisibility(); |
| // Record our state. |
| text_before_change_ = GetText(); |
| GetSelection(sel_before_change_); |
| @@ -1894,6 +1906,12 @@ void OmniboxViewWin::OnPaint(HDC bogus_hdc) { |
| rect.left, rect.top, SRCCOPY); |
| memory_dc.SelectBitmap(old_bitmap); |
| edit_hwnd = old_edit_hwnd; |
| + |
| + // Determine the caret height and apply the current focus visibility. This is |
| + // done in every paint event to account for window resizes that repaint the |
| + // Omnibox. |
| + caret_height_ = rect.Height() - 3; |
| + ApplyFocusVisibility(); |
| } |
| void OmniboxViewWin::OnPaste() { |
| @@ -2753,3 +2771,14 @@ int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { |
| // PosFromChar(i) might return 0 when i is greater than 1. |
| return font_.GetStringWidth(text) + GetHorizontalMargin(); |
| } |
| + |
| +void OmniboxViewWin::ApplyFocusVisibility() { |
| + if (!chrome::search::IsInstantExtendedAPIEnabled(parent_view_->profile())) |
| + return; |
| + HideCaret(); |
|
Peter Kasting
2012/12/01 01:48:31
Why are we hiding the caret unconditionally instea
Mathieu
2012/12/03 02:29:04
Ah, the Windows API... If DestroyCaret is called a
|
| + ::DestroyCaret(); |
|
Peter Kasting
2012/12/01 01:48:31
Do we have to DestroyCaret() and later CreateCaret
Mathieu
2012/12/03 02:29:04
The Hide/Show Windows API is broken in this way: w
Peter Kasting
2012/12/03 23:03:32
Interesting. You should add comments about this.
Mathieu
2012/12/03 23:23:32
I've now added comments where I felt appropriate.
|
| + if (model()->is_focus_visible()) { |
| + ::CreateCaret(m_hWnd, (HBITMAP) NULL, 1, caret_height_); |
| + ShowCaret(); |
| + } |
| +} |