mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-23 04:26:50 +03:00
GIF content handler: Convert to using content_broadcast_errorcode().
This commit is contained in:
parent
337bd98f6c
commit
d83f6ea3c1
@ -72,7 +72,6 @@ static void *nsgif_bitmap_create(int width, int height)
|
|||||||
|
|
||||||
static nserror nsgif_create_gif_data(nsgif_content *c)
|
static nserror nsgif_create_gif_data(nsgif_content *c)
|
||||||
{
|
{
|
||||||
union content_msg_data msg_data;
|
|
||||||
gif_bitmap_callback_vt gif_bitmap_callbacks = {
|
gif_bitmap_callback_vt gif_bitmap_callbacks = {
|
||||||
.bitmap_create = nsgif_bitmap_create,
|
.bitmap_create = nsgif_bitmap_create,
|
||||||
.bitmap_destroy = guit->bitmap->destroy,
|
.bitmap_destroy = guit->bitmap->destroy,
|
||||||
@ -85,8 +84,7 @@ static nserror nsgif_create_gif_data(nsgif_content *c)
|
|||||||
/* Initialise our data structure */
|
/* Initialise our data structure */
|
||||||
c->gif = calloc(sizeof(gif_animation), 1);
|
c->gif = calloc(sizeof(gif_animation), 1);
|
||||||
if (c->gif == NULL) {
|
if (c->gif == NULL) {
|
||||||
msg_data.error = messages_get("NoMemory");
|
content_broadcast_errorcode(&c->base, NSERROR_NOMEM);
|
||||||
content_broadcast(&c->base, CONTENT_MSG_ERROR, &msg_data);
|
|
||||||
return NSERROR_NOMEM;
|
return NSERROR_NOMEM;
|
||||||
}
|
}
|
||||||
gif_create(c->gif, &gif_bitmap_callbacks);
|
gif_create(c->gif, &gif_bitmap_callbacks);
|
||||||
@ -238,7 +236,6 @@ static bool nsgif_convert(struct content *c)
|
|||||||
{
|
{
|
||||||
nsgif_content *gif = (nsgif_content *) c;
|
nsgif_content *gif = (nsgif_content *) c;
|
||||||
int res;
|
int res;
|
||||||
union content_msg_data msg_data;
|
|
||||||
const char *data;
|
const char *data;
|
||||||
unsigned long size;
|
unsigned long size;
|
||||||
char *title;
|
char *title;
|
||||||
@ -251,17 +248,18 @@ static bool nsgif_convert(struct content *c)
|
|||||||
res = gif_initialise(gif->gif, size, (unsigned char *) data);
|
res = gif_initialise(gif->gif, size, (unsigned char *) data);
|
||||||
if (res != GIF_OK && res != GIF_WORKING &&
|
if (res != GIF_OK && res != GIF_WORKING &&
|
||||||
res != GIF_INSUFFICIENT_FRAME_DATA) {
|
res != GIF_INSUFFICIENT_FRAME_DATA) {
|
||||||
|
nserror error = NSERROR_UNKNOWN;
|
||||||
switch (res) {
|
switch (res) {
|
||||||
case GIF_FRAME_DATA_ERROR:
|
case GIF_FRAME_DATA_ERROR:
|
||||||
case GIF_INSUFFICIENT_DATA:
|
case GIF_INSUFFICIENT_DATA:
|
||||||
case GIF_DATA_ERROR:
|
case GIF_DATA_ERROR:
|
||||||
msg_data.error = messages_get("BadGIF");
|
error = NSERROR_GIF_ERROR;
|
||||||
break;
|
break;
|
||||||
case GIF_INSUFFICIENT_MEMORY:
|
case GIF_INSUFFICIENT_MEMORY:
|
||||||
msg_data.error = messages_get("NoMemory");
|
error = NSERROR_NOMEM;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
|
content_broadcast_errorcode(c, error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} while (res != GIF_OK && res != GIF_INSUFFICIENT_FRAME_DATA);
|
} while (res != GIF_OK && res != GIF_INSUFFICIENT_FRAME_DATA);
|
||||||
@ -269,8 +267,7 @@ static bool nsgif_convert(struct content *c)
|
|||||||
/* Abort on bad GIFs */
|
/* Abort on bad GIFs */
|
||||||
if ((gif->gif->frame_count_partial == 0) || (gif->gif->width == 0) ||
|
if ((gif->gif->frame_count_partial == 0) || (gif->gif->width == 0) ||
|
||||||
(gif->gif->height == 0)) {
|
(gif->gif->height == 0)) {
|
||||||
msg_data.error = messages_get("BadGIF");
|
content_broadcast_errorcode(c, NSERROR_GIF_ERROR);
|
||||||
content_broadcast(c, CONTENT_MSG_ERROR, &msg_data);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +49,8 @@ typedef enum {
|
|||||||
|
|
||||||
NSERROR_BMP_ERROR, /**< A BMP error occurred */
|
NSERROR_BMP_ERROR, /**< A BMP error occurred */
|
||||||
|
|
||||||
|
NSERROR_GIF_ERROR, /**< A GIF error occurred */
|
||||||
|
|
||||||
NSERROR_BAD_ENCODING, /**< The character set is unknown */
|
NSERROR_BAD_ENCODING, /**< The character set is unknown */
|
||||||
|
|
||||||
NSERROR_NEED_DATA, /**< More data needed */
|
NSERROR_NEED_DATA, /**< More data needed */
|
||||||
|
Loading…
Reference in New Issue
Block a user