summaryrefslogtreecommitdiff
path: root/css
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2013-05-16 18:18:06 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2013-05-16 18:18:06 +0100
commitabebc6ae2b3fb5e40b581d9afdc32d954bcb51b9 (patch)
treef1072b180fea517303b5939ffe91b698ef5378c2 /css
parent023c014ac439b03de4e45dd4cf567fe3a393bbf7 (diff)
downloadnetsurf-abebc6ae2b3fb5e40b581d9afdc32d954bcb51b9.tar.gz
netsurf-abebc6ae2b3fb5e40b581d9afdc32d954bcb51b9.tar.bz2
Fix visited support for libdom. (Still disabled.)
Diffstat (limited to 'css')
-rw-r--r--css/select.c65
1 files changed, 43 insertions, 22 deletions
diff --git a/css/select.c b/css/select.c
index a98ab06f5..0d3be383a 100644
--- a/css/select.c
+++ b/css/select.c
@@ -1552,38 +1552,59 @@ css_error node_is_visited(void *pw, void *node, bool *match)
*match = false;
/** \todo Implement visted check in a more performant way */
-
#ifdef SUPPORT_VISITED
+
nscss_select_ctx *ctx = pw;
- xmlNode *n = node;
+ nsurl *url;
+ nserror error;
+ const struct url_data *data;
- if (strcasecmp((const char *) n->name, "a") == 0) {
- nsurl *url;
- nserror error;
- const struct url_data *data;
- xmlChar *href = xmlGetProp(n, (const xmlChar *) "href");
+ dom_exception exc;
+ dom_node *n = node;
+ dom_string *s = NULL;
- if (href == NULL)
- return CSS_OK;
+ exc = dom_node_get_node_name(n, &s);
+ if ((exc != DOM_NO_ERR) || (s == NULL)) {
+ return CSS_NOMEM;
+ }
- /* Make href absolute */
- /* TODO: this duplicates what we do for box->href */
- error = nsurl_join(ctx->base_url, (const char *)href, &url);
+ if (!dom_string_caseless_lwc_isequal(s, corestring_lwc_a)) {
+ /* Can't be visited; not ancher element */
+ dom_string_unref(s);
+ return CSS_OK;
+ }
- xmlFree(href);
- if (error != NSERROR_OK) {
- return CSS_NOMEM;
- }
+ /* Finished with node name string */
+ dom_string_unref(s);
+ s = NULL;
+
+ exc = dom_element_get_attribute(n, corestring_dom_href, &s);
+ if ((exc != DOM_NO_ERR) || (s == NULL)) {
+ /* Can't be visited; not got a URL */
+ return CSS_OK;
+ }
- data = urldb_get_url_data(nsurl_access(url));
+ /* Make href absolute */
+ /* TODO: this duplicates what we do for box->href
+ * should we put the absolute URL on the dom node? */
+ error = nsurl_join(ctx->base_url, dom_string_data(s), &url);
- /* Visited if in the db and has
- * non-zero visit count */
- if (data != NULL && data->visits > 0)
- *match = true;
+ /* Finished with href string */
+ dom_string_unref(s);
- nsurl_unref(url);
+ if (error != NSERROR_OK) {
+ /* Couldn't make nsurl object */
+ return CSS_NOMEM;
}
+
+ data = urldb_get_url_data(url);
+
+ /* Visited if in the db and has
+ * non-zero visit count */
+ if (data != NULL && data->visits > 0)
+ *match = true;
+
+ nsurl_unref(url);
#endif
return CSS_OK;