From abebc6ae2b3fb5e40b581d9afdc32d954bcb51b9 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Thu, 16 May 2013 18:18:06 +0100 Subject: Fix visited support for libdom. (Still disabled.) --- css/select.c | 65 ++++++++++++++++++++++++++++++++++++++++-------------------- 1 file 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; -- cgit v1.2.3 From 39cc1a6d4a77415de3a1b4ac8780c2d1b1839091 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Fri, 17 May 2013 12:25:04 +0100 Subject: Add function to get a nsurl's hash value. --- utils/nsurl.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ utils/nsurl.h | 9 +++++++++ 2 files changed, 74 insertions(+) diff --git a/utils/nsurl.c b/utils/nsurl.c index 23e177e05..61f849e5f 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; @@ -1614,6 +1655,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) { @@ -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 b075c42a1..435df73bd 100644 --- a/utils/nsurl.h +++ b/utils/nsurl.h @@ -207,6 +207,15 @@ const char *nsurl_access_leaf(const nsurl *url); 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 * -- cgit v1.2.3 From c240fb0c008b57ee72ae6c1e9a9d94dbc3d7a955 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Fri, 17 May 2013 12:38:06 +0100 Subject: Enable :visited handling for experimentation. --- css/select.c | 1 + 1 file changed, 1 insertion(+) diff --git a/css/select.c b/css/select.c index 0d3be383a..ddfea62ad 100644 --- a/css/select.c +++ b/css/select.c @@ -1552,6 +1552,7 @@ css_error node_is_visited(void *pw, void *node, bool *match) *match = false; /** \todo Implement visted check in a more performant way */ +#define SUPPORT_VISITED #ifdef SUPPORT_VISITED nscss_select_ctx *ctx = pw; -- cgit v1.2.3 From 13e667ff78f66029cfcae00ca7737144e13a3ff7 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 18 May 2013 13:26:07 +0100 Subject: Remove friend BitMap as it doesn't solve the problem intended, and I'm concerned that it will cause problems on gfx cards which only have LE modes --- amiga/plotters.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/amiga/plotters.c b/amiga/plotters.c index 8a1ce4d68..2b3a1f57a 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); -- cgit v1.2.3 From 5fcdbb80f03e445d1b1f9206d31c1d5afe6fb4ca Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sat, 18 May 2013 13:34:36 +0100 Subject: Try to avoid the split point jumping around when it occurs exactly on the boundary requested --- amiga/font.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/amiga/font.c b/amiga/font.c index e624d5677..5ec52032f 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); } -- cgit v1.2.3 From 943025ddb04b04d4938eb249d7f55825c8d7a470 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 18 May 2013 14:40:42 +0100 Subject: Remove SUPPORT_VISITED build switch. --- css/select.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/css/select.c b/css/select.c index ddfea62ad..b9b8c28c3 100644 --- a/css/select.c +++ b/css/select.c @@ -1551,10 +1551,6 @@ css_error node_is_visited(void *pw, void *node, bool *match) { *match = false; - /** \todo Implement visted check in a more performant way */ -#define SUPPORT_VISITED -#ifdef SUPPORT_VISITED - nscss_select_ctx *ctx = pw; nsurl *url; nserror error; @@ -1606,7 +1602,6 @@ css_error node_is_visited(void *pw, void *node, bool *match) *match = true; nsurl_unref(url); -#endif return CSS_OK; } -- cgit v1.2.3