summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--content/content.c80
-rw-r--r--content/content.h16
-rw-r--r--content/fetchcache.c7
-rw-r--r--content/fetchcache.h5
-rw-r--r--css/css.c10
-rw-r--r--css/css.h2
-rwxr-xr-xcss/makeenum1
-rw-r--r--css/ruleset.c2
-rw-r--r--desktop/browser.c20
-rw-r--r--desktop/browser.h3
-rw-r--r--makefile4
-rw-r--r--render/box.c34
-rw-r--r--render/box.h8
-rw-r--r--render/html.c57
-rw-r--r--render/html.h6
-rw-r--r--riscos/gui.h1
-rw-r--r--riscos/plugin.c60
-rw-r--r--riscos/plugin.h13
18 files changed, 221 insertions, 108 deletions
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
diff --git a/css/css.c b/css/css.c
index 48dd28bee..8a29abb85 100644
--- a/css/css.c
+++ b/css/css.c
@@ -146,7 +146,7 @@ void css_revive(struct content *c, unsigned int width, unsigned int height)
c->data.css.import_content[i] = fetchcache(
c->data.css.import_url[i], c->url,
css_atimport_callback, c, i,
- c->width, c->height, 0);
+ c->width, c->height);
if (c->data.css.import_content[i]->status != CONTENT_STATUS_DONE)
c->active++;
}
@@ -179,7 +179,7 @@ void css_destroy(struct content *c)
if (c->data.css.import_content[i] != 0) {
free(c->data.css.import_url[i]);
content_remove_user(c->data.css.import_content[i],
- css_atimport_callback, c, i, 0);
+ css_atimport_callback, c, i);
}
xfree(c->data.css.import_url);
xfree(c->data.css.import_content);
@@ -295,7 +295,7 @@ void css_atimport(struct content *c, struct node *node)
c->data.css.import_url[i] = url_join(url, c->url);
c->data.css.import_content[i] = fetchcache(
c->data.css.import_url[i], c->url, css_atimport_callback,
- c, i, c->width, c->height, 0);
+ c, i, c->width, c->height);
if (c->data.css.import_content[i]->status != CONTENT_STATUS_DONE)
c->active++;
@@ -311,7 +311,7 @@ void css_atimport_callback(content_msg msg, struct content *css,
switch (msg) {
case CONTENT_MSG_LOADING:
if (css->type != CONTENT_CSS) {
- content_remove_user(css, css_atimport_callback, c, i, 0);
+ content_remove_user(css, css_atimport_callback, c, i);
c->data.css.import_content[i] = 0;
c->active--;
c->error = 1;
@@ -342,7 +342,7 @@ void css_atimport_callback(content_msg msg, struct content *css,
c->data.css.import_url[i] = xstrdup(error);
c->data.css.import_content[i] = fetchcache(
c->data.css.import_url[i], c->url, css_atimport_callback,
- c, i, css->width, css->height, 0);
+ c, i, css->width, css->height);
if (c->data.css.import_content[i]->status != CONTENT_STATUS_DONE)
c->active++;
break;
diff --git a/css/css.h b/css/css.h
index 002c30fcd..08464c1e3 100644
--- a/css/css.h
+++ b/css/css.h
@@ -159,7 +159,7 @@ struct parse_params {
* interface
*/
-#include "netsurf/content/content.h"
+struct content;
void css_create(struct content *c);
void css_process_data(struct content *c, char *data, unsigned long size);
diff --git a/css/makeenum b/css/makeenum
index 516e2c06b..4950cc14d 100755
--- a/css/makeenum
+++ b/css/makeenum
@@ -11,6 +11,7 @@ $out = shift or die "usage: makeenum leafname";
open H, ">$out.h" or die "open 'enum.h' failed";
open C, ">$out.c" or die "open 'enum.c' failed";
+print C "#include <string.h>\n";
print C "#include \"$out.h\"\n\n";
while (<>) {
diff --git a/css/ruleset.c b/css/ruleset.c
index 36e1a03cf..908b8a2f7 100644
--- a/css/ruleset.c
+++ b/css/ruleset.c
@@ -8,10 +8,10 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
-#include <strings.h>
#define CSS_INTERNALS
#define NDEBUG
#include "netsurf/css/css.h"
+#include "netsurf/content/content.h"
#include "netsurf/utils/log.h"
#include "netsurf/utils/utils.h"
diff --git a/desktop/browser.c b/desktop/browser.c
index 5016b9d82..4f9fcc362 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -60,7 +60,7 @@ void browser_window_stop_throbber(struct browser_window* bw)
}
-void browser_window_reformat(struct browser_window* bw)
+void browser_window_reformat(struct browser_window* bw, int scroll_to_top)
{
LOG(("bw = %p", bw));
@@ -73,7 +73,8 @@ void browser_window_reformat(struct browser_window* bw)
else
gui_window_set_title(bw->window, bw->current_content->title);
gui_window_set_extent(bw->window, bw->current_content->width, bw->current_content->height);
- gui_window_set_scroll(bw->window, 0, 0);
+ if (scroll_to_top)
+ gui_window_set_scroll(bw->window, 0, 0);
gui_window_redraw_window(bw->window);
LOG(("done"));
@@ -182,8 +183,10 @@ void browser_window_destroy(struct browser_window* bw)
LOG(("bw = %p", bw));
assert(bw != 0);
- if (bw->current_content != NULL)
- content_remove_user(bw->current_content, browser_window_callback, bw, 0, 0);
+ if (bw->current_content != NULL) {
+ content_remove_instance(bw->current_content, bw, 0, 0, 0, &bw->current_content_state);
+ content_remove_user(bw->current_content, browser_window_callback, bw, 0);
+ }
if (bw->history != NULL)
{
@@ -226,7 +229,7 @@ void browser_window_open_location_historical(struct browser_window* bw, const ch
browser_window_start_throbber(bw);
bw->time0 = clock();
bw->loading_content = fetchcache(url, 0, browser_window_callback, bw, 0,
- gui_window_get_width(bw->window), 0, 0);
+ gui_window_get_width(bw->window), 0);
if (bw->loading_content->status == CONTENT_STATUS_READY)
browser_window_callback(CONTENT_MSG_READY, bw->loading_content, bw, 0, 0);
else if (bw->loading_content->status == CONTENT_STATUS_DONE)
@@ -294,18 +297,21 @@ void browser_window_callback(content_msg msg, struct content *c,
gui_remove_gadget(bw->current_content->data.html.elements.gadgets[gc]);
}
}
- content_remove_user(bw->current_content, browser_window_callback, bw, 0, 0);
+ content_remove_instance(bw->current_content, bw, 0, 0, 0, &bw->current_content_state);
+ content_remove_user(bw->current_content, browser_window_callback, bw, 0);
}
bw->current_content = c;
bw->loading_content = 0;
}
- browser_window_reformat(bw);
gui_window_set_redraw_safety(bw->window, previous_safety);
if (bw->current_content->status == CONTENT_STATUS_DONE) {
+ content_add_instance(bw->current_content, bw, 0, 0, 0, &bw->current_content_state);
+ browser_window_reformat(bw, 0);
sprintf(status, "Page complete (%gs)", ((float) (clock() - bw->time0)) / CLOCKS_PER_SEC);
browser_window_set_status(bw, status);
browser_window_stop_throbber(bw);
} else {
+ browser_window_reformat(bw, 1);
browser_window_set_status(bw, c->status_message);
}
break;
diff --git a/desktop/browser.h b/desktop/browser.h
index d7bd0781b..016f2e636 100644
--- a/desktop/browser.h
+++ b/desktop/browser.h
@@ -52,6 +52,7 @@ struct browser_window
struct { int mult; int div; } scale;
struct content* current_content;
+ void *current_content_state;
struct content* loading_content;
struct history* history;
clock_t time0;
@@ -117,6 +118,6 @@ int box_position_distance(struct box_position* x, struct box_position* y);
void gui_redraw_gadget(struct browser_window* bw, struct gui_gadget* g);
void browser_window_stop_throbber(struct browser_window* bw);
-void browser_window_reformat(struct browser_window* bw);
+void browser_window_reformat(struct browser_window* bw, int scroll_to_top);
#endif
diff --git a/makefile b/makefile
index ea95bad4f..bd007f1e6 100644
--- a/makefile
+++ b/makefile
@@ -23,9 +23,9 @@ WARNFLAGS = -W -Wall -Wundef -Wpointer-arith -Wbad-function-cast -Wcast-qual \
-Wcast-align -Wwrite-strings -Wconversion -Wstrict-prototypes \
-Wmissing-prototypes -Wmissing-declarations -Wredundant-decls \
-Wnested-externs -Winline -Wno-unused-parameter -Wuninitialized
-CFLAGS = -O $(WARNFLAGS) -I.. -I/usr/local/riscoslibs/include \
+CFLAGS = -std=c9x -D_BSD_SOURCE -Driscos -DBOOL_DEFINED -O $(WARNFLAGS) -I.. -I/usr/local/riscoslibs/include \
-Dfd_set=long -mpoke-function-name
-CFLAGS_DEBUG = -O $(WARNFLAGS) -I.. -I/usr/include/libxml2 \
+CFLAGS_DEBUG = -std=c9x -D_BSD_SOURCE -O $(WARNFLAGS) -I.. -I/usr/include/libxml2 \
-Dfd_set=long -g
LDFLAGS = \
/usr/local/riscoslibs/libungif/libungif.ro \
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 <assert.h>
#include <ctype.h>
#include <stdio.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#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 <param>, 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 <object> 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
diff --git a/riscos/gui.h b/riscos/gui.h
index e447eb278..841d8c7c2 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -8,6 +8,7 @@
#ifndef _NETSURF_RISCOS_GUI_H_
#define _NETSURF_RISCOS_GUI_H_
+#include "netsurf/render/box.h"
#include "oslib/wimp.h"
extern char *NETSURF_DIR;
diff --git a/riscos/plugin.c b/riscos/plugin.c
index 421d8b6f2..6d7b80f1a 100644
--- a/riscos/plugin.c
+++ b/riscos/plugin.c
@@ -28,21 +28,28 @@
*/
void plugin_create(struct content *c)
{
+ c->data.plugin.data = xcalloc(0, 1);
+ c->data.plugin.length = 0;
/* we can't create the plugin here, because this is only called
* once, even if the object appears several times */
}
/**
- * plugin_add_user
+ * plugin_add_instance
*
* The content has been added to a page somewhere: launch the plugin.
* This may be called anytime after plugin_create any number of times.
* Each must launch a new plugin.
+ *
+ * bw is the window which the plugin is in
+ * page, box, params are 0 if the object is standalone
+ * state may be used to store a pointer to state data
*/
-void plugin_add_user(struct content *c, struct object_params *params)
+void plugin_add_instance(struct content *c, struct browser_window *bw,
+ struct content *page, struct box *box,
+ struct object_params *params, void **state)
{
- assert(params != 0);
/* ok, it looks like we can handle this object.
* Broadcast Message_PlugIn_Open (&4D540) and listen for response
* Message_PlugIn_Opening (&4D541). If no response, try to launch
@@ -57,17 +64,37 @@ void plugin_add_user(struct content *c, struct object_params *params)
/**
- * plugin_remove_user
+ * plugin_remove_instance
*
* A plugin is no longer required, eg. the page containing it has
* been closed.
+ *
+ * Any storage associated with state must be freed.
*/
-void plugin_remove_user(struct content *c, struct object_params *params)
+void plugin_remove_instance(struct content *c, struct browser_window *bw,
+ struct content *page, struct box *box,
+ struct object_params *params, void **state)
{
- assert(params != 0);
}
+/**
+ * plugin_reshape_instance
+ *
+ * The box containing the plugin has moved or resized,
+ * or the window containing the plugin has resized if standalone.
+ */
+void plugin_reshape_instance(struct content *c, struct browser_window *bw,
+ struct content *page, struct box *box,
+ struct object_params *params, void **state)
+{
+ /* By now, we've got the plugin up and running in a nested window
+ * off the viewable page area. Now we want to display it in its place.
+ * Therefore, broadcast a Message_PlugIn_Reshape (&4D544) with the values
+ * given to us.
+ */
+}
+
static const char * const ALIAS_PREFIX = "Alias$@PlugInType_";
@@ -78,16 +105,17 @@ static const char * const ALIAS_PREFIX = "Alias$@PlugInType_";
*/
bool plugin_handleable(const char *mime_type)
{
- char *sysvar;
+ char sysvar[40]; /* must be sufficient for ALIAS_PREFIX and a hex number */
unsigned int *fv;
os_error *e;
- /* prefix + 3 for file type + 1 for terminating \0 */
- sysvar = xcalloc(strlen(ALIAS_PREFIX)+4, sizeof(char));
-
e = xmimemaptranslate_mime_type_to_filetype(mime_type, (bits *) &fv);
+ if (e) {
+ LOG(("xmimemaptranslate_mime_type_to_filetype failed: %s", e->errmess));
+ return FALSE;
+ }
- sprintf(sysvar, "%s%x", ALIAS_PREFIX, e == NULL ? fv : 0 );
+ sprintf(sysvar, "%s%x", ALIAS_PREFIX, fv);
if (getenv(sysvar) == 0)
return FALSE;
return TRUE;
@@ -114,6 +142,11 @@ void plugin_process_data(struct content *c, char *data, unsigned long size)
/* I think we should just buffer the data here, in case the
* plugin requests it sometime in the future. - James */
+
+ c->data.plugin.data = xrealloc(c->data.plugin.data, c->data.plugin.length + size);
+ memcpy(c->data.plugin.data + c->data.plugin.length, data, size);
+ c->data.plugin.length += size;
+ c->size += size;
}
/**
@@ -155,9 +188,4 @@ void plugin_redraw(struct content *c, long x, long y,
unsigned long width, unsigned long height)
{
- /* By now, we've got the plugin up and running in a nested window
- * off the viewable page area. Now we want to display it in its place.
- * Therefore, broadcast a Message_PlugIn_Reshape (&4D544) with the values
- * given to us.
- */
}
diff --git a/riscos/plugin.h b/riscos/plugin.h
index 0c65012f1..40924b884 100644
--- a/riscos/plugin.h
+++ b/riscos/plugin.h
@@ -8,6 +8,7 @@
#ifndef _NETSURF_RISCOS_PLUGIN_H_
#define _NETSURF_RISCOS_PLUGIN_H_
+#include <stdbool.h>
#include "netsurf/content/content.h"
#include "netsurf/render/box.h"
@@ -25,7 +26,15 @@ void plugin_reformat(struct content *c, unsigned int width, unsigned int height)
void plugin_destroy(struct content *c);
void plugin_redraw(struct content *c, long x, long y,
unsigned long width, unsigned long height);
-void plugin_add_user(struct content *c, struct object_params *params);
-void plugin_remove_user(struct content *c, struct object_params *params);
+void plugin_add_instance(struct content *c, struct browser_window *bw,
+ struct content *page, struct box *box,
+ struct object_params *params, void **state);
+void plugin_remove_instance(struct content *c, struct browser_window *bw,
+ struct content *page, struct box *box,
+ struct object_params *params, void **state);
+void plugin_reshape_instance(struct content *c, struct browser_window *bw,
+ struct content *page, struct box *box,
+ struct object_params *params, void **state);
+
#endif