changeset 1735:9b95f6d31e13

merge
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Mon, 11 Oct 2010 21:56:57 +0200
parents 90feb0de4310 (current diff) 2c90a2e90866 (diff)
children 6b1ecbfe96b5
files src/css.cc src/html.cc
diffstat 11 files changed, 63 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/dillorc	Mon Oct 11 21:50:13 2010 +0200
+++ b/dillorc	Mon Oct 11 21:56:57 2010 +0200
@@ -46,6 +46,11 @@
 #                           RENDERING SECTION
 #-------------------------------------------------------------------------
 
+# Set the background color
+# bg_color=gray
+# bg_color=0xd6d6c0
+#bg_color=0xdcd1ba
+
 # Default fonts:
 #
 # If FLTK2 has been configured with Xft enabled (the default), you can
--- a/dw/layout.cc	Mon Oct 11 21:50:13 2010 +0200
+++ b/dw/layout.cc	Mon Oct 11 21:56:57 2010 +0200
@@ -246,7 +246,6 @@
 
    canvasHeightGreater = false;
    setSizeHints ();
-   updateBgColor ();
    queueResize ();
 }
 
@@ -609,17 +608,11 @@
       setCursor (style::CURSOR_DEFAULT);
 }
 
-void Layout::updateBgColor ()
+void Layout::setBgColor (style::Color *color)
 {
-   /* The toplevel widget should always have a defined background color,
-    * except at the beginning. Searching a defined background is not
-    * necessary. */
-   if (topLevel && topLevel->getStyle() &&
-       topLevel->getStyle()->backgroundColor)
-      bgColor = topLevel->getStyle()->backgroundColor;
-   else
-      bgColor = NULL;
-   view->setBgColor (bgColor);
+   bgColor = color;
+   if (view)
+      view->setBgColor (bgColor);
 }
 
 void Layout::resizeIdle ()
--- a/dw/layout.hh	Mon Oct 11 21:50:13 2010 +0200
+++ b/dw/layout.hh	Mon Oct 11 21:56:57 2010 +0200
@@ -202,7 +202,6 @@
    void removeAnchor (Widget *widget, char* name);
    void setCursor (style::Cursor cursor);
    void updateCursor ();
-   void updateBgColor ();
    void queueDraw (int x, int y, int width, int height);
    void queueDrawExcept (int x, int y, int width, int height,
       int ex, int ey, int ewidth, int eheight);
@@ -362,6 +361,10 @@
 
    /** \brief See dw::core::FindtextState::resetSearch. */
    inline void resetSearch () { findtextState.resetSearch (); }
+
+   void setBgColor (style::Color *color);
+
+   inline style::Color* getBgColor () { return bgColor; }
 };
 
 } // namespace dw
--- a/dw/widget.cc	Mon Oct 11 21:50:13 2010 +0200
+++ b/dw/widget.cc	Mon Oct 11 21:56:57 2010 +0200
@@ -302,8 +302,6 @@
    this->style = style;
 
    if (layout != NULL) {
-      if (parent == NULL)
-         layout->updateBgColor ();
       layout->updateCursor ();
    }
 
@@ -339,9 +337,7 @@
       widget = widget->parent;
    }
 
-   MSG_WARN("No background color found!\n");
-   return NULL;
-
+   return layout->getBgColor ();
 }
 
 
@@ -399,7 +395,9 @@
     *   widget->style->background_color is NULL (shining through).
     */
    /** \todo Background images? */
-   if (parent && style->backgroundColor)
+
+   if (style->backgroundColor &&
+       (parent || layout->getBgColor () != style->backgroundColor))
       style::drawBackground (view, &viewArea, allocation.x, allocation.y,
                              allocation.width, getHeight (), style, inverse);
 }
--- a/src/css.cc	Mon Oct 11 21:50:13 2010 +0200
+++ b/src/css.cc	Mon Oct 11 21:56:57 2010 +0200
@@ -558,8 +558,7 @@
  */
 void CssContext::buildUserAgentStyle () {
    const char *cssBuf =
-     "body  {background-color: #e0e0a3; font-family: sans-serif; color: black;"
-     "       margin: 5px}"
+     "body  {margin: 5px}"
      "big {font-size: 1.17em}"
      "blockquote, dd {margin-left: 40px; margin-right: 40px}"
      "center {text-align: center}"
--- a/src/html.cc	Mon Oct 11 21:50:13 2010 +0200
+++ b/src/html.cc	Mon Oct 11 21:56:57 2010 +0200
@@ -1715,6 +1715,9 @@
    Textblock *textblock;
    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;
@@ -1729,6 +1732,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"))) {
@@ -1753,6 +1772,14 @@
 
    html->dw->setStyle (html->styleEngine->style ());
 
+   /* Set canvas color if not already set from Html_open_html().
+    */
+   if (!bgColor)
+      bgColor = html->styleEngine->style ()->backgroundColor;
+
+   if (bgColor)
+      HT2LT(html)->setBgColor(bgColor);  
+
    /* Determine a color for visited links.
     * This color is computed once per page and used for immediate feedback
     * when clicking a link.
@@ -1777,6 +1804,7 @@
             html->styleEngine->backgroundStyle()->backgroundColor->getColor());
    }
 
+
    S_TOP(html)->parse_mode = DILLO_HTML_PARSE_MODE_BODY;
 }
 
--- a/src/prefs.c	Mon Oct 11 21:50:13 2010 +0200
+++ b/src/prefs.c	Mon Oct 11 21:56:57 2010 +0200
@@ -36,6 +36,7 @@
 void a_Prefs_init(void)
 {
    prefs.allow_white_bg = TRUE;
+   prefs.bg_color = 0xdcd1ba;
    prefs.buffered_drawing = 1;
    prefs.contrast_visited_color = TRUE;
    prefs.enterpress_forces_submit = FALSE;
--- a/src/prefs.h	Mon Oct 11 21:50:13 2010 +0200
+++ b/src/prefs.h	Mon Oct 11 21:56:57 2010 +0200
@@ -46,6 +46,7 @@
    DilloUrl *start_page;
    DilloUrl *home;
    bool_t allow_white_bg;
+   int32_t bg_color;
    bool_t contrast_visited_color;
    bool_t show_tooltip;
    int panel_size;
--- a/src/prefsparser.cc	Mon Oct 11 21:50:13 2010 +0200
+++ b/src/prefsparser.cc	Mon Oct 11 21:56:57 2010 +0200
@@ -16,11 +16,13 @@
 #include "prefs.h"
 #include "misc.h"
 #include "msg.h"
+#include "colors.h"
 
 #include "prefsparser.hh"
 
 typedef enum {
    PREFS_BOOL,
+   PREFS_COLOR,
    PREFS_STRING,
    PREFS_URL,
    PREFS_INT32,
@@ -43,10 +45,12 @@
 {
    const SymNode_t *node;
    uint_t i;
+   int st;
 
    /* Symbol array, sorted alphabetically */
    const SymNode_t symbols[] = {
       { "allow_white_bg", &prefs.allow_white_bg, PREFS_BOOL },
+      { "bg_color", &prefs.bg_color, PREFS_COLOR },
       { "buffered_drawing", &prefs.buffered_drawing, PREFS_INT32 },
       { "contrast_visited_color", &prefs.contrast_visited_color, PREFS_BOOL },
       { "enterpress_forces_submit", &prefs.enterpress_forces_submit,
@@ -122,6 +126,9 @@
       *(bool_t *)node->pref = (!dStrcasecmp(value, "yes") ||
                                !dStrcasecmp(value, "true"));
       break;
+   case PREFS_COLOR:
+      *(int32_t *)node->pref = a_Color_parse(value, *(int32_t*)node->pref,&st);
+      break;
    case PREFS_STRING:
       dFree(*(char **)node->pref);
       *(char **)node->pref = dStrdup(value);
--- a/src/uicmd.cc	Mon Oct 11 21:50:13 2010 +0200
+++ b/src/uicmd.cc	Mon Oct 11 21:56:57 2010 +0200
@@ -449,6 +449,8 @@
    // Now create the Dw render layout and viewport
    FltkPlatform *platform = new FltkPlatform ();
    Layout *layout = new Layout (platform);
+   style::Color *bgColor = style::Color::create (layout, prefs.bg_color);
+   layout->setBgColor (bgColor);
 
    FltkViewport *viewport = new FltkViewport (0, 0, 1, 1);
    if (prefs.buffered_drawing == 1)
@@ -507,6 +509,8 @@
    // Now create the Dw render layout and viewport
    FltkPlatform *platform = new FltkPlatform ();
    Layout *layout = new Layout (platform);
+   style::Color *bgColor = style::Color::create (layout, prefs.bg_color);
+   layout->setBgColor (bgColor);
 
    FltkViewport *viewport = new FltkViewport (0, 0, 1, 1);
 
--- a/src/web.cc	Mon Oct 11 21:50:13 2010 +0200
+++ b/src/web.cc	Mon Oct 11 21:56:57 2010 +0200
@@ -61,10 +61,13 @@
    if (Web->flags & WEB_RootUrl) {
       /* We have RootUrl! */
 
+      style::Color *bgColor = style::Color::create (layout, prefs.bg_color);
+      Web->bgColor = bgColor->getColor ();
+      layout->setBgColor (bgColor);
+
       /* Set a style for the widget */
       StyleEngine styleEngine (layout);
       styleEngine.startElement ("body");
-      Web->bgColor= styleEngine.backgroundStyle()->backgroundColor->getColor();
 
       dw = (Widget*) a_Mime_set_viewer(Type, Web, Call, Data);
       if (dw == NULL)