summaryrefslogtreecommitdiff
path: root/render
diff options
context:
space:
mode:
Diffstat (limited to 'render')
-rw-r--r--render/box.c29
-rw-r--r--render/box.h2
-rw-r--r--render/html.c7
-rw-r--r--render/html.h3
4 files changed, 39 insertions, 2 deletions
diff --git a/render/box.c b/render/box.c
index d694481a1..015af7411 100644
--- a/render/box.c
+++ b/render/box.c
@@ -190,6 +190,7 @@ struct box * box_create(struct css_style * style,
box->col = 0;
box->font = 0;
box->gadget = 0;
+ box->usemap = 0;
box->object = 0;
#ifdef WITH_PLUGIN
box->object_params = 0;
@@ -771,7 +772,7 @@ struct result box_image(xmlNode *n, struct status *status,
struct css_style *style)
{
struct box *box;
- char *s, *url, *s1;
+ char *s, *url, *s1, *map;
xmlChar *s2;
box = box_create(style, status->href, status->title,
@@ -789,6 +790,17 @@ struct result box_image(xmlNode *n, struct status *status,
if (!(s = (char *) xmlGetProp(n, (const xmlChar *) "src")))
return (struct result) {box, 0};
+ /* imagemap associated with this image */
+ if ((map = xmlGetProp(n, (const xmlChar *) "usemap"))) {
+ if (map[0] == '#') {
+ box->usemap = xstrdup(map+1);
+ }
+ else {
+ box->usemap = xstrdup(map);
+ }
+ xmlFree(map);
+ }
+
/* remove leading and trailing whitespace */
s1 = strip(s);
@@ -1764,6 +1776,8 @@ void box_free_box(struct box *box)
free(box->style);
}
+ if (box->usemap)
+ free(box->usemap);
free(box->text);
/* TODO: free object_params */
}
@@ -1779,7 +1793,7 @@ struct result box_object(xmlNode *n, struct status *status,
struct box *box;
struct object_params *po;
struct plugin_params* pp;
- char *s, *url = NULL;
+ char *s, *url = NULL, *map;
xmlNode *c;
box = box_create(style, status->href, 0,
@@ -1808,6 +1822,17 @@ struct result box_object(xmlNode *n, struct status *status,
xmlFree(s);
}
+ /* imagemap associated with this object */
+ if ((map = xmlGetProp(n, (const xmlChar *) "usemap"))) {
+ if (map[0] == '#') {
+ box->usemap = xstrdup(map+1);
+ }
+ else {
+ box->usemap = xstrdup(map);
+ }
+ xmlFree(map);
+ }
+
/* object type */
if ((s = (char *) xmlGetProp(n, (const xmlChar *) "type"))) {
diff --git a/render/box.h b/render/box.h
index 7e74da638..8fd7a1a93 100644
--- a/render/box.h
+++ b/render/box.h
@@ -195,6 +195,8 @@ struct box {
/** Form control data, or 0 if not a form control. */
struct form_control* gadget;
+ char *usemap; /** (Image)map to use with this object, or 0 if none */
+
/** Object in this box (usually an image), or 0 if none. */
struct content* object;
/** Parameters for the object, or 0. */
diff --git a/render/html.c b/render/html.c
index e028e523d..9ca025156 100644
--- a/render/html.c
+++ b/render/html.c
@@ -18,6 +18,7 @@
#include "netsurf/content/content.h"
#include "netsurf/content/fetch.h"
#include "netsurf/content/fetchcache.h"
+#include "netsurf/desktop/imagemap.h"
#ifdef riscos
#include "netsurf/desktop/gui.h"
#endif
@@ -180,6 +181,10 @@ int html_convert(struct content *c, unsigned int width, unsigned int height)
xml_to_box(html, c);
/*box_dump(c->data.html.layout->children, 0);*/
+ /* extract image maps - can't do this sensibly in xml_to_box */
+ imagemap_extract(html, c);
+ /*imagemap_dump(c);*/
+
/* XML tree not required past this point */
xmlFreeDoc(document);
@@ -752,6 +757,8 @@ void html_destroy(struct content *c)
free(c->title);
+ imagemap_destroy(c);
+
if (c->data.html.parser)
htmlFreeParserCtxt(c->data.html.parser);
diff --git a/render/html.h b/render/html.h
index d029a7554..79b2ca3ec 100644
--- a/render/html.h
+++ b/render/html.h
@@ -23,6 +23,7 @@ struct box;
struct browser_window;
struct content;
struct object_params;
+struct imagemap;
struct box_position {
struct box *box;
@@ -73,6 +74,8 @@ struct content_html_data {
const content_type *permitted_types;
} *object;
+ struct imagemap **imagemaps; /**< Hashtable of imagemaps */
+
pool box_pool; /**< Memory pool for box tree. */
pool string_pool; /**< Memory pool for strings. */
};