diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2008-10-26 15:36:58 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2008-10-26 15:36:58 +0000 |
commit | 3de4a3051a59a2b6bfe7029c63ba6af035f437a7 (patch) | |
tree | 77d75863c431224b65fb81cd88cfe0415b5863c0 /src | |
parent | ff9495d56006405324e4404089f158d61b944c57 (diff) | |
download | libcss-3de4a3051a59a2b6bfe7029c63ba6af035f437a7.tar.gz libcss-3de4a3051a59a2b6bfe7029c63ba6af035f437a7.tar.bz2 |
direction
display
svn path=/trunk/libcss/; revision=5638
Diffstat (limited to 'src')
-rw-r--r-- | src/parse/css21.c | 22 | ||||
-rw-r--r-- | src/parse/css21props.c | 106 |
2 files changed, 119 insertions, 9 deletions
diff --git a/src/parse/css21.c b/src/parse/css21.c index 07bb68c..4a341bf 100644 --- a/src/parse/css21.c +++ b/src/parse/css21.c @@ -53,7 +53,10 @@ enum { INHERIT, IMPORTANT, NONE, BOTH, FIXED, SCROLL, TRANSPARENT, NO_REPEAT, REPEAT_X, REPEAT_Y, REPEAT, HIDDEN, DOTTED, DASHED, SOLID, DOUBLE, GROOVE, RIDGE, INSET, OUTSET, THIN, MEDIUM, THICK, - COLLAPSE, SEPARATE, AUTO, + COLLAPSE, SEPARATE, AUTO, LTR, RTL, INLINE, BLOCK, LIST_ITEM, RUN_IN, + INLINE_BLOCK, TABLE, INLINE_TABLE, TABLE_ROW_GROUP, TABLE_HEADER_GROUP, + TABLE_FOOTER_GROUP, TABLE_ROW, TABLE_COLUMN_GROUP, TABLE_COLUMN, + TABLE_CELL, TABLE_CAPTION, LAST_KNOWN }; @@ -194,6 +197,23 @@ static struct { { "collapse", SLEN("collapse") }, { "separate", SLEN("separate") }, { "auto", SLEN("auto") }, + { "ltr", SLEN("ltr") }, + { "rtl", SLEN("rtl") }, + { "inline", SLEN("inline") }, + { "block", SLEN("block") }, + { "list-item", SLEN("list-item") }, + { "run-in", SLEN("run-in") }, + { "inline-block", SLEN("inline-block") }, + { "table", SLEN("table") }, + { "inline-table", SLEN("inline-table") }, + { "table-row-group", SLEN("table-row-group") }, + { "table-header-group", SLEN("table-header-group") }, + { "table-footer-group", SLEN("table-footer-group") }, + { "table-row", SLEN("table-row") }, + { "table-column-group", SLEN("table-column-group") }, + { "table-column", SLEN("table-column") }, + { "table-cell", SLEN("table-cell") }, + { "table-caption", SLEN("table-caption") }, }; typedef struct context_entry { diff --git a/src/parse/css21props.c b/src/parse/css21props.c index 273abb3..47bee38 100644 --- a/src/parse/css21props.c +++ b/src/parse/css21props.c @@ -1178,6 +1178,7 @@ css_error parse_cursor(css_css21 *c, const parserutils_vector *vector, int *ctx, css_style **result) { + /** \todo cursor */ UNUSED(c); UNUSED(vector); UNUSED(ctx); @@ -1190,10 +1191,39 @@ css_error parse_direction(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 (ltr, rtl, 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[LTR]) { + value = DIRECTION_LTR; + } else if (ident->lower.ptr == c->strings[RTL]) { + value = DIRECTION_RTL; + } else + return CSS_INVALID; + + opv = buildOPV(OP_DIRECTION, flags, value); + + /* Allocate result */ + *result = css_stylesheet_style_create(c->sheet, sizeof(opv)); + if (*result == NULL) + return CSS_NOMEM; + + /* Copy the bytecode to it */ + memcpy((*result)->bytecode, &opv, sizeof(opv)); return CSS_OK; } @@ -1202,10 +1232,70 @@ css_error parse_display(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 (inline, block, list-item, run-in, inline-block, table, + * inline-table, table-row-group, table-header-group, + * table-footer-group, table-row, table-column-group, table-column, + * table-cell, table-caption, none, 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[INLINE]) { + value = DISPLAY_INLINE; + } else if (ident->lower.ptr == c->strings[BLOCK]) { + value = DISPLAY_BLOCK; + } else if (ident->lower.ptr == c->strings[LIST_ITEM]) { + value = DISPLAY_LIST_ITEM; + } else if (ident->lower.ptr == c->strings[RUN_IN]) { + value = DISPLAY_RUN_IN; + } else if (ident->lower.ptr == c->strings[INLINE_BLOCK]) { + value = DISPLAY_INLINE_BLOCK; + } else if (ident->lower.ptr == c->strings[TABLE]) { + value = DISPLAY_TABLE; + } else if (ident->lower.ptr == c->strings[INLINE_TABLE]) { + value = DISPLAY_INLINE_TABLE; + } else if (ident->lower.ptr == c->strings[TABLE_ROW_GROUP]) { + value = DISPLAY_TABLE_ROW_GROUP; + } else if (ident->lower.ptr == c->strings[TABLE_HEADER_GROUP]) { + value = DISPLAY_TABLE_HEADER_GROUP; + } else if (ident->lower.ptr == c->strings[TABLE_FOOTER_GROUP]) { + value = DISPLAY_TABLE_FOOTER_GROUP; + } else if (ident->lower.ptr == c->strings[TABLE_ROW]) { + value = DISPLAY_TABLE_ROW; + } else if (ident->lower.ptr == c->strings[TABLE_COLUMN_GROUP]) { + value = DISPLAY_TABLE_COLUMN_GROUP; + } else if (ident->lower.ptr == c->strings[TABLE_COLUMN]) { + value = DISPLAY_TABLE_COLUMN; + } else if (ident->lower.ptr == c->strings[TABLE_CELL]) { + value = DISPLAY_TABLE_CELL; + } else if (ident->lower.ptr == c->strings[TABLE_CAPTION]) { + value = DISPLAY_TABLE_CAPTION; + } else if (ident->lower.ptr == c->strings[NONE]) { + value = DISPLAY_NONE; + } else + return CSS_INVALID; + + opv = buildOPV(OP_DISPLAY, flags, value); + + /* Allocate result */ + *result = css_stylesheet_style_create(c->sheet, sizeof(opv)); + if (*result == NULL) + return CSS_NOMEM; + + /* Copy the bytecode to it */ + memcpy((*result)->bytecode, &opv, sizeof(opv)); return CSS_OK; } |