aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-03-10 12:54:59 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2009-03-10 12:54:59 +0100
commitd4a1b71555071730503f09db02c562e48cf06419 (patch)
tree88a8d7940c408aa525522e7fcb053d6c71d08242 /src
parent45033ba07b58cafbc9fa9ab6881c92dd92243aaf (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/html.cc43
-rw-r--r--src/html_common.hh5
-rw-r--r--src/prefs.c4
-rw-r--r--src/prefs.h1
4 files changed, 35 insertions, 18 deletions
diff --git a/src/html.cc b/src/html.cc
index e3d9653b..f6ef5994 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -462,7 +462,8 @@ DilloHtml::DilloHtml(BrowserWindow *p_bw, const DilloUrl *url,
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 @@ static void Html_tag_open_body(DilloHtml *html, const char *tag, int tagsize)
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 @@ static void Html_tag_open_body(DilloHtml *html, const char *tag, int tagsize)
}
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 @@ static void Html_tag_open_a(DilloHtml *html, const char *tag, int tagsize)
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,
diff --git a/src/html_common.hh b/src/html_common.hh
index 8856825d..88de079c 100644
--- a/src/html_common.hh
+++ b/src/html_common.hh
@@ -204,8 +204,9 @@ public: //BUG: for now everything is public
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) */
diff --git a/src/prefs.c b/src/prefs.c
index 76200470..ddd44d72 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -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 @@ static int Prefs_parse_dillorc(void)
{ "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 @@ void a_Prefs_init(void)
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 */
diff --git a/src/prefs.h b/src/prefs.h
index 955515bb..485d146d 100644
--- a/src/prefs.h
+++ b/src/prefs.h
@@ -29,7 +29,6 @@ struct _DilloPrefs {
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;