aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2008-10-28 21:27:48 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2008-10-28 21:27:48 +0100
commit3c493dd1d7470fcaaa26d18b3b8c4ebabdb1f688 (patch)
treec4197e2f3427c7c37a1ccb90c2411b4f0493f665
parentfffb653ce6ab4689cb3c5aec18e980497e73ac6d (diff)
add doctree.hh
-rw-r--r--src/css.cc8
-rw-r--r--src/css.hh66
-rw-r--r--src/doctree.hh21
-rw-r--r--src/styleengine.hh1
4 files changed, 93 insertions, 3 deletions
diff --git a/src/css.cc b/src/css.cc
index b816ea52..4cc9f59e 100644
--- a/src/css.cc
+++ b/src/css.cc
@@ -12,3 +12,11 @@
#include <stdio.h>
#include "css.hh"
+void CssProperty::apply (dw::core::style::StyleAttrs *styleAttrs) {
+ switch (name) {
+
+
+ default:
+ break;
+ }
+}
diff --git a/src/css.hh b/src/css.hh
index 50e5ae88..b59307ae 100644
--- a/src/css.hh
+++ b/src/css.hh
@@ -3,6 +3,8 @@
#include "dw/core.hh"
+#include "doctree.hh"
+
class CssProperty {
public:
typedef union {
@@ -116,19 +118,77 @@ class CssProperty {
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
diff --git a/src/doctree.hh b/src/doctree.hh
new file mode 100644
index 00000000..7d35135a
--- /dev/null
+++ b/src/doctree.hh
@@ -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
diff --git a/src/styleengine.hh b/src/styleengine.hh
index 3d6ef382..af615a44 100644
--- a/src/styleengine.hh
+++ b/src/styleengine.hh
@@ -2,6 +2,7 @@
#define __STYLEENGINE_HH__
#include "dw/core.hh"
+#include "doctree.hh"
class StyleEngine {
private: