1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-29 03:17:53 -04:00

[css] Do not show css.

This commit is contained in:
Witold Filipczyk 2020-07-09 20:47:58 +02:00
parent ef848edd95
commit 38e73d9950
3 changed files with 41 additions and 5 deletions

View File

@ -83,6 +83,7 @@ struct html_context {
unsigned int skip_html:1;
unsigned int skip_select:1;
unsigned int skip_textarea:1;
unsigned int support_css:1;
/* For html/parser.c, html/renderer.c */
int margin;

View File

@ -670,15 +670,15 @@ dump_dom_element(struct source_renderer *renderer, dom_node *node, int depth)
return false;
} else {
if (DOM_TEXT_NODE == type) {
dom_string *str;
dom_string *str = NULL;
//fprintf(stderr, "skip_html=%d skip_textarea=%d skip->select=%d\n", html_context->skip_html, html_context->skip_textarea, html_context->skip_select);
if (html_context->skip_textarea || html_context->skip_select) {
if (html_context->skip_textarea || html_context->skip_select || (html_context->was_style && !html_context->support_css)) {
return true;
}
exc = dom_node_get_text_content(node, &str);
if (exc == DOM_NO_ERR && str != NULL) {
if (exc == DOM_NO_ERR && str) {
int length = dom_string_byte_length(str);
unsigned char *html = (unsigned char *)dom_string_data(str);
unsigned char *eof = html + length;
@ -688,7 +688,13 @@ dump_dom_element(struct source_renderer *renderer, dom_node *node, int depth)
length--;
eof--;
}
#ifdef CONFIG_CSS
if (html_context->was_style) {
css_parse_stylesheet(&html_context->css_styles, html_context->base_href, html, eof);
dom_string_unref(str);
return true;
}
#endif
if (length > 0) {
int noupdate = 0;
@ -926,7 +932,8 @@ next_break:
html_context->was_body = 0;
}
#endif
#if 0
/* If this is a style tag, parse it. */
#ifdef CONFIG_CSS
if (html_type == DOM_HTML_ELEMENT_TYPE_STYLE && html_context->options->css_enable) {
@ -950,6 +957,7 @@ next_break:
#endif
}
}
#endif
#endif
/* If this element is inline, non-nestable, and not <li>, and the next

View File

@ -3848,6 +3848,32 @@ tags_html_style(struct source_renderer *renderer, dom_node *node, unsigned char
struct html_context *html_context = renderer->html_context;
html_context->was_style = 1;
html_context->skip_html = 1;
#ifdef CONFIG_CSS
if (html_context->options->css_enable) {
dom_string *media_value = NULL;
unsigned char *media = NULL;
dom_exception exc = dom_html_style_element_get_media((dom_html_style_element *)node, &media_value);
if (DOM_NO_ERR == exc && media_value) {
media = memacpy(dom_string_data(media_value), dom_string_byte_length(media_value));
dom_string_unref(media_value);
}
// unsigned char *media
// = get_attr_val(attr, "media", html_context->doc_cp);
html_context->support_css = supports_html_media_attr(media);
mem_free_if(media);
// if (support)
// css_parse_stylesheet(&html_context->css_styles,
// html_context->base_href,
// html, eof);
}
#endif
//html_skip(html_context, a);
}
@ -3858,6 +3884,7 @@ tags_html_style_close(struct source_renderer *renderer, dom_node *node, unsigned
struct html_context *html_context = renderer->html_context;
html_context->was_style = 0;
html_context->skip_html = 0;
html_context->support_css = 0;
}
void