diff --git a/content/base/public/nsIDocument.h b/content/base/public/nsIDocument.h index 54a9316db69..cac86556e7c 100644 --- a/content/base/public/nsIDocument.h +++ b/content/base/public/nsIDocument.h @@ -79,8 +79,8 @@ class Element; } // namespace mozilla #define NS_IDOCUMENT_IID \ -{ 0x57fe44ae, 0x6656, 0x44b8, \ - { 0x8d, 0xc0, 0xfc, 0xa7, 0x43, 0x28, 0xbe, 0x86 } } +{ 0x0e1324c9, 0xc997, 0x447e, \ + { 0xbc, 0xd9, 0xa6, 0x57, 0x80, 0x29, 0x91, 0xe4 } } // Flag for AddStyleSheet(). #define NS_STYLESHEET_FROM_CATALOG (1 << 0) @@ -1621,7 +1621,10 @@ public: // Add/Remove images from the document image tracker virtual nsresult AddImage(imgIRequest* aImage) = 0; - virtual nsresult RemoveImage(imgIRequest* aImage) = 0; + // If the REQUEST_DISCARD flag is passed then if the lock count is zero we + // will request the image be discarded now (instead of waiting). + enum { REQUEST_DISCARD = 0x1 }; + virtual nsresult RemoveImage(imgIRequest* aImage, uint32_t aFlags = 0) = 0; // Makes the images on this document locked/unlocked. By default, the locking // state is unlocked/false. diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index fde7e2d7383..c4cf12796f7 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -8424,7 +8424,7 @@ nsDocument::NotifyAudioAvailableListener() } nsresult -nsDocument::RemoveImage(imgIRequest* aImage) +nsDocument::RemoveImage(imgIRequest* aImage, uint32_t aFlags) { NS_ENSURE_ARG_POINTER(aImage); @@ -8460,10 +8460,12 @@ nsDocument::RemoveImage(imgIRequest* aImage) 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(); + if (aFlags & REQUEST_DISCARD) { + // 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; } diff --git a/content/base/src/nsDocument.h b/content/base/src/nsDocument.h index 972c4c39e58..f9a620900c5 100644 --- a/content/base/src/nsDocument.h +++ b/content/base/src/nsDocument.h @@ -915,7 +915,7 @@ public: virtual Element *LookupImageElement(const nsAString& aElementId); virtual NS_HIDDEN_(nsresult) AddImage(imgIRequest* aImage); - virtual NS_HIDDEN_(nsresult) RemoveImage(imgIRequest* aImage); + virtual NS_HIDDEN_(nsresult) RemoveImage(imgIRequest* aImage, uint32_t aFlags); virtual NS_HIDDEN_(nsresult) SetImageLockingState(bool aLocked); // AddPlugin adds a plugin-related element to mPlugins when the element is diff --git a/content/base/src/nsImageLoadingContent.cpp b/content/base/src/nsImageLoadingContent.cpp index 626a94bb5b0..ffc6764b4a4 100644 --- a/content/base/src/nsImageLoadingContent.cpp +++ b/content/base/src/nsImageLoadingContent.cpp @@ -1183,9 +1183,9 @@ nsImageLoadingContent::UnbindFromTree(bool aDeep, bool aNullParent) pusher.PushNull(); if (mCurrentRequestFlags & REQUEST_SHOULD_BE_TRACKED) - doc->RemoveImage(mCurrentRequest); + doc->RemoveImage(mCurrentRequest, nsIDocument::REQUEST_DISCARD); if (mPendingRequestFlags & REQUEST_SHOULD_BE_TRACKED) - doc->RemoveImage(mPendingRequest); + doc->RemoveImage(mPendingRequest, nsIDocument::REQUEST_DISCARD); } nsresult @@ -1227,7 +1227,7 @@ nsImageLoadingContent::UntrackImage(imgIRequest* aImage) // all locked images on destruction. nsIDocument* doc = GetOurCurrentDoc(); if (doc) - return doc->RemoveImage(aImage); + return doc->RemoveImage(aImage, nsIDocument::REQUEST_DISCARD); return NS_OK; } diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index b0c637da8d0..60d17b3c197 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -580,7 +580,7 @@ nsStyleBorder::UntrackImage(nsPresContext* aContext) // Unregister the image with the document nsIDocument* doc = aContext->Document(); if (doc) - doc->RemoveImage(mBorderImageSource); + doc->RemoveImage(mBorderImageSource, nsIDocument::REQUEST_DISCARD); // Mark state #ifdef DEBUG @@ -1507,7 +1507,7 @@ nsStyleImage::UntrackImage(nsPresContext* aContext) // Unregister the image with the document nsIDocument* doc = aContext->Document(); if (doc) - doc->RemoveImage(mImage); + doc->RemoveImage(mImage, nsIDocument::REQUEST_DISCARD); // Mark state #ifdef DEBUG @@ -2408,7 +2408,7 @@ nsStyleContentData::UntrackImage(nsPresContext* aContext) // Unregister the image with the document nsIDocument* doc = aContext->Document(); if (doc) - doc->RemoveImage(mContent.mImage); + doc->RemoveImage(mContent.mImage, nsIDocument::REQUEST_DISCARD); // Mark state #ifdef DEBUG