summaryrefslogtreecommitdiff
path: root/css
diff options
context:
space:
mode:
Diffstat (limited to 'css')
-rw-r--r--css/css.c434
-rw-r--r--css/css.h20
-rw-r--r--css/internal.c7
-rw-r--r--css/internal.h4
-rw-r--r--css/select.c43
-rw-r--r--css/select.h2
6 files changed, 241 insertions, 269 deletions
diff --git a/css/css.c b/css/css.c
index cf8902037..473ea488a 100644
--- a/css/css.c
+++ b/css/css.c
@@ -20,17 +20,18 @@
#include <libwapcaplet/libwapcaplet.h>
-#include "content/content.h"
+#include "content/content_protected.h"
#include "content/fetch.h"
-#include "content/fetchcache.h"
+#include "content/hlcache.h"
#include "css/css.h"
#include "css/internal.h"
#include "desktop/gui.h"
#include "render/html.h"
+#include "utils/http.h"
#include "utils/messages.h"
-static void nscss_import(content_msg msg, struct content *c,
- intptr_t p1, intptr_t p2, union content_msg_data data);
+static nserror nscss_import(hlcache_handle *handle,
+ const hlcache_event *event, void *pw);
/**
* Allocation callback for libcss
@@ -49,125 +50,63 @@ static void *myrealloc(void *ptr, size_t size, void *pw)
* Initialise a CSS content
*
* \param c Content to initialise
- * \param parent Parent content, or NULL if top-level
* \param params Content-Type parameters
* \return true on success, false on failure
*/
-bool nscss_create(struct content *c, struct content *parent,
- const char *params[])
+bool nscss_create(struct content *c, const http_parameter *params)
{
const char *charset = NULL;
- css_origin origin = CSS_ORIGIN_AUTHOR;
- uint64_t media = CSS_MEDIA_ALL;
- lwc_context *dict = NULL;
- bool quirks = true;
- uint32_t i;
union content_msg_data msg_data;
- css_error error;
+ nserror error;
/** \todo what happens about the allocator? */
/** \todo proper error reporting */
/* Find charset specified on HTTP layer, if any */
- /** \todo What happens if there isn't one and parent content exists? */
- for (i = 0; params[i] != NULL; i += 2) {
- if (strcasecmp(params[i], "charset") == 0) {
- charset = params[i + 1];
- break;
- }
+ error = http_parameter_list_find_item(params, "charset", &charset);
+ if (error != NSERROR_OK) {
+ /* No charset specified, use fallback, if any */
+ /** \todo libcss will take this as gospel, which is wrong */
+ charset = c->fallback_charset;
}
- if (parent != NULL) {
- assert(parent->type == CONTENT_HTML ||
- parent->type == CONTENT_CSS);
-
- if (parent->type == CONTENT_HTML) {
- assert(parent->data.html.dict != NULL);
-
- if (c == parent->data.html.
- stylesheets[STYLESHEET_BASE].c ||
- c == parent->data.html.
- stylesheets[STYLESHEET_QUIRKS].c ||
- c == parent->data.html.
- stylesheets[STYLESHEET_ADBLOCK].c)
- origin = CSS_ORIGIN_UA;
-
- quirks = (parent->data.html.quirks !=
- BINDING_QUIRKS_MODE_NONE);
-
- for (i = 0; i < parent->data.html.stylesheet_count;
- i++) {
- if (parent->data.html.stylesheets[i].c == c) {
- media = parent->data.html.
- stylesheets[i].media;
- break;
- }
- }
-
- dict = parent->data.html.dict;
- } else {
- assert(parent->data.css.sheet != NULL);
- assert(parent->data.css.dict != NULL);
-
- error = css_stylesheet_get_origin(
- parent->data.css.sheet, &origin);
- if (error != CSS_OK) {
- msg_data.error = "?";
- content_broadcast(c, CONTENT_MSG_ERROR,
- msg_data);
- return false;
- }
-
- error = css_stylesheet_quirks_allowed(
- parent->data.css.sheet, &quirks);
- if (error != CSS_OK) {
- msg_data.error = "?";
- content_broadcast(c, CONTENT_MSG_ERROR,
- msg_data);
- return false;
- }
-
- for (i = 0; i < parent->data.css.import_count; i++) {
- if (parent->data.css.imports[i].c == c) {
- media = parent->data.css.
- imports[i].media;
- break;
- }
- }
-
- dict = parent->data.css.dict;
- }
+ if (nscss_create_css_data(&c->data.css, content__get_url(c),
+ charset, c->quirks) != NSERROR_OK) {
+ msg_data.error = messages_get("NoMemory");
+ content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
+ return false;
}
- if (dict == NULL) {
- lwc_error lerror = lwc_create_context(myrealloc, NULL, &dict);
+ return true;
+}
- if (lerror != lwc_error_ok) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
- return false;
- }
- }
+/**
+ * Create a struct content_css_data, creating a stylesheet object
+ *
+ * \param c Struct to populate
+ * \param url URL of stylesheet
+ * \param charset Stylesheet charset
+ * \param quirks Stylesheet quirks mode
+ * \return NSERROR_OK on success, NSERROR_NOMEM on memory exhaustion
+ */
+nserror nscss_create_css_data(struct content_css_data *c,
+ const char *url, const char *charset, bool quirks)
+{
+ css_error error;
- c->data.css.dict = lwc_context_ref(dict);
- c->data.css.import_count = 0;
- c->data.css.imports = NULL;
+ c->import_count = 0;
+ c->imports = NULL;
error = css_stylesheet_create(CSS_LEVEL_21, charset,
- c->url, NULL, origin, media, quirks, false,
- c->data.css.dict,
+ url, NULL, quirks, false,
myrealloc, NULL,
nscss_resolve_url, NULL,
- &c->data.css.sheet);
+ &c->sheet);
if (error != CSS_OK) {
- lwc_context_unref(c->data.css.dict);
- c->data.css.dict = NULL;
- msg_data.error = messages_get("NoMemory");
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
- return false;
+ return NSERROR_NOMEM;
}
- return true;
+ return NSERROR_OK;
}
/**
@@ -183,9 +122,7 @@ bool nscss_process_data(struct content *c, char *data, unsigned int size)
union content_msg_data msg_data;
css_error error;
- error = css_stylesheet_append_data(c->data.css.sheet,
- (const uint8_t *) data, size);
-
+ error = nscss_process_css_data(&c->data.css, data, size);
if (error != CSS_OK && error != CSS_NEEDDATA) {
msg_data.error = "?";
content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
@@ -195,6 +132,21 @@ bool nscss_process_data(struct content *c, char *data, unsigned int size)
}
/**
+ * Process CSS data
+ *
+ * \param c CSS content object
+ * \param data Data to process
+ * \param size Number of bytes to process
+ * \return CSS_OK on success, appropriate error otherwise
+ */
+css_error nscss_process_css_data(struct content_css_data *c, char *data,
+ unsigned int size)
+{
+ return css_stylesheet_append_data(c->sheet,
+ (const uint8_t *) data, size);
+}
+
+/**
* Convert a CSS content ready for use
*
* \param c Content to convert
@@ -209,22 +161,73 @@ bool nscss_convert(struct content *c, int w, int h)
size_t size;
css_error error;
- error = css_stylesheet_data_done(c->data.css.sheet);
+ error = nscss_convert_css_data(&c->data.css, w, h);
+ if (error != CSS_OK) {
+ msg_data.error = "?";
+ content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
+ c->status = CONTENT_STATUS_ERROR;
+ return false;
+ }
+
+ /* Retrieve the size of this sheet */
+ error = css_stylesheet_size(c->data.css.sheet, &size);
+ if (error != CSS_OK) {
+ msg_data.error = "?";
+ content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
+ c->status = CONTENT_STATUS_ERROR;
+ return false;
+ }
+ c->size += size;
+
+ /* Add on the size of the imported sheets */
+ for (i = 0; i < c->data.css.import_count; i++) {
+ struct content *import = hlcache_handle_get_content(
+ c->data.css.imports[i].c);
+
+ if (import != NULL) {
+ c->size += import->size;
+ }
+ }
+
+ c->status = CONTENT_STATUS_DONE;
+
+ return error == CSS_OK;
+}
+
+/**
+ * Convert CSS data ready for use
+ *
+ * \param c CSS data to convert
+ * \param w Width of area content will be displayed in
+ * \param h Height of area content will be displayed in
+ * \return CSS error
+ */
+css_error nscss_convert_css_data(struct content_css_data *c, int w, int h)
+{
+ const char *referer;
+ uint32_t i = 0;
+ css_error error;
+ nserror nerror;
+
+ error = css_stylesheet_get_url(c->sheet, &referer);
+ if (error != CSS_OK) {
+ return error;
+ }
+
+ error = css_stylesheet_data_done(c->sheet);
/* Process pending imports */
while (error == CSS_IMPORTS_PENDING) {
+ hlcache_child_context child;
struct nscss_import *imports;
lwc_string *uri;
uint64_t media;
css_stylesheet *sheet;
- error = css_stylesheet_next_pending_import(c->data.css.sheet,
+ error = css_stylesheet_next_pending_import(c->sheet,
&uri, &media);
if (error != CSS_OK && error != CSS_INVALID) {
- msg_data.error = "?";
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
- c->status = CONTENT_STATUS_ERROR;
- return false;
+ return error;
}
/* Give up if there are no more imports */
@@ -234,111 +237,63 @@ bool nscss_convert(struct content *c, int w, int h)
}
/* Increase space in table */
- imports = realloc(c->data.css.imports,
- (c->data.css.import_count + 1) *
+ imports = realloc(c->imports, (c->import_count + 1) *
sizeof(struct nscss_import));
if (imports == NULL) {
- msg_data.error = "?";
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
- c->status = CONTENT_STATUS_ERROR;
- return false;
+ return CSS_NOMEM;
}
- c->data.css.imports = imports;
+ c->imports = imports;
- /* Create content */
- i = c->data.css.import_count;
- c->data.css.imports[c->data.css.import_count].media = media;
- c->data.css.imports[c->data.css.import_count++].c =
- fetchcache(lwc_string_data(uri),
- nscss_import, (intptr_t) c, i,
- c->width, c->height, true, NULL, NULL,
- false, false);
- if (c->data.css.imports[i].c == NULL) {
- msg_data.error = "?";
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
- c->status = CONTENT_STATUS_ERROR;
- return false;
+ /** \todo fallback charset */
+ child.charset = NULL;
+ error = css_stylesheet_quirks_allowed(c->sheet, &child.quirks);
+ if (error != CSS_OK) {
+ return error;
}
- /* Fetch content */
- c->active++;
- fetchcache_go(c->data.css.imports[i].c, c->url,
- nscss_import, (intptr_t) c, i,
- c->width, c->height, NULL, NULL, false, c);
+ /* Create content */
+ i = c->import_count;
+ c->imports[c->import_count].media = media;
+ nerror = hlcache_handle_retrieve(lwc_string_data(uri),
+ 0, referer, NULL, w, h, nscss_import, c,
+ &child, &c->imports[c->import_count++].c);
+ if (error != NSERROR_OK) {
+ return CSS_NOMEM;
+ }
/* Wait for import to fetch + convert */
- while (c->active > 0) {
+ /** \todo This blocking approach needs to die */
+ while (c->imports[i].c != NULL &&
+ content_get_status(c->imports[i].c) !=
+ CONTENT_STATUS_DONE) {
fetch_poll();
gui_multitask();
}
- if (c->data.css.imports[i].c != NULL) {
- sheet = c->data.css.imports[i].c->data.css.sheet;
- c->data.css.imports[i].c->data.css.sheet = NULL;
+ if (c->imports[i].c != NULL) {
+ struct content *s = hlcache_handle_get_content(
+ c->imports[i].c);
+ sheet = s->data.css.sheet;
} else {
error = css_stylesheet_create(CSS_LEVEL_DEFAULT,
- NULL, "", NULL, CSS_ORIGIN_AUTHOR,
- media, false, false, c->data.css.dict,
+ NULL, "", NULL, false, false,
myrealloc, NULL,
nscss_resolve_url, NULL,
&sheet);
if (error != CSS_OK) {
- msg_data.error = messages_get("NoMemory");
- content_broadcast(c, CONTENT_MSG_ERROR,
- msg_data);
- c->status = CONTENT_STATUS_ERROR;
- return false;
+ return error;
}
}
- error = css_stylesheet_register_import(
- c->data.css.sheet, sheet);
+ error = css_stylesheet_register_import(c->sheet, sheet);
if (error != CSS_OK) {
- msg_data.error = "?";
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
- c->status = CONTENT_STATUS_ERROR;
- return false;
+ return error;
}
error = CSS_IMPORTS_PENDING;
}
- /* Retrieve the size of this sheet */
- error = css_stylesheet_size(c->data.css.sheet, &size);
- if (error != CSS_OK) {
- msg_data.error = "?";
- content_broadcast(c, CONTENT_MSG_ERROR, msg_data);
- c->status = CONTENT_STATUS_ERROR;
- return false;
- }
- c->size += size;
-
- /* Add on the size of the imported sheets, removing ourselves from
- * their user list as we go (they're of no use to us now, as we've
- * inserted the sheet into ourselves) */
- for (i = 0; i < c->data.css.import_count; i++) {
- if (c->data.css.imports[i].c != NULL) {
- c->size += c->data.css.imports[i].c->size;
-
- content_remove_user(c->data.css.imports[i].c,
- nscss_import, (uintptr_t) c, i);
- }
-
- c->data.css.imports[i].c = NULL;
- }
-
- /* Remove the imports */
- c->data.css.import_count = 0;
- free(c->data.css.imports);
- c->data.css.imports = NULL;
-
- c->status = CONTENT_STATUS_DONE;
-
- /* Filthy hack to stop this content being reused
- * when whatever is using it has finished with it. */
- c->fresh = false;
-
- return error == CSS_OK;
+ return error;
}
/**
@@ -348,80 +303,99 @@ bool nscss_convert(struct content *c, int w, int h)
*/
void nscss_destroy(struct content *c)
{
+ nscss_destroy_css_data(&c->data.css);
+}
+
+/**
+ * Clean up CSS data
+ *
+ * \param c CSS data to clean up
+ */
+void nscss_destroy_css_data(struct content_css_data *c)
+{
uint32_t i;
- for (i = 0; i < c->data.css.import_count; i++) {
- if (c->data.css.imports[i].c != NULL) {
- content_remove_user(c->data.css.imports[i].c,
- nscss_import, (uintptr_t) c, i);
+ for (i = 0; i < c->import_count; i++) {
+ if (c->imports[i].c != NULL) {
+ hlcache_handle_release(c->imports[i].c);
}
- c->data.css.imports[i].c = NULL;
+ c->imports[i].c = NULL;
}
- free(c->data.css.imports);
+ free(c->imports);
- if (c->data.css.sheet != NULL) {
- css_stylesheet_destroy(c->data.css.sheet);
- c->data.css.sheet = NULL;
+ if (c->sheet != NULL) {
+ css_stylesheet_destroy(c->sheet);
+ c->sheet = NULL;
}
+}
- if (c->data.css.dict != NULL) {
- lwc_context_unref(c->data.css.dict);
- c->data.css.dict = NULL;
- }
+/**
+ * Retrieve imported stylesheets
+ *
+ * \param h Stylesheet containing imports
+ * \param n Pointer to location to receive number of imports
+ * \return Pointer to array of imported stylesheets
+ */
+struct nscss_import *nscss_get_imports(hlcache_handle *h, uint32_t *n)
+{
+ struct content *c = hlcache_handle_get_content(h);
+
+ assert(c != NULL);
+ assert(c->type == CONTENT_CSS);
+ assert(n != NULL);
+
+ *n = c->data.css.import_count;
+
+ return c->data.css.imports;
}
/**
- * Fetchcache handler for imported stylesheets
+ * Handler for imported stylesheet events
*
- * \param msg Message type
- * \param c Content being fetched
- * \param p1 Parent content
- * \param p2 Index into parent's imported stylesheet array
- * \param data Message data
+ * \param handle Handle for stylesheet
+ * \param event Event object
+ * \param pw Callback context
+ * \return NSERROR_OK on success, appropriate error otherwise
*/
-void nscss_import(content_msg msg, struct content *c,
- intptr_t p1, intptr_t p2, union content_msg_data data)
+nserror nscss_import(hlcache_handle *handle,
+ const hlcache_event *event, void *pw)
{
- struct content *parent = (struct content *) p1;
- uint32_t i = (uint32_t) p2;
+ struct content_css_data *parent = pw;
+ uint32_t i = 0;
- switch (msg) {
+ switch (event->type) {
case CONTENT_MSG_LOADING:
- if (c->type != CONTENT_CSS) {
- content_remove_user(c, nscss_import, p1, p2);
- if (c->user_list->next == NULL) {
- fetch_abort(c->fetch);
- c->fetch = NULL;
- c->status = CONTENT_STATUS_ERROR;
- }
+ if (content_get_type(handle) != CONTENT_CSS) {
+ hlcache_handle_release(handle);
- parent->data.css.imports[i].c = NULL;
- parent->active--;
- content_add_error(parent, "NotCSS", 0);
+ for (i = 0; i < parent->import_count; i++) {
+ if (parent->imports[i].c == handle) {
+ parent->imports[i].c = NULL;
+ break;
+ }
+ }
}
break;
case CONTENT_MSG_READY:
break;
case CONTENT_MSG_DONE:
- parent->active--;
break;
- case CONTENT_MSG_AUTH:
- case CONTENT_MSG_SSL:
- case CONTENT_MSG_LAUNCH:
case CONTENT_MSG_ERROR:
- if (parent->data.css.imports[i].c == c) {
- parent->data.css.imports[i].c = NULL;
- parent->active--;
+ hlcache_handle_release(handle);
+ for (i = 0; i < parent->import_count; i++) {
+ if (parent->imports[i].c == handle) {
+ parent->imports[i].c = NULL;
+ break;
+ }
}
break;
case CONTENT_MSG_STATUS:
break;
- case CONTENT_MSG_NEWPTR:
- parent->data.css.imports[i].c = c;
- break;
default:
assert(0);
}
+
+ return NSERROR_OK;
}
diff --git a/css/css.h b/css/css.h
index d65de15cf..925b4ae40 100644
--- a/css/css.h
+++ b/css/css.h
@@ -23,7 +23,11 @@
#include <libcss/libcss.h>
+#include "utils/errors.h"
+
struct content;
+struct hlcache_handle;
+struct http_parameter;
struct nscss_import;
/**
@@ -31,8 +35,6 @@ struct nscss_import;
*/
struct content_css_data
{
- lwc_context *dict; /**< Dictionary to intern strings in */
-
css_stylesheet *sheet; /**< Stylesheet object */
uint32_t import_count; /**< Number of sheets imported */
@@ -43,12 +45,11 @@ struct content_css_data
* Imported stylesheet record
*/
struct nscss_import {
- struct content *c; /**< Content containing sheet */
+ struct hlcache_handle *c; /**< Content containing sheet */
uint64_t media; /**< Media types that sheet applies to */
};
-bool nscss_create(struct content *c, struct content *parent,
- const char *params[]);
+bool nscss_create(struct content *c, const struct http_parameter *params);
bool nscss_process_data(struct content *c, char *data, unsigned int size);
@@ -56,5 +57,14 @@ bool nscss_convert(struct content *c, int w, int h);
void nscss_destroy(struct content *c);
+nserror nscss_create_css_data(struct content_css_data *c,
+ const char *url, const char *charset, bool quirks);
+css_error nscss_process_css_data(struct content_css_data *c, char *data,
+ unsigned int size);
+css_error nscss_convert_css_data(struct content_css_data *c, int w, int h);
+void nscss_destroy_css_data(struct content_css_data *c);
+
+struct nscss_import *nscss_get_imports(struct hlcache_handle *h, uint32_t *n);
+
#endif
diff --git a/css/internal.c b/css/internal.c
index b9aa83f0d..4c80e639e 100644
--- a/css/internal.c
+++ b/css/internal.c
@@ -26,7 +26,6 @@
* URL resolution callback for libcss
*
* \param pw Resolution context
- * \param ctx Dictionary to intern result in
* \param base Base URI
* \param rel Relative URL
* \param abs Pointer to location to receive resolved URL
@@ -34,8 +33,8 @@
* CSS_NOMEM on memory exhaustion,
* CSS_INVALID if resolution failed.
*/
-css_error nscss_resolve_url(void *pw, lwc_context *ctx,
- const char *base, lwc_string *rel, lwc_string **abs)
+css_error nscss_resolve_url(void *pw, const char *base,
+ lwc_string *rel, lwc_string **abs)
{
lwc_error lerror;
char *abs_url, *norm_url;
@@ -57,7 +56,7 @@ css_error nscss_resolve_url(void *pw, lwc_context *ctx,
free(abs_url);
/* Intern it */
- lerror = lwc_context_intern(ctx, norm_url, strlen(norm_url), abs);
+ lerror = lwc_intern_string(norm_url, strlen(norm_url), abs);
if (lerror != lwc_error_ok) {
*abs = NULL;
free(norm_url);
diff --git a/css/internal.h b/css/internal.h
index e675a4876..0344d6b32 100644
--- a/css/internal.h
+++ b/css/internal.h
@@ -21,7 +21,7 @@
#include "css/css.h"
-css_error nscss_resolve_url(void *pw, lwc_context *ctx,
- const char *base, lwc_string *rel, lwc_string **abs);
+css_error nscss_resolve_url(void *pw, const char *base,
+ lwc_string *rel, lwc_string **abs);
#endif
diff --git a/css/select.c b/css/select.c
index aeb7d3c58..be95a29c0 100644
--- a/css/select.c
+++ b/css/select.c
@@ -21,7 +21,7 @@
#include <string.h>
#include <strings.h>
-#include "content/content.h"
+#include "content/content_protected.h"
#include "content/urldb.h"
#include "css/internal.h"
#include "css/select.h"
@@ -31,12 +31,10 @@
#include "utils/url.h"
#include "utils/utils.h"
-static css_error node_name(void *pw, void *node,
- lwc_context *dict, lwc_string **name);
+static css_error node_name(void *pw, void *node, lwc_string **name);
static css_error node_classes(void *pw, void *node,
- lwc_context *dict, lwc_string ***classes, uint32_t *n_classes);
-static css_error node_id(void *pw, void *node,
- lwc_context *dict, lwc_string **id);
+ lwc_string ***classes, uint32_t *n_classes);
+static css_error node_id(void *pw, void *node, lwc_string **id);
static css_error named_ancestor_node(void *pw, void *node,
lwc_string *name, void **ancestor);
static css_error named_parent_node(void *pw, void *node,
@@ -125,21 +123,20 @@ static css_select_handler selection_handler = {
* \param charset Charset of data, or NULL if unknown
* \param url URL of document containing data
* \param allow_quirks True to permit CSS parsing quirks
- * \param dict String internment context
* \param alloc Memory allocation function
* \param pw Private word for allocator
* \return Pointer to stylesheet, or NULL on failure.
*/
css_stylesheet *nscss_create_inline_style(const uint8_t *data, size_t len,
const char *charset, const char *url, bool allow_quirks,
- lwc_context *dict, css_allocator_fn alloc, void *pw)
+ css_allocator_fn alloc, void *pw)
{
css_stylesheet *sheet;
css_error error;
error = css_stylesheet_create(CSS_LEVEL_DEFAULT, charset, url, NULL,
- CSS_ORIGIN_AUTHOR, CSS_MEDIA_ALL, allow_quirks, true,
- dict, alloc, pw, nscss_resolve_url, NULL, &sheet);
+ allow_quirks, true, alloc, pw, nscss_resolve_url,
+ NULL, &sheet);
if (error != CSS_OK) {
LOG(("Failed creating sheet: %d", error));
return NULL;
@@ -413,18 +410,16 @@ bool nscss_parse_colour(const char *data, css_color *result)
*
* \param pw HTML document
* \param node DOM node
- * \param dict Dictionary to intern result in
* \param name Pointer to location to receive node name
* \return CSS_OK on success,
* CSS_NOMEM on memory exhaustion.
*/
-css_error node_name(void *pw, void *node,
- lwc_context *dict, lwc_string **name)
+css_error node_name(void *pw, void *node, lwc_string **name)
{
xmlNode *n = node;
lwc_error lerror;
- lerror = lwc_context_intern(dict, (const char *) n->name,
+ lerror = lwc_intern_string((const char *) n->name,
strlen((const char *) n->name), name);
switch (lerror) {
case lwc_error_oom:
@@ -444,7 +439,6 @@ css_error node_name(void *pw, void *node,
*
* \param pw HTML document
* \param node DOM node
- * \param dict Dictionary to intern result in
* \param classes Pointer to location to receive class name array
* \param n_classes Pointer to location to receive length of class name array
* \return CSS_OK on success,
@@ -454,8 +448,8 @@ css_error node_name(void *pw, void *node,
* be allocated using the same allocator as used by libcss during style
* selection.
*/
-css_error node_classes(void *pw, void *node,
- lwc_context *dict, lwc_string ***classes, uint32_t *n_classes)
+css_error node_classes(void *pw, void *node,
+ lwc_string ***classes, uint32_t *n_classes)
{
xmlNode *n = node;
xmlAttr *class;
@@ -503,8 +497,7 @@ css_error node_classes(void *pw, void *node,
}
result = temp;
- lerror = lwc_context_intern(dict, start, p - start,
- &result[items]);
+ lerror = lwc_intern_string(start, p - start, &result[items]);
switch (lerror) {
case lwc_error_oom:
error = CSS_NOMEM;
@@ -536,7 +529,7 @@ cleanup:
uint32_t i;
for (i = 0; i < items; i++)
- lwc_context_string_unref(dict, result[i]);
+ lwc_string_unref(result[i]);
free(result);
}
@@ -553,13 +546,11 @@ cleanup:
*
* \param pw HTML document
* \param node DOM node
- * \param dict Dictionary to intern result in
* \param id Pointer to location to receive id value
* \return CSS_OK on success,
* CSS_NOMEM on memory exhaustion.
*/
-css_error node_id(void *pw, void *node,
- lwc_context *dict, lwc_string **id)
+css_error node_id(void *pw, void *node, lwc_string **id)
{
xmlNode *n = node;
xmlAttr *attr;
@@ -590,7 +581,7 @@ css_error node_id(void *pw, void *node,
}
/* Intern value */
- lerror = lwc_context_intern(dict, start, strlen(start), id);
+ lerror = lwc_intern_string(start, strlen(start), id);
switch (lerror) {
case lwc_error_oom:
error = CSS_NOMEM;
@@ -1285,9 +1276,7 @@ css_error node_presentational_hint(void *pw, void *node,
lwc_string *iurl;
lwc_error lerror;
- lerror = lwc_context_intern(
- html->data.html.dict, url,
- strlen(url), &iurl);
+ lerror = lwc_intern_string(url, strlen(url), &iurl);
free(url);
diff --git a/css/select.h b/css/select.h
index 7b87b2783..06868d5b2 100644
--- a/css/select.h
+++ b/css/select.h
@@ -29,7 +29,7 @@ struct content;
css_stylesheet *nscss_create_inline_style(const uint8_t *data, size_t len,
const char *charset, const char *url, bool allow_quirks,
- lwc_context *dict, css_allocator_fn alloc, void *pw);
+ css_allocator_fn alloc, void *pw);
css_computed_style *nscss_get_style(struct content *html, xmlNode *n,
uint32_t pseudo_element, uint64_t media,