summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2015-03-07 21:41:28 (GMT)
committer Michael Drake <tlsa@netsurf-browser.org>2016-11-19 14:30:07 (GMT)
commitfac1ad8641848a3d747b6c495cf443ccc29c077e (patch)
tree4b34bfe4c32cb6033958a8bae7a740492746a4df
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.
-rw-r--r--include/libcss/computed.h4
-rw-r--r--src/select/computed.c29
-rw-r--r--test/select-common.c2
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;