Bug 1462272: Remove handling for an impossible condition. r?dholbert
The frame is notified via its mListener, which is an observer of the
nsImageLoadingContent (mContent).
This last one only notifies for the current and pending requests, otherwise it's
a bug we need to fix there, not wallpaper here, since that'd mean that we forgot
to cancel the previous request. Added assertions to that effect.
Notify() is only called with the this object as a first argument from
imgRequestProxy, so it'd better be non-null, too.
MozReview-Commit-ID: DHaOLph2EAo
--- a/dom/base/nsImageLoadingContent.cpp
+++ b/dom/base/nsImageLoadingContent.cpp
@@ -130,33 +130,29 @@ nsImageLoadingContent::~nsImageLoadingCo
/*
* imgINotificationObserver impl
*/
NS_IMETHODIMP
nsImageLoadingContent::Notify(imgIRequest* aRequest,
int32_t aType,
const nsIntRect* aData)
{
+ MOZ_ASSERT(aRequest, "no request?");
+ MOZ_ASSERT(aRequest == mCurrentRequest || aRequest == mPendingRequest,
+ "Forgot to cancel a previous request?");
+
if (aType == imgINotificationObserver::IS_ANIMATED) {
return OnImageIsAnimated(aRequest);
}
if (aType == imgINotificationObserver::UNLOCKED_DRAW) {
OnUnlockedDraw();
return NS_OK;
}
- if (aType == imgINotificationObserver::LOAD_COMPLETE) {
- // We should definitely have a request here
- MOZ_ASSERT(aRequest, "no request?");
-
- MOZ_ASSERT(aRequest == mCurrentRequest || aRequest == mPendingRequest,
- "Unknown request");
- }
-
{
// Calling Notify on observers can modify the list of observers so make
// a local copy.
AutoTArray<nsCOMPtr<imgINotificationObserver>, 2> observers;
for (ImageObserver* observer = &mObserverList, *next; observer;
observer = next) {
next = observer->mNext;
if (observer->mObserver) {
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -680,33 +680,22 @@ nsImageFrame::InvalidateSelf(const nsInt
aLayerInvalidRect,
aFrameInvalidRect);
}
}
nsresult
nsImageFrame::OnLoadComplete(imgIRequest* aRequest, nsresult aStatus)
{
- // Check what request type we're dealing with
- nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mContent);
- NS_ASSERTION(imageLoader, "Who's notifying us??");
- int32_t loadType = nsIImageLoadingContent::UNKNOWN_REQUEST;
- imageLoader->GetRequestType(aRequest, &loadType);
- if (loadType != nsIImageLoadingContent::CURRENT_REQUEST &&
- loadType != nsIImageLoadingContent::PENDING_REQUEST) {
- return NS_ERROR_FAILURE;
- }
-
NotifyNewCurrentRequest(aRequest, aStatus);
return NS_OK;
}
void
-nsImageFrame::NotifyNewCurrentRequest(imgIRequest *aRequest,
- nsresult aStatus)
+nsImageFrame::NotifyNewCurrentRequest(imgIRequest* aRequest, nsresult aStatus)
{
nsCOMPtr<imgIContainer> image;
aRequest->GetImage(getter_AddRefs(image));
NS_ASSERTION(image || NS_FAILED(aStatus), "Successful load with no container?");
// May have to switch sizes here!
bool intrinsicSizeChanged = true;
if (NS_SUCCEEDED(aStatus) && image && SizeIsAvailable(aRequest)) {