changeset 501:424e4f409636

add doctree.hh
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Tue, 28 Oct 2008 21:27:48 +0100
parents c049012b8b74
children e1ff5d59c338
files src/css.cc src/css.hh src/doctree.hh src/styleengine.hh
diffstat 4 files changed, 93 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/css.cc	Tue Oct 28 16:54:26 2008 +0100
+++ b/src/css.cc	Tue Oct 28 21:27:48 2008 +0100
@@ -12,3 +12,11 @@
 #include <stdio.h>
 #include "css.hh"
 
+void CssProperty::apply (dw::core::style::StyleAttrs *styleAttrs) {
+   switch (name) {
+      
+
+      default:
+         break;
+   }
+}
--- a/src/css.hh	Tue Oct 28 16:54:26 2008 +0100
+++ b/src/css.hh	Tue Oct 28 21:27:48 2008 +0100
@@ -3,6 +3,8 @@
 
 #include "dw/core.hh"
 
+#include "doctree.hh"
+
 class CssProperty {
    public:
       typedef union {
@@ -116,19 +118,77 @@
       void apply (dw::core::style::StyleAttrs *styleAttr);
 };
 
-typedef lout::container::typed::List <CssProperty> CssPropertyList;
+class CssPropertyList : public lout::misc::SimpleVector <CssProperty*> {
+   public:
+      CssPropertyList() : lout::misc::SimpleVector <CssProperty*> (1) {};
+      void apply (dw::core::style::StyleAttrs *styleAttr);
+};
 
+/** \todo proper implementation */
 class CssSelector {
+   private:
+      int tagIndex;
+      const char *klass, *id;
+
+   public:
+      CssSelector (int tagIndex, const char *klass, const char *id) {
+         this->tagIndex = tagIndex;
+         this->klass = klass;
+         this->id = id;
+      }; 
+
+      bool match (Doctree *dt);
 };
 
 class CssRule {
    private:
-      CssPropertyList props;
+      CssSelector *selector;
+      CssPropertyList *props;
 
    public:
-      CssRule ();
+      CssRule (CssSelector *selector, CssPropertyList *props) {
+         this->selector = selector;
+         this->props = props;
+      };
       ~CssRule ();
 
+      void apply (dw::core::style::StyleAttrs *styleAttr);
+};
+
+class CssStyleSheet : public lout::misc::SimpleVector <CssRule*> {
+   public:
+      CssStyleSheet() : lout::misc::SimpleVector <CssRule*> (1) {};
+      void apply (dw::core::style::StyleAttrs *styleAttr);
+};
+
+typedef enum {
+   CSS_PRIMARY_USER_IMPORTANT,
+   CSS_PRIMARY_AUTHOR_IMPORTANT,
+   CSS_PRIMARY_AUTHOR,
+   CSS_PRIMARY_USER,
+   CSS_PRIMARY_USER_AGENT
+} CssPrimaryOrder;
+
+class CssContext {
+   public:
+      typedef enum {
+         USER_IMPORTANT,
+         AUTHOR_IMPORTANT,
+         AUTHOR,
+         USER,
+         USER_AGENT
+      } PrimaryOrder;
+
+   private:
+      CssStyleSheet sheet[USER_AGENT + 1];
+
+   public:
+      void addRule (CssRule *rule, PrimaryOrder order) {
+         sheet[order].increase ();
+         sheet[order].set (sheet[order].size () - 1, rule);
+      };
+
+      void apply (dw::core::style::StyleAttrs *styleAttr);
 };
 
 #endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/doctree.hh	Tue Oct 28 21:27:48 2008 +0100
@@ -0,0 +1,21 @@
+#ifndef __DOCTREE_HH__
+#define __DOCTREE_HH__
+
+class DoctreeNode {
+   private:
+      int index;
+
+   public:
+      int tagIndex;
+      const char *klass;
+      const char *id;
+};
+
+class Doctree {
+   public:
+      virtual ~Doctree () = 0;
+      virtual const DoctreeNode *top () = 0;
+      virtual const DoctreeNode *parent (const DoctreeNode *node) = 0;
+};
+
+#endif
--- a/src/styleengine.hh	Tue Oct 28 16:54:26 2008 +0100
+++ b/src/styleengine.hh	Tue Oct 28 21:27:48 2008 +0100
@@ -2,6 +2,7 @@
 #define __STYLEENGINE_HH__
 
 #include "dw/core.hh"
+#include "doctree.hh"
 
 class StyleEngine {
    private: