summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--makefile5
-rw-r--r--render/html.c50
-rw-r--r--render/html.h4
-rw-r--r--riscos/frames.c305
-rw-r--r--riscos/frames.h75
-rw-r--r--riscos/htmlinstance.c64
-rw-r--r--riscos/htmlredraw.c2
7 files changed, 452 insertions, 53 deletions
diff --git a/makefile b/makefile
index 22d05f4e4..e0b7569f2 100644
--- a/makefile
+++ b/makefile
@@ -12,8 +12,9 @@ OBJECTS_COMMON = cache.o content.o fetch.o fetchcache.o other.o \
messages.o utils.o
OBJECTS = $(OBJECTS_COMMON) \
browser.o loginlist.o netsurf.o \
- htmlredraw.o \
- 401login.o dialog.o download.o gui.o menus.o mouseactions.o \
+ htmlinstance.o htmlredraw.o \
+ 401login.o dialog.o download.o frames.o gui.o \
+ menus.o mouseactions.o \
options.o textselection.o theme.o window.o \
draw.o gif.o jpeg.o plugin.o png.o sprite.o \
about.o filetype.o font.o uri.o
diff --git a/render/html.c b/render/html.c
index 7751e652e..e3953597e 100644
--- a/render/html.c
+++ b/render/html.c
@@ -508,56 +508,6 @@ 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)
-{
- 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);
- }
-}
-
-
void html_revive(struct content *c, unsigned int width, unsigned int height)
{
unsigned int i;
diff --git a/render/html.h b/render/html.h
index b4d72f417..db41f7f11 100644
--- a/render/html.h
+++ b/render/html.h
@@ -57,6 +57,8 @@ 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);
+
+/* 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);
@@ -66,6 +68,8 @@ void html_reshape_instance(struct content *c, struct browser_window *bw,
void html_remove_instance(struct content *c, struct browser_window *bw,
struct content *page, struct box *box,
struct object_params *params, void **state);
+
+/* in riscos/htmlredraw.c */
void html_redraw(struct content *c, long x, long y,
unsigned long width, unsigned long height,
long clip_x0, long clip_y0, long clip_x1, long clip_y1);
diff --git a/riscos/frames.c b/riscos/frames.c
new file mode 100644
index 000000000..32e35ad6e
--- /dev/null
+++ b/riscos/frames.c
@@ -0,0 +1,305 @@
+/*
+ * 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 John M Bell <jmb202@ecs.soton.ac.uk>
+ */
+
+#include <stdbool.h>
+
+#include "netsurf/riscos/frames.h"
+#ifndef TEST
+# define NDEBUG
+#endif
+#include "netsurf/utils/log.h"
+#include "netsurf/utils/utils.h"
+
+#ifdef TEST
+# include <stdio.h>
+#endif
+
+static struct frame_list fl = {0, 0, &fl, &fl};
+static struct frame_list *flist = &fl;
+
+/* -------------------------------------------------------------------- *
+ * List handling stuff *
+ * -------------------------------------------------------------------- */
+
+/**
+ * Adds a new frameset associated with a browser window to the list
+ */
+void frameset_add_to_list(struct browser_window *bw, struct frame *frame) {
+
+ struct frame_list *nfl = xcalloc(1, sizeof(*nfl));
+
+ LOG(("adding %p to list", frame));
+ nfl->frame = frame;
+ nfl->bw = bw;
+ nfl->prev = flist->prev;
+ nfl->next = flist;
+ flist->prev->next = nfl;
+ flist->prev = nfl;
+}
+
+/**
+ * Removes a frameset associated with a browser window to the list
+ */
+void frameset_remove_from_list(struct browser_window *bw) {
+
+ struct frame_list *temp = frameset_get_from_list(bw);
+ if(temp != NULL) {
+ delete_tree(temp->frame);
+ temp->prev->next = temp->next;
+ temp->next->prev = temp->prev;
+ xfree(temp);
+ }
+}
+
+/**
+ * Retrieves a frameset from the list
+ * Returns a frame_list struct pointer or NULL is nothing is found
+ */
+struct frame_list *frameset_get_from_list(struct browser_window *bw) {
+
+ struct frame_list *nfl;
+
+ for(nfl = flist->next; (nfl != flist) && (nfl->bw != bw);
+ nfl = nfl->next)
+ ;
+
+ if(nfl != flist)
+ return nfl;
+
+ return NULL;
+}
+
+/**
+ * Retrieves a frame from the list/tree structure.
+ * Returns a frame struct pointer or NULL if nothing is found
+ */
+struct frame *frame_get_from_list(struct browser_window *bw, struct box *b,
+ bool strict) {
+
+ struct frame_list *nfl;
+ struct frame *f=0;
+
+ for(nfl = flist->next; (nfl != flist); nfl = nfl->next) {
+ LOG(("checking tree %p",nfl->frame));
+ if ((f = get_frame_from_tree(nfl->frame, bw, b, strict))) {
+ LOG(("returning f: %p", f));
+ return f;
+ }
+ }
+
+ return NULL;
+}
+
+/* -------------------------------------------------------------------- *
+ * Tree handling stuff *
+ * -------------------------------------------------------------------- */
+
+/**
+ * Adds a new frame to the tree
+ * Creates a new tree if appropriate.
+ */
+void add_frame_to_tree (struct browser_window *parent_bw, struct box *box,
+ struct browser_window *bw, struct content *c,
+ char *name) {
+
+ struct frame *nrf;
+ struct frame *parent;
+ struct frame *nf = xcalloc(1, sizeof(*nf));
+ unsigned int i;
+
+ /* get parent node */
+ if ((parent = frame_get_from_list(parent_bw, box, false)) == NULL) {
+
+ LOG(("no tree found - creating new"));
+ nrf = xcalloc(1, sizeof(*nrf));
+ nrf->win = parent_bw;
+ nrf->box = (struct box*)-1;
+ nrf->c = 0;
+ nrf->name = xstrdup("_top");
+ nrf->parent = 0;
+ nrf->no_children = 0;
+ nrf->children = xcalloc(0,1);
+ frameset_add_to_list(parent_bw, nrf);
+ parent = frame_get_from_list(parent_bw, (struct box*)-1, true);
+ }
+
+ LOG(("got parent"));
+ nf->win = bw;
+ nf->box = box;
+ nf->c = c;
+ nf->name = xstrdup(name);
+ nf->parent = parent;
+ nf->no_children = 0;
+
+ LOG(("adding frame to tree"));
+ i = parent->no_children;
+ parent->children =
+ xrealloc(parent->children, (i+1) * sizeof(struct frame));
+ parent->children[i] = nf;
+ parent->no_children++;
+}
+
+/**
+ * Retrieves a frame from the tree.
+ * If 'strict' is true, tests for both bw and box. Otherwise, just tests bw.
+ * Returns the frame or NULL.
+ */
+struct frame *get_frame_from_tree(struct frame *root,
+ struct browser_window *bw,
+ struct box *b,
+ bool strict) {
+
+ int i;
+
+ if (!root) {
+ LOG(("tree was empty"));
+ return NULL; /* empty tree */
+ }
+
+ if (strict) {
+ if (root->parent != 0) { /* has a parent node => check that */
+ LOG(("(%p, %p),(%p, %p)", root->parent->win, bw, root->box, b));
+ if (root->parent->win == bw && root->box == b) { /* found frame */
+ LOG(("found frame %p", root));
+ return root;
+ }
+ }
+ else { /* no parent node => check this one */
+ LOG(("(%p, %p),(%p, %p)", root->win, bw, root->box, b));
+ if (root->win == bw && root->box == b) { /* found frame */
+ LOG(("found frame %p", root));
+ return root;
+ }
+ }
+ }
+ else {
+ if (root->parent != 0) { /* has a parent node => check that */
+ LOG(("(%p, %p),(%p, %p)", root->parent->win, bw, root->box, b));
+ if (root->parent->win == bw) { /* found frame */
+ LOG(("found frame %p", root));
+ return root;
+ }
+ else if (root->win == bw) {
+ LOG(("adding as child of '%s'", root->name));
+ return root;
+ }
+ }
+ else { /* no parent node => check this one */
+ LOG(("(%p, %p),(%p, %p)", root->win, bw, root->box, b));
+ if (root->win == bw) { /* found frame */
+ LOG(("found frame %p", root));
+ return root;
+ }
+ }
+ }
+
+ if (root->no_children == 0)
+ return NULL;
+
+ for (i=0; i!=root->no_children; i++) { /* not found so recurse */
+ return get_frame_from_tree(root->children[i], bw, b, strict);
+ }
+
+ return NULL;
+}
+
+/**
+ * Deletes a complete tree.
+ */
+void delete_tree(struct frame *root) {
+
+ int i;
+
+ if (!root) return; /* empty tree */
+
+ if (root->no_children == 0) { /* leaf node => delete and return */
+ LOG(("deleting '%s'", root->name));
+ xfree(root->name);
+ xfree(root);
+ return;
+ }
+
+ for (i=0; i!=root->no_children; i++) { /* non-leaf node
+ => kill children */
+ delete_tree(root->children[i]);
+ }
+
+ /* all children killed => remove this node */
+ LOG(("deleting '%s'", root->name));
+ xfree(root->name);
+ xfree(root);
+}
+
+
+
+#ifdef TEST
+void traverse_tree(struct frame *root, int depth) {
+
+ int i;
+
+ if (!root) return; /* empty tree */
+
+ if (root->no_children == 0) {
+ for (i=0; i!=(depth+1); i++)
+ printf("\t");
+ printf("frame: %p (%s)\n", root, root->name);
+ return;
+ }
+ else {
+ for(i=0; i!=(depth+1); i++)
+ printf("\t");
+ printf("frame: %p (%s)\n", root, root->name);
+ }
+
+ for (i=0; i!=root->no_children; i++) { /* not found so recurse */
+ traverse_tree(root->children[i], (depth+1));
+ }
+
+ return;
+}
+
+void dump_all_frame_moose(void) {
+
+ struct frame_list *nfl;
+
+ for (nfl=flist->next; nfl!=flist; nfl=nfl->next) {
+ printf("bw: %p\n", nfl->bw);
+ traverse_tree(nfl->frame, 0);
+ printf("\n");
+ }
+}
+
+int main (void) {
+
+ struct frame *f;
+
+ add_frame_to_tree(1, 1, 1, 3, "test");
+ add_frame_to_tree(0, 2, 2, 5, "moo");
+ add_frame_to_tree(0, 3, 3, 1, "moose");
+ add_frame_to_tree(2, 4, 4, 2, "elk");
+
+ dump_all_frame_moose();
+
+ f = frame_get_from_list(1, 1, true);
+ if (f)
+ printf("%s: %d, %d\n", f->name, f->win, f->c);
+ else
+ printf("couldn't find 1,1\n");
+
+ frameset_remove_from_list(1);
+
+ f = frame_get_from_list(2, 4, true);
+ if (f)
+ printf("%s: %d, %d\n", f->name, f->win, f->c);
+ else
+ printf("couldn't find 2,4\n");
+
+ dump_all_frame_moose();
+
+ return 0;
+}
+#endif
diff --git a/riscos/frames.h b/riscos/frames.h
new file mode 100644
index 000000000..b83cf8e1a
--- /dev/null
+++ b/riscos/frames.h
@@ -0,0 +1,75 @@
+/*
+ * 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 John M Bell <jmb202@ecs.soton.ac.uk>
+ */
+
+/*
+ * Frames are represented as a tree structure. eg:
+ *
+ * index.html
+ * |
+ * --------------------
+ * | |
+ * nav.html main.html
+ * |
+ * --------------------
+ * | | |
+ * top.html mid.html end.html
+ *
+ * might represent something like:
+ *
+ * ------------------------
+ * | nav.html | top.html |
+ * | |------------|
+ * | | mid.html |
+ * | |------------|
+ * | | end.html |
+ * -------------------------
+ *
+ * where the left frame is main.html with three sub frames (top, mid, end)
+ * and the entire page is index.html with two sub frames (nav, main)
+ */
+
+#ifndef _NETSURF_RISCOS_FRAMES_H_
+#define _NETSURF_RISCOS_FRAMES_H_
+
+#include "netsurf/content/content.h"
+#include "netsurf/desktop/browser.h"
+#include "netsurf/render/box.h"
+#include "netsurf/riscos/gui.h"
+
+struct frame_list {
+
+ struct frame *frame; /**< top most frame (ie root of tree) */
+ struct browser_window *bw; /**< main window */
+ struct frame_list *next; /**< next in list */
+ struct frame_list *prev; /**< previous in list */
+};
+
+struct frame {
+
+ struct browser_window *win; /**< window in which this frame appears */
+ struct box *box; /**< box in parent window containing this frame */
+ struct content *c; /**< content of this frame */
+ char *name; /**< name of this frame */
+ struct frame *parent; /**< parent frame */
+ unsigned int no_children; /**< number of children this frame has */
+ struct frame **children; /**< child frames */
+};
+
+void frameset_add_to_list(struct browser_window *bw, struct frame *frame);
+void frameset_remove_from_list(struct browser_window *bw);
+struct frame_list *frameset_get_from_list(struct browser_window *bw);
+struct frame *frame_get_from_list(struct browser_window *bw, struct box *b,
+ bool strict);
+
+void add_frame_to_tree (struct browser_window *pbw, struct box *box,
+ struct browser_window *bw, struct content *c,
+ char *name);
+struct frame *get_frame_from_tree(struct frame *root,
+ struct browser_window *bw,
+ struct box *b, bool strict);
+void delete_tree(struct frame *root);
+#endif
diff --git a/riscos/htmlinstance.c b/riscos/htmlinstance.c
new file mode 100644
index 000000000..78f6bdd57
--- /dev/null
+++ b/riscos/htmlinstance.c
@@ -0,0 +1,64 @@
+/*
+ * 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/content/content.h"
+#include "netsurf/desktop/browser.h"
+#include "netsurf/render/box.h"
+#include "netsurf/render/html.h"
+#include "netsurf/riscos/frames.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;
+ if (c->data.html.object[i].content->type == CONTENT_HTML)
+ LOG(("html object"));
+ 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);
+ }
+} \ No newline at end of file
diff --git a/riscos/htmlredraw.c b/riscos/htmlredraw.c
index b76a06105..60f95efe0 100644
--- a/riscos/htmlredraw.c
+++ b/riscos/htmlredraw.c
@@ -130,7 +130,7 @@ void html_redraw_box(struct content *content, struct box * box,
current_background_color = box->style->background_color;
}
- if (box->object) {
+ if (box->object /*&& box->object->type != CONTENT_HTML*/) {
content_redraw(box->object, x, y, width, height, x0, y0, x1, y1);
} else if (box->gadget &&