diff --git a/mozilla/modules/libimg/gifcom/gif.cpp b/mozilla/modules/libimg/gifcom/gif.cpp index 6200e9891b3..18fafdc3b08 100644 --- a/mozilla/modules/libimg/gifcom/gif.cpp +++ b/mozilla/modules/libimg/gifcom/gif.cpp @@ -607,11 +607,11 @@ il_gif_write_ready(il_container *ic) int32 max; if (!gs) - return 1; /* Let imglib generic code decide */ + return -1; /* Let imglib generic code decide */ max = MAX(MAX_READ_AHEAD, gs->requested_buffer_fullness); if (gs->gathered < max) - return 1; /* Let imglib generic code decide */ + return -1; /* Let imglib generic code decide */ else return 0; /* No more data until timeout expires */ } @@ -622,21 +622,26 @@ process_buffered_gif_input_data(gif_struct* gs) { gstate state; il_container *ic = gs->ic; + uint8 err = 0; /* Force any data we've buffered up to be processed. */ - il_gif_write(ic, (uint8 *) "", 0); + err = il_gif_write(ic, (uint8 *) "", 0); /* The stream has already finished delivering data and the stream completion routine has been called sometime in the past. Now that we're actually done handling all of that data, call the stream completion routine again, but this time for real. */ state = gs->state; + + /* test, stop loopers if error */ + if( state == gif_error){ + ic->loop_count = 0; + gs->destroy_pending =TRUE; + ic->state = IC_ABORT_PENDING; + } if (gs->destroy_pending && ((state == gif_done) || (state == gif_error) || (state == gif_oom))) { - /* test, stop loopers if error */ - if( state == gif_error) - ic->loop_count = 0; il_gif_abort(ic); if(ic->imgdcb) @@ -771,7 +776,7 @@ il_gif_write(il_container *ic, const uint8 *buf, int32 len) NI_PixmapHeader *src_header = ic->src_header; NI_ColorMap *cmap = &src_header->color_space->cmap; const uint8 *q, *p=buf,*ep=buf+len; - nsresult result = 0; + /* If this assert fires, chances are the netlib flubbed and continued to send data after the image stream was closed. */ diff --git a/mozilla/modules/libimg/gifcom/nsGIFDecoder.cpp b/mozilla/modules/libimg/gifcom/nsGIFDecoder.cpp index fa442b83ae0..26b707d4b08 100644 --- a/mozilla/modules/libimg/gifcom/nsGIFDecoder.cpp +++ b/mozilla/modules/libimg/gifcom/nsGIFDecoder.cpp @@ -61,27 +61,36 @@ GIFDecoder::ImgDInit() return(il_gif_init(ilContainer)); } else { - return nsnull; + return NS_OK; } } NS_IMETHODIMP -GIFDecoder::ImgDWriteReady() +GIFDecoder::ImgDWriteReady(PRUint32 *chunksizep) { + int ret; + if(ilContainer != NULL) { - return(il_gif_write_ready(ilContainer)); + ret = il_gif_write_ready(ilContainer); + + if(ret != 0) + return NS_ERROR_FAILURE; } - return 0; + return NS_OK; } NS_IMETHODIMP GIFDecoder::ImgDWrite(const unsigned char *buf, int32 len) { + int ret; + if( ilContainer != NULL ) { - return(il_gif_write(ilContainer, buf,len)); + ret = il_gif_write(ilContainer, buf,len); + if(ret != 0) + return NS_ERROR_FAILURE; } - return 0; + return NS_OK; } NS_IMETHODIMP @@ -90,7 +99,7 @@ GIFDecoder::ImgDComplete() if( ilContainer != NULL ) { il_gif_complete(ilContainer); } - return 0; + return NS_OK; } NS_IMETHODIMP @@ -99,7 +108,7 @@ GIFDecoder::ImgDAbort() if( ilContainer != NULL ) { il_gif_abort(ilContainer); } - return 0; + return NS_OK; } diff --git a/mozilla/modules/libimg/gifcom/nsGIFDecoder.h b/mozilla/modules/libimg/gifcom/nsGIFDecoder.h index 84ac9452b57..fa82897d339 100644 --- a/mozilla/modules/libimg/gifcom/nsGIFDecoder.h +++ b/mozilla/modules/libimg/gifcom/nsGIFDecoder.h @@ -49,7 +49,7 @@ public: /* stream */ NS_IMETHOD ImgDInit(); - NS_IMETHOD ImgDWriteReady(); + NS_IMETHOD ImgDWriteReady(PRUint32 *request_size); NS_IMETHOD ImgDWrite(const unsigned char *buf, int32 len); NS_IMETHOD ImgDComplete(); NS_IMETHOD ImgDAbort(); diff --git a/mozilla/modules/libimg/jpgcom/jpeg.h b/mozilla/modules/libimg/jpgcom/jpeg.h index f1b27269593..7cf20698c0d 100644 --- a/mozilla/modules/libimg/jpgcom/jpeg.h +++ b/mozilla/modules/libimg/jpgcom/jpeg.h @@ -25,7 +25,7 @@ extern int il_jpeg_init(il_container *ic); extern int il_jpeg_write(il_container *, const uint8 *, int32); extern void il_jpeg_complete(il_container *ic); -extern unsigned int il_jpeg_write_ready(il_container *ic); +//extern unsigned int il_jpeg_write_ready(il_container *ic); extern void il_jpeg_abort(il_container *ic); diff --git a/mozilla/modules/libimg/jpgcom/nsJPGDecoder.cpp b/mozilla/modules/libimg/jpgcom/nsJPGDecoder.cpp index 9a9e5fb7f17..f10e037387b 100644 --- a/mozilla/modules/libimg/jpgcom/nsJPGDecoder.cpp +++ b/mozilla/modules/libimg/jpgcom/nsJPGDecoder.cpp @@ -54,7 +54,7 @@ public: /* stream */ NS_IMETHOD ImgDInit(); - NS_IMETHOD ImgDWriteReady(); + NS_IMETHOD ImgDWriteReady(PRUint32 *request_size); NS_IMETHOD ImgDWrite(const unsigned char *buf, int32 len); NS_IMETHOD ImgDComplete(); NS_IMETHOD ImgDAbort(); @@ -256,28 +256,35 @@ NSGetFactory(nsISupports* serviceMgr, NS_IMETHODIMP JPGDecoder::ImgDInit() { - if(ilContainer != NULL) { - return(il_jpeg_init(ilContainer)); - } - else { - return nsnull; + int ret; + + if( ilContainer != NULL ) { + ret = il_jpeg_init(ilContainer); + if(ret != 1) + return NS_ERROR_FAILURE; } + return NS_OK; } NS_IMETHODIMP -JPGDecoder::ImgDWriteReady() -{ /* IL_StreamWriteReady needs a return 1 */ - return 1; +JPGDecoder::ImgDWriteReady(PRUint32 *chunksizep) +{ + /* dummy return needed */ + return NS_OK; } NS_IMETHODIMP JPGDecoder::ImgDWrite(const unsigned char *buf, int32 len) { + int ret; + if( ilContainer != NULL ) { - return(il_jpeg_write(ilContainer, buf,len)); + ret = il_jpeg_write(ilContainer, buf,len); + if(ret != 0) + return NS_ERROR_FAILURE; } - return 0; + return NS_OK; } NS_IMETHODIMP @@ -286,15 +293,16 @@ JPGDecoder::ImgDComplete() if( ilContainer != NULL ) { il_jpeg_complete(ilContainer); } - return 0; + return NS_OK; } NS_IMETHODIMP JPGDecoder::ImgDAbort() { if( ilContainer != NULL ) { - il_jpeg_abort(ilContainer); + il_jpeg_abort(ilContainer); } - return 0; + return NS_OK; + } diff --git a/mozilla/modules/libimg/pngcom/ipng.cpp b/mozilla/modules/libimg/pngcom/ipng.cpp index 6e95486c239..f5064722dad 100644 --- a/mozilla/modules/libimg/pngcom/ipng.cpp +++ b/mozilla/modules/libimg/pngcom/ipng.cpp @@ -29,7 +29,6 @@ #include "nsIImgDCallbk.h" #include "ilISystemServices.h" -#define OK 1 #define MINIMUM_DELAY_TIME 10 @@ -65,18 +64,16 @@ il_png_init(il_container *ic) ic->ds = ipngs; ipngs->state = PNG_INIT; ipngs->ic = ic; + + /* Initialize the container's source image header. */ + /* Always decode to 24 bit pixdepth */ + + src_color_space->type = NI_TrueColor; + src_color_space->pixmap_depth = 24; + src_color_space->bit_alloc.index_depth = 0; + return 0; } - - /* Initialize the container's source image header. */ - /* Always decode to 24 bit pixdepth */ - - src_color_space->type = NI_TrueColor; - src_color_space->pixmap_depth = 24; - src_color_space->bit_alloc.index_depth = 0; - - - - return (ipngs != 0); + return -1; } @@ -92,7 +89,6 @@ il_png_write(il_container *ic, const unsigned char *buf, int32 len) /*------*/ - ipng_ptr = (ipng_structp)ic->ds; if(ipng_ptr->state == PNG_INIT ){ png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL ); @@ -102,7 +98,7 @@ il_png_write(il_container *ic, const unsigned char *buf, int32 len) ipng_ptr->info_p = info_ptr; if (info_ptr == NULL){ png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL); - return !OK; + return -1; } png_set_progressive_read_fn(png_ptr, (void *)buf, info_callback, row_callback, end_callback); @@ -115,12 +111,12 @@ il_png_write(il_container *ic, const unsigned char *buf, int32 len) png_ptr->io_ptr = ic; if (setjmp(png_ptr->jmpbuf)) { png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - return !OK; + return -1; } png_process_data( png_ptr, info_ptr, (unsigned char *)buf, len ); ipng_ptr->state = PNG_CONTINUE; - return OK; + return 0; } void @@ -140,9 +136,7 @@ png_set_dims( il_container *ic, png_structp png_ptr) ic->image->header.alpha_shift = 0; ic->image->header.is_interleaved_alpha = TRUE; } -#endif - -#if 0 +#else if(png_ptr->num_trans){ ic->image->header.alpha_bits = 1; ic->image->header.alpha_shift = 0; @@ -226,9 +220,10 @@ png_delay_time_callback(void *closure) return; ipng_ptr->delay_time = 0; /* Reset for next image */ + return; } -void +int il_png_complete(il_container *ic) { ipng_structp ipng_ptr; @@ -238,8 +233,7 @@ il_png_complete(il_container *ic) il_png_abort(ic); /* notify observers that the current frame has completed. */ - - //il_frame_complete_notify(ic); + ic->imgdcb->ImgDCBHaveImageFrame(); /* An image can specify a delay time before which to display @@ -258,12 +252,13 @@ il_png_complete(il_container *ic) ipng_ptr->state = PNG_INIT; } - return; + return 0; } -void il_png_abort(il_container *ic) +int +il_png_abort(il_container *ic) { -/* il_abort( ic ); */ - return; + /* il_abort( ic ); */ + return 0; } diff --git a/mozilla/modules/libimg/pngcom/nsPNGDecoder.cpp b/mozilla/modules/libimg/pngcom/nsPNGDecoder.cpp index b9b0a39f8eb..ce89658c9c6 100644 --- a/mozilla/modules/libimg/pngcom/nsPNGDecoder.cpp +++ b/mozilla/modules/libimg/pngcom/nsPNGDecoder.cpp @@ -54,7 +54,7 @@ public: /* stream */ NS_IMETHOD ImgDInit(); - NS_IMETHOD ImgDWriteReady(); + NS_IMETHOD ImgDWriteReady(PRUint32 *request_size); NS_IMETHOD ImgDWrite(const unsigned char *buf, int32 len); NS_IMETHOD ImgDComplete(); NS_IMETHOD ImgDAbort(); @@ -253,50 +253,61 @@ NSGetFactory(nsISupports* serviceMgr, NS_IMETHODIMP PNGDecoder::ImgDInit() { - if(ilContainer != NULL) { - return(il_png_init(ilContainer)); - } - else { - return nsnull; + int ret; + + if( ilContainer != NULL ) { + ret = il_png_init(ilContainer); + if(ret != 0) + return NS_ERROR_FAILURE; } + return NS_OK; } NS_IMETHODIMP -PNGDecoder::ImgDWriteReady() +PNGDecoder::ImgDWriteReady(PRUint32 *request_size) { - if(ilContainer != NULL) { - /* see ImageConsumer::OnDataAvailable(). dummy return */ - return 1; - } - return 0; + /* dummy return needed */ + return NS_OK; } NS_IMETHODIMP PNGDecoder::ImgDWrite(const unsigned char *buf, int32 len) { + int ret; + if( ilContainer != NULL ) { - return(il_png_write(ilContainer, buf,len)); + ret = il_png_write(ilContainer, buf,len); + if(ret != 0) + return NS_ERROR_FAILURE; } - return 0; + return NS_OK; } NS_IMETHODIMP PNGDecoder::ImgDComplete() { + int ret; + if( ilContainer != NULL ) { - il_png_complete(ilContainer); + ret = il_png_complete(ilContainer); + if(ret != 0) + return NS_ERROR_FAILURE; } - return 0; + return NS_OK; } NS_IMETHODIMP PNGDecoder::ImgDAbort() { + int ret; + if( ilContainer != NULL ) { - il_png_abort(ilContainer); + ret = il_png_abort(ilContainer); + if(ret != 0) + return NS_ERROR_FAILURE; } - return 0; + return NS_OK; } diff --git a/mozilla/modules/libimg/pngcom/pngdec.h b/mozilla/modules/libimg/pngcom/pngdec.h index c3395e8f978..2607cebd2df 100644 --- a/mozilla/modules/libimg/pngcom/pngdec.h +++ b/mozilla/modules/libimg/pngcom/pngdec.h @@ -22,7 +22,7 @@ extern int il_png_init(il_container *ic); extern int il_png_write(il_container *, const uint8 *, int32); -extern void il_png_complete(il_container *ic); -extern unsigned int il_png_write_ready(il_container *ic); -extern void il_png_abort(il_container *ic); +extern int il_png_complete(il_container *ic); +//extern unsigned int il_png_write_ready(il_container *ic); +extern int il_png_abort(il_container *ic); extern void png_delay_time_callback(void *closure); diff --git a/mozilla/modules/libimg/public_com/nsIImgDecoder.h b/mozilla/modules/libimg/public_com/nsIImgDecoder.h index d7946b410b3..d3974f9f3b9 100644 --- a/mozilla/modules/libimg/public_com/nsIImgDecoder.h +++ b/mozilla/modules/libimg/public_com/nsIImgDecoder.h @@ -37,7 +37,7 @@ public: NS_IMETHOD ImgDInit()=0; - NS_IMETHOD ImgDWriteReady()=0; + NS_IMETHOD ImgDWriteReady(PRUint32 *request_size)=0; NS_IMETHOD ImgDWrite(const unsigned char *buf, int32 len)=0; NS_IMETHOD ImgDComplete()=0; NS_IMETHOD ImgDAbort()=0;