Bug 756419 - White standalone image background flashes into view when switching tabs. r=roc,bholley

This commit is contained in:
Jared Wein
2012-08-08 12:42:37 -07:00
parent 0519366022
commit 420fcd774a
3 changed files with 30 additions and 8 deletions

View File

@@ -92,7 +92,9 @@ public:
// imgIDecoderObserver (override nsStubImageDecoderObserver)
NS_IMETHOD OnStartContainer(imgIRequest* aRequest, imgIContainer* aImage);
NS_IMETHOD OnStopContainer(imgIRequest* aRequest, imgIContainer* aImage);
NS_IMETHOD OnStopDecode(imgIRequest *aRequest, nsresult aStatus, const PRUnichar *aStatusArg);
NS_IMETHOD OnDiscard(imgIRequest *aRequest);
// nsIDOMEventListener
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
@@ -519,6 +521,20 @@ ImageDocument::OnStartContainer(imgIRequest* aRequest, imgIContainer* aImage)
return NS_OK;
}
NS_IMETHODIMP
ImageDocument::OnStopContainer(imgIRequest* aRequest, imgIContainer* aImage)
{
if (mImageContent) {
// Update the background-color of the image only after the
// image has been decoded to prevent flashes of just the
// background-color.
mImageContent->SetAttr(kNameSpaceID_None, nsGkAtoms::_class,
NS_LITERAL_STRING("decoded"), true);
}
return NS_OK;
}
NS_IMETHODIMP
ImageDocument::OnStopDecode(imgIRequest *aRequest,
nsresult aStatus,
@@ -526,12 +542,6 @@ ImageDocument::OnStopDecode(imgIRequest *aRequest,
{
UpdateTitleAndCharset();
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mImageContent);
if (imageLoader) {
mObservingImageLoader = false;
imageLoader->RemoveObserver(this);
}
// mImageContent can be null if the document is already destroyed
if (NS_FAILED(aStatus) && mStringBundle && mImageContent) {
nsCAutoString src;
@@ -549,6 +559,18 @@ ImageDocument::OnStopDecode(imgIRequest *aRequest,
return NS_OK;
}
NS_IMETHODIMP
ImageDocument::OnDiscard(imgIRequest *aRequest)
{
// mImageContent can be null if the document is already destroyed
if (mImageContent) {
// Remove any decoded-related styling when the image is unloaded.
mImageContent->UnsetAttr(kNameSpaceID_None, nsGkAtoms::_class,
true);
}
return NS_OK;
}
NS_IMETHODIMP
ImageDocument::HandleEvent(nsIDOMEvent* aEvent)
{