diff options
-rw-r--r-- | debug/netsurfd.c | 6 | ||||
-rw-r--r-- | render/box.c | 93 | ||||
-rw-r--r-- | render/box.h | 3 | ||||
-rw-r--r-- | render/box_construct.c | 2 | ||||
-rw-r--r-- | render/layout.c | 6 | ||||
-rw-r--r-- | riscos/gui.c | 47 | ||||
-rw-r--r-- | riscos/gui.h | 1 | ||||
-rw-r--r-- | riscos/window.c | 11 |
8 files changed, 104 insertions, 65 deletions
diff --git a/debug/netsurfd.c b/debug/netsurfd.c index 8cda2fd00..b6c289cb7 100644 --- a/debug/netsurfd.c +++ b/debug/netsurfd.c @@ -97,8 +97,10 @@ int main(int argc, char *argv[]) fetchcache_go(c, 0, callback, 0, 0, 1000, 1000, 0, 0, true, 0); done = c->status == CONTENT_STATUS_DONE; - while (!done) + while (!done) { fetch_poll(); + sleep(1); + } puts("=== SUCCESS, dumping cache"); } else { destroyed = 1; @@ -110,7 +112,7 @@ int main(int argc, char *argv[]) /* content_reformat(c, 1, 1000); */ /* save_complete(c, "save_complete");*/ if (c->type == CONTENT_HTML) - box_dump(c->data.html.layout, 0); + box_dump(stderr, c->data.html.layout, 0); else if (c->type == CONTENT_CSS) css_dump_stylesheet(c->data.css.css); else if (c->type == CONTENT_GIF) diff --git a/render/box.c b/render/box.c index ee3be9bd3..a643127ea 100644 --- a/render/box.c +++ b/render/box.c @@ -1,5 +1,5 @@ /* - * Copyright 2005 James Bursa <bursa@users.sourceforge.net> + * Copyright 2005-2007 James Bursa <bursa@users.sourceforge.net> * Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net> * Copyright 2005 John M Bell <jmb202@ecs.soton.ac.uk> * @@ -24,6 +24,7 @@ #include <assert.h> #include <stdbool.h> +#include <stdio.h> #include <string.h> #include "content/content.h" #include "css/css.h" @@ -498,110 +499,110 @@ bool box_visible(struct box *box) /** - * Print a box tree to stderr. + * Print a box tree to a file. */ -void box_dump(struct box *box, unsigned int depth) +void box_dump(FILE *stream, struct box *box, unsigned int depth) { unsigned int i; struct box *c, *prev; for (i = 0; i != depth; i++) - fprintf(stderr, " "); + fprintf(stream, " "); - fprintf(stderr, "%p ", box); - fprintf(stderr, "x%i y%i w%i h%i ", box->x, box->y, + fprintf(stream, "%p ", box); + fprintf(stream, "x%i y%i w%i h%i ", box->x, box->y, box->width, box->height); if (box->max_width != UNKNOWN_MAX_WIDTH) - fprintf(stderr, "min%i max%i ", box->min_width, box->max_width); - fprintf(stderr, "(%i %i %i %i) ", + fprintf(stream, "min%i max%i ", box->min_width, box->max_width); + fprintf(stream, "(%i %i %i %i) ", box->descendant_x0, box->descendant_y0, box->descendant_x1, box->descendant_y1); switch (box->type) { - case BOX_BLOCK: fprintf(stderr, "BLOCK "); break; - case BOX_INLINE_CONTAINER: fprintf(stderr, "INLINE_CONTAINER "); break; - case BOX_INLINE: fprintf(stderr, "INLINE "); break; - case BOX_INLINE_END: fprintf(stderr, "INLINE_END "); break; - case BOX_INLINE_BLOCK: fprintf(stderr, "INLINE_BLOCK "); break; - case BOX_TABLE: fprintf(stderr, "TABLE [columns %i] ", + case BOX_BLOCK: fprintf(stream, "BLOCK "); break; + case BOX_INLINE_CONTAINER: fprintf(stream, "INLINE_CONTAINER "); break; + case BOX_INLINE: fprintf(stream, "INLINE "); break; + case BOX_INLINE_END: fprintf(stream, "INLINE_END "); break; + case BOX_INLINE_BLOCK: fprintf(stream, "INLINE_BLOCK "); break; + case BOX_TABLE: fprintf(stream, "TABLE [columns %i] ", box->columns); break; - case BOX_TABLE_ROW: fprintf(stderr, "TABLE_ROW "); break; - case BOX_TABLE_CELL: fprintf(stderr, "TABLE_CELL [columns %i, " + case BOX_TABLE_ROW: fprintf(stream, "TABLE_ROW "); break; + case BOX_TABLE_CELL: fprintf(stream, "TABLE_CELL [columns %i, " "start %i, rows %i] ", box->columns, box->start_column, box->rows); break; - case BOX_TABLE_ROW_GROUP: fprintf(stderr, "TABLE_ROW_GROUP "); break; - case BOX_FLOAT_LEFT: fprintf(stderr, "FLOAT_LEFT "); break; - case BOX_FLOAT_RIGHT: fprintf(stderr, "FLOAT_RIGHT "); break; - case BOX_BR: fprintf(stderr, "BR "); break; - case BOX_TEXT: fprintf(stderr, "TEXT "); break; - default: fprintf(stderr, "Unknown box type "); + case BOX_TABLE_ROW_GROUP: fprintf(stream, "TABLE_ROW_GROUP "); break; + case BOX_FLOAT_LEFT: fprintf(stream, "FLOAT_LEFT "); break; + case BOX_FLOAT_RIGHT: fprintf(stream, "FLOAT_RIGHT "); break; + case BOX_BR: fprintf(stream, "BR "); break; + case BOX_TEXT: fprintf(stream, "TEXT "); break; + default: fprintf(stream, "Unknown box type "); } if (box->text) - fprintf(stderr, "%li '%.*s' ", (unsigned long) box->byte_offset, + fprintf(stream, "%li '%.*s' ", (unsigned long) box->byte_offset, (int) box->length, box->text); if (box->space) - fprintf(stderr, "space "); + fprintf(stream, "space "); if (box->object) - fprintf(stderr, "(object '%s') ", box->object->url); + fprintf(stream, "(object '%s') ", box->object->url); if (box->style) css_dump_style(box->style); if (box->href) - fprintf(stderr, " -> '%s'", box->href); + fprintf(stream, " -> '%s'", box->href); if (box->target) - fprintf(stderr, " |%s|", box->target); + fprintf(stream, " |%s|", box->target); if (box->title) - fprintf(stderr, " [%s]", box->title); + fprintf(stream, " [%s]", box->title); if (box->id) - fprintf(stderr, " <%s>", box->id); + fprintf(stream, " <%s>", box->id); if (box->type == BOX_INLINE || box->type == BOX_INLINE_END) - fprintf(stderr, " inline_end %p", box->inline_end); + fprintf(stream, " inline_end %p", box->inline_end); if (box->float_children) - fprintf(stderr, " float_children %p", box->float_children); + fprintf(stream, " float_children %p", box->float_children); if (box->next_float) - fprintf(stderr, " next_float %p", box->next_float); + fprintf(stream, " next_float %p", box->next_float); if (box->col) { - fprintf(stderr, " (columns"); + fprintf(stream, " (columns"); for (i = 0; i != box->columns; i++) - fprintf(stderr, " (%s %i %i %i)", + fprintf(stream, " (%s %i %i %i)", ((const char *[]) {"UNKNOWN", "FIXED", "AUTO", "PERCENT", "RELATIVE"}) [box->col[i].type], box->col[i].width, box->col[i].min, box->col[i].max); - fprintf(stderr, ")"); + fprintf(stream, ")"); } - fprintf(stderr, "\n"); + fprintf(stream, "\n"); if (box->list_marker) { for (i = 0; i != depth; i++) - fprintf(stderr, " "); - fprintf(stderr, "list_marker:\n"); - box_dump(box->list_marker, depth + 1); + fprintf(stream, " "); + fprintf(stream, "list_marker:\n"); + box_dump(stream, box->list_marker, depth + 1); } for (c = box->children; c && c->next; c = c->next) ; if (box->last != c) - fprintf(stderr, "warning: box->last %p (should be %p) " + fprintf(stream, "warning: box->last %p (should be %p) " "(box %p)\n", box->last, c, box); for (prev = 0, c = box->children; c; prev = c, c = c->next) { if (c->parent != box) - fprintf(stderr, "warning: box->parent %p (should be " + fprintf(stream, "warning: box->parent %p (should be " "%p) (box on next line)\n", c->parent, box); if (c->prev != prev) - fprintf(stderr, "warning: box->prev %p (should be " + fprintf(stream, "warning: box->prev %p (should be " "%p) (box on next line)\n", c->prev, prev); - box_dump(c, depth + 1); + box_dump(stream, c, depth + 1); } if (box->fallback) { for (i = 0; i != depth; i++) - fprintf(stderr, " "); - fprintf(stderr, "fallback:\n"); + fprintf(stream, " "); + fprintf(stream, "fallback:\n"); for (c = box->fallback; c; c = c->next) - box_dump(c, depth + 1); + box_dump(stream, c, depth + 1); } } diff --git a/render/box.h b/render/box.h index 7adcf5988..22a40d13d 100644 --- a/render/box.h +++ b/render/box.h @@ -88,6 +88,7 @@ #include <limits.h> #include <stdbool.h> +#include <stdio.h> #include <libxml/HTMLparser.h> @@ -288,7 +289,7 @@ struct box *box_at_point(struct box *box, int x, int y, struct box *box_object_at_point(struct content *c, int x, int y); struct box *box_find_by_id(struct box *box, const char *id); bool box_visible(struct box *box); -void box_dump(struct box *box, unsigned int depth); +void box_dump(FILE *stream, struct box *box, unsigned int depth); bool box_extract_link(const char *rel, const char *base, char **result); bool box_vscrollbar_present(const struct box *box); diff --git a/render/box_construct.c b/render/box_construct.c index bdde7a76c..ed54cc96d 100644 --- a/render/box_construct.c +++ b/render/box_construct.c @@ -628,7 +628,7 @@ bool box_construct_text(xmlNode *n, struct content *content, while (parent->parent && parent->parent->parent) parent = parent->parent; - box_dump(parent, 0); + box_dump(stderr, parent, 0); } assert((*inline_container)->last != 0); (*inline_container)->last->space = 1; diff --git a/render/layout.c b/render/layout.c index 95b734433..7b2ac7809 100644 --- a/render/layout.c +++ b/render/layout.c @@ -477,7 +477,7 @@ void layout_minmax_block(struct box *block) } if (max < min) { - box_dump(block, 0); + box_dump(stderr, block, 0); assert(0); } @@ -1338,7 +1338,7 @@ bool layout_line(struct box *first, int *width, int *y, } if (cont->float_children == b) { LOG(("float %p already placed", b)); - box_dump(cont, 0); + box_dump(stderr, cont, 0); assert(0); } b->next_float = cont->float_children; @@ -2349,7 +2349,7 @@ void layout_minmax_table(struct box *table) for (i = 0; i != table->columns; i++) { if (col[i].max < col[i].min) { - box_dump(table, 0); + box_dump(stderr, table, 0); assert(0); } table_min += col[i].min; diff --git a/riscos/gui.c b/riscos/gui.c index 1289cc6b7..f1b5d3d7e 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -847,7 +847,7 @@ void ro_gui_signal(int sig) for (c = content_list; c; c = c->next) if (c->type == CONTENT_HTML && c->data.html.layout) { LOG(("Dumping: '%s'", c->url)); - box_dump(c->data.html.layout, 0); + box_dump(stderr, c->data.html.layout, 0); } options_dump(); /*rufl_dump_state();*/ @@ -2108,6 +2108,7 @@ void ro_gui_open_help_page(const char *page) browser_window_create(url, NULL, 0, true); } + /** * Send the source of a content to a text editor. */ @@ -2187,7 +2188,8 @@ void ro_gui_view_source(struct content *content) } -void ro_gui_view_source_bounce(wimp_message *message) { +void ro_gui_view_source_bounce(wimp_message *message) +{ char *filename; os_error *error; char command[256]; @@ -2205,6 +2207,47 @@ void ro_gui_view_source_bounce(wimp_message *message) { /** + * Send the debug dump of a content to a text editor. + */ + +void ro_gui_dump_content(struct content *content) +{ + os_error *error; + + /* open file for dump */ + FILE *stream = fopen("<Wimp$ScrapDir>.WWW.NetSurf.dump", "w"); + if (!stream) { + LOG(("fopen: errno %i", errno)); + warn_user("SaveError", strerror(errno)); + return; + } + + /* output debug information to file */ + switch (content->type) { + case CONTENT_HTML: + box_dump(stream, content->data.html.layout, 0); + break; + case CONTENT_CSS: + css_dump_stylesheet(content->data.css.css); + break; + default: + break; + } + + fclose(stream); + + /* launch file in editor */ + error = xwimp_start_task("Filer_Run <Wimp$ScrapDir>.WWW.NetSurf.dump", + 0); + if (error) { + LOG(("xwimp_start_task failed: 0x%x: %s", + error->errnum, error->errmess)); + warn_user("WimpError", error->errmess); + } +} + + +/** * Broadcast an URL that we can't handle. */ diff --git a/riscos/gui.h b/riscos/gui.h index f564b55e2..ee7ed896f 100644 --- a/riscos/gui.h +++ b/riscos/gui.h @@ -122,6 +122,7 @@ void ro_gui_open_window_request(wimp_open *open); void ro_gui_open_help_page(const char *page); void ro_gui_screen_size(int *width, int *height); void ro_gui_view_source(struct content *content); +void ro_gui_dump_content(struct content *content); void ro_gui_drag_box_start(wimp_pointer *pointer); bool ro_gui_prequit(void); const char *ro_gui_default_language(void); diff --git a/riscos/window.c b/riscos/window.c index b437e6362..b0dc828aa 100644 --- a/riscos/window.c +++ b/riscos/window.c @@ -2439,16 +2439,7 @@ bool ro_gui_window_keypress(wimp_key *key) case IS_WIMP_KEY + wimp_KEY_F9: /* Dump content for debugging. */ - switch (content->type) { - case CONTENT_HTML: - box_dump(content->data.html.layout, 0); - break; - case CONTENT_CSS: - css_dump_stylesheet(content->data.css.css); - break; - default: - break; - } + ro_gui_dump_content(content); return true; case IS_WIMP_KEY + wimp_KEY_CONTROL + wimp_KEY_F9: |