зеркало из https://github.com/mozilla/pjs.git
Fixing 132759 -- 100% CPU with Flash, r=peterl, sr=jst
This commit is contained in:
Родитель
f313b063f7
Коммит
853796579e
|
@ -128,6 +128,8 @@
|
||||||
|
|
||||||
#include "nsObjectFrame.h"
|
#include "nsObjectFrame.h"
|
||||||
#include "nsIObjectFrame.h"
|
#include "nsIObjectFrame.h"
|
||||||
|
#include "nsPluginNativeWindow.h"
|
||||||
|
#include "nsPIPluginHost.h"
|
||||||
|
|
||||||
// accessibility support
|
// accessibility support
|
||||||
#ifdef ACCESSIBILITY
|
#ifdef ACCESSIBILITY
|
||||||
|
@ -327,7 +329,7 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsPluginWindow mPluginWindow;
|
nsPluginNativeWindow *mPluginWindow;
|
||||||
nsIPluginInstance *mInstance;
|
nsIPluginInstance *mInstance;
|
||||||
nsObjectFrame *mOwner;
|
nsObjectFrame *mOwner;
|
||||||
nsCString mDocumentBase;
|
nsCString mDocumentBase;
|
||||||
|
@ -667,9 +669,14 @@ nsObjectFrame::Destroy(nsIPresContext* aPresContext)
|
||||||
// doing this in the destructor is too late.
|
// doing this in the destructor is too late.
|
||||||
if(mInstanceOwner != nsnull)
|
if(mInstanceOwner != nsnull)
|
||||||
{
|
{
|
||||||
nsIPluginInstance *inst;
|
nsCOMPtr<nsIPluginInstance> inst;
|
||||||
if(NS_OK == mInstanceOwner->GetInstance(inst))
|
if(NS_SUCCEEDED(mInstanceOwner->GetInstance(*getter_AddRefs(inst))))
|
||||||
{
|
{
|
||||||
|
nsPluginWindow *win;
|
||||||
|
mInstanceOwner->GetWindow(win);
|
||||||
|
nsPluginNativeWindow *window = (nsPluginNativeWindow *)win;
|
||||||
|
nsCOMPtr<nsIPluginInstance> nullinst;
|
||||||
|
|
||||||
PRBool doCache = PR_TRUE;
|
PRBool doCache = PR_TRUE;
|
||||||
PRBool doCallSetWindowAfterDestroy = PR_FALSE;
|
PRBool doCallSetWindowAfterDestroy = PR_FALSE;
|
||||||
|
|
||||||
|
@ -684,24 +691,34 @@ nsObjectFrame::Destroy(nsIPresContext* aPresContext)
|
||||||
if (doCallSetWindowAfterDestroy) {
|
if (doCallSetWindowAfterDestroy) {
|
||||||
inst->Stop();
|
inst->Stop();
|
||||||
inst->Destroy();
|
inst->Destroy();
|
||||||
|
|
||||||
|
if (window)
|
||||||
|
window->CallSetWindow(nullinst);
|
||||||
|
else
|
||||||
inst->SetWindow(nsnull);
|
inst->SetWindow(nsnull);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (window)
|
||||||
|
window->CallSetWindow(nullinst);
|
||||||
|
else
|
||||||
inst->SetWindow(nsnull);
|
inst->SetWindow(nsnull);
|
||||||
|
|
||||||
inst->Stop();
|
inst->Stop();
|
||||||
inst->Destroy();
|
inst->Destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (window)
|
||||||
|
window->CallSetWindow(nullinst);
|
||||||
|
else
|
||||||
inst->SetWindow(nsnull);
|
inst->SetWindow(nsnull);
|
||||||
|
|
||||||
inst->Stop();
|
inst->Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIPluginHost> pluginHost = do_GetService(kCPluginManagerCID);
|
nsCOMPtr<nsIPluginHost> pluginHost = do_GetService(kCPluginManagerCID);
|
||||||
if(pluginHost)
|
if(pluginHost)
|
||||||
pluginHost->StopPluginInstance(inst);
|
pluginHost->StopPluginInstance(inst);
|
||||||
|
|
||||||
NS_RELEASE(inst);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nsObjectFrameSuper::Destroy(aPresContext);
|
return nsObjectFrameSuper::Destroy(aPresContext);
|
||||||
|
@ -1243,6 +1260,8 @@ nsObjectFrame::InstantiatePlugin(nsIPresContext* aPresContext,
|
||||||
|
|
||||||
mInstanceOwner->GetWindow(window);
|
mInstanceOwner->GetWindow(window);
|
||||||
|
|
||||||
|
NS_ENSURE_TRUE(window, NS_ERROR_NULL_POINTER);
|
||||||
|
|
||||||
GetOffsetFromView(aPresContext, origin, &parentWithView);
|
GetOffsetFromView(aPresContext, origin, &parentWithView);
|
||||||
window->x = NSTwipsToIntPixels(origin.x, t2p);
|
window->x = NSTwipsToIntPixels(origin.x, t2p);
|
||||||
window->y = NSTwipsToIntPixels(origin.y, t2p);
|
window->y = NSTwipsToIntPixels(origin.y, t2p);
|
||||||
|
@ -1528,16 +1547,18 @@ nsObjectFrame::DidReflow(nsIPresContext* aPresContext,
|
||||||
vm->SetViewVisibility(view, bHidden ? nsViewVisibility_kHide : nsViewVisibility_kShow);
|
vm->SetViewVisibility(view, bHidden ? nsViewVisibility_kHide : nsViewVisibility_kShow);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsPluginWindow *window;
|
nsPluginWindow *win = nsnull;
|
||||||
|
|
||||||
nsCOMPtr<nsIPluginInstance> pi;
|
nsCOMPtr<nsIPluginInstance> pi;
|
||||||
if (!mInstanceOwner ||
|
if (!mInstanceOwner ||
|
||||||
NS_FAILED(rv = mInstanceOwner->GetWindow(window)) ||
|
NS_FAILED(rv = mInstanceOwner->GetWindow(win)) ||
|
||||||
NS_FAILED(rv = mInstanceOwner->GetInstance(*getter_AddRefs(pi))) ||
|
NS_FAILED(rv = mInstanceOwner->GetInstance(*getter_AddRefs(pi))) ||
|
||||||
!pi ||
|
!pi ||
|
||||||
!window)
|
!win)
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
|
nsPluginNativeWindow *window = (nsPluginNativeWindow *)win;
|
||||||
|
|
||||||
#ifdef XP_MAC
|
#ifdef XP_MAC
|
||||||
mInstanceOwner->FixUpPluginWindow();
|
mInstanceOwner->FixUpPluginWindow();
|
||||||
#endif // XP_MAC
|
#endif // XP_MAC
|
||||||
|
@ -1557,7 +1578,11 @@ nsObjectFrame::DidReflow(nsIPresContext* aPresContext,
|
||||||
|
|
||||||
// refresh the plugin port as well
|
// refresh the plugin port as well
|
||||||
window->window = mInstanceOwner->GetPluginPort();
|
window->window = mInstanceOwner->GetPluginPort();
|
||||||
pi->SetWindow(window);
|
|
||||||
|
// this will call pi->SetWindow and take care of window subclassing
|
||||||
|
// if needed, see bug 132759
|
||||||
|
window->CallSetWindow(pi);
|
||||||
|
|
||||||
mInstanceOwner->ReleasePluginPort((nsPluginPort *)window->window);
|
mInstanceOwner->ReleasePluginPort((nsPluginPort *)window->window);
|
||||||
|
|
||||||
if (mWidget) {
|
if (mWidget) {
|
||||||
|
@ -2091,7 +2116,15 @@ nsPluginInstanceOwner::nsPluginInstanceOwner()
|
||||||
{
|
{
|
||||||
NS_INIT_ISUPPORTS();
|
NS_INIT_ISUPPORTS();
|
||||||
|
|
||||||
memset(&mPluginWindow, 0, sizeof(mPluginWindow));
|
// create nsPluginNativeWindow object, it is derived from nsPluginWindow
|
||||||
|
// struct and allows to manipulate native window procedure
|
||||||
|
nsCOMPtr<nsIPluginHost> ph = do_GetService(kCPluginManagerCID);
|
||||||
|
nsCOMPtr<nsPIPluginHost> pph(do_QueryInterface(ph));
|
||||||
|
if (pph)
|
||||||
|
pph->NewPluginNativeWindow(&mPluginWindow);
|
||||||
|
else
|
||||||
|
mPluginWindow = nsnull;
|
||||||
|
|
||||||
mInstance = nsnull;
|
mInstance = nsnull;
|
||||||
mOwner = nsnull;
|
mOwner = nsnull;
|
||||||
mWidget = nsnull;
|
mWidget = nsnull;
|
||||||
|
@ -2152,11 +2185,19 @@ nsPluginInstanceOwner::~nsPluginInstanceOwner()
|
||||||
#ifdef XP_UNIX
|
#ifdef XP_UNIX
|
||||||
// the mem for this struct is allocated
|
// the mem for this struct is allocated
|
||||||
// by PR_MALLOC in ns4xPluginInstance.cpp:ns4xPluginInstance::SetWindow()
|
// by PR_MALLOC in ns4xPluginInstance.cpp:ns4xPluginInstance::SetWindow()
|
||||||
if (mPluginWindow.ws_info) {
|
if (mPluginWindow && mPluginWindow->ws_info) {
|
||||||
PR_Free(mPluginWindow.ws_info);
|
PR_Free(mPluginWindow->ws_info);
|
||||||
mPluginWindow.ws_info = nsnull;
|
mPluginWindow->ws_info = nsnull;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// clean up plugin native window object
|
||||||
|
nsCOMPtr<nsIPluginHost> ph = do_GetService(kCPluginManagerCID);
|
||||||
|
nsCOMPtr<nsPIPluginHost> pph(do_QueryInterface(ph));
|
||||||
|
if (pph) {
|
||||||
|
pph->DeletePluginNativeWindow(mPluginWindow);
|
||||||
|
mPluginWindow = nsnull;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2193,7 +2234,8 @@ NS_IMETHODIMP nsPluginInstanceOwner::SetInstance(nsIPluginInstance *aInstance)
|
||||||
|
|
||||||
NS_IMETHODIMP nsPluginInstanceOwner::GetWindow(nsPluginWindow *&aWindow)
|
NS_IMETHODIMP nsPluginInstanceOwner::GetWindow(nsPluginWindow *&aWindow)
|
||||||
{
|
{
|
||||||
aWindow = &mPluginWindow;
|
NS_ASSERTION(mPluginWindow, "the plugin window object being returned is null");
|
||||||
|
aWindow = mPluginWindow;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2746,7 +2788,9 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetWidth(PRUint32 *result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(result);
|
NS_ENSURE_ARG_POINTER(result);
|
||||||
|
|
||||||
*result = mPluginWindow.width;
|
NS_ENSURE_TRUE(mPluginWindow, NS_ERROR_NULL_POINTER);
|
||||||
|
|
||||||
|
*result = mPluginWindow->width;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -2755,7 +2799,9 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetHeight(PRUint32 *result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(result);
|
NS_ENSURE_ARG_POINTER(result);
|
||||||
|
|
||||||
*result = mPluginWindow.height;
|
NS_ENSURE_TRUE(mPluginWindow, NS_ERROR_NULL_POINTER);
|
||||||
|
|
||||||
|
*result = mPluginWindow->height;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -3190,7 +3236,7 @@ nsresult nsPluginInstanceOwner::Blur(nsIDOMEvent * aFocusEvent)
|
||||||
nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent)
|
nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent)
|
||||||
{
|
{
|
||||||
#ifndef XP_MAC
|
#ifndef XP_MAC
|
||||||
if (nsPluginWindowType_Window == mPluginWindow.type)
|
if (!mPluginWindow || nsPluginWindowType_Window == mPluginWindow->type)
|
||||||
return NS_ERROR_FAILURE; // means consume event
|
return NS_ERROR_FAILURE; // means consume event
|
||||||
// continue only for cases without child window
|
// continue only for cases without child window
|
||||||
#endif
|
#endif
|
||||||
|
@ -3344,7 +3390,7 @@ nsresult nsPluginInstanceOwner::KeyPress(nsIDOMEvent* aKeyEvent)
|
||||||
nsresult nsPluginInstanceOwner::DispatchKeyToPlugin(nsIDOMEvent* aKeyEvent)
|
nsresult nsPluginInstanceOwner::DispatchKeyToPlugin(nsIDOMEvent* aKeyEvent)
|
||||||
{
|
{
|
||||||
#ifndef XP_MAC
|
#ifndef XP_MAC
|
||||||
if (nsPluginWindowType_Window == mPluginWindow.type)
|
if (!mPluginWindow || nsPluginWindowType_Window == mPluginWindow->type)
|
||||||
return NS_ERROR_FAILURE; // means consume event
|
return NS_ERROR_FAILURE; // means consume event
|
||||||
// continue only for cases without child window
|
// continue only for cases without child window
|
||||||
#endif
|
#endif
|
||||||
|
@ -3382,7 +3428,7 @@ nsresult
|
||||||
nsPluginInstanceOwner::MouseMove(nsIDOMEvent* aMouseEvent)
|
nsPluginInstanceOwner::MouseMove(nsIDOMEvent* aMouseEvent)
|
||||||
{
|
{
|
||||||
#ifndef XP_MAC
|
#ifndef XP_MAC
|
||||||
if (nsPluginWindowType_Window == mPluginWindow.type)
|
if (!mPluginWindow || nsPluginWindowType_Window == mPluginWindow->type)
|
||||||
return NS_ERROR_FAILURE; // means consume event
|
return NS_ERROR_FAILURE; // means consume event
|
||||||
// continue only for cases without child window
|
// continue only for cases without child window
|
||||||
#endif
|
#endif
|
||||||
|
@ -3414,14 +3460,14 @@ nsresult
|
||||||
nsPluginInstanceOwner::MouseDown(nsIDOMEvent* aMouseEvent)
|
nsPluginInstanceOwner::MouseDown(nsIDOMEvent* aMouseEvent)
|
||||||
{
|
{
|
||||||
#ifndef XP_MAC
|
#ifndef XP_MAC
|
||||||
if (nsPluginWindowType_Window == mPluginWindow.type)
|
if (!mPluginWindow || nsPluginWindowType_Window == mPluginWindow->type)
|
||||||
return NS_ERROR_FAILURE; // means consume event
|
return NS_ERROR_FAILURE; // means consume event
|
||||||
// continue only for cases without child window
|
// continue only for cases without child window
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// if the plugin is windowless, we need to set focus ourselves
|
// if the plugin is windowless, we need to set focus ourselves
|
||||||
// otherwise, we might not get key events
|
// otherwise, we might not get key events
|
||||||
if (mPluginWindow.type == nsPluginWindowType_Drawable) {
|
if (mPluginWindow && mPluginWindow->type == nsPluginWindowType_Drawable) {
|
||||||
nsCOMPtr<nsIContent> content;
|
nsCOMPtr<nsIContent> content;
|
||||||
mOwner->GetContent(getter_AddRefs(content));
|
mOwner->GetContent(getter_AddRefs(content));
|
||||||
if (content)
|
if (content)
|
||||||
|
@ -3478,7 +3524,7 @@ nsPluginInstanceOwner::MouseOut(nsIDOMEvent* aMouseEvent)
|
||||||
nsresult nsPluginInstanceOwner::DispatchMouseToPlugin(nsIDOMEvent* aMouseEvent)
|
nsresult nsPluginInstanceOwner::DispatchMouseToPlugin(nsIDOMEvent* aMouseEvent)
|
||||||
{
|
{
|
||||||
#ifndef XP_MAC
|
#ifndef XP_MAC
|
||||||
if (nsPluginWindowType_Window == mPluginWindow.type)
|
if (!mPluginWindow || nsPluginWindowType_Window == mPluginWindow->type)
|
||||||
return NS_ERROR_FAILURE; // means consume event
|
return NS_ERROR_FAILURE; // means consume event
|
||||||
// continue only for cases without child window
|
// continue only for cases without child window
|
||||||
#endif
|
#endif
|
||||||
|
@ -3899,7 +3945,7 @@ nsPluginPort* nsPluginInstanceOwner::GetPluginPort()
|
||||||
if (mWidget != NULL)
|
if (mWidget != NULL)
|
||||||
{
|
{
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
if(mPluginWindow.type == nsPluginWindowType_Drawable)
|
if(mPluginWindow && mPluginWindow->type == nsPluginWindowType_Drawable)
|
||||||
result = (nsPluginPort*) mWidget->GetNativeData(NS_NATIVE_GRAPHIC);
|
result = (nsPluginPort*) mWidget->GetNativeData(NS_NATIVE_GRAPHIC);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
@ -3913,7 +3959,7 @@ void nsPluginInstanceOwner::ReleasePluginPort(nsPluginPort * pluginPort)
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
if (mWidget != NULL)
|
if (mWidget != NULL)
|
||||||
{
|
{
|
||||||
if(mPluginWindow.type == nsPluginWindowType_Drawable)
|
if(mPluginWindow && mPluginWindow->type == nsPluginWindowType_Drawable)
|
||||||
mWidget->FreeNativeData((HDC)pluginPort, NS_NATIVE_GRAPHIC);
|
mWidget->FreeNativeData((HDC)pluginPort, NS_NATIVE_GRAPHIC);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -3921,6 +3967,8 @@ void nsPluginInstanceOwner::ReleasePluginPort(nsPluginPort * pluginPort)
|
||||||
|
|
||||||
NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
|
NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
|
||||||
{
|
{
|
||||||
|
NS_ENSURE_TRUE(mPluginWindow, NS_ERROR_NULL_POINTER);
|
||||||
|
|
||||||
nsIView *view;
|
nsIView *view;
|
||||||
nsresult rv = NS_ERROR_FAILURE;
|
nsresult rv = NS_ERROR_FAILURE;
|
||||||
float p2t;
|
float p2t;
|
||||||
|
@ -3940,8 +3988,8 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
|
||||||
// always create widgets in Twips, not pixels
|
// always create widgets in Twips, not pixels
|
||||||
mContext->GetScaledPixelsToTwips(&p2t);
|
mContext->GetScaledPixelsToTwips(&p2t);
|
||||||
rv = mOwner->CreateWidget(mContext,
|
rv = mOwner->CreateWidget(mContext,
|
||||||
NSIntPixelsToTwips(mPluginWindow.width, p2t),
|
NSIntPixelsToTwips(mPluginWindow->width, p2t),
|
||||||
NSIntPixelsToTwips(mPluginWindow.height, p2t),
|
NSIntPixelsToTwips(mPluginWindow->height, p2t),
|
||||||
windowless);
|
windowless);
|
||||||
if (NS_OK == rv)
|
if (NS_OK == rv)
|
||||||
{
|
{
|
||||||
|
@ -3961,20 +4009,20 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
|
||||||
|
|
||||||
if (PR_TRUE == windowless)
|
if (PR_TRUE == windowless)
|
||||||
{
|
{
|
||||||
mPluginWindow.type = nsPluginWindowType_Drawable;
|
mPluginWindow->type = nsPluginWindowType_Drawable;
|
||||||
mPluginWindow.window = nsnull; // this needs to be a HDC according to the spec,
|
mPluginWindow->window = nsnull; // this needs to be a HDC according to the spec,
|
||||||
// but I do not see the right way to release it
|
// but I do not see the right way to release it
|
||||||
// so let's postpone passing HDC till paint event
|
// so let's postpone passing HDC till paint event
|
||||||
// when it is really needed. Change spec?
|
// when it is really needed. Change spec?
|
||||||
}
|
}
|
||||||
else if (mWidget)
|
else if (mWidget)
|
||||||
{
|
{
|
||||||
mWidget->Resize(mPluginWindow.width, mPluginWindow.height, PR_FALSE);
|
mWidget->Resize(mPluginWindow->width, mPluginWindow->height, PR_FALSE);
|
||||||
|
|
||||||
|
|
||||||
// mPluginWindow.type is used in |GetPluginPort| so it must be initilized first
|
// mPluginWindow->type is used in |GetPluginPort| so it must be initilized first
|
||||||
mPluginWindow.type = nsPluginWindowType_Window;
|
mPluginWindow->type = nsPluginWindowType_Window;
|
||||||
mPluginWindow.window = GetPluginPort();
|
mPluginWindow->window = GetPluginPort();
|
||||||
|
|
||||||
#if defined(XP_MAC)
|
#if defined(XP_MAC)
|
||||||
// Is this needed in the windowless case ???
|
// Is this needed in the windowless case ???
|
||||||
|
@ -4131,7 +4179,9 @@ inline PRUint16 COLOR8TOCOLOR16(PRUint8 color8)
|
||||||
|
|
||||||
void nsPluginInstanceOwner::FixUpPluginWindow()
|
void nsPluginInstanceOwner::FixUpPluginWindow()
|
||||||
{
|
{
|
||||||
if (mWidget) {
|
if (!mWidget || !mPluginWindow)
|
||||||
|
return;
|
||||||
|
|
||||||
nscoord absWidgetX = 0;
|
nscoord absWidgetX = 0;
|
||||||
nscoord absWidgetY = 0;
|
nscoord absWidgetY = 0;
|
||||||
nsRect widgetClip(0,0,0,0);
|
nsRect widgetClip(0,0,0,0);
|
||||||
|
@ -4149,14 +4199,14 @@ void nsPluginInstanceOwner::FixUpPluginWindow()
|
||||||
mWidgetVisible = isVisible;
|
mWidgetVisible = isVisible;
|
||||||
|
|
||||||
// set the port coordinates
|
// set the port coordinates
|
||||||
mPluginWindow.x = absWidgetX;
|
mPluginWindow->x = absWidgetX;
|
||||||
mPluginWindow.y = absWidgetY;
|
mPluginWindow->y = absWidgetY;
|
||||||
|
|
||||||
// fix up the clipping region
|
// fix up the clipping region
|
||||||
mPluginWindow.clipRect.top = widgetClip.y;
|
mPluginWindow->clipRect.top = widgetClip.y;
|
||||||
mPluginWindow.clipRect.left = widgetClip.x;
|
mPluginWindow->clipRect.left = widgetClip.x;
|
||||||
mPluginWindow.clipRect.bottom = mPluginWindow.clipRect.top + widgetClip.height;
|
mPluginWindow->clipRect.bottom = mPluginWindow->clipRect.top + widgetClip.height;
|
||||||
mPluginWindow.clipRect.right = mPluginWindow.clipRect.left + widgetClip.width;
|
mPluginWindow->clipRect.right = mPluginWindow->clipRect.left + widgetClip.width;
|
||||||
|
|
||||||
// the Mac widget doesn't set the background color right away!!
|
// the Mac widget doesn't set the background color right away!!
|
||||||
// the background color needs to be set here on the plugin port
|
// the background color needs to be set here on the plugin port
|
||||||
|
@ -4173,7 +4223,6 @@ void nsPluginInstanceOwner::FixUpPluginWindow()
|
||||||
::RGBBackColor(&macColor);
|
::RGBBackColor(&macColor);
|
||||||
::SetPort(savePort); // restore port
|
::SetPort(savePort); // restore port
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#endif // XP_MAC
|
#endif // XP_MAC
|
||||||
|
|
||||||
|
|
|
@ -128,6 +128,8 @@
|
||||||
|
|
||||||
#include "nsObjectFrame.h"
|
#include "nsObjectFrame.h"
|
||||||
#include "nsIObjectFrame.h"
|
#include "nsIObjectFrame.h"
|
||||||
|
#include "nsPluginNativeWindow.h"
|
||||||
|
#include "nsPIPluginHost.h"
|
||||||
|
|
||||||
// accessibility support
|
// accessibility support
|
||||||
#ifdef ACCESSIBILITY
|
#ifdef ACCESSIBILITY
|
||||||
|
@ -327,7 +329,7 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsPluginWindow mPluginWindow;
|
nsPluginNativeWindow *mPluginWindow;
|
||||||
nsIPluginInstance *mInstance;
|
nsIPluginInstance *mInstance;
|
||||||
nsObjectFrame *mOwner;
|
nsObjectFrame *mOwner;
|
||||||
nsCString mDocumentBase;
|
nsCString mDocumentBase;
|
||||||
|
@ -667,9 +669,14 @@ nsObjectFrame::Destroy(nsIPresContext* aPresContext)
|
||||||
// doing this in the destructor is too late.
|
// doing this in the destructor is too late.
|
||||||
if(mInstanceOwner != nsnull)
|
if(mInstanceOwner != nsnull)
|
||||||
{
|
{
|
||||||
nsIPluginInstance *inst;
|
nsCOMPtr<nsIPluginInstance> inst;
|
||||||
if(NS_OK == mInstanceOwner->GetInstance(inst))
|
if(NS_SUCCEEDED(mInstanceOwner->GetInstance(*getter_AddRefs(inst))))
|
||||||
{
|
{
|
||||||
|
nsPluginWindow *win;
|
||||||
|
mInstanceOwner->GetWindow(win);
|
||||||
|
nsPluginNativeWindow *window = (nsPluginNativeWindow *)win;
|
||||||
|
nsCOMPtr<nsIPluginInstance> nullinst;
|
||||||
|
|
||||||
PRBool doCache = PR_TRUE;
|
PRBool doCache = PR_TRUE;
|
||||||
PRBool doCallSetWindowAfterDestroy = PR_FALSE;
|
PRBool doCallSetWindowAfterDestroy = PR_FALSE;
|
||||||
|
|
||||||
|
@ -684,24 +691,34 @@ nsObjectFrame::Destroy(nsIPresContext* aPresContext)
|
||||||
if (doCallSetWindowAfterDestroy) {
|
if (doCallSetWindowAfterDestroy) {
|
||||||
inst->Stop();
|
inst->Stop();
|
||||||
inst->Destroy();
|
inst->Destroy();
|
||||||
|
|
||||||
|
if (window)
|
||||||
|
window->CallSetWindow(nullinst);
|
||||||
|
else
|
||||||
inst->SetWindow(nsnull);
|
inst->SetWindow(nsnull);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (window)
|
||||||
|
window->CallSetWindow(nullinst);
|
||||||
|
else
|
||||||
inst->SetWindow(nsnull);
|
inst->SetWindow(nsnull);
|
||||||
|
|
||||||
inst->Stop();
|
inst->Stop();
|
||||||
inst->Destroy();
|
inst->Destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (window)
|
||||||
|
window->CallSetWindow(nullinst);
|
||||||
|
else
|
||||||
inst->SetWindow(nsnull);
|
inst->SetWindow(nsnull);
|
||||||
|
|
||||||
inst->Stop();
|
inst->Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIPluginHost> pluginHost = do_GetService(kCPluginManagerCID);
|
nsCOMPtr<nsIPluginHost> pluginHost = do_GetService(kCPluginManagerCID);
|
||||||
if(pluginHost)
|
if(pluginHost)
|
||||||
pluginHost->StopPluginInstance(inst);
|
pluginHost->StopPluginInstance(inst);
|
||||||
|
|
||||||
NS_RELEASE(inst);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nsObjectFrameSuper::Destroy(aPresContext);
|
return nsObjectFrameSuper::Destroy(aPresContext);
|
||||||
|
@ -1243,6 +1260,8 @@ nsObjectFrame::InstantiatePlugin(nsIPresContext* aPresContext,
|
||||||
|
|
||||||
mInstanceOwner->GetWindow(window);
|
mInstanceOwner->GetWindow(window);
|
||||||
|
|
||||||
|
NS_ENSURE_TRUE(window, NS_ERROR_NULL_POINTER);
|
||||||
|
|
||||||
GetOffsetFromView(aPresContext, origin, &parentWithView);
|
GetOffsetFromView(aPresContext, origin, &parentWithView);
|
||||||
window->x = NSTwipsToIntPixels(origin.x, t2p);
|
window->x = NSTwipsToIntPixels(origin.x, t2p);
|
||||||
window->y = NSTwipsToIntPixels(origin.y, t2p);
|
window->y = NSTwipsToIntPixels(origin.y, t2p);
|
||||||
|
@ -1528,16 +1547,18 @@ nsObjectFrame::DidReflow(nsIPresContext* aPresContext,
|
||||||
vm->SetViewVisibility(view, bHidden ? nsViewVisibility_kHide : nsViewVisibility_kShow);
|
vm->SetViewVisibility(view, bHidden ? nsViewVisibility_kHide : nsViewVisibility_kShow);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsPluginWindow *window;
|
nsPluginWindow *win = nsnull;
|
||||||
|
|
||||||
nsCOMPtr<nsIPluginInstance> pi;
|
nsCOMPtr<nsIPluginInstance> pi;
|
||||||
if (!mInstanceOwner ||
|
if (!mInstanceOwner ||
|
||||||
NS_FAILED(rv = mInstanceOwner->GetWindow(window)) ||
|
NS_FAILED(rv = mInstanceOwner->GetWindow(win)) ||
|
||||||
NS_FAILED(rv = mInstanceOwner->GetInstance(*getter_AddRefs(pi))) ||
|
NS_FAILED(rv = mInstanceOwner->GetInstance(*getter_AddRefs(pi))) ||
|
||||||
!pi ||
|
!pi ||
|
||||||
!window)
|
!win)
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
|
nsPluginNativeWindow *window = (nsPluginNativeWindow *)win;
|
||||||
|
|
||||||
#ifdef XP_MAC
|
#ifdef XP_MAC
|
||||||
mInstanceOwner->FixUpPluginWindow();
|
mInstanceOwner->FixUpPluginWindow();
|
||||||
#endif // XP_MAC
|
#endif // XP_MAC
|
||||||
|
@ -1557,7 +1578,11 @@ nsObjectFrame::DidReflow(nsIPresContext* aPresContext,
|
||||||
|
|
||||||
// refresh the plugin port as well
|
// refresh the plugin port as well
|
||||||
window->window = mInstanceOwner->GetPluginPort();
|
window->window = mInstanceOwner->GetPluginPort();
|
||||||
pi->SetWindow(window);
|
|
||||||
|
// this will call pi->SetWindow and take care of window subclassing
|
||||||
|
// if needed, see bug 132759
|
||||||
|
window->CallSetWindow(pi);
|
||||||
|
|
||||||
mInstanceOwner->ReleasePluginPort((nsPluginPort *)window->window);
|
mInstanceOwner->ReleasePluginPort((nsPluginPort *)window->window);
|
||||||
|
|
||||||
if (mWidget) {
|
if (mWidget) {
|
||||||
|
@ -2091,7 +2116,15 @@ nsPluginInstanceOwner::nsPluginInstanceOwner()
|
||||||
{
|
{
|
||||||
NS_INIT_ISUPPORTS();
|
NS_INIT_ISUPPORTS();
|
||||||
|
|
||||||
memset(&mPluginWindow, 0, sizeof(mPluginWindow));
|
// create nsPluginNativeWindow object, it is derived from nsPluginWindow
|
||||||
|
// struct and allows to manipulate native window procedure
|
||||||
|
nsCOMPtr<nsIPluginHost> ph = do_GetService(kCPluginManagerCID);
|
||||||
|
nsCOMPtr<nsPIPluginHost> pph(do_QueryInterface(ph));
|
||||||
|
if (pph)
|
||||||
|
pph->NewPluginNativeWindow(&mPluginWindow);
|
||||||
|
else
|
||||||
|
mPluginWindow = nsnull;
|
||||||
|
|
||||||
mInstance = nsnull;
|
mInstance = nsnull;
|
||||||
mOwner = nsnull;
|
mOwner = nsnull;
|
||||||
mWidget = nsnull;
|
mWidget = nsnull;
|
||||||
|
@ -2152,11 +2185,19 @@ nsPluginInstanceOwner::~nsPluginInstanceOwner()
|
||||||
#ifdef XP_UNIX
|
#ifdef XP_UNIX
|
||||||
// the mem for this struct is allocated
|
// the mem for this struct is allocated
|
||||||
// by PR_MALLOC in ns4xPluginInstance.cpp:ns4xPluginInstance::SetWindow()
|
// by PR_MALLOC in ns4xPluginInstance.cpp:ns4xPluginInstance::SetWindow()
|
||||||
if (mPluginWindow.ws_info) {
|
if (mPluginWindow && mPluginWindow->ws_info) {
|
||||||
PR_Free(mPluginWindow.ws_info);
|
PR_Free(mPluginWindow->ws_info);
|
||||||
mPluginWindow.ws_info = nsnull;
|
mPluginWindow->ws_info = nsnull;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// clean up plugin native window object
|
||||||
|
nsCOMPtr<nsIPluginHost> ph = do_GetService(kCPluginManagerCID);
|
||||||
|
nsCOMPtr<nsPIPluginHost> pph(do_QueryInterface(ph));
|
||||||
|
if (pph) {
|
||||||
|
pph->DeletePluginNativeWindow(mPluginWindow);
|
||||||
|
mPluginWindow = nsnull;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2193,7 +2234,8 @@ NS_IMETHODIMP nsPluginInstanceOwner::SetInstance(nsIPluginInstance *aInstance)
|
||||||
|
|
||||||
NS_IMETHODIMP nsPluginInstanceOwner::GetWindow(nsPluginWindow *&aWindow)
|
NS_IMETHODIMP nsPluginInstanceOwner::GetWindow(nsPluginWindow *&aWindow)
|
||||||
{
|
{
|
||||||
aWindow = &mPluginWindow;
|
NS_ASSERTION(mPluginWindow, "the plugin window object being returned is null");
|
||||||
|
aWindow = mPluginWindow;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2746,7 +2788,9 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetWidth(PRUint32 *result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(result);
|
NS_ENSURE_ARG_POINTER(result);
|
||||||
|
|
||||||
*result = mPluginWindow.width;
|
NS_ENSURE_TRUE(mPluginWindow, NS_ERROR_NULL_POINTER);
|
||||||
|
|
||||||
|
*result = mPluginWindow->width;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -2755,7 +2799,9 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetHeight(PRUint32 *result)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(result);
|
NS_ENSURE_ARG_POINTER(result);
|
||||||
|
|
||||||
*result = mPluginWindow.height;
|
NS_ENSURE_TRUE(mPluginWindow, NS_ERROR_NULL_POINTER);
|
||||||
|
|
||||||
|
*result = mPluginWindow->height;
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -3190,7 +3236,7 @@ nsresult nsPluginInstanceOwner::Blur(nsIDOMEvent * aFocusEvent)
|
||||||
nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent)
|
nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent)
|
||||||
{
|
{
|
||||||
#ifndef XP_MAC
|
#ifndef XP_MAC
|
||||||
if (nsPluginWindowType_Window == mPluginWindow.type)
|
if (!mPluginWindow || nsPluginWindowType_Window == mPluginWindow->type)
|
||||||
return NS_ERROR_FAILURE; // means consume event
|
return NS_ERROR_FAILURE; // means consume event
|
||||||
// continue only for cases without child window
|
// continue only for cases without child window
|
||||||
#endif
|
#endif
|
||||||
|
@ -3344,7 +3390,7 @@ nsresult nsPluginInstanceOwner::KeyPress(nsIDOMEvent* aKeyEvent)
|
||||||
nsresult nsPluginInstanceOwner::DispatchKeyToPlugin(nsIDOMEvent* aKeyEvent)
|
nsresult nsPluginInstanceOwner::DispatchKeyToPlugin(nsIDOMEvent* aKeyEvent)
|
||||||
{
|
{
|
||||||
#ifndef XP_MAC
|
#ifndef XP_MAC
|
||||||
if (nsPluginWindowType_Window == mPluginWindow.type)
|
if (!mPluginWindow || nsPluginWindowType_Window == mPluginWindow->type)
|
||||||
return NS_ERROR_FAILURE; // means consume event
|
return NS_ERROR_FAILURE; // means consume event
|
||||||
// continue only for cases without child window
|
// continue only for cases without child window
|
||||||
#endif
|
#endif
|
||||||
|
@ -3382,7 +3428,7 @@ nsresult
|
||||||
nsPluginInstanceOwner::MouseMove(nsIDOMEvent* aMouseEvent)
|
nsPluginInstanceOwner::MouseMove(nsIDOMEvent* aMouseEvent)
|
||||||
{
|
{
|
||||||
#ifndef XP_MAC
|
#ifndef XP_MAC
|
||||||
if (nsPluginWindowType_Window == mPluginWindow.type)
|
if (!mPluginWindow || nsPluginWindowType_Window == mPluginWindow->type)
|
||||||
return NS_ERROR_FAILURE; // means consume event
|
return NS_ERROR_FAILURE; // means consume event
|
||||||
// continue only for cases without child window
|
// continue only for cases without child window
|
||||||
#endif
|
#endif
|
||||||
|
@ -3414,14 +3460,14 @@ nsresult
|
||||||
nsPluginInstanceOwner::MouseDown(nsIDOMEvent* aMouseEvent)
|
nsPluginInstanceOwner::MouseDown(nsIDOMEvent* aMouseEvent)
|
||||||
{
|
{
|
||||||
#ifndef XP_MAC
|
#ifndef XP_MAC
|
||||||
if (nsPluginWindowType_Window == mPluginWindow.type)
|
if (!mPluginWindow || nsPluginWindowType_Window == mPluginWindow->type)
|
||||||
return NS_ERROR_FAILURE; // means consume event
|
return NS_ERROR_FAILURE; // means consume event
|
||||||
// continue only for cases without child window
|
// continue only for cases without child window
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// if the plugin is windowless, we need to set focus ourselves
|
// if the plugin is windowless, we need to set focus ourselves
|
||||||
// otherwise, we might not get key events
|
// otherwise, we might not get key events
|
||||||
if (mPluginWindow.type == nsPluginWindowType_Drawable) {
|
if (mPluginWindow && mPluginWindow->type == nsPluginWindowType_Drawable) {
|
||||||
nsCOMPtr<nsIContent> content;
|
nsCOMPtr<nsIContent> content;
|
||||||
mOwner->GetContent(getter_AddRefs(content));
|
mOwner->GetContent(getter_AddRefs(content));
|
||||||
if (content)
|
if (content)
|
||||||
|
@ -3478,7 +3524,7 @@ nsPluginInstanceOwner::MouseOut(nsIDOMEvent* aMouseEvent)
|
||||||
nsresult nsPluginInstanceOwner::DispatchMouseToPlugin(nsIDOMEvent* aMouseEvent)
|
nsresult nsPluginInstanceOwner::DispatchMouseToPlugin(nsIDOMEvent* aMouseEvent)
|
||||||
{
|
{
|
||||||
#ifndef XP_MAC
|
#ifndef XP_MAC
|
||||||
if (nsPluginWindowType_Window == mPluginWindow.type)
|
if (!mPluginWindow || nsPluginWindowType_Window == mPluginWindow->type)
|
||||||
return NS_ERROR_FAILURE; // means consume event
|
return NS_ERROR_FAILURE; // means consume event
|
||||||
// continue only for cases without child window
|
// continue only for cases without child window
|
||||||
#endif
|
#endif
|
||||||
|
@ -3899,7 +3945,7 @@ nsPluginPort* nsPluginInstanceOwner::GetPluginPort()
|
||||||
if (mWidget != NULL)
|
if (mWidget != NULL)
|
||||||
{
|
{
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
if(mPluginWindow.type == nsPluginWindowType_Drawable)
|
if(mPluginWindow && mPluginWindow->type == nsPluginWindowType_Drawable)
|
||||||
result = (nsPluginPort*) mWidget->GetNativeData(NS_NATIVE_GRAPHIC);
|
result = (nsPluginPort*) mWidget->GetNativeData(NS_NATIVE_GRAPHIC);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
@ -3913,7 +3959,7 @@ void nsPluginInstanceOwner::ReleasePluginPort(nsPluginPort * pluginPort)
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
if (mWidget != NULL)
|
if (mWidget != NULL)
|
||||||
{
|
{
|
||||||
if(mPluginWindow.type == nsPluginWindowType_Drawable)
|
if(mPluginWindow && mPluginWindow->type == nsPluginWindowType_Drawable)
|
||||||
mWidget->FreeNativeData((HDC)pluginPort, NS_NATIVE_GRAPHIC);
|
mWidget->FreeNativeData((HDC)pluginPort, NS_NATIVE_GRAPHIC);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -3921,6 +3967,8 @@ void nsPluginInstanceOwner::ReleasePluginPort(nsPluginPort * pluginPort)
|
||||||
|
|
||||||
NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
|
NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
|
||||||
{
|
{
|
||||||
|
NS_ENSURE_TRUE(mPluginWindow, NS_ERROR_NULL_POINTER);
|
||||||
|
|
||||||
nsIView *view;
|
nsIView *view;
|
||||||
nsresult rv = NS_ERROR_FAILURE;
|
nsresult rv = NS_ERROR_FAILURE;
|
||||||
float p2t;
|
float p2t;
|
||||||
|
@ -3940,8 +3988,8 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
|
||||||
// always create widgets in Twips, not pixels
|
// always create widgets in Twips, not pixels
|
||||||
mContext->GetScaledPixelsToTwips(&p2t);
|
mContext->GetScaledPixelsToTwips(&p2t);
|
||||||
rv = mOwner->CreateWidget(mContext,
|
rv = mOwner->CreateWidget(mContext,
|
||||||
NSIntPixelsToTwips(mPluginWindow.width, p2t),
|
NSIntPixelsToTwips(mPluginWindow->width, p2t),
|
||||||
NSIntPixelsToTwips(mPluginWindow.height, p2t),
|
NSIntPixelsToTwips(mPluginWindow->height, p2t),
|
||||||
windowless);
|
windowless);
|
||||||
if (NS_OK == rv)
|
if (NS_OK == rv)
|
||||||
{
|
{
|
||||||
|
@ -3961,20 +4009,20 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
|
||||||
|
|
||||||
if (PR_TRUE == windowless)
|
if (PR_TRUE == windowless)
|
||||||
{
|
{
|
||||||
mPluginWindow.type = nsPluginWindowType_Drawable;
|
mPluginWindow->type = nsPluginWindowType_Drawable;
|
||||||
mPluginWindow.window = nsnull; // this needs to be a HDC according to the spec,
|
mPluginWindow->window = nsnull; // this needs to be a HDC according to the spec,
|
||||||
// but I do not see the right way to release it
|
// but I do not see the right way to release it
|
||||||
// so let's postpone passing HDC till paint event
|
// so let's postpone passing HDC till paint event
|
||||||
// when it is really needed. Change spec?
|
// when it is really needed. Change spec?
|
||||||
}
|
}
|
||||||
else if (mWidget)
|
else if (mWidget)
|
||||||
{
|
{
|
||||||
mWidget->Resize(mPluginWindow.width, mPluginWindow.height, PR_FALSE);
|
mWidget->Resize(mPluginWindow->width, mPluginWindow->height, PR_FALSE);
|
||||||
|
|
||||||
|
|
||||||
// mPluginWindow.type is used in |GetPluginPort| so it must be initilized first
|
// mPluginWindow->type is used in |GetPluginPort| so it must be initilized first
|
||||||
mPluginWindow.type = nsPluginWindowType_Window;
|
mPluginWindow->type = nsPluginWindowType_Window;
|
||||||
mPluginWindow.window = GetPluginPort();
|
mPluginWindow->window = GetPluginPort();
|
||||||
|
|
||||||
#if defined(XP_MAC)
|
#if defined(XP_MAC)
|
||||||
// Is this needed in the windowless case ???
|
// Is this needed in the windowless case ???
|
||||||
|
@ -4131,7 +4179,9 @@ inline PRUint16 COLOR8TOCOLOR16(PRUint8 color8)
|
||||||
|
|
||||||
void nsPluginInstanceOwner::FixUpPluginWindow()
|
void nsPluginInstanceOwner::FixUpPluginWindow()
|
||||||
{
|
{
|
||||||
if (mWidget) {
|
if (!mWidget || !mPluginWindow)
|
||||||
|
return;
|
||||||
|
|
||||||
nscoord absWidgetX = 0;
|
nscoord absWidgetX = 0;
|
||||||
nscoord absWidgetY = 0;
|
nscoord absWidgetY = 0;
|
||||||
nsRect widgetClip(0,0,0,0);
|
nsRect widgetClip(0,0,0,0);
|
||||||
|
@ -4149,14 +4199,14 @@ void nsPluginInstanceOwner::FixUpPluginWindow()
|
||||||
mWidgetVisible = isVisible;
|
mWidgetVisible = isVisible;
|
||||||
|
|
||||||
// set the port coordinates
|
// set the port coordinates
|
||||||
mPluginWindow.x = absWidgetX;
|
mPluginWindow->x = absWidgetX;
|
||||||
mPluginWindow.y = absWidgetY;
|
mPluginWindow->y = absWidgetY;
|
||||||
|
|
||||||
// fix up the clipping region
|
// fix up the clipping region
|
||||||
mPluginWindow.clipRect.top = widgetClip.y;
|
mPluginWindow->clipRect.top = widgetClip.y;
|
||||||
mPluginWindow.clipRect.left = widgetClip.x;
|
mPluginWindow->clipRect.left = widgetClip.x;
|
||||||
mPluginWindow.clipRect.bottom = mPluginWindow.clipRect.top + widgetClip.height;
|
mPluginWindow->clipRect.bottom = mPluginWindow->clipRect.top + widgetClip.height;
|
||||||
mPluginWindow.clipRect.right = mPluginWindow.clipRect.left + widgetClip.width;
|
mPluginWindow->clipRect.right = mPluginWindow->clipRect.left + widgetClip.width;
|
||||||
|
|
||||||
// the Mac widget doesn't set the background color right away!!
|
// the Mac widget doesn't set the background color right away!!
|
||||||
// the background color needs to be set here on the plugin port
|
// the background color needs to be set here on the plugin port
|
||||||
|
@ -4173,7 +4223,6 @@ void nsPluginInstanceOwner::FixUpPluginWindow()
|
||||||
::RGBBackColor(&macColor);
|
::RGBBackColor(&macColor);
|
||||||
::SetPort(savePort); // restore port
|
::SetPort(savePort); // restore port
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#endif // XP_MAC
|
#endif // XP_MAC
|
||||||
|
|
||||||
|
|
|
@ -987,6 +987,13 @@
|
||||||
<FILEKIND>Text</FILEKIND>
|
<FILEKIND>Text</FILEKIND>
|
||||||
<FILEFLAGS>Debug</FILEFLAGS>
|
<FILEFLAGS>Debug</FILEFLAGS>
|
||||||
</FILE>
|
</FILE>
|
||||||
|
<FILE>
|
||||||
|
<PATHTYPE>Name</PATHTYPE>
|
||||||
|
<PATH>nsPluginNativeWindow.cpp</PATH>
|
||||||
|
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||||
|
<FILEKIND>Text</FILEKIND>
|
||||||
|
<FILEFLAGS>Debug</FILEFLAGS>
|
||||||
|
</FILE>
|
||||||
<FILE>
|
<FILE>
|
||||||
<PATHTYPE>Name</PATHTYPE>
|
<PATHTYPE>Name</PATHTYPE>
|
||||||
<PATH>nsPluginDocLoaderFactory.cpp</PATH>
|
<PATH>nsPluginDocLoaderFactory.cpp</PATH>
|
||||||
|
@ -1098,6 +1105,11 @@
|
||||||
<PATH>nsPluginsDirMac.cpp</PATH>
|
<PATH>nsPluginsDirMac.cpp</PATH>
|
||||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||||
</FILEREF>
|
</FILEREF>
|
||||||
|
<FILEREF>
|
||||||
|
<PATHTYPE>Name</PATHTYPE>
|
||||||
|
<PATH>nsPluginNativeWindow.cpp</PATH>
|
||||||
|
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||||
|
</FILEREF>
|
||||||
<FILEREF>
|
<FILEREF>
|
||||||
<PATHTYPE>Name</PATHTYPE>
|
<PATHTYPE>Name</PATHTYPE>
|
||||||
<PATH>nsPluginDirServiceProvider.cpp</PATH>
|
<PATH>nsPluginDirServiceProvider.cpp</PATH>
|
||||||
|
@ -2064,6 +2076,13 @@
|
||||||
<FILEKIND>Text</FILEKIND>
|
<FILEKIND>Text</FILEKIND>
|
||||||
<FILEFLAGS>Debug</FILEFLAGS>
|
<FILEFLAGS>Debug</FILEFLAGS>
|
||||||
</FILE>
|
</FILE>
|
||||||
|
<FILE>
|
||||||
|
<PATHTYPE>Name</PATHTYPE>
|
||||||
|
<PATH>nsPluginNativeWindow.cpp</PATH>
|
||||||
|
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||||
|
<FILEKIND>Text</FILEKIND>
|
||||||
|
<FILEFLAGS>Debug</FILEFLAGS>
|
||||||
|
</FILE>
|
||||||
<FILE>
|
<FILE>
|
||||||
<PATHTYPE>Name</PATHTYPE>
|
<PATHTYPE>Name</PATHTYPE>
|
||||||
<PATH>nsPluginDocLoaderFactory.cpp</PATH>
|
<PATH>nsPluginDocLoaderFactory.cpp</PATH>
|
||||||
|
@ -2175,6 +2194,11 @@
|
||||||
<PATH>nsPluginsDirMac.cpp</PATH>
|
<PATH>nsPluginsDirMac.cpp</PATH>
|
||||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||||
</FILEREF>
|
</FILEREF>
|
||||||
|
<FILEREF>
|
||||||
|
<PATHTYPE>Name</PATHTYPE>
|
||||||
|
<PATH>nsPluginNativeWindow.cpp</PATH>
|
||||||
|
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||||
|
</FILEREF>
|
||||||
<FILEREF>
|
<FILEREF>
|
||||||
<PATHTYPE>Name</PATHTYPE>
|
<PATHTYPE>Name</PATHTYPE>
|
||||||
<PATH>nsPluginDirServiceProvider.cpp</PATH>
|
<PATH>nsPluginDirServiceProvider.cpp</PATH>
|
||||||
|
@ -2260,6 +2284,12 @@
|
||||||
<PATH>nsPluginsDirMac.cpp</PATH>
|
<PATH>nsPluginsDirMac.cpp</PATH>
|
||||||
<PATHFORMAT>MacOS</PATHFORMAT>
|
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||||
</FILEREF>
|
</FILEREF>
|
||||||
|
<FILEREF>
|
||||||
|
<TARGETNAME>pluginDebug.shlb</TARGETNAME>
|
||||||
|
<PATHTYPE>Name</PATHTYPE>
|
||||||
|
<PATH>nsPluginNativeWindow.cpp</PATH>
|
||||||
|
<PATHFORMAT>MacOS</PATHFORMAT>
|
||||||
|
</FILEREF>
|
||||||
<FILEREF>
|
<FILEREF>
|
||||||
<TARGETNAME>pluginDebug.shlb</TARGETNAME>
|
<TARGETNAME>pluginDebug.shlb</TARGETNAME>
|
||||||
<PATHTYPE>Name</PATHTYPE>
|
<PATHTYPE>Name</PATHTYPE>
|
||||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -55,3 +55,4 @@ npapi.h
|
||||||
npupp.h
|
npupp.h
|
||||||
nsDefaultPlugin.h
|
nsDefaultPlugin.h
|
||||||
nsPIPluginInstancePeer.h
|
nsPIPluginInstancePeer.h
|
||||||
|
nsPluginNativeWindow.h
|
||||||
|
|
|
@ -57,6 +57,7 @@ EXPORTS = \
|
||||||
nsPluginError.h \
|
nsPluginError.h \
|
||||||
nsDefaultPlugin.h \
|
nsDefaultPlugin.h \
|
||||||
nsPIPluginInstancePeer.h \
|
nsPIPluginInstancePeer.h \
|
||||||
|
nsPluginNativeWindow.h \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
# 4.x headers moved from mozilla/include
|
# 4.x headers moved from mozilla/include
|
||||||
|
|
|
@ -1,94 +0,0 @@
|
||||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
||||||
/* ***** BEGIN LICENSE BLOCK *****
|
|
||||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the Netscape Public License
|
|
||||||
* Version 1.1 (the "License"); you may not use this file except in
|
|
||||||
* compliance with the License. You may obtain a copy of the License at
|
|
||||||
* http://www.mozilla.org/NPL/
|
|
||||||
*
|
|
||||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
||||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
||||||
* for the specific language governing rights and limitations under the
|
|
||||||
* License.
|
|
||||||
*
|
|
||||||
* The Original Code is mozilla.org code.
|
|
||||||
*
|
|
||||||
* The Initial Developer of the Original Code is
|
|
||||||
* Netscape Communications Corporation.
|
|
||||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
||||||
* the Initial Developer. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Contributor(s):
|
|
||||||
*
|
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
|
||||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
||||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
||||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
||||||
* of those above. If you wish to allow use of your version of this file only
|
|
||||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
||||||
* use your version of this file under the terms of the NPL, indicate your
|
|
||||||
* decision by deleting the provisions above and replace them with the notice
|
|
||||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
||||||
* the provisions above, a recipient may use your version of this file under
|
|
||||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
|
||||||
|
|
||||||
#ifndef nsPIPluginHost_h___
|
|
||||||
#define nsPIPluginHost_h___
|
|
||||||
|
|
||||||
#include "nsIPluginInstance.h"
|
|
||||||
|
|
||||||
#define NS_PIPLUGINHOST_IID \
|
|
||||||
{/* 8e3d71e6-2319-11d5-9cf8-0060b0fbd8ac */ \
|
|
||||||
0x8e3d71e6, 0x2319, 0x11d5, \
|
|
||||||
{0x9c, 0xf8, 0x00, 0x60, 0xb0, 0xfb, 0xd8, 0xac} \
|
|
||||||
}
|
|
||||||
|
|
||||||
class nsPIPluginHost : public nsISupports
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_PIPLUGINHOST_IID)
|
|
||||||
|
|
||||||
/*
|
|
||||||
* To notify the plugin manager that the plugin created a script object
|
|
||||||
*/
|
|
||||||
NS_IMETHOD
|
|
||||||
SetIsScriptableInstance(nsCOMPtr<nsIPluginInstance> aPluginInstance, PRBool aScriptable) = 0;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method parses post buffer to find out case insensitive "Content-length" string
|
|
||||||
* and CR or LF some where after that, then it assumes there is http headers in
|
|
||||||
* the input buffer and continue to search for end of headers (CRLFCRLF or LFLF).
|
|
||||||
* It will *always malloc()* output buffer (caller is responsible to free it)
|
|
||||||
* if input buffer starts with LF, which comes from 4.x spec
|
|
||||||
* http://developer.netscape.com/docs/manuals/communicator/plugin/pgfn2.htm#1007754
|
|
||||||
* "If no custom headers are required, simply add a blank
|
|
||||||
* line ('\n') to the beginning of the file or buffer.",
|
|
||||||
* it skips that '\n' and considers rest of the input buffer as data.
|
|
||||||
* If "Content-length" string and end of headers is found
|
|
||||||
* it substitutes single LF with CRLF in the headers, so the end of headers
|
|
||||||
* always will be CRLFCRLF (single CR in headers, if any, remain untouched)
|
|
||||||
* else
|
|
||||||
* it puts "Content-length: "+size_of_data+CRLFCRLF at the beginning of the output buffer
|
|
||||||
* and memcpy data to the output buffer
|
|
||||||
*
|
|
||||||
* On failure outPostData and outPostDataLen will be set in 0.
|
|
||||||
* @param inPostData, the post data
|
|
||||||
* @param the length of inPostData
|
|
||||||
* @param outPostData the buffer.
|
|
||||||
* @param outPostDataLen the length of outPostData
|
|
||||||
**/
|
|
||||||
NS_IMETHOD
|
|
||||||
ParsePostBufferToFixHeaders(const char *inPostData, PRUint32 inPostDataLen,
|
|
||||||
char **outPostData, PRUint32 *outPostDataLen) = 0;
|
|
||||||
/*
|
|
||||||
* To create tmp file with Content len header in, it will use by http POST
|
|
||||||
*/
|
|
||||||
NS_IMETHOD
|
|
||||||
CreateTmpFileToPost(const char *postDataURL, char **pTmpFileName) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* nsPIPluginHost_h___ */
|
|
|
@ -73,14 +73,18 @@ CPPSRCS = \
|
||||||
|
|
||||||
ifeq ($(OS_ARCH), BeOS)
|
ifeq ($(OS_ARCH), BeOS)
|
||||||
CPPSRCS += nsPluginsDirBeOS.cpp
|
CPPSRCS += nsPluginsDirBeOS.cpp
|
||||||
|
CPPSRCS += nsPluginNativeWindow.cpp
|
||||||
else
|
else
|
||||||
ifeq ($(OS_ARCH),WINNT)
|
ifeq ($(OS_ARCH),WINNT)
|
||||||
CPPSRCS += nsPluginsDirWin.cpp
|
CPPSRCS += nsPluginsDirWin.cpp
|
||||||
|
CPPSRCS += nsPluginNativeWindowWin.cpp
|
||||||
else
|
else
|
||||||
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
|
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
|
||||||
CPPSRCS += nsPluginsDirOS2.cpp
|
CPPSRCS += nsPluginsDirOS2.cpp
|
||||||
|
CPPSRCS += nsPluginNativeWindow.cpp
|
||||||
else
|
else
|
||||||
CPPSRCS += nsPluginsDirUnix.cpp
|
CPPSRCS += nsPluginsDirUnix.cpp
|
||||||
|
CPPSRCS += nsPluginNativeWindow.cpp
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -163,6 +163,7 @@
|
||||||
#include "nsIWebNavigation.h"
|
#include "nsIWebNavigation.h"
|
||||||
#include "nsISupportsArray.h"
|
#include "nsISupportsArray.h"
|
||||||
#include "nsIDocShell.h"
|
#include "nsIDocShell.h"
|
||||||
|
#include "nsPluginNativeWindow.h"
|
||||||
|
|
||||||
#ifdef XP_UNIX
|
#ifdef XP_UNIX
|
||||||
#if defined(MOZ_WIDGET_GTK) || defined (MOZ_WIDGET_GTK2)
|
#if defined(MOZ_WIDGET_GTK) || defined (MOZ_WIDGET_GTK2)
|
||||||
|
@ -3624,28 +3625,27 @@ NS_IMETHODIMP nsPluginHostImpl::InstantiateFullPagePlugin(const char *aMimeType,
|
||||||
|
|
||||||
if (NS_OK == rv)
|
if (NS_OK == rv)
|
||||||
{
|
{
|
||||||
nsIPluginInstance *instance = nsnull;
|
nsCOMPtr<nsIPluginInstance> instance;
|
||||||
nsPluginWindow *window = nsnull;
|
nsPluginWindow * win = nsnull;
|
||||||
|
|
||||||
aOwner->GetInstance(instance);
|
aOwner->GetInstance(*getter_AddRefs(instance));
|
||||||
aOwner->GetWindow(window);
|
aOwner->GetWindow(win);
|
||||||
|
|
||||||
if (nsnull != instance)
|
if (win && instance)
|
||||||
{
|
{
|
||||||
instance->Start();
|
instance->Start();
|
||||||
aOwner->CreateWidget();
|
aOwner->CreateWidget();
|
||||||
|
|
||||||
// If we've got a native window, the let the plugin know about it.
|
// If we've got a native window, the let the plugin know about it.
|
||||||
|
nsPluginNativeWindow * window = (nsPluginNativeWindow *)win;
|
||||||
if (window->window)
|
if (window->window)
|
||||||
instance->SetWindow(window);
|
window->CallSetWindow(instance);
|
||||||
|
|
||||||
rv = NewFullPagePluginStream(aStreamListener, instance);
|
rv = NewFullPagePluginStream(aStreamListener, instance);
|
||||||
|
|
||||||
// If we've got a native window, the let the plugin know about it.
|
// If we've got a native window, the let the plugin know about it.
|
||||||
if (window->window)
|
if (window->window)
|
||||||
instance->SetWindow(window);
|
window->CallSetWindow(instance);
|
||||||
|
|
||||||
NS_RELEASE(instance);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6034,8 +6034,13 @@ NS_IMETHODIMP nsPluginHostImpl::Observe(nsISupports *aSubject,
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
NS_IMETHODIMP nsPluginHostImpl::HandleBadPlugin(PRLibrary* aLibrary, nsIPluginInstance *instance)
|
NS_IMETHODIMP
|
||||||
|
nsPluginHostImpl::HandleBadPlugin(PRLibrary* aLibrary, nsIPluginInstance *aInstance)
|
||||||
{
|
{
|
||||||
|
// the |aLibrary| parameter is not needed anymore, after we added |aInstance| which
|
||||||
|
// can also be used to look up the plugin name, but we cannot get rid of it because
|
||||||
|
// the |nsIPluginHost| interface is deprecated which in fact means 'frozen'
|
||||||
|
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
NS_ASSERTION(PR_FALSE, "Plugin performed illegal operation");
|
NS_ASSERTION(PR_FALSE, "Plugin performed illegal operation");
|
||||||
|
@ -6045,9 +6050,9 @@ NS_IMETHODIMP nsPluginHostImpl::HandleBadPlugin(PRLibrary* aLibrary, nsIPluginIn
|
||||||
|
|
||||||
nsCOMPtr<nsIPluginInstanceOwner> owner;
|
nsCOMPtr<nsIPluginInstanceOwner> owner;
|
||||||
|
|
||||||
if (instance) {
|
if (aInstance) {
|
||||||
nsCOMPtr<nsIPluginInstancePeer> peer;
|
nsCOMPtr<nsIPluginInstancePeer> peer;
|
||||||
rv =instance->GetPeer(getter_AddRefs(peer));
|
rv = aInstance->GetPeer(getter_AddRefs(peer));
|
||||||
if (NS_SUCCEEDED(rv) && peer) {
|
if (NS_SUCCEEDED(rv) && peer) {
|
||||||
nsCOMPtr<nsPIPluginInstancePeer> privpeer(do_QueryInterface(peer));
|
nsCOMPtr<nsPIPluginInstancePeer> privpeer(do_QueryInterface(peer));
|
||||||
privpeer->GetOwner(getter_AddRefs(owner));
|
privpeer->GetOwner(getter_AddRefs(owner));
|
||||||
|
@ -6081,8 +6086,10 @@ NS_IMETHODIMP nsPluginHostImpl::HandleBadPlugin(PRLibrary* aLibrary, nsIPluginIn
|
||||||
|
|
||||||
// add plugin name to the message
|
// add plugin name to the message
|
||||||
char * pluginname = nsnull;
|
char * pluginname = nsnull;
|
||||||
for (nsPluginTag * tag = mPlugins; tag; tag = tag->mNext) {
|
nsActivePlugin * p = mActivePluginList.find(aInstance);
|
||||||
if (tag->mLibrary == aLibrary) {
|
if (p) {
|
||||||
|
nsPluginTag * tag = p->mPluginTag;
|
||||||
|
if (tag) {
|
||||||
if (tag->mName)
|
if (tag->mName)
|
||||||
pluginname = tag->mName;
|
pluginname = tag->mName;
|
||||||
else
|
else
|
||||||
|
@ -6110,9 +6117,10 @@ NS_IMETHODIMP nsPluginHostImpl::HandleBadPlugin(PRLibrary* aLibrary, nsIPluginIn
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
// nsPIPluginHost interface
|
/**
|
||||||
|
* nsPIPluginHost interface
|
||||||
|
*/
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsPluginHostImpl::SetIsScriptableInstance(nsCOMPtr<nsIPluginInstance> aPluginInstance,
|
nsPluginHostImpl::SetIsScriptableInstance(nsCOMPtr<nsIPluginInstance> aPluginInstance,
|
||||||
PRBool aScriptable)
|
PRBool aScriptable)
|
||||||
|
@ -6128,8 +6136,6 @@ nsPluginHostImpl::SetIsScriptableInstance(nsCOMPtr<nsIPluginInstance> aPluginIns
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsPluginHostImpl::ParsePostBufferToFixHeaders(
|
nsPluginHostImpl::ParsePostBufferToFixHeaders(
|
||||||
const char *inPostData, PRUint32 inPostDataLen,
|
const char *inPostData, PRUint32 inPostDataLen,
|
||||||
|
@ -6284,7 +6290,6 @@ nsPluginHostImpl::ParsePostBufferToFixHeaders(
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsPluginHostImpl::CreateTmpFileToPost(const char *postDataURL, char **pTmpFileName)
|
nsPluginHostImpl::CreateTmpFileToPost(const char *postDataURL, char **pTmpFileName)
|
||||||
{
|
{
|
||||||
|
@ -6400,6 +6405,20 @@ nsPluginHostImpl::CreateTmpFileToPost(const char *postDataURL, char **pTmpFileNa
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsPluginHostImpl::NewPluginNativeWindow(nsPluginNativeWindow ** aPluginNativeWindow)
|
||||||
|
{
|
||||||
|
return PLUG_NewPluginNativeWindow(aPluginNativeWindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
NS_IMETHODIMP
|
||||||
|
nsPluginHostImpl::DeletePluginNativeWindow(nsPluginNativeWindow * aPluginNativeWindow)
|
||||||
|
{
|
||||||
|
return PLUG_DeletePluginNativeWindow(aPluginNativeWindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----- end of nsPIPluginHost implementation ----- */
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsPluginHostImpl::ScanForRealInComponentsFolder(nsIComponentManager * aCompManager)
|
nsPluginHostImpl::ScanForRealInComponentsFolder(nsIComponentManager * aCompManager)
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
#include "nsIPrompt.h"
|
#include "nsIPrompt.h"
|
||||||
#include "nsIGenericFactory.h"
|
#include "nsIGenericFactory.h"
|
||||||
#include "nsISupportsArray.h"
|
#include "nsISupportsArray.h"
|
||||||
|
#include "nsPluginNativeWindow.h"
|
||||||
|
|
||||||
class ns4xPlugin;
|
class ns4xPlugin;
|
||||||
class nsFileSpec;
|
class nsFileSpec;
|
||||||
|
@ -363,6 +364,12 @@ public:
|
||||||
NS_IMETHOD
|
NS_IMETHOD
|
||||||
CreateTmpFileToPost(const char *postDataURL, char **pTmpFileName);
|
CreateTmpFileToPost(const char *postDataURL, char **pTmpFileName);
|
||||||
|
|
||||||
|
NS_IMETHOD
|
||||||
|
NewPluginNativeWindow(nsPluginNativeWindow ** aPluginNativeWindow);
|
||||||
|
|
||||||
|
NS_IMETHOD
|
||||||
|
DeletePluginNativeWindow(nsPluginNativeWindow * aPluginNativeWindow);
|
||||||
|
|
||||||
/* Called by GetURL and PostURL */
|
/* Called by GetURL and PostURL */
|
||||||
|
|
||||||
NS_IMETHOD
|
NS_IMETHOD
|
||||||
|
|
|
@ -38,6 +38,9 @@
|
||||||
#ifndef nsPluginSafety_h__
|
#ifndef nsPluginSafety_h__
|
||||||
#define nsPluginSafety_h__
|
#define nsPluginSafety_h__
|
||||||
|
|
||||||
|
#include "npapi.h"
|
||||||
|
#include "nsIPluginHost.h"
|
||||||
|
|
||||||
#if defined(XP_PC) && !defined(XP_OS2)
|
#if defined(XP_PC) && !defined(XP_OS2)
|
||||||
#define CALL_SAFETY_ON
|
#define CALL_SAFETY_ON
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -67,6 +67,8 @@
|
||||||
#include "nsContentCID.h"
|
#include "nsContentCID.h"
|
||||||
#include "nsIScriptGlobalObject.h"
|
#include "nsIScriptGlobalObject.h"
|
||||||
#include "nsITimer.h"
|
#include "nsITimer.h"
|
||||||
|
#include "nsPIPluginHost.h"
|
||||||
|
#include "nsPluginNativeWindow.h"
|
||||||
|
|
||||||
class nsIPrintSettings;
|
class nsIPrintSettings;
|
||||||
class nsIDOMWindow;
|
class nsIDOMWindow;
|
||||||
|
@ -163,7 +165,7 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsPluginWindow mPluginWindow;
|
nsPluginNativeWindow *mPluginWindow;
|
||||||
nsIPluginInstance *mInstance;
|
nsIPluginInstance *mInstance;
|
||||||
nsIWidget *mWindow; //we do not addref this...
|
nsIWidget *mWindow; //we do not addref this...
|
||||||
PluginViewerImpl *mViewer; //we do not addref this...
|
PluginViewerImpl *mViewer; //we do not addref this...
|
||||||
|
@ -454,9 +456,14 @@ PluginViewerImpl::Destroy(void)
|
||||||
// doing this in the destructor is too late.
|
// doing this in the destructor is too late.
|
||||||
if(mOwner != nsnull)
|
if(mOwner != nsnull)
|
||||||
{
|
{
|
||||||
nsIPluginInstance *inst;
|
nsCOMPtr<nsIPluginInstance> inst;
|
||||||
if(NS_OK == mOwner->GetInstance(inst))
|
if(NS_SUCCEEDED(mOwner->GetInstance(*getter_AddRefs(inst))))
|
||||||
{
|
{
|
||||||
|
nsPluginWindow *win;
|
||||||
|
mOwner->GetWindow(win);
|
||||||
|
nsPluginNativeWindow *window = (nsPluginNativeWindow *)win;
|
||||||
|
nsCOMPtr<nsIPluginInstance> nullinst;
|
||||||
|
|
||||||
PRBool doCache = PR_TRUE;
|
PRBool doCache = PR_TRUE;
|
||||||
PRBool doCallSetWindowAfterDestroy = PR_FALSE;
|
PRBool doCallSetWindowAfterDestroy = PR_FALSE;
|
||||||
|
|
||||||
|
@ -468,19 +475,26 @@ PluginViewerImpl::Destroy(void)
|
||||||
// Set Window. This is for bug 50547.
|
// Set Window. This is for bug 50547.
|
||||||
inst->GetValue(nsPluginInstanceVariable_CallSetWindowAfterDestroyBool,
|
inst->GetValue(nsPluginInstanceVariable_CallSetWindowAfterDestroyBool,
|
||||||
(void *) &doCallSetWindowAfterDestroy);
|
(void *) &doCallSetWindowAfterDestroy);
|
||||||
!doCallSetWindowAfterDestroy ? inst->SetWindow(nsnull) : 0;
|
if (!doCallSetWindowAfterDestroy) {
|
||||||
|
if (window)
|
||||||
|
window->CallSetWindow(nullinst);
|
||||||
|
else
|
||||||
|
inst->SetWindow(nsnull);
|
||||||
|
}
|
||||||
inst->Stop();
|
inst->Stop();
|
||||||
inst->Destroy();
|
inst->Destroy();
|
||||||
doCallSetWindowAfterDestroy ? inst->SetWindow(nsnull) : 0; }
|
if (doCallSetWindowAfterDestroy) {
|
||||||
else {
|
if (window)
|
||||||
|
window->CallSetWindow(nullinst);
|
||||||
|
else
|
||||||
inst->SetWindow(nsnull);
|
inst->SetWindow(nsnull);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
window ? window->CallSetWindow(nullinst) : inst->SetWindow(nsnull);
|
||||||
inst->Stop();
|
inst->Stop();
|
||||||
}
|
}
|
||||||
NS_RELEASE(inst);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,9 +600,9 @@ PluginViewerImpl::SetBounds(const nsRect& aBounds)
|
||||||
if (nsnull != mWindow) {
|
if (nsnull != mWindow) {
|
||||||
// Don't have the widget repaint. Layout will generate repaint requests
|
// Don't have the widget repaint. Layout will generate repaint requests
|
||||||
// during reflow
|
// during reflow
|
||||||
nsIPluginInstance *inst;
|
nsCOMPtr<nsIPluginInstance> inst;
|
||||||
mWindow->Resize(aBounds.x, aBounds.y, aBounds.width, aBounds.height, PR_FALSE);
|
mWindow->Resize(aBounds.x, aBounds.y, aBounds.width, aBounds.height, PR_FALSE);
|
||||||
if ((nsnull != mOwner) && (NS_OK == mOwner->GetInstance(inst)) && (nsnull != inst)) {
|
if (mOwner && NS_SUCCEEDED(mOwner->GetInstance(*getter_AddRefs(inst))) && inst) {
|
||||||
nsPluginWindow *win;
|
nsPluginWindow *win;
|
||||||
if (NS_OK == mOwner->GetWindow(win)) {
|
if (NS_OK == mOwner->GetWindow(win)) {
|
||||||
win->x = aBounds.x;
|
win->x = aBounds.x;
|
||||||
|
@ -603,9 +617,8 @@ PluginViewerImpl::SetBounds(const nsRect& aBounds)
|
||||||
#ifdef XP_MAC // On Mac we also need to add in the widget offset to the plugin window
|
#ifdef XP_MAC // On Mac we also need to add in the widget offset to the plugin window
|
||||||
mOwner->FixUpPluginWindow();
|
mOwner->FixUpPluginWindow();
|
||||||
#endif
|
#endif
|
||||||
inst->SetWindow(win);
|
((nsPluginNativeWindow *)win)->CallSetWindow(inst);
|
||||||
}
|
}
|
||||||
NS_RELEASE(inst);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -616,9 +629,9 @@ PluginViewerImpl::Move(PRInt32 aX, PRInt32 aY)
|
||||||
{
|
{
|
||||||
NS_PRECONDITION(nsnull != mWindow, "null window");
|
NS_PRECONDITION(nsnull != mWindow, "null window");
|
||||||
if (nsnull != mWindow) {
|
if (nsnull != mWindow) {
|
||||||
nsIPluginInstance *inst;
|
nsCOMPtr<nsIPluginInstance> inst;
|
||||||
mWindow->Move(aX, aY);
|
mWindow->Move(aX, aY);
|
||||||
if ((nsnull != mOwner) && (NS_OK == mOwner->GetInstance(inst)) && (nsnull != inst)) {
|
if (mOwner && NS_SUCCEEDED(mOwner->GetInstance(*getter_AddRefs(inst))) && inst) {
|
||||||
nsPluginWindow *win;
|
nsPluginWindow *win;
|
||||||
if (NS_OK == mOwner->GetWindow(win)) {
|
if (NS_OK == mOwner->GetWindow(win)) {
|
||||||
win->x = aX;
|
win->x = aX;
|
||||||
|
@ -631,9 +644,8 @@ PluginViewerImpl::Move(PRInt32 aX, PRInt32 aY)
|
||||||
#ifdef XP_MAC // On Mac we also need to add in the widget offset to the plugin window
|
#ifdef XP_MAC // On Mac we also need to add in the widget offset to the plugin window
|
||||||
mOwner->FixUpPluginWindow();
|
mOwner->FixUpPluginWindow();
|
||||||
#endif
|
#endif
|
||||||
inst->SetWindow(win);
|
((nsPluginNativeWindow *)win)->CallSetWindow(inst);
|
||||||
}
|
}
|
||||||
NS_RELEASE(inst);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -1020,7 +1032,15 @@ pluginInstanceOwner :: pluginInstanceOwner()
|
||||||
{
|
{
|
||||||
NS_INIT_ISUPPORTS();
|
NS_INIT_ISUPPORTS();
|
||||||
|
|
||||||
memset(&mPluginWindow, 0, sizeof(mPluginWindow));
|
// create nsPluginNativeWindow object, it is derived from nsPluginWindow
|
||||||
|
// struct and allows to manipulate native window procedure
|
||||||
|
nsCOMPtr<nsIPluginHost> ph = do_GetService(kCPluginManagerCID);
|
||||||
|
nsCOMPtr<nsPIPluginHost> pph(do_QueryInterface(ph));
|
||||||
|
if (pph)
|
||||||
|
pph->NewPluginNativeWindow(&mPluginWindow);
|
||||||
|
else
|
||||||
|
mPluginWindow = nsnull;
|
||||||
|
|
||||||
mInstance = nsnull;
|
mInstance = nsnull;
|
||||||
mWindow = nsnull;
|
mWindow = nsnull;
|
||||||
mViewer = nsnull;
|
mViewer = nsnull;
|
||||||
|
@ -1038,6 +1058,14 @@ pluginInstanceOwner :: ~pluginInstanceOwner()
|
||||||
|
|
||||||
mWindow = nsnull;
|
mWindow = nsnull;
|
||||||
mViewer = nsnull;
|
mViewer = nsnull;
|
||||||
|
|
||||||
|
// clean up plugin native window object
|
||||||
|
nsCOMPtr<nsIPluginHost> ph = do_GetService(kCPluginManagerCID);
|
||||||
|
nsCOMPtr<nsPIPluginHost> pph(do_QueryInterface(ph));
|
||||||
|
if (pph) {
|
||||||
|
pph->DeletePluginNativeWindow(mPluginWindow);
|
||||||
|
mPluginWindow = nsnull;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS2(pluginInstanceOwner, nsIPluginInstanceOwner,nsITimerCallback);
|
NS_IMPL_ISUPPORTS2(pluginInstanceOwner, nsIPluginInstanceOwner,nsITimerCallback);
|
||||||
|
@ -1064,7 +1092,8 @@ NS_IMETHODIMP pluginInstanceOwner :: GetInstance(nsIPluginInstance *&aInstance)
|
||||||
|
|
||||||
NS_IMETHODIMP pluginInstanceOwner :: GetWindow(nsPluginWindow *&aWindow)
|
NS_IMETHODIMP pluginInstanceOwner :: GetWindow(nsPluginWindow *&aWindow)
|
||||||
{
|
{
|
||||||
aWindow = &mPluginWindow;
|
NS_ASSERTION(mPluginWindow, "the plugin window object being returned is null");
|
||||||
|
aWindow = mPluginWindow;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1076,6 +1105,8 @@ NS_IMETHODIMP pluginInstanceOwner :: GetMode(nsPluginMode *aMode)
|
||||||
|
|
||||||
NS_IMETHODIMP pluginInstanceOwner :: CreateWidget(void)
|
NS_IMETHODIMP pluginInstanceOwner :: CreateWidget(void)
|
||||||
{
|
{
|
||||||
|
NS_ENSURE_TRUE(mPluginWindow, NS_ERROR_NULL_POINTER);
|
||||||
|
|
||||||
PRBool windowless;
|
PRBool windowless;
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
|
@ -1093,13 +1124,13 @@ NS_IMETHODIMP pluginInstanceOwner :: CreateWidget(void)
|
||||||
|
|
||||||
if (PR_TRUE == windowless)
|
if (PR_TRUE == windowless)
|
||||||
{
|
{
|
||||||
mPluginWindow.window = nsnull; //XXX this needs to be a HDC
|
mPluginWindow->window = nsnull; //XXX this needs to be a HDC
|
||||||
mPluginWindow.type = nsPluginWindowType_Drawable;
|
mPluginWindow->type = nsPluginWindowType_Drawable;
|
||||||
}
|
}
|
||||||
else if (nsnull != mWindow)
|
else if (nsnull != mWindow)
|
||||||
{
|
{
|
||||||
mPluginWindow.window = (nsPluginPort *)mWindow->GetNativeData(NS_NATIVE_PLUGIN_PORT);
|
mPluginWindow->window = (nsPluginPort *)mWindow->GetNativeData(NS_NATIVE_PLUGIN_PORT);
|
||||||
mPluginWindow.type = nsPluginWindowType_Window;
|
mPluginWindow->type = nsPluginWindowType_Window;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
@ -1447,6 +1478,9 @@ static void GetWidgetPosClipAndVis(nsIWidget* aWidget,nscoord& aAbsX, nscoord& a
|
||||||
|
|
||||||
void pluginInstanceOwner::FixUpPluginWindow()
|
void pluginInstanceOwner::FixUpPluginWindow()
|
||||||
{
|
{
|
||||||
|
if (!mPluginWindow)
|
||||||
|
return;
|
||||||
|
|
||||||
if (mWindow) {
|
if (mWindow) {
|
||||||
nscoord absWidgetX = 0;
|
nscoord absWidgetX = 0;
|
||||||
nscoord absWidgetY = 0;
|
nscoord absWidgetY = 0;
|
||||||
|
@ -1458,14 +1492,14 @@ void pluginInstanceOwner::FixUpPluginWindow()
|
||||||
mWidgetVisible = isVisible;
|
mWidgetVisible = isVisible;
|
||||||
|
|
||||||
// set the port coordinates
|
// set the port coordinates
|
||||||
mPluginWindow.x = absWidgetX;
|
mPluginWindow->x = absWidgetX;
|
||||||
mPluginWindow.y = absWidgetY;
|
mPluginWindow->y = absWidgetY;
|
||||||
|
|
||||||
// fix up the clipping region
|
// fix up the clipping region
|
||||||
mPluginWindow.clipRect.top = widgetClip.y;
|
mPluginWindow->clipRect.top = widgetClip.y;
|
||||||
mPluginWindow.clipRect.left = widgetClip.x;
|
mPluginWindow->clipRect.left = widgetClip.x;
|
||||||
mPluginWindow.clipRect.bottom = mPluginWindow.clipRect.top + widgetClip.height;
|
mPluginWindow->clipRect.bottom = mPluginWindow->clipRect.top + widgetClip.height;
|
||||||
mPluginWindow.clipRect.right = mPluginWindow.clipRect.left + widgetClip.width;
|
mPluginWindow->clipRect.right = mPluginWindow->clipRect.left + widgetClip.width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче