diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2013-12-13 20:16:52 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2013-12-13 20:16:52 +0000 |
commit | 1b95fec601a3d006ba6b99e1dea3f61c3c8318fc (patch) | |
tree | 1a0c3a78afe1db919ff6b4c56a6c3f2e01d03607 /src/select/properties | |
parent | e3372335ec1628e1d6ef1a4fd63b11bb47f2e0e6 (diff) | |
download | libcss-1b95fec601a3d006ba6b99e1dea3f61c3c8318fc.tar.gz libcss-1b95fec601a3d006ba6b99e1dea3f61c3c8318fc.tar.bz2 |
Various changes which modify API and ABI:
- Remove client allocation function.
- Change node_classes callback not to yield array ownership to libcss.
- Node bloom filters now built by, during selection libcss.
- Added selection callbacks to get and set data on document nodes.
Test suite, example, and documentation updated to match.
Diffstat (limited to 'src/select/properties')
-rw-r--r-- | src/select/properties/content.c | 31 | ||||
-rw-r--r-- | src/select/properties/counter_increment.c | 9 | ||||
-rw-r--r-- | src/select/properties/counter_reset.c | 9 | ||||
-rw-r--r-- | src/select/properties/cursor.c | 32 | ||||
-rw-r--r-- | src/select/properties/font_family.c | 30 | ||||
-rw-r--r-- | src/select/properties/helpers.c | 19 | ||||
-rw-r--r-- | src/select/properties/quotes.c | 34 | ||||
-rw-r--r-- | src/select/properties/voice_family.c | 22 |
8 files changed, 82 insertions, 104 deletions
diff --git a/src/select/properties/content.c b/src/select/properties/content.c index 1d033f2..c79dd0d 100644 --- a/src/select/properties/content.c +++ b/src/select/properties/content.c @@ -35,16 +35,15 @@ css_error css__cascade_content(uint32_t opv, css_style *style, lwc_string *he; css_computed_content_item *temp; - css__stylesheet_string_get(style->sheet, *((css_code_t *) style->bytecode), &he); + css__stylesheet_string_get(style->sheet, + *((css_code_t *) style->bytecode), &he); - temp = state->computed->alloc(content, + temp = realloc(content, (n_contents + 1) * - sizeof(css_computed_content_item), - state->computed->pw); + sizeof(css_computed_content_item)); if (temp == NULL) { if (content != NULL) { - state->computed->alloc(content, - 0, state->computed->pw); + free(content); } return CSS_NOMEM; } @@ -127,11 +126,10 @@ css_error css__cascade_content(uint32_t opv, css_style *style, if (n_contents > 0) { css_computed_content_item *temp; - temp = state->computed->alloc(content, - (n_contents + 1) * sizeof(css_computed_content_item), - state->computed->pw); + temp = realloc(content, (n_contents + 1) * + sizeof(css_computed_content_item)); if (temp == NULL) { - state->computed->alloc(content, 0, state->computed->pw); + free(content); return CSS_NOMEM; } @@ -146,11 +144,11 @@ css_error css__cascade_content(uint32_t opv, css_style *style, error = set_content(state->computed, value, content); if (error != CSS_OK && content != NULL) - state->computed->alloc(content, 0, state->computed->pw); + free(content); return error; } else if (content != NULL) { - state->computed->alloc(content, 0, state->computed->pw); + free(content); } return CSS_OK; @@ -190,7 +188,7 @@ css_error css__set_content_from_hint(const css_hint *hint, } if (error != CSS_OK && hint->data.content != NULL) - style->alloc(hint->data.content, 0, style->pw); + free(hint->data.content); return error; } @@ -226,9 +224,8 @@ css_error css__compose_content(const css_computed_style *parent, i++) n_items++; - copy = result->alloc(NULL, (n_items + 1) * - sizeof(css_computed_content_item), - result->pw); + copy = malloc((n_items + 1) * + sizeof(css_computed_content_item)); if (copy == NULL) return CSS_NOMEM; @@ -238,7 +235,7 @@ css_error css__compose_content(const css_computed_style *parent, error = set_content(result, type, copy); if (error != CSS_OK && copy != NULL) - result->alloc(copy, 0, result->pw); + free(copy); return error; } diff --git a/src/select/properties/counter_increment.c b/src/select/properties/counter_increment.c index 26419a2..429e558 100644 --- a/src/select/properties/counter_increment.c +++ b/src/select/properties/counter_increment.c @@ -37,7 +37,7 @@ css_error css__set_counter_increment_from_hint(const css_hint *hint, } if (error != CSS_OK && hint->data.counter != NULL) - style->alloc(hint->data.counter, 0, style->pw); + free(hint->data.counter); return error; } @@ -73,9 +73,8 @@ css_error css__compose_counter_increment(const css_computed_style *parent, for (i = items; i->name != NULL; i++) n_items++; - copy = result->alloc(NULL, (n_items + 1) * - sizeof(css_computed_counter), - result->pw); + copy = malloc((n_items + 1) * + sizeof(css_computed_counter)); if (copy == NULL) return CSS_NOMEM; @@ -85,7 +84,7 @@ css_error css__compose_counter_increment(const css_computed_style *parent, error = set_counter_increment(result, type, copy); if (error != CSS_OK && copy != NULL) - result->alloc(copy, 0, result->pw); + free(copy); return error; } diff --git a/src/select/properties/counter_reset.c b/src/select/properties/counter_reset.c index 362c86d..ddf54aa 100644 --- a/src/select/properties/counter_reset.c +++ b/src/select/properties/counter_reset.c @@ -37,7 +37,7 @@ css_error css__set_counter_reset_from_hint(const css_hint *hint, } if (error != CSS_OK && hint->data.counter != NULL) - style->alloc(hint->data.counter, 0, style->pw); + free(hint->data.counter); return error; } @@ -72,9 +72,8 @@ css_error css__compose_counter_reset(const css_computed_style *parent, for (i = items; i->name != NULL; i++) n_items++; - copy = result->alloc(NULL, (n_items + 1) * - sizeof(css_computed_counter), - result->pw); + copy = malloc((n_items + 1) * + sizeof(css_computed_counter)); if (copy == NULL) return CSS_NOMEM; @@ -84,7 +83,7 @@ css_error css__compose_counter_reset(const css_computed_style *parent, error = set_counter_reset(result, type, copy); if (error != CSS_OK && copy != NULL) - result->alloc(copy, 0, result->pw); + free(copy); return error; } diff --git a/src/select/properties/cursor.c b/src/select/properties/cursor.c index d4785b1..a77d21b 100644 --- a/src/select/properties/cursor.c +++ b/src/select/properties/cursor.c @@ -28,16 +28,16 @@ css_error css__cascade_cursor(uint32_t opv, css_style *style, lwc_string *uri; lwc_string **temp; - css__stylesheet_string_get(style->sheet, *((css_code_t *) style->bytecode), &uri); + css__stylesheet_string_get(style->sheet, + *((css_code_t *) style->bytecode), + &uri); advance_bytecode(style, sizeof(css_code_t)); - temp = state->computed->alloc(uris, - (n_uris + 1) * sizeof(lwc_string *), - state->computed->pw); + temp = realloc(uris, + (n_uris + 1) * sizeof(lwc_string *)); if (temp == NULL) { if (uris != NULL) { - state->computed->alloc(uris, 0, - state->computed->pw); + free(uris); } return CSS_NOMEM; } @@ -111,11 +111,10 @@ css_error css__cascade_cursor(uint32_t opv, css_style *style, if (n_uris > 0) { lwc_string **temp; - temp = state->computed->alloc(uris, - (n_uris + 1) * sizeof(lwc_string *), - state->computed->pw); + temp = realloc(uris, + (n_uris + 1) * sizeof(lwc_string *)); if (temp == NULL) { - state->computed->alloc(uris, 0, state->computed->pw); + free(uris); return CSS_NOMEM; } @@ -130,12 +129,12 @@ css_error css__cascade_cursor(uint32_t opv, css_style *style, error = set_cursor(state->computed, value, uris); if (error != CSS_OK && n_uris > 0) - state->computed->alloc(uris, 0, state->computed->pw); + free(uris); return error; } else { if (n_uris > 0) - state->computed->alloc(uris, 0, state->computed->pw); + free(uris); } return CSS_OK; @@ -155,7 +154,7 @@ css_error css__set_cursor_from_hint(const css_hint *hint, } if (error != CSS_OK && hint->data.strings != NULL) - style->alloc(hint->data.strings, 0, style->pw); + free(hint->data.strings); return error; } @@ -190,9 +189,8 @@ css_error css__compose_cursor(const css_computed_style *parent, for (i = urls; (*i) != NULL; i++) n_urls++; - copy = result->alloc(NULL, (n_urls + 1) * - sizeof(lwc_string *), - result->pw); + copy = malloc((n_urls + 1) * + sizeof(lwc_string *)); if (copy == NULL) return CSS_NOMEM; @@ -202,7 +200,7 @@ css_error css__compose_cursor(const css_computed_style *parent, error = set_cursor(result, type, copy); if (error != CSS_OK && copy != NULL) - result->alloc(copy, 0, result->pw); + free(copy); return error; } diff --git a/src/select/properties/font_family.c b/src/select/properties/font_family.c index 44860f9..514a43a 100644 --- a/src/select/properties/font_family.c +++ b/src/select/properties/font_family.c @@ -63,13 +63,11 @@ css_error css__cascade_font_family(uint32_t opv, css_style *style, * first generic-family are ignored. */ /** \todo Do this at bytecode generation time? */ if (value == CSS_FONT_FAMILY_INHERIT && font != NULL) { - temp = state->computed->alloc(fonts, - (n_fonts + 1) * sizeof(lwc_string *), - state->computed->pw); + temp = realloc(fonts, + (n_fonts + 1) * sizeof(lwc_string *)); if (temp == NULL) { if (fonts != NULL) { - state->computed->alloc(fonts, 0, - state->computed->pw); + free(fonts); } return CSS_NOMEM; } @@ -90,11 +88,9 @@ css_error css__cascade_font_family(uint32_t opv, css_style *style, if (n_fonts > 0) { lwc_string **temp; - temp = state->computed->alloc(fonts, - (n_fonts + 1) * sizeof(lwc_string *), - state->computed->pw); + temp = realloc(fonts, (n_fonts + 1) * sizeof(lwc_string *)); if (temp == NULL) { - state->computed->alloc(fonts, 0, state->computed->pw); + free(fonts); return CSS_NOMEM; } @@ -126,9 +122,7 @@ css_error css__cascade_font_family(uint32_t opv, css_style *style, } if (hint.data.strings != NULL) { - state->computed->alloc( - hint.data.strings, - 0, state->computed->pw); + free(hint.data.strings); } } @@ -145,12 +139,12 @@ css_error css__cascade_font_family(uint32_t opv, css_style *style, error = set_font_family(state->computed, value, fonts); if (error != CSS_OK && n_fonts > 0) - state->computed->alloc(fonts, 0, state->computed->pw); + free(fonts); return error; } else { if (n_fonts > 0) - state->computed->alloc(fonts, 0, state->computed->pw); + free(fonts); } return CSS_OK; @@ -170,7 +164,7 @@ css_error css__set_font_family_from_hint(const css_hint *hint, } if (error != CSS_OK && hint->data.strings != NULL) - style->alloc(hint->data.strings, 0, style->pw); + free(hint->data.strings); return error; } @@ -209,9 +203,7 @@ css_error css__compose_font_family(const css_computed_style *parent, for (i = names; (*i) != NULL; i++) n_names++; - copy = result->alloc(NULL, (n_names + 1) * - sizeof(lwc_string *), - result->pw); + copy = malloc((n_names + 1) * sizeof(lwc_string *)); if (copy == NULL) return CSS_NOMEM; @@ -221,7 +213,7 @@ css_error css__compose_font_family(const css_computed_style *parent, error = set_font_family(result, type, copy); if (error != CSS_OK && copy != NULL) - result->alloc(copy, 0, result->pw); + free(copy); return error; } diff --git a/src/select/properties/helpers.c b/src/select/properties/helpers.c index 28ecdcc..df076db 100644 --- a/src/select/properties/helpers.c +++ b/src/select/properties/helpers.c @@ -421,14 +421,12 @@ css_error css__cascade_counter_increment_reset(uint32_t opv, css_style *style, val = *((css_fixed *) style->bytecode); advance_bytecode(style, sizeof(css_code_t)); - temp = state->computed->alloc(counters, + temp = realloc(counters, (n_counters + 1) * - sizeof(css_computed_counter), - state->computed->pw); + sizeof(css_computed_counter)); if (temp == NULL) { if (counters != NULL) { - state->computed->alloc(counters, - 0, state->computed->pw); + free(counters); } return CSS_NOMEM; } @@ -455,11 +453,10 @@ css_error css__cascade_counter_increment_reset(uint32_t opv, css_style *style, if (n_counters > 0) { css_computed_counter *temp; - temp = state->computed->alloc(counters, - (n_counters + 1) * sizeof(css_computed_counter), - state->computed->pw); + temp = realloc(counters, (n_counters + 1) * + sizeof(css_computed_counter)); if (temp == NULL) { - state->computed->alloc(counters, 0, state->computed->pw); + free(counters); return CSS_NOMEM; } @@ -475,11 +472,11 @@ css_error css__cascade_counter_increment_reset(uint32_t opv, css_style *style, error = fun(state->computed, value, counters); if (error != CSS_OK && n_counters > 0) - state->computed->alloc(counters, 0, state->computed->pw); + free(counters); return error; } else if (n_counters > 0) { - state->computed->alloc(counters, 0, state->computed->pw); + free(counters); } return CSS_OK; diff --git a/src/select/properties/quotes.c b/src/select/properties/quotes.c index 7671c1d..2dd6af4 100644 --- a/src/select/properties/quotes.c +++ b/src/select/properties/quotes.c @@ -30,19 +30,21 @@ css_error css__cascade_quotes(uint32_t opv, css_style *style, lwc_string *open, *close; lwc_string **temp; - css__stylesheet_string_get(style->sheet, *((css_code_t *) style->bytecode), &open); + css__stylesheet_string_get(style->sheet, + *((css_code_t *) style->bytecode), + &open); advance_bytecode(style, sizeof(css_code_t)); - css__stylesheet_string_get(style->sheet, *((css_code_t *) style->bytecode), &close); + css__stylesheet_string_get(style->sheet, + *((css_code_t *) style->bytecode), + &close); advance_bytecode(style, sizeof(css_code_t)); - temp = state->computed->alloc(quotes, - (n_quotes + 2) * sizeof(lwc_string *), - state->computed->pw); + temp = realloc(quotes, + (n_quotes + 2) * sizeof(lwc_string *)); if (temp == NULL) { if (quotes != NULL) { - state->computed->alloc(quotes, 0, - state->computed->pw); + free(quotes); } return CSS_NOMEM; } @@ -61,11 +63,9 @@ css_error css__cascade_quotes(uint32_t opv, css_style *style, if (n_quotes > 0) { lwc_string **temp; - temp = state->computed->alloc(quotes, - (n_quotes + 1) * sizeof(lwc_string *), - state->computed->pw); + temp = realloc(quotes, (n_quotes + 1) * sizeof(lwc_string *)); if (temp == NULL) { - state->computed->alloc(quotes, 0, state->computed->pw); + free(quotes); return CSS_NOMEM; } @@ -80,12 +80,12 @@ css_error css__cascade_quotes(uint32_t opv, css_style *style, error = set_quotes(state->computed, value, quotes); if (error != CSS_OK && quotes != NULL) - state->computed->alloc(quotes, 0, state->computed->pw); + free(quotes); return error; } else { if (quotes != NULL) - state->computed->alloc(quotes, 0, state->computed->pw); + free(quotes); } return CSS_OK; @@ -105,7 +105,7 @@ css_error css__set_quotes_from_hint(const css_hint *hint, } if (error != CSS_OK && hint->data.strings != NULL) - style->alloc(hint->data.strings, 0, style->pw); + free(hint->data.strings); return error; } @@ -145,9 +145,7 @@ css_error css__compose_quotes(const css_computed_style *parent, for (i = quotes; (*i) != NULL; i++) n_quotes++; - copy = result->alloc(NULL, (n_quotes + 1) * - sizeof(lwc_string *), - result->pw); + copy = malloc((n_quotes + 1) * sizeof(lwc_string *)); if (copy == NULL) return CSS_NOMEM; @@ -157,7 +155,7 @@ css_error css__compose_quotes(const css_computed_style *parent, error = set_quotes(result, type, copy); if (error != CSS_OK && copy != NULL) - result->alloc(copy, 0, result->pw); + free(copy); return error; } diff --git a/src/select/properties/voice_family.c b/src/select/properties/voice_family.c index e61d2c6..5c70d1e 100644 --- a/src/select/properties/voice_family.c +++ b/src/select/properties/voice_family.c @@ -31,7 +31,9 @@ css_error css__cascade_voice_family(uint32_t opv, css_style *style, switch (v) { case VOICE_FAMILY_STRING: case VOICE_FAMILY_IDENT_LIST: - css__stylesheet_string_get(style->sheet, *((css_code_t *) style->bytecode), &voice); + css__stylesheet_string_get(style->sheet, + *((css_code_t *) style->bytecode), + &voice); advance_bytecode(style, sizeof(css_code_t)); break; case VOICE_FAMILY_MALE: @@ -53,13 +55,11 @@ css_error css__cascade_voice_family(uint32_t opv, css_style *style, * first generic-family are ignored. */ /** \todo Do this at bytecode generation time? */ if (value == 0 && voice != NULL) { - temp = state->computed->alloc(voices, - (n_voices + 1) * sizeof(lwc_string *), - state->computed->pw); + temp = realloc(voices, + (n_voices + 1) * sizeof(lwc_string *)); if (temp == NULL) { if (voices != NULL) { - state->computed->alloc(voices, 0, - state->computed->pw); + free(voices); } return CSS_NOMEM; } @@ -80,11 +80,9 @@ css_error css__cascade_voice_family(uint32_t opv, css_style *style, if (n_voices > 0) { lwc_string **temp; - temp = state->computed->alloc(voices, - (n_voices + 1) * sizeof(lwc_string *), - state->computed->pw); + temp = realloc(voices, (n_voices + 1) * sizeof(lwc_string *)); if (temp == NULL) { - state->computed->alloc(voices, 0, state->computed->pw); + free(voices); return CSS_NOMEM; } @@ -97,10 +95,10 @@ css_error css__cascade_voice_family(uint32_t opv, css_style *style, isInherit(opv))) { /** \todo voice-family */ if (n_voices > 0) - state->computed->alloc(voices, 0, state->computed->pw); + free(voices); } else { if (n_voices > 0) - state->computed->alloc(voices, 0, state->computed->pw); + free(voices); } return CSS_OK; |