From abb037cbc2d2279f77125f3d8a2c9e127363f762 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sat, 10 Jan 2009 16:36:01 +0000 Subject: text-decoration svn path=/trunk/libcss/; revision=6018 --- src/parse/properties.c | 64 +++++++++++++++++++++++++++++++++++++++++++++---- src/parse/propstrings.h | 8 +++++-- 2 files changed, 65 insertions(+), 7 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; } diff --git a/src/parse/propstrings.h b/src/parse/propstrings.h index 382982e..98fb869 100644 --- a/src/parse/propstrings.h +++ b/src/parse/propstrings.h @@ -68,7 +68,7 @@ enum { DEFAULT, POINTER, MOVE, E_RESIZE, NE_RESIZE, NW_RESIZE, N_RESIZE, SE_RESIZE, SW_RESIZE, S_RESIZE, W_RESIZE, TEXT, WAIT, HELP, PROGRESS, SERIF, SANS_SERIF, CURSIVE, FANTASY, MONOSPACE, MALE, FEMALE, CHILD, - MIX, + MIX, UNDERLINE, OVERLINE, LINE_THROUGH, BLINK, LAST_KNOWN }; @@ -349,7 +349,11 @@ static struct { { "male", SLEN("male") }, { "female", SLEN("female") }, { "child", SLEN("child") }, - { "mix", SLEN("mix") } + { "mix", SLEN("mix") }, + { "underline", SLEN("underline") }, + { "overline", SLEN("overline") }, + { "line-through", SLEN("line-through") }, + { "blink", SLEN("blink") } }; #endif -- cgit v1.2.3