зеркало из https://github.com/mozilla/gecko-dev.git
Bug 731419 - Part 2: Discard image data immediately on tab close, DOM changes. r=bz
This commit is contained in:
Родитель
35076a79dd
Коммит
996c02e7e2
|
@ -3247,6 +3247,14 @@ nsIDocument::TakeFrameRequestCallbacks(FrameRequestCallbackList& aCallbacks)
|
||||||
mFrameRequestCallbacks.Clear();
|
mFrameRequestCallbacks.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PLDHashOperator RequestDiscardEnumerator(imgIRequest* aKey,
|
||||||
|
PRUint32 aData,
|
||||||
|
void* userArg)
|
||||||
|
{
|
||||||
|
aKey->RequestDiscard();
|
||||||
|
return PL_DHASH_NEXT;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nsDocument::DeleteShell()
|
nsDocument::DeleteShell()
|
||||||
{
|
{
|
||||||
|
@ -3255,6 +3263,11 @@ nsDocument::DeleteShell()
|
||||||
RevokeAnimationFrameNotifications();
|
RevokeAnimationFrameNotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When our shell goes away, request that all our images be immediately
|
||||||
|
// discarded, so we don't carry around decoded image data for a document we
|
||||||
|
// no longer intend to paint.
|
||||||
|
mImageTracker.EnumerateRead(RequestDiscardEnumerator, nsnull);
|
||||||
|
|
||||||
mPresShell = nsnull;
|
mPresShell = nsnull;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8309,26 +8322,32 @@ nsDocument::RemoveImage(imgIRequest* aImage)
|
||||||
|
|
||||||
// If the count is now zero, remove from the tracker.
|
// If the count is now zero, remove from the tracker.
|
||||||
// Otherwise, set the new value.
|
// Otherwise, set the new value.
|
||||||
if (count == 0) {
|
if (count != 0) {
|
||||||
mImageTracker.Remove(aImage);
|
|
||||||
} else {
|
|
||||||
mImageTracker.Put(aImage, count);
|
mImageTracker.Put(aImage, count);
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mImageTracker.Remove(aImage);
|
||||||
|
|
||||||
nsresult rv = NS_OK;
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
// If we removed the image from the tracker and we're locking images, unlock
|
// Now that we're no longer tracking this image, unlock it if we'd
|
||||||
// this image.
|
// previously locked it.
|
||||||
if (count == 0 && mLockingImages)
|
if (mLockingImages) {
|
||||||
rv = aImage->UnlockImage();
|
rv = aImage->UnlockImage();
|
||||||
|
}
|
||||||
|
|
||||||
// If we removed the image from the tracker and we're animating images,
|
// If we're animating images, remove our request to animate this one.
|
||||||
// remove our request to animate this image.
|
if (mAnimatingImages) {
|
||||||
if (count == 0 && mAnimatingImages) {
|
|
||||||
nsresult rv2 = aImage->DecrementAnimationConsumers();
|
nsresult rv2 = aImage->DecrementAnimationConsumers();
|
||||||
rv = NS_SUCCEEDED(rv) ? rv2 : rv;
|
rv = NS_SUCCEEDED(rv) ? rv2 : rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Request that the image be discarded if nobody else holds a lock on it.
|
||||||
|
// Do this even if !mLockingImages, because even if we didn't just unlock
|
||||||
|
// this image, it might still be a candidate for discarding.
|
||||||
|
aImage->RequestDiscard();
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче