summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/plugins/gtk_plugin_container.cc42
-rw-r--r--webkit/glue/plugins/gtk_plugin_container.h8
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_gtk.cc2
3 files changed, 44 insertions, 8 deletions
diff --git a/webkit/glue/plugins/gtk_plugin_container.cc b/webkit/glue/plugins/gtk_plugin_container.cc
index 64b3dc3..18bdb30 100644
--- a/webkit/glue/plugins/gtk_plugin_container.cc
+++ b/webkit/glue/plugins/gtk_plugin_container.cc
@@ -6,10 +6,13 @@
#include <gtk/gtk.h>
+#include "base/basictypes.h"
+
namespace {
-// This class has no members/methods, and is only used for namespacing purposes.
-class GtkPluginContainer {
+// NOTE: This class doesn't have constructors/destructors, it is created
+// through GLib's object management.
+class GtkPluginContainer : public GtkSocket {
public:
static GtkWidget* CreateNewWidget() {
GtkWidget* container = GTK_WIDGET(g_object_new(GetType(), NULL));
@@ -18,6 +21,18 @@ class GtkPluginContainer {
return container;
}
+ // Sets the requested size of the widget.
+ void set_size(int width, int height) {
+ width_ = width;
+ height_ = height;
+ }
+
+ // Casts a widget into a GtkPluginContainer, after checking the type.
+ template <class T>
+ static GtkPluginContainer *CastChecked(T *instance) {
+ return G_TYPE_CHECK_INSTANCE_CAST(instance, GetType(), GtkPluginContainer);
+ }
+
private:
// Create and register our custom container type with GTK.
static GType GetType() {
@@ -29,7 +44,7 @@ class GtkPluginContainer {
static_cast<GClassInitFunc>(&ClassInit),
NULL, NULL,
sizeof(GtkSocket), // We are identical to a GtkSocket.
- 0, NULL,
+ 0, &InstanceInit,
};
type = g_type_register_static(GTK_TYPE_SOCKET,
"GtkPluginContainer",
@@ -45,11 +60,18 @@ class GtkPluginContainer {
widget_class->size_request = &HandleSizeRequest;
}
+ // Implementation of the instance initializer (constructor).
+ static void InstanceInit(GTypeInstance *instance, gpointer klass) {
+ GtkPluginContainer *container = CastChecked(instance);
+ container->set_size(0, 0);
+ }
+
// Report our allocation size during size requisition.
static void HandleSizeRequest(GtkWidget* widget,
GtkRequisition* requisition) {
- requisition->width = widget->allocation.width;
- requisition->height = widget->allocation.height;
+ GtkPluginContainer *container = CastChecked(widget);
+ requisition->width = container->width_;
+ requisition->height = container->height_;
}
static gboolean OnPlugRemoved(GtkSocket* socket) {
@@ -57,6 +79,10 @@ class GtkPluginContainer {
// We return TRUE to indicate that we don't want to destroy our side.
return TRUE;
}
+
+ int width_;
+ int height_;
+ DISALLOW_IMPLICIT_CONSTRUCTORS(GtkPluginContainer);
};
} // anonymous namespace
@@ -65,3 +91,9 @@ class GtkPluginContainer {
GtkWidget* gtk_plugin_container_new() {
return GtkPluginContainer::CreateNewWidget();
}
+
+void gtk_plugin_container_set_size(GtkWidget *widget, int width, int height) {
+ GtkPluginContainer::CastChecked(widget)->set_size(width, height);
+ // Signal the parent that the size request has changed.
+ gtk_widget_queue_resize_no_redraw(widget);
+}
diff --git a/webkit/glue/plugins/gtk_plugin_container.h b/webkit/glue/plugins/gtk_plugin_container.h
index bde5db6..eed6b94 100644
--- a/webkit/glue/plugins/gtk_plugin_container.h
+++ b/webkit/glue/plugins/gtk_plugin_container.h
@@ -10,9 +10,8 @@
// directly, so we need a subclass of GtkSocket that sidesteps the
// size_request handler.
//
-// The custom size_request handler just reports the allocation, so it's
-// the owner's responsibility to call gtk_widget_size_allocate() with the
-// proper size.
+// The custom size_request handler just reports the size set by
+// gtk_plugin_container_set_size.
typedef struct _GtkWidget GtkWidget;
@@ -21,4 +20,7 @@ typedef struct _GtkWidget GtkWidget;
// This is a GtkSocket subclass; see its documentation for available methods.
GtkWidget* gtk_plugin_container_new();
+// Sets the size of the GtkPluginContainer.
+void gtk_plugin_container_set_size(GtkWidget *widget, int width, int height);
+
#endif // WEBKIT_GLUE_PLUGINS_GTK_PLUGIN_CONTAINER_H_
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
index 75390bf..f583876 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
+++ b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
@@ -306,6 +306,8 @@ bool WebPluginDelegateImpl::WindowedReposition(
// allows the window moves/scrolling/clipping to be synchronized with the page
// and other windows.
if (window_rect.size() != window_rect_.size()) {
+ gtk_plugin_container_set_size(windowed_handle_, window_rect.width(),
+ window_rect.height());
GtkAllocation allocation = { 0, 0,
window_rect.width(), window_rect.height() };
gtk_widget_size_allocate(windowed_handle_, &allocation);