Make sure that non-image inputs don't claim to have a useful image via

nsIImageLoadingContent.  Bug 301635, r=biesi, sr=jst
This commit is contained in:
bzbarsky%mit.edu 2005-08-19 14:55:07 +00:00
parent 32368a1a98
commit 9df2704ed9
3 changed files with 25 additions and 0 deletions

View File

@ -375,6 +375,9 @@ nsImageLoadingContent::LoadImageWithChannel(nsIChannel* aChannel,
// Don't bother
return NS_OK;
}
// Null out our mCurrentURI, in case we have no image requests right now.
mCurrentURI = nsnull;
CancelImageRequests(NS_ERROR_IMAGE_SRC_CHANGED, PR_FALSE,
nsIContentPolicy::ACCEPT);
@ -527,6 +530,14 @@ nsImageLoadingContent::ImageURIChanged(const nsAString& aNewURI,
return NS_OK;
}
void
nsImageLoadingContent::CancelImageRequests()
{
// Make sure to null out mCurrentURI here, so we no longer look like an image
mCurrentURI = nsnull;
CancelImageRequests(NS_BINDING_ABORTED, PR_TRUE, nsIContentPolicy::ACCEPT);
}
void
nsImageLoadingContent::CancelImageRequests(nsresult aReason,
PRBool aEvenIfSizeAvailable,

View File

@ -87,6 +87,13 @@ protected:
nsresult ImageURIChanged(const nsAString& aNewURI,
PRBool aForce);
/**
* CancelImageRequests is called by subclasses when they want to
* cancel all image requests (for example when the subclass is
* somehow not an image anymore).
*/
void CancelImageRequests();
private:
/**
* Struct used to manage the image observers.

View File

@ -531,6 +531,13 @@ nsHTMLInputElement::AfterSetAttr(PRInt32 aNameSpaceID, nsIAtom* aName,
}
}
if (mType != NS_FORM_INPUT_IMAGE) {
// We're no longer an image input. Cancel our image requests, if we have
// any. Note that doing this when we already weren't an image is ok --
// just does nothing.
CancelImageRequests();
}
if (aNotify && mType == NS_FORM_INPUT_IMAGE && !mCurrentRequest) {
// We just got switched to be an image input; we should see
// whether we have an image to load;