diff --git a/modules/libpr0n/decoders/nsBMPDecoder.cpp b/modules/libpr0n/decoders/nsBMPDecoder.cpp index b6e855f0dae..7e493b7c2a8 100644 --- a/modules/libpr0n/decoders/nsBMPDecoder.cpp +++ b/modules/libpr0n/decoders/nsBMPDecoder.cpp @@ -80,7 +80,7 @@ nsBMPDecoder::~nsBMPDecoder() free(mRow); } -nsresult +void nsBMPDecoder::InitInternal() { PR_LOG(gBMPLog, PR_LOG_DEBUG, ("nsBMPDecoder::Init(%p)\n", mImage.get())); @@ -88,11 +88,9 @@ nsBMPDecoder::InitInternal() // Fire OnStartDecode at init time to support bug 512435 if (!IsSizeDecode() && mObserver) mObserver->OnStartDecode(nsnull); - - return NS_OK; } -nsresult +void nsBMPDecoder::FinishInternal() { // We should never make multiple frames @@ -107,7 +105,6 @@ nsBMPDecoder::FinishInternal() mObserver->OnStopDecode(nsnull, NS_OK, nsnull); } } - return NS_OK; } // ---------------------------------------- @@ -150,16 +147,16 @@ NS_METHOD nsBMPDecoder::CalcBitShift() return NS_OK; } -nsresult +void nsBMPDecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) { // No forgiveness if (IsError()) - return NS_ERROR_FAILURE; + return; // aCount=0 means EOF, mCurLine=0 means we're past end of image if (!aCount || !mCurLine) - return NS_OK; + return; nsresult rv; if (mPos < BFH_LENGTH) { /* In BITMAPFILEHEADER */ @@ -175,7 +172,7 @@ nsBMPDecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) ProcessFileHeader(); if (mBFH.signature[0] != 'B' || mBFH.signature[1] != 'M') { PostDataError(); - return NS_ERROR_FAILURE; + return; } if (mBFH.bihsize == OS2_BIH_LENGTH) mLOH = OS2_HEADER_LENGTH; @@ -197,7 +194,7 @@ nsBMPDecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) if (mBIH.bpp != 1 && mBIH.bpp != 4 && mBIH.bpp != 8 && mBIH.bpp != 16 && mBIH.bpp != 24 && mBIH.bpp != 32) { PostDataError(); - return NS_ERROR_UNEXPECTED; + return; } // BMPs with negative width are invalid @@ -205,7 +202,7 @@ nsBMPDecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) const PRInt32 k64KWidth = 0x0000FFFF; if (mBIH.width < 0 || mBIH.width > k64KWidth) { PostDataError(); - return NS_ERROR_FAILURE; + return; } PRUint32 real_height = (mBIH.height > 0) ? mBIH.height : -mBIH.height; @@ -216,7 +213,7 @@ nsBMPDecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) // We have the size. If we're doing a size decode, we got what // we came for. if (IsSizeDecode()) - return NS_OK; + return; // We're doing a real decode. mOldLine = mCurLine = real_height; @@ -230,7 +227,7 @@ nsBMPDecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) mColors = new colorTable[256]; if (!mColors) { PostDecoderError(NS_ERROR_OUT_OF_MEMORY); - return NS_ERROR_OUT_OF_MEMORY; + return; } memset(mColors, 0, 256 * sizeof(colorTable)); @@ -255,15 +252,14 @@ nsBMPDecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) // Also, it compensates rounding error. if (!mRow) { PostDecoderError(NS_ERROR_OUT_OF_MEMORY); - return NS_ERROR_OUT_OF_MEMORY; + return; } rv = mImage->AppendFrame(0, 0, mBIH.width, real_height, gfxASurface::ImageFormatRGB24, (PRUint8**)&mImageData, &imageLength); } - NS_ENSURE_SUCCESS(rv, rv); - if (!mImageData) { + if (NS_FAILED(rv) || !mImageData) { PostDecoderError(NS_ERROR_FAILURE); - return NS_ERROR_FAILURE; + return; } // Prepare for transparancy @@ -272,7 +268,7 @@ nsBMPDecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) || ((mBIH.compression == BI_RLE4) && (mBIH.bpp != 4) && (mBIH.bpp != 1))) { PR_LOG(gBMPLog, PR_LOG_DEBUG, ("BMP RLE8/RLE4 compression only supports 8/4 bits per pixel\n")); PostDataError(); - return NS_ERROR_FAILURE; + return; } // Clear the image, as the RLE may jump over areas memset(mImageData, 0, imageLength); @@ -416,7 +412,7 @@ nsBMPDecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) || ((mBIH.compression == BI_RLE4) && (mBIH.bpp != 4) && (mBIH.bpp != 1))) { PR_LOG(gBMPLog, PR_LOG_DEBUG, ("BMP RLE8/RLE4 compression only supports 8/4 bits per pixel\n")); PostDataError(); - return NS_ERROR_FAILURE; + return; } while (aCount > 0) { @@ -484,7 +480,7 @@ nsBMPDecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) mStateData -= mBIH.width & 1; if (mCurPos + mStateData > (PRUint32)mBIH.width) { PostDataError(); - return NS_ERROR_FAILURE; + return; } } @@ -570,7 +566,7 @@ nsBMPDecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) default : NS_ABORT_IF_FALSE(0, "BMP RLE decompression: unknown state!"); PostDecoderError(NS_ERROR_UNEXPECTED); - return NS_ERROR_FAILURE; + return; } // Because of the use of the continue statement // we only get here for eol, eof or y delta @@ -592,7 +588,7 @@ nsBMPDecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) mOldLine = mCurLine; } - return NS_OK; + return; } void nsBMPDecoder::ProcessFileHeader() diff --git a/modules/libpr0n/decoders/nsBMPDecoder.h b/modules/libpr0n/decoders/nsBMPDecoder.h index 7656ca43617..ff18ee6af16 100644 --- a/modules/libpr0n/decoders/nsBMPDecoder.h +++ b/modules/libpr0n/decoders/nsBMPDecoder.h @@ -146,9 +146,9 @@ public: nsBMPDecoder(); ~nsBMPDecoder(); - virtual nsresult InitInternal(); - virtual nsresult WriteInternal(const char* aBuffer, PRUint32 aCount); - virtual nsresult FinishInternal(); + virtual void InitInternal(); + virtual void WriteInternal(const char* aBuffer, PRUint32 aCount); + virtual void FinishInternal(); private: diff --git a/modules/libpr0n/decoders/nsGIFDecoder2.cpp b/modules/libpr0n/decoders/nsGIFDecoder2.cpp index 6de74686004..f4d173c7246 100644 --- a/modules/libpr0n/decoders/nsGIFDecoder2.cpp +++ b/modules/libpr0n/decoders/nsGIFDecoder2.cpp @@ -128,7 +128,7 @@ nsGIFDecoder2::~nsGIFDecoder2() PR_FREEIF(mGIFStruct.local_colormap); } -nsresult +void nsGIFDecoder2::InitInternal() { // Fire OnStartDecode at init time to support bug 512435 @@ -138,11 +138,9 @@ nsGIFDecoder2::InitInternal() // Start with the version (GIF89a|GIF87a) mGIFStruct.state = gif_type; mGIFStruct.bytes_to_consume = 6; - - return NS_OK; } -nsresult +void nsGIFDecoder2::FinishInternal() { // Send notifications if appropriate @@ -151,58 +149,50 @@ nsGIFDecoder2::FinishInternal() EndImageFrame(); EndGIF(/* aSuccess = */ PR_TRUE); } - - return NS_OK; } // Push any new rows according to mCurrentPass/mLastFlushedPass and // mCurrentRow/mLastFlushedRow. Note: caller is responsible for // updating mlastFlushed{Row,Pass}. -nsresult +void nsGIFDecoder2::FlushImageData(PRUint32 fromRow, PRUint32 rows) { nsIntRect r(mGIFStruct.x_offset, mGIFStruct.y_offset + fromRow, mGIFStruct.width, rows); PostInvalidation(r); - - return NS_OK; } -nsresult +void nsGIFDecoder2::FlushImageData() { - nsresult rv = NS_OK; - switch (mCurrentPass - mLastFlushedPass) { case 0: // same pass if (mCurrentRow - mLastFlushedRow) - rv = FlushImageData(mLastFlushedRow + 1, mCurrentRow - mLastFlushedRow); + FlushImageData(mLastFlushedRow + 1, mCurrentRow - mLastFlushedRow); break; case 1: // one pass on - need to handle bottom & top rects - rv = FlushImageData(0, mCurrentRow + 1); - rv |= FlushImageData(mLastFlushedRow + 1, mGIFStruct.height - (mLastFlushedRow + 1)); + FlushImageData(0, mCurrentRow + 1); + FlushImageData(mLastFlushedRow + 1, mGIFStruct.height - (mLastFlushedRow + 1)); break; default: // more than one pass on - push the whole frame - rv = FlushImageData(0, mGIFStruct.height); + FlushImageData(0, mGIFStruct.height); } - return rv; } -nsresult +void nsGIFDecoder2::WriteInternal(const char *aBuffer, PRUint32 aCount) { // Don't forgive previously flagged errors if (IsError()) - return NS_ERROR_FAILURE; + return; // Push the data to the GIF decoder nsresult rv = GifWrite((const unsigned char *)aBuffer, aCount); // Flushing is only needed for first frame if (NS_SUCCEEDED(rv) && !mGIFStruct.images_decoded) { - rv = FlushImageData(); - NS_ENSURE_SUCCESS(rv, rv); + FlushImageData(); mLastFlushedRow = mCurrentRow; mLastFlushedPass = mCurrentPass; } @@ -226,8 +216,6 @@ nsGIFDecoder2::WriteInternal(const char *aBuffer, PRUint32 aCount) else PostDataError(); } - - return IsError() ? NS_ERROR_FAILURE : NS_OK; } //****************************************************************************** @@ -328,7 +316,7 @@ void nsGIFDecoder2::EndImageFrame() // First flush all pending image data if (!mGIFStruct.images_decoded) { // Only need to flush first frame - (void) FlushImageData(); + FlushImageData(); // If the first frame is smaller in height than the entire image, send an // invalidation for the area it does not have data for. diff --git a/modules/libpr0n/decoders/nsGIFDecoder2.h b/modules/libpr0n/decoders/nsGIFDecoder2.h index 04089ee1a56..578592afca8 100644 --- a/modules/libpr0n/decoders/nsGIFDecoder2.h +++ b/modules/libpr0n/decoders/nsGIFDecoder2.h @@ -61,9 +61,9 @@ public: nsGIFDecoder2(); ~nsGIFDecoder2(); - virtual nsresult InitInternal(); - virtual nsresult WriteInternal(const char* aBuffer, PRUint32 aCount); - virtual nsresult FinishInternal(); + virtual void InitInternal(); + virtual void WriteInternal(const char* aBuffer, PRUint32 aCount); + virtual void FinishInternal(); private: /* These functions will be called when the decoder has a decoded row, @@ -73,8 +73,8 @@ private: void EndGIF(PRBool aSuccess); nsresult BeginImageFrame(gfx_depth aDepth); void EndImageFrame(); - nsresult FlushImageData(); - nsresult FlushImageData(PRUint32 fromRow, PRUint32 rows); + void FlushImageData(); + void FlushImageData(PRUint32 fromRow, PRUint32 rows); nsresult GifWrite(const PRUint8 * buf, PRUint32 numbytes); PRUint32 OutputRow(); diff --git a/modules/libpr0n/decoders/nsICODecoder.cpp b/modules/libpr0n/decoders/nsICODecoder.cpp index 97d4e7c3490..57d09d71448 100644 --- a/modules/libpr0n/decoders/nsICODecoder.cpp +++ b/modules/libpr0n/decoders/nsICODecoder.cpp @@ -100,21 +100,17 @@ nsICODecoder::~nsICODecoder() mDecodingAndMask = PR_FALSE; } -nsresult +void nsICODecoder::InitInternal() { // Fire OnStartDecode at init time to support bug 512435 if (!IsSizeDecode() && mObserver) mObserver->OnStartDecode(nsnull); - - return NS_OK; } -nsresult +void nsICODecoder::FinishInternal() { - nsresult rv = NS_OK; - // We should never make multiple frames NS_ABORT_IF_FALSE(GetFrameCount() <= 1, "Multiple ICO frames?"); @@ -132,25 +128,23 @@ nsICODecoder::FinishInternal() mObserver->OnStopDecode(nsnull, NS_OK, nsnull); } } - - return rv; } -nsresult +void nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) { // No forgiveness if (IsError()) - return NS_ERROR_FAILURE; + return; if (!aCount) // aCount=0 means EOF - return NS_OK; + return; while (aCount && (mPos < ICONCOUNTOFFSET)) { // Skip to the # of icons. if (mPos == 2) { // if the third byte is 1: This is an icon, 2: a cursor if ((*aBuffer != 1) && (*aBuffer != 2)) { PostDataError(); - return NS_ERROR_FAILURE; + return; } mIsCursor = (*aBuffer == 2); } @@ -165,7 +159,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) } if (mNumIcons == 0) - return NS_OK; // Nothing to do. + return; // Nothing to do. PRUint16 colorDepth = 0; while (mCurrIcon < mNumIcons) { @@ -180,7 +174,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) aBuffer += toCopy; } if (aCount == 0) - return NS_OK; // Need more data + return; // Need more data IconDirEntry e; if (mPos == 22+mCurrIcon*sizeof(mDirEntryArray)) { @@ -194,7 +188,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) PRUint32 minImageOffset = DIRENTRYOFFSET + mNumIcons*sizeof(mDirEntryArray); if (mImageOffset < minImageOffset) { PostDataError(); - return NS_ERROR_FAILURE; + return; } colorDepth = e.mBitCount; @@ -233,7 +227,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) ProcessInfoHeader(); PostSize(mDirEntry.mWidth, mDirEntry.mHeight); if (IsSizeDecode()) - return NS_OK; + return; if (mBIH.bpp <= 8) { switch (mBIH.bpp) { @@ -248,13 +242,13 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) break; default: PostDataError(); - return NS_ERROR_FAILURE; + return; } mColors = new colorTable[mNumColors]; if (!mColors) { PostDecoderError(NS_ERROR_OUT_OF_MEMORY); - return NS_ERROR_OUT_OF_MEMORY; + return; } } @@ -278,13 +272,16 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) // Also, it compensates rounding error. if (!mRow) { PostDecoderError(NS_ERROR_OUT_OF_MEMORY); - return NS_ERROR_OUT_OF_MEMORY; + return; } PRUint32 imageLength; rv = mImage->AppendFrame(0, 0, mDirEntry.mWidth, mDirEntry.mHeight, gfxASurface::ImageFormatARGB32, (PRUint8**)&mImageData, &imageLength); - NS_ENSURE_SUCCESS(rv, rv); + if (NS_FAILED(rv)) { + PostDecoderError(rv); + return; + } // Tell the superclass we're starting a frame PostFrameStart(); @@ -330,7 +327,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) NS_ASSERTION(mImageData, "mImageData is null"); if (!mRow || !mImageData) { PostDataError(); - return NS_ERROR_FAILURE; + return; } PRUint32 rowSize = (mBIH.bpp * mDirEntry.mWidth + 7) / 8; // +7 to round up @@ -416,7 +413,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) default: // This is probably the wrong place to check this... PostDataError(); - return NS_ERROR_FAILURE; + return; } if (mCurLine == 0) @@ -438,7 +435,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) mRow = (PRUint8*)realloc(mRow, rowSize); if (!mRow) { PostDecoderError(NS_ERROR_OUT_OF_MEMORY); - return NS_ERROR_OUT_OF_MEMORY; + return; } } @@ -447,7 +444,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) NS_ASSERTION(mImageData, "mImageData is null"); if (!mRow || !mImageData) { PostDataError(); - return NS_ERROR_FAILURE; + return; } while (mCurLine > 0 && aCount > 0) { @@ -477,7 +474,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) } } - return NS_OK; + return; } void diff --git a/modules/libpr0n/decoders/nsICODecoder.h b/modules/libpr0n/decoders/nsICODecoder.h index 7c6bd84061d..10d0efe5824 100644 --- a/modules/libpr0n/decoders/nsICODecoder.h +++ b/modules/libpr0n/decoders/nsICODecoder.h @@ -76,9 +76,9 @@ public: nsICODecoder(); virtual ~nsICODecoder(); - virtual nsresult InitInternal(); - virtual nsresult WriteInternal(const char* aBuffer, PRUint32 aCount); - virtual nsresult FinishInternal(); + virtual void InitInternal(); + virtual void WriteInternal(const char* aBuffer, PRUint32 aCount); + virtual void FinishInternal(); private: // Private helper methods diff --git a/modules/libpr0n/decoders/nsIconDecoder.cpp b/modules/libpr0n/decoders/nsIconDecoder.cpp index 4cea9a3b4df..1d19cf34339 100644 --- a/modules/libpr0n/decoders/nsIconDecoder.cpp +++ b/modules/libpr0n/decoders/nsIconDecoder.cpp @@ -66,34 +66,30 @@ nsIconDecoder::~nsIconDecoder() { } -nsresult +void nsIconDecoder::InitInternal() { // Fire OnStartDecode at init time to support bug 512435 if (!IsSizeDecode() && mObserver) mObserver->OnStartDecode(nsnull); - - return NS_OK; } -nsresult +void nsIconDecoder::FinishInternal() { // If we haven't notified of completion yet for a full/success decode, we // didn't finish. Notify in error mode if (!IsSizeDecode() && !mNotifiedDone) NotifyDone(/* aSuccess = */ PR_FALSE); - - return NS_OK; } -nsresult +void nsIconDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) { nsresult rv; if (IsError()) - return NS_IMAGELIB_ERROR_FAILURE; + return; // We put this here to avoid errors about crossing initialization with case // jumps on linux. @@ -137,7 +133,7 @@ nsIconDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) &mImageData, &mPixBytesTotal); if (NS_FAILED(rv)) { PostDecoderError(rv); - return rv; + return; } // Tell the superclass we're starting a frame @@ -180,8 +176,6 @@ nsIconDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) break; } } - - return NS_OK; } void diff --git a/modules/libpr0n/decoders/nsIconDecoder.h b/modules/libpr0n/decoders/nsIconDecoder.h index 5c10328144b..96007b6ebb5 100644 --- a/modules/libpr0n/decoders/nsIconDecoder.h +++ b/modules/libpr0n/decoders/nsIconDecoder.h @@ -77,9 +77,9 @@ public: nsIconDecoder(); virtual ~nsIconDecoder(); - virtual nsresult InitInternal(); - virtual nsresult WriteInternal(const char* aBuffer, PRUint32 aCount); - virtual nsresult FinishInternal(); + virtual void InitInternal(); + virtual void WriteInternal(const char* aBuffer, PRUint32 aCount); + virtual void FinishInternal(); PRUint8 mWidth; PRUint8 mHeight; diff --git a/modules/libpr0n/decoders/nsJPEGDecoder.cpp b/modules/libpr0n/decoders/nsJPEGDecoder.cpp index c9403254bc3..fae042ada90 100644 --- a/modules/libpr0n/decoders/nsJPEGDecoder.cpp +++ b/modules/libpr0n/decoders/nsJPEGDecoder.cpp @@ -139,7 +139,7 @@ nsJPEGDecoder::~nsJPEGDecoder() } -nsresult +void nsJPEGDecoder::InitInternal() { /* Fire OnStartDecode at init time to support bug 512435 */ @@ -156,7 +156,7 @@ nsJPEGDecoder::InitInternal() * We need to clean up the JPEG object, close the input file, and return. */ PostDecoderError(NS_ERROR_FAILURE); - return NS_ERROR_FAILURE; + return; } /* Step 1: allocate and initialize JPEG decompression object */ @@ -176,11 +176,9 @@ nsJPEGDecoder::InitInternal() /* Record app markers for ICC data */ for (PRUint32 m = 0; m < 16; m++) jpeg_save_markers(&mInfo, JPEG_APP0 + m, 0xFFFF); - - return NS_OK; } -nsresult +void nsJPEGDecoder::FinishInternal() { /* If we're not in any sort of error case, flush the decoder. @@ -197,18 +195,15 @@ nsJPEGDecoder::FinishInternal() /* If we already know we're in an error state, don't bother flagging another one here. */ if (mState == JPEG_ERROR) - return NS_OK; + return; /* If we're doing a full decode and haven't notified of completion yet, * we must not have got everything we wanted. Send error notifications. */ if (!IsSizeDecode() && !mNotifiedDone) NotifyDone(/* aSuccess = */ PR_FALSE); - - /* Otherwise, no problems. */ - return NS_OK; } -nsresult +void nsJPEGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) { mSegment = (const JOCTET *)aBuffer; @@ -224,7 +219,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) mState = JPEG_SINK_NON_JPEG_TRAILER; PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG, ("} (setjmp returned NS_ERROR_FAILURE)")); - return NS_OK; + return; } else { /* Error due to reasons external to the stream (probably out of memory) - let libpr0n attempt to clean up, even though @@ -233,7 +228,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) mState = JPEG_ERROR; PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG, ("} (setjmp returned an error)")); - return error_code; + return; } } @@ -249,7 +244,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) if (jpeg_read_header(&mInfo, TRUE) == JPEG_SUSPENDED) { PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG, ("} (JPEG_SUSPENDED)")); - return NS_OK; /* I/O suspension */ + return; /* I/O suspension */ } // Post our size to the superclass @@ -257,7 +252,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) /* If we're doing a size decode, we're done. */ if (IsSizeDecode()) - return NS_OK; + return; /* We're doing a full decode. */ JOCTET *profile; @@ -303,7 +298,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) PostDataError(); PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG, ("} (unknown colorpsace (1))")); - return NS_ERROR_UNEXPECTED; + return; } if (!mismatch) { @@ -320,7 +315,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) PostDataError(); PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG, ("} (unknown colorpsace (2))")); - return NS_ERROR_UNEXPECTED; + return; } #if 0 /* We don't currently support CMYK profiles. The following @@ -370,7 +365,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) PostDataError(); PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG, ("} (unknown colorpsace (3))")); - return NS_ERROR_UNEXPECTED; + return; break; } } @@ -395,7 +390,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) PostDecoderError(NS_ERROR_OUT_OF_MEMORY); PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG, ("} (could not initialize image frame)")); - return NS_ERROR_OUT_OF_MEMORY; + return; } PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG, @@ -426,7 +421,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) if (jpeg_start_decompress(&mInfo) == FALSE) { PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG, ("} (I/O suspension after jpeg_start_decompress())")); - return NS_OK; /* I/O suspension */ + return; /* I/O suspension */ } /* Force to use our YCbCr to Packed RGB converter when possible */ @@ -448,14 +443,12 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) LOG_SCOPE(gJPEGlog, "nsJPEGDecoder::Write -- JPEG_DECOMPRESS_SEQUENTIAL case"); PRBool suspend; - nsresult rv = OutputScanlines(&suspend); - if (NS_FAILED(rv)) - return rv; + OutputScanlines(&suspend); if (suspend) { PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG, ("} (I/O suspension after OutputScanlines() - SEQUENTIAL)")); - return NS_OK; /* I/O suspension */ + return; /* I/O suspension */ } /* If we've completed image output ... */ @@ -491,7 +484,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) if (!jpeg_start_output(&mInfo, scan)) { PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG, ("} (I/O suspension after jpeg_start_output() - PROGRESSIVE)")); - return NS_OK; /* I/O suspension */ + return; /* I/O suspension */ } } @@ -499,9 +492,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) mInfo.output_scanline = 0; PRBool suspend; - nsresult rv = OutputScanlines(&suspend); - if (NS_FAILED(rv)) - return rv; + OutputScanlines(&suspend); if (suspend) { if (mInfo.output_scanline == 0) { @@ -511,7 +502,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) } PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG, ("} (I/O suspension after OutputScanlines() - PROGRESSIVE)")); - return NS_OK; /* I/O suspension */ + return; /* I/O suspension */ } if (mInfo.output_scanline == mInfo.output_height) @@ -519,7 +510,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) if (!jpeg_finish_output(&mInfo)) { PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG, ("} (I/O suspension after jpeg_finish_output() - PROGRESSIVE)")); - return NS_OK; /* I/O suspension */ + return; /* I/O suspension */ } if (jpeg_input_complete(&mInfo) && @@ -543,7 +534,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) if (jpeg_finish_decompress(&mInfo) == FALSE) { PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG, ("} (I/O suspension after jpeg_finish_decompress() - DONE)")); - return NS_OK; /* I/O suspension */ + return; /* I/O suspension */ } mState = JPEG_SINK_NON_JPEG_TRAILER; @@ -563,7 +554,7 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) PR_LOG(gJPEGDecoderAccountingLog, PR_LOG_DEBUG, ("} (end of function)")); - return NS_OK; + return; } void @@ -586,13 +577,12 @@ nsJPEGDecoder::NotifyDone(PRBool aSuccess) mNotifiedDone = PR_TRUE; } -nsresult +void nsJPEGDecoder::OutputScanlines(PRBool* suspend) { *suspend = PR_FALSE; const PRUint32 top = mInfo.output_scanline; - nsresult rv = NS_OK; while ((mInfo.output_scanline < mInfo.output_height)) { /* Use the Cairo image buffer as scanline buffer */ @@ -682,7 +672,6 @@ nsJPEGDecoder::OutputScanlines(PRBool* suspend) PostInvalidation(r); } - return rv; } diff --git a/modules/libpr0n/decoders/nsJPEGDecoder.h b/modules/libpr0n/decoders/nsJPEGDecoder.h index 9dbf4282dc1..2a58468f63a 100644 --- a/modules/libpr0n/decoders/nsJPEGDecoder.h +++ b/modules/libpr0n/decoders/nsJPEGDecoder.h @@ -89,14 +89,14 @@ public: nsJPEGDecoder(); virtual ~nsJPEGDecoder(); - virtual nsresult InitInternal(); - virtual nsresult WriteInternal(const char* aBuffer, PRUint32 aCount); - virtual nsresult FinishInternal(); + virtual void InitInternal(); + virtual void WriteInternal(const char* aBuffer, PRUint32 aCount); + virtual void FinishInternal(); void NotifyDone(PRBool aSuccess); protected: - nsresult OutputScanlines(PRBool* suspend); + void OutputScanlines(PRBool* suspend); public: PRUint8 *mImageData; diff --git a/modules/libpr0n/decoders/nsPNGDecoder.cpp b/modules/libpr0n/decoders/nsPNGDecoder.cpp index 21e89dd74c9..5badd7f6674 100644 --- a/modules/libpr0n/decoders/nsPNGDecoder.cpp +++ b/modules/libpr0n/decoders/nsPNGDecoder.cpp @@ -212,7 +212,7 @@ void nsPNGDecoder::EndImageFrame() PostFrameStop(); } -nsresult +void nsPNGDecoder::InitInternal() { @@ -244,9 +244,9 @@ nsPNGDecoder::InitInternal() mHeaderBuf = (PRUint8 *)nsMemory::Alloc(BYTES_NEEDED_FOR_DIMENSIONS); if (!mHeaderBuf) { PostDecoderError(NS_ERROR_OUT_OF_MEMORY); - return NS_ERROR_OUT_OF_MEMORY; + return; } - return NS_OK; + return; } /* For full decodes, do png init stuff */ @@ -259,14 +259,14 @@ nsPNGDecoder::InitInternal() nsPNGDecoder::warning_callback); if (!mPNG) { PostDecoderError(NS_ERROR_OUT_OF_MEMORY); - return NS_ERROR_OUT_OF_MEMORY; + return; } mInfo = png_create_info_struct(mPNG); if (!mInfo) { PostDecoderError(NS_ERROR_OUT_OF_MEMORY); png_destroy_read_struct(&mPNG, NULL, NULL); - return NS_ERROR_OUT_OF_MEMORY; + return; } #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED @@ -289,11 +289,9 @@ nsPNGDecoder::InitInternal() nsPNGDecoder::row_callback, nsPNGDecoder::end_callback); - - return NS_OK; } -nsresult +void nsPNGDecoder::FinishInternal() { @@ -301,11 +299,9 @@ nsPNGDecoder::FinishInternal() // we didn't get all the data we needed. Send error notifications. if (!IsSizeDecode() && !mNotifiedDone) NotifyDone(/* aSuccess = */ PR_FALSE); - - return NS_OK; } -nsresult +void nsPNGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) { // We use gotos, so we need to declare variables here @@ -314,14 +310,14 @@ nsPNGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) // No forgiveness if we previously hit an error if (IsError()) - goto error; + return; // If we only want width/height, we don't need to go through libpng if (IsSizeDecode()) { // Are we done? if (mHeaderBytesRead == BYTES_NEEDED_FOR_DIMENSIONS) - return NS_OK; + return; // Read data into our header buffer PRUint32 bytesToRead = PR_MIN(aCount, BYTES_NEEDED_FOR_DIMENSIONS - @@ -335,7 +331,7 @@ nsPNGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) // Check that the signature bytes are right if (memcmp(mHeaderBuf, pngSignatureBytes, sizeof(pngSignatureBytes))) { PostDataError(); - goto error; + return; } // Grab the width and height, accounting for endianness (thanks libpng!) @@ -345,7 +341,7 @@ nsPNGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) // Too big? if ((width > MOZ_PNG_MAX_DIMENSION) || (height > MOZ_PNG_MAX_DIMENSION)) { PostDataError(); - goto error; + return; } // Post our size to the superclass @@ -365,20 +361,13 @@ nsPNGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) PostDataError(); png_destroy_read_struct(&mPNG, &mInfo, NULL); - goto error; + return; } // Pass the data off to libpng png_process_data(mPNG, mInfo, (unsigned char *)aBuffer, aCount); } - - return NS_OK; - - // Consolidate error handling - error: - NS_ABORT_IF_FALSE(IsError(), "Should only get here if we flagged an error!"); - return NS_ERROR_FAILURE; } void diff --git a/modules/libpr0n/decoders/nsPNGDecoder.h b/modules/libpr0n/decoders/nsPNGDecoder.h index 009860c3191..0b5d997fe37 100644 --- a/modules/libpr0n/decoders/nsPNGDecoder.h +++ b/modules/libpr0n/decoders/nsPNGDecoder.h @@ -62,9 +62,9 @@ public: nsPNGDecoder(); virtual ~nsPNGDecoder(); - virtual nsresult InitInternal(); - virtual nsresult WriteInternal(const char* aBuffer, PRUint32 aCount); - virtual nsresult FinishInternal(); + virtual void InitInternal(); + virtual void WriteInternal(const char* aBuffer, PRUint32 aCount); + virtual void FinishInternal(); void CreateFrame(png_uint_32 x_offset, png_uint_32 y_offset, PRInt32 width, PRInt32 height, diff --git a/modules/libpr0n/src/Decoder.cpp b/modules/libpr0n/src/Decoder.cpp index 7d9ebb9ed27..9dadbe31849 100644 --- a/modules/libpr0n/src/Decoder.cpp +++ b/modules/libpr0n/src/Decoder.cpp @@ -120,9 +120,9 @@ Decoder::FlushInvalidations() * Hook stubs. Override these as necessary in decoder implementations. */ -nsresult Decoder::InitInternal() {return NS_OK; } -nsresult Decoder::WriteInternal(const char* aBuffer, PRUint32 aCount) {return NS_OK; } -nsresult Decoder::FinishInternal() {return NS_OK; } +void Decoder::InitInternal() { } +void Decoder::WriteInternal(const char* aBuffer, PRUint32 aCount) { } +void Decoder::FinishInternal() { } /* * Progress Notifications diff --git a/modules/libpr0n/src/Decoder.h b/modules/libpr0n/src/Decoder.h index 18772e0c193..08e7d183619 100644 --- a/modules/libpr0n/src/Decoder.h +++ b/modules/libpr0n/src/Decoder.h @@ -129,9 +129,9 @@ protected: * Internal hooks. Decoder implementations may override these and * only these methods. */ - virtual nsresult InitInternal(); - virtual nsresult WriteInternal(const char* aBuffer, PRUint32 aCount); - virtual nsresult FinishInternal(); + virtual void InitInternal(); + virtual void WriteInternal(const char* aBuffer, PRUint32 aCount); + virtual void FinishInternal(); /* * Progress notifications.