changeset 992:5e2c7a06f7ab

replace visited_color dillorc option to change the color of visited links add a line :visited {color: red} to your ~/.dillo/style.css file instead.
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Tue, 10 Mar 2009 12:54:59 +0100
parents 49cf18b45335
children 6fa2d325a913
files ChangeLog src/html.cc src/html_common.hh src/prefs.c src/prefs.h
diffstat 5 files changed, 36 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Mar 09 21:30:03 2009 +0000
+++ b/ChangeLog	Tue Mar 10 12:54:59 2009 +0100
@@ -68,6 +68,7 @@
  - Replace bg_color dillorc option.
  - Remove text_color, link_color, and force_my_colors dillorc options.
  - Fix CSS string parsing bug.
+ - Replace visited_color dillorc option.
    Patches: Johannes Hofmann
 +- Updated the GPL copyright note in the source files.
    Patch: Detlef Riekenberg
--- a/src/html.cc	Mon Mar 09 21:30:03 2009 +0000
+++ b/src/html.cc	Tue Mar 10 12:54:59 2009 +0100
@@ -462,7 +462,8 @@
 
    attr_data = dStr_sized_new(1024);
 
-   link_color = -1;
+   non_css_link_color = -1;
+   non_css_visited_color = -1;
    visited_color = -1;
 
    /* Init page-handling variables */
@@ -1678,6 +1679,7 @@
    Textblock *textblock;
    CssPropertyList props;
    int32_t color;
+   int tag_index_a = a_Html_tag_index ("a");
 
    if (!(html->InFlags & IN_BODY))
       html->InFlags |= IN_BODY;
@@ -1707,21 +1709,38 @@
    }
 
    if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "link")))
-      html->link_color = a_Html_color_parse(html, attrbuf, -1);
+      html->non_css_link_color = a_Html_color_parse(html, attrbuf, -1);
 
    if ((attrbuf = a_Html_get_attr(html, tag, tagsize, "vlink")))
-      html->visited_color = a_Html_color_parse(html, attrbuf, -1);
+      html->non_css_visited_color = a_Html_color_parse(html, attrbuf, -1);
 
    html->styleEngine->setNonCssHints (&props);
    html->dw->setStyle (html->styleEngine->style ());
 
+   /* Determine a color for visited links.
+    * This color is computed once per page and used for immediate feedback
+    * when clicking a link.
+    * On reload style including color for visited links is computed properly
+    * according to CSS.
+    */
+   html->styleEngine->startElement (tag_index_a);
+   html->styleEngine->setPseudoVisited ();
+   if (html->non_css_visited_color != -1) {
+      CssPropertyList vprops; 
+      vprops.set (CSS_PROPERTY_COLOR, CSS_TYPE_COLOR,
+                 html->non_css_visited_color);
+      html->styleEngine->setNonCssHints (&vprops);
+   }
+   html->visited_color = html->styleEngine->style ()->color->getColor ();
+   html->styleEngine->endElement (tag_index_a);
+
    if (prefs.contrast_visited_color) {
       /* get a color that has a "safe distance" from text, link and bg */
       html->visited_color =
-            a_Color_vc(html->visited_color,
-                       html->styleEngine->style ()->color->getColor(),
-                       html->link_color,
-                       S_TOP(html)->current_bg_color);
+         a_Color_vc(html->visited_color,
+            html->styleEngine->style ()->color->getColor(),
+            html->non_css_link_color,
+            S_TOP(html)->current_bg_color);
    }
 
    S_TOP(html)->parse_mode = DILLO_HTML_PARSE_MODE_BODY;
@@ -2371,12 +2390,14 @@
       if (a_Capi_get_flags(url) & CAPI_IsCached) {
          html->InVisitedLink = true;
          html->styleEngine->setPseudoVisited ();
-         if (html->visited_color != -1)
-            props.set (CSS_PROPERTY_COLOR,CSS_TYPE_COLOR,html->visited_color);
+         if (html->non_css_visited_color != -1)
+            props.set (CSS_PROPERTY_COLOR, CSS_TYPE_COLOR,
+                       html->non_css_visited_color);
       } else {
          html->styleEngine->setPseudoLink ();
-         if (html->link_color != -1)
-            props.set (CSS_PROPERTY_COLOR, CSS_TYPE_COLOR, html->link_color);
+         if (html->non_css_link_color != -1)
+            props.set (CSS_PROPERTY_COLOR, CSS_TYPE_COLOR,
+                       html->non_css_link_color);
       }
 
       props.set (PROPERTY_X_LINK, CSS_TYPE_INTEGER,
--- a/src/html_common.hh	Mon Mar 09 21:30:03 2009 +0000
+++ b/src/html_common.hh	Tue Mar 10 12:54:59 2009 +0100
@@ -204,8 +204,9 @@
 
    Dstr *attr_data;       /* Buffer for attribute value */
 
-   int32_t link_color;
-   int32_t visited_color;
+   int32_t non_css_link_color; /* as provided by link attribute in <body> */
+   int32_t non_css_visited_color; /* as provided by vlink attribute in <body> */
+   int32_t visited_color; /* as computed according to CSS */
 
    /* -------------------------------------------------------------------*/
    /* Variables required after parsing (for page functionality)          */
--- a/src/prefs.c	Mon Mar 09 21:30:03 2009 +0000
+++ b/src/prefs.c	Tue Mar 10 12:54:59 2009 +0100
@@ -43,8 +43,6 @@
 #define D_SEARCH_URL "http://www.google.com/search?ie=UTF-8&oe=UTF-8&q=%s"
 #define D_SAVE_DIR "/tmp/"
 
-#define DW_COLOR_DEFAULT_VLINK  0x800080
-
 /*-----------------------------------------------------------------------------
  * Global Data
  *---------------------------------------------------------------------------*/
@@ -199,7 +197,6 @@
    { "show_url", &prefs.show_url, PREFS_BOOL },
    { "small_icons", &prefs.small_icons, PREFS_BOOL },
    { "start_page", &prefs.start_page, PREFS_URL },
-   { "visited_color", &prefs.visited_color, PREFS_COLOR },
    { "w3c_plus_heuristics", &prefs.w3c_plus_heuristics, PREFS_BOOL }
    };
 
@@ -306,7 +303,6 @@
    prefs.show_url=TRUE;
    prefs.small_icons = FALSE;
    prefs.start_page = a_Url_new(DILLO_START_PAGE, NULL);
-   prefs.visited_color = DW_COLOR_DEFAULT_VLINK;
    prefs.w3c_plus_heuristics = TRUE;
 
    /* this locale stuff is to avoid parsing problems with float numbers */
--- a/src/prefs.h	Mon Mar 09 21:30:03 2009 +0000
+++ b/src/prefs.h	Tue Mar 10 12:54:59 2009 +0100
@@ -29,7 +29,6 @@
    char *no_proxy;
    DilloUrl *start_page;
    DilloUrl *home;
-   int32_t visited_color;
    bool_t allow_white_bg;
    bool_t contrast_visited_color;
    bool_t show_tooltip;