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

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

Issue 361020: Fix checkfailure on Linux Views build by actually opening the popup when it's... (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_gtk.h" 5 #include "chrome/browser/views/autocomplete/autocomplete_popup_gtk.h"
6 6
7 #include "app/gfx/insets.h" 7 #include "app/gfx/insets.h"
8 #include "chrome/browser/autocomplete/autocomplete_edit_view.h" 8 #include "chrome/browser/autocomplete/autocomplete_edit_view.h"
9 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" 9 #include "chrome/browser/autocomplete/autocomplete_popup_model.h"
10 #include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h" 10 #include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h"
11 #include "chrome/common/gtk_util.h" 11 #include "chrome/common/gtk_util.h"
12 12
13 //////////////////////////////////////////////////////////////////////////////// 13 ////////////////////////////////////////////////////////////////////////////////
14 // AutocompletePopupGtk, public: 14 // AutocompletePopupGtk, public:
15 15
16 AutocompletePopupGtk::AutocompletePopupGtk( 16 AutocompletePopupGtk::AutocompletePopupGtk(
17 AutocompletePopupContentsView* contents) 17 AutocompletePopupContentsView* contents)
18 : WidgetGtk(WidgetGtk::TYPE_POPUP), 18 : WidgetGtk(WidgetGtk::TYPE_POPUP),
19 contents_(contents), 19 contents_(contents),
20 edit_view_(NULL) { 20 edit_view_(NULL),
21 is_open_(false) {
21 set_delete_on_destroy(false); 22 set_delete_on_destroy(false);
22 } 23 }
23 24
24 AutocompletePopupGtk::~AutocompletePopupGtk() { 25 AutocompletePopupGtk::~AutocompletePopupGtk() {
25 } 26 }
26 27
28 void AutocompletePopupGtk::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 if (!IsVisible()) {
33 WidgetGtk::Show();
34 StackWindow();
35 }
36 is_open_ = true;
37 }
38
39 void AutocompletePopupGtk::Hide() {
40 WidgetGtk::Hide();
41 is_open_ = false;
42 }
43
27 void AutocompletePopupGtk::Init(AutocompleteEditView* edit_view, 44 void AutocompletePopupGtk::Init(AutocompleteEditView* edit_view,
28 views::View* contents) { 45 views::View* contents) {
29 MakeTransparent(); 46 MakeTransparent();
30 // Create the popup 47 // Create the popup
31 WidgetGtk::Init(gtk_widget_get_parent(edit_view->GetNativeView()), 48 WidgetGtk::Init(gtk_widget_get_parent(edit_view->GetNativeView()),
32 contents_->GetPopupBounds()); 49 contents_->GetPopupBounds());
33 // The contents is owned by the LocationBarView. 50 // The contents is owned by the LocationBarView.
34 contents_->SetParentOwned(false); 51 contents_->SetParentOwned(false);
35 SetContentsView(contents_); 52 SetContentsView(contents_);
36 53
37 edit_view_ = edit_view; 54 edit_view_ = edit_view;
38 }
39 55
40 void AutocompletePopupGtk::Show() { 56 Show();
41 // Move the popup to the place appropriate for the window's current position -
42 // it may have been moved since it was last shown.
43 SetBounds(contents_->GetPopupBounds());
44 if (!IsVisible()) {
45 WidgetGtk::Show();
46 StackWindow();
47 }
48 } 57 }
49 58
50 bool AutocompletePopupGtk::IsOpen() const { 59 bool AutocompletePopupGtk::IsOpen() const {
51 return IsCreated() && IsVisible(); 60 const bool is_open = IsCreated() && IsVisible();
61 CHECK(is_open == is_open_);
62 return is_open;
52 } 63 }
53 64
54 bool AutocompletePopupGtk::IsCreated() const { 65 bool AutocompletePopupGtk::IsCreated() const {
55 return GTK_IS_WIDGET(GetNativeView()); 66 return GTK_IS_WIDGET(GetNativeView());
56 } 67 }
57 68
58 void AutocompletePopupGtk::StackWindow() { 69 void AutocompletePopupGtk::StackWindow() {
59 GtkWidget* toplevel = gtk_widget_get_toplevel(edit_view_->GetNativeView()); 70 GtkWidget* toplevel = gtk_widget_get_toplevel(edit_view_->GetNativeView());
60 DCHECK(GTK_WIDGET_TOPLEVEL(toplevel)); 71 DCHECK(GTK_WIDGET_TOPLEVEL(toplevel));
61 gtk_util::StackPopupWindow(GetNativeView(), toplevel); 72 gtk_util::StackPopupWindow(GetNativeView(), toplevel);
62 } 73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698