From 670d13728a51caedf44ea9fbed35751614111653 Mon Sep 17 00:00:00 2001 From: Miciah Dashiel Butler Masters Date: Sat, 22 Dec 2007 03:20:55 +0000 Subject: [PATCH] Optionally honour "display: none" (default off) Because ELinks's CSS support is still so incomplete, some documents still render better if "display: none" is not honoured. Therefore, it is now honoured, unless document.css.ignore_display_none = 0, which is the default. --- src/document/css/apply.c | 4 ++++ src/document/css/css.c | 7 +++++++ src/document/css/property.h | 1 + src/document/css/value.c | 2 ++ src/document/options.c | 1 + src/document/options.h | 1 + 6 files changed, 16 insertions(+) diff --git a/src/document/css/apply.c b/src/document/css/apply.c index 60c9c327a..6b8f9c591 100644 --- a/src/document/css/apply.c +++ b/src/document/css/apply.c @@ -76,6 +76,10 @@ css_apply_display(struct html_context *html_context, struct html_element *elemen * YMMV. */ element->linebreak = 2; break; + case CSS_DISP_NONE: + if (html_context->options->css_ignore_display_none) + element->invisible = 1; + break; default: INTERNAL("Bad prop->value.display %d", prop->value.display); break; diff --git a/src/document/css/css.c b/src/document/css/css.c index aaf801ae8..fffc1b8a3 100644 --- a/src/document/css/css.c +++ b/src/document/css/css.c @@ -35,6 +35,13 @@ struct option_info css_options_info[] = { "enable", 0, 1, N_("Enable adding of CSS style info to documents.")), + INIT_OPT_BOOL("document.css", N_("Ignore \"display: none\""), + "ignore_display_none", 0, 1, + N_("When enabled, elements are rendered, even when their display\n" + "property has the value \"none\". Because ELinks's CSS support is\n" + "still very incomplete, this setting can improve the way that some\n" + "documents are rendered.")), + INIT_OPT_BOOL("document.css", N_("Import external style sheets"), "import", 0, 1, N_("When enabled any external style sheets that are imported from\n" diff --git a/src/document/css/property.h b/src/document/css/property.h index 1d69cdbd3..995f460e2 100644 --- a/src/document/css/property.h +++ b/src/document/css/property.h @@ -47,6 +47,7 @@ struct css_property { enum css_display { CSS_DISP_INLINE, CSS_DISP_BLOCK, + CSS_DISP_NONE, } display; struct { enum text_style_format add, rem; diff --git a/src/document/css/value.c b/src/document/css/value.c index 329709128..e08960b80 100644 --- a/src/document/css/value.c +++ b/src/document/css/value.c @@ -300,6 +300,8 @@ css_parse_display_value(struct css_property_info *propinfo, value->display = CSS_DISP_INLINE; /* XXX */ } else if (scanner_token_contains(token, "block")) { value->display = CSS_DISP_BLOCK; + } else if (scanner_token_contains(token, "none")) { + value->display = CSS_DISP_NONE; } else { return 0; } diff --git a/src/document/options.c b/src/document/options.c index 5fd9a851f..7aef84238 100644 --- a/src/document/options.c +++ b/src/document/options.c @@ -58,6 +58,7 @@ init_document_options(struct session *ses, struct document_options *doo) /* Boolean options. */ #ifdef CONFIG_CSS doo->css_enable = get_opt_bool("document.css.enable", ses); + doo->css_ignore_display_none = get_opt_bool("document.css.ignore_display_none", ses); doo->css_import = get_opt_bool("document.css.import", ses); #endif diff --git a/src/document/options.h b/src/document/options.h index fe74691f9..9fc2baff1 100644 --- a/src/document/options.h +++ b/src/document/options.h @@ -71,6 +71,7 @@ struct document_options { * @{ */ unsigned int css_enable:1; unsigned int css_import:1; + unsigned int css_ignore_display_none:1; /** @} */ #endif