diff options
-rw-r--r-- | include/libcss/computed.h | 4 | ||||
-rw-r--r-- | src/select/computed.c | 29 | ||||
-rw-r--r-- | test/select-common.c | 2 |
3 files changed, 28 insertions, 7 deletions
diff --git a/include/libcss/computed.h b/include/libcss/computed.h index 3470da8..0009267 100644 --- a/include/libcss/computed.h +++ b/include/libcss/computed.h @@ -83,12 +83,12 @@ css_error css_computed_style_initialise(css_computed_style *style, struct css_select_handler *handler, void *pw); css_error css_computed_style_compose(const css_computed_style *parent, - const css_computed_style *child, + css_computed_style *child, css_error (*compute_font_size)(void *pw, const struct css_hint *parent, struct css_hint *size), void *pw, - css_computed_style *result); + css_computed_style **result); /****************************************************************************** * Property accessors below here * diff --git a/src/select/computed.c b/src/select/computed.c index 817da31..182a7e7 100644 --- a/src/select/computed.c +++ b/src/select/computed.c @@ -7,6 +7,7 @@ #include <string.h> +#include "select/arena.h" #include "select/computed.h" #include "select/dispatch.h" #include "select/propget.h" @@ -92,6 +93,13 @@ css_error css__computed_uncommon_destroy(css_computed_uncommon *uncommon) if (uncommon == NULL) return CSS_BADPARM; + if (uncommon->count > 1) { + uncommon->count--; + return CSS_OK; + + } else if (uncommon->count == 1) { + css__arena_remove_uncommon_style(uncommon); + } if (uncommon != NULL) { if (uncommon->counter_increment != NULL) { @@ -176,6 +184,13 @@ css_error css_computed_style_destroy(css_computed_style *style) css__computed_uncommon_destroy(style->i.uncommon); + if (style->count > 1) { + style->count--; + return CSS_OK; + + } else if (style->count == 1) { + css__arena_remove_style(style); + } if (style->page != NULL) { free(style->page); @@ -270,11 +285,11 @@ css_error css_computed_style_initialise(css_computed_style *style, * \note \a child and \a result may point at the same object */ css_error css_computed_style_compose(const css_computed_style *parent, - const css_computed_style *child, + css_computed_style *child, css_error (*compute_font_size)(void *pw, const css_hint *parent, css_hint *size), void *pw, - css_computed_style *result) + css_computed_style **result) { css_error error = CSS_OK; size_t i; @@ -297,13 +312,19 @@ css_error css_computed_style_compose(const css_computed_style *parent, continue; /* Compose the property */ - error = prop_dispatch[i].compose(parent, child, result); + error = prop_dispatch[i].compose(parent, child, *result); if (error != CSS_OK) break; } /* Finally, compute absolute values for everything */ - return css__compute_absolute_values(parent, result, compute_font_size, pw); + error = css__compute_absolute_values(parent, *result, + compute_font_size, pw); + if (error != CSS_OK) { + return error; + } + + return css__arena_intern_style(result); } /****************************************************************************** diff --git a/test/select-common.c b/test/select-common.c index 432bd54..c6d33c0 100644 --- a/test/select-common.c +++ b/test/select-common.c @@ -773,7 +773,7 @@ static void run_test_select_tree(css_select_ctx *select, node->parent->sr->styles[ctx->pseudo_element], sr->styles[ctx->pseudo_element], compute_font_size, NULL, - sr->styles[ctx->pseudo_element]) == CSS_OK); + &(sr->styles[ctx->pseudo_element])) == CSS_OK); } node->sr = sr; |