summaryrefslogtreecommitdiff
path: root/src/parse/properties/border_spacing.c
diff options
context:
space:
mode:
authorVincent Sanders <vince@netsurf-browser.org>2011-01-19 23:12:37 +0000
committerVincent Sanders <vince@netsurf-browser.org>2011-01-19 23:12:37 +0000
commit6a50bef84ae6a0a67e03ac1356f8d85d15fe09d6 (patch)
tree01f78f04b22517899f603787f6005f70b359271e /src/parse/properties/border_spacing.c
parent63c21aca7c77b1d37cb64ad2b1fa76d6b0b92f48 (diff)
downloadlibcss-6a50bef84ae6a0a67e03ac1356f8d85d15fe09d6.tar.gz
libcss-6a50bef84ae6a0a67e03ac1356f8d85d15fe09d6.tar.bz2
Merge parser autogeneration and string handling refactor branch r=jmb,kinnison,vince
svn path=/trunk/libcss/; revision=11408
Diffstat (limited to 'src/parse/properties/border_spacing.c')
-rw-r--r--src/parse/properties/border_spacing.c50
1 files changed, 22 insertions, 28 deletions
diff --git a/src/parse/properties/border_spacing.c b/src/parse/properties/border_spacing.c
index 623f616..3d8f994 100644
--- a/src/parse/properties/border_spacing.c
+++ b/src/parse/properties/border_spacing.c
@@ -29,17 +29,13 @@
*/
css_error parse_border_spacing(css_language *c,
const parserutils_vector *vector, int *ctx,
- css_style **result)
+ css_style *result)
{
int orig_ctx = *ctx;
css_error error;
const css_token *token;
- uint8_t flags = 0;
- uint16_t value = 0;
- uint32_t opv;
css_fixed length[2] = { 0 };
uint32_t unit[2] = { 0 };
- uint32_t required_size;
bool match;
/* length length? | IDENT(inherit) */
@@ -54,7 +50,11 @@ css_error parse_border_spacing(css_language *c,
token->idata, c->strings[INHERIT],
&match) == lwc_error_ok && match)) {
parserutils_vector_iterate(vector, ctx);
- flags = FLAG_INHERIT;
+ /* inherit */
+ error = css_stylesheet_style_appendOPV(result,
+ CSS_PROP_BORDER_SPACING,
+ FLAG_INHERIT,
+ 0);
} else {
int num_lengths = 0;
@@ -109,35 +109,29 @@ css_error parse_border_spacing(css_language *c,
return CSS_INVALID;
}
- value = BORDER_SPACING_SET;
- }
+ error = css_stylesheet_style_appendOPV(result,
+ CSS_PROP_BORDER_SPACING,
+ 0,
+ BORDER_SPACING_SET);
- opv = buildOPV(CSS_PROP_BORDER_SPACING, flags, value);
+ if (error != CSS_OK) {
+ *ctx = orig_ctx;
+ return error;
+ }
- required_size = sizeof(opv);
- if ((flags & FLAG_INHERIT) == false && value == BORDER_SPACING_SET)
- required_size += 2 * (sizeof(length[0]) + sizeof(unit[0]));
+ error = css_stylesheet_style_vappend(result,
+ 4,
+ length[0],
+ unit[0],
+ length[1],
+ unit[1]);
+
+ }
- /* Allocate result */
- error = css_stylesheet_style_create(c->sheet, required_size, result);
if (error != CSS_OK) {
*ctx = orig_ctx;
return error;
}
- /* Copy the bytecode to it */
- memcpy((*result)->bytecode, &opv, sizeof(opv));
- if ((flags & FLAG_INHERIT) == false && value == BORDER_SPACING_SET) {
- uint8_t *ptr = ((uint8_t *) (*result)->bytecode) + sizeof(opv);
-
- memcpy(ptr, &length[0], sizeof(length[0]));
- ptr += sizeof(length[0]);
- memcpy(ptr, &unit[0], sizeof(unit[0]));
- ptr += sizeof(unit[0]);
- memcpy(ptr, &length[1], sizeof(length[1]));
- ptr += sizeof(length[1]);
- memcpy(ptr, &unit[1], sizeof(unit[1]));
- }
-
return CSS_OK;
}