Gitweb links:

...log 
http://git.netsurf-browser.org/libcss.git/shortlog/3b4fdeafdbed6b779b3b826eda9c9b703dd8c0a1
...commit 
http://git.netsurf-browser.org/libcss.git/commit/3b4fdeafdbed6b779b3b826eda9c9b703dd8c0a1
...tree 
http://git.netsurf-browser.org/libcss.git/tree/3b4fdeafdbed6b779b3b826eda9c9b703dd8c0a1

The branch, master has been updated
       via  3b4fdeafdbed6b779b3b826eda9c9b703dd8c0a1 (commit)
      from  846a5fccea928453de47b4ff4bdf120071a1ba79 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/libcss.git/commit/?id=3b4fdeafdbed6b779b3b826eda9c9b703dd8c0a1
commit 3b4fdeafdbed6b779b3b826eda9c9b703dd8c0a1
Author: Michael Drake <t...@netsurf-browser.org>
Commit: Michael Drake <t...@netsurf-browser.org>

    Access lwc caseless hash through supported API.

diff --git a/src/select/bloom.h b/src/select/bloom.h
index 85094cd..11628ab 100644
--- a/src/select/bloom.h
+++ b/src/select/bloom.h
@@ -16,9 +16,9 @@
  * Generate the bloom filter by adding calling css_bloom_add_hash() on each
  * ancestor element name, class name and id name for the node.
  *
- * Use the insesnsitive lwc_string:
+ * Use the insesnsitive hash value:
  *
- *     lwc_string_hash_value(str->insensitive)
+ *     lwc_err = lwc_string_caseless_hash_value(str, &hash);
  */
 
 #ifndef libcss_bloom_h_
diff --git a/src/select/hash.c b/src/select/hash.c
index 9f83cfb..57ab2e5 100644
--- a/src/select/hash.c
+++ b/src/select/hash.c
@@ -366,6 +366,7 @@ css_error css__selector_hash_find(css_selector_hash *hash,
                const css_selector ***matched)
 {
        uint32_t index, mask;
+       lwc_hash name_hash;
        hash_entry *head;
 
        if (hash == NULL || req == NULL || iterator == NULL || matched == NULL)
@@ -374,12 +375,11 @@ css_error css__selector_hash_find(css_selector_hash *hash,
        /* Find index */
        mask = hash->elements.n_slots - 1;
 
-       if (req->qname.name->insensitive == NULL &&
-                       lwc__intern_caseless_string(
-                       req->qname.name) != lwc_error_ok) {
+       if (lwc_string_caseless_hash_value(req->qname.name,
+                       &name_hash) != lwc_error_ok) {
                return CSS_NOMEM;
        }
-       index = _hash_name(req->qname.name) & mask;
+       index = name_hash & mask;
 
        head = &hash->elements.slots[index];
 
@@ -437,6 +437,7 @@ css_error 
css__selector_hash_find_by_class(css_selector_hash *hash,
                const css_selector ***matched)
 {
        uint32_t index, mask;
+       lwc_hash class_hash;
        hash_entry *head;
 
        if (hash == NULL || req == NULL || req->class == NULL ||
@@ -446,12 +447,11 @@ css_error 
css__selector_hash_find_by_class(css_selector_hash *hash,
        /* Find index */
        mask = hash->classes.n_slots - 1;
 
-       if (req->class->insensitive == NULL &&
-                       lwc__intern_caseless_string(
-                       req->class) != lwc_error_ok) {
+       if (lwc_string_caseless_hash_value(req->class,
+                       &class_hash) != lwc_error_ok) {
                return CSS_NOMEM;
        }
-       index = _hash_name(req->class) & mask;
+       index = class_hash & mask;
 
        head = &hash->classes.slots[index];
 
@@ -517,6 +517,7 @@ css_error css__selector_hash_find_by_id(css_selector_hash 
*hash,
                const css_selector ***matched)
 {
        uint32_t index, mask;
+       lwc_hash id_hash;
        hash_entry *head;
 
        if (hash == NULL || req == NULL || req->id == NULL ||
@@ -526,12 +527,11 @@ css_error css__selector_hash_find_by_id(css_selector_hash 
*hash,
        /* Find index */
        mask = hash->ids.n_slots - 1;
 
-       if (req->id->insensitive == NULL &&
-                       lwc__intern_caseless_string(
-                       req->id) != lwc_error_ok) {
+       if (lwc_string_caseless_hash_value(req->id,
+                       &id_hash) != lwc_error_ok) {
                return CSS_NOMEM;
        }
-       index = _hash_name(req->id) & mask;
+       index = id_hash & mask;
 
        head = &hash->ids.slots[index];
 
diff --git a/src/select/select.c b/src/select/select.c
index a575a2f..ce56def 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -440,6 +440,7 @@ css_error css_select_style(css_select_ctx *ctx, void *node,
        css_hint *hints = NULL;
        css_bloom *bloom = NULL;
        css_bloom *parent_bloom = NULL;
+       lwc_hash hash;
 
        if (ctx == NULL || node == NULL || result == NULL || handler == NULL ||
            handler->handler_version != CSS_SELECT_HANDLER_VERSION_1)
@@ -659,43 +660,34 @@ css_error css_select_style(css_select_ctx *ctx, void 
*node,
        }
 
        /* Add node name to bloom */
-       if (state.element.name->insensitive == NULL) {
-               if (lwc__intern_caseless_string(
-                               state.element.name) != lwc_error_ok) {
-                       error = CSS_NOMEM;
-                       goto cleanup;
-               }
+
+       if (lwc_string_caseless_hash_value(state.element.name,
+                       &hash) != lwc_error_ok) {
+               error = CSS_NOMEM;
+               goto cleanup;
        }
-       css_bloom_add_hash(bloom, lwc_string_hash_value(
-                       state.element.name->insensitive));
+       css_bloom_add_hash(bloom, hash);
 
        /* Add id name to bloom */
        if (state.id != NULL) {
-               if (state.id->insensitive == NULL) {
-                       if (lwc__intern_caseless_string(state.id) !=
-                                       lwc_error_ok) {
-                               error = CSS_NOMEM;
-                               goto cleanup;
-                       }
+               if (lwc_string_caseless_hash_value(state.id,
+                               &hash) != lwc_error_ok) {
+                       error = CSS_NOMEM;
+                       goto cleanup;
                }
-               css_bloom_add_hash(bloom, lwc_string_hash_value(
-                               state.id->insensitive));
+               css_bloom_add_hash(bloom, hash);
        }
 
        /* Add class names to bloom */
        if (state.classes != NULL) {
-               lwc_string *s;
                for (i = 0; i < state.n_classes; i++) {
-                       s = state.classes[i];
-                       if (s->insensitive == NULL) {
-                               if (lwc__intern_caseless_string(s) !=
-                                               lwc_error_ok) {
-                                       error = CSS_NOMEM;
-                                       goto cleanup;
-                               }
+                       lwc_string *s = state.classes[i];
+                       if (lwc_string_caseless_hash_value(s,
+                                       &hash) != lwc_error_ok) {
+                               error = CSS_NOMEM;
+                               goto cleanup;
                        }
-                       css_bloom_add_hash(bloom, lwc_string_hash_value(
-                                       s->insensitive));
+                       css_bloom_add_hash(bloom, hash);
                }
        }
 


-----------------------------------------------------------------------

Summary of changes:
 src/select/bloom.h  |    4 ++--
 src/select/hash.c   |   24 ++++++++++++------------
 src/select/select.c |   44 ++++++++++++++++++--------------------------
 3 files changed, 32 insertions(+), 40 deletions(-)

diff --git a/src/select/bloom.h b/src/select/bloom.h
index 85094cd..11628ab 100644
--- a/src/select/bloom.h
+++ b/src/select/bloom.h
@@ -16,9 +16,9 @@
  * Generate the bloom filter by adding calling css_bloom_add_hash() on each
  * ancestor element name, class name and id name for the node.
  *
- * Use the insesnsitive lwc_string:
+ * Use the insesnsitive hash value:
  *
- *     lwc_string_hash_value(str->insensitive)
+ *     lwc_err = lwc_string_caseless_hash_value(str, &hash);
  */
 
 #ifndef libcss_bloom_h_
diff --git a/src/select/hash.c b/src/select/hash.c
index 9f83cfb..57ab2e5 100644
--- a/src/select/hash.c
+++ b/src/select/hash.c
@@ -366,6 +366,7 @@ css_error css__selector_hash_find(css_selector_hash *hash,
                const css_selector ***matched)
 {
        uint32_t index, mask;
+       lwc_hash name_hash;
        hash_entry *head;
 
        if (hash == NULL || req == NULL || iterator == NULL || matched == NULL)
@@ -374,12 +375,11 @@ css_error css__selector_hash_find(css_selector_hash *hash,
        /* Find index */
        mask = hash->elements.n_slots - 1;
 
-       if (req->qname.name->insensitive == NULL &&
-                       lwc__intern_caseless_string(
-                       req->qname.name) != lwc_error_ok) {
+       if (lwc_string_caseless_hash_value(req->qname.name,
+                       &name_hash) != lwc_error_ok) {
                return CSS_NOMEM;
        }
-       index = _hash_name(req->qname.name) & mask;
+       index = name_hash & mask;
 
        head = &hash->elements.slots[index];
 
@@ -437,6 +437,7 @@ css_error 
css__selector_hash_find_by_class(css_selector_hash *hash,
                const css_selector ***matched)
 {
        uint32_t index, mask;
+       lwc_hash class_hash;
        hash_entry *head;
 
        if (hash == NULL || req == NULL || req->class == NULL ||
@@ -446,12 +447,11 @@ css_error 
css__selector_hash_find_by_class(css_selector_hash *hash,
        /* Find index */
        mask = hash->classes.n_slots - 1;
 
-       if (req->class->insensitive == NULL &&
-                       lwc__intern_caseless_string(
-                       req->class) != lwc_error_ok) {
+       if (lwc_string_caseless_hash_value(req->class,
+                       &class_hash) != lwc_error_ok) {
                return CSS_NOMEM;
        }
-       index = _hash_name(req->class) & mask;
+       index = class_hash & mask;
 
        head = &hash->classes.slots[index];
 
@@ -517,6 +517,7 @@ css_error css__selector_hash_find_by_id(css_selector_hash 
*hash,
                const css_selector ***matched)
 {
        uint32_t index, mask;
+       lwc_hash id_hash;
        hash_entry *head;
 
        if (hash == NULL || req == NULL || req->id == NULL ||
@@ -526,12 +527,11 @@ css_error css__selector_hash_find_by_id(css_selector_hash 
*hash,
        /* Find index */
        mask = hash->ids.n_slots - 1;
 
-       if (req->id->insensitive == NULL &&
-                       lwc__intern_caseless_string(
-                       req->id) != lwc_error_ok) {
+       if (lwc_string_caseless_hash_value(req->id,
+                       &id_hash) != lwc_error_ok) {
                return CSS_NOMEM;
        }
-       index = _hash_name(req->id) & mask;
+       index = id_hash & mask;
 
        head = &hash->ids.slots[index];
 
diff --git a/src/select/select.c b/src/select/select.c
index a575a2f..ce56def 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -440,6 +440,7 @@ css_error css_select_style(css_select_ctx *ctx, void *node,
        css_hint *hints = NULL;
        css_bloom *bloom = NULL;
        css_bloom *parent_bloom = NULL;
+       lwc_hash hash;
 
        if (ctx == NULL || node == NULL || result == NULL || handler == NULL ||
            handler->handler_version != CSS_SELECT_HANDLER_VERSION_1)
@@ -659,43 +660,34 @@ css_error css_select_style(css_select_ctx *ctx, void 
*node,
        }
 
        /* Add node name to bloom */
-       if (state.element.name->insensitive == NULL) {
-               if (lwc__intern_caseless_string(
-                               state.element.name) != lwc_error_ok) {
-                       error = CSS_NOMEM;
-                       goto cleanup;
-               }
+
+       if (lwc_string_caseless_hash_value(state.element.name,
+                       &hash) != lwc_error_ok) {
+               error = CSS_NOMEM;
+               goto cleanup;
        }
-       css_bloom_add_hash(bloom, lwc_string_hash_value(
-                       state.element.name->insensitive));
+       css_bloom_add_hash(bloom, hash);
 
        /* Add id name to bloom */
        if (state.id != NULL) {
-               if (state.id->insensitive == NULL) {
-                       if (lwc__intern_caseless_string(state.id) !=
-                                       lwc_error_ok) {
-                               error = CSS_NOMEM;
-                               goto cleanup;
-                       }
+               if (lwc_string_caseless_hash_value(state.id,
+                               &hash) != lwc_error_ok) {
+                       error = CSS_NOMEM;
+                       goto cleanup;
                }
-               css_bloom_add_hash(bloom, lwc_string_hash_value(
-                               state.id->insensitive));
+               css_bloom_add_hash(bloom, hash);
        }
 
        /* Add class names to bloom */
        if (state.classes != NULL) {
-               lwc_string *s;
                for (i = 0; i < state.n_classes; i++) {
-                       s = state.classes[i];
-                       if (s->insensitive == NULL) {
-                               if (lwc__intern_caseless_string(s) !=
-                                               lwc_error_ok) {
-                                       error = CSS_NOMEM;
-                                       goto cleanup;
-                               }
+                       lwc_string *s = state.classes[i];
+                       if (lwc_string_caseless_hash_value(s,
+                                       &hash) != lwc_error_ok) {
+                               error = CSS_NOMEM;
+                               goto cleanup;
                        }
-                       css_bloom_add_hash(bloom, lwc_string_hash_value(
-                                       s->insensitive));
+                       css_bloom_add_hash(bloom, hash);
                }
        }
 


-- 
Cascading Style Sheets library

_______________________________________________
netsurf-commits mailing list
netsurf-commits@netsurf-browser.org
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to