summaryrefslogtreecommitdiff
path: root/src/select/hash.h
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2013-12-01 19:02:37 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2013-12-01 19:02:37 +0000
commitcea0f412145c239a7583c10554c2d88964e94fd7 (patch)
tree7c8919bc45001c596ad6dc21a6035077fa48ad68 /src/select/hash.h
parentd2460b3a2f2690813abdf3b350be9dc5ebf2fe18 (diff)
downloadlibcss-cea0f412145c239a7583c10554c2d88964e94fd7.tar.gz
libcss-cea0f412145c239a7583c10554c2d88964e94fd7.tar.bz2
Significantly optimise CSS selection performance.
Now we pass a node bloom filter to css_get_style. That node bloom filter is filled with the node's ancestor element, class, and id names. Internally, libcss also generates a bloom filter for each selector chain. If the selector chain's bloom filter is not a subset of the node bloom filter, we know that the selector chain's rule does not apply to the node. This avoids the slow selector chain matching process. Other smaller optimisations to move the ruling out of selector chains for inapplicable media types and other reasons to before we start comparing rules from different sources to find the next rule. All this is now done in hash.c so select.c never sees the trivially ruled out rules.
Diffstat (limited to 'src/select/hash.h')
-rw-r--r--src/select/hash.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/select/hash.h b/src/select/hash.h
index 06c27a9..2217cbd 100644
--- a/src/select/hash.h
+++ b/src/select/hash.h
@@ -10,6 +10,7 @@
#include <libwapcaplet/libwapcaplet.h>
+#include <libcss/bloom.h>
#include <libcss/errors.h>
#include <libcss/functypes.h>
@@ -18,7 +19,16 @@ struct css_selector;
typedef struct css_selector_hash css_selector_hash;
+struct css_hash_selection_requirments {
+ css_qname qname; /* Element name, or universal '*' */
+ lwc_string *class; /* Name of class, or NULL */
+ lwc_string *id; /* Name of id, or NULL */
+ uint64_t media; /* Media type(s) we're selecting for */
+ const css_bloom *node_bloom; /* Node's bloom filter */
+};
+
typedef css_error (*css_selector_hash_iterator)(
+ const struct css_hash_selection_requirments *req,
const struct css_selector **current,
const struct css_selector ***next);
@@ -32,18 +42,19 @@ css_error css__selector_hash_remove(css_selector_hash *hash,
const struct css_selector *selector);
css_error css__selector_hash_find(css_selector_hash *hash,
- css_qname *qname,
+ const struct css_hash_selection_requirments *req,
css_selector_hash_iterator *iterator,
const struct css_selector ***matched);
css_error css__selector_hash_find_by_class(css_selector_hash *hash,
- lwc_string *name,
+ const struct css_hash_selection_requirments *req,
css_selector_hash_iterator *iterator,
const struct css_selector ***matched);
css_error css__selector_hash_find_by_id(css_selector_hash *hash,
- lwc_string *name,
+ const struct css_hash_selection_requirments *req,
css_selector_hash_iterator *iterator,
const struct css_selector ***matched);
css_error css__selector_hash_find_universal(css_selector_hash *hash,
+ const struct css_hash_selection_requirments *req,
css_selector_hash_iterator *iterator,
const struct css_selector ***matched);