From 889ae885c66b0278c632090a0e1b89746a895ed4 Mon Sep 17 00:00:00 2001 From: James Bursa Date: Mon, 14 Jul 2003 22:57:45 +0000 Subject: [project @ 2003-07-14 22:57:45 by bursa] Add content instances. svn path=/import/netsurf/; revision=216 --- content/content.c | 80 ++++++++++++++++++++++++++++++++++++++++------------ content/content.h | 16 +++++++++-- content/fetchcache.c | 7 ++--- content/fetchcache.h | 5 +--- 4 files changed, 80 insertions(+), 28 deletions(-) (limited to 'content') diff --git a/content/content.c b/content/content.c index 056fabdaa..3b0ba7e77 100644 --- a/content/content.c +++ b/content/content.c @@ -13,10 +13,12 @@ #include "netsurf/css/css.h" #include "netsurf/render/html.h" #include "netsurf/render/textplain.h" +#ifdef riscos #include "netsurf/riscos/jpeg.h" #include "netsurf/riscos/png.h" #include "netsurf/riscos/gif.h" #include "netsurf/riscos/plugin.h" +#endif #include "netsurf/utils/log.h" #include "netsurf/utils/utils.h" @@ -48,31 +50,40 @@ struct handler_entry { void (*destroy)(struct content *c); void (*redraw)(struct content *c, long x, long y, unsigned long width, unsigned long height); - void (*add_user)(struct content *c, struct object_params *params); - void (*remove_user)(struct content *c, struct object_params *params); + void (*add_instance)(struct content *c, struct browser_window *bw, + struct content *page, struct box *box, + struct object_params *params, void **state); + void (*remove_instance)(struct content *c, struct browser_window *bw, + struct content *page, struct box *box, + struct object_params *params, void **state); + void (*reshape_instance)(struct content *c, struct browser_window *bw, + struct content *page, struct box *box, + struct object_params *params, void **state); }; static const struct handler_entry handler_map[] = { {html_create, html_process_data, html_convert, html_revive, - html_reformat, html_destroy, 0, 0, 0}, + html_reformat, html_destroy, 0, + html_add_instance, html_remove_instance, 0}, {textplain_create, textplain_process_data, textplain_convert, - textplain_revive, textplain_reformat, textplain_destroy, 0, 0, 0}, + textplain_revive, textplain_reformat, textplain_destroy, 0, 0, 0, 0}, #ifdef riscos {jpeg_create, jpeg_process_data, jpeg_convert, jpeg_revive, - jpeg_reformat, jpeg_destroy, jpeg_redraw, 0, 0}, + jpeg_reformat, jpeg_destroy, jpeg_redraw, 0, 0, 0}, #endif {css_create, css_process_data, css_convert, css_revive, - css_reformat, css_destroy, 0, 0, 0}, + css_reformat, css_destroy, 0, 0, 0, 0}, #ifdef riscos {nspng_create, nspng_process_data, nspng_convert, nspng_revive, - nspng_reformat, nspng_destroy, nspng_redraw, 0, 0}, + nspng_reformat, nspng_destroy, nspng_redraw, 0, 0, 0}, {nsgif_create, nsgif_process_data, nsgif_convert, nsgif_revive, - nsgif_reformat, nsgif_destroy, nsgif_redraw, 0, 0}, + nsgif_reformat, nsgif_destroy, nsgif_redraw, 0, 0, 0}, {plugin_create, plugin_process_data, plugin_convert, plugin_revive, plugin_reformat, plugin_destroy, plugin_redraw, - plugin_add_user, plugin_remove_user}, + plugin_add_instance, plugin_remove_instance, + plugin_reshape_instance}, #endif {other_create, other_process_data, other_convert, other_revive, - other_reformat, other_destroy, 0, 0, 0} + other_reformat, other_destroy, 0, 0, 0, 0} }; #define HANDLER_MAP_COUNT (sizeof(handler_map) / sizeof(handler_map[0])) @@ -87,8 +98,10 @@ content_type content_lookup(const char *mime_type) m = bsearch(mime_type, mime_map, MIME_MAP_COUNT, sizeof(mime_map[0]), (int (*)(const void *, const void *)) strcmp); if (m == 0) { +#ifdef riscos if (plugin_handleable(mime_type)) return CONTENT_PLUGIN; +#endif return CONTENT_OTHER; } return m->type; @@ -126,10 +139,10 @@ struct content * content_create(char *url) void content_set_type(struct content *c, content_type type, char* mime_type) { + assert(c != 0); assert(c->status == CONTENT_STATUS_TYPE_UNKNOWN); assert(type < CONTENT_UNKNOWN); LOG(("content %s, type %i", c->url, type)); - /* TODO: call add_user on each existing user */ c->type = type; c->mime_type = mime_type; c->status = CONTENT_STATUS_LOADING; @@ -245,7 +258,7 @@ void content_redraw(struct content *c, long x, long y, void content_add_user(struct content *c, void (*callback)(content_msg msg, struct content *c, void *p1, void *p2, const char *error), - void *p1, void *p2, struct object_params *params) + void *p1, void *p2) { struct content_user *user; LOG(("content %s, user %p %p %p", c->url, callback, p1, p2)); @@ -255,8 +268,6 @@ void content_add_user(struct content *c, user->p2 = p2; user->next = c->user_list->next; c->user_list->next = user; - if (c->type != CONTENT_UNKNOWN && handler_map[c->type].add_user != 0) - handler_map[c->type].add_user(c, params); } @@ -267,14 +278,11 @@ void content_add_user(struct content *c, void content_remove_user(struct content *c, void (*callback)(content_msg msg, struct content *c, void *p1, void *p2, const char *error), - void *p1, void *p2, struct object_params *params) + void *p1, void *p2) { struct content_user *user, *next; LOG(("content %s, user %p %p %p", c->url, callback, p1, p2)); - if (c->type != CONTENT_UNKNOWN && handler_map[c->type].remove_user != 0) - handler_map[c->type].remove_user(c, params); - /* user_list starts with a sentinel */ for (user = c->user_list; user->next != 0 && !(user->next->callback == callback && @@ -320,3 +328,39 @@ void content_broadcast(struct content *c, content_msg msg, char *error) } } + +void content_add_instance(struct content *c, struct browser_window *bw, + struct content *page, struct box *box, + struct object_params *params, void **state) +{ + assert(c != 0); + assert(c->type < CONTENT_UNKNOWN); + LOG(("content %s", c->url)); + if (handler_map[c->type].add_instance != 0) + handler_map[c->type].add_instance(c, bw, page, box, params, state); +} + + +void content_remove_instance(struct content *c, struct browser_window *bw, + struct content *page, struct box *box, + struct object_params *params, void **state) +{ + assert(c != 0); + assert(c->type < CONTENT_UNKNOWN); + LOG(("content %s", c->url)); + if (handler_map[c->type].remove_instance != 0) + handler_map[c->type].remove_instance(c, bw, page, box, params, state); +} + + +void content_reshape_instance(struct content *c, struct browser_window *bw, + struct content *page, struct box *box, + struct object_params *params, void **state) +{ + assert(c != 0); + assert(c->type < CONTENT_UNKNOWN); + LOG(("content %s", c->url)); + if (handler_map[c->type].reshape_instance != 0) + handler_map[c->type].reshape_instance(c, bw, page, box, params, state); +} + diff --git a/content/content.h b/content/content.h index 1c033f8bc..5ef9f4eea 100644 --- a/content/content.h +++ b/content/content.h @@ -188,6 +188,9 @@ struct content }; +struct browser_window; + + content_type content_lookup(const char *mime_type); struct content * content_create(char *url); void content_set_type(struct content *c, content_type type, char *mime_type); @@ -201,11 +204,20 @@ void content_redraw(struct content *c, long x, long y, void content_add_user(struct content *c, void (*callback)(content_msg msg, struct content *c, void *p1, void *p2, const char *error), - void *p1, void *p2, struct object_params *params); + void *p1, void *p2); void content_remove_user(struct content *c, void (*callback)(content_msg msg, struct content *c, void *p1, void *p2, const char *error), - void *p1, void *p2, struct object_params *params); + void *p1, void *p2); void content_broadcast(struct content *c, content_msg msg, char *error); +void content_add_instance(struct content *c, struct browser_window *bw, + struct content *page, struct box *box, + struct object_params *params, void **state); +void content_remove_instance(struct content *c, struct browser_window *bw, + struct content *page, struct box *box, + struct object_params *params, void **state); +void content_reshape_instance(struct content *c, struct browser_window *bw, + struct content *page, struct box *box, + struct object_params *params, void **state); #endif diff --git a/content/fetchcache.c b/content/fetchcache.c index 23316b1b6..844111376 100644 --- a/content/fetchcache.c +++ b/content/fetchcache.c @@ -21,8 +21,7 @@ static void fetchcache_callback(fetch_msg msg, void *p, char *data, unsigned lon struct content * fetchcache(const char *url0, char *referer, void (*callback)(content_msg msg, struct content *c, void *p1, void *p2, const char *error), - void *p1, void *p2, unsigned long width, unsigned long height, - struct object_params *object_params) + void *p1, void *p2, unsigned long width, unsigned long height) { struct content *c; char *url = xstrdup(url0); @@ -36,12 +35,12 @@ struct content * fetchcache(const char *url0, char *referer, c = cache_get(url); if (c != 0) { - content_add_user(c, callback, p1, p2, object_params); + content_add_user(c, callback, p1, p2); return c; } c = content_create(url); - content_add_user(c, callback, p1, p2, object_params); + content_add_user(c, callback, p1, p2); cache_put(c); c->fetch_size = 0; c->width = width; diff --git a/content/fetchcache.h b/content/fetchcache.h index 1353f682d..ddfc2fa76 100644 --- a/content/fetchcache.h +++ b/content/fetchcache.h @@ -10,12 +10,9 @@ #include "netsurf/content/content.h" -struct object_params; - struct content * fetchcache(const char *url, char *referer, void (*callback)(content_msg msg, struct content *c, void *p1, void *p2, const char *error), - void *p1, void *p2, unsigned long width, unsigned long height, - struct object_params *object_params); + void *p1, void *p2, unsigned long width, unsigned long height); #endif -- cgit v1.2.3