view src/styleengine.hh @ 982:d04d960da3f4

remove bg_color dillorc option To set a custom background color add a line like: body {background-color: white} to your ~/.dillo/style.css file. This also works for plain text display and image viewing.
author Johannes Hofmann <>
date Fri, 06 Mar 2009 10:09:38 +0100
parents dd46fa6ceb94
children 36d9fee90159
line wrap: on
line source
#ifndef __STYLEENGINE_HH__
#define __STYLEENGINE_HH__

#include "dw/core.hh"
#include "doctree.hh"
#include "css.hh"
#include "cssparser.hh"

class StyleEngine : public Doctree {
      class Node : public DoctreeNode {
            dw::core::style::Style *style;
            dw::core::style::Style *wordStyle;
            const char *styleAttribute;
            bool inheritBackgroundColor;

      dw::core::Layout *layout;
      lout::misc::SimpleVector <Node> *stack;
      CssContext *cssContext;
      int num;

      dw::core::style::Style *style0 (CssPropertyList *nonCssHints = NULL);
      dw::core::style::Style *wordStyle0 (CssPropertyList *nonCssHints = NULL);
      void apply (dw::core::style::StyleAttrs *attrs, CssPropertyList *props);
      bool computeValue (int *dest, CssLength value, dw::core::style::Font *font);
      bool computeValue (int *dest, CssLength value, dw::core::style::Font *font,
         int percentageBase);
      bool computeLength (dw::core::style::Length *dest, CssLength value, dw::core::style::Font *font);

      StyleEngine (dw::core::Layout *layout);
      ~StyleEngine ();

      /* Doctree interface */
      inline const DoctreeNode *top () {
         return stack->getRef (stack->size () - 1);

      inline const DoctreeNode *parent (const DoctreeNode *n) {
         if (n->depth > 1)
            return stack->getRef (n->depth - 1);
            return NULL;

      void parse (const char *buf, int buflen, CssOrigin origin);
      void startElement (int tag);
      void startElement (const char *tagname);
      void setId (const char *id);
      const char * getId () { return top ()->id; };
      void setClass (const char *klass);
      void setStyle (const char *style);
      void endElement (int tag);
      void setPseudoLink ();
      void setPseudoVisited ();
      void setNonCssHints (CssPropertyList *nonCssHints);
      void inheritBackgroundColor (); /* \todo get rid of this somehow */
      dw::core::style::Style *backgroundStyle ();

      inline dw::core::style::Style *style () {
         dw::core::style::Style *s = stack->getRef (stack->size () - 1)->style;
         if (s)
            return s;
            return style0 ();
      inline dw::core::style::Style *wordStyle () {
         dw::core::style::Style *s = stack->getRef (stack->size () - 1)->wordStyle;
         if (s)
            return s;
            return wordStyle0 ();