From f93fc4926297cb1d8b9c59c44c1fe1fb60da20c9 Mon Sep 17 00:00:00 2001 From: Jim Mathies Date: Thu, 29 Jan 2015 13:41:57 -0600 Subject: [PATCH] Bug 1095754 - Add platform widget support for providing widget identifiers used in remote widget tracking and hookl this up on gtk and Windows. r=roc --- dom/plugins/ipc/PluginWidgetParent.cpp | 12 ++++---- gfx/layers/ipc/CompositorChild.cpp | 7 ++++- widget/gtk/nsWindow.cpp | 40 ++++++++++++++++++-------- widget/gtk/nsWindow.h | 3 ++ widget/nsBaseWidget.cpp | 4 +-- widget/nsIWidget.h | 2 ++ widget/windows/nsWindow.cpp | 1 + 7 files changed, 48 insertions(+), 21 deletions(-) diff --git a/dom/plugins/ipc/PluginWidgetParent.cpp b/dom/plugins/ipc/PluginWidgetParent.cpp index f2adba08ef9c..34c319d6902d 100644 --- a/dom/plugins/ipc/PluginWidgetParent.cpp +++ b/dom/plugins/ipc/PluginWidgetParent.cpp @@ -144,12 +144,6 @@ PluginWidgetParent::RecvCreate() drv = mWidget->Enable(true); NS_ASSERTION(NS_SUCCEEDED(drv), "widget call failure"); - // 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 - // over with corresponding layer updates. - mWidget->RegisterPluginWindowForRemoteUpdates(); - #if defined(MOZ_WIDGET_GTK) // For setup, initially GTK code expects 'window' to hold the parent. mWrapper->window = mWidget->GetNativeData(NS_NATIVE_PLUGIN_PORT); @@ -164,6 +158,12 @@ PluginWidgetParent::RecvCreate() NS_ASSERTION(winres, "SetPropW call failure"); #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 + // over with corresponding layer updates. + mWidget->RegisterPluginWindowForRemoteUpdates(); + return true; } diff --git a/gfx/layers/ipc/CompositorChild.cpp b/gfx/layers/ipc/CompositorChild.cpp index b98d0a044bbb..92aba42498eb 100644 --- a/gfx/layers/ipc/CompositorChild.cpp +++ b/gfx/layers/ipc/CompositorChild.cpp @@ -196,7 +196,12 @@ CompositorChild::RecvUpdatePluginConfigurations(const nsIntPoint& aContentOffset nsTArray visiblePluginIds; for (uint32_t pluginsIdx = 0; pluginsIdx < aPlugins.Length(); pluginsIdx++) { - nsIWidget* widget = nsIWidget::LookupRegisteredPluginWindow(aPlugins[pluginsIdx].windowId()); + nsIWidget* widget = + nsIWidget::LookupRegisteredPluginWindow(aPlugins[pluginsIdx].windowId()); + if (!widget) { + NS_WARNING("Unexpected, plugin id not found!"); + continue; + } bool isVisible = aPlugins[pluginsIdx].visible(); if (widget && !widget->Destroyed()) { nsIntRect bounds; diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp index 1ef011f7f66d..cf945b0765d0 100644 --- a/widget/gtk/nsWindow.cpp +++ b/widget/gtk/nsWindow.cpp @@ -1052,24 +1052,13 @@ nsWindow::Resize(double aWidth, double aHeight, bool aRepaint) } NotifyRollupGeometryChange(); + ResizePluginSocketWidget(); // send a resize notification if this is a toplevel if (mIsTopLevel || mListenForResizes) { DispatchResized(width, height); } - // 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) { - nsPluginNativeWindowGtk* wrapper = (nsPluginNativeWindowGtk*) - GetNativeData(NS_NATIVE_PLUGIN_OBJECT_PTR); - if (wrapper) { - wrapper->width = mBounds.width; - wrapper->height = mBounds.height; - wrapper->SetAllocation(); - } - } return NS_OK; } @@ -1136,6 +1125,7 @@ nsWindow::Resize(double aX, double aY, double aWidth, double aHeight, } NotifyRollupGeometryChange(); + ResizePluginSocketWidget(); if (mIsTopLevel || mListenForResizes) { DispatchResized(width, height); @@ -1144,6 +1134,23 @@ nsWindow::Resize(double aX, double aY, double aWidth, double aHeight, return NS_OK; } +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) { + nsPluginNativeWindowGtk* wrapper = (nsPluginNativeWindowGtk*) + GetNativeData(NS_NATIVE_PLUGIN_OBJECT_PTR); + if (wrapper) { + wrapper->width = mBounds.width; + wrapper->height = mBounds.height; + wrapper->SetAllocation(); + } + } +} + NS_IMETHODIMP nsWindow::Enable(bool aState) { @@ -1662,6 +1669,15 @@ nsWindow::GetNativeData(uint32_t aDataType) return SetupPluginPort(); break; + case NS_NATIVE_PLUGIN_ID: + if (!mPluginNativeWindow) { + NS_WARNING("no native plugin instance!"); + return nullptr; + } + // Return the socket widget XID + return (void*)mPluginNativeWindow->window; + break; + case NS_NATIVE_DISPLAY: #ifdef MOZ_X11 return GDK_DISPLAY_XDISPLAY(gdk_display_get_default()); diff --git a/widget/gtk/nsWindow.h b/widget/gtk/nsWindow.h index cbef5522b122..f86650366278 100644 --- a/widget/gtk/nsWindow.h +++ b/widget/gtk/nsWindow.h @@ -432,6 +432,9 @@ 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; diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index 71e6d8eceaaf..d44d8a6a9030 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -1766,7 +1766,7 @@ nsBaseWidget::RegisterPluginWindowForRemoteUpdates() return; #else MOZ_ASSERT(NS_IsMainThread()); - void* id = GetNativeData(NS_NATIVE_PLUGIN_PORT); + void* id = GetNativeData(NS_NATIVE_PLUGIN_ID); if (!id) { NS_WARNING("This is not a valid native widget!"); return; @@ -1784,7 +1784,7 @@ nsBaseWidget::UnregisterPluginWindowForRemoteUpdates() return; #else MOZ_ASSERT(NS_IsMainThread()); - void* id = GetNativeData(NS_NATIVE_PLUGIN_PORT); + void* id = GetNativeData(NS_NATIVE_PLUGIN_ID); if (!id) { NS_WARNING("This is not a valid native widget!"); return; diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h index 1ac7298ba5fa..ee76fed042fa 100644 --- a/widget/nsIWidget.h +++ b/widget/nsIWidget.h @@ -108,6 +108,8 @@ typedef void* nsNativeWidget; // set/get nsPluginNativeWindowGtk, e10s specific #define NS_NATIVE_PLUGIN_OBJECT_PTR 104 #endif +// See RegisterPluginWindowForRemoteUpdates +#define NS_NATIVE_PLUGIN_ID 105 #define NS_IWIDGET_IID \ { 0xa7db3e01, 0xb8fe, 0x4122, \ diff --git a/widget/windows/nsWindow.cpp b/widget/windows/nsWindow.cpp index 27d5dbd95388..da482eeb9f6c 100644 --- a/widget/windows/nsWindow.cpp +++ b/widget/windows/nsWindow.cpp @@ -2919,6 +2919,7 @@ void* nsWindow::GetNativeData(uint32_t aDataType) nullptr, nsToolkit::mDllInstance, nullptr); + case NS_NATIVE_PLUGIN_ID: case NS_NATIVE_PLUGIN_PORT: case NS_NATIVE_WIDGET: case NS_NATIVE_WINDOW: