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

Unified Diff: views/controls/native/native_view_host_gtk.cc

Issue 126107: Creates a new TabContentsViewGtk for views based FE. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 months 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 side-by-side diff with in-line comments
Download patch
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();
}
////////////////////////////////////////////////////////////////////////////////

Powered by Google App Engine
This is Rietveld 408576698