diff --git a/image/src/RasterImage.cpp b/image/src/RasterImage.cpp index 539ad94319a0..3e84ec27c297 100644 --- a/image/src/RasterImage.cpp +++ b/image/src/RasterImage.cpp @@ -1064,7 +1064,7 @@ RasterImage::GetCurrentImage() if (!mDecoded) { // We can't call StartDecoding because that can synchronously notify // which can cause DOM modification - RequestDecode(); + RequestDecodeCore(ASYNCHRONOUS); return nullptr; } @@ -2727,14 +2727,14 @@ RasterImage::WantDecodedFrames() NS_IMETHODIMP RasterImage::RequestDecode() { - return RequestDecodeCore(ASYNCHRONOUS); + return RequestDecodeCore(SYNCHRONOUS_NOTIFY); } /* void startDecode() */ NS_IMETHODIMP RasterImage::StartDecoding() { - return RequestDecodeCore(SOMEWHAT_SYNCHRONOUS); + return RequestDecodeCore(SYNCHRONOUS_NOTIFY_AND_SOME_DECODE); } @@ -2791,7 +2791,8 @@ RasterImage::RequestDecodeCore(RequestDecodeType aDecodeType) // If the image is waiting for decode work to be notified, go ahead and do that. if (mDecodeRequest && - mDecodeRequest->mRequestStatus == DecodeRequest::REQUEST_WORK_DONE) { + mDecodeRequest->mRequestStatus == DecodeRequest::REQUEST_WORK_DONE && + aDecodeType != ASYNCHRONOUS) { nsresult rv = FinishedSomeDecoding(); CONTAINER_ENSURE_SUCCESS(rv); } @@ -2835,7 +2836,7 @@ RasterImage::RequestDecodeCore(RequestDecodeType aDecodeType) // If we can do decoding now, do so. Small images will decode completely, // large images will decode a bit and post themselves to the event loop // to finish decoding. - if (!mDecoded && !mInDecoder && mHasSourceData && aDecodeType == SOMEWHAT_SYNCHRONOUS) { + if (!mDecoded && !mInDecoder && mHasSourceData && aDecodeType == SYNCHRONOUS_NOTIFY_AND_SOME_DECODE) { PROFILER_LABEL_PRINTF("RasterImage", "DecodeABitOf", "%s", GetURIString().get()); mDecoder->SetSynchronous(true); diff --git a/image/src/RasterImage.h b/image/src/RasterImage.h index 6f6fcaa18558..15a8eefe712b 100644 --- a/image/src/RasterImage.h +++ b/image/src/RasterImage.h @@ -712,7 +712,8 @@ private: bool IsInUpdateImageContainer() { return mInUpdateImageContainer; } enum RequestDecodeType { ASYNCHRONOUS, - SOMEWHAT_SYNCHRONOUS + SYNCHRONOUS_NOTIFY, + SYNCHRONOUS_NOTIFY_AND_SOME_DECODE }; NS_IMETHOD RequestDecodeCore(RequestDecodeType aDecodeType);