summaryrefslogtreecommitdiff
path: root/src/parse/properties.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/parse/properties.c')
-rw-r--r--src/parse/properties.c64
1 files changed, 59 insertions, 5 deletions
diff --git a/src/parse/properties.c b/src/parse/properties.c
index 3abdc76..a070354 100644
--- a/src/parse/properties.c
+++ b/src/parse/properties.c
@@ -5246,12 +5246,66 @@ css_error parse_text_decoration(css_language *c,
const parserutils_vector *vector, int *ctx,
css_style **result)
{
- /** \todo text-decoration */
+ css_error error;
+ const css_token *ident;
+ uint8_t flags = 0;
+ uint16_t value = 0;
+ uint32_t opv;
- UNUSED(c);
- UNUSED(vector);
- UNUSED(ctx);
- UNUSED(result);
+ /* IDENT([ underline || overline || line-through || blink ])
+ * | IDENT (none, inherit) */
+ ident = parserutils_vector_iterate(vector, ctx);
+ if (ident == NULL || ident->type != CSS_TOKEN_IDENT)
+ return CSS_INVALID;
+
+ if (ident->ilower == c->strings[INHERIT]) {
+ flags |= FLAG_INHERIT;
+ } else if (ident->ilower == c->strings[NONE]) {
+ value = TEXT_DECORATION_NONE;
+ } else {
+ while (ident != NULL) {
+ if (ident->ilower == c->strings[UNDERLINE]) {
+ if ((value & TEXT_DECORATION_UNDERLINE) == 0)
+ value |= TEXT_DECORATION_UNDERLINE;
+ else
+ return CSS_INVALID;
+ } else if (ident->ilower == c->strings[OVERLINE]) {
+ if ((value & TEXT_DECORATION_OVERLINE) == 0)
+ value |= TEXT_DECORATION_OVERLINE;
+ else
+ return CSS_INVALID;
+ } else if (ident->ilower == c->strings[LINE_THROUGH]) {
+ if ((value & TEXT_DECORATION_LINE_THROUGH) == 0)
+ value |= TEXT_DECORATION_LINE_THROUGH;
+ else
+ return CSS_INVALID;
+ } else if (ident->ilower == c->strings[BLINK]) {
+ if ((value & TEXT_DECORATION_BLINK) == 0)
+ value |= TEXT_DECORATION_BLINK;
+ else
+ return CSS_INVALID;
+ } else
+ return CSS_INVALID;
+
+ ident = parserutils_vector_peek(vector, *ctx);
+ if (ident != NULL && ident->type != CSS_TOKEN_IDENT)
+ break;
+ }
+ }
+
+ error = parse_important(c, vector, ctx, &flags);
+ if (error != CSS_OK)
+ return error;
+
+ opv = buildOPV(OP_TEXT_DECORATION, 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;
}