summaryrefslogtreecommitdiff
path: root/src/select
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@netsurf-browser.org>2010-03-27 16:10:57 +0000
committerDaniel Silverstone <dsilvers@netsurf-browser.org>2010-03-27 16:10:57 +0000
commit80cfe125983eb126a9f8afd974196cf0bf347877 (patch)
treee6fe993a7ad2fc6859509b661d2d4f721e846e60 /src/select
parent46e3a946d7b2f7d68f3753a37c6f68a732a36f01 (diff)
downloadlibcss-80cfe125983eb126a9f8afd974196cf0bf347877.tar.gz
libcss-80cfe125983eb126a9f8afd974196cf0bf347877.tar.bz2
Fix libcss to use new libwapcaplet behaviour.
TODO: update the tests to include a refcounting proof svn path=/trunk/libcss/; revision=10162
Diffstat (limited to 'src/select')
-rw-r--r--src/select/hash.c27
-rw-r--r--src/select/hash.h3
-rw-r--r--src/select/select.c80
3 files changed, 40 insertions, 70 deletions
diff --git a/src/select/hash.c b/src/select/hash.c
index de01ca3..ed956a0 100644
--- a/src/select/hash.c
+++ b/src/select/hash.c
@@ -33,8 +33,6 @@ struct css_selector_hash {
hash_entry universal;
- lwc_context *ctx;
-
size_t hash_size;
css_allocator_fn alloc;
@@ -67,19 +65,17 @@ static css_error _iterate_universal(css_selector_hash *hash,
/**
* Create a hash
*
- * \param dict Dictionary containing interned strings
* \param alloc Memory (de)allocation function
* \param pw Pointer to client-specific private data
* \param hash Pointer to location to receive result
* \return CSS_OK on success, appropriate error otherwise
*/
-css_error css_selector_hash_create(lwc_context *dict,
- css_allocator_fn alloc, void *pw,
+css_error css_selector_hash_create(css_allocator_fn alloc, void *pw,
css_selector_hash **hash)
{
css_selector_hash *h;
- if (dict == NULL || alloc == NULL || hash == NULL)
+ if (alloc == NULL || hash == NULL)
return CSS_BADPARM;
h = alloc(0, sizeof(css_selector_hash), pw);
@@ -124,7 +120,6 @@ css_error css_selector_hash_create(lwc_context *dict,
DEFAULT_SLOTS * sizeof(hash_entry) +
DEFAULT_SLOTS * sizeof(hash_entry);
- h->ctx = lwc_context_ref(dict);
h->alloc = alloc;
h->pw = pw;
@@ -184,8 +179,6 @@ css_error css_selector_hash_destroy(css_selector_hash *hash)
hash->alloc(d, 0, hash->pw);
}
- lwc_context_unref(hash->ctx);
-
hash->alloc(hash, 0, hash->pw);
return CSS_OK;
@@ -321,7 +314,7 @@ css_error css_selector_hash_find(css_selector_hash *hash,
lwc_error lerror;
bool match = false;
- lerror = lwc_context_string_caseless_isequal(hash->ctx,
+ lerror = lwc_string_caseless_isequal(
name, head->sel->data.name, &match);
if (lerror != lwc_error_ok)
return css_error_from_lwc_error(lerror);
@@ -379,8 +372,8 @@ css_error css_selector_hash_find_by_class(css_selector_hash *hash,
n = _class_name(head->sel);
if (n != NULL) {
- lerror = lwc_context_string_caseless_isequal(
- hash->ctx, name, n, &match);
+ lerror = lwc_string_caseless_isequal(
+ name, n, &match);
if (lerror != lwc_error_ok)
return css_error_from_lwc_error(lerror);
@@ -438,8 +431,8 @@ css_error css_selector_hash_find_by_id(css_selector_hash *hash,
n = _id_name(head->sel);
if (n != NULL) {
- lerror = lwc_context_string_caseless_isequal(
- hash->ctx, name, n, &match);
+ lerror = lwc_string_caseless_isequal(
+ name, n, &match);
if (lerror != lwc_error_ok)
return css_error_from_lwc_error(lerror);
@@ -713,7 +706,7 @@ css_error _iterate_elements(css_selector_hash *hash,
lwc_error lerror = lwc_error_ok;
bool match = false;
- lerror = lwc_context_string_caseless_isequal(hash->ctx,
+ lerror = lwc_string_caseless_isequal(
name, head->sel->data.name, &match);
if (lerror != lwc_error_ok)
return css_error_from_lwc_error(lerror);
@@ -762,7 +755,7 @@ css_error _iterate_classes(css_selector_hash *hash,
if (name == NULL)
continue;
- lerror = lwc_context_string_caseless_isequal(hash->ctx,
+ lerror = lwc_string_caseless_isequal(
ref, name, &match);
if (lerror != lwc_error_ok)
return css_error_from_lwc_error(lerror);
@@ -811,7 +804,7 @@ css_error _iterate_ids(css_selector_hash *hash,
if (name == NULL)
continue;
- lerror = lwc_context_string_caseless_isequal(hash->ctx,
+ lerror = lwc_string_caseless_isequal(
ref, name, &match);
if (lerror != lwc_error_ok)
return css_error_from_lwc_error(lerror);
diff --git a/src/select/hash.h b/src/select/hash.h
index e705554..e1f2542 100644
--- a/src/select/hash.h
+++ b/src/select/hash.h
@@ -22,8 +22,7 @@ typedef css_error (*css_selector_hash_iterator)(css_selector_hash *hash,
const struct css_selector **current,
const struct css_selector ***next);
-css_error css_selector_hash_create(lwc_context *dict,
- css_allocator_fn alloc, void *pw,
+css_error css_selector_hash_create(css_allocator_fn alloc, void *pw,
css_selector_hash **hash);
css_error css_selector_hash_destroy(css_selector_hash *hash);
diff --git a/src/select/select.c b/src/select/select.c
index 7898d60..abf4099 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -389,49 +389,27 @@ css_error css_select_style(css_select_ctx *ctx, void *node,
cleanup:
if (ctx->n_sheets > 0 && ctx->sheets[0].sheet != NULL) {
if (state.universal != NULL)
- lwc_context_string_unref(
- ctx->sheets[0].sheet->dictionary,
- state.universal);
+ lwc_string_unref(state.universal);
if (state.first_child != NULL)
- lwc_context_string_unref(
- ctx->sheets[0].sheet->dictionary,
- state.first_child);
+ lwc_string_unref(state.first_child);
if (state.link != NULL)
- lwc_context_string_unref(
- ctx->sheets[0].sheet->dictionary,
- state.link);
+ lwc_string_unref(state.link);
if (state.visited != NULL)
- lwc_context_string_unref(
- ctx->sheets[0].sheet->dictionary,
- state.visited);
+ lwc_string_unref(state.visited);
if (state.hover != NULL)
- lwc_context_string_unref(
- ctx->sheets[0].sheet->dictionary,
- state.hover);
+ lwc_string_unref(state.hover);
if (state.active != NULL)
- lwc_context_string_unref(
- ctx->sheets[0].sheet->dictionary,
- state.active);
+ lwc_string_unref(state.active);
if (state.focus != NULL)
- lwc_context_string_unref(
- ctx->sheets[0].sheet->dictionary,
- state.focus);
+ lwc_string_unref(state.focus);
if (state.first_line != NULL)
- lwc_context_string_unref(
- ctx->sheets[0].sheet->dictionary,
- state.first_line);
+ lwc_string_unref(state.first_line);
if (state.first_letter != NULL)
- lwc_context_string_unref(
- ctx->sheets[0].sheet->dictionary,
- state.first_letter);
+ lwc_string_unref(state.first_letter);
if (state.before != NULL)
- lwc_context_string_unref(
- ctx->sheets[0].sheet->dictionary,
- state.before);
+ lwc_string_unref(state.before);
if (state.after != NULL)
- lwc_context_string_unref(
- ctx->sheets[0].sheet->dictionary,
- state.after);
+ lwc_string_unref(state.after);
}
return error;
}
@@ -574,73 +552,73 @@ css_error intern_strings_for_sheet(css_select_ctx *ctx,
lwc_error error;
UNUSED(ctx);
+ UNUSED(sheet);
/* Universal selector */
if (state->universal != NULL)
return CSS_OK;
- error = lwc_context_intern(sheet->dictionary,
- "*", SLEN("*"), &state->universal);
+ error = lwc_intern_string("*", SLEN("*"), &state->universal);
if (error != lwc_error_ok)
return css_error_from_lwc_error(error);
/* Pseudo classes */
- error = lwc_context_intern(sheet->dictionary,
+ error = lwc_intern_string(
"first-child", SLEN("first-child"),
&state->first_child);
if (error != lwc_error_ok)
return css_error_from_lwc_error(error);
- error = lwc_context_intern(sheet->dictionary,
+ error = lwc_intern_string(
"link", SLEN("link"),
&state->link);
if (error != lwc_error_ok)
return css_error_from_lwc_error(error);
- error = lwc_context_intern(sheet->dictionary,
+ error = lwc_intern_string(
"visited", SLEN("visited"),
&state->visited);
if (error != lwc_error_ok)
return css_error_from_lwc_error(error);
- error = lwc_context_intern(sheet->dictionary,
+ error = lwc_intern_string(
"hover", SLEN("hover"),
&state->hover);
if (error != lwc_error_ok)
return css_error_from_lwc_error(error);
- error = lwc_context_intern(sheet->dictionary,
+ error = lwc_intern_string(
"active", SLEN("active"),
&state->active);
if (error != lwc_error_ok)
return css_error_from_lwc_error(error);
- error = lwc_context_intern(sheet->dictionary,
+ error = lwc_intern_string(
"focus", SLEN("focus"),
&state->focus);
if (error != lwc_error_ok)
return css_error_from_lwc_error(error);
/* Pseudo elements */
- error = lwc_context_intern(sheet->dictionary,
+ error = lwc_intern_string(
"first-line", SLEN("first-line"),
&state->first_line);
if (error != lwc_error_ok)
return css_error_from_lwc_error(error);
- error = lwc_context_intern(sheet->dictionary,
+ error = lwc_intern_string(
"first_letter", SLEN("first-letter"),
&state->first_letter);
if (error != lwc_error_ok)
return css_error_from_lwc_error(error);
- error = lwc_context_intern(sheet->dictionary,
+ error = lwc_intern_string(
"before", SLEN("before"),
&state->before);
if (error != lwc_error_ok)
return css_error_from_lwc_error(error);
- error = lwc_context_intern(sheet->dictionary,
+ error = lwc_intern_string(
"after", SLEN("after"),
&state->after);
if (error != lwc_error_ok)
@@ -742,13 +720,13 @@ css_error match_selectors_in_sheet(css_select_ctx *ctx,
/* Get node's name */
error = state->handler->node_name(state->pw, state->node,
- sheet->dictionary, &element);
+ &element);
if (error != CSS_OK)
return error;
/* Get node's ID, if any */
error = state->handler->node_id(state->pw, state->node,
- sheet->dictionary, &id);
+ &id);
if (error != CSS_OK)
goto cleanup;
@@ -757,7 +735,7 @@ css_error match_selectors_in_sheet(css_select_ctx *ctx,
* every time we call this? It seems hugely inefficient, given they can
* cache the data. */
error = state->handler->node_classes(state->pw, state->node,
- sheet->dictionary, &classes, &n_classes);
+ &classes, &n_classes);
if (error != CSS_OK)
goto cleanup;
@@ -870,15 +848,15 @@ cleanup:
if (classes != NULL) {
for (i = 0; i < n_classes; i++)
- lwc_context_string_unref(sheet->dictionary, classes[i]);
+ lwc_string_unref(classes[i]);
ctx->alloc(classes, 0, ctx->pw);
}
if (id != NULL)
- lwc_context_string_unref(sheet->dictionary, id);
+ lwc_string_unref(id);
- lwc_context_string_unref(sheet->dictionary, element);
+ lwc_string_unref(element);
return error;
}