From 53c0e810e5c34cb89c73c6b79b31dfa53b14f90f Mon Sep 17 00:00:00 2001 From: James Bursa Date: Tue, 8 Oct 2002 09:38:29 +0000 Subject: [project @ 2002-10-08 09:38:29 by bursa] LOG(()) macro for easier debugging. svn path=/import/netsurf/; revision=41 --- desktop/netsurf.c | 3 ++- makefile | 4 ++-- render/box.c | 19 ++++++++++++++++++- render/layout.c | 4 ++-- utils/log.h | 24 ++++++++++++++++++++++++ 5 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 utils/log.h diff --git a/desktop/netsurf.c b/desktop/netsurf.c index cc53acc05..47f9c7ed6 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -1,5 +1,5 @@ /** - * $Id: netsurf.c,v 1.1 2002/09/11 14:24:02 monkeyson Exp $ + * $Id: netsurf.c,v 1.2 2002/10/08 09:38:29 bursa Exp $ */ #include "netsurf/desktop/netsurf.h" @@ -22,6 +22,7 @@ void netsurf_poll(void) void netsurf_init(int argc, char** argv) { + stdout = stderr; gui_init(argc, argv); } diff --git a/makefile b/makefile index ae97dd22d..55fc8dbcb 100644 --- a/makefile +++ b/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.3 2002/09/11 21:19:24 bursa Exp $ +# $Id: makefile,v 1.4 2002/10/08 09:38:29 bursa Exp $ all: netsurf,ff8 clean: @@ -9,7 +9,7 @@ FLAGS = -g -Wall -W -Wundef -Wpointer-arith -Wbad-function-cast -Wcast-qual \ -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -std=c9x \ -I.. -I../../Tools/libxml2/include -I../../Tools/oslib \ -I../../Tools/curl/include -I../../Tools/libutf-8 \ - -Dfd_set=long -mpoke-function-name + -Dfd_set=long -mpoke-function-name -DNETSURF_DUMP CC = riscos-gcc OBJECTS = render/objs-riscos/utils.o render/objs-riscos/css.o \ render/objs-riscos/css_enum.o render/objs-riscos/box.o \ diff --git a/render/box.c b/render/box.c index 7ee7e712b..5a8269d95 100644 --- a/render/box.c +++ b/render/box.c @@ -1,5 +1,5 @@ /** - * $Id: box.c,v 1.17 2002/09/26 21:38:32 bursa Exp $ + * $Id: box.c,v 1.18 2002/10/08 09:38:29 bursa Exp $ */ #include @@ -13,6 +13,7 @@ #include "netsurf/riscos/font.h" #include "netsurf/render/box.h" #include "netsurf/render/utils.h" +#include "netsurf/utils/log.h" /** * internal functions @@ -123,8 +124,10 @@ void xml_to_box(xmlNode * n, struct css_style * parent_style, struct box * parent, struct box * inline_container, const char *href, struct font_set *fonts) { + LOG(("node %p", n)); convert_xml_to_box(n, parent_style, stylesheet, selector, depth, parent, inline_container, href, fonts); + LOG(("normalising")); box_normalise_block(parent->children); } @@ -141,6 +144,9 @@ struct box * convert_xml_to_box(xmlNode * n, struct css_style * parent_style, xmlNode * c; char * s; + assert(n != 0 && parent_style != 0 && stylesheet != 0 && selector != 0 && + parent != 0 && fonts != 0); + LOG(("depth %i, node %p, node type %i", depth, n, n->type)); gui_multitask(); if (n->type == XML_ELEMENT_NODE) { @@ -153,6 +159,7 @@ struct box * convert_xml_to_box(xmlNode * n, struct css_style * parent_style, free(s); } style = box_get_style(stylesheet, parent_style, n, *selector, depth + 1); + LOG(("display: %s", css_display_name[style->display])); if (style->display == CSS_DISPLAY_NONE) return inline_container; @@ -174,12 +181,16 @@ struct box * convert_xml_to_box(xmlNode * n, struct css_style * parent_style, box_add_child(parent, inline_container); } if (n->type == XML_TEXT_NODE) { + LOG(("text node")); box = box_create(n, BOX_INLINE, parent_style, href); box->text = squash_whitespace(n->content); box->length = strlen(box->text); + LOG(("text node 2")); box->font = font_open(fonts, box->style); box_add_child(inline_container, box); + LOG(("text node 3")); } else { + LOG(("float")); box = box_create(0, BOX_FLOAT_LEFT, 0, href); if (style->float_ == CSS_FLOAT_RIGHT) box->type = BOX_FLOAT_RIGHT; box_add_child(inline_container, box); @@ -258,6 +269,7 @@ struct box * convert_xml_to_box(xmlNode * n, struct css_style * parent_style, } } + LOG(("depth %i, node %p, node type %i END", depth, n, n->type)); return inline_container; } @@ -373,6 +385,7 @@ void box_normalise_block(struct box *block) struct box *table; struct css_style *style; + LOG(("block %p", block)); assert(block->type == BOX_BLOCK || block->type == BOX_TABLE_CELL); for (child = block->children; child != 0; prev_child = child, child = child->next) { @@ -434,6 +447,7 @@ void box_normalise_table(struct box *table) struct box *row_group; struct css_style *style; + LOG(("table %p", table)); assert(table->type == BOX_TABLE); for (child = table->children; child != 0; prev_child = child, child = child->next) { @@ -495,6 +509,7 @@ void box_normalise_table_row_group(struct box *row_group) struct box *row; struct css_style *style; + LOG(("row_group %p", row_group)); assert(row_group->type == BOX_TABLE_ROW_GROUP); for (child = row_group->children; child != 0; prev_child = child, child = child->next) { @@ -555,6 +570,7 @@ void box_normalise_table_row(struct box *row) struct css_style *style; unsigned int columns = 0; + LOG(("row %p", row)); assert(row->type == BOX_TABLE_ROW); for (child = row->children; child != 0; prev_child = child, child = child->next) { @@ -616,6 +632,7 @@ void box_normalise_inline_container(struct box *cont) struct box *child; struct box *prev_child = 0; + LOG(("cont %p")); assert(cont->type == BOX_INLINE_CONTAINER); for (child = cont->children; child != 0; prev_child = child, child = child->next) { diff --git a/render/layout.c b/render/layout.c index 44baa4cef..f9e29bb90 100644 --- a/render/layout.c +++ b/render/layout.c @@ -1,5 +1,5 @@ /** - * $Id: layout.c,v 1.19 2002/09/26 21:38:33 bursa Exp $ + * $Id: layout.c,v 1.20 2002/10/08 09:38:29 bursa Exp $ */ #include @@ -14,7 +14,7 @@ #include "netsurf/render/utils.h" #include "netsurf/render/layout.h" -/* #define DEBUG_LAYOUT */ +#define DEBUG_LAYOUT /** * internal functions diff --git a/utils/log.h b/utils/log.h new file mode 100644 index 000000000..4ca658419 --- /dev/null +++ b/utils/log.h @@ -0,0 +1,24 @@ +/** + * $Id: log.h,v 1.1 2002/10/08 09:38:29 bursa Exp $ + */ + +#include + +#ifndef _NETSURF_LOG_H_ +#define _NETSURF_LOG_H_ + +#ifdef NDEBUG + +#define LOG(x) ((void) 0) + +#else + +#ifdef __GNUC__ +#define LOG(x) (printf(__FILE__ " " __PRETTY_FUNCTION__ " %i: ", __LINE__), printf x, printf("\n")) +#else +#define LOG(x) (printf(__FILE__ " %i: ", __LINE__), printf x, printf("\n")) +#endif + +#endif + +#endif -- cgit v1.2.3