summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-03-04 01:24:12 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-03-04 01:24:12 +0000
commit7c809b74610653dc55276bb6e99459e073d2112c (patch)
tree189487a527dfb07ac96c66ccdeacbd40b8a6f3af /src
parentccb0737a07d5f97e917d37252123b1293ab242fe (diff)
downloadlibcss-7c809b74610653dc55276bb6e99459e073d2112c.tar.gz
libcss-7c809b74610653dc55276bb6e99459e073d2112c.tar.bz2
Constify.
Compose counter-increment and counter-reset. Fix compose_content. svn path=/trunk/libcss/; revision=6692
Diffstat (limited to 'src')
-rw-r--r--src/select/properties.c82
1 files changed, 81 insertions, 1 deletions
diff --git a/src/select/properties.c b/src/select/properties.c
index 572a151..daf3411 100644
--- a/src/select/properties.c
+++ b/src/select/properties.c
@@ -1181,7 +1181,7 @@ css_error compose_content(const css_computed_style *parent,
copy = result->alloc(NULL, (n_items + 1) *
sizeof(css_computed_content_item),
result->pw);
- if (i == NULL)
+ if (copy == NULL)
return CSS_NOMEM;
memcpy(copy, items, (n_items + 1) *
@@ -1210,6 +1210,46 @@ css_error initial_counter_increment(css_computed_style *style)
return set_counter_increment(style, CSS_COUNTER_INCREMENT_NONE, NULL);
}
+css_error compose_counter_increment(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ css_error error;
+ const css_computed_counter *items = NULL;
+
+ if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ css_computed_counter_increment(child, &items) ==
+ CSS_COUNTER_INCREMENT_INHERIT) {
+ uint8_t p = css_computed_counter_increment(parent, &items);
+ size_t n_items = 0;
+ css_computed_counter *copy = NULL;
+
+ if (p == CSS_COUNTER_INCREMENT_NAMED && items != NULL) {
+ const css_computed_counter *i;
+
+ for (i = items; i->name != NULL; i++)
+ n_items++;
+
+ copy = result->alloc(NULL, (n_items + 1) *
+ sizeof(css_computed_counter),
+ result->pw);
+ if (copy == NULL)
+ return CSS_NOMEM;
+
+ memcpy(copy, items, (n_items + 1) *
+ sizeof(css_computed_counter));
+ }
+
+ error = set_counter_increment(result, p, copy);
+ if (error != CSS_OK && copy != NULL)
+ result->alloc(copy, 0, result->pw);
+
+ return error;
+ }
+
+ return CSS_OK;
+}
+
css_error cascade_counter_reset(uint32_t opv, css_style *style,
css_select_state *state)
{
@@ -1222,6 +1262,46 @@ css_error initial_counter_reset(css_computed_style *style)
return set_counter_reset(style, CSS_COUNTER_RESET_NONE, NULL);
}
+css_error compose_counter_reset(const css_computed_style *parent,
+ const css_computed_style *child,
+ css_computed_style *result)
+{
+ css_error error;
+ const css_computed_counter *items = NULL;
+
+ if ((child->uncommon == NULL && parent->uncommon != NULL) ||
+ css_computed_counter_reset(child, &items) ==
+ CSS_COUNTER_RESET_INHERIT) {
+ uint8_t p = css_computed_counter_reset(parent, &items);
+ size_t n_items = 0;
+ css_computed_counter *copy = NULL;
+
+ if (p == CSS_COUNTER_RESET_NAMED && items != NULL) {
+ const css_computed_counter *i;
+
+ for (i = items; i->name != NULL; i++)
+ n_items++;
+
+ copy = result->alloc(NULL, (n_items + 1) *
+ sizeof(css_computed_counter),
+ result->pw);
+ if (copy == NULL)
+ return CSS_NOMEM;
+
+ memcpy(copy, items, (n_items + 1) *
+ sizeof(css_computed_counter));
+ }
+
+ error = set_counter_reset(result, p, copy);
+ if (error != CSS_OK && copy != NULL)
+ result->alloc(copy, 0, result->pw);
+
+ return error;
+ }
+
+ return CSS_OK;
+}
+
css_error cascade_cue_after(uint32_t opv, css_style *style,
css_select_state *state)
{