From 5d371fb47e0b1b1e43574cf674893b890067b9b6 Mon Sep 17 00:00:00 2001 From: James Bursa Date: Tue, 25 Mar 2003 21:51:29 +0000 Subject: [PATCH] [project @ 2003-03-25 21:51:29 by bursa] Show alt text for images. svn path=/import/netsurf/; revision=109 --- render/box.c | 23 +++++++++++++++++------ render/html.c | 6 +++--- render/layout.c | 5 ++--- riscos/gui.c | 10 +++++----- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/render/box.c b/render/box.c index 96b0931d7..3fbbbb5aa 100644 --- a/render/box.c +++ b/render/box.c @@ -1,5 +1,5 @@ /** - * $Id: box.c,v 1.34 2003/03/04 11:59:35 bursa Exp $ + * $Id: box.c,v 1.35 2003/03/25 21:51:29 bursa Exp $ */ #include @@ -13,6 +13,7 @@ #include "netsurf/riscos/font.h" #include "netsurf/render/box.h" #include "netsurf/utils/utils.h" +#define NDEBUG #include "netsurf/utils/log.h" #include "netsurf/desktop/gui.h" @@ -206,8 +207,15 @@ struct box * convert_xml_to_box(xmlNode * n, struct css_style * parent_style, } else if (strcmp((const char *) n->name, "img") == 0) { LOG(("image")); - box = box_image(n, style, href); - add_img_element(elements, box->img); + /*box = box_image(n, style, href); + add_img_element(elements, box->img);*/ + if (style->display == CSS_DISPLAY_INLINE) { + if ((s = (char *) xmlGetProp(n, (const xmlChar *) "alt"))) { + text = squash_whitespace(tolat1(s)); + xfree(s); + } + } + /* TODO: block images, start fetch */ } else if (strcmp((const char *) n->name, "textarea") == 0) { char * content = xmlNodeGetContent(n); @@ -247,6 +255,9 @@ struct box * convert_xml_to_box(xmlNode * n, struct css_style * parent_style, } else if (n->type == XML_TEXT_NODE) { text = squash_whitespace(tolat1(n->content)); + } + + if (text != 0) { if (text[0] == ' ' && text[1] == 0) { if (inline_container != 0) { assert(inline_container->last != 0); @@ -257,7 +268,7 @@ struct box * convert_xml_to_box(xmlNode * n, struct css_style * parent_style, } } - if (n->type == XML_TEXT_NODE || + if (text != 0 || (box != 0 && style->display == CSS_DISPLAY_INLINE) || (n->type == XML_ELEMENT_NODE && (style->float_ == CSS_FLOAT_LEFT || style->float_ == CSS_FLOAT_RIGHT))) { @@ -269,7 +280,7 @@ 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) { + if (text != 0) { LOG(("text node")); box = box_create(n, BOX_INLINE, parent_style, href); box_add_child(inline_container, box); @@ -305,7 +316,7 @@ struct box * convert_xml_to_box(xmlNode * n, struct css_style * parent_style, } } - if (n->type == XML_ELEMENT_NODE) { + if (n->type == XML_ELEMENT_NODE && text == 0) { switch (style->display) { case CSS_DISPLAY_BLOCK: /* blocks get a node in the box tree */ if (box == 0) diff --git a/render/html.c b/render/html.c index b41ca6ed2..39f1e5aa2 100644 --- a/render/html.c +++ b/render/html.c @@ -1,5 +1,5 @@ /** - * $Id: html.c,v 1.5 2003/03/04 11:59:35 bursa Exp $ + * $Id: html.c,v 1.6 2003/03/25 21:51:29 bursa Exp $ */ #include @@ -92,11 +92,11 @@ int html_convert(struct content *c, unsigned int width, unsigned int height) xml_to_box(c->data.html.markup, c->data.html.style, c->data.html.stylesheet, &selector, 0, c->data.html.layout, 0, 0, c->data.html.fonts, 0, 0, 0, 0, &c->data.html.elements); - box_dump(c->data.html.layout->children, 0); + /*box_dump(c->data.html.layout->children, 0);*/ LOG(("Layout document")); layout_document(c->data.html.layout->children, width); - box_dump(c->data.html.layout->children, 0); + /*box_dump(c->data.html.layout->children, 0);*/ c->width = c->data.html.layout->children->width; c->height = c->data.html.layout->children->height; diff --git a/render/layout.c b/render/layout.c index 25f27844d..677329406 100644 --- a/render/layout.c +++ b/render/layout.c @@ -1,5 +1,5 @@ /** - * $Id: layout.c,v 1.35 2003/03/08 21:25:56 bursa Exp $ + * $Id: layout.c,v 1.36 2003/03/25 21:51:29 bursa Exp $ */ #include @@ -14,10 +14,9 @@ #include "netsurf/render/layout.h" #include "netsurf/riscos/font.h" #include "netsurf/utils/utils.h" +#define NDEBUG #include "netsurf/utils/log.h" -#define DEBUG_LAYOUT - /** * internal functions */ diff --git a/riscos/gui.c b/riscos/gui.c index 7fa307e19..1e53d00ee 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -1,5 +1,5 @@ /** - * $Id: gui.c,v 1.22 2003/03/15 15:53:20 bursa Exp $ + * $Id: gui.c,v 1.23 2003/03/25 21:51:29 bursa Exp $ */ #include "netsurf/riscos/font.h" @@ -1525,15 +1525,15 @@ void ro_gui_window_click(gui_window* g, wimp_pointer* pointer) if (pointer->buttons == wimp_CLICK_MENU) { /* check for mouse gestures */ - mouseaction ma = ro_gui_try_mouse_action(); +/* mouseaction ma = ro_gui_try_mouse_action(); if (ma == mouseaction_NONE) - { + {*/ os_t now; int z; os_mouse(&x, &y, &z, &now); ro_gui_create_menu((wimp_menu*) &browser_menu, x - 64, y, g); - } +/* } else { fprintf(stderr, "MOUSE GESTURE %d\n", ma); @@ -1551,7 +1551,7 @@ void ro_gui_window_click(gui_window* g, wimp_pointer* pointer) browser_window_open_location_historical(g->data.browser.bw, g->data.browser.bw->url); break; } - } + }*/ } else if (g->data.browser.bw->current_content != NULL) {