diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index b2456b8afcac..e14fbd9ef4e2 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -76,8 +76,6 @@ #include "ContentParent.h" #include "TabParent.h" -#include "mozilla/plugins/PPluginWidgetParent.h" -#include "../plugins/ipc/PluginWidgetParent.h" #include "mozilla/AsyncEventDispatcher.h" #include "mozilla/BasePrincipal.h" #include "mozilla/GuardObjects.h" @@ -102,6 +100,11 @@ #include "nsPrincipal.h" +#ifdef XP_WIN +#include "mozilla/plugins/PPluginWidgetParent.h" +#include "../plugins/ipc/PluginWidgetParent.h" +#endif + #ifdef MOZ_XUL #include "nsXULPopupManager.h" #endif @@ -1440,6 +1443,7 @@ nsFrameLoader::SwapWithOtherRemoteLoader(nsFrameLoader* aOther, aOther->mRemoteBrowser->SetBrowserDOMWindow(browserDOMWindow); mRemoteBrowser->SetBrowserDOMWindow(otherBrowserDOMWindow); +#ifdef XP_WIN // Native plugin windows used by this remote content need to be reparented. if (nsPIDOMWindowOuter* newWin = ourDoc->GetWindow()) { RefPtr newParent = nsGlobalWindow::Cast(newWin)->GetMainWidget(); @@ -1449,6 +1453,7 @@ nsFrameLoader::SwapWithOtherRemoteLoader(nsFrameLoader* aOther, static_cast(iter.Get()->GetKey())->SetParent(newParent); } } +#endif // XP_WIN MaybeUpdatePrimaryTabParent(eTabParentRemoved); aOther->MaybeUpdatePrimaryTabParent(eTabParentRemoved); diff --git a/dom/ipc/PPluginWidget.ipdl b/dom/ipc/PPluginWidget.ipdl index d96ea4ed87a5..94f9bab2bc54 100644 --- a/dom/ipc/PPluginWidget.ipdl +++ b/dom/ipc/PPluginWidget.ipdl @@ -1,4 +1,4 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public + /* 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/. */ @@ -13,7 +13,7 @@ namespace plugins { /** * PPluginWidget - a nsIWidget'ish protocol for windowed plugins in e10s. - * On windows and linux we create native widgets in chrome which we then manage + * On windows we create native widgets in chrome which we then manage * from content. On the content side there's PluginWidgetProxy which * implements nsIWidget. We hand this around layout and plugins code. Anything * not dealt with via PluginWidgetProxy falls through to PuppetWidget. Native diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 457a1fe97006..213b7d8c0cef 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -20,7 +20,6 @@ #include "mozilla/ClearOnShutdown.h" #include "mozilla/EventListenerManager.h" #include "mozilla/dom/indexedDB/PIndexedDBPermissionRequestChild.h" -#include "mozilla/plugins/PluginWidgetChild.h" #include "mozilla/IMEStateManager.h" #include "mozilla/ipc/DocumentRendererChild.h" #include "mozilla/ipc/URIUtils.h" @@ -39,6 +38,7 @@ #include "mozilla/layers/WebRenderLayerManager.h" #include "mozilla/layout/RenderFrameChild.h" #include "mozilla/layout/RenderFrameParent.h" +#include "mozilla/plugins/PPluginWidgetChild.h" #include "mozilla/LookAndFeel.h" #include "mozilla/MouseEvents.h" #include "mozilla/Move.h" @@ -123,6 +123,10 @@ #include "nsISupportsPrimitives.h" #include "mozilla/Telemetry.h" +#ifdef XP_WIN +#include "mozilla/plugins/PluginWidgetChild.h" +#endif + #ifdef NS_PRINTING #include "nsIPrintSession.h" #include "nsIPrintSettings.h" @@ -3144,16 +3148,22 @@ TabChild::TakeAwaitingLargeAlloc() mozilla::plugins::PPluginWidgetChild* TabChild::AllocPPluginWidgetChild() { - return new mozilla::plugins::PluginWidgetChild(); +#ifdef XP_WIN + return new mozilla::plugins::PluginWidgetChild(); +#else + MOZ_ASSERT_UNREACHABLE(); + return nullptr; +#endif } bool TabChild::DeallocPPluginWidgetChild(mozilla::plugins::PPluginWidgetChild* aActor) { - delete aActor; - return true; + delete aActor; + return true; } +#ifdef XP_WIN nsresult TabChild::CreatePluginWidget(nsIWidget* aParent, nsIWidget** aOut) { @@ -3184,6 +3194,7 @@ TabChild::CreatePluginWidget(nsIWidget* aParent, nsIWidget** aOut) pluginWidget.forget(aOut); return rv; } +#endif // XP_WIN ScreenIntSize TabChild::GetInnerSize() diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index f4e0ff2fd25c..28998e363729 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -62,10 +62,6 @@ namespace widget { struct AutoCacheNativeKeyCommands; } // namespace widget -namespace plugins { -class PluginWidgetChild; -} // namespace plugins - namespace dom { class TabChild; @@ -609,7 +605,9 @@ public: bool DeallocPPluginWidgetChild(PPluginWidgetChild* aActor) override; +#ifdef XP_WIN nsresult CreatePluginWidget(nsIWidget* aParent, nsIWidget** aOut); +#endif LayoutDeviceIntPoint GetClientOffset() const { return mClientOffset; } LayoutDeviceIntPoint GetChromeDisplacement() const { return mChromeDisp; }; diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 9745b4cd15f7..1de6a840e62d 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -20,7 +20,6 @@ #include "mozilla/dom/Event.h" #include "mozilla/dom/indexedDB/ActorsParent.h" #include "mozilla/dom/ipc/BlobParent.h" -#include "mozilla/plugins/PluginWidgetParent.h" #include "mozilla/EventStateManager.h" #include "mozilla/gfx/2D.h" #include "mozilla/gfx/DataSurfaceHelpers.h" @@ -32,6 +31,7 @@ #include "mozilla/layers/AsyncDragMetrics.h" #include "mozilla/layers/InputAPZContext.h" #include "mozilla/layout/RenderFrameParent.h" +#include "mozilla/plugins/PPluginWidgetParent.h" #include "mozilla/LookAndFeel.h" #include "mozilla/MouseEvents.h" #include "mozilla/net/NeckoChild.h" @@ -100,6 +100,10 @@ #include "nsIGroupedSHistory.h" #include "PartialSHistory.h" +#ifdef XP_WIN +#include "mozilla/plugins/PluginWidgetParent.h" +#endif + #if defined(XP_WIN) && defined(ACCESSIBILITY) #include "mozilla/a11y/AccessibleWrap.h" #include "mozilla/a11y/nsWinUtils.h" @@ -386,6 +390,7 @@ TabParent::DestroyInternal() frame->Destroy(); } +#ifdef XP_WIN // Let all PluginWidgets know we are tearing down. Prevents // these objects from sending async events after the child side // is shut down. @@ -395,6 +400,7 @@ TabParent::DestroyInternal() static_cast( iter.Get()->GetKey())->ParentDestroy(); } +#endif } void @@ -2876,7 +2882,12 @@ TabParent::RecvRemotePaintIsReady() mozilla::plugins::PPluginWidgetParent* TabParent::AllocPPluginWidgetParent() { +#ifdef XP_WIN return new mozilla::plugins::PluginWidgetParent(); +#else + MOZ_ASSERT_UNREACHABLE(); + return nullptr; +#endif } bool diff --git a/dom/plugins/base/moz.build b/dom/plugins/base/moz.build index f43f75f790bd..7a16ffddfbad 100644 --- a/dom/plugins/base/moz.build +++ b/dom/plugins/base/moz.build @@ -31,7 +31,6 @@ EXPORTS += [ 'nsPluginInstanceOwner.h', 'nsPluginLogging.h', 'nsPluginNativeWindow.h', - 'nsPluginNativeWindowGtk.h', 'nsPluginsCID.h', 'nsPluginsDir.h', 'nsPluginTags.h', @@ -70,17 +69,9 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': ] else: UNIFIED_SOURCES += [ + 'nsPluginNativeWindow.cpp', 'nsPluginsDirUnix.cpp', ] - if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']: - # This file cannot be built in unified mode because of name clashes in X11 headers. - SOURCES += [ - 'nsPluginNativeWindowGtk.cpp', - ] - else: - UNIFIED_SOURCES += [ - 'nsPluginNativeWindow.cpp', - ] LOCAL_INCLUDES += [ '/dom/base', diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index 1e3118e284be..0d8b6b0d7805 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -3344,8 +3344,6 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void) { NS_ENSURE_TRUE(mPluginWindow, NS_ERROR_NULL_POINTER); - nsresult rv = NS_ERROR_FAILURE; - // Can't call this twice! if (mWidget) { NS_WARNING("Trying to create a plugin widget twice!"); @@ -3355,15 +3353,21 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void) bool windowless = false; mInstance->IsWindowless(&windowless); if (!windowless) { +#ifndef XP_WIN + // Only Windows supports windowed mode! + MOZ_ASSERT_UNREACHABLE(); + return NS_ERROR_FAILURE; +#else // Try to get a parent widget, on some platforms widget creation will fail without // a parent. + nsresult rv = NS_ERROR_FAILURE; + nsCOMPtr parentWidget; nsIDocument *doc = nullptr; nsCOMPtr content = do_QueryReferent(mContent); if (content) { doc = content->OwnerDoc(); parentWidget = nsContentUtils::WidgetForDocument(doc); -#ifndef XP_MACOSX // If we're running in the content process, we need a remote widget created in chrome. if (XRE_IsContentProcess()) { if (nsCOMPtr window = doc->GetWindow()) { @@ -3379,16 +3383,13 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void) } } } -#endif // XP_MACOSX } -#ifndef XP_MACOSX // A failure here is terminal since we can't fall back on the non-e10s code // path below. if (!mWidget && XRE_IsContentProcess()) { return NS_ERROR_UNEXPECTED; } -#endif // XP_MACOSX if (!mWidget) { // native (single process) @@ -3410,6 +3411,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void) mWidget->EnableDragDrop(true); mWidget->Show(false); mWidget->Enable(false); +#endif // XP_WIN } if (mPluginFrame) { diff --git a/dom/plugins/base/nsPluginNativeWindow.cpp b/dom/plugins/base/nsPluginNativeWindow.cpp index f9baf5b813ee..2fe312052257 100644 --- a/dom/plugins/base/nsPluginNativeWindow.cpp +++ b/dom/plugins/base/nsPluginNativeWindow.cpp @@ -12,42 +12,54 @@ #include "nsDebug.h" #include "nsPluginNativeWindow.h" -class nsPluginNativeWindowPLATFORM : public nsPluginNativeWindow { -public: - nsPluginNativeWindowPLATFORM(); - virtual ~nsPluginNativeWindowPLATFORM(); +class nsPluginNativeWindowImpl : public nsPluginNativeWindow +{ +public: + nsPluginNativeWindowImpl(); + virtual ~nsPluginNativeWindowImpl(); + +#ifdef MOZ_WIDGET_GTK + NPSetWindowCallbackStruct mWsInfo; +#endif }; -nsPluginNativeWindowPLATFORM::nsPluginNativeWindowPLATFORM() : nsPluginNativeWindow() +nsPluginNativeWindowImpl::nsPluginNativeWindowImpl() : nsPluginNativeWindow() { // initialize the struct fields - window = nullptr; - x = 0; - y = 0; - width = 0; - height = 0; + window = nullptr; + x = 0; + y = 0; + width = 0; + height = 0; memset(&clipRect, 0, sizeof(clipRect)); -#if defined(XP_UNIX) && !defined(XP_MACOSX) + type = NPWindowTypeWindow; + +#ifdef MOZ_WIDGET_GTK + ws_info = &mWsInfo; + mWsInfo.type = 0; + mWsInfo.display = nullptr; + mWsInfo.visual = nullptr; + mWsInfo.colormap = 0; + mWsInfo.depth = 0; +#elif defined(XP_UNIX) && !defined(XP_MACOSX) ws_info = nullptr; #endif - type = NPWindowTypeWindow; } -nsPluginNativeWindowPLATFORM::~nsPluginNativeWindowPLATFORM() +nsPluginNativeWindowImpl::~nsPluginNativeWindowImpl() { } nsresult PLUG_NewPluginNativeWindow(nsPluginNativeWindow ** aPluginNativeWindow) { NS_ENSURE_ARG_POINTER(aPluginNativeWindow); - *aPluginNativeWindow = new nsPluginNativeWindowPLATFORM(); + *aPluginNativeWindow = new nsPluginNativeWindowImpl(); return NS_OK; } nsresult PLUG_DeletePluginNativeWindow(nsPluginNativeWindow * aPluginNativeWindow) { NS_ENSURE_ARG_POINTER(aPluginNativeWindow); - nsPluginNativeWindowPLATFORM *p = (nsPluginNativeWindowPLATFORM *)aPluginNativeWindow; - delete p; + delete static_cast(aPluginNativeWindow); return NS_OK; } diff --git a/dom/plugins/base/nsPluginNativeWindowGtk.cpp b/dom/plugins/base/nsPluginNativeWindowGtk.cpp deleted file mode 100644 index bfb9510e07c0..000000000000 --- a/dom/plugins/base/nsPluginNativeWindowGtk.cpp +++ /dev/null @@ -1,356 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim:expandtab:shiftwidth=2:tabstop=2: -*/ -/* 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/. */ - -/** - * This file is the Gtk2 implementation of plugin native window. - */ - -#include "nsDebug.h" -#include "nsPluginNativeWindowGtk.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" - -static void plug_added_cb(GtkWidget *widget, gpointer data); -static gboolean plug_removed_cb (GtkWidget *widget, gpointer data); -static void socket_unrealize_cb (GtkWidget *widget, gpointer data); - -nsPluginNativeWindowGtk::nsPluginNativeWindowGtk() : nsPluginNativeWindow() -{ - // initialize the struct fields - window = nullptr; - x = 0; - y = 0; - width = 0; - height = 0; - memset(&clipRect, 0, sizeof(clipRect)); - ws_info = &mWsInfo; - type = NPWindowTypeWindow; - mSocketWidget = 0; - mWsInfo.type = 0; - mWsInfo.display = nullptr; - mWsInfo.visual = nullptr; - mWsInfo.colormap = 0; - mWsInfo.depth = 0; -} - -nsPluginNativeWindowGtk::~nsPluginNativeWindowGtk() -{ - if(mSocketWidget) { - gtk_widget_destroy(mSocketWidget); - } -} - -nsresult PLUG_NewPluginNativeWindow(nsPluginNativeWindow ** aPluginNativeWindow) -{ - NS_ENSURE_ARG_POINTER(aPluginNativeWindow); - *aPluginNativeWindow = new nsPluginNativeWindowGtk(); - return NS_OK; -} - -nsresult PLUG_DeletePluginNativeWindow(nsPluginNativeWindow * aPluginNativeWindow) -{ - NS_ENSURE_ARG_POINTER(aPluginNativeWindow); - nsPluginNativeWindowGtk *p = (nsPluginNativeWindowGtk *)aPluginNativeWindow; - delete p; - return NS_OK; -} - -nsresult nsPluginNativeWindowGtk::CallSetWindow(RefPtr &aPluginInstance) -{ - if (aPluginInstance) { - if (type == NPWindowTypeWindow && - XRE_IsContentProcess()) { - // In this case, most of the initialization code here has already happened - // in the chrome process. The window we have in content is the XID of the - // socket widget we need to hand to plugins. - SetWindow((XID)window); - } else if (type == NPWindowTypeWindow) { - if (!mSocketWidget) { - nsresult rv; - - // The documentation on the types for many variables in NP(N|P)_GetValue - // is vague. Often boolean values are NPBool (1 byte), but - // https://developer.mozilla.org/en/XEmbed_Extension_for_Mozilla_Plugins - // treats NPPVpluginNeedsXEmbed as PRBool (int), and - // on x86/32-bit, flash stores to this using |movl 0x1,&needsXEmbed|. - // thus we can't use NPBool for needsXEmbed, or the three bytes above - // it on the stack would get clobbered. so protect with the larger bool. - int needsXEmbed = 0; - rv = aPluginInstance->GetValueFromPlugin(NPPVpluginNeedsXEmbed, &needsXEmbed); - // If the call returned an error code make sure we still use our default value. - if (NS_FAILED(rv)) { - needsXEmbed = 0; - } -#ifdef DEBUG - printf("nsPluginNativeWindowGtk: NPPVpluginNeedsXEmbed=%d\n", needsXEmbed); -#endif - - bool isOOPPlugin = aPluginInstance->GetPlugin()->GetLibrary()->IsOOP(); - if (needsXEmbed || isOOPPlugin) { - bool enableXtFocus = !needsXEmbed; - rv = CreateXEmbedWindow(enableXtFocus); - } - else { -#if (MOZ_WIDGET_GTK == 2) - rv = CreateXtWindow(); -#else - return NS_ERROR_FAILURE; -#endif - } - - if (NS_FAILED(rv)) { - return NS_ERROR_FAILURE; - } - } - - if (!mSocketWidget) { - return NS_ERROR_FAILURE; - } - - // Make sure to resize and re-place the window if required. - SetAllocation(); - // Need to reset "window" each time as nsPluginFrame::DidReflow sets it - // to the ancestor window. -#if (MOZ_WIDGET_GTK == 2) - if (GTK_IS_XTBIN(mSocketWidget)) { - // Point the NPWindow structures window to the actual X window - SetWindow(GTK_XTBIN(mSocketWidget)->xtwindow); - } - else { // XEmbed or OOP&Xt - SetWindow(gtk_socket_get_id(GTK_SOCKET(mSocketWidget))); - } -#else - // Gtk3 supports only OOP by GtkSocket - SetWindow(gtk_socket_get_id(GTK_SOCKET(mSocketWidget))); -#endif - -#ifdef DEBUG - printf("nsPluginNativeWindowGtk: call SetWindow with xid=%p\n", (void *)window); -#endif - } // NPWindowTypeWindow - aPluginInstance->SetWindow(this); - } else if (mPluginInstance) { - mPluginInstance->SetWindow(nullptr); - } - - SetPluginInstance(aPluginInstance); - return NS_OK; -} - -nsresult nsPluginNativeWindowGtk::CreateXEmbedWindow(bool aEnableXtFocus) { - NS_ASSERTION(!mSocketWidget,"Already created a socket widget!"); - GdkDisplay *display = gdk_display_get_default(); - GdkWindow *parent_win = gdk_x11_window_lookup_for_display(display, GetWindow()); - mSocketWidget = gtk_socket_new(); - - //attach the socket to the container widget - gtk_widget_set_parent_window(mSocketWidget, parent_win); - - // enable/disable focus event handlers, - // see plugin_window_filter_func() for details - g_object_set_data(G_OBJECT(mSocketWidget), "enable-xt-focus", (void *)aEnableXtFocus); - - g_signal_connect(mSocketWidget, "plug_added", - G_CALLBACK(plug_added_cb), nullptr); - - // Make sure to handle the plug_removed signal. If we don't the - // socket will automatically be destroyed when the plug is - // removed, which means we're destroying it more than once. - // SYNTAX ERROR. - g_signal_connect(mSocketWidget, "plug_removed", - G_CALLBACK(plug_removed_cb), nullptr); - - g_signal_connect(mSocketWidget, "unrealize", - G_CALLBACK(socket_unrealize_cb), nullptr); - - g_signal_connect(mSocketWidget, "destroy", - G_CALLBACK(gtk_widget_destroyed), &mSocketWidget); - - gpointer user_data = nullptr; - gdk_window_get_user_data(parent_win, &user_data); - - GtkContainer *container = GTK_CONTAINER(user_data); - gtk_container_add(container, mSocketWidget); - gtk_widget_realize(mSocketWidget); - - // The GtkSocket has a visible window, but the plugin's XEmbed plug will - // cover this window. Normally GtkSockets let the X server paint their - // background and this would happen immediately (before the plug is - // created). Setting the background to None prevents the server from - // painting this window, avoiding flicker. - // TODO GTK3 -#if (MOZ_WIDGET_GTK == 2) - gdk_window_set_back_pixmap(gtk_widget_get_window(mSocketWidget), nullptr, FALSE); -#endif - - // Resize before we show - SetAllocation(); - - gtk_widget_show(mSocketWidget); - - gdk_flush(); - SetWindow(gtk_socket_get_id(GTK_SOCKET(mSocketWidget))); - - // Fill out the ws_info structure. - // (The windowless case is done in nsPluginFrame.cpp.) - GdkWindow *gdkWindow = gdk_x11_window_lookup_for_display(display, GetWindow()); - if(!gdkWindow) - return NS_ERROR_FAILURE; - - mWsInfo.display = GDK_WINDOW_XDISPLAY(gdkWindow); -#if (MOZ_WIDGET_GTK == 2) - mWsInfo.colormap = GDK_COLORMAP_XCOLORMAP(gdk_drawable_get_colormap(gdkWindow)); - GdkVisual* gdkVisual = gdk_drawable_get_visual(gdkWindow); - mWsInfo.depth = gdkVisual->depth; -#else - mWsInfo.colormap = X11None; - GdkVisual* gdkVisual = gdk_window_get_visual(gdkWindow); - mWsInfo.depth = gdk_visual_get_depth(gdkVisual); -#endif - mWsInfo.visual = GDK_VISUAL_XVISUAL(gdkVisual); - - return NS_OK; -} - -void nsPluginNativeWindowGtk::SetAllocation() { - if (!mSocketWidget) - return; - - GtkAllocation new_allocation; - new_allocation.x = 0; - new_allocation.y = 0; - new_allocation.width = width; - new_allocation.height = height; - gtk_widget_size_allocate(mSocketWidget, &new_allocation); -} - -#if (MOZ_WIDGET_GTK == 2) -nsresult nsPluginNativeWindowGtk::CreateXtWindow() { - NS_ASSERTION(!mSocketWidget,"Already created a socket widget!"); - -#ifdef DEBUG - printf("About to create new xtbin of %i X %i from %p...\n", - width, height, (void*)window); -#endif - GdkDisplay *display = gdk_display_get_default(); - GdkWindow *gdkWindow = gdk_x11_window_lookup_for_display(display, GetWindow()); - mSocketWidget = gtk_xtbin_new(gdkWindow, 0); - // Check to see if creating the xtbin failed for some reason. - // if it did, we can't go any further. - if (!mSocketWidget) - return NS_ERROR_FAILURE; - - g_signal_connect(mSocketWidget, "destroy", - G_CALLBACK(gtk_widget_destroyed), &mSocketWidget); - - gtk_widget_set_size_request(mSocketWidget, width, height); - -#ifdef DEBUG - printf("About to show xtbin(%p)...\n", (void*)mSocketWidget); fflush(nullptr); -#endif - gtk_widget_show(mSocketWidget); -#ifdef DEBUG - printf("completed gtk_widget_show(%p)\n", (void*)mSocketWidget); fflush(nullptr); -#endif - - // Fill out the ws_info structure. - GtkXtBin* xtbin = GTK_XTBIN(mSocketWidget); - // The xtbin has its own Display structure. - mWsInfo.display = xtbin->xtdisplay; - mWsInfo.colormap = xtbin->xtclient.xtcolormap; - mWsInfo.visual = xtbin->xtclient.xtvisual; - mWsInfo.depth = xtbin->xtclient.xtdepth; - // Leave mWsInfo.type = 0 - Who knows what this is meant to be? - - XFlush(mWsInfo.display); - - return NS_OK; -} -#endif - -static void -plug_window_finalize_cb(gpointer socket, GObject* plug_window) -{ - g_object_unref(socket); -} - -static void -plug_added_cb(GtkWidget *socket, gpointer data) -{ - // The plug window has been embedded, and gtk_socket_add_window() has added - // a filter to the socket's plug_window, passing the socket as data for the - // filter, so the socket must live as long as events may be received on the - // plug window. - // - // https://git.gnome.org/browse/gtk+/tree/gtk/gtksocket.c?h=3.18.7#n1124 - g_object_ref(socket); - // When the socket is unrealized, perhaps during gtk_widget_destroy() from - // ~nsPluginNativeWindowGtk, the plug is removed. The plug in the child - // process then destroys its widget and window. When the browser process - // receives the DestroyNotify event for the plug window, GDK releases its - // reference to plugWindow. This is typically the last reference and so the - // weak ref callback triggers release of the socket. - GdkWindow* plugWindow = gtk_socket_get_plug_window(GTK_SOCKET(socket)); - g_object_weak_ref(G_OBJECT(plugWindow), plug_window_finalize_cb, socket); -} - -/* static */ -gboolean -plug_removed_cb (GtkWidget *widget, gpointer data) -{ - // Gee, thanks for the info! - return TRUE; -} - -static void -socket_unrealize_cb(GtkWidget *widget, gpointer data) -{ - // Unmap and reparent any child windows that GDK does not yet know about. - // (See bug 540114 comment 10.) - GdkWindow* socket_window = gtk_widget_get_window(widget); - GdkDisplay* gdkDisplay = gdk_display_get_default(); - Display* display = GDK_DISPLAY_XDISPLAY(gdkDisplay); - - // Ignore X errors that may happen if windows get destroyed (possibly - // requested by the plugin) between XQueryTree and when we operate on them. - gdk_error_trap_push(); - - Window root, parent; - Window* children; - unsigned int nchildren; - if (!XQueryTree(display, gdk_x11_window_get_xid(socket_window), - &root, &parent, &children, &nchildren)) - return; - - for (unsigned int i = 0; i < nchildren; ++i) { - Window child = children[i]; - if (!gdk_x11_window_lookup_for_display(gdkDisplay, child)) { - // This window is not known to GDK. - XUnmapWindow(display, child); - XReparentWindow(display, child, DefaultRootWindow(display), 0, 0); - } - } - - if (children) XFree(children); - - mozilla::FinishX(display); -#if (MOZ_WIDGET_GTK == 3) - gdk_error_trap_pop_ignored(); -#else - gdk_error_trap_pop(); -#endif -} diff --git a/dom/plugins/base/nsPluginNativeWindowGtk.h b/dom/plugins/base/nsPluginNativeWindowGtk.h deleted file mode 100644 index 872d7f017f3e..000000000000 --- a/dom/plugins/base/nsPluginNativeWindowGtk.h +++ /dev/null @@ -1,51 +0,0 @@ -/* 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 "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(RefPtr &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/PluginWidgetChild.cpp b/dom/plugins/ipc/PluginWidgetChild.cpp index 263082981a24..0a54a048538a 100644 --- a/dom/plugins/ipc/PluginWidgetChild.cpp +++ b/dom/plugins/ipc/PluginWidgetChild.cpp @@ -12,9 +12,7 @@ #include "mozilla/DebugOnly.h" #include "nsDebug.h" -#if defined(XP_WIN) #include "mozilla/plugins/PluginInstanceParent.h" -#endif #define PWLOG(...) //#define PWLOG(...) printf_stderr(__VA_ARGS__) diff --git a/dom/plugins/ipc/PluginWidgetChild.h b/dom/plugins/ipc/PluginWidgetChild.h index cfb5a4327c00..60ac7c38e3c2 100644 --- a/dom/plugins/ipc/PluginWidgetChild.h +++ b/dom/plugins/ipc/PluginWidgetChild.h @@ -5,6 +5,10 @@ #ifndef mozilla_plugins_PluginWidgetChild_h #define mozilla_plugins_PluginWidgetChild_h +#ifndef XP_WIN +#error "This header should be Windows-only." +#endif + #include "mozilla/plugins/PPluginWidgetChild.h" namespace mozilla { diff --git a/dom/plugins/ipc/PluginWidgetParent.cpp b/dom/plugins/ipc/PluginWidgetParent.cpp index a29781aa7e21..5c145073f4ff 100644 --- a/dom/plugins/ipc/PluginWidgetParent.cpp +++ b/dom/plugins/ipc/PluginWidgetParent.cpp @@ -12,24 +12,18 @@ #include "mozilla/DebugOnly.h" #include "nsDebug.h" -#if defined(MOZ_WIDGET_GTK) -#include "nsPluginNativeWindowGtk.h" -#endif - using namespace mozilla; using namespace mozilla::widget; #define PWLOG(...) //#define PWLOG(...) printf_stderr(__VA_ARGS__) -#if defined(XP_WIN) namespace mozilla { namespace dom { // For nsWindow const wchar_t* kPluginWidgetContentParentProperty = L"kPluginWidgetParentProperty"; } } -#endif namespace mozilla { namespace plugins { @@ -95,19 +89,6 @@ PluginWidgetParent::RecvCreate(nsresult* aResult, uint64_t* aScrollCaptureId, mWidget = do_CreateInstance(kWidgetCID, aResult); NS_ASSERTION(NS_SUCCEEDED(*aResult), "widget create failure"); -#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) { - KillWidget(); - return IPC_FAIL_NO_REASON(this); - } - // Give a copy of this to the widget, which handles some update - // work for us. - mWidget->SetNativeData(NS_NATIVE_PLUGIN_OBJECT_PTR, (uintptr_t)mWrapper.get()); -#endif - // This returns the top level window widget nsCOMPtr parentWidget = GetTabParent()->GetWidget(); // If this fails, bail. @@ -132,25 +113,6 @@ PluginWidgetParent::RecvCreate(nsresult* aResult, uint64_t* aScrollCaptureId, mWidget->EnableDragDrop(true); -#if defined(MOZ_WIDGET_GTK) - // For setup, initially GTK code expects 'window' to hold the parent. - mWrapper->window = mWidget->GetNativeData(NS_NATIVE_PLUGIN_PORT); - DebugOnly drv = mWrapper->CreateXEmbedWindow(false); - NS_ASSERTION(NS_SUCCEEDED(drv), "widget call failure"); - mWrapper->SetAllocation(); - PWLOG("Plugin XID=%p\n", (void*)mWrapper->window); -#elif defined(XP_WIN) - DebugOnly winres = - ::SetPropW((HWND)mWidget->GetNativeData(NS_NATIVE_WINDOW), - mozilla::dom::kPluginWidgetContentParentProperty, - GetTabParent()->Manager()->AsContentParent()); - NS_ASSERTION(winres, "SetPropW call failure"); - - *aScrollCaptureId = mWidget->CreateScrollCaptureContainer(); - *aPluginInstanceId = - reinterpret_cast(mWidget->GetNativeData(NS_NATIVE_PLUGIN_ID)); -#endif - // This is a special call we make to nsBaseWidget to register this // window as a remote plugin window which is expected to receive // visibility updates from the compositor, which ships this data @@ -167,13 +129,8 @@ PluginWidgetParent::KillWidget() if (mWidget) { mWidget->UnregisterPluginWindowForRemoteUpdates(); mWidget->Destroy(); -#if defined(MOZ_WIDGET_GTK) - mWidget->SetNativeData(NS_NATIVE_PLUGIN_OBJECT_PTR, (uintptr_t)0); - mWrapper = nullptr; -#elif defined(XP_WIN) ::RemovePropW((HWND)mWidget->GetNativeData(NS_NATIVE_WINDOW), mozilla::dom::kPluginWidgetContentParentProperty); -#endif mWidget = nullptr; } } @@ -207,13 +164,8 @@ mozilla::ipc::IPCResult PluginWidgetParent::RecvGetNativePluginPort(uintptr_t* value) { ENSURE_CHANNEL; -#if defined(MOZ_WIDGET_GTK) - *value = (uintptr_t)mWrapper->window; - NS_ASSERTION(*value, "no xid??"); -#else *value = (uintptr_t)mWidget->GetNativeData(NS_NATIVE_PLUGIN_PORT); NS_ASSERTION(*value, "no native port??"); -#endif PWLOG("PluginWidgetParent::RecvGetNativeData() %p\n", (void*)*value); return IPC_OK(); } @@ -221,16 +173,11 @@ PluginWidgetParent::RecvGetNativePluginPort(uintptr_t* value) mozilla::ipc::IPCResult PluginWidgetParent::RecvSetNativeChildWindow(const uintptr_t& aChildWindow) { -#if defined(XP_WIN) ENSURE_CHANNEL; PWLOG("PluginWidgetParent::RecvSetNativeChildWindow(%p)\n", (void*)aChildWindow); mWidget->SetNativeData(NS_NATIVE_CHILD_WINDOW, aChildWindow); return IPC_OK(); -#else - NS_NOTREACHED("PluginWidgetParent::RecvSetNativeChildWindow not implemented!"); - return IPC_FAIL_NO_REASON(this); -#endif } } // namespace plugins diff --git a/dom/plugins/ipc/PluginWidgetParent.h b/dom/plugins/ipc/PluginWidgetParent.h index 43ef7907dbcf..b1818174babb 100644 --- a/dom/plugins/ipc/PluginWidgetParent.h +++ b/dom/plugins/ipc/PluginWidgetParent.h @@ -5,15 +5,15 @@ #ifndef mozilla_plugins_PluginWidgetParent_h #define mozilla_plugins_PluginWidgetParent_h +#ifndef XP_WIN +#error "This header should be Windows-only." +#endif + #include "mozilla/plugins/PPluginWidgetParent.h" #include "nsAutoPtr.h" #include "nsIWidget.h" #include "nsCOMPtr.h" -#if defined(MOZ_WIDGET_GTK) -class nsPluginNativeWindowGtk; -#endif - namespace mozilla { namespace dom { @@ -53,9 +53,6 @@ private: // The chrome side native widget. nsCOMPtr mWidget; -#if defined(MOZ_WIDGET_GTK) - nsAutoPtr mWrapper; -#endif }; } // namespace plugins diff --git a/dom/plugins/ipc/moz.build b/dom/plugins/ipc/moz.build index b569aeb4c1fa..cc478168eaea 100644 --- a/dom/plugins/ipc/moz.build +++ b/dom/plugins/ipc/moz.build @@ -39,8 +39,6 @@ EXPORTS.mozilla.plugins += [ 'PluginStreamChild.h', 'PluginStreamParent.h', 'PluginUtilsOSX.h', - 'PluginWidgetChild.h', - 'PluginWidgetParent.h', 'StreamNotifyChild.h', 'StreamNotifyParent.h', ] @@ -89,8 +87,6 @@ UNIFIED_SOURCES += [ SOURCES += [ 'PluginInstanceChild.cpp', # 'PluginThreadCallback' : ambiguous symbol 'PluginModuleChild.cpp', # Redefinition of mozilla::WindowsDllInterceptor sUser32Intercept - 'PluginWidgetChild.cpp', - 'PluginWidgetParent.cpp', ] if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': @@ -100,10 +96,18 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': ] if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': + EXPORTS.mozilla.plugins += [ + 'PluginWidgetChild.h', + 'PluginWidgetParent.h', + ] UNIFIED_SOURCES += [ 'D3D11SurfaceHolder.cpp', 'PluginUtilsWin.cpp' ] + SOURCES += [ + 'PluginWidgetChild.cpp', + 'PluginWidgetParent.cpp', + ] IPDL_SOURCES += [ 'PBrowserStream.ipdl', diff --git a/widget/PluginWidgetProxy.cpp b/widget/PluginWidgetProxy.cpp index 57ca55288d4b..638321241041 100644 --- a/widget/PluginWidgetProxy.cpp +++ b/widget/PluginWidgetProxy.cpp @@ -75,13 +75,11 @@ PluginWidgetProxy::Create(nsIWidget* aParent, mEnabled = true; mVisible = true; -#if defined(XP_WIN) PluginInstanceParent* instance = PluginInstanceParent::LookupPluginInstanceByID(pluginInstanceId); if (instance) { Unused << NS_WARN_IF(NS_FAILED(instance->SetScrollCaptureId(scrollCaptureId))); } -#endif return NS_OK; } @@ -158,7 +156,6 @@ PluginWidgetProxy::GetNativeData(uint32_t aDataType) return (void*)mCachedPluginPort; } -#if defined(XP_WIN) void PluginWidgetProxy::SetNativeData(uint32_t aDataType, uintptr_t aVal) { @@ -179,7 +176,6 @@ PluginWidgetProxy::SetNativeData(uint32_t aDataType, uintptr_t aVal) NS_ERROR("SetNativeData called with unsupported data type."); } } -#endif nsresult PluginWidgetProxy::SetFocus(bool aRaise) diff --git a/widget/PluginWidgetProxy.h b/widget/PluginWidgetProxy.h index 54d65556dfca..0482caa2b7f1 100644 --- a/widget/PluginWidgetProxy.h +++ b/widget/PluginWidgetProxy.h @@ -5,6 +5,10 @@ #ifndef mozilla_widget_RemotePlugin_h__ #define mozilla_widget_RemotePlugin_h__ +#ifndef XP_WIN +#error "Plugin widgets are Windows-only." +#endif + #include "PuppetWidget.h" #include "mozilla/dom/TabChild.h" @@ -46,9 +50,7 @@ public: virtual nsIWidget* GetParent(void) override; virtual void* GetNativeData(uint32_t aDataType) override; -#if defined(XP_WIN) void SetNativeData(uint32_t aDataType, uintptr_t aVal) override; -#endif virtual nsTransparencyMode GetTransparencyMode() override { return eTransparencyOpaque; } virtual void GetWindowClipRegion(nsTArray* aRects) override; diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp index f0c612be7976..0575ae6abad8 100644 --- a/widget/gtk/nsWindow.cpp +++ b/widget/gtk/nsWindow.cpp @@ -80,7 +80,6 @@ #include "nsIPropertyBag2.h" #include "GLContext.h" #include "gfx2DGlue.h" -#include "nsPluginNativeWindowGtk.h" #ifdef ACCESSIBILITY #include "mozilla/a11y/Accessible.h" @@ -242,12 +241,6 @@ extern "C" { static GdkFilterReturn popup_take_focus_filter (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data); -static GdkFilterReturn plugin_window_filter_func (GdkXEvent *gdk_xevent, - GdkEvent *event, - gpointer data); -static GdkFilterReturn plugin_client_message_filter (GdkXEvent *xevent, - GdkEvent *event, - gpointer data); #endif /* MOZ_X11 */ #ifdef __cplusplus } @@ -360,7 +353,6 @@ static nsWindow *gFocusWindow = nullptr; static bool gBlockActivateEvent = false; static bool gGlobalsInitialized = false; static bool gRaiseWindows = true; -static nsWindow *gPluginFocusWindow = nullptr; #if GTK_CHECK_VERSION(3,4,0) static uint32_t gLastTouchID = 0; @@ -440,7 +432,6 @@ nsWindow::nsWindow() mContainer = nullptr; mGdkWindow = nullptr; mShell = nullptr; - mPluginNativeWindow = nullptr; mHasMappedToplevel = false; mIsFullyObscured = false; mRetryPointerGrab = false; @@ -457,8 +448,6 @@ nsWindow::nsWindow() mXVisual = nullptr; mXDepth = 0; #endif /* MOZ_X11 */ - mPluginType = PluginType_NONE; - if (!gGlobalsInitialized) { gGlobalsInitialized = true; @@ -759,13 +748,6 @@ nsWindow::Destroy() gFocusWindow = nullptr; } -#if (MOZ_WIDGET_GTK == 2) && defined(MOZ_X11) - // make sure that we remove ourself as the plugin focus window - if (gPluginFocusWindow == this) { - gPluginFocusWindow->LoseNonXEmbedPluginFocus(); - } -#endif /* MOZ_X11 && MOZ_WIDGET_GTK == 2 && defined(MOZ_X11) */ - GtkWidget *owningWidget = GetMozContainerWidget(); if (mShell) { gtk_widget_destroy(mShell); @@ -1124,7 +1106,6 @@ nsWindow::Resize(double aWidth, double aHeight, bool aRepaint) NativeResize(); NotifyRollupGeometryChange(); - ResizePluginSocketWidget(); // send a resize notification if this is a toplevel if (mIsTopLevel || mListenForResizes) { @@ -1155,7 +1136,6 @@ nsWindow::Resize(double aX, double aY, double aWidth, double aHeight, NativeMoveResize(); NotifyRollupGeometryChange(); - ResizePluginSocketWidget(); if (mIsTopLevel || mListenForResizes) { DispatchResized(); @@ -1164,23 +1144,6 @@ nsWindow::Resize(double aX, double aY, double aWidth, double aHeight, return; } -void -nsWindow::ResizePluginSocketWidget() -{ - // e10s specific, a eWindowType_plugin_ipc_chrome holds its own - // nsPluginNativeWindowGtk wrapper. We are responsible for resizing - // the embedded socket widget. - if (mWindowType == eWindowType_plugin_ipc_chrome) { - auto* wrapper = (nsPluginNativeWindowGtk*) - GetNativeData(NS_NATIVE_PLUGIN_OBJECT_PTR); - if (wrapper) { - wrapper->width = mBounds.width; - wrapper->height = mBounds.height; - wrapper->SetAllocation(); - } - } -} - void nsWindow::Enable(bool aState) { @@ -1711,17 +1674,6 @@ nsWindow::GetNativeData(uint32_t aDataType) return mGdkWindow; } - case NS_NATIVE_PLUGIN_PORT: - return SetupPluginPort(); - - case NS_NATIVE_PLUGIN_ID: - if (!mPluginNativeWindow) { - NS_WARNING("no native plugin instance!"); - return nullptr; - } - // Return the socket widget XID - return (void*)mPluginNativeWindow->window; - case NS_NATIVE_DISPLAY: { #ifdef MOZ_X11 GdkDisplay* gdkDisplay = gdk_display_get_default(); @@ -1736,8 +1688,6 @@ nsWindow::GetNativeData(uint32_t aDataType) case NS_NATIVE_SHAREABLE_WINDOW: return (void *) GDK_WINDOW_XID(gdk_window_get_toplevel(mGdkWindow)); - case NS_NATIVE_PLUGIN_OBJECT_PTR: - return (void *) mPluginNativeWindow; case NS_RAW_NATIVE_IME_CONTEXT: { void* pseudoIMEContext = GetPseudoIMEContext(); if (pseudoIMEContext) { @@ -1762,16 +1712,6 @@ nsWindow::GetNativeData(uint32_t aDataType) } } -void -nsWindow::SetNativeData(uint32_t aDataType, uintptr_t aVal) -{ - if (aDataType != NS_NATIVE_PLUGIN_OBJECT_PTR) { - NS_WARNING("nsWindow::SetNativeData called with bad value"); - return; - } - mPluginNativeWindow = (nsPluginNativeWindowGtk*)aVal; -} - nsresult nsWindow::SetTitle(const nsAString& aTitle) { @@ -2620,13 +2560,6 @@ nsWindow::OnMotionNotifyEvent(GdkEventMotion *aEvent) synthEvent = true; XNextEvent (GDK_WINDOW_XDISPLAY(aEvent->window), &xevent); } -#if (MOZ_WIDGET_GTK == 2) - // if plugins still keeps the focus, get it back - if (gPluginFocusWindow && gPluginFocusWindow != this) { - RefPtr kungFuDeathGrip = gPluginFocusWindow; - gPluginFocusWindow->LoseNonXEmbedPluginFocus(); - } -#endif /* MOZ_WIDGET_GTK == 2 */ } #endif /* MOZ_X11 */ @@ -2944,14 +2877,6 @@ nsWindow::OnContainerFocusOutEvent(GdkEventFocus *aEvent) } } -#if (MOZ_WIDGET_GTK == 2) && defined(MOZ_X11) - // plugin lose focus - if (gPluginFocusWindow) { - RefPtr kungFuDeathGrip = gPluginFocusWindow; - gPluginFocusWindow->LoseNonXEmbedPluginFocus(); - } -#endif /* MOZ_X11 && MOZ_WIDGET_GTK == 2 */ - if (gFocusWindow) { RefPtr kungFuDeathGrip = gFocusWindow; if (gFocusWindow->mIMContext) { @@ -3815,6 +3740,9 @@ nsWindow::Create(nsIWidget* aParent, case eWindowType_plugin: case eWindowType_plugin_ipc_chrome: case eWindowType_plugin_ipc_content: + MOZ_ASSERT_UNREACHABLE(); + return NS_ERROR_FAILURE; + case eWindowType_child: { if (parentMozContainer) { mGdkWindow = CreateGdkWindow(parentGdkWindow, parentMozContainer); @@ -4770,157 +4698,12 @@ nsWindow::SetUrgencyHint(GtkWidget *top_window, bool state) gdk_window_set_urgency_hint(gtk_widget_get_window(top_window), state); } -void * -nsWindow::SetupPluginPort(void) -{ - if (!mGdkWindow) - return nullptr; - - if (gdk_window_is_destroyed(mGdkWindow) == TRUE) - return nullptr; - - Window window = gdk_x11_window_get_xid(mGdkWindow); - - // we have to flush the X queue here so that any plugins that - // might be running on separate X connections will be able to use - // this window in case it was just created -#ifdef MOZ_X11 - XWindowAttributes xattrs; - Display *display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); - XGetWindowAttributes(display, window, &xattrs); - XSelectInput (display, window, - xattrs.your_event_mask | - SubstructureNotifyMask); - - gdk_window_add_filter(mGdkWindow, plugin_window_filter_func, this); - - XSync(display, False); -#endif /* MOZ_X11 */ - - return (void *)window; -} - void nsWindow::SetDefaultIcon(void) { SetIcon(NS_LITERAL_STRING("default")); } -void -nsWindow::SetPluginType(PluginType aPluginType) -{ - mPluginType = aPluginType; -} - -#ifdef MOZ_X11 -void -nsWindow::SetNonXEmbedPluginFocus() -{ - if (gPluginFocusWindow == this || mPluginType!=PluginType_NONXEMBED) { - return; - } - - if (gPluginFocusWindow) { - RefPtr kungFuDeathGrip = gPluginFocusWindow; - gPluginFocusWindow->LoseNonXEmbedPluginFocus(); - } - - LOGFOCUS(("nsWindow::SetNonXEmbedPluginFocus\n")); - - Window curFocusWindow; - int focusState; - - GdkDisplay *gdkDisplay = gdk_window_get_display(mGdkWindow); - XGetInputFocus(gdk_x11_display_get_xdisplay(gdkDisplay), - &curFocusWindow, - &focusState); - - LOGFOCUS(("\t curFocusWindow=%p\n", curFocusWindow)); - - GdkWindow* toplevel = gdk_window_get_toplevel(mGdkWindow); -#if (MOZ_WIDGET_GTK == 2) - GdkWindow *gdkfocuswin = gdk_window_lookup(curFocusWindow); -#else - GdkWindow *gdkfocuswin = gdk_x11_window_lookup_for_display(gdkDisplay, - curFocusWindow); -#endif - - // lookup with the focus proxy window is supposed to get the - // same GdkWindow as toplevel. If the current focused window - // is not the focus proxy, we return without any change. - if (gdkfocuswin != toplevel) { - return; - } - - // switch the focus from the focus proxy to the plugin window - mOldFocusWindow = curFocusWindow; - XRaiseWindow(GDK_WINDOW_XDISPLAY(mGdkWindow), - gdk_x11_window_get_xid(mGdkWindow)); - gdk_error_trap_push(); - XSetInputFocus(GDK_WINDOW_XDISPLAY(mGdkWindow), - gdk_x11_window_get_xid(mGdkWindow), - RevertToNone, - CurrentTime); - gdk_flush(); -#if (MOZ_WIDGET_GTK == 3) - gdk_error_trap_pop_ignored(); -#else - gdk_error_trap_pop(); -#endif - gPluginFocusWindow = this; - gdk_window_add_filter(nullptr, plugin_client_message_filter, this); - - LOGFOCUS(("nsWindow::SetNonXEmbedPluginFocus oldfocus=%p new=%p\n", - mOldFocusWindow, gdk_x11_window_get_xid(mGdkWindow))); -} - -void -nsWindow::LoseNonXEmbedPluginFocus() -{ - LOGFOCUS(("nsWindow::LoseNonXEmbedPluginFocus\n")); - - // This method is only for the nsWindow which contains a - // Non-XEmbed plugin, for example, JAVA plugin. - if (gPluginFocusWindow != this || mPluginType!=PluginType_NONXEMBED) { - return; - } - - Window curFocusWindow; - int focusState; - - XGetInputFocus(GDK_WINDOW_XDISPLAY(mGdkWindow), - &curFocusWindow, - &focusState); - - // we only switch focus between plugin window and focus proxy. If the - // current focused window is not the plugin window, just removing the - // event filter that blocks the WM_TAKE_FOCUS is enough. WM and gtk2 - // will take care of the focus later. - if (!curFocusWindow || - curFocusWindow == gdk_x11_window_get_xid(mGdkWindow)) { - - gdk_error_trap_push(); - XRaiseWindow(GDK_WINDOW_XDISPLAY(mGdkWindow), - mOldFocusWindow); - XSetInputFocus(GDK_WINDOW_XDISPLAY(mGdkWindow), - mOldFocusWindow, - RevertToParent, - CurrentTime); - gdk_flush(); -#if (MOZ_WIDGET_GTK == 3) - gdk_error_trap_pop_ignored(); -#else - gdk_error_trap_pop(); -#endif - } - gPluginFocusWindow = nullptr; - mOldFocusWindow = 0; - gdk_window_remove_filter(nullptr, plugin_client_message_filter, this); - - LOGFOCUS(("nsWindow::LoseNonXEmbedPluginFocus end\n")); -} -#endif /* MOZ_X11 */ - gint nsWindow::ConvertBorderStyles(nsBorderStyle aStyle) { @@ -5814,110 +5597,6 @@ popup_take_focus_filter(GdkXEvent *gdk_xevent, gdk_window_focus(parent_window, timestamp); return GDK_FILTER_REMOVE; } - -static GdkFilterReturn -plugin_window_filter_func(GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data) -{ - GdkWindow *plugin_window; - XEvent *xevent; - Window xeventWindow; - - RefPtr nswindow = (nsWindow*)data; - GdkFilterReturn return_val; - - xevent = (XEvent *)gdk_xevent; - return_val = GDK_FILTER_CONTINUE; - - switch (xevent->type) - { - case CreateNotify: - case ReparentNotify: - if (xevent->type==CreateNotify) { - xeventWindow = xevent->xcreatewindow.window; - } - else { - if (xevent->xreparent.event != xevent->xreparent.parent) - break; - xeventWindow = xevent->xreparent.window; - } -#if (MOZ_WIDGET_GTK == 2) - plugin_window = gdk_window_lookup(xeventWindow); -#else - plugin_window = gdk_x11_window_lookup_for_display( - gdk_x11_lookup_xdisplay(xevent->xcreatewindow.display), xeventWindow); -#endif - if (plugin_window) { - GtkWidget *widget = - get_gtk_widget_for_gdk_window(plugin_window); - -// TODO GTK3 -#if (MOZ_WIDGET_GTK == 2) - if (GTK_IS_XTBIN(widget)) { - nswindow->SetPluginType(nsWindow::PluginType_NONXEMBED); - break; - } - else -#endif - if(GTK_IS_SOCKET(widget)) { - if (!g_object_get_data(G_OBJECT(widget), "enable-xt-focus")) { - nswindow->SetPluginType(nsWindow::PluginType_XEMBED); - break; - } - } - } - nswindow->SetPluginType(nsWindow::PluginType_NONXEMBED); - return_val = GDK_FILTER_REMOVE; - break; - case EnterNotify: - nswindow->SetNonXEmbedPluginFocus(); - break; - case DestroyNotify: - gdk_window_remove_filter - ((GdkWindow*)(nswindow->GetNativeData(NS_NATIVE_WINDOW)), - plugin_window_filter_func, - nswindow); - // Currently we consider all plugins are non-xembed and calls - // LoseNonXEmbedPluginFocus without any checking. - nswindow->LoseNonXEmbedPluginFocus(); - break; - default: - break; - } - return return_val; -} - -static GdkFilterReturn -plugin_client_message_filter(GdkXEvent *gdk_xevent, - GdkEvent *event, - gpointer data) -{ - XEvent *xevent; - xevent = (XEvent *)gdk_xevent; - - GdkFilterReturn return_val; - return_val = GDK_FILTER_CONTINUE; - - if (!gPluginFocusWindow || xevent->type!=ClientMessage) { - return return_val; - } - - // When WM sends out WM_TAKE_FOCUS, gtk2 will use XSetInputFocus - // to set the focus to the focus proxy. To prevent this happen - // while the focus is on the plugin, we filter the WM_TAKE_FOCUS - // out. - if (gdk_x11_get_xatom_by_name("WM_PROTOCOLS") - != xevent->xclient.message_type) { - return return_val; - } - - if ((Atom) xevent->xclient.data.l[0] == - gdk_x11_get_xatom_by_name("WM_TAKE_FOCUS")) { - // block it from gtk2.0 focus proxy - return_val = GDK_FILTER_REMOVE; - } - - return return_val; -} #endif /* MOZ_X11 */ static gboolean diff --git a/widget/gtk/nsWindow.h b/widget/gtk/nsWindow.h index 4f61de3136eb..a079388ae4d6 100644 --- a/widget/gtk/nsWindow.h +++ b/widget/gtk/nsWindow.h @@ -62,7 +62,6 @@ extern PRLogModuleInfo *gWidgetDrawLog; #endif /* MOZ_LOGGING */ class gfxPattern; -class nsPluginNativeWindowGtk; namespace mozilla { class TimeStamp; @@ -140,7 +139,6 @@ public: uint32_t aHotspotX, uint32_t aHotspotY) override; virtual void Invalidate(const LayoutDeviceIntRect& aRect) override; virtual void* GetNativeData(uint32_t aDataType) override; - void SetNativeData(uint32_t aDataType, uintptr_t aVal) override; virtual nsresult SetTitle(const nsAString& aTitle) override; virtual void SetIcon(const nsAString& aIconSpec) override; virtual void SetWindowClass(const nsAString& xulWinType) override; @@ -236,18 +234,6 @@ private: void UpdateClientOffset(); public: - enum PluginType { - PluginType_NONE = 0, /* do not have any plugin */ - PluginType_XEMBED, /* the plugin support xembed */ - PluginType_NONXEMBED /* the plugin does not support xembed */ - }; - - void SetPluginType(PluginType aPluginType); -#ifdef MOZ_X11 - void SetNonXEmbedPluginFocus(void); - void LoseNonXEmbedPluginFocus(void); -#endif /* MOZ_X11 */ - void ThemeChanged(void); void OnDPIChanged(void); void OnCheckResize(void); @@ -417,7 +403,6 @@ private: GtkWidget *GetToplevelWidget(); nsWindow *GetContainerWindow(); void SetUrgencyHint(GtkWidget *top_window, bool state); - void *SetupPluginPort(void); void SetDefaultIcon(void); void InitButtonEvent(mozilla::WidgetMouseEvent& aEvent, GdkEventButton* aGdkEvent); @@ -444,7 +429,6 @@ private: mIsFullyObscured : 1, mRetryPointerGrab : 1; nsSizeMode mSizeState; - PluginType mPluginType; int32_t mTransparencyBitmapWidth; int32_t mTransparencyBitmapHeight; @@ -517,12 +501,6 @@ private: void DispatchRestoreEventAccessible(); #endif - // Updates the bounds of the socket widget we manage for remote plugins. - void ResizePluginSocketWidget(); - - // e10s specific - for managing the socket widget this window hosts. - nsPluginNativeWindowGtk* mPluginNativeWindow; - // The cursor cache static GdkCursor *gsGtkCursorCache[eCursorCount]; diff --git a/widget/moz.build b/widget/moz.build index ae1694fac5e4..4b87be880c12 100644 --- a/widget/moz.build +++ b/widget/moz.build @@ -101,7 +101,6 @@ EXPORTS += [ 'nsIWidgetListener.h', 'nsWidgetInitData.h', 'nsWidgetsCID.h', - 'PluginWidgetProxy.h', 'PuppetWidget.h', ] @@ -192,12 +191,9 @@ if CONFIG['MOZ_XUL'] and CONFIG['NS_PRINTING']: # nsBaseWidget.cpp needs to be built separately because of name clashes in the OS X headers # nsBaseDragService.cpp moved out of UNIFIED to fix xgill crash (bug 1259850) after moving widget/ContentHelper -> apz/util/TouchActionHelper -# PluginWidgetProxy includes MacOS system headers which define a Point struct -# that conflicts with mozilla::gfx::Point SOURCES += [ 'nsBaseDragService.cpp', 'nsBaseWidget.cpp', - 'PluginWidgetProxy.cpp', ] if CONFIG['MOZ_INSTRUMENT_EVENT_LOOP']: @@ -217,6 +213,14 @@ if CONFIG['MOZ_X11']: 'WindowSurfaceX11SHM.cpp', ] +if toolkit == 'windows': + EXPORTS += [ + 'PluginWidgetProxy.h', + ] + SOURCES += [ + 'PluginWidgetProxy.cpp', + ] + if toolkit in ('cocoa', 'windows'): UNIFIED_SOURCES += [ 'nsBaseClipboard.cpp',