changeset 1727:beea6d3a79a7

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).
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Fri, 17 Sep 2010 23:16:43 +0200
parents 548d4f2bc61d
children ea58555667ac
files src/html.cc
diffstat 1 files changed, 23 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/html.cc	Fri Sep 17 23:13:27 2010 +0200
+++ b/src/html.cc	Fri Sep 17 23:16:43 2010 +0200
@@ -1569,16 +1569,10 @@
  */
 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 @@
    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 @@
       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 @@
 
    /* 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