aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2010-09-17 23:16:43 +0200
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2010-09-17 23:16:43 +0200
commit301d6d61c841a7456f0b5f0fd1f6142b0ed933df (patch)
tree67bfc07f27ec1c45c06c57443a2c6162c3e2e22d
parentde069598570c05a2bb8359700872974e24f9eee6 (diff)
recompute style for <html> in Html_open_body()
The CSS style information is only available after <head> has been parsed completely. So we redo the style for the <html> tag in Html_open_body(). Also set the canvas color either as background color of the <html> or the <body> tag (see http://www.w3.org/TR/CSS2/colors.html).
-rw-r--r--src/html.cc31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/html.cc b/src/html.cc
index 9649b42e..c46ec4af 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -1569,16 +1569,10 @@ static void Html_parse_doctype(DilloHtml *html, const char *tag, int tagsize)
*/
static void Html_tag_open_html(DilloHtml *html, const char *tag, int tagsize)
{
- Style *style;
-
if (!(html->InFlags & IN_HTML))
html->InFlags |= IN_HTML;
++html->Num_HTML;
- style = html->styleEngine->style ();
- if (style->backgroundColor)
- HT2LT(html)->setBgColor(style->backgroundColor);
-
if (html->Num_HTML > 1) {
BUG_MSG("HTML element was already open\n");
}
@@ -1731,6 +1725,9 @@ static void Html_tag_open_body(DilloHtml *html, const char *tag, int tagsize)
CssPropertyList props;
int32_t color;
int tag_index_a = a_Html_tag_index ("a");
+ int tag_index_body = a_Html_tag_index ("body");
+ int tag_index_html = a_Html_tag_index ("html");
+ style::Color *bgColor;
if (!(html->InFlags & IN_BODY))
html->InFlags |= IN_BODY;
@@ -1745,6 +1742,22 @@ static void Html_tag_open_body(DilloHtml *html, const char *tag, int tagsize)
BUG_MSG("unclosed HEAD element\n");
}
+ html->styleEngine->endElement(tag_index_body);
+ html->styleEngine->endElement(tag_index_html);
+ html->styleEngine->startElement(tag_index_html);
+ bgColor = html->styleEngine->style ()->backgroundColor;
+ html->styleEngine->startElement(tag_index_body);
+
+ if ((attrbuf = Html_get_attr2(html, tag, tagsize, "id",
+ HTML_LeftTrim | HTML_RightTrim)))
+ html->styleEngine->setId(attrbuf);
+ if ((attrbuf = Html_get_attr2(html, tag, tagsize, "class",
+ HTML_LeftTrim | HTML_RightTrim)))
+ html->styleEngine->setClass(attrbuf);
+ if ((attrbuf = Html_get_attr2(html, tag, tagsize, "style",
+ HTML_LeftTrim | HTML_RightTrim)))
+ html->styleEngine->setStyle(attrbuf);
+
textblock = HT2TB(html);
if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "bgcolor"))) {
@@ -1770,8 +1783,10 @@ static void Html_tag_open_body(DilloHtml *html, const char *tag, int tagsize)
/* Set canvas color if not already set from Html_open_html().
*/
- if (! HT2LT(html)->getBgColor())
- HT2LT(html)->setBgColor(html->styleEngine->style ()->backgroundColor);
+ if (!bgColor)
+ bgColor = html->styleEngine->style ()->backgroundColor;
+
+ HT2LT(html)->setBgColor(bgColor);
/* Determine a color for visited links.
* This color is computed once per page and used for immediate feedback