Bug 513681 - part 8 - Fold nsJPEGDecoder::Flush() into nsJPEGDecoder::Close().r=joe,a=blocker

This commit is contained in:
Bobby Holley 2010-08-12 14:16:36 -04:00
Родитель 4e0bd46489
Коммит d8d9b0b5da
2 изменённых файлов: 13 добавлений и 23 удалений

Просмотреть файл

@ -197,6 +197,18 @@ NS_IMETHODIMP nsJPEGDecoder::Close(PRUint32 aFlags)
PR_LOG(gJPEGlog, PR_LOG_DEBUG,
("[this=%p] nsJPEGDecoder::Close\n", this));
/* If we're not in any sort of error case, flush the decoder.
*
* XXXbholley - It seems wrong that this should be necessary, but at the
* moment I'm just folding the contents of Flush() into Close() so that
* we can get rid of it.
*/
if ((mState != JPEG_DONE && mState != JPEG_SINK_NON_JPEG_TRAILER) &&
(mState != JPEG_ERROR) &&
!(mFlags & imgIDecoder::DECODER_FLAG_HEADERONLY) &&
!(aFlags & CLOSE_FLAG_DONTNOTIFY))
this->Write(nsnull, 0);
/* Step 8: Release JPEG decompression object */
mInfo.src = nsnull;
@ -221,11 +233,6 @@ NS_IMETHODIMP nsJPEGDecoder::Close(PRUint32 aFlags)
/* void flush (); */
NS_IMETHODIMP nsJPEGDecoder::Flush()
{
LOG_SCOPE(gJPEGlog, "nsJPEGDecoder::Flush");
if (mState != JPEG_DONE && mState != JPEG_SINK_NON_JPEG_TRAILER && mState != JPEG_ERROR)
return this->Write(nsnull, 0);
return NS_OK;
}

Просмотреть файл

@ -2175,29 +2175,12 @@ RasterImage::ShutdownDecoder(eShutdownIntent aIntent)
// Ensure that the decoder is initialized
NS_ABORT_IF_FALSE(mDecoder, "Calling ShutdownDecoder() with no active decoder!");
nsresult rv;
// If we're "done" _and_ it's a full decode, flush
if ((aIntent == eShutdownIntent_Done) &&
!(mDecoderFlags && imgIDecoder::DECODER_FLAG_HEADERONLY)) {
mInDecoder = PR_TRUE;
rv = mDecoder->Flush();
mInDecoder = PR_FALSE;
// The error case here is a bit tricky. We flag an error, which takes us
// back into this function, and then we return.
if (NS_FAILED(rv)) {
DoError();
return rv;
}
}
// Close the decoder with the appropriate flags
mInDecoder = PR_TRUE;
PRUint32 closeFlags = (aIntent == eShutdownIntent_Error)
? (PRUint32) imgIDecoder::CLOSE_FLAG_DONTNOTIFY
: 0;
rv = mDecoder->Close(closeFlags);
nsresult rv = mDecoder->Close(closeFlags);
mInDecoder = PR_FALSE;
// null out the decoder, _then_ check for errors on the close (otherwise the