summaryrefslogtreecommitdiff
path: root/src/parse/css21props.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-11-25 22:54:22 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-11-25 22:54:22 +0000
commit754cdc83af108f46062f08e25ab43d2a43bc66f2 (patch)
tree472fe71bf72bd897abdbcf13c58441b24d269c53 /src/parse/css21props.c
parent53d8843963752cb12b12134496f4576cd593d60e (diff)
downloadlibcss-754cdc83af108f46062f08e25ab43d2a43bc66f2.tar.gz
libcss-754cdc83af108f46062f08e25ab43d2a43bc66f2.tar.bz2
text-align
svn path=/trunk/libcss/; revision=5794
Diffstat (limited to 'src/parse/css21props.c')
-rw-r--r--src/parse/css21props.c41
1 files changed, 37 insertions, 4 deletions
diff --git a/src/parse/css21props.c b/src/parse/css21props.c
index 097f36c..e58cad5 100644
--- a/src/parse/css21props.c
+++ b/src/parse/css21props.c
@@ -3611,10 +3611,43 @@ css_error parse_text_align(css_css21 *c,
const parserutils_vector *vector, int *ctx,
css_style **result)
{
- UNUSED(c);
- UNUSED(vector);
- UNUSED(ctx);
- UNUSED(result);
+ css_error error;
+ const css_token *ident;
+ uint8_t flags = 0;
+ uint16_t value = 0;
+ uint32_t opv;
+
+ /* IDENT (left, right, center, justify, inherit) */
+ ident = parserutils_vector_iterate(vector, ctx);
+ if (ident == NULL || ident->type != CSS_TOKEN_IDENT)
+ return CSS_INVALID;
+
+ error = parse_important(c, vector, ctx, &flags);
+ if (error != CSS_OK)
+ return error;
+
+ if (ident->lower.ptr == c->strings[INHERIT]) {
+ flags |= FLAG_INHERIT;
+ } else if (ident->lower.ptr == c->strings[LEFT]) {
+ value = TEXT_ALIGN_LEFT;
+ } else if (ident->lower.ptr == c->strings[RIGHT]) {
+ value = TEXT_ALIGN_RIGHT;
+ } else if (ident->lower.ptr == c->strings[CENTER]) {
+ value = TEXT_ALIGN_CENTER;
+ } else if (ident->lower.ptr == c->strings[JUSTIFY]) {
+ value = TEXT_ALIGN_JUSTIFY;
+ } else
+ return CSS_INVALID;
+
+ opv = buildOPV(OP_TEXT_ALIGN, flags, value);
+
+ /* Allocate result */
+ error = css_stylesheet_style_create(c->sheet, sizeof(opv), result);
+ if (error != CSS_OK)
+ return error;
+
+ /* Copy the bytecode to it */
+ memcpy((*result)->bytecode, &opv, sizeof(opv));
return CSS_OK;
}