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 cdfce5fc6b9f1a7eb3e29d7aae290b38491a33b1..1ee986b6e1c1dbbfab07c5374406fbfba1fffca2 100644 |
--- a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc |
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc |
@@ -760,11 +760,30 @@ void OmniboxViewWin::UpdatePopup() { |
void OmniboxViewWin::SetFocus() { |
::SetFocus(m_hWnd); |
+ model()->SetFocusVisibility(true); |
Peter Kasting
2012/12/04 02:18:30
See question in the other CL about this particular
Mathieu
2012/12/04 17:00:14
Acknowledged. Will wait for the outcome of that co
|
} |
void OmniboxViewWin::ApplyFocusVisibility() { |
- // TODO(mathp): implement for Windows. |
- NOTIMPLEMENTED(); |
+ if (!chrome::search::IsInstantExtendedAPIEnabled(parent_view_->profile())) |
Peter Kasting
2012/12/04 02:18:30
I don't think it's appropriate to check this here.
Mathieu
2012/12/04 17:00:14
I was trying to minimize the manipulation of the C
Peter Kasting
2012/12/04 21:24:43
If they don't have instant extended enabled, this
Mathieu
2012/12/04 22:30:51
Well there is an ApplyCaretVisibility() call in On
|
+ return; |
+ // We hide the caret just before destroying it, since destroying a caret that |
Peter Kasting
2012/12/04 02:18:30
I still don't see why the hide/destroy part is don
Mathieu
2012/12/04 17:00:14
Moved the DestroyCaret() call in an else, but that
Peter Kasting
2012/12/04 21:24:43
Then don't put any of it in an else, and add comme
Mathieu
2012/12/04 22:30:51
Done.
|
+ // is in the "solid" phase of its blinking will leave a solid vertical bar. |
+ HideCaret(); |
+ // We use DestroyCaret/CreateCaret instead of simply HideCaret/ShowCaret |
+ // because HideCaret is not sticky across paint events, e.g. a window resize |
+ // will effectively restore caret visibility, regardless of whether HideCaret |
+ // was called before. |
Peter Kasting
2012/12/04 02:18:30
Nit: And add "While we do catch and handle these p
Mathieu
2012/12/04 17:00:14
Done.
|
+ ::DestroyCaret(); |
+ if (model()->is_focus_visible()) { |
+ // Get caret height from omnibox height. |
+ CRect rect; |
+ GetClientRect(&rect); |
+ int caret_height = rect.Height() - 3; |
Peter Kasting
2012/12/04 02:18:30
I suspect this calculation is wrong to hardcode "c
Mathieu
2012/12/04 17:00:14
The 3 points seem odd to me too, I agree. I looked
Peter Kasting
2012/12/04 21:24:43
You don't want to refer to that rect. It's not gu
Mathieu
2012/12/04 22:30:51
Wow, it was indeed font_.GetHeight()!
I tested wi
|
+ ::CreateCaret(m_hWnd, (HBITMAP) NULL, 1, caret_height); |
+ // According to the Windows API documentation, a newly created caret needs |
+ // ShowCaret to be visible. |
+ ShowCaret(); |
+ } |
} |
void OmniboxViewWin::SetDropHighlightPosition(int position) { |
@@ -849,6 +868,7 @@ void OmniboxViewWin::OnRevertTemporaryText() { |
} |
void OmniboxViewWin::OnBeforePossibleChange() { |
+ model()->SetFocusVisibility(true); |
Peter Kasting
2012/12/04 02:18:30
Nit: Add comments about this.
Mathieu
2012/12/04 17:00:14
Done.
|
// Record our state. |
text_before_change_ = GetText(); |
GetSelection(sel_before_change_); |
@@ -1899,6 +1919,8 @@ void OmniboxViewWin::OnPaint(HDC bogus_hdc) { |
rect.left, rect.top, SRCCOPY); |
memory_dc.SelectBitmap(old_bitmap); |
edit_hwnd = old_edit_hwnd; |
+ |
+ ApplyFocusVisibility(); |
Peter Kasting
2012/12/04 02:18:30
Do you actually need to do this on every paint cal
Mathieu
2012/12/04 17:00:14
I've tested this, and it is not so. This call need
Peter Kasting
2012/12/04 21:24:43
Then you need to add commentary about this too.
T
Mathieu
2012/12/04 22:30:51
Got it. Makes sense, thanks.
|
} |
void OmniboxViewWin::OnPaste() { |