From c97107af5cad3c96f75c566880ff139ce378ee62 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Fri, 17 Oct 2003 23:47:13 +0000 Subject: [project @ 2003-10-17 23:47:13 by jmb] Add text-decoration support. Overline needs work. a:link defaults to being underlined. svn path=/import/netsurf/; revision=368 --- !NetSurf/!Run,feb | 2 +- !NetSurf/Resources/CSS,f79 | 2 +- Docs/TODO-CSS | 6 +++--- css/css.c | 7 +++++++ css/css.h | 1 + css/css_enums | 2 +- css/ruleset.c | 12 ++++++++++++ riscos/htmlredraw.c | 47 +++++++++++++++++++++++++++++++++++++++++++--- 8 files changed, 70 insertions(+), 9 deletions(-) diff --git a/!NetSurf/!Run,feb b/!NetSurf/!Run,feb index 61463bbdf..b32a481dd 100644 --- a/!NetSurf/!Run,feb +++ b/!NetSurf/!Run,feb @@ -39,7 +39,7 @@ RMEnsure MimeMap 0.10 Error NetSurf requires MimeMap 0.10 or later | drag the 'next' slot in the task manager to something huge and ridiculous, | and/or increase the number below -Wimpslot -min 2000k +Wimpslot -min 2750k -max 2750k Set NetSurf$running "yes" .!RunImage 2>.stderr diff --git a/!NetSurf/Resources/CSS,f79 b/!NetSurf/Resources/CSS,f79 index 4595ec20d..27e7f73d1 100644 --- a/!NetSurf/Resources/CSS,f79 +++ b/!NetSurf/Resources/CSS,f79 @@ -27,7 +27,7 @@ h5 { font-size: medium; font-style: italic; } h6 { font-size: medium; font-style: italic; } b, strong { font-weight: bold; } i, em { font-style: italic; } -a:link { color: #00f; } +a:link { color: #00f; text-decoration: line-through; } th { font-weight: bold; } td { text-align: left; } diff --git a/Docs/TODO-CSS b/Docs/TODO-CSS index b68755924..65b276b7e 100644 --- a/Docs/TODO-CSS +++ b/Docs/TODO-CSS @@ -1,4 +1,4 @@ -$Id: TODO-CSS,v 1.3 2003/10/09 15:46:30 bursa Exp $ +$Id: TODO-CSS,v 1.4 2003/10/17 23:47:13 jmb Exp $ TODO-CSS file for NetSurf. @@ -77,14 +77,14 @@ See TODO-HTML for HTML related TODOs. - size - table-layout + text-align -- text-decoration += text-decoration (not blink. overline needs positioning right) - text-indent - text-shadow - text-transform - top - unicode-bidi - vertical-align -- visibility += visibility (not collapse) = white-space - widows + width diff --git a/css/css.c b/css/css.c index d2f4ef679..ec0084ec8 100644 --- a/css/css.c +++ b/css/css.c @@ -47,6 +47,7 @@ const struct css_style css_base_style = { { CSS_HEIGHT_AUTO, { 1, CSS_UNIT_EM } }, { CSS_LINE_HEIGHT_ABSOLUTE, { 1.3 } }, CSS_TEXT_ALIGN_LEFT, + CSS_TEXT_DECORATION_NONE, CSS_VISIBILITY_VISIBLE, { CSS_WIDTH_AUTO, { { 1, CSS_UNIT_EM } } }, CSS_WHITE_SPACE_NORMAL @@ -64,6 +65,7 @@ const struct css_style css_empty_style = { { CSS_HEIGHT_INHERIT, { 1, CSS_UNIT_EM } }, { CSS_LINE_HEIGHT_INHERIT, { 1.3 } }, CSS_TEXT_ALIGN_INHERIT, + CSS_TEXT_DECORATION_INHERIT, CSS_VISIBILITY_INHERIT, { CSS_WIDTH_INHERIT, { { 1, CSS_UNIT_EM } } }, CSS_WHITE_SPACE_INHERIT @@ -81,6 +83,7 @@ const struct css_style css_blank_style = { { CSS_HEIGHT_AUTO, { 1, CSS_UNIT_EM } }, { CSS_LINE_HEIGHT_INHERIT, { 1.3 } }, CSS_TEXT_ALIGN_INHERIT, + CSS_TEXT_DECORATION_NONE, CSS_VISIBILITY_INHERIT, { CSS_WIDTH_AUTO, { { 1, CSS_UNIT_EM } } }, CSS_WHITE_SPACE_INHERIT @@ -709,6 +712,8 @@ void css_cascade(struct css_style * const style, const struct css_style * const style->line_height = apply->line_height; if (apply->text_align != CSS_TEXT_ALIGN_INHERIT) style->text_align = apply->text_align; + if (apply->text_decoration != CSS_TEXT_DECORATION_INHERIT) + style->text_decoration = apply->text_decoration; if (apply->visibility != CSS_VISIBILITY_INHERIT) style->visibility = apply->visibility; if (apply->width.width != CSS_WIDTH_INHERIT) @@ -780,6 +785,8 @@ void css_merge(struct css_style * const style, const struct css_style * const ap style->line_height = apply->line_height; if (apply->text_align != CSS_TEXT_ALIGN_INHERIT) style->text_align = apply->text_align; + if (apply->text_decoration != CSS_TEXT_DECORATION_INHERIT) + style->text_decoration = apply->text_decoration; if (apply->visibility != CSS_VISIBILITY_INHERIT) style->visibility = apply->visibility; if (apply->width.width != CSS_WIDTH_INHERIT) diff --git a/css/css.h b/css/css.h index c58da6509..9bf843efe 100644 --- a/css/css.h +++ b/css/css.h @@ -68,6 +68,7 @@ struct css_style { } line_height; css_text_align text_align; + css_text_decoration text_decoration; css_visibility visibility; diff --git a/css/css_enums b/css/css_enums index 7882baceb..49fd5870f 100644 --- a/css/css_enums +++ b/css/css_enums @@ -15,7 +15,7 @@ css_list_style_position outside inside css_list_style_type disc circle square decimal lower_alpha lower_roman upper_alpha upper_roman none css_margin auto length percent css_text_align inherit left right center justify -css_text_decoration none blink line_through overline underline +css_text_decoration none blink line-through overline underline inherit css_text_transform none capitalize lowercase uppercase css_vertical_align baseline bottom middle sub super text_bottom text_top top percent css_visibility inherit visible hidden diff --git a/css/ruleset.c b/css/ruleset.c index 0cda4b131..c2e84f1d1 100644 --- a/css/ruleset.c +++ b/css/ruleset.c @@ -50,6 +50,7 @@ static void parse_font_weight(struct css_style * const s, const struct css_node static void parse_height(struct css_style * const s, const struct css_node * const v); static void parse_line_height(struct css_style * const s, const struct css_node * const v); static void parse_text_align(struct css_style * const s, const struct css_node * const v); +static void parse_text_decoration(struct css_style * const s, const struct css_node * const v); 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); @@ -70,6 +71,7 @@ static const struct property_entry property_table[] = { { "height", parse_height }, { "line-height", parse_line_height }, { "text-align", parse_text_align }, + { "text-decoration", parse_text_decoration }, { "visibility", parse_visibility }, { "white-space", parse_white_space }, { "width", parse_width }, @@ -518,6 +520,16 @@ void parse_text_align(struct css_style * const s, const struct css_node * const s->text_align = z; } +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) + return; + 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) { css_visibility z; diff --git a/riscos/htmlredraw.c b/riscos/htmlredraw.c index f4a6c50de..0a8561421 100644 --- a/riscos/htmlredraw.c +++ b/riscos/htmlredraw.c @@ -16,6 +16,7 @@ #include "netsurf/render/html.h" #include "netsurf/riscos/gui.h" #include "netsurf/utils/log.h" +#include "netsurf/utils/utils.h" static void html_redraw_box(struct content *content, struct box * box, @@ -282,12 +283,52 @@ void html_redraw_box(struct content *content, struct box * box, colourtrans_set_font_colours(box->font->handle, current_background_color << 8, box->style->color << 8, 14, 0, 0, 0); - - font_paint(box->font->handle, box->text, + if (box->style->text_decoration == CSS_TEXT_DECORATION_NONE) { + font_paint(box->font->handle, box->text, font_OS_UNITS | font_GIVEN_FONT | font_KERN | font_GIVEN_LENGTH, x, y - (int) (box->height * 1.5), NULL, NULL, (int) box->length); - + } + else if (box->style->text_decoration == CSS_TEXT_DECORATION_UNDERLINE) { + char ulctrl[3]; + char *temp = xcalloc(strlen(box->text)+4, + sizeof(char)); + sprintf(ulctrl, "%c%c%c", (char)25, (char)230, + (char)10); + sprintf(temp, "%s%s", ulctrl, box->text); + font_paint(box->font->handle, temp, + font_OS_UNITS | font_GIVEN_FONT | font_KERN | font_GIVEN_LENGTH, + x, y - (int) (box->height * 1.5), + NULL, NULL, (int) box->length + 4); + xfree(temp); + } + else if (box->style->text_decoration == CSS_TEXT_DECORATION_LINE_THROUGH){ + char ulctrl[3]; + char *temp = xcalloc(strlen(box->text)+4, + sizeof(char)); + sprintf(ulctrl, "%c%c%c", (char)25, (char)95, + (char)10); + sprintf(temp, "%s%s", ulctrl, box->text); + font_paint(box->font->handle, temp, + font_OS_UNITS | font_GIVEN_FONT | font_KERN | font_GIVEN_LENGTH, + x, y - (int) (box->height * 1.5), + NULL, NULL, (int) box->length + 4); + xfree(temp); + LOG(("line-through")); + } + else { + char ulctrl[3]; + char *temp = xcalloc(strlen(box->text)+4, + sizeof(char)); + sprintf(ulctrl, "%c%c%c", (char)25, (char)127, + (char)10); + sprintf(temp, "%s%s", ulctrl, box->text); + font_paint(box->font->handle, temp, + font_OS_UNITS | font_GIVEN_FONT | font_KERN | font_GIVEN_LENGTH, + x, y - (int) (box->height * 1.5), + NULL, NULL, (int) box->length + 4); + xfree(temp); + } } else { for (c = box->children; c != 0; c = c->next) if (c->type != BOX_FLOAT_LEFT && c->type != BOX_FLOAT_RIGHT) -- cgit v1.2.3