Gitweb links:
...log
http://git.netsurf-browser.org/libcss.git/shortlog/3959f3c25347f32d33c35fdf31cb797948a8a5da
...commit
http://git.netsurf-browser.org/libcss.git/commit/3959f3c25347f32d33c35fdf31cb797948a8a5da
...tree
http://git.netsurf-browser.org/libcss.git/tree/3959f3c25347f32d33c35fdf31cb797948a8a5da
The branch, tlsa/shared-styles has been updated
discards ecdd3af87a14b464cc6e0edc22d4c4fb988d20a8 (commit)
discards 8eac2e784c1b6b4f4f89768b7a05b4d2973981a5 (commit)
discards 3bff37d955346551fd4755707beae8defc3ee4b0 (commit)
discards 91eec6f8aa794cc7e2a0202e94b1ebc52ecf48b5 (commit)
discards 6660698efa8b77a07982106db52f11ff925af16d (commit)
via 3959f3c25347f32d33c35fdf31cb797948a8a5da (commit)
via d9072ae1c5e4032a52f780603212b38f55ca1337 (commit)
via f63f74900accbe9faa53b6123352cbcfb07ec8d5 (commit)
via 7688ce3ff33b5b2818d20bcaa4a4ccab4eddbfb8 (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (ecdd3af87a14b464cc6e0edc22d4c4fb988d20a8)
\
N -- N -- N (3959f3c25347f32d33c35fdf31cb797948a8a5da)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
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=3959f3c25347f32d33c35fdf31cb797948a8a5da
commit 3959f3c25347f32d33c35fdf31cb797948a8a5da
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
WIP: Make node data contain list of partial node styles.
diff --git a/src/select/computed.h b/src/select/computed.h
index 57981b2..f77bda2 100644
--- a/src/select/computed.h
+++ b/src/select/computed.h
@@ -338,6 +338,10 @@ static inline css_computed_style * css__computed_style_ref(
if (style == NULL)
return NULL;
+ if (style->i.uncommon != NULL) {
+ style->i.uncommon->count++;
+ }
+
style->count++;
return style;
}
diff --git a/src/select/select.c b/src/select/select.c
index 9f5f3a3..955370b 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -170,12 +170,21 @@ static css_error css__create_node_data(struct
css_node_data **node_data)
static void css__destroy_node_data(struct css_node_data *node_data)
{
+ int i;
+
assert(node_data != NULL);
if (node_data->bloom != NULL) {
free(node_data->bloom);
}
+ for (i = 0; i < CSS_PSEUDO_ELEMENT_COUNT; i++) {
+ if (node_data->partial.styles[i] != NULL) {
+ css_computed_style_destroy(
+ node_data->partial.styles[i]);
+ }
+ }
+
free(node_data);
}
@@ -660,19 +669,32 @@ cleanup:
static css_error css__set_node_data(void *node, css_select_state *state,
css_select_handler *handler, void *pw)
{
+ int i;
css_error error;
css_bloom *bloom;
+ css_select_results *results;
+
+ struct css_node_data *node_data = state->node_data;
/* Set node bloom filter */
error = css__create_node_bloom(&bloom, state);
if (error != CSS_OK) {
return error;
}
- state->node_data->bloom = bloom;
+ node_data->bloom = bloom;
- error = handler->set_libcss_node_data(pw, node, state->node_data);
+ /* Set selection results */
+ results = state->results;
+ for (i = 0; i < CSS_PSEUDO_ELEMENT_COUNT; i++) {
+ node_data->partial.styles[i] =
+ css__computed_style_ref(results->styles[i]);
+ }
+
+ error = handler->set_libcss_node_data(pw, node, node_data);
if (error != CSS_OK) {
- return error;
+ //css__destroy_node_data(node_data);
+ state->node_data = NULL;
+ return CSS_OK;
}
state->node_data = NULL;
diff --git a/src/select/select.h b/src/select/select.h
index 196914d..254b095 100644
--- a/src/select/select.h
+++ b/src/select/select.h
@@ -32,6 +32,7 @@ typedef struct prop_state {
} prop_state;
struct css_node_data {
+ css_select_results partial;
css_bloom *bloom;
};
diff --git a/test/select-common.c b/test/select-common.c
index b4f588a..ef96efd 100644
--- a/test/select-common.c
+++ b/test/select-common.c
@@ -1667,15 +1667,4 @@ css_error compute_font_size(void *pw, const css_hint
*parent, css_hint *size)
return CSS_OK;
}
-static css_error set_libcss_node_data(void *pw, void *n,
- void *libcss_node_data)
-{
- node *node = n;
- UNUSED(pw);
-
- node->libcss_node_data = libcss_node_data;
-
- return CSS_OK;
-}
-
diff --git a/test/select-nd.c b/test/select-nd.c
index 6469267..3c236a6 100644
--- a/test/select-nd.c
+++ b/test/select-nd.c
@@ -1,6 +1,17 @@
#include "select-common.c"
+static css_error set_libcss_node_data(void *pw, void *n,
+ void *libcss_node_data)
+{
+ node *node = n;
+ UNUSED(pw);
+
+ node->libcss_node_data = libcss_node_data;
+
+ return CSS_OK;
+}
+
static css_error get_libcss_node_data(void *pw, void *n,
void **libcss_node_data)
{
diff --git a/test/select-no-nd.c b/test/select-no-nd.c
index 8eb3735..c035126 100644
--- a/test/select-no-nd.c
+++ b/test/select-no-nd.c
@@ -1,6 +1,16 @@
#include "select-common.c"
+static css_error set_libcss_node_data(void *pw, void *n,
+ void *libcss_node_data)
+{
+ UNUSED(n);
+ UNUSED(pw);
+ UNUSED(libcss_node_data);
+
+ return CSS_PROPERTY_NOT_SET;
+}
+
static css_error get_libcss_node_data(void *pw, void *n,
void **libcss_node_data)
{
@@ -12,3 +22,4 @@ static css_error get_libcss_node_data(void *pw, void *n,
return CSS_OK;
}
+
commitdiff
http://git.netsurf-browser.org/libcss.git/commit/?id=d9072ae1c5e4032a52f780603212b38f55ca1337
commit d9072ae1c5e4032a52f780603212b38f55ca1337
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
Separate node data creation and node bloom creation.
diff --git a/src/select/select.c b/src/select/select.c
index ee7fd7f..9f5f3a3 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -581,20 +581,14 @@ static css_error css__get_parent_bloom(void *parent,
return CSS_OK;
}
-/**
- * Set a node's data
- *
- * \param parent Node to set node data for
- * \param handler Dispatch table of handler functions
- * \param pw Client-specific private data for handler functions
- * \return CSS_OK on success, appropriate error otherwise.
- */
-static css_error css__set_node_data(void *node, css_select_state *state,
- css_select_handler *handler, void *pw)
+static css_error css__create_node_bloom(
+ css_bloom **node_bloom, css_select_state *state)
{
css_error error;
css_bloom *bloom;
+ *node_bloom = NULL;
+
/* Create the node's bloom */
bloom = calloc(sizeof(css_bloom), CSS_BLOOM_SIZE);
if (bloom == NULL) {
@@ -645,14 +639,7 @@ static css_error css__set_node_data(void *node,
css_select_state *state,
/* Merge parent bloom into node bloom */
css_bloom_merge(state->node_data->bloom, bloom);
- state->node_data->bloom = bloom;
-
- /* Set node bloom filter */
- error = handler->set_libcss_node_data(pw, node, state->node_data);
- if (error != CSS_OK)
- goto cleanup;
-
- state->node_data = NULL;
+ *node_bloom = bloom;
return CSS_OK;
@@ -662,6 +649,37 @@ cleanup:
return error;
}
+/**
+ * Set a node's data
+ *
+ * \param parent Node to set node data for
+ * \param handler Dispatch table of handler functions
+ * \param pw Client-specific private data for handler functions
+ * \return CSS_OK on success, appropriate error otherwise.
+ */
+static css_error css__set_node_data(void *node, css_select_state *state,
+ css_select_handler *handler, void *pw)
+{
+ css_error error;
+ css_bloom *bloom;
+
+ /* Set node bloom filter */
+ error = css__create_node_bloom(&bloom, state);
+ if (error != CSS_OK) {
+ return error;
+ }
+ state->node_data->bloom = bloom;
+
+ error = handler->set_libcss_node_data(pw, node, state->node_data);
+ if (error != CSS_OK) {
+ return error;
+ }
+
+ state->node_data = NULL;
+
+ return CSS_OK;
+}
+
/**
* Select a style for the given node
commitdiff
http://git.netsurf-browser.org/libcss.git/commit/?id=f63f74900accbe9faa53b6123352cbcfb07ec8d5
commit f63f74900accbe9faa53b6123352cbcfb07ec8d5
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
Allow more than just bloom to be stored on nodes.
We now have a css_node_data struct which is sored on nodes.
It currently contians just the bloom filter.
diff --git a/src/select/select.c b/src/select/select.c
index f2baf0f..ee7fd7f 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -154,15 +154,41 @@ static void dump_chain(const css_selector *selector);
#endif
+static css_error css__create_node_data(struct css_node_data **node_data)
+{
+ struct css_node_data *nd;
+
+ nd = calloc(sizeof(struct css_node_data), 1);
+ if (nd == NULL) {
+ return CSS_NOMEM;
+ }
+
+ *node_data = nd;
+
+ return CSS_OK;
+}
+
+static void css__destroy_node_data(struct css_node_data *node_data)
+{
+ assert(node_data != NULL);
+
+ if (node_data->bloom != NULL) {
+ free(node_data->bloom);
+ }
+
+ free(node_data);
+}
+
+
/* Exported function documented in public select.h header. */
css_error css_libcss_node_data_handler(css_select_handler *handler,
css_node_data_action action, void *pw, void *node,
void *clone_node, void *libcss_node_data)
{
- css_bloom *bloom = libcss_node_data;
- css_bloom *clone_bloom = NULL;
+ struct css_node_data *node_data = libcss_node_data;
css_error error;
- unsigned int i;
+
+ UNUSED(clone_node);
if (handler == NULL || libcss_node_data == NULL ||
handler->handler_version != CSS_SELECT_HANDLER_VERSION_1) {
@@ -171,7 +197,7 @@ css_error css_libcss_node_data_handler(css_select_handler
*handler,
switch (action) {
case CSS_NODE_DELETED:
- free(bloom);
+ css__destroy_node_data(node_data);
break;
case CSS_NODE_MODIFIED:
@@ -180,9 +206,9 @@ css_error css_libcss_node_data_handler(css_select_handler
*handler,
return CSS_BADPARM;
}
- free(bloom);
+ css__destroy_node_data(node_data);
- /* Don't bother rebuilding bloom here, it can be done
+ /* Don't bother rebuilding node_data, it can be done
* when the node is selected for. Just ensure the
* client drops its reference to the libcss_node_data. */
error = handler->set_libcss_node_data(pw, node, NULL);
@@ -192,25 +218,10 @@ css_error css_libcss_node_data_handler(css_select_handler
*handler,
break;
case CSS_NODE_CLONED:
- if (node == NULL || clone_node == NULL) {
- return CSS_BADPARM;
- }
-
- clone_bloom = malloc(sizeof(css_bloom) * CSS_BLOOM_SIZE);
- if (clone_bloom == NULL) {
- return CSS_NOMEM;
- }
-
- for (i = 0; i < CSS_BLOOM_SIZE; i++) {
- clone_bloom[i] = bloom[i];
- }
-
- error = handler->set_libcss_node_data(pw, clone_node,
- clone_bloom);
- if (error != CSS_OK) {
- free(clone_bloom);
- return error;
- }
+ /* TODO: is it worth cloning libcss data? We only store
+ * data on the nodes as an optimisation, which is
+ * unlikely to be valid for most cloning cases.
+ */
break;
default:
@@ -484,6 +495,7 @@ css_error css_select_default_style(css_select_ctx *ctx,
return CSS_OK;
}
+
/**
* Get a bloom filter for the parent node
*
@@ -500,18 +512,25 @@ static css_error css__get_parent_bloom(void *parent,
css_select_handler *handler, void *pw,
css_bloom **parent_bloom)
{
- css_error error;
+ struct css_node_data *node_data = NULL;
css_bloom *bloom = NULL;
+ css_error error;
/* Get parent node's bloom filter */
if (parent != NULL) {
/* Get parent bloom filter */
- /* Hideous casting to avoid warnings on all platforms
- * we build for. */
+ struct css_node_data *node_data;
+
+ /* Hideous casting to avoid warnings on all platforms
+ * we build for. */
error = handler->get_libcss_node_data(pw, parent,
- (void **) (void *) &bloom);
- if (error != CSS_OK)
+ (void **) (void *) &node_data);
+ if (error != CSS_OK) {
return error;
+ }
+ if (node_data != NULL) {
+ bloom = node_data->bloom;
+ }
}
if (bloom == NULL) {
@@ -534,12 +553,21 @@ static css_error css__get_parent_bloom(void *parent,
bloom[i] = ~0;
}
- /* Set parent node bloom filter */
- error = handler->set_libcss_node_data(pw,
- parent, bloom);
- if (error != CSS_OK) {
- free(bloom);
- return error;
+ if (node_data == NULL) {
+ error = css__create_node_data(&node_data);
+ if (error != CSS_OK) {
+ free(bloom);
+ return error;
+ }
+ node_data->bloom = bloom;
+
+ /* Set parent node bloom filter */
+ error = handler->set_libcss_node_data(pw,
+ parent, node_data);
+ if (error != CSS_OK) {
+ css__destroy_node_data(node_data);
+ return error;
+ }
}
} else {
/* No ancestors; empty bloom filter */
@@ -554,14 +582,14 @@ static css_error css__get_parent_bloom(void *parent,
}
/**
- * Set a node's bloom filter
+ * Set a node's data
*
- * \param parent Node to set bloom filter for
+ * \param parent Node to set node data for
* \param handler Dispatch table of handler functions
* \param pw Client-specific private data for handler functions
* \return CSS_OK on success, appropriate error otherwise.
*/
-static css_error css__set_node_bloom(void *node, css_select_state *state,
+static css_error css__set_node_data(void *node, css_select_state *state,
css_select_handler *handler, void *pw)
{
css_error error;
@@ -616,13 +644,16 @@ static css_error css__set_node_bloom(void *node,
css_select_state *state,
}
/* Merge parent bloom into node bloom */
- css_bloom_merge(state->bloom, bloom);
+ css_bloom_merge(state->node_data->bloom, bloom);
+ state->node_data->bloom = bloom;
/* Set node bloom filter */
- error = handler->set_libcss_node_data(pw, node, bloom);
+ error = handler->set_libcss_node_data(pw, node, state->node_data);
if (error != CSS_OK)
goto cleanup;
+ state->node_data = NULL;
+
return CSS_OK;
cleanup:
@@ -676,6 +707,7 @@ css_error css_select_style(css_select_ctx *ctx, void *node,
state.media = media;
state.handler = handler;
state.pw = pw;
+ state.node_data = NULL;
state.next_reject = state.reject_cache +
(N_ELEMENTS(state.reject_cache) - 1);
@@ -695,6 +727,11 @@ css_error css_select_style(css_select_ctx *ctx, void *node,
return error;
}
+ error = css__create_node_data(&state.node_data);
+ if (error != CSS_OK) {
+ goto cleanup;
+ }
+
error = handler->parent_node(pw, node, &parent);
if (error != CSS_OK)
goto cleanup;
@@ -703,7 +740,7 @@ css_error css_select_style(css_select_ctx *ctx, void *node,
if (error != CSS_OK) {
goto cleanup;
}
- state.bloom = parent_bloom;
+ state.node_data->bloom = parent_bloom;
/* Get node's name */
error = handler->node_name(pw, node, &state.element);
@@ -854,7 +891,7 @@ css_error css_select_style(css_select_ctx *ctx, void *node,
}
}
- error = css__set_node_bloom(node, &state, handler, pw);
+ error = css__set_node_data(node, &state, handler, pw);
if (error != CSS_OK) {
goto cleanup;
}
@@ -876,6 +913,10 @@ cleanup:
free(parent_bloom);
}
+ if (state.node_data != NULL) {
+ css__destroy_node_data(state.node_data);
+ }
+
if (state.classes != NULL) {
for (i = 0; i < state.n_classes; i++)
lwc_string_unref(state.classes[i]);
@@ -1649,7 +1690,7 @@ css_error match_selectors_in_sheet(css_select_ctx *ctx,
/* Set up general selector chain requirments */
req.media = state->media;
- req.node_bloom = state->bloom;
+ req.node_bloom = state->node_data->bloom;
req.uni = ctx->universal;
/* Find hash chain that applies to current node */
diff --git a/src/select/select.h b/src/select/select.h
index fad86ac..196914d 100644
--- a/src/select/select.h
+++ b/src/select/select.h
@@ -31,6 +31,10 @@ typedef struct prop_state {
inherit : 1; /* Property is set to inherit */
} prop_state;
+struct css_node_data {
+ css_bloom *bloom;
+};
+
/**
* Selection state
*/
@@ -58,7 +62,7 @@ typedef struct css_select_state {
reject_item reject_cache[128]; /* Reject cache (filled from end) */
reject_item *next_reject; /* Next free slot in reject cache */
- const css_bloom *bloom; /* Bloom filter */
+ struct css_node_data *node_data; /* Data we'll store on node */
prop_state props[CSS_N_PROPERTIES][CSS_PSEUDO_ELEMENT_COUNT];
} css_select_state;
commitdiff
http://git.netsurf-browser.org/libcss.git/commit/?id=7688ce3ff33b5b2818d20bcaa4a4ccab4eddbfb8
commit 7688ce3ff33b5b2818d20bcaa4a4ccab4eddbfb8
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>
Split bloom filter get/set out into helpers.
diff --git a/src/select/select.c b/src/select/select.c
index 617f53f..f2baf0f 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -484,6 +484,153 @@ css_error css_select_default_style(css_select_ctx *ctx,
return CSS_OK;
}
+/**
+ * Get a bloom filter for the parent node
+ *
+ * \param parent Parent node to get bloom filter for
+ * \param handler Dispatch table of handler functions
+ * \param pw Client-specific private data for handler functions
+ * \param parent_bloom Updated to parent bloom to use.
+ * Note: if there's no parent, the caller must free
+ * the returned parent bloom, since it has no node to
+ * own it.
+ * \return CSS_OK on success, appropriate error otherwise.
+ */
+static css_error css__get_parent_bloom(void *parent,
+ css_select_handler *handler, void *pw,
+ css_bloom **parent_bloom)
+{
+ css_error error;
+ css_bloom *bloom = NULL;
+
+ /* Get parent node's bloom filter */
+ if (parent != NULL) {
+ /* Get parent bloom filter */
+ /* Hideous casting to avoid warnings on all platforms
+ * we build for. */
+ error = handler->get_libcss_node_data(pw, parent,
+ (void **) (void *) &bloom);
+ if (error != CSS_OK)
+ return error;
+ }
+
+ if (bloom == NULL) {
+ uint32_t i;
+ /* Need to create parent bloom */
+
+ /* TODO:
+ * Build & set the parent node's bloom properly. This will
+ * speed up the case where DOM change has caused bloom to get
+ * deleted. For now we fall back to a fully satruated bloom
+ * filter, which is slower but perfectly valid.
+ */
+ bloom = malloc(sizeof(css_bloom) * CSS_BLOOM_SIZE);
+ if (bloom == NULL) {
+ return CSS_NOMEM;
+ }
+ if (parent != NULL) {
+ /* Have to make up fully saturated bloom filter */
+ for (i = 0; i < CSS_BLOOM_SIZE; i++) {
+ bloom[i] = ~0;
+ }
+
+ /* Set parent node bloom filter */
+ error = handler->set_libcss_node_data(pw,
+ parent, bloom);
+ if (error != CSS_OK) {
+ free(bloom);
+ return error;
+ }
+ } else {
+ /* No ancestors; empty bloom filter */
+ for (i = 0; i < CSS_BLOOM_SIZE; i++) {
+ bloom[i] = 0;
+ }
+ }
+ }
+
+ *parent_bloom = bloom;
+ return CSS_OK;
+}
+
+/**
+ * Set a node's bloom filter
+ *
+ * \param parent Node to set bloom filter for
+ * \param handler Dispatch table of handler functions
+ * \param pw Client-specific private data for handler functions
+ * \return CSS_OK on success, appropriate error otherwise.
+ */
+static css_error css__set_node_bloom(void *node, css_select_state *state,
+ css_select_handler *handler, void *pw)
+{
+ css_error error;
+ css_bloom *bloom;
+
+ /* Create the node's bloom */
+ bloom = calloc(sizeof(css_bloom), CSS_BLOOM_SIZE);
+ if (bloom == NULL) {
+ return CSS_NOMEM;
+ }
+
+ /* 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;
+ }
+ }
+ css_bloom_add_hash(bloom, lwc_string_hash_value(
+ state->element.name->insensitive));
+
+ /* Add id name to bloom */
+ if (state->id != NULL) {
+ lwc_string *id = state->id;
+ if (id->insensitive == NULL) {
+ if (lwc__intern_caseless_string(id) != lwc_error_ok) {
+ error = CSS_NOMEM;
+ goto cleanup;
+ }
+ }
+ css_bloom_add_hash(bloom, lwc_string_hash_value(
+ id->insensitive));
+ }
+
+ /* Add class names to bloom */
+ if (state->classes != NULL) {
+ lwc_string *s;
+ uint32_t i;
+ 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;
+ }
+ }
+ css_bloom_add_hash(bloom, lwc_string_hash_value(
+ s->insensitive));
+ }
+ }
+
+ /* Merge parent bloom into node bloom */
+ css_bloom_merge(state->bloom, bloom);
+
+ /* Set node bloom filter */
+ error = handler->set_libcss_node_data(pw, node, bloom);
+ if (error != CSS_OK)
+ goto cleanup;
+
+ return CSS_OK;
+
+cleanup:
+ free(bloom);
+
+ return error;
+}
+
/**
* Select a style for the given node
@@ -515,10 +662,9 @@ css_error css_select_style(css_select_ctx *ctx, void *node,
uint32_t i, j, nhints;
css_error error;
css_select_state state;
- void *parent = NULL;
- css_hint *hints = NULL;
- css_bloom *bloom = NULL;
css_bloom *parent_bloom = NULL;
+ css_hint *hints = NULL;
+ void *parent = NULL;
if (ctx == NULL || node == NULL || result == NULL || handler == NULL ||
handler->handler_version != CSS_SELECT_HANDLER_VERSION_1)
@@ -549,56 +695,15 @@ css_error css_select_style(css_select_ctx *ctx, void
*node,
return error;
}
- /* Create the node's bloom */
- bloom = calloc(sizeof(css_bloom), CSS_BLOOM_SIZE);
- if (bloom == NULL) {
- error = CSS_NOMEM;
- goto cleanup;
- }
-
error = handler->parent_node(pw, node, &parent);
if (error != CSS_OK)
goto cleanup;
- /* Get parent node's bloom filter */
- if (parent != NULL) {
- /* Get parent bloom filter */
- /* Hideous casting to avoid warnings on all platforms
- * we build for. */
- error = handler->get_libcss_node_data(pw, parent,
- (void **) (void *) &state.bloom);
- if (error != CSS_OK)
- goto cleanup;
- /* TODO:
- * If state.bloom == NULL, build & set parent node's bloom,
- * and use it as state.bloom. This will speed up the case
- * where DOM change has caused bloom to get deleted.
- * For now we fall back to a fully satruated bloom filter,
- * which is slower but perfectly valid.
- */
- }
-
- if (state.bloom == NULL) {
- /* Need to create parent bloom */
- parent_bloom = malloc(sizeof(css_bloom) * CSS_BLOOM_SIZE);
- if (parent_bloom == NULL) {
- error = CSS_NOMEM;
- goto cleanup;
- }
- if (parent != NULL) {
- /* Have to make up fully saturated bloom filter */
- for (i = 0; i < CSS_BLOOM_SIZE; i++) {
- parent_bloom[i] = ~0;
- }
- } else {
- /* Empty bloom filter */
- for (i = 0; i < CSS_BLOOM_SIZE; i++) {
- parent_bloom[i] = 0;
- }
- }
-
- state.bloom = parent_bloom;
+ error = css__get_parent_bloom(parent, handler, pw, &parent_bloom);
+ if (error != CSS_OK) {
+ goto cleanup;
}
+ state.bloom = parent_bloom;
/* Get node's name */
error = handler->node_name(pw, node, &state.element);
@@ -749,56 +854,10 @@ 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;
- }
- }
- css_bloom_add_hash(bloom, lwc_string_hash_value(
- state.element.name->insensitive));
-
- /* 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;
- }
- }
- css_bloom_add_hash(bloom, lwc_string_hash_value(
- state.id->insensitive));
- }
-
- /* 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;
- }
- }
- css_bloom_add_hash(bloom, lwc_string_hash_value(
- s->insensitive));
- }
- }
-
- /* Merge parent bloom into node bloom */
- css_bloom_merge(state.bloom, bloom);
-
- /* Set node bloom filter */
- error = handler->set_libcss_node_data(pw, node, bloom);
- if (error != CSS_OK)
+ error = css__set_node_bloom(node, &state, handler, pw);
+ if (error != CSS_OK) {
goto cleanup;
-
- bloom = NULL;
+ }
*result = state.results;
error = CSS_OK;
@@ -811,14 +870,12 @@ cleanup:
css_select_results_destroy(state.results);
}
- if (parent_bloom != NULL) {
+ /* If there's no parent, the parent_bloom is not owned by any node,
+ * so we need to free it. */
+ if (parent == NULL) {
free(parent_bloom);
}
- if (bloom != NULL) {
- free(bloom);
- }
-
if (state.classes != NULL) {
for (i = 0; i < state.n_classes; i++)
lwc_string_unref(state.classes[i]);
-----------------------------------------------------------------------
Summary of changes:
--
Cascading Style Sheets library
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org