1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

Apply styles of html element for body element.

See test/css/css_body.html and test/css/css_html.html
This commit is contained in:
witekfl 2012-05-22 15:22:48 +02:00
parent ce48dc5ffd
commit 5f9b54f594
2 changed files with 18 additions and 0 deletions

View File

@ -42,6 +42,7 @@ struct html_context {
* from <style>-tags and external stylesheets if enabled is merged * from <style>-tags and external stylesheets if enabled is merged
* added to it. */ * added to it. */
struct css_stylesheet css_styles; struct css_stylesheet css_styles;
struct html_element html;
#endif #endif
/* These are global per-document base values, alterable by the <base> /* These are global per-document base values, alterable by the <base>
@ -79,6 +80,7 @@ struct html_context {
unsigned int has_link_lines:1; unsigned int has_link_lines:1;
unsigned int was_body:1; /* For META refresh inside <body>. */ unsigned int was_body:1; /* For META refresh inside <body>. */
unsigned int was_body_background:1; /* For <HTML> with style. */ unsigned int was_body_background:1; /* For <HTML> with style. */
unsigned int was_html:1; /* was <HTML> */
/* For html/parser.c, html/renderer.c */ /* For html/parser.c, html/renderer.c */
int margin; int margin;

View File

@ -647,6 +647,7 @@ parse_html(unsigned char *html, unsigned char *eof,
html_context->was_br = 0; html_context->was_br = 0;
html_context->was_li = 0; html_context->was_li = 0;
html_context->was_body = 0; html_context->was_body = 0;
html_context->was_html = 0;
/* html_context->was_body_background = 0; */ /* html_context->was_body_background = 0; */
html_context->part = part; html_context->part = part;
html_context->eoff = eof; html_context->eoff = eof;
@ -950,6 +951,21 @@ start_element(struct element_info *ei,
/* Apply CSS styles. */ /* Apply CSS styles. */
#ifdef CONFIG_CSS #ifdef CONFIG_CSS
if (html_top->options && html_context->options->css_enable) { if (html_top->options && html_context->options->css_enable) {
if (ei->open == html_html) {
html_context->html = *html_top;
html_context->was_html = 1;
}
if (ei->open == html_body && html_context->was_html == 1) {
selector = get_css_selector_for_element(html_context,
&html_context->html,
&html_context->css_styles,
&html_context->stack);
if (selector) {
apply_css_selector_style(html_context, html_top, selector);
done_css_selector(selector);
}
}
/* XXX: We should apply CSS otherwise as well, but that'll need /* XXX: We should apply CSS otherwise as well, but that'll need
* some deeper changes in order to have options filled etc. * some deeper changes in order to have options filled etc.
* Probably just applying CSS from more places, since we * Probably just applying CSS from more places, since we