summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-10-26 23:03:49 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-10-26 23:03:49 +0000
commit6289f4216fe8fada44cf57c0fb939029ca720ae9 (patch)
tree2d510eec574805c77093eaf74aaefd6ffc3e4a81 /src
parentdf44d6ea1cdac2561af3497c8de8f2de49da887b (diff)
downloadlibcss-6289f4216fe8fada44cf57c0fb939029ca720ae9.tar.gz
libcss-6289f4216fe8fada44cf57c0fb939029ca720ae9.tar.bz2
font-variant, font-weight
svn path=/trunk/libcss/; revision=5644
Diffstat (limited to 'src')
-rw-r--r--src/parse/css21.c7
-rw-r--r--src/parse/css21props.c94
2 files changed, 92 insertions, 9 deletions
diff --git a/src/parse/css21.c b/src/parse/css21.c
index fe207b6..e3031b7 100644
--- a/src/parse/css21.c
+++ b/src/parse/css21.c
@@ -58,7 +58,8 @@ enum {
TABLE_FOOTER_GROUP, TABLE_ROW, TABLE_COLUMN_GROUP, TABLE_COLUMN,
TABLE_CELL, TABLE_CAPTION, BELOW, LEVEL, ABOVE, HIGHER, LOWER,
SHOW, HIDE, XX_SMALL, X_SMALL, SMALL, LARGE, X_LARGE, XX_LARGE,
- LARGER, SMALLER, NORMAL, ITALIC, OBLIQUE,
+ LARGER, SMALLER, NORMAL, ITALIC, OBLIQUE, SMALL_CAPS, BOLD, BOLDER,
+ LIGHTER,
LAST_KNOWN
};
@@ -234,6 +235,10 @@ static struct {
{ "normal", SLEN("normal") },
{ "italic", SLEN("italic") },
{ "oblique", SLEN("oblique") },
+ { "small-caps", SLEN("small-caps") },
+ { "bold", SLEN("bold") },
+ { "bolder", SLEN("bolder") },
+ { "lighter", SLEN("lighter") },
};
typedef struct context_entry {
diff --git a/src/parse/css21props.c b/src/parse/css21props.c
index ff41ceb..8a315b5 100644
--- a/src/parse/css21props.c
+++ b/src/parse/css21props.c
@@ -1622,10 +1622,39 @@ css_error parse_font_variant(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 (normal, small-caps, 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[NORMAL]) {
+ value = FONT_VARIANT_NORMAL;
+ } else if (ident->lower.ptr == c->strings[SMALL_CAPS]) {
+ value = FONT_VARIANT_SMALL_CAPS;
+ } else
+ return CSS_INVALID;
+
+ opv = buildOPV(OP_FONT_VARIANT, 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;
}
@@ -1634,10 +1663,59 @@ css_error parse_font_weight(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 *token;
+ uint8_t flags = 0;
+ uint16_t value = 0;
+ uint32_t opv;
+
+ /* NUMBER (100, 200, 300, 400, 500, 600, 700, 800, 900) |
+ * IDENT (normal, bold, bolder, lighter, inherit) */
+ token = parserutils_vector_iterate(vector, ctx);
+ if (token == NULL || (token->type != CSS_TOKEN_IDENT &&
+ token->type != CSS_TOKEN_NUMBER))
+ return CSS_INVALID;
+
+ error = parse_important(c, vector, ctx, &flags);
+ if (error != CSS_OK)
+ return error;
+
+ if (token->lower.ptr == c->strings[INHERIT]) {
+ flags |= FLAG_INHERIT;
+ } else if (token->type == CSS_TOKEN_NUMBER) {
+ int32_t num = 100; /** \todo strntol */
+ switch (num) {
+ case 100: value = FONT_WEIGHT_100; break;
+ case 200: value = FONT_WEIGHT_200; break;
+ case 300: value = FONT_WEIGHT_300; break;
+ case 400: value = FONT_WEIGHT_400; break;
+ case 500: value = FONT_WEIGHT_500; break;
+ case 600: value = FONT_WEIGHT_600; break;
+ case 700: value = FONT_WEIGHT_700; break;
+ case 800: value = FONT_WEIGHT_800; break;
+ case 900: value = FONT_WEIGHT_900; break;
+ default: return CSS_INVALID;
+ }
+ } else if (token->lower.ptr == c->strings[NORMAL]) {
+ value = FONT_WEIGHT_NORMAL;
+ } else if (token->lower.ptr == c->strings[BOLD]) {
+ value = FONT_WEIGHT_BOLD;
+ } else if (token->lower.ptr == c->strings[BOLDER]) {
+ value = FONT_WEIGHT_BOLDER;
+ } else if (token->lower.ptr == c->strings[LIGHTER]) {
+ value = FONT_WEIGHT_LIGHTER;
+ } else
+ return CSS_INVALID;
+
+ opv = buildOPV(OP_FONT_WEIGHT, 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;
}