From 0e5d05b12544a73d4ecaa4d89d22251afef92916 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Fri, 10 Oct 2003 18:13:36 +0000 Subject: [project @ 2003-10-10 18:13:36 by jmb] CSS visibility support (not collapse) svn path=/import/netsurf/; revision=361 --- css/css.c | 8 ++++++++ css/css.h | 2 ++ css/css_enums | 1 + css/ruleset.c | 12 ++++++++++++ riscos/htmlredraw.c | 11 ++++++++++- 5 files changed, 33 insertions(+), 1 deletion(-) diff --git a/css/css.c b/css/css.c index 7afdee9d1..6fd1960c2 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_VISIBILITY_VISIBLE, { CSS_WIDTH_AUTO, { { 1, CSS_UNIT_EM } } }, CSS_WHITE_SPACE_NORMAL }; @@ -63,6 +64,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_VISIBILITY_INHERIT, { CSS_WIDTH_INHERIT, { { 1, CSS_UNIT_EM } } }, CSS_WHITE_SPACE_INHERIT }; @@ -79,6 +81,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_VISIBILITY_INHERIT, { CSS_WIDTH_AUTO, { { 1, CSS_UNIT_EM } } }, CSS_WHITE_SPACE_INHERIT }; @@ -613,6 +616,7 @@ void css_dump_style(const struct css_style * const style) } fprintf(stderr, "; "); fprintf(stderr, "text-align: %s; ", css_text_align_name[style->text_align]); + fprintf(stderr, "visibility: %s", css_visibility_name[style->visibility]); fprintf(stderr, "width: "); switch (style->width.width) { case CSS_WIDTH_AUTO: fprintf(stderr, "auto"); break; @@ -685,6 +689,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->visibility != CSS_VISIBILITY_INHERIT) + style->visibility = apply->visibility; if (apply->width.width != CSS_WIDTH_INHERIT) style->width = apply->width; if (apply->white_space != CSS_WHITE_SPACE_INHERIT) @@ -754,6 +760,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->visibility != CSS_VISIBILITY_INHERIT) + style->visibility = apply->visibility; if (apply->width.width != CSS_WIDTH_INHERIT) style->width = apply->width; if (apply->white_space != CSS_WHITE_SPACE_INHERIT) diff --git a/css/css.h b/css/css.h index ae5d88433..f0a9ce620 100644 --- a/css/css.h +++ b/css/css.h @@ -68,6 +68,8 @@ struct css_style { css_text_align text_align; + css_visibility visibility; + struct { enum { CSS_WIDTH_INHERIT, CSS_WIDTH_AUTO, diff --git a/css/css_enums b/css/css_enums index 19b626026..7882baceb 100644 --- a/css/css_enums +++ b/css/css_enums @@ -18,4 +18,5 @@ css_text_align inherit left right center justify css_text_decoration none blink line_through overline underline 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 css_white_space inherit normal nowrap pre diff --git a/css/ruleset.c b/css/ruleset.c index 81ab6734c..0cda4b131 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_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); @@ -69,6 +70,7 @@ static const struct property_entry property_table[] = { { "height", parse_height }, { "line-height", parse_line_height }, { "text-align", parse_text_align }, + { "visibility", parse_visibility }, { "white-space", parse_white_space }, { "width", parse_width }, }; @@ -516,6 +518,16 @@ void parse_text_align(struct css_style * const s, const struct css_node * const s->text_align = z; } +void parse_visibility(struct css_style * const s, const struct css_node * const v) +{ + css_visibility z; + if (v->type != CSS_NODE_IDENT || v->next != 0) + return; + z = css_visibility_parse(v->data); + if (z != CSS_VISIBILITY_UNKNOWN) + s->visibility = z; +} + void parse_width(struct css_style * const s, const struct css_node * const v) { if (v->type == CSS_NODE_IDENT && strcasecmp(v->data, "auto") == 0) diff --git a/riscos/htmlredraw.c b/riscos/htmlredraw.c index d41702692..cb1ef3125 100644 --- a/riscos/htmlredraw.c +++ b/riscos/htmlredraw.c @@ -11,6 +11,7 @@ #include #include "oslib/colourtrans.h" #include "oslib/font.h" +#include "netsurf/css/css.h" #include "netsurf/content/content.h" #include "netsurf/render/html.h" #include "netsurf/riscos/gui.h" @@ -90,6 +91,14 @@ void html_redraw_box(struct content *content, struct box * box, x1 = x0 + width - 1; y0 = y1 - height + 1; + /* return if visibility is hidden or inherited visibility is hidden + */ + if (box->style->visibility == CSS_VISIBILITY_HIDDEN || + (box->style->visibility == CSS_VISIBILITY_INHERIT && + box->parent->style->visibility == CSS_VISIBILITY_HIDDEN)) { + return; + } + /* return if the box is completely outside the clip rectangle, except * for table rows which may contain cells spanning into other rows */ if (box->type != BOX_TABLE_ROW && @@ -219,7 +228,7 @@ void html_redraw_box(struct content *content, struct box * box, wimp_plot_icon(&icon); break; } - + } else if (box->text && box->font) { if (content->data.html.text_selection.selected == 1) { -- cgit v1.2.3