changeset 679:14ce954d98c0

inherit pseudo classes "link" and "visited"
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Sun, 14 Dec 2008 22:21:18 +0100
parents d8829df904cf
children d79762895bd9
files src/html.cc src/styleengine.cc src/styleengine.hh
diffstat 3 files changed, 17 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/html.cc	Sun Dec 14 21:58:05 2008 +0100
+++ b/src/html.cc	Sun Dec 14 22:21:18 2008 +0100
@@ -2414,11 +2414,11 @@
 
       if (a_Capi_get_flags(url) & CAPI_IsCached) {
          html->InVisitedLink = true;
-         html->styleEngine->setPseudo ("visited");
+         html->styleEngine->setPseudoVisited ();
          if (html->visited_color != -1)
             props.set (CssProperty::CSS_PROPERTY_COLOR, html->visited_color);
       } else {
-         html->styleEngine->setPseudo ("link");
+         html->styleEngine->setPseudoLink ();
          if (html->link_color != -1)
             props.set (CssProperty::CSS_PROPERTY_COLOR, html->link_color);
       }
--- a/src/styleengine.cc	Sun Dec 14 21:58:05 2008 +0100
+++ b/src/styleengine.cc	Sun Dec 14 22:21:18 2008 +0100
@@ -39,6 +39,7 @@
    style_attrs.backgroundColor = Color::create (layout, 0xffffff);
    
    n->style = Style::create (layout, &style_attrs);
+   n->pseudo = NULL;
 }
 
 StyleEngine::~StyleEngine () {
@@ -64,7 +65,7 @@
    n->element = element;
    n->id = NULL;
    n->klass = NULL;
-   n->pseudo = NULL;
+   n->pseudo = stack->getRef (stack->size () - 2)->pseudo; // inherit pseudo
    n->styleAttribute = NULL;
    n->inheritBackgroundColor = false;
 }
@@ -108,12 +109,19 @@
 }
 
 /**
- * \brief set the CSS pseudo class (e.g. "link", "visited").
+ * \brief set the CSS pseudo class :link.
  */
-void StyleEngine::setPseudo (const char *pseudo) {
+void StyleEngine::setPseudoLink () {
    Node *n =  stack->getRef (stack->size () - 1);
-   assert (n->pseudo == NULL);
-   n->pseudo = dStrdup (pseudo);
+   n->pseudo = "link";
+}
+
+/**
+ * \brief set the CSS pseudo class :visited.
+ */
+void StyleEngine::setPseudoVisited () {
+   Node *n =  stack->getRef (stack->size () - 1);
+   n->pseudo = "visited";
 }
 
 /**
--- a/src/styleengine.hh	Sun Dec 14 21:58:05 2008 +0100
+++ b/src/styleengine.hh	Sun Dec 14 22:21:18 2008 +0100
@@ -50,7 +50,8 @@
       void setClass (const char *klass);
       void setStyle (const char *style);
       void endElement (int tag);
-      void setPseudo (const char *pseudo);
+      void setPseudoLink ();
+      void setPseudoVisited ();
       void setNonCssHints (CssPropertyList *nonCssHints);
       void inheritBackgroundColor (); /* \todo get rid of this somehow */