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

This commit is contained in:
Jim Mathies 2015-01-29 13:41:57 -06:00
Родитель d5d37f938c
Коммит f93fc49262
7 изменённых файлов: 48 добавлений и 21 удалений

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -196,7 +196,12 @@ CompositorChild::RecvUpdatePluginConfigurations(const nsIntPoint& aContentOffset
nsTArray<uintptr_t> 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;

Просмотреть файл

@ -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());

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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, \

Просмотреть файл

@ -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: