diff options
Diffstat (limited to 'content')
-rw-r--r-- | content/content.c | 83 | ||||
-rw-r--r-- | content/content.h | 32 |
2 files changed, 37 insertions, 78 deletions
diff --git a/content/content.c b/content/content.c index da6adeb83..82e015150 100644 --- a/content/content.c +++ b/content/content.c @@ -155,15 +155,10 @@ struct handler_entry { int width, int height, int clip_x0, int clip_y0, int clip_x1, int clip_y1, float scale); - void (*add_instance)(struct content *c, struct browser_window *bw, + void (*open)(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); + struct object_params *params); + void (*close)(struct content *c); /** There must be one content per user for this type. */ bool no_share; }; @@ -172,44 +167,44 @@ struct handler_entry { static const struct handler_entry handler_map[] = { {html_create, html_process_data, html_convert, html_reformat, html_destroy, html_stop, html_redraw, - html_add_instance, html_remove_instance, html_reshape_instance, + html_open, html_close, true}, {textplain_create, html_process_data, textplain_convert, - 0, 0, 0, 0, 0, 0, 0, true}, - {0, 0, css_convert, 0, css_destroy, 0, 0, 0, 0, 0, false}, + 0, 0, 0, 0, 0, 0, true}, + {0, 0, css_convert, 0, css_destroy, 0, 0, 0, 0, false}, #ifdef WITH_JPEG {nsjpeg_create, 0, nsjpeg_convert, - 0, nsjpeg_destroy, 0, nsjpeg_redraw, 0, 0, 0, false}, + 0, nsjpeg_destroy, 0, nsjpeg_redraw, 0, 0, false}, #endif #ifdef WITH_GIF {nsgif_create, 0, nsgif_convert, - 0, nsgif_destroy, 0, nsgif_redraw, 0, 0, 0, false}, + 0, nsgif_destroy, 0, nsgif_redraw, 0, 0, false}, #endif #ifdef WITH_PNG {nsmng_create, nsmng_process_data, nsmng_convert, - 0, nsmng_destroy, 0, nsmng_redraw, 0, 0, 0, false}, + 0, nsmng_destroy, 0, nsmng_redraw, 0, 0, false}, #endif #ifdef WITH_MNG {nsmng_create, nsmng_process_data, nsmng_convert, - 0, nsmng_destroy, 0, nsmng_redraw, 0, 0, 0, false}, + 0, nsmng_destroy, 0, nsmng_redraw, 0, 0, false}, {nsmng_create, nsmng_process_data, nsmng_convert, - 0, nsmng_destroy, 0, nsmng_redraw, 0, 0, 0, false}, + 0, nsmng_destroy, 0, nsmng_redraw, 0, 0, false}, #endif #ifdef WITH_SPRITE {sprite_create, sprite_process_data, sprite_convert, - 0, sprite_destroy, 0, sprite_redraw, 0, 0, 0, false}, + 0, sprite_destroy, 0, sprite_redraw, 0, 0, false}, #endif #ifdef WITH_DRAW {0, 0, draw_convert, - 0, draw_destroy, 0, draw_redraw, 0, 0, 0, false}, + 0, draw_destroy, 0, draw_redraw, 0, 0, false}, #endif #ifdef WITH_PLUGIN {plugin_create, 0, plugin_convert, 0, plugin_destroy, 0, plugin_redraw, - plugin_add_instance, plugin_remove_instance, - plugin_reshape_instance, true}, + plugin_open, plugin_close, + true}, #endif - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, false} + {0, 0, 0, 0, 0, 0, 0, 0, 0, false} }; #define HANDLER_MAP_COUNT (sizeof(handler_map) / sizeof(handler_map[0])) @@ -290,9 +285,6 @@ struct content * content_create(const char *url) c->total_size = 0; c->no_error_pages = false; c->error_count = 0; - c->owning_bw = 0; - c->owning_box = 0; - c->params = 0; c->prev = 0; c->next = content_list; @@ -867,60 +859,39 @@ void content_stop_check(struct content *c) /** - * Add an instance to a content. + * A window containing the content has been opened. * - * Calls the add_instance function for the content. + * Calls the open function for the content. */ -void content_add_instance(struct content *c, struct browser_window *bw, +void content_open(struct content *c, struct browser_window *bw, struct content *page, struct box *box, - struct object_params *params, void **state) + struct object_params *params) { assert(c != 0); assert(c->type < CONTENT_UNKNOWN); LOG(("content %s", c->url)); - if (handler_map[c->type].add_instance) - handler_map[c->type].add_instance(c, bw, page, box, params, state); + if (handler_map[c->type].open) + handler_map[c->type].open(c, bw, page, box, params); } /** - * Remove an instance from a content. + * The window containing the content has been closed. * - * Calls the remove_instance function for the content. + * Calls the close function for the content. */ -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_close(struct content *c) { assert(c != 0); assert(c->type < CONTENT_UNKNOWN); LOG(("content %s", c->url)); - if (handler_map[c->type].remove_instance) - handler_map[c->type].remove_instance(c, bw, page, box, params, state); + if (handler_map[c->type].close) + handler_map[c->type].close(c); } -/** - * Reshape an instance of a content. - * - * Calls the reshape_instance function for the content. - */ - -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) - handler_map[c->type].reshape_instance(c, bw, page, box, params, state); -} - - - void content_add_error(struct content *c, const char *token, unsigned int line) { diff --git a/content/content.h b/content/content.h index c3116c5c5..48a15ed00 100644 --- a/content/content.h +++ b/content/content.h @@ -35,7 +35,7 @@ * content_create -> TYPE_UNKNOWN [style=bold]; * TYPE_UNKNOWN -> content_set_type [style=bold]; * content_set_type -> LOADING [label=MSG_LOADING, style=bold]; - * content_set_type -> LOADING [label="MSG_NEWPTR\nMSG_LOADING",style=bold]; + * content_set_type -> LOADING [label="MSG_NEWPTR\nMSG_LOADING"]; * content_set_type -> ERROR [label=MSG_ERROR]; * LOADING -> content_process_data [style=bold]; * content_process_data -> LOADING [style=bold]; @@ -81,8 +81,12 @@ * CONTENT_STATUS_READY. Must stop any processing and set the status to * CONTENT_STATUS_DONE. Required iff the status can be CONTENT_STATUS_READY. * - * - <i>type</i>_(add|remove|reshape)_instance: ask James, this will probably - * be redesigned sometime. + * - <i>type</i>_open(): called when a window containing the content is + * opened. Probably only makes sense if no_share is set for the content type + * in handler_map. Optional. + * + * - <i>type</i>_close(): called when the window containing the content is + * closed. Optional. * * - <i>type</i>_create(), <i>type</i>_process_data(), <i>type</i>_convert(): * if an error occurs, must broadcast CONTENT_MSG_ERROR and return false. @@ -248,17 +252,6 @@ struct content { } error_list[40]; unsigned int error_count; /**< Number of valid error entries. */ - /** Browser window that this content is in, valid only if - * handler_map[type].no_share and 1 user, 0 if not visible. */ - struct browser_window *owning_bw; - /** Box window that this content is in, valid only if - * handler_map[type].no_share and 1 user, 0 if not in an HTML tree. */ - struct box *owning_box; - /** Parameters of <object> or <embed>, valid only if - * handler_map[type].no_share and 1 user, 0 if not in an <object> or - * <embed>. */ - struct object_params *params; - struct content *prev; /**< Previous in global content list. */ struct content *next; /**< Next in global content list. */ }; @@ -303,15 +296,10 @@ void content_stop(struct content *c, void (*callback)(content_msg msg, struct content *c, void *p1, void *p2, union content_msg_data data), void *p1, void *p2); -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, +void content_open(struct content *c, struct browser_window *bw, struct content *page, struct box *box, - struct object_params *params, void **state); + struct object_params *params); +void content_close(struct content *c); void content_add_error(struct content *c, const char *token, unsigned int line); |