summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2013-05-18 15:17:24 (GMT)
committer Michael Drake <tlsa@netsurf-browser.org>2013-05-18 15:17:24 (GMT)
commit7a7043f90650c3fd4f3fc2778619743aafc8d335 (patch)
treed8f377d15d97ac5eb5f8d88b948a2eafc9cb9106
parentb25d7b5b5ea0495e61a8b7afc2bbca520d7e447d (diff)
parent943025ddb04b04d4938eb249d7f55825c8d7a470 (diff)
downloadnetsurf-tlsa/selection-search-refactor.tar.gz
netsurf-tlsa/selection-search-refactor.tar.bz2
Merge branch 'master' of git://git.netsurf-browser.org/netsurf into tlsa/selection-search-refactortlsa/selection-search-refactor
-rwxr-xr-xamiga/font.c5
-rwxr-xr-xamiga/plotters.c7
-rw-r--r--css/select.c67
-rw-r--r--utils/nsurl.c65
-rw-r--r--utils/nsurl.h9
5 files changed, 118 insertions, 35 deletions
diff --git a/amiga/font.c b/amiga/font.c
index e624d56..5ec5203 100755
--- a/amiga/font.c
+++ b/amiga/font.c
@@ -341,15 +341,14 @@ bool nsfont_split(const plot_font_style_t *fstyle,
}
}
- tx += tempx;
-
if ((x < tx) && (*char_offset != 0)) {
/* Reached available width, and a space was found;
* split there. */
free(outf16);
return true;
}
-
+
+ tx += tempx;
utf16 = utf16next;
utf8_pos = utf8_next(string, length, utf8_pos);
}
diff --git a/amiga/plotters.c b/amiga/plotters.c
index 8a1ce4d..2b3a1f5 100755
--- a/amiga/plotters.c
+++ b/amiga/plotters.c
@@ -163,13 +163,6 @@ void ami_init_layers(struct gui_globals *gg, ULONG width, ULONG height)
palette_mapped = true;
} else {
palette_mapped = false;
-
- /* If we're not palette-mapping allocate using a friend BitMap if the
- * depth is 32bpp. In all other cases using a friend BitMap causes a
- * hard lockup or odd/missing graphical effects.
- */
-
- if(depth == 32) friend = scrn->RastPort.BitMap;
}
if(nsoption_int(redraw_tile_size_x) <= 0) nsoption_set_int(redraw_tile_size_x, scrn->Width);
diff --git a/css/select.c b/css/select.c
index a98ab06..b9b8c28 100644
--- a/css/select.c
+++ b/css/select.c
@@ -1551,40 +1551,57 @@ 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;
}
-#endif
+
+ 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);
return CSS_OK;
}
diff --git a/utils/nsurl.c b/utils/nsurl.c
index 23e177e..61f849e 100644
--- a/utils/nsurl.c
+++ b/utils/nsurl.c
@@ -154,6 +154,7 @@ struct nsurl {
struct nsurl_components components;
int count; /* Number of references to NetSurf URL object */
+ uint32_t hash; /* Hash value for nsurl identification */
size_t length; /* Length of string */
char string[FLEX_ARRAY_LEN_DECL]; /* Full URL as a string */
@@ -1185,6 +1186,43 @@ static void nsurl_get_string(const struct nsurl_components *url, char *url_s,
}
+/**
+ * Calculate hash value
+ *
+ * \param url NetSurf URL object to set hash value for
+ */
+static void nsurl_calc_hash(nsurl *url)
+{
+ uint32_t hash = 0;
+
+ if (url->components.scheme)
+ hash ^= lwc_string_hash_value(url->components.scheme);
+
+ if (url->components.username)
+ hash ^= lwc_string_hash_value(url->components.username);
+
+ if (url->components.password)
+ hash ^= lwc_string_hash_value(url->components.password);
+
+ if (url->components.host)
+ hash ^= lwc_string_hash_value(url->components.host);
+
+ if (url->components.port)
+ hash ^= lwc_string_hash_value(url->components.port);
+
+ if (url->components.path)
+ hash ^= lwc_string_hash_value(url->components.path);
+
+ if (url->components.query)
+ hash ^= lwc_string_hash_value(url->components.query);
+
+ if (url->components.fragment)
+ hash ^= lwc_string_hash_value(url->components.fragment);
+
+ url->hash = hash;
+}
+
+
#ifdef NSURL_DEBUG
/**
* Dump a NetSurf URL's internal components
@@ -1282,6 +1320,9 @@ nserror nsurl_create(const char * const url_s, nsurl **url)
/* Fill out the url string */
nsurl_get_string(&c, (*url)->string, &str_len, str_flags);
+ /* Get the nsurl's hash */
+ nsurl_calc_hash(*url);
+
/* Give the URL a reference */
(*url)->count = 1;
@@ -1615,6 +1656,15 @@ size_t nsurl_length(const nsurl *url)
/* exported interface, documented in nsurl.h */
+uint32_t nsurl_hash(const nsurl *url)
+{
+ assert(url != NULL);
+
+ return url->hash;
+}
+
+
+/* exported interface, documented in nsurl.h */
nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined)
{
struct url_markers m;
@@ -1819,6 +1869,9 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined)
/* Fill out the url string */
nsurl_get_string(&c, (*joined)->string, &str_len, str_flags);
+ /* Get the nsurl's hash */
+ nsurl_calc_hash(*joined);
+
/* Give the URL a reference */
(*joined)->count = 1;
@@ -1871,6 +1924,9 @@ nserror nsurl_defragment(const nsurl *url, nsurl **no_frag)
pos += length;
*pos = '\0';
+ /* Get the nsurl's hash */
+ nsurl_calc_hash(*no_frag);
+
/* Give the URL a reference */
(*no_frag)->count = 1;
@@ -1936,6 +1992,9 @@ nserror nsurl_refragment(const nsurl *url, lwc_string *frag, nsurl **new_url)
(*new_url)->components.scheme_type = url->components.scheme_type;
+ /* Get the nsurl's hash */
+ nsurl_calc_hash(*new_url);
+
/* Give the URL a reference */
(*new_url)->count = 1;
@@ -2019,6 +2078,9 @@ nserror nsurl_replace_query(const nsurl *url, const char *query,
(*new_url)->components.scheme_type = url->components.scheme_type;
+ /* Get the nsurl's hash */
+ nsurl_calc_hash(*new_url);
+
/* Give the URL a reference */
(*new_url)->count = 1;
@@ -2114,6 +2176,9 @@ nserror nsurl_parent(const nsurl *url, nsurl **new_url)
(*new_url)->components.scheme_type = url->components.scheme_type;
+ /* Get the nsurl's hash */
+ nsurl_calc_hash(*new_url);
+
/* Give the URL a reference */
(*new_url)->count = 1;
diff --git a/utils/nsurl.h b/utils/nsurl.h
index b075c42..435df73 100644
--- a/utils/nsurl.h
+++ b/utils/nsurl.h
@@ -208,6 +208,15 @@ size_t nsurl_length(const nsurl *url);
/**
+ * Get a URL's hash value
+ *
+ * \param url NetSurf URL get hash value for.
+ * \return the hash value
+ */
+uint32_t nsurl_hash(const nsurl *url);
+
+
+/**
* Join a base url to a relative link part, creating a new NetSurf URL object
*
* \param base NetSurf URL containing the base to join rel to