diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-17 04:23:00 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-17 04:23:00 +0000 |
commit | 4c9471c16ba43fb40017e9f5fae8231799e86ccb (patch) | |
tree | 86d1f5ec140af9841b92108299208ca3e7fdfed7 /views/widget/widget_gtk.h | |
parent | 061efec5fa1af222d72b887feb5788260cb5248f (diff) | |
download | chromium_src-4c9471c16ba43fb40017e9f5fae8231799e86ccb.zip chromium_src-4c9471c16ba43fb40017e9f5fae8231799e86ccb.tar.gz chromium_src-4c9471c16ba43fb40017e9f5fae8231799e86ccb.tar.bz2 |
Fix build bustage by removing another dependency on browser/gtk by creating a new TabContentsViewGtk specifically for views. This subclasses WidgetGtk similar to how TabContentsViewWin subclasses WidgetWin.
There was a bug in NativeViewHostGtk - reparenting needs to be done atomically using gtk_widget_reparent since GtkWidgets are refcounted and when removed from a container are released, causing a crash when a TabContents is reparented.
The code now compiles thanks to a stubbed BlockedPopupContainer, however there is one remaining issue - the browser window no longer paints and the app instantly hangs. However this is better than the current state so I figured I'd send the code review.
Review URL: http://codereview.chromium.org/126107
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18588 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget/widget_gtk.h')
-rw-r--r-- | views/widget/widget_gtk.h | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/views/widget/widget_gtk.h b/views/widget/widget_gtk.h index 2442f74..b5dd6a0 100644 --- a/views/widget/widget_gtk.h +++ b/views/widget/widget_gtk.h @@ -56,15 +56,25 @@ class WidgetGtk : public Widget, public MessageLoopForUI::Observer { delete_on_destroy_ = delete_on_destroy; } + // Adds and removes the specified widget as a child of this widget's contents. + // These methods make sure to add the widget to the window's contents + // container if this widget is a window. void AddChild(GtkWidget* child); void RemoveChild(GtkWidget* child); + // A safe way to reparent a child widget to this widget. Calls + // gtk_widget_reparent which handles refcounting to avoid destroying the + // widget when removing it from its old parent. + void ReparentChild(GtkWidget* child); + // Positions a child GtkWidget at the specified location and bounds. void PositionChild(GtkWidget* child, int x, int y, int w, int h); - // Parent GtkWidget all children are added to. This is not necessarily - // the same as returned by GetNativeView. - GtkWidget* child_widget_parent() const { return child_widget_parent_; } + // Parent GtkWidget all children are added to. When this WidgetGtk corresponds + // to a top level window, this is the GtkFixed within the GtkWindow, not the + // GtkWindow itself. For child widgets, this is the same GtkFixed as + // |widget_|. + GtkWidget* window_contents() const { return window_contents_; } virtual void SetContentsView(View* view); @@ -174,7 +184,10 @@ class WidgetGtk : public Widget, public MessageLoopForUI::Observer { static Window* GetWindowImpl(GtkWidget* widget); // Creates the GtkWidget. - void CreateGtkWidget(); + void CreateGtkWidget(GtkWidget* parent); + + // Attaches the widget contents to the window's widget. + void AttachGtkWidgetToWindow(); // Invoked from create widget to enable the various bits needed for a // transparent background. This is only invoked if MakeTransparent has been @@ -186,10 +199,15 @@ class WidgetGtk : public Widget, public MessageLoopForUI::Observer { const Type type_; // Our native views. If we're a window/popup, then widget_ is the window and - // child_widget_parent_ is a GtkFixed. If we're not a window/popup, then - // widget_ and child_widget_parent_ are a GtkFixed. + // window_contents_ is a GtkFixed. If we're not a window/popup, then widget_ + // and window_contents_ point to the same GtkFixed. GtkWidget* widget_; - GtkWidget* child_widget_parent_; + GtkWidget* window_contents_; + + // Child GtkWidgets created with no parent need to be parented to a valid top + // level window otherwise Gtk throws a fit. |null_parent_| is an invisible + // popup that such GtkWidgets are parented to. + static GtkWidget* null_parent_; // The root of the View hierarchy attached to this window. scoped_ptr<RootView> root_view_; |