From 83f9e707eba500d39c12b8078948b932706cdab2 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 9 May 2011 15:32:34 +0000 Subject: refactor content handler initilisation to use named initialisors svn path=/trunk/netsurf/; revision=12341 --- amiga/dt_picture.c | 22 +++++++--------------- amiga/icon.c | 22 +++++++--------------- content/content.c | 4 ++-- content/content_protected.h | 2 +- css/css.c | 23 ++++++++--------------- image/bmp.c | 22 +++++++--------------- image/gif.c | 22 +++++++--------------- image/ico.c | 22 +++++++--------------- image/jpeg.c | 22 +++++++--------------- image/mng.c | 23 ++++++++--------------- image/nssprite.c | 22 +++++++--------------- image/png.c | 23 ++++++++--------------- image/rsvg.c | 23 ++++++++--------------- image/svg.c | 23 ++++++++--------------- image/webp.c | 22 +++++++--------------- render/html.c | 29 ++++++++++++++--------------- render/textplain.c | 26 +++++++++++--------------- riscos/content-handlers/artworks.c | 22 +++++++--------------- riscos/content-handlers/draw.c | 22 +++++++--------------- riscos/content-handlers/sprite.c | 22 +++++++--------------- 20 files changed, 145 insertions(+), 273 deletions(-) diff --git a/amiga/dt_picture.c b/amiga/dt_picture.c index c3828d8f5..6866545f5 100644 --- a/amiga/dt_picture.c +++ b/amiga/dt_picture.c @@ -61,21 +61,13 @@ static nserror amiga_dt_picture_clone(const struct content *old, struct content static content_type amiga_dt_picture_content_type(lwc_string *mime_type); static const content_handler amiga_dt_picture_content_handler = { - amiga_dt_picture_create, - NULL, - amiga_dt_picture_convert, - NULL, - amiga_dt_picture_destroy, - NULL, - NULL, - NULL, - amiga_dt_picture_redraw, - NULL, - NULL, - amiga_dt_picture_clone, - NULL, - amiga_dt_picture_content_type, - false + .create = amiga_dt_picture_create, + .data_complete = amiga_dt_picture_convert, + .destroy = amiga_dt_picture_destroy, + .redraw = amiga_dt_picture_redraw, + .clone = amiga_dt_picture_clone, + .type = amiga_dt_picture_content_type, + .no_share = false, }; nserror amiga_dt_picture_init_from_mime(void) diff --git a/amiga/icon.c b/amiga/icon.c index 59df3e955..c6632b018 100644 --- a/amiga/icon.c +++ b/amiga/icon.c @@ -72,21 +72,13 @@ static nserror amiga_icon_clone(const struct content *old, static content_type amiga_icon_content_type(lwc_string *mime_type); static const content_handler amiga_icon_content_handler = { - amiga_icon_create, - NULL, - amiga_icon_convert, - NULL, - amiga_icon_destroy, - NULL, - NULL, - NULL, - amiga_icon_redraw, - NULL, - NULL, - amiga_icon_clone, - NULL, - amiga_icon_content_type, - false + .create = amiga_icon_create, + .data_complete = amiga_icon_convert, + .destroy = amiga_icon_destroy, + .redraw = amiga_icon_redraw, + .clone = amiga_icon_clone, + .type = amiga_icon_content_type, + .no_share = false, }; static const char *amiga_icon_types[] = { diff --git a/content/content.c b/content/content.c index 606f2a91b..c2bc5902b 100644 --- a/content/content.c +++ b/content/content.c @@ -278,9 +278,9 @@ void content_convert(struct content *c) LOG(("content %s (%p)", llcache_handle_get_url(c->llcache), c)); - if (c->handler->convert != NULL) { + if (c->handler->data_complete != NULL) { c->locked = true; - if (c->handler->convert(c) == false) { + if (c->handler->data_complete(c) == false) { c->locked = false; c->status = CONTENT_STATUS_ERROR; } diff --git a/content/content_protected.h b/content/content_protected.h index 6659e2cd8..144136df4 100644 --- a/content/content_protected.h +++ b/content/content_protected.h @@ -46,7 +46,7 @@ struct content_handler { bool (*process_data)(struct content *c, const char *data, unsigned int size); - bool (*convert)(struct content *c); + bool (*data_complete)(struct content *c); void (*reformat)(struct content *c, int width, int height); void (*destroy)(struct content *c); void (*stop)(struct content *c); diff --git a/css/css.c b/css/css.c index a70ae8037..63862c720 100644 --- a/css/css.c +++ b/css/css.c @@ -79,21 +79,14 @@ static css_error nscss_register_import(struct content_css_data *c, const hlcache_handle *import); static const content_handler css_content_handler = { - nscss_create, - nscss_process_data, - nscss_convert, - NULL, - nscss_destroy, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - nscss_clone, - nscss_matches_quirks, - nscss_content_type, - false + .create = nscss_create, + .process_data = nscss_process_data, + .data_complete = nscss_convert, + .destroy = nscss_destroy, + .clone = nscss_clone, + .matches_quirks = nscss_matches_quirks, + .type = nscss_content_type, + .no_share = false, }; static lwc_string *css_mime_type; diff --git a/image/bmp.c b/image/bmp.c index 9e1326e62..b40ab7e8c 100644 --- a/image/bmp.c +++ b/image/bmp.c @@ -272,21 +272,13 @@ static content_type nsbmp_content_type(lwc_string *mime_type) static const content_handler nsbmp_content_handler = { - nsbmp_create, - NULL, - nsbmp_convert, - NULL, - nsbmp_destroy, - NULL, - NULL, - NULL, - nsbmp_redraw, - NULL, - NULL, - nsbmp_clone, - NULL, - nsbmp_content_type, - false + .create = nsbmp_create, + .data_complete = nsbmp_convert, + .destroy = nsbmp_destroy, + .redraw = nsbmp_redraw, + .clone = nsbmp_clone, + .type = nsbmp_content_type, + .no_share = false, }; nserror nsbmp_init(void) diff --git a/image/gif.c b/image/gif.c index 5812952c1..696362205 100644 --- a/image/gif.c +++ b/image/gif.c @@ -418,21 +418,13 @@ static content_type nsgif_content_type(lwc_string *mime_type) static const content_handler nsgif_content_handler = { - nsgif_create, - NULL, - nsgif_convert, - NULL, - nsgif_destroy, - NULL, - NULL, - NULL, - nsgif_redraw, - NULL, - NULL, - nsgif_clone, - NULL, - nsgif_content_type, - false + .create = nsgif_create, + .data_complete = nsgif_convert, + .destroy = nsgif_destroy, + .redraw = nsgif_redraw, + .clone = nsgif_clone, + .type = nsgif_content_type, + .no_share = false, }; nserror nsgif_init(void) diff --git a/image/ico.c b/image/ico.c index 2f546b6e8..e9cfc3a55 100644 --- a/image/ico.c +++ b/image/ico.c @@ -230,21 +230,13 @@ static content_type nsico_content_type(lwc_string *mime_type) } static const content_handler nsico_content_handler = { - nsico_create, - NULL, - nsico_convert, - NULL, - nsico_destroy, - NULL, - NULL, - NULL, - nsico_redraw, - NULL, - NULL, - nsico_clone, - NULL, - nsico_content_type, - false + .create = nsico_create, + .data_complete = nsico_convert, + .destroy = nsico_destroy, + .redraw = nsico_redraw, + .clone = nsico_clone, + .type = nsico_content_type, + .no_share = false, }; diff --git a/image/jpeg.c b/image/jpeg.c index 1d0e16edd..5b355f3e5 100644 --- a/image/jpeg.c +++ b/image/jpeg.c @@ -335,21 +335,13 @@ static content_type nsjpeg_content_type(lwc_string *mime_type) } static const content_handler nsjpeg_content_handler = { - nsjpeg_create, - NULL, - nsjpeg_convert, - NULL, - nsjpeg_destroy, - NULL, - NULL, - NULL, - nsjpeg_redraw, - NULL, - NULL, - nsjpeg_clone, - NULL, - nsjpeg_content_type, - false + .create = nsjpeg_create, + .data_complete = nsjpeg_convert, + .destroy = nsjpeg_destroy, + .redraw = nsjpeg_redraw, + .clone = nsjpeg_clone, + .type = nsjpeg_content_type, + .no_share = false, }; nserror nsjpeg_init(void) diff --git a/image/mng.c b/image/mng.c index 21e5d9d38..ee2b121ea 100644 --- a/image/mng.c +++ b/image/mng.c @@ -96,21 +96,14 @@ static void nsmng_free(mng_ptr p, mng_size_t n); #endif static const content_handler nsmng_content_handler = { - nsmng_create, - nsmng_process_data, - nsmng_convert, - NULL, - nsmng_destroy, - NULL, - NULL, - NULL, - nsmng_redraw, - NULL, - NULL, - nsmng_clone, - NULL, - nsmng_content_type, - false + .create = nsmng_create, + .process_data = nsmng_process_data, + .data_complete = nsmng_convert, + .destroy = nsmng_destroy, + .redraw = nsmng_redraw, + .clone = nsmng_clone, + .type = nsmng_content_type, + .no_share = false, }; static const char *jng_types[] = { diff --git a/image/nssprite.c b/image/nssprite.c index 670764ab7..4c1e173c0 100644 --- a/image/nssprite.c +++ b/image/nssprite.c @@ -72,21 +72,13 @@ static content_type nssprite_content_type(lwc_string *mime_type); } while(0) static const content_handler nssprite_content_handler = { - nssprite_create, - NULL, - nssprite_convert, - NULL, - nssprite_destroy, - NULL, - NULL, - NULL, - nssprite_redraw, - NULL, - NULL, - nssprite_clone, - NULL, - nssprite_content_type, - false + .create = nssprite_create, + .data_complete = nssprite_convert, + .destroy = nssprite_destroy, + .redraw = nssprite_redraw, + .clone = nssprite_clone, + .type = nssprite_content_type, + .no_share = false, }; static const char *nssprite_types[] = { diff --git a/image/png.c b/image/png.c index f3fbf35ea..3093c89e8 100644 --- a/image/png.c +++ b/image/png.c @@ -413,21 +413,14 @@ static content_type nspng_content_type(lwc_string *mime_type) } static const content_handler nspng_content_handler = { - nspng_create, - nspng_process_data, - nspng_convert, - NULL, - nspng_destroy, - NULL, - NULL, - NULL, - nspng_redraw, - NULL, - NULL, - nspng_clone, - NULL, - nspng_content_type, - false + .create = nspng_create, + .process_data = nspng_process_data, + .data_complete = nspng_convert, + .destroy = nspng_destroy, + .redraw = nspng_redraw, + .clone = nspng_clone, + .type = nspng_content_type, + .no_share = false, }; nserror nspng_init(void) diff --git a/image/rsvg.c b/image/rsvg.c index 80c5368a4..63c2f2b6f 100644 --- a/image/rsvg.c +++ b/image/rsvg.c @@ -310,21 +310,14 @@ static content_type rsvg_content_type(lwc_string *mime_type) } static const content_handler rsvg_content_handler = { - rsvg_create, - rsvg_process_data, - rsvg_convert, - NULL, - rsvg_destroy, - NULL, - NULL, - NULL, - rsvg_redraw, - NULL, - NULL, - rsvg_clone, - NULL, - rsvg_content_type, - false + .create = rsvg_create, + .process_data = rsvg_process_data, + .data_complete = rsvg_convert, + .destroy = rsvg_destroy, + .redraw = rsvg_redraw, + .clone = rsvg_clone, + .type = rsvg_content_type, + .no_share = false, }; nserror nsrsvg_init(void) diff --git a/image/svg.c b/image/svg.c index 5f093b8e8..a447eaf54 100644 --- a/image/svg.c +++ b/image/svg.c @@ -59,21 +59,14 @@ static nserror svg_clone(const struct content *old, struct content **newc); static content_type svg_content_type(lwc_string *mime_type); static const content_handler svg_content_handler = { - svg_create, - NULL, - svg_convert, - svg_reformat, - svg_destroy, - NULL, - NULL, - NULL, - svg_redraw, - NULL, - NULL, - svg_clone, - NULL, - svg_content_type, - false + .create = svg_create, + .data_complete = svg_convert, + .reformat = svg_reformat, + .destroy = svg_destroy, + .redraw = svg_redraw, + .clone = svg_clone, + .type = svg_content_type, + .no_share = false, }; static const char *svg_types[] = { diff --git a/image/webp.c b/image/webp.c index 7b651a1c7..daa7f4522 100644 --- a/image/webp.c +++ b/image/webp.c @@ -55,21 +55,13 @@ static nserror webp_clone(const struct content *old, struct content **newc); static content_type webp_content_type(lwc_string *mime_type); static const content_handler webp_content_handler = { - webp_create, - NULL, - webp_convert, - NULL, - webp_destroy, - NULL, - NULL, - NULL, - webp_redraw, - NULL, - NULL, - webp_clone, - NULL, - webp_content_type, - false + .create = webp_create, + .data_complete = webp_convert, + .destroy = webp_destroy, + .redraw = webp_redraw, + .clone = webp_clone, + .type = webp_content_type, + .no_share = false, }; static const char *webp_types[] = { diff --git a/render/html.c b/render/html.c index dd29d2c54..84f0bab40 100644 --- a/render/html.c +++ b/render/html.c @@ -102,21 +102,20 @@ static void html_dump_frameset(struct content_html_frames *frame, #endif static const content_handler html_content_handler = { - html_create, - html_process_data, - html_convert, - html_reformat, - html_destroy, - html_stop, - html_mouse_track, - html_mouse_action, - html_redraw, - html_open, - html_close, - html_clone, - NULL, - html_content_type, - true + .create = html_create, + .process_data = html_process_data, + .data_complete = html_convert, + .reformat = html_reformat, + .destroy = html_destroy, + .stop = html_stop, + .mouse_track = html_mouse_track, + .mouse_action = html_mouse_action, + .redraw = html_redraw, + .open = html_open, + .close = html_close, + .clone = html_clone, + .type = html_content_type, + .no_share = true, }; static const char empty_document[] = diff --git a/render/textplain.c b/render/textplain.c index 6ec2f2521..f498869de 100644 --- a/render/textplain.c +++ b/render/textplain.c @@ -121,21 +121,17 @@ static int textplain_coord_from_offset(const char *text, size_t offset, static float textplain_line_height(void); static const content_handler textplain_content_handler = { - textplain_create, - textplain_process_data, - textplain_convert, - textplain_reformat, - textplain_destroy, - NULL, - textplain_mouse_track, - textplain_mouse_action, - textplain_redraw, - NULL, - NULL, - textplain_clone, - NULL, - textplain_content_type, - true + .create = textplain_create, + .process_data = textplain_process_data, + .data_complete = textplain_convert, + .reformat = textplain_reformat, + .destroy = textplain_destroy, + .mouse_track = textplain_mouse_track, + .mouse_action = textplain_mouse_action, + .redraw = textplain_redraw, + .clone = textplain_clone, + .type = textplain_content_type, + .no_share = true, }; static lwc_string *textplain_mime_type; diff --git a/riscos/content-handlers/artworks.c b/riscos/content-handlers/artworks.c index a46a03010..be1ba7dd2 100644 --- a/riscos/content-handlers/artworks.c +++ b/riscos/content-handlers/artworks.c @@ -118,21 +118,13 @@ static nserror artworks_clone(const struct content *old, struct content **newc); static content_type artworks_content_type(lwc_string *mime_type); static const content_handler artworks_content_handler = { - artworks_create, - NULL, - artworks_convert, - NULL, - artworks_destroy, - NULL, - NULL, - NULL, - artworks_redraw, - NULL, - NULL, - artworks_clone, - NULL, - artworks_content_type, - false + .create = artworks_create, + .data_complete = artworks_convert, + .destroy = artworks_destroy, + .redraw = artworks_redraw, + .clone = artworks_clone, + .type = artworks_content_type, + .no_share = false, }; static const char *artworks_types[] = { diff --git a/riscos/content-handlers/draw.c b/riscos/content-handlers/draw.c index ccb9353cd..97346580e 100644 --- a/riscos/content-handlers/draw.c +++ b/riscos/content-handlers/draw.c @@ -58,21 +58,13 @@ static nserror draw_clone(const struct content *old, struct content **newc); static content_type draw_content_type(lwc_string *mime_type); static const content_handler draw_content_handler = { - draw_create, - NULL, - draw_convert, - NULL, - draw_destroy, - NULL, - NULL, - NULL, - draw_redraw, - NULL, - NULL, - draw_clone, - NULL, - draw_content_type, - false + .create = draw_create, + .data_complete = draw_convert, + .destroy = draw_destroy, + .redraw = draw_redraw, + .clone = draw_clone, + .type = draw_content_type, + .no_share = false, }; static const char *draw_types[] = { diff --git a/riscos/content-handlers/sprite.c b/riscos/content-handlers/sprite.c index de65faca6..b4f370e1a 100644 --- a/riscos/content-handlers/sprite.c +++ b/riscos/content-handlers/sprite.c @@ -60,21 +60,13 @@ static nserror sprite_clone(const struct content *old, struct content **newc); static content_type sprite_content_type(lwc_string *mime_type); static const content_handler sprite_content_handler = { - sprite_create, - NULL, - sprite_convert, - NULL, - sprite_destroy, - NULL, - NULL, - NULL, - sprite_redraw, - NULL, - NULL, - sprite_clone, - NULL, - sprite_content_type, - false + .create = sprite_create, + .data_complete = sprite_convert, + .destroy = sprite_destroy, + .redraw = sprite_redraw, + .clone = sprite_clone, + .type = sprite_content_type, + .no_share = false, }; static const char *sprite_types[] = { -- cgit v1.2.3