diff options
-rw-r--r-- | src/css.cc | 8 | ||||
-rw-r--r-- | src/css.hh | 66 | ||||
-rw-r--r-- | src/doctree.hh | 21 | ||||
-rw-r--r-- | src/styleengine.hh | 1 |
4 files changed, 93 insertions, 3 deletions
@@ -12,3 +12,11 @@ #include <stdio.h> #include "css.hh" +void CssProperty::apply (dw::core::style::StyleAttrs *styleAttrs) { + switch (name) { + + + default: + break; + } +} @@ -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: |