Fixing 132759 -- 100% CPU with Flash, r=peterl, sr=jst

This commit is contained in:
av%netscape.com 2002-09-26 02:53:27 +00:00
Родитель f313b063f7
Коммит 853796579e
12 изменённых файлов: 394 добавлений и 2443 удалений

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

@ -128,6 +128,8 @@
#include "nsObjectFrame.h"
#include "nsIObjectFrame.h"
#include "nsPluginNativeWindow.h"
#include "nsPIPluginHost.h"
// accessibility support
#ifdef ACCESSIBILITY
@ -327,7 +329,7 @@ public:
#endif
private:
nsPluginWindow mPluginWindow;
nsPluginNativeWindow *mPluginWindow;
nsIPluginInstance *mInstance;
nsObjectFrame *mOwner;
nsCString mDocumentBase;
@ -667,9 +669,14 @@ nsObjectFrame::Destroy(nsIPresContext* aPresContext)
// doing this in the destructor is too late.
if(mInstanceOwner != nsnull)
{
nsIPluginInstance *inst;
if(NS_OK == mInstanceOwner->GetInstance(inst))
nsCOMPtr<nsIPluginInstance> 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 doCallSetWindowAfterDestroy = PR_FALSE;
@ -684,24 +691,34 @@ nsObjectFrame::Destroy(nsIPresContext* aPresContext)
if (doCallSetWindowAfterDestroy) {
inst->Stop();
inst->Destroy();
if (window)
window->CallSetWindow(nullinst);
else
inst->SetWindow(nsnull);
}
else {
if (window)
window->CallSetWindow(nullinst);
else
inst->SetWindow(nsnull);
inst->Stop();
inst->Destroy();
}
}
else {
if (window)
window->CallSetWindow(nullinst);
else
inst->SetWindow(nsnull);
inst->Stop();
}
nsCOMPtr<nsIPluginHost> pluginHost = do_GetService(kCPluginManagerCID);
if(pluginHost)
pluginHost->StopPluginInstance(inst);
NS_RELEASE(inst);
}
}
return nsObjectFrameSuper::Destroy(aPresContext);
@ -1243,6 +1260,8 @@ nsObjectFrame::InstantiatePlugin(nsIPresContext* aPresContext,
mInstanceOwner->GetWindow(window);
NS_ENSURE_TRUE(window, NS_ERROR_NULL_POINTER);
GetOffsetFromView(aPresContext, origin, &parentWithView);
window->x = NSTwipsToIntPixels(origin.x, t2p);
window->y = NSTwipsToIntPixels(origin.y, t2p);
@ -1528,16 +1547,18 @@ nsObjectFrame::DidReflow(nsIPresContext* aPresContext,
vm->SetViewVisibility(view, bHidden ? nsViewVisibility_kHide : nsViewVisibility_kShow);
}
nsPluginWindow *window;
nsPluginWindow *win = nsnull;
nsCOMPtr<nsIPluginInstance> pi;
if (!mInstanceOwner ||
NS_FAILED(rv = mInstanceOwner->GetWindow(window)) ||
NS_FAILED(rv = mInstanceOwner->GetWindow(win)) ||
NS_FAILED(rv = mInstanceOwner->GetInstance(*getter_AddRefs(pi))) ||
!pi ||
!window)
!win)
return rv;
nsPluginNativeWindow *window = (nsPluginNativeWindow *)win;
#ifdef XP_MAC
mInstanceOwner->FixUpPluginWindow();
#endif // XP_MAC
@ -1557,7 +1578,11 @@ nsObjectFrame::DidReflow(nsIPresContext* aPresContext,
// refresh the plugin port as well
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);
if (mWidget) {
@ -2091,7 +2116,15 @@ nsPluginInstanceOwner::nsPluginInstanceOwner()
{
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;
mOwner = nsnull;
mWidget = nsnull;
@ -2152,11 +2185,19 @@ nsPluginInstanceOwner::~nsPluginInstanceOwner()
#ifdef XP_UNIX
// the mem for this struct is allocated
// by PR_MALLOC in ns4xPluginInstance.cpp:ns4xPluginInstance::SetWindow()
if (mPluginWindow.ws_info) {
PR_Free(mPluginWindow.ws_info);
mPluginWindow.ws_info = nsnull;
if (mPluginWindow && mPluginWindow->ws_info) {
PR_Free(mPluginWindow->ws_info);
mPluginWindow->ws_info = nsnull;
}
#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)
{
aWindow = &mPluginWindow;
NS_ASSERTION(mPluginWindow, "the plugin window object being returned is null");
aWindow = mPluginWindow;
return NS_OK;
}
@ -2746,7 +2788,9 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetWidth(PRUint32 *result)
{
NS_ENSURE_ARG_POINTER(result);
*result = mPluginWindow.width;
NS_ENSURE_TRUE(mPluginWindow, NS_ERROR_NULL_POINTER);
*result = mPluginWindow->width;
return NS_OK;
}
@ -2755,7 +2799,9 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetHeight(PRUint32 *result)
{
NS_ENSURE_ARG_POINTER(result);
*result = mPluginWindow.height;
NS_ENSURE_TRUE(mPluginWindow, NS_ERROR_NULL_POINTER);
*result = mPluginWindow->height;
return NS_OK;
}
@ -3190,7 +3236,7 @@ nsresult nsPluginInstanceOwner::Blur(nsIDOMEvent * aFocusEvent)
nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent)
{
#ifndef XP_MAC
if (nsPluginWindowType_Window == mPluginWindow.type)
if (!mPluginWindow || nsPluginWindowType_Window == mPluginWindow->type)
return NS_ERROR_FAILURE; // means consume event
// continue only for cases without child window
#endif
@ -3344,7 +3390,7 @@ nsresult nsPluginInstanceOwner::KeyPress(nsIDOMEvent* aKeyEvent)
nsresult nsPluginInstanceOwner::DispatchKeyToPlugin(nsIDOMEvent* aKeyEvent)
{
#ifndef XP_MAC
if (nsPluginWindowType_Window == mPluginWindow.type)
if (!mPluginWindow || nsPluginWindowType_Window == mPluginWindow->type)
return NS_ERROR_FAILURE; // means consume event
// continue only for cases without child window
#endif
@ -3382,7 +3428,7 @@ nsresult
nsPluginInstanceOwner::MouseMove(nsIDOMEvent* aMouseEvent)
{
#ifndef XP_MAC
if (nsPluginWindowType_Window == mPluginWindow.type)
if (!mPluginWindow || nsPluginWindowType_Window == mPluginWindow->type)
return NS_ERROR_FAILURE; // means consume event
// continue only for cases without child window
#endif
@ -3414,14 +3460,14 @@ nsresult
nsPluginInstanceOwner::MouseDown(nsIDOMEvent* aMouseEvent)
{
#ifndef XP_MAC
if (nsPluginWindowType_Window == mPluginWindow.type)
if (!mPluginWindow || nsPluginWindowType_Window == mPluginWindow->type)
return NS_ERROR_FAILURE; // means consume event
// continue only for cases without child window
#endif
// if the plugin is windowless, we need to set focus ourselves
// otherwise, we might not get key events
if (mPluginWindow.type == nsPluginWindowType_Drawable) {
if (mPluginWindow && mPluginWindow->type == nsPluginWindowType_Drawable) {
nsCOMPtr<nsIContent> content;
mOwner->GetContent(getter_AddRefs(content));
if (content)
@ -3478,7 +3524,7 @@ nsPluginInstanceOwner::MouseOut(nsIDOMEvent* aMouseEvent)
nsresult nsPluginInstanceOwner::DispatchMouseToPlugin(nsIDOMEvent* aMouseEvent)
{
#ifndef XP_MAC
if (nsPluginWindowType_Window == mPluginWindow.type)
if (!mPluginWindow || nsPluginWindowType_Window == mPluginWindow->type)
return NS_ERROR_FAILURE; // means consume event
// continue only for cases without child window
#endif
@ -3899,7 +3945,7 @@ nsPluginPort* nsPluginInstanceOwner::GetPluginPort()
if (mWidget != NULL)
{
#ifdef XP_WIN
if(mPluginWindow.type == nsPluginWindowType_Drawable)
if(mPluginWindow && mPluginWindow->type == nsPluginWindowType_Drawable)
result = (nsPluginPort*) mWidget->GetNativeData(NS_NATIVE_GRAPHIC);
else
#endif
@ -3913,7 +3959,7 @@ void nsPluginInstanceOwner::ReleasePluginPort(nsPluginPort * pluginPort)
#ifdef XP_WIN
if (mWidget != NULL)
{
if(mPluginWindow.type == nsPluginWindowType_Drawable)
if(mPluginWindow && mPluginWindow->type == nsPluginWindowType_Drawable)
mWidget->FreeNativeData((HDC)pluginPort, NS_NATIVE_GRAPHIC);
}
#endif
@ -3921,6 +3967,8 @@ void nsPluginInstanceOwner::ReleasePluginPort(nsPluginPort * pluginPort)
NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
{
NS_ENSURE_TRUE(mPluginWindow, NS_ERROR_NULL_POINTER);
nsIView *view;
nsresult rv = NS_ERROR_FAILURE;
float p2t;
@ -3940,8 +3988,8 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
// always create widgets in Twips, not pixels
mContext->GetScaledPixelsToTwips(&p2t);
rv = mOwner->CreateWidget(mContext,
NSIntPixelsToTwips(mPluginWindow.width, p2t),
NSIntPixelsToTwips(mPluginWindow.height, p2t),
NSIntPixelsToTwips(mPluginWindow->width, p2t),
NSIntPixelsToTwips(mPluginWindow->height, p2t),
windowless);
if (NS_OK == rv)
{
@ -3961,20 +4009,20 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
if (PR_TRUE == windowless)
{
mPluginWindow.type = nsPluginWindowType_Drawable;
mPluginWindow.window = nsnull; // this needs to be a HDC according to the spec,
mPluginWindow->type = nsPluginWindowType_Drawable;
mPluginWindow->window = nsnull; // this needs to be a HDC according to the spec,
// but I do not see the right way to release it
// so let's postpone passing HDC till paint event
// when it is really needed. Change spec?
}
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 = nsPluginWindowType_Window;
mPluginWindow.window = GetPluginPort();
// mPluginWindow->type is used in |GetPluginPort| so it must be initilized first
mPluginWindow->type = nsPluginWindowType_Window;
mPluginWindow->window = GetPluginPort();
#if defined(XP_MAC)
// Is this needed in the windowless case ???
@ -4131,7 +4179,9 @@ inline PRUint16 COLOR8TOCOLOR16(PRUint8 color8)
void nsPluginInstanceOwner::FixUpPluginWindow()
{
if (mWidget) {
if (!mWidget || !mPluginWindow)
return;
nscoord absWidgetX = 0;
nscoord absWidgetY = 0;
nsRect widgetClip(0,0,0,0);
@ -4149,14 +4199,14 @@ void nsPluginInstanceOwner::FixUpPluginWindow()
mWidgetVisible = isVisible;
// set the port coordinates
mPluginWindow.x = absWidgetX;
mPluginWindow.y = absWidgetY;
mPluginWindow->x = absWidgetX;
mPluginWindow->y = absWidgetY;
// fix up the clipping region
mPluginWindow.clipRect.top = widgetClip.y;
mPluginWindow.clipRect.left = widgetClip.x;
mPluginWindow.clipRect.bottom = mPluginWindow.clipRect.top + widgetClip.height;
mPluginWindow.clipRect.right = mPluginWindow.clipRect.left + widgetClip.width;
mPluginWindow->clipRect.top = widgetClip.y;
mPluginWindow->clipRect.left = widgetClip.x;
mPluginWindow->clipRect.bottom = mPluginWindow->clipRect.top + widgetClip.height;
mPluginWindow->clipRect.right = mPluginWindow->clipRect.left + widgetClip.width;
// the Mac widget doesn't set the background color right away!!
// the background color needs to be set here on the plugin port
@ -4173,7 +4223,6 @@ void nsPluginInstanceOwner::FixUpPluginWindow()
::RGBBackColor(&macColor);
::SetPort(savePort); // restore port
}
}
#endif // XP_MAC

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

@ -128,6 +128,8 @@
#include "nsObjectFrame.h"
#include "nsIObjectFrame.h"
#include "nsPluginNativeWindow.h"
#include "nsPIPluginHost.h"
// accessibility support
#ifdef ACCESSIBILITY
@ -327,7 +329,7 @@ public:
#endif
private:
nsPluginWindow mPluginWindow;
nsPluginNativeWindow *mPluginWindow;
nsIPluginInstance *mInstance;
nsObjectFrame *mOwner;
nsCString mDocumentBase;
@ -667,9 +669,14 @@ nsObjectFrame::Destroy(nsIPresContext* aPresContext)
// doing this in the destructor is too late.
if(mInstanceOwner != nsnull)
{
nsIPluginInstance *inst;
if(NS_OK == mInstanceOwner->GetInstance(inst))
nsCOMPtr<nsIPluginInstance> 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 doCallSetWindowAfterDestroy = PR_FALSE;
@ -684,24 +691,34 @@ nsObjectFrame::Destroy(nsIPresContext* aPresContext)
if (doCallSetWindowAfterDestroy) {
inst->Stop();
inst->Destroy();
if (window)
window->CallSetWindow(nullinst);
else
inst->SetWindow(nsnull);
}
else {
if (window)
window->CallSetWindow(nullinst);
else
inst->SetWindow(nsnull);
inst->Stop();
inst->Destroy();
}
}
else {
if (window)
window->CallSetWindow(nullinst);
else
inst->SetWindow(nsnull);
inst->Stop();
}
nsCOMPtr<nsIPluginHost> pluginHost = do_GetService(kCPluginManagerCID);
if(pluginHost)
pluginHost->StopPluginInstance(inst);
NS_RELEASE(inst);
}
}
return nsObjectFrameSuper::Destroy(aPresContext);
@ -1243,6 +1260,8 @@ nsObjectFrame::InstantiatePlugin(nsIPresContext* aPresContext,
mInstanceOwner->GetWindow(window);
NS_ENSURE_TRUE(window, NS_ERROR_NULL_POINTER);
GetOffsetFromView(aPresContext, origin, &parentWithView);
window->x = NSTwipsToIntPixels(origin.x, t2p);
window->y = NSTwipsToIntPixels(origin.y, t2p);
@ -1528,16 +1547,18 @@ nsObjectFrame::DidReflow(nsIPresContext* aPresContext,
vm->SetViewVisibility(view, bHidden ? nsViewVisibility_kHide : nsViewVisibility_kShow);
}
nsPluginWindow *window;
nsPluginWindow *win = nsnull;
nsCOMPtr<nsIPluginInstance> pi;
if (!mInstanceOwner ||
NS_FAILED(rv = mInstanceOwner->GetWindow(window)) ||
NS_FAILED(rv = mInstanceOwner->GetWindow(win)) ||
NS_FAILED(rv = mInstanceOwner->GetInstance(*getter_AddRefs(pi))) ||
!pi ||
!window)
!win)
return rv;
nsPluginNativeWindow *window = (nsPluginNativeWindow *)win;
#ifdef XP_MAC
mInstanceOwner->FixUpPluginWindow();
#endif // XP_MAC
@ -1557,7 +1578,11 @@ nsObjectFrame::DidReflow(nsIPresContext* aPresContext,
// refresh the plugin port as well
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);
if (mWidget) {
@ -2091,7 +2116,15 @@ nsPluginInstanceOwner::nsPluginInstanceOwner()
{
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;
mOwner = nsnull;
mWidget = nsnull;
@ -2152,11 +2185,19 @@ nsPluginInstanceOwner::~nsPluginInstanceOwner()
#ifdef XP_UNIX
// the mem for this struct is allocated
// by PR_MALLOC in ns4xPluginInstance.cpp:ns4xPluginInstance::SetWindow()
if (mPluginWindow.ws_info) {
PR_Free(mPluginWindow.ws_info);
mPluginWindow.ws_info = nsnull;
if (mPluginWindow && mPluginWindow->ws_info) {
PR_Free(mPluginWindow->ws_info);
mPluginWindow->ws_info = nsnull;
}
#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)
{
aWindow = &mPluginWindow;
NS_ASSERTION(mPluginWindow, "the plugin window object being returned is null");
aWindow = mPluginWindow;
return NS_OK;
}
@ -2746,7 +2788,9 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetWidth(PRUint32 *result)
{
NS_ENSURE_ARG_POINTER(result);
*result = mPluginWindow.width;
NS_ENSURE_TRUE(mPluginWindow, NS_ERROR_NULL_POINTER);
*result = mPluginWindow->width;
return NS_OK;
}
@ -2755,7 +2799,9 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetHeight(PRUint32 *result)
{
NS_ENSURE_ARG_POINTER(result);
*result = mPluginWindow.height;
NS_ENSURE_TRUE(mPluginWindow, NS_ERROR_NULL_POINTER);
*result = mPluginWindow->height;
return NS_OK;
}
@ -3190,7 +3236,7 @@ nsresult nsPluginInstanceOwner::Blur(nsIDOMEvent * aFocusEvent)
nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent)
{
#ifndef XP_MAC
if (nsPluginWindowType_Window == mPluginWindow.type)
if (!mPluginWindow || nsPluginWindowType_Window == mPluginWindow->type)
return NS_ERROR_FAILURE; // means consume event
// continue only for cases without child window
#endif
@ -3344,7 +3390,7 @@ nsresult nsPluginInstanceOwner::KeyPress(nsIDOMEvent* aKeyEvent)
nsresult nsPluginInstanceOwner::DispatchKeyToPlugin(nsIDOMEvent* aKeyEvent)
{
#ifndef XP_MAC
if (nsPluginWindowType_Window == mPluginWindow.type)
if (!mPluginWindow || nsPluginWindowType_Window == mPluginWindow->type)
return NS_ERROR_FAILURE; // means consume event
// continue only for cases without child window
#endif
@ -3382,7 +3428,7 @@ nsresult
nsPluginInstanceOwner::MouseMove(nsIDOMEvent* aMouseEvent)
{
#ifndef XP_MAC
if (nsPluginWindowType_Window == mPluginWindow.type)
if (!mPluginWindow || nsPluginWindowType_Window == mPluginWindow->type)
return NS_ERROR_FAILURE; // means consume event
// continue only for cases without child window
#endif
@ -3414,14 +3460,14 @@ nsresult
nsPluginInstanceOwner::MouseDown(nsIDOMEvent* aMouseEvent)
{
#ifndef XP_MAC
if (nsPluginWindowType_Window == mPluginWindow.type)
if (!mPluginWindow || nsPluginWindowType_Window == mPluginWindow->type)
return NS_ERROR_FAILURE; // means consume event
// continue only for cases without child window
#endif
// if the plugin is windowless, we need to set focus ourselves
// otherwise, we might not get key events
if (mPluginWindow.type == nsPluginWindowType_Drawable) {
if (mPluginWindow && mPluginWindow->type == nsPluginWindowType_Drawable) {
nsCOMPtr<nsIContent> content;
mOwner->GetContent(getter_AddRefs(content));
if (content)
@ -3478,7 +3524,7 @@ nsPluginInstanceOwner::MouseOut(nsIDOMEvent* aMouseEvent)
nsresult nsPluginInstanceOwner::DispatchMouseToPlugin(nsIDOMEvent* aMouseEvent)
{
#ifndef XP_MAC
if (nsPluginWindowType_Window == mPluginWindow.type)
if (!mPluginWindow || nsPluginWindowType_Window == mPluginWindow->type)
return NS_ERROR_FAILURE; // means consume event
// continue only for cases without child window
#endif
@ -3899,7 +3945,7 @@ nsPluginPort* nsPluginInstanceOwner::GetPluginPort()
if (mWidget != NULL)
{
#ifdef XP_WIN
if(mPluginWindow.type == nsPluginWindowType_Drawable)
if(mPluginWindow && mPluginWindow->type == nsPluginWindowType_Drawable)
result = (nsPluginPort*) mWidget->GetNativeData(NS_NATIVE_GRAPHIC);
else
#endif
@ -3913,7 +3959,7 @@ void nsPluginInstanceOwner::ReleasePluginPort(nsPluginPort * pluginPort)
#ifdef XP_WIN
if (mWidget != NULL)
{
if(mPluginWindow.type == nsPluginWindowType_Drawable)
if(mPluginWindow && mPluginWindow->type == nsPluginWindowType_Drawable)
mWidget->FreeNativeData((HDC)pluginPort, NS_NATIVE_GRAPHIC);
}
#endif
@ -3921,6 +3967,8 @@ void nsPluginInstanceOwner::ReleasePluginPort(nsPluginPort * pluginPort)
NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
{
NS_ENSURE_TRUE(mPluginWindow, NS_ERROR_NULL_POINTER);
nsIView *view;
nsresult rv = NS_ERROR_FAILURE;
float p2t;
@ -3940,8 +3988,8 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
// always create widgets in Twips, not pixels
mContext->GetScaledPixelsToTwips(&p2t);
rv = mOwner->CreateWidget(mContext,
NSIntPixelsToTwips(mPluginWindow.width, p2t),
NSIntPixelsToTwips(mPluginWindow.height, p2t),
NSIntPixelsToTwips(mPluginWindow->width, p2t),
NSIntPixelsToTwips(mPluginWindow->height, p2t),
windowless);
if (NS_OK == rv)
{
@ -3961,20 +4009,20 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
if (PR_TRUE == windowless)
{
mPluginWindow.type = nsPluginWindowType_Drawable;
mPluginWindow.window = nsnull; // this needs to be a HDC according to the spec,
mPluginWindow->type = nsPluginWindowType_Drawable;
mPluginWindow->window = nsnull; // this needs to be a HDC according to the spec,
// but I do not see the right way to release it
// so let's postpone passing HDC till paint event
// when it is really needed. Change spec?
}
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 = nsPluginWindowType_Window;
mPluginWindow.window = GetPluginPort();
// mPluginWindow->type is used in |GetPluginPort| so it must be initilized first
mPluginWindow->type = nsPluginWindowType_Window;
mPluginWindow->window = GetPluginPort();
#if defined(XP_MAC)
// Is this needed in the windowless case ???
@ -4131,7 +4179,9 @@ inline PRUint16 COLOR8TOCOLOR16(PRUint8 color8)
void nsPluginInstanceOwner::FixUpPluginWindow()
{
if (mWidget) {
if (!mWidget || !mPluginWindow)
return;
nscoord absWidgetX = 0;
nscoord absWidgetY = 0;
nsRect widgetClip(0,0,0,0);
@ -4149,14 +4199,14 @@ void nsPluginInstanceOwner::FixUpPluginWindow()
mWidgetVisible = isVisible;
// set the port coordinates
mPluginWindow.x = absWidgetX;
mPluginWindow.y = absWidgetY;
mPluginWindow->x = absWidgetX;
mPluginWindow->y = absWidgetY;
// fix up the clipping region
mPluginWindow.clipRect.top = widgetClip.y;
mPluginWindow.clipRect.left = widgetClip.x;
mPluginWindow.clipRect.bottom = mPluginWindow.clipRect.top + widgetClip.height;
mPluginWindow.clipRect.right = mPluginWindow.clipRect.left + widgetClip.width;
mPluginWindow->clipRect.top = widgetClip.y;
mPluginWindow->clipRect.left = widgetClip.x;
mPluginWindow->clipRect.bottom = mPluginWindow->clipRect.top + widgetClip.height;
mPluginWindow->clipRect.right = mPluginWindow->clipRect.left + widgetClip.width;
// the Mac widget doesn't set the background color right away!!
// the background color needs to be set here on the plugin port
@ -4173,7 +4223,6 @@ void nsPluginInstanceOwner::FixUpPluginWindow()
::RGBBackColor(&macColor);
::SetPort(savePort); // restore port
}
}
#endif // XP_MAC

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

@ -987,6 +987,13 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPluginNativeWindow.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPluginDocLoaderFactory.cpp</PATH>
@ -1098,6 +1105,11 @@
<PATH>nsPluginsDirMac.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPluginNativeWindow.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPluginDirServiceProvider.cpp</PATH>
@ -2064,6 +2076,13 @@
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPluginNativeWindow.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
<FILEKIND>Text</FILEKIND>
<FILEFLAGS>Debug</FILEFLAGS>
</FILE>
<FILE>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPluginDocLoaderFactory.cpp</PATH>
@ -2175,6 +2194,11 @@
<PATH>nsPluginsDirMac.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPluginNativeWindow.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPluginDirServiceProvider.cpp</PATH>
@ -2260,6 +2284,12 @@
<PATH>nsPluginsDirMac.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>pluginDebug.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>
<PATH>nsPluginNativeWindow.cpp</PATH>
<PATHFORMAT>MacOS</PATHFORMAT>
</FILEREF>
<FILEREF>
<TARGETNAME>pluginDebug.shlb</TARGETNAME>
<PATHTYPE>Name</PATHTYPE>

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -55,3 +55,4 @@ npapi.h
npupp.h
nsDefaultPlugin.h
nsPIPluginInstancePeer.h
nsPluginNativeWindow.h

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

@ -57,6 +57,7 @@ EXPORTS = \
nsPluginError.h \
nsDefaultPlugin.h \
nsPIPluginInstancePeer.h \
nsPluginNativeWindow.h \
$(NULL)
# 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)
CPPSRCS += nsPluginsDirBeOS.cpp
CPPSRCS += nsPluginNativeWindow.cpp
else
ifeq ($(OS_ARCH),WINNT)
CPPSRCS += nsPluginsDirWin.cpp
CPPSRCS += nsPluginNativeWindowWin.cpp
else
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
CPPSRCS += nsPluginsDirOS2.cpp
CPPSRCS += nsPluginNativeWindow.cpp
else
CPPSRCS += nsPluginsDirUnix.cpp
CPPSRCS += nsPluginNativeWindow.cpp
endif
endif
endif

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

@ -163,6 +163,7 @@
#include "nsIWebNavigation.h"
#include "nsISupportsArray.h"
#include "nsIDocShell.h"
#include "nsPluginNativeWindow.h"
#ifdef XP_UNIX
#if defined(MOZ_WIDGET_GTK) || defined (MOZ_WIDGET_GTK2)
@ -3624,28 +3625,27 @@ NS_IMETHODIMP nsPluginHostImpl::InstantiateFullPagePlugin(const char *aMimeType,
if (NS_OK == rv)
{
nsIPluginInstance *instance = nsnull;
nsPluginWindow *window = nsnull;
nsCOMPtr<nsIPluginInstance> instance;
nsPluginWindow * win = nsnull;
aOwner->GetInstance(instance);
aOwner->GetWindow(window);
aOwner->GetInstance(*getter_AddRefs(instance));
aOwner->GetWindow(win);
if (nsnull != instance)
if (win && instance)
{
instance->Start();
aOwner->CreateWidget();
// If we've got a native window, the let the plugin know about it.
nsPluginNativeWindow * window = (nsPluginNativeWindow *)win;
if (window->window)
instance->SetWindow(window);
window->CallSetWindow(instance);
rv = NewFullPagePluginStream(aStreamListener, instance);
// If we've got a native window, the let the plugin know about it.
if (window->window)
instance->SetWindow(window);
NS_RELEASE(instance);
window->CallSetWindow(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;
NS_ASSERTION(PR_FALSE, "Plugin performed illegal operation");
@ -6045,9 +6050,9 @@ NS_IMETHODIMP nsPluginHostImpl::HandleBadPlugin(PRLibrary* aLibrary, nsIPluginIn
nsCOMPtr<nsIPluginInstanceOwner> owner;
if (instance) {
if (aInstance) {
nsCOMPtr<nsIPluginInstancePeer> peer;
rv =instance->GetPeer(getter_AddRefs(peer));
rv = aInstance->GetPeer(getter_AddRefs(peer));
if (NS_SUCCEEDED(rv) && peer) {
nsCOMPtr<nsPIPluginInstancePeer> privpeer(do_QueryInterface(peer));
privpeer->GetOwner(getter_AddRefs(owner));
@ -6081,8 +6086,10 @@ NS_IMETHODIMP nsPluginHostImpl::HandleBadPlugin(PRLibrary* aLibrary, nsIPluginIn
// add plugin name to the message
char * pluginname = nsnull;
for (nsPluginTag * tag = mPlugins; tag; tag = tag->mNext) {
if (tag->mLibrary == aLibrary) {
nsActivePlugin * p = mActivePluginList.find(aInstance);
if (p) {
nsPluginTag * tag = p->mPluginTag;
if (tag) {
if (tag->mName)
pluginname = tag->mName;
else
@ -6110,9 +6117,10 @@ NS_IMETHODIMP nsPluginHostImpl::HandleBadPlugin(PRLibrary* aLibrary, nsIPluginIn
return rv;
}
// nsPIPluginHost interface
/**
* nsPIPluginHost interface
*/
////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsPluginHostImpl::SetIsScriptableInstance(nsCOMPtr<nsIPluginInstance> aPluginInstance,
PRBool aScriptable)
@ -6128,8 +6136,6 @@ nsPluginHostImpl::SetIsScriptableInstance(nsCOMPtr<nsIPluginInstance> aPluginIns
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsPluginHostImpl::ParsePostBufferToFixHeaders(
const char *inPostData, PRUint32 inPostDataLen,
@ -6284,7 +6290,6 @@ nsPluginHostImpl::ParsePostBufferToFixHeaders(
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsPluginHostImpl::CreateTmpFileToPost(const char *postDataURL, char **pTmpFileName)
{
@ -6400,6 +6405,20 @@ nsPluginHostImpl::CreateTmpFileToPost(const char *postDataURL, char **pTmpFileNa
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
nsPluginHostImpl::ScanForRealInComponentsFolder(nsIComponentManager * aCompManager)
{

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

@ -55,6 +55,7 @@
#include "nsIPrompt.h"
#include "nsIGenericFactory.h"
#include "nsISupportsArray.h"
#include "nsPluginNativeWindow.h"
class ns4xPlugin;
class nsFileSpec;
@ -363,6 +364,12 @@ public:
NS_IMETHOD
CreateTmpFileToPost(const char *postDataURL, char **pTmpFileName);
NS_IMETHOD
NewPluginNativeWindow(nsPluginNativeWindow ** aPluginNativeWindow);
NS_IMETHOD
DeletePluginNativeWindow(nsPluginNativeWindow * aPluginNativeWindow);
/* Called by GetURL and PostURL */
NS_IMETHOD

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

@ -38,6 +38,9 @@
#ifndef nsPluginSafety_h__
#define nsPluginSafety_h__
#include "npapi.h"
#include "nsIPluginHost.h"
#if defined(XP_PC) && !defined(XP_OS2)
#define CALL_SAFETY_ON
#endif

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

@ -67,6 +67,8 @@
#include "nsContentCID.h"
#include "nsIScriptGlobalObject.h"
#include "nsITimer.h"
#include "nsPIPluginHost.h"
#include "nsPluginNativeWindow.h"
class nsIPrintSettings;
class nsIDOMWindow;
@ -163,7 +165,7 @@ public:
#endif
private:
nsPluginWindow mPluginWindow;
nsPluginNativeWindow *mPluginWindow;
nsIPluginInstance *mInstance;
nsIWidget *mWindow; //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.
if(mOwner != nsnull)
{
nsIPluginInstance *inst;
if(NS_OK == mOwner->GetInstance(inst))
nsCOMPtr<nsIPluginInstance> 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 doCallSetWindowAfterDestroy = PR_FALSE;
@ -468,19 +475,26 @@ PluginViewerImpl::Destroy(void)
// Set Window. This is for bug 50547.
inst->GetValue(nsPluginInstanceVariable_CallSetWindowAfterDestroyBool,
(void *) &doCallSetWindowAfterDestroy);
!doCallSetWindowAfterDestroy ? inst->SetWindow(nsnull) : 0;
if (!doCallSetWindowAfterDestroy) {
if (window)
window->CallSetWindow(nullinst);
else
inst->SetWindow(nsnull);
}
inst->Stop();
inst->Destroy();
doCallSetWindowAfterDestroy ? inst->SetWindow(nsnull) : 0; }
else {
if (doCallSetWindowAfterDestroy) {
if (window)
window->CallSetWindow(nullinst);
else
inst->SetWindow(nsnull);
}
} else {
window ? window->CallSetWindow(nullinst) : inst->SetWindow(nsnull);
inst->Stop();
}
NS_RELEASE(inst);
}
}
return NS_OK;
}
@ -586,9 +600,9 @@ PluginViewerImpl::SetBounds(const nsRect& aBounds)
if (nsnull != mWindow) {
// Don't have the widget repaint. Layout will generate repaint requests
// during reflow
nsIPluginInstance *inst;
nsCOMPtr<nsIPluginInstance> inst;
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;
if (NS_OK == mOwner->GetWindow(win)) {
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
mOwner->FixUpPluginWindow();
#endif
inst->SetWindow(win);
((nsPluginNativeWindow *)win)->CallSetWindow(inst);
}
NS_RELEASE(inst);
}
}
return NS_OK;
@ -616,9 +629,9 @@ PluginViewerImpl::Move(PRInt32 aX, PRInt32 aY)
{
NS_PRECONDITION(nsnull != mWindow, "null window");
if (nsnull != mWindow) {
nsIPluginInstance *inst;
nsCOMPtr<nsIPluginInstance> inst;
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;
if (NS_OK == mOwner->GetWindow(win)) {
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
mOwner->FixUpPluginWindow();
#endif
inst->SetWindow(win);
((nsPluginNativeWindow *)win)->CallSetWindow(inst);
}
NS_RELEASE(inst);
}
}
return NS_OK;
@ -1020,7 +1032,15 @@ pluginInstanceOwner :: pluginInstanceOwner()
{
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;
mWindow = nsnull;
mViewer = nsnull;
@ -1038,6 +1058,14 @@ pluginInstanceOwner :: ~pluginInstanceOwner()
mWindow = 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);
@ -1064,7 +1092,8 @@ NS_IMETHODIMP pluginInstanceOwner :: GetInstance(nsIPluginInstance *&aInstance)
NS_IMETHODIMP pluginInstanceOwner :: GetWindow(nsPluginWindow *&aWindow)
{
aWindow = &mPluginWindow;
NS_ASSERTION(mPluginWindow, "the plugin window object being returned is null");
aWindow = mPluginWindow;
return NS_OK;
}
@ -1076,6 +1105,8 @@ NS_IMETHODIMP pluginInstanceOwner :: GetMode(nsPluginMode *aMode)
NS_IMETHODIMP pluginInstanceOwner :: CreateWidget(void)
{
NS_ENSURE_TRUE(mPluginWindow, NS_ERROR_NULL_POINTER);
PRBool windowless;
nsresult rv = NS_OK;
@ -1093,13 +1124,13 @@ NS_IMETHODIMP pluginInstanceOwner :: CreateWidget(void)
if (PR_TRUE == windowless)
{
mPluginWindow.window = nsnull; //XXX this needs to be a HDC
mPluginWindow.type = nsPluginWindowType_Drawable;
mPluginWindow->window = nsnull; //XXX this needs to be a HDC
mPluginWindow->type = nsPluginWindowType_Drawable;
}
else if (nsnull != mWindow)
{
mPluginWindow.window = (nsPluginPort *)mWindow->GetNativeData(NS_NATIVE_PLUGIN_PORT);
mPluginWindow.type = nsPluginWindowType_Window;
mPluginWindow->window = (nsPluginPort *)mWindow->GetNativeData(NS_NATIVE_PLUGIN_PORT);
mPluginWindow->type = nsPluginWindowType_Window;
}
else
return NS_ERROR_FAILURE;
@ -1447,6 +1478,9 @@ static void GetWidgetPosClipAndVis(nsIWidget* aWidget,nscoord& aAbsX, nscoord& a
void pluginInstanceOwner::FixUpPluginWindow()
{
if (!mPluginWindow)
return;
if (mWindow) {
nscoord absWidgetX = 0;
nscoord absWidgetY = 0;
@ -1458,14 +1492,14 @@ void pluginInstanceOwner::FixUpPluginWindow()
mWidgetVisible = isVisible;
// set the port coordinates
mPluginWindow.x = absWidgetX;
mPluginWindow.y = absWidgetY;
mPluginWindow->x = absWidgetX;
mPluginWindow->y = absWidgetY;
// fix up the clipping region
mPluginWindow.clipRect.top = widgetClip.y;
mPluginWindow.clipRect.left = widgetClip.x;
mPluginWindow.clipRect.bottom = mPluginWindow.clipRect.top + widgetClip.height;
mPluginWindow.clipRect.right = mPluginWindow.clipRect.left + widgetClip.width;
mPluginWindow->clipRect.top = widgetClip.y;
mPluginWindow->clipRect.left = widgetClip.x;
mPluginWindow->clipRect.bottom = mPluginWindow->clipRect.top + widgetClip.height;
mPluginWindow->clipRect.right = mPluginWindow->clipRect.left + widgetClip.width;
}
}