diff --git a/dom/plugins/base/moz.build b/dom/plugins/base/moz.build index 41bc465e9e4d..262ad152e100 100644 --- a/dom/plugins/base/moz.build +++ b/dom/plugins/base/moz.build @@ -31,6 +31,7 @@ EXPORTS += [ 'nsPluginInstanceOwner.h', 'nsPluginLogging.h', 'nsPluginNativeWindow.h', + 'nsPluginNativeWindowGtk.h', 'nsPluginPlayPreviewInfo.h', 'nsPluginsCID.h', 'nsPluginsDir.h', diff --git a/dom/plugins/base/nsPluginNativeWindowGtk.cpp b/dom/plugins/base/nsPluginNativeWindowGtk.cpp index eb3fd4bb0d0d..24f2385a4094 100644 --- a/dom/plugins/base/nsPluginNativeWindowGtk.cpp +++ b/dom/plugins/base/nsPluginNativeWindowGtk.cpp @@ -10,7 +10,7 @@ */ #include "nsDebug.h" -#include "nsPluginNativeWindow.h" +#include "nsPluginNativeWindowGtk.h" #include "nsNPAPIPlugin.h" #include "npapi.h" #include @@ -24,35 +24,6 @@ #endif #include "mozilla/X11Util.h" -class nsPluginNativeWindowGtk : public nsPluginNativeWindow { -public: - nsPluginNativeWindowGtk(); - virtual ~nsPluginNativeWindowGtk(); - - virtual nsresult CallSetWindow(nsRefPtr &aPluginInstance); -private: - void SetWindow(XID aWindow) - { - window = reinterpret_cast(static_cast(aWindow)); - } - XID GetWindow() const - { - return static_cast(reinterpret_cast(window)); - } - - NPSetWindowCallbackStruct mWsInfo; - /** - * Either a GtkSocket or a special GtkXtBin widget (derived from GtkSocket) - * that encapsulates the Xt toolkit within a Gtk Application. - */ - GtkWidget* mSocketWidget; - nsresult CreateXEmbedWindow(bool aEnableXtFocus); -#if (MOZ_WIDGET_GTK == 2) - nsresult CreateXtWindow(); -#endif - void SetAllocation(); -}; - static gboolean plug_removed_cb (GtkWidget *widget, gpointer data); static void socket_unrealize_cb (GtkWidget *widget, gpointer data); diff --git a/dom/plugins/base/nsPluginNativeWindowGtk.h b/dom/plugins/base/nsPluginNativeWindowGtk.h new file mode 100644 index 000000000000..d1bafe84284e --- /dev/null +++ b/dom/plugins/base/nsPluginNativeWindowGtk.h @@ -0,0 +1,52 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef _nsPluginNativeWindowGdk_h_ +#define _nsPluginNativeWindowGdk_h_ + +#include "nsPluginNativeWindow.h" +#include "nsNPAPIPlugin.h" +#include "npapi.h" +#include +#include +#include +#if (GTK_MAJOR_VERSION == 3) +#include +#else +#include "gtk2xtbin.h" +#endif +#include "mozilla/X11Util.h" + +class nsPluginNativeWindowGtk : public nsPluginNativeWindow { +public: + nsPluginNativeWindowGtk(); + virtual ~nsPluginNativeWindowGtk(); + + virtual nsresult CallSetWindow(nsRefPtr &aPluginInstance); + nsresult CreateXEmbedWindow(bool aEnableXtFocus); + void SetAllocation(); + + XID GetWindow() const + { + return static_cast(reinterpret_cast(window)); + } + +private: + void SetWindow(XID aWindow) + { + window = reinterpret_cast(static_cast(aWindow)); + } + + NPSetWindowCallbackStruct mWsInfo; + /** + * Either a GtkSocket or a special GtkXtBin widget (derived from GtkSocket) + * that encapsulates the Xt toolkit within a Gtk Application. + */ + GtkWidget* mSocketWidget; +#if (MOZ_WIDGET_GTK == 2) + nsresult CreateXtWindow(); +#endif +}; + +#endif diff --git a/dom/plugins/ipc/PluginWidgetParent.cpp b/dom/plugins/ipc/PluginWidgetParent.cpp index 133e922194e3..b784fb67035e 100644 --- a/dom/plugins/ipc/PluginWidgetParent.cpp +++ b/dom/plugins/ipc/PluginWidgetParent.cpp @@ -8,6 +8,12 @@ #include "nsWidgetsCID.h" #include "nsDebug.h" +#if defined(MOZ_WIDGET_GTK) +#include "nsPluginNativeWindowGtk.h" +#else +#include "nsPluginNativeWindow.h" +#endif + using namespace mozilla::widget; #define PWLOG(...) @@ -28,6 +34,9 @@ static NS_DEFINE_CID(kWidgetCID, NS_CHILD_CID); } PluginWidgetParent::PluginWidgetParent() +#if defined(MOZ_WIDGET_GTK) + : mWrapper(nullptr) +#endif { PWLOG("PluginWidgetParent::PluginWidgetParent()\n"); MOZ_COUNT_CTOR(PluginWidgetParent); @@ -60,9 +69,8 @@ PluginWidgetParent::ActorDestroy(ActorDestroyReason aWhy) // When plugins run in chrome, nsPluginNativeWindow(Plat) implements platform // specific functionality that wraps plugin widgets. With e10s we currently -// bypass this code since we can't connect up platform specific bits in the -// content process. We may need to instantiate nsPluginNativeWindow here and -// enable some of its logic. +// bypass this code on Window, and reuse a bit of it on Linux. Content still +// makes use of some of the utility functions as well. bool PluginWidgetParent::RecvCreate() @@ -73,6 +81,15 @@ PluginWidgetParent::RecvCreate() mWidget = do_CreateInstance(kWidgetCID, &rv); +#if defined(MOZ_WIDGET_GTK) + // We need this currently just for GTK in setting up a socket widget + // we can send over to content -> plugin. + PLUG_NewPluginNativeWindow((nsPluginNativeWindow**)&mWrapper); + if (!mWrapper) { + return false; + } +#endif + // This returns the top level window widget nsCOMPtr parentWidget = GetTabParent()->GetWidget(); @@ -98,6 +115,14 @@ PluginWidgetParent::RecvCreate() // chrome. RecvMove(0, 0); +#if defined(MOZ_WIDGET_GTK) + // For setup, initially GTK code expects 'window' to hold the parent. + mWrapper->window = mWidget->GetNativeData(NS_NATIVE_PLUGIN_PORT); + mWrapper->CreateXEmbedWindow(false); + mWrapper->SetAllocation(); + PWLOG("Plugin XID=%p\n", (void*)mWrapper->window); +#endif + return true; } @@ -143,7 +168,12 @@ PluginWidgetParent::RecvGetNativePluginPort(uintptr_t* value) { ENSURE_CHANNEL; PWLOG("PluginWidgetParent::RecvGetNativeData()\n"); +#if defined(MOZ_WIDGET_GTK) + *value = (uintptr_t)mWrapper->window; +#else *value = (uintptr_t)mWidget->GetNativeData(NS_NATIVE_PLUGIN_PORT); +#endif + PWLOG("PluginWidgetParent::RecvGetNativeData() %p\n", (void*)*value); return true; } @@ -153,6 +183,11 @@ PluginWidgetParent::RecvResize(const nsIntRect& aRect) ENSURE_CHANNEL; PWLOG("PluginWidgetParent::RecvResize(%d, %d, %d, %d)\n", aRect.x, aRect.y, aRect.width, aRect.height); mWidget->Resize(aRect.width, aRect.height, true); +#if defined(MOZ_WIDGET_GTK) + mWrapper->width = aRect.width; + mWrapper->height = aRect.height; + mWrapper->SetAllocation(); +#endif return true; } diff --git a/dom/plugins/ipc/PluginWidgetParent.h b/dom/plugins/ipc/PluginWidgetParent.h index 6ceac304aa52..676d02e7b941 100644 --- a/dom/plugins/ipc/PluginWidgetParent.h +++ b/dom/plugins/ipc/PluginWidgetParent.h @@ -9,6 +9,10 @@ #include "nsIWidget.h" #include "nsCOMPtr.h" +#if defined(MOZ_WIDGET_GTK) +class nsPluginNativeWindowGtk; +#endif + namespace mozilla { namespace dom { @@ -40,6 +44,9 @@ private: mozilla::dom::TabParent* GetTabParent(); // The chrome side native widget. nsCOMPtr mWidget; +#if defined(MOZ_WIDGET_GTK) + UniquePtr mWrapper; +#endif }; } // namespace plugins diff --git a/widget/PluginWidgetProxy.cpp b/widget/PluginWidgetProxy.cpp index 7f85517cfed4..0d31f491815e 100644 --- a/widget/PluginWidgetProxy.cpp +++ b/widget/PluginWidgetProxy.cpp @@ -143,6 +143,7 @@ PluginWidgetProxy::GetNativeData(uint32_t aDataType) } uintptr_t value = 0; mActor->SendGetNativePluginPort(&value); + PWLOG("PluginWidgetProxy::GetNativeData %p\n", (void*)value); return (void*)value; }