Bug 641621: Fix bug in which we misinterpret an NPError return value as an nsresult. r=bsmedberg

This commit is contained in:
Josh Aas 2011-03-23 11:46:09 -07:00
Родитель 692d6d526b
Коммит 1bc8708eb5
5 изменённых файлов: 73 добавлений и 39 удалений

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

@ -3517,9 +3517,14 @@ NS_IMETHODIMP nsPluginInstanceOwner::InvalidateRect(NPRect *invalidRect)
#ifdef MOZ_USE_IMAGE_EXPOSE
PRBool simpleImageRender = PR_FALSE;
mInstance->GetValueFromPlugin(NPPVpluginWindowlessLocalBool,
&simpleImageRender);
if (simpleImageRender) {
nsresult rv = mInstance->GetValueFromPlugin(NPPVpluginWindowlessLocalBool,
&simpleImageRender);
// If the call returned an error code make sure we still use our default value.
if (NS_FAILED(rv)) {
simpleImageRender = PR_FALSE;
}
if (simpleImageRender) {
NativeImageDraw(invalidRect);
return NS_OK;
}
@ -4401,8 +4406,8 @@ void nsPluginInstanceOwner::RenderCoreAnimation(CGContextRef aCGContext,
if (mCARenderer.isInit() == false) {
void *caLayer = NULL;
mInstance->GetValueFromPlugin(NPPVpluginCoreAnimationLayer, &caLayer);
if (!caLayer) {
nsresult rv = mInstance->GetValueFromPlugin(NPPVpluginCoreAnimationLayer, &caLayer);
if (NS_FAILED(rv) || !caLayer) {
return;
}
@ -5956,8 +5961,12 @@ void nsPluginInstanceOwner::Paint(gfxContext* aContext,
// us to handle plugins that do not self invalidate (slowly, but
// accurately), and it allows us to reduce flicker.
PRBool simpleImageRender = PR_FALSE;
mInstance->GetValueFromPlugin(NPPVpluginWindowlessLocalBool,
&simpleImageRender);
nsresult rv = mInstance->GetValueFromPlugin(NPPVpluginWindowlessLocalBool,
&simpleImageRender);
// If the call returned an error code make sure we still use our default value.
if (NS_FAILED(rv)) {
simpleImageRender = PR_FALSE;
}
if (simpleImageRender) {
gfxMatrix matrix = aContext->CurrentMatrix();
if (!matrix.HasNonAxisAlignedTransform())
@ -7023,10 +7032,15 @@ nsPluginInstanceOwner::SetAbsoluteScreenPosition(nsIDOMElement* element,
return NS_OK;
PRBool simpleImageRender = PR_FALSE;
mInstance->GetValueFromPlugin(NPPVpluginWindowlessLocalBool,
&simpleImageRender);
if (simpleImageRender)
nsresult rv = mInstance->GetValueFromPlugin(NPPVpluginWindowlessLocalBool,
&simpleImageRender);
// If the call returned an error code make sure we still use our default value.
if (NS_FAILED(rv)) {
simpleImageRender = PR_FALSE;
}
if (simpleImageRender) {
NativeImageDraw();
}
return NS_OK;
}
#endif

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

@ -2042,7 +2042,11 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
inst->IsWindowless(&windowless);
NPBool needXEmbed = PR_FALSE;
if (!windowless) {
inst->GetValueFromPlugin(NPPVpluginNeedsXEmbed, &needXEmbed);
res = inst->GetValueFromPlugin(NPPVpluginNeedsXEmbed, &needXEmbed);
// If the call returned an error code make sure we still use our default value.
if (NS_FAILED(res)) {
needXEmbed = PR_FALSE;
}
}
if (windowless || needXEmbed) {
(*(Display **)result) = mozilla::DefaultXDisplay();

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

@ -602,19 +602,26 @@ NS_IMETHODIMP nsNPAPIPluginInstance::GetValueFromPlugin(NPPVariable variable, vo
return NS_OK;
}
#endif
if (!mPlugin || !mPlugin->GetLibrary())
return NS_ERROR_FAILURE;
NPPluginFuncs* pluginFunctions = mPlugin->PluginFuncs();
nsresult rv = NS_ERROR_FAILURE;
if (pluginFunctions->getvalue && RUNNING == mRunning) {
PluginDestructionGuard guard(this);
NS_TRY_SAFE_CALL_RETURN(rv, (*pluginFunctions->getvalue)(&mNPP, variable, value), this);
NPError pluginError = NPERR_GENERIC_ERROR;
NS_TRY_SAFE_CALL_RETURN(pluginError, (*pluginFunctions->getvalue)(&mNPP, variable, value), this);
NPP_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
("NPP GetValue called: this=%p, npp=%p, var=%d, value=%d, return=%d\n",
this, &mNPP, variable, value, rv));
this, &mNPP, variable, value, pluginError));
if (pluginError == NPERR_NO_ERROR) {
rv = NS_OK;
}
}
return rv;

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

@ -78,7 +78,6 @@ private:
nsresult CreateXEmbedWindow();
nsresult CreateXtWindow();
void SetAllocation();
PRBool CanGetValueFromPlugin(nsCOMPtr<nsIPluginInstance> &aPluginInstance);
#ifdef MOZ_COMPOSITED_PLUGINS
nsresult CreateXCompositedWindow();
static GdkFilterReturn plugin_composite_filter_func (GdkXEvent *xevent,
@ -182,19 +181,22 @@ nsPluginNativeWindowGtk2::plugin_composite_filter_func (GdkXEvent *xevent,
nsresult nsPluginNativeWindowGtk2::CallSetWindow(nsCOMPtr<nsIPluginInstance> &aPluginInstance)
{
if(aPluginInstance) {
if (aPluginInstance) {
if (type == NPWindowTypeWindow) {
nsresult rv;
if(!mSocketWidget) {
PRBool needXEmbed = PR_FALSE;
if (CanGetValueFromPlugin(aPluginInstance)) {
rv = aPluginInstance->GetValueFromPlugin(NPPVpluginNeedsXEmbed, &needXEmbed);
#ifdef DEBUG
printf("nsPluginNativeWindowGtk2: NPPVpluginNeedsXEmbed=%d\n", needXEmbed);
#endif
}
if (!mSocketWidget) {
nsresult rv;
if(needXEmbed) {
PRBool needXEmbed = PR_FALSE;
rv = aPluginInstance->GetValueFromPlugin(NPPVpluginNeedsXEmbed, &needXEmbed);
// If the call returned an error code make sure we still use our default value.
if (NS_FAILED(rv)) {
needXEmbed = PR_FALSE;
}
#ifdef DEBUG
printf("nsPluginNativeWindowGtk2: NPPVpluginNeedsXEmbed=%d\n", needXEmbed);
#endif
if (needXEmbed) {
#ifdef MOZ_COMPOSITED_PLUGINS
rv = CreateXCompositedWindow();
#else
@ -204,17 +206,20 @@ nsresult nsPluginNativeWindowGtk2::CallSetWindow(nsCOMPtr<nsIPluginInstance> &aP
else {
rv = CreateXtWindow();
}
if(NS_FAILED(rv))
if (NS_FAILED(rv)) {
return NS_ERROR_FAILURE;
}
}
if(!mSocketWidget)
if (!mSocketWidget) {
return NS_ERROR_FAILURE;
}
// Make sure to resize and re-place the window if required.
// Need to reset "window" each time as nsObjectFrame::DidReflow sets it
// to the ancestor window.
if(GTK_IS_XTBIN(mSocketWidget)) {
if (GTK_IS_XTBIN(mSocketWidget)) {
gtk_xtbin_resize(mSocketWidget, width, height);
// Point the NPWindow structures window to the actual X window
window = (void*)GTK_XTBIN(mSocketWidget)->xtwindow;
@ -436,11 +441,6 @@ nsresult nsPluginNativeWindowGtk2::CreateXtWindow() {
return NS_OK;
}
PRBool nsPluginNativeWindowGtk2::CanGetValueFromPlugin(nsCOMPtr<nsIPluginInstance> &aPluginInstance)
{
return PR_TRUE;
}
/* static */
gboolean
plug_removed_cb (GtkWidget *widget, gpointer data)

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

@ -158,9 +158,13 @@ nsPluginByteRangeStreamListener::OnStartRequest(nsIRequest *request, nsISupports
if (responseCode != 200) {
PRBool bWantsAllNetworkStreams = PR_FALSE;
pslp->GetPluginInstance()->
GetValueFromPlugin(NPPVpluginWantsAllNetworkStreams,
(void*)&bWantsAllNetworkStreams);
rv = pslp->GetPluginInstance()->GetValueFromPlugin(NPPVpluginWantsAllNetworkStreams,
&bWantsAllNetworkStreams);
// If the call returned an error code make sure we still use our default value.
if (NS_FAILED(rv)) {
bWantsAllNetworkStreams = PR_FALSE;
}
if (!bWantsAllNetworkStreams){
return NS_ERROR_FAILURE;
}
@ -515,7 +519,7 @@ NS_IMETHODIMP
nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request,
nsISupports* aContext)
{
nsresult rv = NS_OK;
nsresult rv = NS_OK;
if (mRequests.IndexOfObject(GetBaseRequest(request)) == -1) {
NS_ASSERTION(mRequests.Count() == 0,
@ -549,8 +553,13 @@ nsPluginStreamListenerPeer::OnStartRequest(nsIRequest *request,
if (responseCode > 206) { // not normal
PRBool bWantsAllNetworkStreams = PR_FALSE;
mPluginInstance->GetValueFromPlugin(NPPVpluginWantsAllNetworkStreams,
(void*)&bWantsAllNetworkStreams);
rv = mPluginInstance->GetValueFromPlugin(NPPVpluginWantsAllNetworkStreams,
&bWantsAllNetworkStreams);
// If the call returned an error code make sure we still use our default value.
if (NS_FAILED(rv)) {
bWantsAllNetworkStreams = PR_FALSE;
}
if (!bWantsAllNetworkStreams) {
mRequestFailed = PR_TRUE;
return NS_ERROR_FAILURE;