From b1a8dce16cd3b0e1234b6e129d6baf7102994833 Mon Sep 17 00:00:00 2001 From: James Bursa Date: Wed, 5 Nov 2003 16:25:35 +0000 Subject: [project @ 2003-11-05 16:25:35 by bursa] Improved text-decoration support. svn path=/import/netsurf/; revision=403 --- css/ruleset.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'css/ruleset.c') diff --git a/css/ruleset.c b/css/ruleset.c index c2e84f1d1..f2994b31f 100644 --- a/css/ruleset.c +++ b/css/ruleset.c @@ -54,6 +54,7 @@ static void parse_text_decoration(struct css_style * const s, const struct css_n static void parse_visibility(struct css_style * const s, const struct css_node * const v); static void parse_width(struct css_style * const s, const struct css_node * const v); static void parse_white_space(struct css_style * const s, const struct css_node * const v); +static css_text_decoration css_text_decoration_parse(const char * const s); /* table of property parsers: MUST be sorted by property name */ @@ -90,6 +91,7 @@ static const struct colour_entry colour_table[] = { { "maroon", 0x000080 }, { "navy", 0x800000 }, { "olive", 0x008080 }, + { "orange", 0xffa500 }, { "purple", 0x800080 }, { "red", 0x0000ff }, { "silver", 0xc0c0c0 }, @@ -523,11 +525,21 @@ void parse_text_align(struct css_style * const s, const struct css_node * const void parse_text_decoration(struct css_style * const s, const struct css_node * const v) { css_text_decoration z; - if (v->type != CSS_NODE_IDENT || v->next != 0) + if (v->type != CSS_NODE_IDENT) return; z = css_text_decoration_parse(v->data); - if (z != CSS_TEXT_DECORATION_UNKNOWN) + if (z == CSS_TEXT_DECORATION_INHERIT || z == CSS_TEXT_DECORATION_NONE) { + if (v->next != 0) + return; s->text_decoration = z; + } + if (z != CSS_TEXT_DECORATION_UNKNOWN) + s->text_decoration |= z; + for (v = v->next; v; v = v->next) { + z = css_text_decoration_parse(v->data); + if (z != CSS_TEXT_DECORATION_UNKNOWN) + s->text_decoration |= z; + } } void parse_visibility(struct css_style * const s, const struct css_node * const v) @@ -561,3 +573,14 @@ void parse_white_space(struct css_style * const s, const struct css_node * const if (z != CSS_WHITE_SPACE_UNKNOWN) s->white_space = z; } + +css_text_decoration css_text_decoration_parse(const char * const s) +{ + if (strcasecmp(s, "inherit") == 0) return CSS_TEXT_DECORATION_INHERIT; + if (strcasecmp(s, "none") == 0) return CSS_TEXT_DECORATION_NONE; + if (strcasecmp(s, "blink") == 0) return CSS_TEXT_DECORATION_BLINK; + if (strcasecmp(s, "line-through") == 0) return CSS_TEXT_DECORATION_LINE_THROUGH; + if (strcasecmp(s, "overline") == 0) return CSS_TEXT_DECORATION_OVERLINE; + if (strcasecmp(s, "underline") == 0) return CSS_TEXT_DECORATION_UNDERLINE; + return CSS_TEXT_DECORATION_UNKNOWN; +} -- cgit v1.2.3