From af16c38d2dbe2decfc45015bd4ee020cb52c608b Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 4 Aug 2014 00:36:14 +0100 Subject: fix DOM tree dump debug --- render/html.c | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) (limited to 'render') diff --git a/render/html.c b/render/html.c index 9e576486f..12c173f0d 100644 --- a/render/html.c +++ b/render/html.c @@ -1971,17 +1971,43 @@ static bool html_drop_file_at_point(struct content *c, int x, int y, char *file) /** * Dump debug info concerning the html_content * - * \param bw The browser window - * \param bw The file to dump to + * \param bw The browser window + * \param f The file to dump to */ -static void html_debug_dump(struct content *c, FILE *f) +static nserror +html_debug_dump(struct content *c, FILE *f, enum content_debug op) { - html_content *html = (html_content *) c; + html_content *htmlc = (html_content *)c; + dom_node *html; + dom_exception exc; /* returned by libdom functions */ + nserror ret; + + assert(htmlc != NULL); - assert(html != NULL); - assert(html->layout != NULL); + if (op == CONTENT_DEBUG_RENDER) { + assert(htmlc->layout != NULL); + box_dump(f, htmlc->layout, 0, true); + ret = NSERROR_OK; + } else { + if (htmlc->document == NULL) { + LOG(("No document to dump")); + return NSERROR_DOM; + } + + exc = dom_document_get_document_element(htmlc->document, (void *) &html); + if ((exc != DOM_NO_ERR) || (html == NULL)) { + LOG(("Unable to obtain root node")); + return NSERROR_DOM; + } + + ret = libdom_dump_structure(html, f, 0); + + LOG(("DOM structure dump returning %d", ret)); + + dom_node_unref(html); + } - box_dump(f, html->layout, 0, true); + return ret; } -- cgit v1.2.3