Fix for 44322 -- implementation of windowless pluign API, patch by dbrittain@superscape.com and av, r=(av, peterl), sr=attinase, a=dbaron

This commit is contained in:
av%netscape.com 2001-06-18 21:41:57 +00:00
Родитель 57f282e844
Коммит ff513c7423
8 изменённых файлов: 402 добавлений и 18 удалений

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

@ -136,6 +136,14 @@ public:
NS_IMETHOD GetDocument(nsIDocument* *aDocument);
NS_IMETHOD InvalidateRect(nsPluginRect *invalidRect);
NS_IMETHOD InvalidateRegion(nsPluginRegion invalidRegion);
NS_IMETHOD ForceRedraw();
NS_IMETHOD GetValue(nsPluginInstancePeerVariable variable, void *value);
//nsIPluginTagInfo interface
NS_IMETHOD GetAttributes(PRUint16& n, const char*const*& names,
@ -572,11 +580,14 @@ nsObjectFrame::CreateWidget(nsIPresContext* aPresContext,
viewMan->InsertChild(parView, view, 0);
result = view->CreateWidget(kWidgetCID);
if(aViewOnly != PR_TRUE) {
if (NS_OK != result) {
result = NS_OK; //XXX why OK? MMP
goto exit; //XXX sue me. MMP
result = view->CreateWidget(kWidgetCID);
if (NS_OK != result) {
result = NS_OK; //XXX why OK? MMP
goto exit; //XXX sue me. MMP
}
}
}
@ -1288,6 +1299,17 @@ nsObjectFrame::DidReflow(nsIPresContext* aPresContext,
GetOffsetFromView(aPresContext, origin, &parentWithView);
// if it's windowless we want to get the offset from the parent frame
if (window->type == nsPluginWindowType_Drawable)
{
nsIFrame* parentFrame;
GetParentWithView(aPresContext, &parentFrame);
if(parentFrame != nsnull)
parentFrame->GetOffsetFromView(aPresContext, origin, &parentWithView);
}
#if 0
// beard: how do we get this?
parentWithView->GetScrollOffset(&offx, &offy);
@ -2023,6 +2045,106 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocument(nsIDocument* *aDocument)
return rv;
}
NS_IMETHODIMP nsPluginInstanceOwner::InvalidateRect(nsPluginRect *invalidRect)
{
nsresult rv = NS_ERROR_FAILURE;
if(invalidRect)
{
//no reference count on view
nsIView* view;
rv = mOwner->GetView(mContext, &view);
if((rv == NS_OK) && view)
{
float ptot;
mContext->GetPixelsToTwips(&ptot);
nsRect rect((int)(ptot * invalidRect->left),
(int)(ptot * invalidRect->top),
(int)(ptot * (invalidRect->right - invalidRect->left)),
(int)(ptot * (invalidRect->bottom - invalidRect->top)));
nsIViewManager* manager;
rv = view->GetViewManager(manager);
//set flags to not do a synchronous update, force update does the redraw
if((rv == NS_OK) && manager)
{
rv = manager->UpdateView(view, rect, NS_VMREFRESH_NO_SYNC);
NS_RELEASE(manager);
}
}
}
return rv;
}
NS_IMETHODIMP nsPluginInstanceOwner::InvalidateRegion(nsPluginRegion invalidRegion)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsPluginInstanceOwner::ForceRedraw()
{
//no reference count on view
nsIView* view;
nsresult rv = mOwner->GetView(mContext, &view);
if((rv == NS_OK) && view)
{
nsIViewManager* manager;
rv = view->GetViewManager(manager);
if((rv == NS_OK) && manager)
{
rv = manager->Composite();
NS_RELEASE(manager);
}
}
return rv;
}
NS_IMETHODIMP nsPluginInstanceOwner::GetValue(nsPluginInstancePeerVariable variable, void *value)
{
nsresult rv = NS_ERROR_FAILURE;
switch(variable)
{
case nsPluginInstancePeerVariable_NetscapeWindow:
{
//no reference count on view
nsIView* view;
rv = mOwner->GetView(mContext, &view);
if((rv == NS_OK) && view)
{
nsIViewManager* manager;
rv = view->GetViewManager(manager);
if((rv == NS_OK) && manager)
{
nsIWidget* widget;
rv = manager->GetWidget(&widget);
if((rv == NS_OK) && widget)
{
void** pvalue = (void**)value;
*pvalue = (void*)widget->GetNativeData(NS_NATIVE_WINDOW);
NS_RELEASE(widget);
}
NS_RELEASE(manager);
}
}
break;
}
}
return rv;
}
NS_IMETHODIMP nsPluginInstanceOwner::GetTagType(nsPluginTagType *result)
{
nsresult rv = NS_ERROR_FAILURE;
@ -3064,7 +3186,12 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
{
mOwner->GetView(mContext, &view);
if (view)
{
view->GetWidget(mWidget);
PRBool fTransparent;
mInstance->GetValue(nsPluginInstanceVariable_TransparentBool, (void *)&fTransparent);
view->SetContentTransparency(fTransparent);
}
if (PR_TRUE == windowless)
{
@ -3077,10 +3204,12 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
else if (mWidget)
{
mWidget->Resize(mPluginWindow.width, mPluginWindow.height, PR_FALSE);
mPluginWindow.window = GetPluginPort();
mPluginWindow.type = nsPluginWindowType_Window;
#if defined(XP_MAC)
// Is this needed in the windowless case ???
// start a periodic timer to provide null events to the plugin instance.
mPluginTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
if (rv == NS_OK)

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

@ -136,6 +136,14 @@ public:
NS_IMETHOD GetDocument(nsIDocument* *aDocument);
NS_IMETHOD InvalidateRect(nsPluginRect *invalidRect);
NS_IMETHOD InvalidateRegion(nsPluginRegion invalidRegion);
NS_IMETHOD ForceRedraw();
NS_IMETHOD GetValue(nsPluginInstancePeerVariable variable, void *value);
//nsIPluginTagInfo interface
NS_IMETHOD GetAttributes(PRUint16& n, const char*const*& names,
@ -572,11 +580,14 @@ nsObjectFrame::CreateWidget(nsIPresContext* aPresContext,
viewMan->InsertChild(parView, view, 0);
result = view->CreateWidget(kWidgetCID);
if(aViewOnly != PR_TRUE) {
if (NS_OK != result) {
result = NS_OK; //XXX why OK? MMP
goto exit; //XXX sue me. MMP
result = view->CreateWidget(kWidgetCID);
if (NS_OK != result) {
result = NS_OK; //XXX why OK? MMP
goto exit; //XXX sue me. MMP
}
}
}
@ -1288,6 +1299,17 @@ nsObjectFrame::DidReflow(nsIPresContext* aPresContext,
GetOffsetFromView(aPresContext, origin, &parentWithView);
// if it's windowless we want to get the offset from the parent frame
if (window->type == nsPluginWindowType_Drawable)
{
nsIFrame* parentFrame;
GetParentWithView(aPresContext, &parentFrame);
if(parentFrame != nsnull)
parentFrame->GetOffsetFromView(aPresContext, origin, &parentWithView);
}
#if 0
// beard: how do we get this?
parentWithView->GetScrollOffset(&offx, &offy);
@ -2023,6 +2045,106 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocument(nsIDocument* *aDocument)
return rv;
}
NS_IMETHODIMP nsPluginInstanceOwner::InvalidateRect(nsPluginRect *invalidRect)
{
nsresult rv = NS_ERROR_FAILURE;
if(invalidRect)
{
//no reference count on view
nsIView* view;
rv = mOwner->GetView(mContext, &view);
if((rv == NS_OK) && view)
{
float ptot;
mContext->GetPixelsToTwips(&ptot);
nsRect rect((int)(ptot * invalidRect->left),
(int)(ptot * invalidRect->top),
(int)(ptot * (invalidRect->right - invalidRect->left)),
(int)(ptot * (invalidRect->bottom - invalidRect->top)));
nsIViewManager* manager;
rv = view->GetViewManager(manager);
//set flags to not do a synchronous update, force update does the redraw
if((rv == NS_OK) && manager)
{
rv = manager->UpdateView(view, rect, NS_VMREFRESH_NO_SYNC);
NS_RELEASE(manager);
}
}
}
return rv;
}
NS_IMETHODIMP nsPluginInstanceOwner::InvalidateRegion(nsPluginRegion invalidRegion)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsPluginInstanceOwner::ForceRedraw()
{
//no reference count on view
nsIView* view;
nsresult rv = mOwner->GetView(mContext, &view);
if((rv == NS_OK) && view)
{
nsIViewManager* manager;
rv = view->GetViewManager(manager);
if((rv == NS_OK) && manager)
{
rv = manager->Composite();
NS_RELEASE(manager);
}
}
return rv;
}
NS_IMETHODIMP nsPluginInstanceOwner::GetValue(nsPluginInstancePeerVariable variable, void *value)
{
nsresult rv = NS_ERROR_FAILURE;
switch(variable)
{
case nsPluginInstancePeerVariable_NetscapeWindow:
{
//no reference count on view
nsIView* view;
rv = mOwner->GetView(mContext, &view);
if((rv == NS_OK) && view)
{
nsIViewManager* manager;
rv = view->GetViewManager(manager);
if((rv == NS_OK) && manager)
{
nsIWidget* widget;
rv = manager->GetWidget(&widget);
if((rv == NS_OK) && widget)
{
void** pvalue = (void**)value;
*pvalue = (void*)widget->GetNativeData(NS_NATIVE_WINDOW);
NS_RELEASE(widget);
}
NS_RELEASE(manager);
}
}
break;
}
}
return rv;
}
NS_IMETHODIMP nsPluginInstanceOwner::GetTagType(nsPluginTagType *result)
{
nsresult rv = NS_ERROR_FAILURE;
@ -3064,7 +3186,12 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
{
mOwner->GetView(mContext, &view);
if (view)
{
view->GetWidget(mWidget);
PRBool fTransparent;
mInstance->GetValue(nsPluginInstanceVariable_TransparentBool, (void *)&fTransparent);
view->SetContentTransparency(fTransparent);
}
if (PR_TRUE == windowless)
{
@ -3077,10 +3204,12 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
else if (mWidget)
{
mWidget->Resize(mPluginWindow.width, mPluginWindow.height, PR_FALSE);
mPluginWindow.window = GetPluginPort();
mPluginWindow.type = nsPluginWindowType_Window;
#if defined(XP_MAC)
// Is this needed in the windowless case ???
// start a periodic timer to provide null events to the plugin instance.
mPluginTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
if (rv == NS_OK)

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

@ -97,6 +97,30 @@ public:
*/
NS_IMETHOD
GetDocument(nsIDocument* *aDocument) = 0;
/**
* Invalidate the rectangle
*/
NS_IMETHOD
InvalidateRect(nsPluginRect *invalidRect) = 0;
/**
* Invalidate the region
*/
NS_IMETHOD
InvalidateRegion(nsPluginRegion invalidRegion) = 0;
/**
* Force a redraw
*/
NS_IMETHOD
ForceRedraw() = 0;
/**
* Get the specified variable
*/
NS_IMETHOD
GetValue(nsPluginInstancePeerVariable variable, void *value) = 0;
};
#endif

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

@ -125,8 +125,10 @@ nsresult nsPluginInstancePeerImpl::QueryInterface(const nsIID& iid, void** insta
NS_IMETHODIMP nsPluginInstancePeerImpl::GetValue(nsPluginInstancePeerVariable variable, void *value)
{
printf("instance peer getvalue %d called\n", variable);
return NS_ERROR_FAILURE;
if(!mOwner)
return NS_ERROR_FAILURE;
return mOwner->GetValue(variable, value);
}
NS_IMETHODIMP nsPluginInstancePeerImpl::GetMIMEType(nsMIMEType *result)
@ -934,17 +936,26 @@ nsresult nsPluginInstancePeerImpl::GetOwner(nsIPluginInstanceOwner *&aOwner)
NS_IMETHODIMP nsPluginInstancePeerImpl::InvalidateRect(nsPluginRect *invalidRect)
{
return NS_OK;
if(!mOwner)
return NS_ERROR_FAILURE;
return mOwner->InvalidateRect(invalidRect);
}
NS_IMETHODIMP nsPluginInstancePeerImpl::InvalidateRegion(nsPluginRegion invalidRegion)
{
return NS_OK;
if(!mOwner)
return NS_ERROR_FAILURE;
return mOwner->InvalidateRegion(invalidRegion);
}
NS_IMETHODIMP nsPluginInstancePeerImpl::ForceRedraw(void)
{
return NS_OK;
if(!mOwner)
return NS_ERROR_FAILURE;
return mOwner->ForceRedraw();
}
/*void

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

@ -112,6 +112,15 @@ public:
NS_IMETHOD ShowStatus(const char *aStatusMsg);
NS_IMETHOD GetDocument(nsIDocument* *aDocument);
NS_IMETHOD InvalidateRect(nsPluginRect *invalidRect);
NS_IMETHOD InvalidateRegion(nsPluginRegion invalidRegion);
NS_IMETHOD ForceRedraw();
NS_IMETHOD GetValue(nsPluginInstancePeerVariable variable, void *value);
//nsIEventListener interface
nsEventStatus ProcessEvent(const nsGUIEvent & anEvent);
@ -682,6 +691,25 @@ nsresult PluginViewerImpl::GetDocument(nsIDocument* *aDocument)
return NS_OK;
}
NS_IMETHODIMP pluginInstanceOwner::InvalidateRect(nsPluginRect *invalidRect)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP pluginInstanceOwner::InvalidateRegion(nsPluginRegion invalidRegion)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP pluginInstanceOwner::ForceRedraw()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP pluginInstanceOwner::GetValue(nsPluginInstancePeerVariable variable, void *value)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* ========================================================================================
* nsIContentViewerFile
* ======================================================================================== */

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

@ -97,6 +97,30 @@ public:
*/
NS_IMETHOD
GetDocument(nsIDocument* *aDocument) = 0;
/**
* Invalidate the rectangle
*/
NS_IMETHOD
InvalidateRect(nsPluginRect *invalidRect) = 0;
/**
* Invalidate the region
*/
NS_IMETHOD
InvalidateRegion(nsPluginRegion invalidRegion) = 0;
/**
* Force a redraw
*/
NS_IMETHOD
ForceRedraw() = 0;
/**
* Get the specified variable
*/
NS_IMETHOD
GetValue(nsPluginInstancePeerVariable variable, void *value) = 0;
};
#endif

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

@ -125,8 +125,10 @@ nsresult nsPluginInstancePeerImpl::QueryInterface(const nsIID& iid, void** insta
NS_IMETHODIMP nsPluginInstancePeerImpl::GetValue(nsPluginInstancePeerVariable variable, void *value)
{
printf("instance peer getvalue %d called\n", variable);
return NS_ERROR_FAILURE;
if(!mOwner)
return NS_ERROR_FAILURE;
return mOwner->GetValue(variable, value);
}
NS_IMETHODIMP nsPluginInstancePeerImpl::GetMIMEType(nsMIMEType *result)
@ -934,17 +936,26 @@ nsresult nsPluginInstancePeerImpl::GetOwner(nsIPluginInstanceOwner *&aOwner)
NS_IMETHODIMP nsPluginInstancePeerImpl::InvalidateRect(nsPluginRect *invalidRect)
{
return NS_OK;
if(!mOwner)
return NS_ERROR_FAILURE;
return mOwner->InvalidateRect(invalidRect);
}
NS_IMETHODIMP nsPluginInstancePeerImpl::InvalidateRegion(nsPluginRegion invalidRegion)
{
return NS_OK;
if(!mOwner)
return NS_ERROR_FAILURE;
return mOwner->InvalidateRegion(invalidRegion);
}
NS_IMETHODIMP nsPluginInstancePeerImpl::ForceRedraw(void)
{
return NS_OK;
if(!mOwner)
return NS_ERROR_FAILURE;
return mOwner->ForceRedraw();
}
/*void

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

@ -112,6 +112,15 @@ public:
NS_IMETHOD ShowStatus(const char *aStatusMsg);
NS_IMETHOD GetDocument(nsIDocument* *aDocument);
NS_IMETHOD InvalidateRect(nsPluginRect *invalidRect);
NS_IMETHOD InvalidateRegion(nsPluginRegion invalidRegion);
NS_IMETHOD ForceRedraw();
NS_IMETHOD GetValue(nsPluginInstancePeerVariable variable, void *value);
//nsIEventListener interface
nsEventStatus ProcessEvent(const nsGUIEvent & anEvent);
@ -682,6 +691,25 @@ nsresult PluginViewerImpl::GetDocument(nsIDocument* *aDocument)
return NS_OK;
}
NS_IMETHODIMP pluginInstanceOwner::InvalidateRect(nsPluginRect *invalidRect)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP pluginInstanceOwner::InvalidateRegion(nsPluginRegion invalidRegion)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP pluginInstanceOwner::ForceRedraw()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP pluginInstanceOwner::GetValue(nsPluginInstancePeerVariable variable, void *value)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* ========================================================================================
* nsIContentViewerFile
* ======================================================================================== */