Bug 1084136 (Part 3) - Don't reset image status flags on error. r=tn

--HG--
extra : rebase_source : a14a69a7f8a000be8c66008edf99c6d08a755325
This commit is contained in:
Seth Fowler 2014-11-06 17:33:57 -08:00
parent d7d09d9afe
commit 909e701391
4 changed files with 14 additions and 23 deletions

View File

@ -432,8 +432,6 @@ imgStatusTracker::Difference(imgStatusTracker* aOther) const
diff.diffImageStatus = ~mImageStatus & aOther->mImageStatus;
diff.unsetDecodeStarted = mImageStatus & imgIRequest::STATUS_DECODE_STARTED
&& !(aOther->mImageStatus & imgIRequest::STATUS_DECODE_STARTED);
diff.foundError = (mImageStatus != imgIRequest::STATUS_ERROR)
&& (aOther->mImageStatus == imgIRequest::STATUS_ERROR);
MOZ_ASSERT(!mIsMultipart || aOther->mIsMultipart, "mIsMultipart should be monotonic");
diff.foundIsMultipart = !mIsMultipart && aOther->mIsMultipart;
@ -492,10 +490,6 @@ imgStatusTracker::ApplyDifference(const ImageStatusDiff& aDiff)
// Unset bits which can get unset as part of the decoding process.
if (aDiff.unsetDecodeStarted)
mImageStatus &= ~imgIRequest::STATUS_DECODE_STARTED;
// The error state is sticky and overrides all other bits.
if (mImageStatus & imgIRequest::STATUS_ERROR)
mImageStatus = imgIRequest::STATUS_ERROR;
}
void
@ -510,7 +504,7 @@ imgStatusTracker::SyncNotifyDifference(const ImageStatusDiff& diff)
mInvalidRect.SetEmpty();
if (diff.foundError) {
if (diff.diffImageStatus & imgIRequest::STATUS_ERROR) {
FireFailureNotification();
}
}
@ -620,8 +614,9 @@ imgStatusTracker::FirstConsumerIs(imgRequestProxy* aConsumer)
void
imgStatusTracker::RecordCancel()
{
if (!(mImageStatus & imgIRequest::STATUS_LOAD_PARTIAL))
mImageStatus = imgIRequest::STATUS_ERROR;
if (!(mImageStatus & imgIRequest::STATUS_LOAD_PARTIAL)) {
mImageStatus |= imgIRequest::STATUS_ERROR;
}
}
void
@ -708,13 +703,12 @@ imgStatusTracker::RecordStopDecode(nsresult aStatus)
"RecordStopDecode called before we have an Image");
mState |= FLAG_DECODE_STOPPED;
if (NS_SUCCEEDED(aStatus) && mImageStatus != imgIRequest::STATUS_ERROR) {
if (NS_SUCCEEDED(aStatus) && !(mImageStatus & imgIRequest::STATUS_ERROR)) {
mImageStatus |= imgIRequest::STATUS_DECODE_COMPLETE;
mImageStatus &= ~imgIRequest::STATUS_DECODE_STARTED;
mHasBeenDecoded = true;
// If we weren't successful, clear all success status bits and set error.
} else {
mImageStatus = imgIRequest::STATUS_ERROR;
mImageStatus |= imgIRequest::STATUS_ERROR;
}
}
@ -866,10 +860,11 @@ imgStatusTracker::RecordStopRequest(bool aLastPart,
mState |= FLAG_REQUEST_STOPPED;
// If we were successful in loading, note that the image is complete.
if (NS_SUCCEEDED(aStatus) && mImageStatus != imgIRequest::STATUS_ERROR)
if (NS_SUCCEEDED(aStatus)) {
mImageStatus |= imgIRequest::STATUS_LOAD_COMPLETE;
else
mImageStatus = imgIRequest::STATUS_ERROR;
} else {
mImageStatus |= imgIRequest::STATUS_ERROR;
}
}
void
@ -919,7 +914,7 @@ imgStatusTracker::OnStopRequest(bool aLastPart,
new OnStopRequestEvent(this, aLastPart, aStatus));
return;
}
bool preexistingError = mImageStatus == imgIRequest::STATUS_ERROR;
bool preexistingError = mImageStatus & imgIRequest::STATUS_ERROR;
RecordStopRequest(aLastPart, aStatus);
/* notify the kids */
@ -1065,7 +1060,7 @@ imgStatusTracker::MaybeUnblockOnload()
void
imgStatusTracker::RecordError()
{
mImageStatus = imgIRequest::STATUS_ERROR;
mImageStatus |= imgIRequest::STATUS_ERROR;
}
void

View File

@ -47,7 +47,6 @@ struct ImageStatusDiff
, diffState(0)
, diffImageStatus(0)
, unsetDecodeStarted(false)
, foundError(false)
, foundIsMultipart(false)
, foundLastPart(false)
, gotDecoded(false)
@ -62,7 +61,6 @@ struct ImageStatusDiff
&& aOther.diffState == diffState
&& aOther.diffImageStatus == diffImageStatus
&& aOther.unsetDecodeStarted == unsetDecodeStarted
&& aOther.foundError == foundError
&& aOther.foundIsMultipart == foundIsMultipart
&& aOther.foundLastPart == foundLastPart
&& aOther.gotDecoded == gotDecoded;
@ -73,7 +71,6 @@ struct ImageStatusDiff
diffState |= aOther.diffState;
diffImageStatus |= aOther.diffImageStatus;
unsetDecodeStarted = unsetDecodeStarted || aOther.unsetDecodeStarted;
foundError = foundError || aOther.foundError;
foundIsMultipart = foundIsMultipart || aOther.foundIsMultipart;
foundLastPart = foundLastPart || aOther.foundLastPart;
gotDecoded = gotDecoded || aOther.gotDecoded;
@ -83,7 +80,6 @@ struct ImageStatusDiff
uint32_t diffState;
uint32_t diffImageStatus;
bool unsetDecodeStarted : 1;
bool foundError : 1;
bool foundIsMultipart : 1;
bool foundLastPart : 1;
bool gotDecoded : 1;

View File

@ -109,7 +109,7 @@ nsAlertsIconListener::OnStopRequest(imgIRequest* aRequest)
uint32_t imgStatus = imgIRequest::STATUS_ERROR;
nsresult rv = aRequest->GetImageStatus(&imgStatus);
NS_ENSURE_SUCCESS(rv, rv);
if (imgStatus == imgIRequest::STATUS_ERROR && !mLoadedFrame) {
if ((imgStatus & imgIRequest::STATUS_ERROR) && !mLoadedFrame) {
// We have an error getting the image. Display the notification with no icon.
ShowAlert(nullptr);
}

View File

@ -389,7 +389,7 @@ OSXNotificationCenter::Notify(imgIRequest *aRequest, int32_t aType, const nsIntR
NSImage *cocoaImage = nil;
uint32_t imgStatus = imgIRequest::STATUS_ERROR;
nsresult rv = aRequest->GetImageStatus(&imgStatus);
if (NS_SUCCEEDED(rv) && imgStatus != imgIRequest::STATUS_ERROR) {
if (NS_SUCCEEDED(rv) && !(imgStatus & imgIRequest::STATUS_ERROR)) {
nsCOMPtr<imgIContainer> image;
rv = aRequest->GetImage(getter_AddRefs(image));
if (NS_SUCCEEDED(rv)) {