summaryrefslogtreecommitdiffstats
path: root/webkit/glue/plugins
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-26 01:13:45 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-26 01:13:45 +0000
commit83d0e2ba3c024eda4291c505300217e7ad8d7ba0 (patch)
tree709637ef3a06d70fed44ecc9ad5892ef14e1da59 /webkit/glue/plugins
parentb6757a4e8d6140ca93381e283bf55664f87d424a (diff)
downloadchromium_src-83d0e2ba3c024eda4291c505300217e7ad8d7ba0.zip
chromium_src-83d0e2ba3c024eda4291c505300217e7ad8d7ba0.tar.gz
chromium_src-83d0e2ba3c024eda4291c505300217e7ad8d7ba0.tar.bz2
Revert all of my patches from today.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19328 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/plugins')
-rw-r--r--webkit/glue/plugins/gtk_plugin_container.cc16
-rw-r--r--webkit/glue/plugins/plugin_host.cc2
-rw-r--r--webkit/glue/plugins/plugin_instance.h8
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.cc4
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl.h6
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_gtk.cc55
-rw-r--r--webkit/glue/plugins/webplugin_delegate_impl_mac.mm7
7 files changed, 67 insertions, 31 deletions
diff --git a/webkit/glue/plugins/gtk_plugin_container.cc b/webkit/glue/plugins/gtk_plugin_container.cc
index c487fa0..18bdb30 100644
--- a/webkit/glue/plugins/gtk_plugin_container.cc
+++ b/webkit/glue/plugins/gtk_plugin_container.cc
@@ -14,6 +14,13 @@ namespace {
// through GLib's object management.
class GtkPluginContainer : public GtkSocket {
public:
+ static GtkWidget* CreateNewWidget() {
+ GtkWidget* container = GTK_WIDGET(g_object_new(GetType(), NULL));
+ g_signal_connect(GTK_SOCKET(container), "plug-removed",
+ G_CALLBACK(OnPlugRemoved), NULL);
+ return container;
+ }
+
// Sets the requested size of the widget.
void set_size(int width, int height) {
width_ = width;
@@ -26,6 +33,7 @@ class GtkPluginContainer : public GtkSocket {
return G_TYPE_CHECK_INSTANCE_CAST(instance, GetType(), GtkPluginContainer);
}
+ private:
// Create and register our custom container type with GTK.
static GType GetType() {
static GType type = 0; // We only want to register our type once.
@@ -66,6 +74,12 @@ class GtkPluginContainer : public GtkSocket {
requisition->height = container->height_;
}
+ static gboolean OnPlugRemoved(GtkSocket* socket) {
+ // This is called when the other side of the socket goes away.
+ // We return TRUE to indicate that we don't want to destroy our side.
+ return TRUE;
+ }
+
int width_;
int height_;
DISALLOW_IMPLICIT_CONSTRUCTORS(GtkPluginContainer);
@@ -75,7 +89,7 @@ class GtkPluginContainer : public GtkSocket {
// Create a new instance of our GTK widget object.
GtkWidget* gtk_plugin_container_new() {
- return GTK_WIDGET(g_object_new(GtkPluginContainer::GetType(), NULL));
+ return GtkPluginContainer::CreateNewWidget();
}
void gtk_plugin_container_set_size(GtkWidget *widget, int width, int height) {
diff --git a/webkit/glue/plugins/plugin_host.cc b/webkit/glue/plugins/plugin_host.cc
index 2e1c233..815b415 100644
--- a/webkit/glue/plugins/plugin_host.cc
+++ b/webkit/glue/plugins/plugin_host.cc
@@ -711,7 +711,7 @@ NPError NPN_GetValue(NPP id, NPNVariable variable, void *value) {
{
#if defined(OS_WIN) || defined(OS_LINUX)
scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id);
- gfx::PluginWindowHandle handle = plugin->window_handle();
+ gfx::NativeView handle = plugin->window_handle();
*((void**)value) = (void*)handle;
rv = NPERR_NO_ERROR;
#else
diff --git a/webkit/glue/plugins/plugin_instance.h b/webkit/glue/plugins/plugin_instance.h
index ba8824f8..e73d49f 100644
--- a/webkit/glue/plugins/plugin_instance.h
+++ b/webkit/glue/plugins/plugin_instance.h
@@ -70,10 +70,8 @@ class PluginInstance : public base::RefCountedThreadSafe<PluginInstance> {
NPP npp() { return npp_; }
// Get/Set for the instance's window handle.
- gfx::PluginWindowHandle window_handle() const { return window_handle_; }
- void set_window_handle(gfx::PluginWindowHandle value) {
- window_handle_ = value;
- }
+ gfx::NativeView window_handle() { return window_handle_; }
+ void set_window_handle(gfx::NativeView value) { window_handle_ = value; }
// Get/Set whether this instance is in Windowless mode.
// Default is false.
@@ -225,7 +223,7 @@ class PluginInstance : public base::RefCountedThreadSafe<PluginInstance> {
scoped_refptr<PluginHost> host_;
NPPluginFuncs* npp_functions_;
std::vector<scoped_refptr<PluginStream> > open_streams_;
- gfx::PluginWindowHandle window_handle_;
+ gfx::NativeView window_handle_;
bool windowless_;
bool transparent_;
WebPlugin* webplugin_;
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.cc b/webkit/glue/plugins/webplugin_delegate_impl.cc
index d197fb11..5cf00a5 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.cc
+++ b/webkit/glue/plugins/webplugin_delegate_impl.cc
@@ -71,7 +71,7 @@ base::LazyInstance<iat_patch::IATPatchFunction> g_iat_patch_set_cursor(
WebPluginDelegate* WebPluginDelegate::Create(
const FilePath& filename,
const std::string& mime_type,
- gfx::PluginWindowHandle containing_view) {
+ gfx::NativeView containing_view) {
scoped_refptr<NPAPI::PluginLib> plugin =
NPAPI::PluginLib::CreatePluginLib(filename);
if (plugin.get() == NULL)
@@ -140,7 +140,7 @@ LRESULT CALLBACK WebPluginDelegateImpl::HandleEventMessageFilterHook(
}
WebPluginDelegateImpl::WebPluginDelegateImpl(
- gfx::PluginWindowHandle containing_view,
+ gfx::NativeView containing_view,
NPAPI::PluginInstance *instance)
: parent_(containing_view),
instance_(instance),
diff --git a/webkit/glue/plugins/webplugin_delegate_impl.h b/webkit/glue/plugins/webplugin_delegate_impl.h
index d3cbdbf..61a41cd 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl.h
+++ b/webkit/glue/plugins/webplugin_delegate_impl.h
@@ -91,7 +91,7 @@ class WebPluginDelegateImpl : public WebPluginDelegate {
private:
friend class DeleteTask<WebPluginDelegateImpl>;
- WebPluginDelegateImpl(gfx::PluginWindowHandle containing_view,
+ WebPluginDelegateImpl(gfx::NativeView containing_view,
NPAPI::PluginInstance *instance);
~WebPluginDelegateImpl();
@@ -154,7 +154,7 @@ class WebPluginDelegateImpl : public WebPluginDelegate {
void DestroyInstance();
// used for windowed plugins
- gfx::PluginWindowHandle windowed_handle_;
+ gfx::NativeView windowed_handle_;
bool windowed_did_set_window_;
#if defined(OS_WIN)
gfx::Rect windowed_last_pos_;
@@ -190,7 +190,7 @@ class WebPluginDelegateImpl : public WebPluginDelegate {
void EnsurePixmapAtLeastSize(int width, int height);
#endif
- gfx::PluginWindowHandle parent_;
+ gfx::NativeView parent_;
NPWindow window_;
#if defined(OS_MACOSX)
NP_CGContext cg_context_;
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
index 49670fc..f583876 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
+++ b/webkit/glue/plugins/webplugin_delegate_impl_gtk.cc
@@ -38,7 +38,7 @@ using WebKit::WebMouseEvent;
WebPluginDelegate* WebPluginDelegate::Create(
const FilePath& filename,
const std::string& mime_type,
- gfx::PluginWindowHandle containing_view) {
+ gfx::NativeView containing_view) {
scoped_refptr<NPAPI::PluginLib> plugin =
NPAPI::PluginLib::CreatePluginLib(filename);
if (plugin.get() == NULL)
@@ -54,7 +54,7 @@ WebPluginDelegate* WebPluginDelegate::Create(
}
WebPluginDelegateImpl::WebPluginDelegateImpl(
- gfx::PluginWindowHandle containing_view,
+ gfx::NativeView containing_view,
NPAPI::PluginInstance *instance)
:
windowed_handle_(0),
@@ -263,40 +263,63 @@ bool WebPluginDelegateImpl::WindowedCreatePlugin() {
return false;
}
- window_.window = reinterpret_cast<void*>(parent_);
- // The remainder of the code expects windowed_handle_ to exist for
- // windowed mode, despite not actually ever reaching through
- // windowed_handle_. So let's set it to the one window handle we
- // actually have available.
- windowed_handle_ = parent_;
+ windowed_handle_ = gtk_plugin_container_new();
+ gtk_container_add(GTK_CONTAINER(parent_), windowed_handle_);
+ gtk_widget_show(windowed_handle_);
+ gtk_widget_realize(windowed_handle_);
+
+ window_.window = GINT_TO_POINTER(
+ gtk_socket_get_id(GTK_SOCKET(windowed_handle_)));
if (!window_.ws_info)
window_.ws_info = new NPSetWindowCallbackStruct;
NPSetWindowCallbackStruct* extra =
static_cast<NPSetWindowCallbackStruct*>(window_.ws_info);
- extra->display = GDK_DISPLAY();
- extra->visual = DefaultVisual(GDK_DISPLAY(), 0);
- extra->depth = DefaultDepth(GDK_DISPLAY(), 0);
- extra->colormap = DefaultColormap(GDK_DISPLAY(), 0);
+ extra->display = GDK_WINDOW_XDISPLAY(windowed_handle_->window);
+ GdkVisual* visual = gdk_drawable_get_visual(windowed_handle_->window);
+ extra->visual = GDK_VISUAL_XVISUAL(visual);
+ extra->depth = visual->depth;
+ extra->colormap = GDK_COLORMAP_XCOLORMAP(gdk_drawable_get_colormap(windowed_handle_->window));
return true;
}
void WebPluginDelegateImpl::WindowedDestroyWindow() {
- // We have no window to destroy; see comment in WindowedCreatePlugin
- // where windowed_handle_ is set.
- windowed_handle_ = 0;
+ if (windowed_handle_ != NULL) {
+ gtk_widget_destroy(windowed_handle_);
+ windowed_handle_ = NULL;
+ }
}
bool WebPluginDelegateImpl::WindowedReposition(
const gfx::Rect& window_rect,
const gfx::Rect& clip_rect) {
- if (window_rect == window_rect_ && clip_rect == clip_rect_)
+ if (!windowed_handle_) {
+ NOTREACHED();
+ return false;
+ }
+
+ if (window_rect_ == window_rect && clip_rect_ == clip_rect)
return false;
+ // We only set the plugin's size here. Its position is moved elsewhere, which
+ // 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);
+ }
+
window_rect_ = window_rect;
clip_rect_ = clip_rect;
+ // TODO(deanm): Is this really needed?
+ // Ensure that the entire window gets repainted.
+ gtk_widget_queue_draw(windowed_handle_);
+
return true;
}
diff --git a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
index 54bf43b..452410d 100644
--- a/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
+++ b/webkit/glue/plugins/webplugin_delegate_impl_mac.mm
@@ -58,7 +58,7 @@ WebPluginDelegateImpl* g_current_plugin_instance = NULL;
WebPluginDelegate* WebPluginDelegate::Create(
const FilePath& filename,
const std::string& mime_type,
- gfx::NativeView containing_view) {
+ gfx::PluginWindowHandle containing_view) {
scoped_refptr<NPAPI::PluginLib> plugin =
NPAPI::PluginLib::CreatePluginLib(filename);
if (plugin.get() == NULL)
@@ -73,12 +73,13 @@ WebPluginDelegate* WebPluginDelegate::Create(
return new WebPluginDelegateImpl(containing_view, instance.get());
}
-bool WebPluginDelegateImpl::IsPluginDelegateWindow(gfx::NativeWindow window) {
+bool WebPluginDelegateImpl::IsPluginDelegateWindow(
+ gfx::PluginNativeView window) {
return false;
}
bool WebPluginDelegateImpl::GetPluginNameFromWindow(
- gfx::NativeWindow window, std::wstring *plugin_name) {
+ gfx::PluginNativeView window, std::wstring *plugin_name) {
if (NULL == plugin_name) {
return false;
}