diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/css.cc | 6 | ||||
-rw-r--r-- | src/css.hh | 10 | ||||
-rw-r--r-- | src/doctree.hh | 2 | ||||
-rw-r--r-- | src/html.cc | 2 | ||||
-rw-r--r-- | src/styleengine.cc | 60 | ||||
-rw-r--r-- | src/styleengine.hh | 7 |
6 files changed, 74 insertions, 13 deletions
@@ -13,7 +13,7 @@ #include "css.hh" /** \todo dummy only */ -CssPropertyList *CssPropertyList::parse (const char *buf, int buflen) { +CssPropertyList *CssPropertyList::parse (const char *buf) { return NULL; } @@ -35,13 +35,13 @@ void CssPropertyList::apply (CssPropertyList *props) { } /** \todo dummy only */ -CssSelector *CssSelector::parse (const char *buf, int buflen) { +CssSelector *CssSelector::parse (const char *buf) { return NULL; } /** \todo dummy only */ bool CssSelector::match (Doctree *docTree) { - return tagIndex < 0 || tagIndex == docTree->top ()->tagIndex; + return tag < 0 || tag == docTree->top ()->tag; } void CssRule::apply (CssPropertyList *props, Doctree *docTree) { @@ -116,7 +116,7 @@ class CssPropertyList : public lout::misc::SimpleVector <CssProperty> { public: CssPropertyList() : lout::misc::SimpleVector <CssProperty> (1) {}; - static CssPropertyList *parse (const char *buf, int buflen); + static CssPropertyList *parse (const char *buf); void set (CssProperty::Name name, CssProperty::Value value); void apply (CssPropertyList *props); }; @@ -124,17 +124,17 @@ class CssPropertyList : public lout::misc::SimpleVector <CssProperty> { /** \todo proper implementation */ class CssSelector { private: - int tagIndex; + int tag; const char *klass, *id; public: - CssSelector (int tagIndex, const char *klass, const char *id) { - this->tagIndex = tagIndex; + CssSelector (int tag, const char *klass, const char *id) { + this->tag = tag; this->klass = klass; this->id = id; }; - static CssSelector *parse (const char *buf, int buflen); + static CssSelector *parse (const char *buf); bool match (Doctree *dt); }; diff --git a/src/doctree.hh b/src/doctree.hh index 6f94a523..92960422 100644 --- a/src/doctree.hh +++ b/src/doctree.hh @@ -4,7 +4,7 @@ class DoctreeNode { public: int depth; - int tagIndex; + int tag; const char *klass; const char *id; }; diff --git a/src/html.cc b/src/html.cc index 391abfdb..6954ec9c 100644 --- a/src/html.cc +++ b/src/html.cc @@ -481,7 +481,7 @@ DilloHtml::DilloHtml(BrowserWindow *p_bw, const DilloUrl *url, stack->getRef(0)->current_bg_color = prefs.bg_color; stack->getRef(0)->hand_over_break = false; - styleEngine = new StyleEngine (); + styleEngine = new StyleEngine (HT2LT (this)); InFlags = IN_NONE; diff --git a/src/styleengine.cc b/src/styleengine.cc index 4147fb17..14a33bd3 100644 --- a/src/styleengine.cc +++ b/src/styleengine.cc @@ -12,8 +12,10 @@ #include <stdio.h> #include "styleengine.hh" -StyleEngine::StyleEngine () { +StyleEngine::StyleEngine (dw::core::Layout *layout) { stack = new lout::misc::SimpleVector <Node> (1); + cssContext = new CssContext (); + this->layout = layout; } StyleEngine::~StyleEngine () { @@ -21,11 +23,65 @@ StyleEngine::~StyleEngine () { } void -StyleEngine::startElement (int tag, const char *id, const char *klass, const char *style) { +StyleEngine::startElement (int tag, const char *id, const char *klass, + const char *style) { fprintf(stderr, "===> START %d %s %s %s\n", tag, id, klass, style); + + if (stack->getRef (stack->size () - 1)->style == NULL) + stack->getRef (stack->size () - 1)->style = style0 (); + + stack->increase (); + Node *n = stack->getRef (stack->size () - 1); + n->style = NULL; + n->nonCssProperties = NULL; + n->depth = stack->size (); + n->tag = tag; + n->id = id; + n->klass = klass; + n->styleAttribute = style; +} + +void +StyleEngine::setNonCssProperties (CssPropertyList *props) { + stack->getRef (stack->size () - 1)->nonCssProperties = props; } void StyleEngine::endElement (int tag) { fprintf(stderr, "===> END %d\n", tag); + stack->setSize (stack->size () - 1); +} + +void StyleEngine::apply (dw::core::style::StyleAttrs *attr, + CssPropertyList *props) { + + for (int i = 0; i < props->size (); i++) { + CssProperty *p = props->getRef (i); + + switch (p->name) { + + + default: + break; + } + } +} + +dw::core::style::Style * StyleEngine::style0 () { + CssPropertyList props; + CssPropertyList *tagStyleProps = CssPropertyList::parse ( + stack->getRef (stack->size () - 1)->styleAttribute); + + dw::core::style::StyleAttrs attrs = + *stack->getRef (stack->size () - 1)->style; + + cssContext->apply (&props, this, tagStyleProps, + stack->getRef (stack->size () - 1)->nonCssProperties); + + apply (&attrs, &props); + + stack->getRef (stack->size () - 1)->style = + dw::core::style::Style::create (layout, &attrs); + + return NULL; } diff --git a/src/styleengine.hh b/src/styleengine.hh index 97d6c8ae..39591633 100644 --- a/src/styleengine.hh +++ b/src/styleengine.hh @@ -10,14 +10,19 @@ class StyleEngine : public Doctree { class Node : public DoctreeNode { public: dw::core::style::Style *style; + CssPropertyList *nonCssProperties; + const char *styleAttribute; }; + dw::core::Layout *layout; lout::misc::SimpleVector <Node> *stack; + CssContext *cssContext; dw::core::style::Style *style0 (); + void apply (dw::core::style::StyleAttrs *attrs, CssPropertyList *props); public: - StyleEngine (); + StyleEngine (dw::core::Layout *layout); ~StyleEngine (); /* Doctree interface */ |