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

Side by Side Diff: chrome/browser/views/autocomplete/autocomplete_popup_win.cc

Issue 342112: Try to add more sanity checking to help track down a crash.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "chrome/browser/views/autocomplete/autocomplete_popup_win.h" 5 #include "chrome/browser/views/autocomplete/autocomplete_popup_win.h"
6 6
7 #include "app/gfx/insets.h" 7 #include "app/gfx/insets.h"
8 #include "app/win_util.h" 8 #include "app/win_util.h"
9 #include "chrome/browser/autocomplete/autocomplete_edit_view_win.h" 9 #include "chrome/browser/autocomplete/autocomplete_edit_view_win.h"
10 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" 10 #include "chrome/browser/autocomplete/autocomplete_popup_model.h"
11 #include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h" 11 #include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h"
12 12
13 //////////////////////////////////////////////////////////////////////////////// 13 ////////////////////////////////////////////////////////////////////////////////
14 // AutocompletePopupWin, public: 14 // AutocompletePopupWin, public:
15 15
16 AutocompletePopupWin::AutocompletePopupWin( 16 AutocompletePopupWin::AutocompletePopupWin(
17 AutocompletePopupContentsView* contents) 17 AutocompletePopupContentsView* contents)
18 : contents_(contents) { 18 : contents_(contents),
19 is_open_(false) {
19 set_delete_on_destroy(false); 20 set_delete_on_destroy(false);
20 set_window_style(WS_POPUP | WS_CLIPCHILDREN); 21 set_window_style(WS_POPUP | WS_CLIPCHILDREN);
21 set_window_ex_style(WS_EX_TOOLWINDOW | WS_EX_LAYERED); 22 set_window_ex_style(WS_EX_TOOLWINDOW | WS_EX_LAYERED);
22 } 23 }
23 24
24 AutocompletePopupWin::~AutocompletePopupWin() { 25 AutocompletePopupWin::~AutocompletePopupWin() {
25 } 26 }
26 27
28 void AutocompletePopupWin::Show() {
29 // Move the popup to the place appropriate for the window's current position -
30 // it may have been moved since it was last shown.
31 SetBounds(contents_->GetPopupBounds());
32 WidgetWin::Show();
33 is_open_ = true;
34 }
35
36 void AutocompletePopupWin::Hide() {
37 WidgetWin::Hide();
38 is_open_ = false;
39 }
40
27 void AutocompletePopupWin::Init(AutocompleteEditView* edit_view, 41 void AutocompletePopupWin::Init(AutocompleteEditView* edit_view,
28 views::View* contents) { 42 views::View* contents) {
29 // Create the popup 43 // Create the popup
30 WidgetWin::Init(GetAncestor(edit_view->GetNativeView(), GA_ROOT), 44 WidgetWin::Init(GetAncestor(edit_view->GetNativeView(), GA_ROOT),
31 contents_->GetPopupBounds()); 45 contents_->GetPopupBounds());
32 // The contents is owned by the LocationBarView. 46 // The contents is owned by the LocationBarView.
33 contents_->SetParentOwned(false); 47 contents_->SetParentOwned(false);
34 SetContentsView(contents_); 48 SetContentsView(contents_);
35 49
36 // When an IME is attached to the rich-edit control, retrieve its window 50 // When an IME is attached to the rich-edit control, retrieve its window
37 // handle and show this popup window under the IME windows. 51 // handle and show this popup window under the IME windows.
38 // Otherwise, show this popup window under top-most windows. 52 // Otherwise, show this popup window under top-most windows.
39 // TODO(hbono): http://b/1111369 if we exclude this popup window from the 53 // TODO(hbono): http://b/1111369 if we exclude this popup window from the
40 // display area of IME windows, this workaround becomes unnecessary. 54 // display area of IME windows, this workaround becomes unnecessary.
41 HWND ime_window = ImmGetDefaultIMEWnd(edit_view->GetNativeView()); 55 HWND ime_window = ImmGetDefaultIMEWnd(edit_view->GetNativeView());
42 SetWindowPos(ime_window ? ime_window : HWND_NOTOPMOST, 0, 0, 0, 0, 56 SetWindowPos(ime_window ? ime_window : HWND_NOTOPMOST, 0, 0, 0, 0,
43 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_SHOWWINDOW); 57 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_SHOWWINDOW);
44 } 58 is_open_ = true;
45
46 void AutocompletePopupWin::Show() {
47 // Move the popup to the place appropriate for the window's current position -
48 // it may have been moved since it was last shown.
49 SetBounds(contents_->GetPopupBounds());
50 if (!IsVisible())
51 WidgetWin::Show();
52 } 59 }
53 60
54 bool AutocompletePopupWin::IsOpen() const { 61 bool AutocompletePopupWin::IsOpen() const {
55 return IsCreated() && IsVisible(); 62 const bool is_open = IsCreated() && IsVisible();
63 CHECK(is_open == is_open_);
64 return is_open;
56 } 65 }
57 66
58 bool AutocompletePopupWin::IsCreated() const { 67 bool AutocompletePopupWin::IsCreated() const {
59 return !!IsWindow(); 68 return !!IsWindow();
60 } 69 }
61 70
62 //////////////////////////////////////////////////////////////////////////////// 71 ////////////////////////////////////////////////////////////////////////////////
63 // AutocompletePopupWin, WidgetWin overrides: 72 // AutocompletePopupWin, WidgetWin overrides:
64 73
65 LRESULT AutocompletePopupWin::OnMouseActivate(HWND window, UINT hit_test, 74 LRESULT AutocompletePopupWin::OnMouseActivate(HWND window, UINT hit_test,
66 UINT mouse_message) { 75 UINT mouse_message) {
67 return MA_NOACTIVATE; 76 return MA_NOACTIVATE;
68 } 77 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698