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 --- render/box.c | 34 ++++++++++------------------------ render/box.h | 8 +------- render/html.c | 57 +++++++++++++++++++++++++++++++++++++++++++-------------- render/html.h | 6 ++++++ 4 files changed, 60 insertions(+), 45 deletions(-) (limited to 'render') diff --git a/render/box.c b/render/box.c index 2909da7de..a4f9073a6 100644 --- a/render/box.c +++ b/render/box.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include "libxml/HTMLparser.h" @@ -20,8 +21,8 @@ #ifdef riscos #include "netsurf/desktop/gui.h" #include "netsurf/riscos/font.h" -#endif #include "netsurf/riscos/plugin.h" +#endif #define NDEBUG #include "netsurf/utils/log.h" #include "netsurf/utils/utils.h" @@ -159,7 +160,7 @@ struct box * box_create(struct css_style * style, box->gadget = 0; box->object = 0; box->object_params = 0; - box->plugin_state = 0; + box->object_state = 0; #endif return box; } @@ -1349,7 +1350,7 @@ void box_free_box(struct box *box) xmlFree(box->href); } - /* TODO: free object_params and plugin_state */ + /* TODO: free object_params */ } @@ -1414,8 +1415,6 @@ struct result box_object(xmlNode *n, struct status *status, po->codebase = 0; po->classid = 0; po->paramds = 0; - po->width = 0; - po->height = 0; /* object data */ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "data"))) { @@ -1458,14 +1457,6 @@ struct result box_object(xmlNode *n, struct status *status, xmlFree(s); } - /* object width */ - if (style->width.width == CSS_WIDTH_LENGTH) - po->width = len(&style->width.value.length, style); - - /* object height */ - if (style->height.height == CSS_HEIGHT_LENGTH) - po->height = len(&style->height.length, style); - /* TODO: go through children looking for , and add * somewhere in po */ @@ -1500,8 +1491,6 @@ struct result box_embed(xmlNode *n, struct status *status, po->codebase = 0; po->classid = 0; po->paramds = 0; - po->width = 0; - po->height = 0; /* embed src */ if ((s = (char *) xmlGetProp(n, (const xmlChar *) "src"))) { @@ -1564,9 +1553,6 @@ struct result box_applet(xmlNode *n, struct status *status, bool plugin_decode(struct content* content, char* url, struct box* box, struct object_params* po) { - os_error *e; - unsigned int *fv; - /* Check if the codebase attribute is defined. * If it is not, set it to the codebase of the current document. */ @@ -1583,12 +1569,12 @@ bool plugin_decode(struct content* content, char* url, struct box* box, * we can't handle this object. */ if(po->data == 0 && po->classid == 0) { - return FALSE; + return false; } if(po->data == 0 && po->classid != 0) { - if(strnicmp(po->classid, "clsid:", 6) == 0) { + if(strncasecmp(po->classid, "clsid:", 6) == 0) { LOG(("ActiveX object - n0")); - return FALSE; + return false; } else { url = url_join(po->classid, po->codebase); @@ -1603,11 +1589,11 @@ bool plugin_decode(struct content* content, char* url, struct box* box, */ if(po->type != 0) { if (content_lookup(po->type) == CONTENT_OTHER) - return FALSE; + return false; } if(po->codetype != 0) { if (content_lookup(po->codetype) == CONTENT_OTHER) - return FALSE; + return false; } /* If we've got to here, the object declaration has provided us with @@ -1619,6 +1605,6 @@ bool plugin_decode(struct content* content, char* url, struct box* box, */ html_fetch_object(content, url, box); - return TRUE; + return true; } diff --git a/render/box.h b/render/box.h index b67d6e7b1..4faaef19a 100644 --- a/render/box.h +++ b/render/box.h @@ -81,9 +81,6 @@ struct gui_gadget { } data; }; -/* state of a plugin handling this box, platform dependent */ -struct plugin_state; - /* parameters for and related elements */ struct object_params { char* data; @@ -92,10 +89,6 @@ struct object_params { char* codebase; char* classid; char* paramds; /* very likely to change */ - unsigned int* width; - unsigned int* height; - /* not a parameter, but stored here for convenience */ - struct plugin_state *plugin_state; }; struct box { @@ -123,6 +116,7 @@ struct box { struct gui_gadget* gadget; struct content* object; /* usually an image */ struct object_params *object_params; + void *object_state; /* state of any object */ }; struct form diff --git a/render/html.c b/render/html.c index b8db76ad1..e9c7b86d7 100644 --- a/render/html.c +++ b/render/html.c @@ -105,13 +105,13 @@ int html_convert(struct content *c, unsigned int width, unsigned int height) xmlFreeDoc(document); content_remove_user(c->data.html.stylesheet_content[0], - html_convert_css_callback, c, 0, 0); + html_convert_css_callback, c, 0); if (c->data.html.stylesheet_content[1] != 0) content_destroy(c->data.html.stylesheet_content[1]); for (i = 2; i != c->data.html.stylesheet_count; i++) if (c->data.html.stylesheet_content[i] != 0) content_remove_user(c->data.html.stylesheet_content[i], - html_convert_css_callback, c, i, 0); + html_convert_css_callback, c, i); xfree(c->data.html.stylesheet_content); /* layout the box tree */ @@ -147,7 +147,7 @@ void html_convert_css_callback(content_msg msg, struct content *css, c->error = 1; sprintf(c->status_message, "Warning: stylesheet is not CSS"); content_broadcast(c, CONTENT_MSG_STATUS, 0); - content_remove_user(css, html_convert_css_callback, c, i, 0); + content_remove_user(css, html_convert_css_callback, c, i); } break; @@ -175,7 +175,7 @@ void html_convert_css_callback(content_msg msg, struct content *css, c->active--; c->data.html.stylesheet_content[i] = fetchcache( error, c->url, html_convert_css_callback, - c, i, css->width, css->height, 0); + c, i, css->width, css->height); if (c->data.html.stylesheet_content[i]->status != CONTENT_STATUS_DONE) c->active++; break; @@ -227,7 +227,7 @@ void html_find_stylesheets(struct content *c, xmlNode *head) #endif c->url, html_convert_css_callback, - c, 0, c->width, c->height, 0); + c, 0, c->width, c->height); if (c->data.html.stylesheet_content[0]->status != CONTENT_STATUS_DONE) c->active++; @@ -277,7 +277,7 @@ void html_find_stylesheets(struct content *c, xmlNode *head) (i + 1) * sizeof(*c->data.html.stylesheet_content)); c->data.html.stylesheet_content[i] = fetchcache(url, c->url, html_convert_css_callback, c, i, - c->width, c->height, 0); + c->width, c->height); if (c->data.html.stylesheet_content[i]->status != CONTENT_STATUS_DONE) c->active++; free(url); @@ -358,7 +358,7 @@ void html_fetch_object(struct content *c, char *url, struct box *box) /* start fetch */ c->data.html.object[i].content = fetchcache(url, c->url, html_object_callback, - c, i, 0, 0, box->object_params); + c, i, 0, 0); c->active++; if (c->data.html.object[i].content->status == CONTENT_STATUS_DONE) html_object_callback(CONTENT_MSG_DONE, @@ -381,7 +381,7 @@ void html_object_callback(content_msg msg, struct content *object, c->error = 1; sprintf(c->status_message, "Warning: bad object type"); content_broadcast(c, CONTENT_MSG_STATUS, 0); - content_remove_user(object, html_object_callback, c, i, 0); + content_remove_user(object, html_object_callback, c, i); } break; @@ -449,8 +449,7 @@ void html_object_callback(content_msg msg, struct content *object, c->data.html.object[i].url = xstrdup(error); c->data.html.object[i].content = fetchcache( error, c->url, html_object_callback, - c, i, 0, 0, - c->data.html.object[i].box->object_params); + c, i, 0, 0); if (c->data.html.object[i].content->status != CONTENT_STATUS_DONE) c->active++; break; @@ -472,6 +471,38 @@ void html_object_callback(content_msg msg, struct content *object, } +void html_add_instance(struct content *c, struct browser_window *bw, + struct content *page, struct box *box, + struct object_params *params, void **state) +{ + for (unsigned int i = 0; i != c->data.html.object_count; i++) { + if (c->data.html.object[i].content == 0) + continue; + content_add_instance(c->data.html.object[i].content, + bw, c, + c->data.html.object[i].box, + c->data.html.object[i].box->object_params, + &c->data.html.object[i].box->object_state); + } +} + + +void html_remove_instance(struct content *c, struct browser_window *bw, + struct content *page, struct box *box, + struct object_params *params, void **state) +{ + for (unsigned int i = 0; i != c->data.html.object_count; i++) { + if (c->data.html.object[i].content == 0) + continue; + content_remove_instance(c->data.html.object[i].content, + bw, c, + c->data.html.object[i].box, + c->data.html.object[i].box->object_params, + &c->data.html.object[i].box->object_state); + } +} + + void html_revive(struct content *c, unsigned int width, unsigned int height) { unsigned int i; @@ -482,8 +513,7 @@ void html_revive(struct content *c, unsigned int width, unsigned int height) c->data.html.object[i].content = fetchcache( c->data.html.object[i].url, c->url, html_object_callback, - c, i, 0, 0, - c->data.html.object[i].box->object_params); + c, i, 0, 0); if (c->data.html.object[i].content->status != CONTENT_STATUS_DONE) c->active++; } @@ -515,8 +545,7 @@ void html_destroy(struct content *c) LOG(("object %i %p", i, c->data.html.object[i].content)); if (c->data.html.object[i].content != 0) content_remove_user(c->data.html.object[i].content, - html_object_callback, c, i, - c->data.html.object[i].box->object_params); + html_object_callback, c, i); free(c->data.html.object[i].url); } free(c->data.html.object); diff --git a/render/html.h b/render/html.h index 2d46f0a05..f58d46255 100644 --- a/render/html.h +++ b/render/html.h @@ -17,5 +17,11 @@ void html_revive(struct content *c, unsigned int width, unsigned int height); void html_reformat(struct content *c, unsigned int width, unsigned int height); void html_destroy(struct content *c); void html_fetch_object(struct content *c, char *url, struct box *box); +void html_add_instance(struct content *c, struct browser_window *bw, + struct content *page, struct box *box, + struct object_params *params, void **state); +void html_remove_instance(struct content *c, struct browser_window *bw, + struct content *page, struct box *box, + struct object_params *params, void **state); #endif -- cgit v1.2.3