Chromium Code Reviews| Index: views/controls/native/native_view_host_gtk.cc |
| =================================================================== |
| --- views/controls/native/native_view_host_gtk.cc (revision 18458) |
| +++ views/controls/native/native_view_host_gtk.cc (working copy) |
| @@ -24,47 +24,24 @@ |
| NativeViewHostGtk::~NativeViewHostGtk() { |
| } |
| -// static |
| -View* NativeViewHostGtk::GetViewForNative(GtkWidget* widget) { |
| - gpointer user_data = g_object_get_data(G_OBJECT(widget), "chrome-view"); |
| - return static_cast<View*>(user_data); |
| -} |
| - |
| -// static |
| -void NativeViewHostGtk::SetViewForNative(GtkWidget* widget, View* view) { |
| - g_object_set_data(G_OBJECT(widget), "chrome-view", view); |
| -} |
| - |
| //////////////////////////////////////////////////////////////////////////////// |
| // NativeViewHostGtk, NativeViewHostWrapper implementation: |
| void NativeViewHostGtk::NativeViewAttached() { |
| DCHECK(host_->native_view()); |
| - GtkWidget* current_parent = gtk_widget_get_parent(host_->native_view()); |
| - GtkWidget* new_parent = host_->GetWidget()->GetNativeView(); |
| - // Only adjust the parent if the parent actually changed. |
| - if (current_parent != new_parent) { |
| - // First hide the new window. We don't want anything to draw (like sub-hwnd |
| - // borders), when we change the parent below. |
| - gtk_widget_hide(host_->native_view()); |
| + if (gtk_widget_get_parent(host_->native_view())) { |
|
sky
2009/06/16 16:01:45
NOTE: rather than invoking ReparentChild you could
|
| + static_cast<WidgetGtk*>(host_->GetWidget())->ReparentChild( |
| + host_->native_view()); |
| + } else { |
| + static_cast<WidgetGtk*>(host_->GetWidget())->AddChild( |
| + host_->native_view()); |
| + } |
| - if (current_parent) { |
| - gtk_container_remove(GTK_CONTAINER(current_parent), |
| - host_->native_view()); |
| - } |
| - |
| - // Adds a mapping between the GtkWidget and us. |
| - SetViewForNative(host_->native_view(), host_); |
| - |
| - if (!destroy_signal_id_) { |
| - destroy_signal_id_ = g_signal_connect(G_OBJECT(host_->native_view()), |
| - "destroy", G_CALLBACK(CallDestroy), |
| - NULL); |
| - } |
| - |
| - // Set the parent. |
| - static_cast<WidgetGtk*>(host_->GetWidget())->AddChild(host_->native_view()); |
| + if (!destroy_signal_id_) { |
| + destroy_signal_id_ = g_signal_connect(G_OBJECT(host_->native_view()), |
| + "destroy", G_CALLBACK(CallDestroy), |
| + this); |
| } |
| // Always layout though. |
| @@ -90,7 +67,7 @@ |
| return; |
| WidgetGtk* parent_widget = static_cast<WidgetGtk*>(host_->GetWidget()); |
| GtkWidget* widget_parent = gtk_widget_get_parent(host_->native_view()); |
| - GtkWidget* parent_widget_widget = parent_widget->child_widget_parent(); |
| + GtkWidget* parent_widget_widget = parent_widget->window_contents(); |
| if (widget_parent != parent_widget_widget) { |
| g_object_ref(host_->native_view()); |
| if (widget_parent) |
| @@ -113,7 +90,7 @@ |
| WidgetGtk* parent_widget = static_cast<WidgetGtk*>(host_->GetWidget()); |
| gtk_widget_hide(host_->native_view()); |
| if (parent_widget) { |
| - gtk_container_remove(GTK_CONTAINER(parent_widget->child_widget_parent()), |
| + gtk_container_remove(GTK_CONTAINER(parent_widget->window_contents()), |
| host_->native_view()); |
| } |
| } |
| @@ -174,12 +151,9 @@ |
| // NativeViewHostGtk, private: |
| // static |
| -void NativeViewHostGtk::CallDestroy(GtkObject* object) { |
| - View* view = GetViewForNative(GTK_WIDGET(object)); |
| - if (!view) |
| - return; |
| - |
| - return static_cast<NativeViewHost*>(view)->NativeViewDestroyed(); |
| +void NativeViewHostGtk::CallDestroy(GtkObject* object, |
| + NativeViewHostGtk* host) { |
| + return host->host_->NativeViewDestroyed(); |
| } |
| //////////////////////////////////////////////////////////////////////////////// |