Bug 669200 - Various changes to non-ipc related plugin code to facilitate remoting windowed plugin widgets in content. r=roc

This commit is contained in:
Jim Mathies 2014-11-12 14:59:20 -06:00
Родитель abf9ba034f
Коммит 6f6e8ef4e9
4 изменённых файлов: 55 добавлений и 43 удалений

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

@ -1033,17 +1033,6 @@ nsObjectLoadingContent::BuildParametersArray()
}
nsAdoptingCString wmodeOverride = Preferences::GetCString("plugins.force.wmode");
#if defined(XP_WIN) || defined(XP_LINUX)
// Bug 923745 (/Bug 1061995) - Until we support windowed mode plugins in
// content processes, force flash to use a windowless rendering mode. This
// hack should go away when bug 923746 lands. (OS X plugins always use some
// native widgets, so unfortunately this does not help there)
if (wmodeOverride.IsEmpty() &&
XRE_GetProcessType() == GeckoProcessType_Content) {
wmodeOverride.AssignLiteral("transparent");
}
#endif
for (uint32_t i = 0; i < mCachedAttributes.Length(); i++) {
if (!wmodeOverride.IsEmpty() && mCachedAttributes[i].mName.EqualsIgnoreCase("wmode")) {
CopyASCIItoUTF16(wmodeOverride, mCachedAttributes[i].mValue);

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

@ -55,6 +55,7 @@ using mozilla::DefaultXDisplay;
#include "mozilla/MouseEvents.h"
#include "mozilla/TextEvents.h"
#include "mozilla/dom/HTMLObjectElementBinding.h"
#include "mozilla/dom/TabChild.h"
#include "nsFrameSelection.h"
#include "nsContentCID.h"
@ -2416,7 +2417,7 @@ void* nsPluginInstanceOwner::GetPluginPortFromWidget()
if (mWidget) {
#ifdef XP_WIN
if (mPluginWindow && (mPluginWindow->type == NPWindowTypeDrawable))
result = mWidget->GetNativeData(NS_NATIVE_GRAPHIC);
result = mWidget->GetNativeData(NS_NATIVE_GRAPHIC); // HDC
else
#endif
#ifdef XP_MACOSX
@ -2426,7 +2427,7 @@ void* nsPluginInstanceOwner::GetPluginPortFromWidget()
result = mWidget->GetNativeData(NS_NATIVE_PLUGIN_PORT_CG);
else
#endif
result = mWidget->GetNativeData(NS_NATIVE_PLUGIN_PORT);
result = mWidget->GetNativeData(NS_NATIVE_PLUGIN_PORT); // HWND/gdk window
}
return result;
}
@ -2455,13 +2456,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
bool windowless = false;
mInstance->IsWindowless(&windowless);
if (!windowless
// Mac plugins use the widget for setting up the plugin window and event handling.
// We want to use the puppet widgets there with e10s
#ifndef XP_MACOSX
&& !nsIWidget::UsePuppetWidgets()
#endif
) {
if (!windowless) {
// Try to get a parent widget, on some platforms widget creation will fail without
// a parent.
nsCOMPtr<nsIWidget> parentWidget;
@ -2469,25 +2464,41 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
if (mContent) {
doc = mContent->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_GetProcessType() == GeckoProcessType_Content) {
nsCOMPtr<nsIDOMWindow> window = doc->GetWindow();
if (window) {
nsCOMPtr<nsIDOMWindow> topWindow;
window->GetTop(getter_AddRefs(topWindow));
if (topWindow) {
dom::TabChild* tc = dom::TabChild::GetFrom(topWindow);
if (tc) {
// This returns a PluginWidgetProxy which remotes a number of calls.
mWidget = tc->CreatePluginWidget(parentWidget.get());
}
}
}
}
#endif // XP_MACOSX
}
if (!mWidget) {
// native (single process)
mWidget = do_CreateInstance(kWidgetCID, &rv);
nsWidgetInitData initData;
initData.mWindowType = eWindowType_plugin;
initData.mUnicode = false;
initData.clipChildren = true;
initData.clipSiblings = true;
rv = mWidget->Create(parentWidget.get(), nullptr, nsIntRect(0,0,0,0),
nullptr, &initData);
if (NS_FAILED(rv)) {
mWidget->Destroy();
mWidget = nullptr;
return rv;
}
}
mWidget = do_CreateInstance(kWidgetCID, &rv);
if (NS_FAILED(rv)) {
return rv;
}
nsWidgetInitData initData;
initData.mWindowType = eWindowType_plugin;
initData.mUnicode = false;
initData.clipChildren = true;
initData.clipSiblings = true;
rv = mWidget->Create(parentWidget.get(), nullptr, nsIntRect(0,0,0,0),
nullptr, &initData);
if (NS_FAILED(rv)) {
mWidget->Destroy();
mWidget = nullptr;
return rv;
}
mWidget->EnableDragDrop(true);
mWidget->Show(false);
@ -2742,17 +2753,20 @@ nsPluginInstanceOwner::UpdateWindowVisibility(bool aVisible)
mPluginWindowVisible = aVisible;
UpdateWindowPositionAndClipRect(true);
}
#endif // XP_MACOSX
void
nsPluginInstanceOwner::UpdateDocumentActiveState(bool aIsActive)
{
mPluginDocumentActiveState = aIsActive;
#ifndef XP_MACOSX
UpdateWindowPositionAndClipRect(true);
#ifdef MOZ_WIDGET_ANDROID
if (mInstance) {
if (!mPluginDocumentActiveState)
if (!mPluginDocumentActiveState) {
RemovePluginView();
}
mInstance->NotifyOnScreen(mPluginDocumentActiveState);
@ -2764,9 +2778,19 @@ nsPluginInstanceOwner::UpdateDocumentActiveState(bool aIsActive)
// that's why we call it here.
mInstance->NotifyForeground(mPluginDocumentActiveState);
}
#endif
#endif // #ifdef MOZ_WIDGET_ANDROID
// We don't have a connection to PluginWidgetParent in the chrome
// process when dealing with tab visibility changes, so this needs
// to be forwarded over after the active state is updated. If we
// don't hide plugin widgets in hidden tabs, the native child window
// in chrome will remain visible after a tab switch.
if (mWidget && XRE_GetProcessType() == GeckoProcessType_Content) {
mWidget->Show(aIsActive);
mWidget->Enable(aIsActive);
}
#endif // #ifndef XP_MACOSX
}
#endif // XP_MACOSX
NS_IMETHODIMP
nsPluginInstanceOwner::CallSetWindow()

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

@ -147,9 +147,10 @@ public:
#else // XP_MACOSX
void UpdateWindowPositionAndClipRect(bool aSetWindow);
void UpdateWindowVisibility(bool aVisible);
void UpdateDocumentActiveState(bool aIsActive);
#endif // XP_MACOSX
void UpdateDocumentActiveState(bool aIsActive);
void SetFrame(nsPluginFrame *aFrame);
nsPluginFrame* GetFrame();

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

@ -1951,11 +1951,9 @@ nsPluginFrame::GetCursor(const nsPoint& aPoint, nsIFrame::Cursor& aCursor)
void
nsPluginFrame::SetIsDocumentActive(bool aIsActive)
{
#ifndef XP_MACOSX
if (mInstanceOwner) {
mInstanceOwner->UpdateDocumentActiveState(aIsActive);
}
#endif
}
// static