summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2013-12-13 20:16:52 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2013-12-13 20:16:52 +0000
commit1b95fec601a3d006ba6b99e1dea3f61c3c8318fc (patch)
tree1a0c3a78afe1db919ff6b4c56a6c3f2e01d03607 /examples
parente3372335ec1628e1d6ef1a4fd63b11bb47f2e0e6 (diff)
downloadlibcss-1b95fec601a3d006ba6b99e1dea3f61c3c8318fc.tar.gz
libcss-1b95fec601a3d006ba6b99e1dea3f61c3c8318fc.tar.bz2
Various changes which modify API and ABI:
- Remove client allocation function. - Change node_classes callback not to yield array ownership to libcss. - Node bloom filters now built by, during selection libcss. - Added selection callbacks to get and set data on document nodes. Test suite, example, and documentation updated to match.
Diffstat (limited to 'examples')
-rw-r--r--examples/example1.c45
1 files changed, 32 insertions, 13 deletions
diff --git a/examples/example1.c b/examples/example1.c
index b092cfd..511771d 100644
--- a/examples/example1.c
+++ b/examples/example1.c
@@ -19,7 +19,6 @@
/* Function declarations. */
-static void *myrealloc(void *ptr, size_t len, void *pw);
static css_error resolve_url(void *pw,
const char *base, lwc_string *rel, lwc_string **abs);
static void die(const char *text, css_error code);
@@ -101,6 +100,10 @@ static css_error ua_default_for_property(void *pw, uint32_t property,
css_hint *hint);
static css_error compute_font_size(void *pw, const css_hint *parent,
css_hint *size);
+static css_error set_libcss_node_data(void *pw, void *n,
+ void *libcss_node_data);
+static css_error get_libcss_node_data(void *pw, void *n,
+ void **libcss_node_data);
/* Table of function pointers for the LibCSS Select API. */
static css_select_handler select_handler = {
@@ -140,7 +143,9 @@ static css_select_handler select_handler = {
node_is_lang,
node_presentational_hint,
ua_default_for_property,
- compute_font_size
+ compute_font_size,
+ set_libcss_node_data,
+ get_libcss_node_data
};
@@ -177,7 +182,7 @@ int main(int argc, char **argv)
params.font_pw = NULL;
/* create a stylesheet */
- code = css_stylesheet_create(&params, myrealloc, NULL, &sheet);
+ code = css_stylesheet_create(&params, &sheet);
if (code != CSS_OK)
die("css_stylesheet_create", code);
code = css_stylesheet_size(sheet, &size);
@@ -201,7 +206,7 @@ int main(int argc, char **argv)
/* prepare a selection context containing the stylesheet */
- code = css_select_ctx_create(myrealloc, 0, &select_ctx);
+ code = css_select_ctx_create(&select_ctx);
if (code != CSS_OK)
die("css_select_ctx_create", code);
code = css_select_ctx_append_sheet(select_ctx, sheet, CSS_ORIGIN_AUTHOR,
@@ -263,15 +268,6 @@ int main(int argc, char **argv)
}
-void *myrealloc(void *ptr, size_t len, void *pw)
-{
- UNUSED(pw);
- /*printf("myrealloc(%p, %zu)\n", ptr, len);*/
-
- return realloc(ptr, len);
-}
-
-
css_error resolve_url(void *pw,
const char *base, lwc_string *rel, lwc_string **abs)
{
@@ -725,4 +721,27 @@ 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)
+{
+ UNUSED(pw);
+ UNUSED(n);
+
+ /* Since we're not storing it, ensure node data gets deleted */
+ css_libcss_node_data_handler(&select_handler, CSS_NODE_DELETED,
+ pw, n, NULL, libcss_node_data);
+
+ return CSS_OK;
+}
+
+static css_error get_libcss_node_data(void *pw, void *n,
+ void **libcss_node_data)
+{
+ UNUSED(pw);
+ UNUSED(n);
+ *libcss_node_data = NULL;
+
+ return CSS_OK;
+}
+