From 58de60a12b1b7e50ab63e0a9fa9779d2169b3973 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sun, 25 Jan 2009 20:16:00 +0000 Subject: Destroy selectors svn path=/trunk/libcss/; revision=6268 --- src/stylesheet.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/stylesheet.c b/src/stylesheet.c index 34439ec..e95f61e 100644 --- a/src/stylesheet.c +++ b/src/stylesheet.c @@ -418,12 +418,24 @@ css_error css_stylesheet_selector_create(css_stylesheet *sheet, css_error css_stylesheet_selector_destroy(css_stylesheet *sheet, css_selector *selector) { - UNUSED(sheet); - UNUSED(selector); + css_selector *c, *d; + + if (sheet == NULL || selector == NULL) + return CSS_BADPARM; + + /* Must not be attached to a rule */ + if (selector->rule != NULL) + return CSS_INVALID; + + /* Destroy combinator chain */ + for (c = selector->combinator; c != NULL; c = d) { + d = c->combinator; + + sheet->alloc(c, 0, sheet->pw); + } - /** \todo Need to ensure that selector is removed from whatever it's - * attached to (be that the parent selector, parent rule, or the - * hashtable of selectors (or any combination of these) */ + /* Destroy this selector */ + sheet->alloc(selector, 0, sheet->pw); return CSS_OK; } -- cgit v1.2.3