summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2011-01-05 01:01:54 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2011-01-05 01:01:54 +0000
commit75008c1ad03a37bbd2d77c2f7d528aa8c54bda95 (patch)
tree976c8eef6eccc27465c4e269e569c6669ff64632 /examples
parent4860bd14179e94a7d073714c1c5b21fd9c200dd7 (diff)
downloadlibcss-75008c1ad03a37bbd2d77c2f7d528aa8c54bda95.tar.gz
libcss-75008c1ad03a37bbd2d77c2f7d528aa8c54bda95.tar.bz2
Fix example to use new selection API.
Squash lwc string leak svn path=/trunk/libcss/; revision=11212
Diffstat (limited to 'examples')
-rw-r--r--examples/example1.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/examples/example1.c b/examples/example1.c
index b2a158f..e173f4b 100644
--- a/examples/example1.c
+++ b/examples/example1.c
@@ -166,7 +166,7 @@ int main(int argc, char **argv)
/* select style for each of h1 to h6 */
for (hh = 1; hh != 7; hh++) {
- css_computed_style *style;
+ css_select_results *style;
char element[20];
lwc_string *element_name;
uint8_t color_type;
@@ -178,22 +178,24 @@ int main(int argc, char **argv)
snprintf(element, sizeof element, "h%i", hh);
lwc_intern_string(element, strlen(element), &element_name);
- code = css_computed_style_create(myrealloc, 0, &style);
- if (code != CSS_OK)
- die("css_computed_style_create", code);
- code = css_select_style(select_ctx, element_name, 0,
- CSS_MEDIA_SCREEN, NULL, style,
- &select_handler, 0);
+ code = css_select_style(select_ctx, element_name,
+ CSS_MEDIA_SCREEN, NULL,
+ &select_handler, 0,
+ &style);
if (code != CSS_OK)
die("css_select_style", code);
- color_type = css_computed_color(style, &color_shade);
+ lwc_string_unref(element_name);
+
+ color_type = css_computed_color(
+ style->styles[CSS_PSEUDO_ELEMENT_NONE],
+ &color_shade);
if (color_type == CSS_COLOR_INHERIT)
printf("color of h%i is 'inherit'\n", hh);
else
printf("color of h%i is %x\n", hh, color_shade);
- code = css_computed_style_destroy(style);
+ code = css_select_results_destroy(style);
if (code != CSS_OK)
die("css_computed_style_destroy", code);
}