diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-06 21:06:39 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-06 21:06:39 +0000 |
commit | da373225b0783166bca66c3534f7bde71eae0c51 (patch) | |
tree | bd744dbfae4f427cf4d9a42996e4ef07ea1da9c1 /webkit/tools/test_shell | |
parent | f98c1541c7c5671ed1de13ffc802d7e0bba276e9 (diff) | |
download | chromium_src-da373225b0783166bca66c3534f7bde71eae0c51.zip chromium_src-da373225b0783166bca66c3534f7bde71eae0c51.tar.gz chromium_src-da373225b0783166bca66c3534f7bde71eae0c51.tar.bz2 |
Revert "linux: OOP windowed plugins"
This reverts r19983. Test failures on Mac and Windows.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19988 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/test_shell')
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate_gtk.cc | 60 | ||||
-rw-r--r-- | webkit/tools/test_shell/webview_host.h | 28 | ||||
-rw-r--r-- | webkit/tools/test_shell/webview_host_gtk.cc | 37 |
3 files changed, 109 insertions, 16 deletions
diff --git a/webkit/tools/test_shell/test_webview_delegate_gtk.cc b/webkit/tools/test_shell/test_webview_delegate_gtk.cc index a05eefd..10ba40f 100644 --- a/webkit/tools/test_shell/test_webview_delegate_gtk.cc +++ b/webkit/tools/test_shell/test_webview_delegate_gtk.cc @@ -23,7 +23,7 @@ #include "webkit/glue/webplugin.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webview.h" -#include "webkit/glue/plugins/gtk_plugin_container_manager.h" +#include "webkit/glue/plugins/gtk_plugin_container.h" #include "webkit/glue/plugins/plugin_list.h" #include "webkit/glue/window_open_disposition.h" #include "webkit/glue/plugins/webplugin_delegate_impl.h" @@ -230,9 +230,61 @@ void TestWebViewDelegate::GetRootWindowResizerRect(WebWidget* webwidget, void TestWebViewDelegate::DidMove(WebWidget* webwidget, const WebPluginGeometry& move) { WebWidgetHost* host = GetHostForWidget(webwidget); - GtkPluginContainerManager* plugin_container_manager = - static_cast<WebViewHost*>(host)->plugin_container_manager(); - plugin_container_manager->MovePluginContainer(move); + + // The "window" on WebPluginGeometry is actually the XEmbed parent + // X window id. + GtkWidget* widget = ((WebViewHost*)host)->MapIDToWidget(move.window); + // If we don't know about this plugin (maybe we're shutting down the + // window?), ignore the message. + if (!widget) + return; + DCHECK(!GTK_WIDGET_NO_WINDOW(widget)); + DCHECK(GTK_WIDGET_REALIZED(widget)); + + if (!move.visible) { + gtk_widget_hide(widget); + return; + } else { + gtk_widget_show(widget); + } + + // Update the clipping region on the GdkWindow. + GdkRectangle clip_rect = move.clip_rect.ToGdkRectangle(); + GdkRegion* clip_region = gdk_region_rectangle(&clip_rect); + gfx::SubtractRectanglesFromRegion(clip_region, move.cutout_rects); + gdk_window_shape_combine_region(widget->window, clip_region, 0, 0); + gdk_region_destroy(clip_region); + + // Update the window position. Resizing is handled by WebPluginDelegate. + // TODO(deanm): Verify that we only need to move and not resize. + // TODO(evanm): we should cache the last shape and position and skip all + // of this business in the common case where nothing has changed. + int current_x, current_y; + + // Until the above TODO is resolved, we can grab the last position + // off of the GtkFixed with a bit of hackery. + GValue value = {0}; + g_value_init(&value, G_TYPE_INT); + gtk_container_child_get_property(GTK_CONTAINER(host->view_handle()), widget, + "x", &value); + current_x = g_value_get_int(&value); + gtk_container_child_get_property(GTK_CONTAINER(host->view_handle()), widget, + "y", &value); + current_y = g_value_get_int(&value); + g_value_unset(&value); + + if (move.window_rect.x() != current_x || move.window_rect.y() != current_y) { + // Calling gtk_fixed_move unnecessarily is a no-no, as it causes the parent + // window to repaint! + gtk_fixed_move(GTK_FIXED(host->view_handle()), + widget, + move.window_rect.x(), + move.window_rect.y()); + } + + gtk_plugin_container_set_size(widget, + move.window_rect.width(), + move.window_rect.height()); } void TestWebViewDelegate::RunModal(WebWidget* webwidget) { diff --git a/webkit/tools/test_shell/webview_host.h b/webkit/tools/test_shell/webview_host.h index 962633b..9c7c489 100644 --- a/webkit/tools/test_shell/webview_host.h +++ b/webkit/tools/test_shell/webview_host.h @@ -11,14 +11,15 @@ #include "base/gfx/native_widget_types.h" #include "base/gfx/rect.h" #include "webkit/tools/test_shell/webwidget_host.h" -#if defined(OS_LINUX) -#include "webkit/glue/plugins/gtk_plugin_container_manager.h" -#endif struct WebPreferences; class WebView; class WebViewDelegate; +#if defined(OS_LINUX) +typedef struct _GtkSocket GtkSocket; +#endif + // This class is a simple NativeView-based host for a WebView class WebViewHost : public WebWidgetHost { public: @@ -36,12 +37,13 @@ class WebViewHost : public WebWidgetHost { // embedders to use. GdkNativeWindow CreatePluginContainer(); + // Map a GdkNativeWindow returned by CreatePluginContainer() back to + // the GtkWidget hosting it. Used when we get a message back from the + // renderer indicating a plugin needs to move. + GtkWidget* MapIDToWidget(GdkNativeWindow id); + // Called when a plugin has been destroyed. Lets us clean up our side. void OnPluginWindowDestroyed(GdkNativeWindow id); - - GtkPluginContainerManager* plugin_container_manager() { - return &plugin_container_manager_; - } #endif protected: @@ -52,8 +54,16 @@ class WebViewHost : public WebWidgetHost { #endif #if defined(OS_LINUX) - // Helper class that creates and moves plugin containers. - GtkPluginContainerManager plugin_container_manager_; + // A map used for MapIDToWidget() above. + typedef std::map<GdkNativeWindow, GtkWidget*> NativeWindowToWidgetMap; + NativeWindowToWidgetMap native_window_to_widget_map_; + + // Callback for when one of our plugins goes away. + static gboolean OnPlugRemovedThunk(GtkSocket* socket, + WebViewHost* web_view_host) { + return web_view_host->OnPlugRemoved(socket); + } + gboolean OnPlugRemoved(GtkSocket* socket); #endif }; diff --git a/webkit/tools/test_shell/webview_host_gtk.cc b/webkit/tools/test_shell/webview_host_gtk.cc index 53c42d9..e089052 100644 --- a/webkit/tools/test_shell/webview_host_gtk.cc +++ b/webkit/tools/test_shell/webview_host_gtk.cc @@ -20,7 +20,6 @@ WebViewHost* WebViewHost::Create(GtkWidget* parent_view, WebViewHost* host = new WebViewHost(); host->view_ = WebWidgetHost::CreateWidget(parent_view, host); - host->plugin_container_manager_.set_host_widget(host->view_); g_object_set_data(G_OBJECT(host->view_), "webwidgethost", host); host->webwidget_ = WebView::Create(delegate, prefs); @@ -34,9 +33,41 @@ WebView* WebViewHost::webview() const { } GdkNativeWindow WebViewHost::CreatePluginContainer() { - return plugin_container_manager_.CreatePluginContainer(); + GtkWidget* plugin_container = gtk_plugin_container_new(); + g_signal_connect(G_OBJECT(plugin_container), "plug-removed", + G_CALLBACK(OnPlugRemovedThunk), this); + gtk_container_add(GTK_CONTAINER(view_handle()), plugin_container); + gtk_widget_show(plugin_container); + gtk_widget_realize(plugin_container); + + GdkNativeWindow id = gtk_socket_get_id(GTK_SOCKET(plugin_container)); + + native_window_to_widget_map_.insert(std::make_pair(id, plugin_container)); + + return id; +} + +GtkWidget* WebViewHost::MapIDToWidget(GdkNativeWindow id) { + NativeWindowToWidgetMap::const_iterator i = + native_window_to_widget_map_.find(id); + if (i != native_window_to_widget_map_.end()) + return i->second; + + LOG(ERROR) << "Request for widget host for unknown window id " << id; + + return NULL; } void WebViewHost::OnPluginWindowDestroyed(GdkNativeWindow id) { - plugin_container_manager_.DestroyPluginContainer(id); + GtkWidget* plugin_container = MapIDToWidget(id); + if (!plugin_container) + return; + + native_window_to_widget_map_.erase(id); + gtk_widget_destroy(plugin_container); } + +gboolean WebViewHost::OnPlugRemoved(GtkSocket* socket) { + return TRUE; // Don't destroy our widget; we manage it ourselves. +} + |