summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2004-08-11 22:08:26 +0000
committerJames Bursa <james@netsurf-browser.org>2004-08-11 22:08:26 +0000
commitacfb4c0adb113b0dfaff7f07e93be58fd4238bd6 (patch)
tree4d0775011a0f7502618b26308eb80139f28d68d3
parent45b241906ed3b29ee6bd0e62fe71f1f5a7facba5 (diff)
downloadnetsurf-acfb4c0adb113b0dfaff7f07e93be58fd4238bd6.tar.gz
netsurf-acfb4c0adb113b0dfaff7f07e93be58fd4238bd6.tar.bz2
[project @ 2004-08-11 22:08:25 by bursa]
Remove content_add_instance(), content_remove_instance(), content_reshape_instance(). Add content_open(), content_close(). Implement for CONTENT_HTML. svn path=/import/netsurf/; revision=1213
-rw-r--r--content/content.c83
-rw-r--r--content/content.h32
-rw-r--r--desktop/browser.c20
-rw-r--r--desktop/browser.h2
-rw-r--r--makefile2
-rw-r--r--render/box.c1
-rw-r--r--render/box.h2
-rw-r--r--render/html.c50
-rw-r--r--render/html.h16
-rw-r--r--riscos/htmlinstance.c62
-rw-r--r--riscos/plugin.c34
-rw-r--r--riscos/plugin.h11
12 files changed, 132 insertions, 183 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);
diff --git a/desktop/browser.c b/desktop/browser.c
index 256e9effd..949d7511b 100644
--- a/desktop/browser.c
+++ b/desktop/browser.c
@@ -217,12 +217,10 @@ void browser_window_callback(content_msg msg, struct content *c,
if (bw->current_content) {
if (bw->current_content->status ==
+ CONTENT_STATUS_READY ||
+ bw->current_content->status ==
CONTENT_STATUS_DONE)
- content_remove_instance(
- bw->current_content,
- bw, 0, 0,
- 0,
- &bw->current_content_state);
+ content_close(bw->current_content);
content_remove_user(bw->current_content,
browser_window_callback,
bw, 0);
@@ -233,6 +231,7 @@ void browser_window_callback(content_msg msg, struct content *c,
gui_window_new_content(bw->window);
gui_window_set_url(bw->window, c->url);
browser_window_update(bw, true);
+ content_open(c, bw, 0, 0, 0);
browser_window_set_status(bw, c->status_message);
if (bw->history_add)
history_add(bw->history, c, bw->frag_id);
@@ -241,11 +240,7 @@ void browser_window_callback(content_msg msg, struct content *c,
case CONTENT_MSG_DONE:
assert(bw->current_content == c);
- content_add_instance(c, bw, 0, 0, 0,
- &bw->current_content_state);
browser_window_update(bw, false);
- content_reshape_instance(c, bw, 0, 0, 0,
- &bw->current_content_state);
sprintf(status, messages_get("Complete"),
((float) (clock() - bw->time0)) /
CLOCKS_PER_SEC);
@@ -510,9 +505,10 @@ void browser_window_destroy(struct browser_window *bw)
}
if (bw->current_content) {
- if (bw->current_content->status == CONTENT_STATUS_DONE)
- content_remove_instance(bw->current_content, bw, 0,
- 0, 0, &bw->current_content_state);
+ if (bw->current_content->status == CONTENT_STATUS_READY ||
+ bw->current_content->status ==
+ CONTENT_STATUS_DONE)
+ content_close(bw->current_content);
content_remove_user(bw->current_content,
browser_window_callback, bw, 0);
}
diff --git a/desktop/browser.h b/desktop/browser.h
index 42bdb39d4..77f084349 100644
--- a/desktop/browser.h
+++ b/desktop/browser.h
@@ -28,8 +28,6 @@ struct browser_window
{
/** Page currently displayed, or 0. Must have status READY or DONE. */
struct content *current_content;
- /** Instance state pointer for current_content. */
- void *current_content_state;
/** Page being loaded, or 0. */
struct content *loading_content;
diff --git a/makefile b/makefile
index fc7e9fc61..316f16c86 100644
--- a/makefile
+++ b/makefile
@@ -27,7 +27,7 @@ OBJECTS_RISCOS = $(OBJECTS_COMMON)
OBJECTS_RISCOS += browser.o netsurf.o version.o # desktop/
OBJECTS_RISCOS += 401login.o debugwin.o \
buffer.o dialog.o download.o draw.o filetype.o font.o gif.o \
- gifread.o gui.o help.o history.o hotlist.o htmlinstance.o \
+ gifread.o gui.o help.o history.o hotlist.o \
htmlredraw.o jpeg.o menus.o mng.o mouseactions.o plugin.o \
print.o save.o save_complete.o save_draw.o save_text.o \
schedule.o search.o sprite.o textselection.o theme.o thumbnail.o \
diff --git a/render/box.c b/render/box.c
index 5776501b0..95224ec2a 100644
--- a/render/box.c
+++ b/render/box.c
@@ -229,7 +229,6 @@ struct box * box_create(struct css_style * style,
box->background = 0;
box->object = 0;
box->object_params = 0;
- box->object_state = 0;
box->x = box->y = 0;
box->height = 0;
for (i = 0; i != 4; i++)
diff --git a/render/box.h b/render/box.h
index f92a339ad..3f69917bf 100644
--- a/render/box.h
+++ b/render/box.h
@@ -216,8 +216,6 @@ struct box {
struct content* object;
/** Parameters for the object, or 0. */
struct object_params *object_params;
- /** State of object, or 0. */
- void *object_state;
};
/** Table column data. */
diff --git a/render/html.c b/render/html.c
index 09cdd570c..8bf03c4bf 100644
--- a/render/html.c
+++ b/render/html.c
@@ -110,6 +110,7 @@ bool html_create(struct content *c, const char *params[])
html->imagemaps = 0;
html->string_pool = pool_create(8000);
html->box_pool = pool_create(sizeof (struct box) * 100);
+ html->bw = 0;
if (!html->parser || !html->base_url || !html->string_pool ||
!html->box_pool) {
@@ -664,8 +665,14 @@ void html_object_callback(content_msg msg, struct content *object,
case CONTENT_MSG_LOADING:
/* check if the type is acceptable for this object */
if (html_object_type_permitted(object->type,
- c->data.html.object[i].permitted_types))
+ c->data.html.object[i].permitted_types)) {
+ if (c->data.html.bw)
+ content_open(object,
+ c->data.html.bw, c,
+ box,
+ box->object_params);
break;
+ }
/* not acceptable */
c->data.html.object[i].content = 0;
@@ -945,3 +952,44 @@ void html_destroy(struct content *c)
pool_destroy(c->data.html.string_pool);
pool_destroy(c->data.html.box_pool);
}
+
+
+/**
+ * Handle a window containing a CONTENT_HTML being opened.
+ */
+
+void html_open(struct content *c, struct browser_window *bw,
+ struct content *page, struct box *box,
+ struct object_params *params)
+{
+ unsigned int i;
+ c->data.html.bw = bw;
+ for (i = 0; i != c->data.html.object_count; i++) {
+ if (c->data.html.object[i].content == 0)
+ continue;
+ if (c->data.html.object[i].content->type == CONTENT_UNKNOWN)
+ continue;
+ content_open(c->data.html.object[i].content,
+ bw, c,
+ c->data.html.object[i].box,
+ c->data.html.object[i].box->object_params);
+ }
+}
+
+
+/**
+ * Handle a window containing a CONTENT_HTML being closed.
+ */
+
+void html_close(struct content *c)
+{
+ unsigned int i;
+ c->data.html.bw = 0;
+ for (i = 0; i != c->data.html.object_count; i++) {
+ if (c->data.html.object[i].content == 0)
+ continue;
+ if (c->data.html.object[i].content->type == CONTENT_UNKNOWN)
+ continue;
+ content_close(c->data.html.object[i].content);
+ }
+}
diff --git a/render/html.h b/render/html.h
index 85a342a14..be84d9efd 100644
--- a/render/html.h
+++ b/render/html.h
@@ -70,6 +70,9 @@ struct content_html_data {
pool box_pool; /**< Memory pool for box tree. */
pool string_pool; /**< Memory pool for strings. */
+
+ /**< Browser window containing this document, or 0 if not open. */
+ struct browser_window *bw;
};
@@ -83,17 +86,10 @@ void html_fetch_object(struct content *c, char *url, struct box *box,
int available_width, int available_height,
bool background);
void html_stop(struct content *c);
-
-/* in riscos/htmlinstance.c */
-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_reshape_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,
+void html_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 html_close(struct content *c);
/* in riscos/htmlredraw.c */
bool html_redraw(struct content *c, int x, int y,
diff --git a/riscos/htmlinstance.c b/riscos/htmlinstance.c
deleted file mode 100644
index ca239ddc8..000000000
--- a/riscos/htmlinstance.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * This file is part of NetSurf, http://netsurf.sourceforge.net/
- * Licensed under the GNU General Public License,
- * http://www.opensource.org/licenses/gpl-license
- * Copyright 2003 James Bursa <bursa@users.sourceforge.net>
- */
-
-#include "netsurf/utils/config.h"
-#include "netsurf/content/content.h"
-#include "netsurf/desktop/browser.h"
-#include "netsurf/render/box.h"
-#include "netsurf/render/html.h"
-#include "netsurf/utils/log.h"
-
-void html_add_instance(struct content *c, struct browser_window *bw,
- struct content *page, struct box *box,
- struct object_params *params, void **state)
-{
- unsigned int i;
- for (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_reshape_instance(struct content *c, struct browser_window *bw,
- struct content *page, struct box *box,
- struct object_params *params, void **state)
-{
- unsigned int i;
- for (i = 0; i != c->data.html.object_count; i++) {
- if (c->data.html.object[i].content == 0)
- continue;
- content_reshape_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)
-{
- unsigned int i;
- for (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);
- }
-}
diff --git a/riscos/plugin.c b/riscos/plugin.c
index 4212e9541..61e907409 100644
--- a/riscos/plugin.c
+++ b/riscos/plugin.c
@@ -77,9 +77,9 @@ struct plugin_list *plugin_get_instance_from_list(plugin_b browser,
plugin_p plugin);
/* message handling */
-void plugin_open(wimp_message *message);
+void plugin_open_msg(wimp_message *message);
void plugin_opening(wimp_message *message);
-void plugin_close(wimp_message *message);
+void plugin_close_msg(wimp_message *message);
void plugin_closed(wimp_message *message);
void plugin_reshape_request(wimp_message *message);
void plugin_stream_new(wimp_message *message);
@@ -311,6 +311,18 @@ void plugin_add_instance(struct content *c, struct browser_window *bw,
}
+
+/**
+ * Handle a window containing a CONTENT_PLUGIN being opened.
+ */
+
+void plugin_open(struct content *c, struct browser_window *bw,
+ struct content *page, struct box *box,
+ struct object_params *params)
+{
+}
+
+
/**
* Process plugin_opening message flags
* NB: this is NOT externally visible.
@@ -390,6 +402,16 @@ void plugin_remove_instance(struct content *c, struct browser_window *bw,
plugin_remove_instance_from_list(params);
}
+
+/**
+ * Handle a window containing a CONTENT_PLUGIN being closed.
+ */
+
+void plugin_close(struct content *c)
+{
+}
+
+
/**
* The box containing the plugin has moved or resized,
* or the window containing the plugin has resized if standalone.
@@ -1114,11 +1136,11 @@ void plugin_msg_parse(wimp_message *message, int ack)
*/
case message_PLUG_IN_OPEN:
if(ack)
- plugin_open(message);
+ plugin_open_msg(message);
break;
case message_PLUG_IN_CLOSE:
if(ack)
- plugin_close(message);
+ plugin_close_msg(message);
break;
case message_PLUG_IN_RESHAPE:
case message_PLUG_IN_STREAM_AS_FILE:
@@ -1133,7 +1155,7 @@ void plugin_msg_parse(wimp_message *message, int ack)
/**
* Handles receipt of plugin_open messages
*/
-void plugin_open(wimp_message *message) {
+void plugin_open_msg(wimp_message *message) {
struct plugin_message *npm = plugin_get_message_from_linked_list(message->my_ref);
@@ -1167,7 +1189,7 @@ void plugin_opening(wimp_message *message) {
/**
* Handles receipt of plugin_close messages
*/
-void plugin_close(wimp_message *message) {
+void plugin_close_msg(wimp_message *message) {
struct plugin_message *npm = plugin_get_message_from_linked_list(message->my_ref);
diff --git a/riscos/plugin.h b/riscos/plugin.h
index dc032f566..72ff798f5 100644
--- a/riscos/plugin.h
+++ b/riscos/plugin.h
@@ -79,15 +79,10 @@ bool plugin_redraw(struct content *c, int x, int y,
int width, int height,
int clip_x0, int clip_y0, int clip_x1, int clip_y1,
float scale);
-void plugin_add_instance(struct content *c, struct browser_window *bw,
+void plugin_open(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);
+ struct object_params *params);
+void plugin_close(struct content *c);
#endif