/** * Extract an imagemap from html source * * \param node XML node containing map * \param c Content containing document * \param entry List of map entries * \return false on memory exhaustion, true otherwise */ bool imagemap_extract_map(xmlNode *node, html_content *c, struct mapentry **entry) { xmlNode *this_node; assert(c != NULL); assert(entry != NULL); if (node->type == XML_ELEMENT_NODE) { /** \todo ignore <area> elements if there are other * block-level elements present in map */ if (strcmp((const char *) node->name, "area") == 0 || strcmp((const char *) node->name, "a") == 0) { if (imagemap_addtolist(node, c->base_url, entry) == false) return false; } } else { return true; } for (this_node = node->children; this_node != NULL; this_node = this_node->next) { if (imagemap_extract_map(this_node, c, entry) == false) return false; } return true; }
/** * Extract an imagemap from html source * * \param node XML node containing map * \param c Content containing document * \param entry List of map entries * \param tname The sub-tags to consider on this pass * \return false on memory exhaustion, true otherwise */ static bool imagemap_extract_map_entries(dom_node *node, html_content *c, struct mapentry **entry, dom_string *tname) { dom_nodelist *nlist; dom_exception exc; unsigned long ent; uint32_t tag_count; exc = dom_element_get_elements_by_tag_name(node, tname, &nlist); if (exc != DOM_NO_ERR) { return false; } exc = dom_nodelist_get_length(nlist, &tag_count); if (exc != DOM_NO_ERR) { dom_nodelist_unref(nlist); return false; } for (ent = 0; ent < tag_count; ++ent) { dom_node *subnode; exc = dom_nodelist_item(nlist, ent, &subnode); if (exc != DOM_NO_ERR) { dom_nodelist_unref(nlist); return false; } if (imagemap_addtolist(c, subnode, c->base_url, entry, tname) == false) { dom_node_unref(subnode); dom_nodelist_unref(nlist); return false; } dom_node_unref(subnode); } dom_nodelist_unref(nlist); return true; }