summaryrefslogtreecommitdiff
path: root/src/select
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2015-03-07 21:41:28 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2016-11-19 14:30:07 +0000
commitfac1ad8641848a3d747b6c495cf443ccc29c077e (patch)
tree4b34bfe4c32cb6033958a8bae7a740492746a4df /src/select
parent60812fc682b8764c93020124bb43e7972f64cb73 (diff)
downloadlibcss-fac1ad8641848a3d747b6c495cf443ccc29c077e.tar.gz
libcss-fac1ad8641848a3d747b6c495cf443ccc29c077e.tar.bz2
After composing styles, intern the result in the style sharing arena.
Note this changes the API. Selection tests updated.
Diffstat (limited to 'src/select')
-rw-r--r--src/select/computed.c29
1 files changed, 25 insertions, 4 deletions
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);
}
/******************************************************************************