summaryrefslogtreecommitdiffstats
path: root/webkit/tools/test_shell/webwidget_host_gtk.cc
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-11 23:51:33 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-11 23:51:33 +0000
commitb4a444265ee00ee0320edc394419832372f8dd35 (patch)
tree05a56e2cc7999a4e7f02d25db0bd4623b6698294 /webkit/tools/test_shell/webwidget_host_gtk.cc
parent6af84197d016e48e9ff2af49ec86961256aa58a0 (diff)
downloadchromium_src-b4a444265ee00ee0320edc394419832372f8dd35.zip
chromium_src-b4a444265ee00ee0320edc394419832372f8dd35.tar.gz
chromium_src-b4a444265ee00ee0320edc394419832372f8dd35.tar.bz2
Take 2: Remove WebView::SetDelegate because I'd like to avoid having a method
like this in the WebKit API. The only consumer was TestShell. It was using this method to replace its TestWebViewDelegate instance. Instead, with this change, it has a manual Reset method. To avoid duplication with the constructor, Reset uses operator=(). This required a couple changes: 1- Remove DISALLOW_COPY_AND_ASSIGN from WebViewDelegate. Anyways, that didn't make sense since you cannot 'copy' a class with pure virtual methods. 2- Change scoped_ptr members of TestWebViewDelegate to linked_ptr. The extra overhead of the linked_ptr seems warranted in this case. I also changed TestWebViewDelegate to not be reference counted since it wasn't necessary. Finally, to get this to work on Linux, I needed to revise the shutdown paths for WebWidgetHost. The problem is that the code wants to support destroying a WebWidgetHost directly by having its destructor called or indirectly by having a "destroy" signal handler notice destruction of the GtkWidget. This actually mirrors the Windows version as well, and so just like the Windows version I added a level of indirection to get from the GtkWidget to the WebWidgetHost. However, I only apply this indirection to the "destroy" signal handler. R=tony BUG=none TEST=none Review URL: http://codereview.chromium.org/165341 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23117 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/test_shell/webwidget_host_gtk.cc')
-rw-r--r--webkit/tools/test_shell/webwidget_host_gtk.cc15
1 files changed, 12 insertions, 3 deletions
diff --git a/webkit/tools/test_shell/webwidget_host_gtk.cc b/webkit/tools/test_shell/webwidget_host_gtk.cc
index 0f688b6..77981e1 100644
--- a/webkit/tools/test_shell/webwidget_host_gtk.cc
+++ b/webkit/tools/test_shell/webwidget_host_gtk.cc
@@ -33,6 +33,9 @@ using WebKit::WebWidgetClient;
namespace {
+// Used to store a backpointer to WebWidgetHost from our GtkWidget.
+const char kWebWidgetHostKey[] = "webwidgethost";
+
// In response to an invalidation, we call into WebKit to do layout. On
// Windows, WM_PAINT is a virtual message so any extra invalidates that come up
// while it's doing layout are implicitly swallowed as soon as we actually do
@@ -83,7 +86,7 @@ class WebWidgetHostGtkWidget {
g_signal_connect(widget, "expose-event",
G_CALLBACK(&HandleExpose), host);
g_signal_connect(widget, "destroy",
- G_CALLBACK(&HandleDestroy), host);
+ G_CALLBACK(&HandleDestroy), NULL);
g_signal_connect(widget, "key-press-event",
G_CALLBACK(&HandleKeyPress), host);
g_signal_connect(widget, "key-release-event",
@@ -103,6 +106,7 @@ class WebWidgetHostGtkWidget {
g_signal_connect(widget, "scroll-event",
G_CALLBACK(&HandleScroll), host);
+ g_object_set_data(G_OBJECT(widget), kWebWidgetHostKey, host);
return widget;
}
@@ -152,8 +156,12 @@ class WebWidgetHostGtkWidget {
}
// The GdkWindow was destroyed.
- static gboolean HandleDestroy(GtkWidget* widget, WebWidgetHost* host) {
- host->WindowDestroyed();
+ static gboolean HandleDestroy(GtkWidget* widget, void* unused) {
+ // The associated WebWidgetHost instance may have already been destroyed.
+ WebWidgetHost* host = static_cast<WebWidgetHost*>(
+ g_object_get_data(G_OBJECT(widget), kWebWidgetHostKey));
+ if (host)
+ host->WindowDestroyed();
return FALSE;
}
@@ -308,6 +316,7 @@ WebWidgetHost::WebWidgetHost()
}
WebWidgetHost::~WebWidgetHost() {
+ g_object_set_data(G_OBJECT(view_), kWebWidgetHostKey, NULL);
webwidget_->close();
}