aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2008-10-29 17:54:18 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2008-10-29 17:54:18 +0100
commit722744ea0c466a212debbd86f8faefeace0d1cdb (patch)
tree2d976acef2853e7a2729be2dd81d4c73873c060e
parentbd4686970e86a67c175d5781cc84038b917b3a34 (diff)
apply to CssPropertyList instead of styleAttrs
-rw-r--r--src/css.cc42
-rw-r--r--src/css.hh19
2 files changed, 29 insertions, 32 deletions
diff --git a/src/css.cc b/src/css.cc
index 5021365f..bed8f081 100644
--- a/src/css.cc
+++ b/src/css.cc
@@ -12,18 +12,22 @@
#include <stdio.h>
#include "css.hh"
-void CssProperty::apply (dw::core::style::StyleAttrs *styleAttrs) {
- switch (name) {
-
-
- default:
- break;
+void CssPropertyList::set (CssProperty::Name name, CssProperty::Value value) {
+ for (int i = 0; i < size (); i++) {
+ if (getRef (i)->name == name) {
+ getRef (i)->value = value;
+ return;
+ }
}
+
+ increase ();
+ getRef (size () - 1)->name = name;
+ getRef (size () - 1)->value = value;
}
-void CssPropertyList::apply (dw::core::style::StyleAttrs *styleAttrs) {
+void CssPropertyList::apply (CssPropertyList *props) {
for (int i = 0; i < size (); i++)
- get (i)->apply (styleAttrs);
+ props->set (getRef (i)->name, getRef (i)->value);
}
/** \todo dummy only */
@@ -31,18 +35,15 @@ bool CssSelector::match (Doctree *docTree) {
return tagIndex < 0 || tagIndex == docTree->top ()->tagIndex;
}
-void CssRule::apply (dw::core::style::StyleAttrs *styleAttrs,
- Doctree *docTree) {
+void CssRule::apply (CssPropertyList *props, Doctree *docTree) {
if (selector->match (docTree))
- props->apply (styleAttrs);
+ this->props->apply (props);
}
-void CssStyleSheet::apply (dw::core::style::StyleAttrs *styleAttrs,
- Doctree *docTree) {
-
+void CssStyleSheet::apply (CssPropertyList *props, Doctree *docTree) {
for (int i = 0; i < size (); i++)
- get (i)->apply (styleAttrs, docTree);
+ get (i)->apply (props, docTree);
}
void CssContext::addRule (CssRule *rule, PrimaryOrder order) {
@@ -50,15 +51,14 @@ void CssContext::addRule (CssRule *rule, PrimaryOrder order) {
sheet[order].set (sheet[order].size () - 1, rule);
};
-void CssContext::apply (dw::core::style::StyleAttrs *styleAttrs,
- Doctree *docTree,
+void CssContext::apply (CssPropertyList *props, Doctree *docTree,
CssPropertyList *tagStyle, CssPropertyList *nonCss) {
- sheet[USER_AGENT].apply (styleAttrs, docTree);
+ sheet[USER_AGENT].apply (props, docTree);
if (nonCss)
- nonCss->apply (styleAttrs);
+ nonCss->apply (props);
for (int o = USER; o <= USER_IMPORTANT; o++)
- sheet[o].apply (styleAttrs, docTree);
+ sheet[o].apply (props, docTree);
if (tagStyle)
- nonCss->apply (styleAttrs);
+ nonCss->apply (props);
}
diff --git a/src/css.hh b/src/css.hh
index 36067a3e..70e2680e 100644
--- a/src/css.hh
+++ b/src/css.hh
@@ -111,17 +111,14 @@ class CssProperty {
Name name;
Value value;
-
- CssProperty ();
- ~CssProperty ();
-
- void apply (dw::core::style::StyleAttrs *styleAttr);
};
-class CssPropertyList : public lout::misc::SimpleVector <CssProperty*> {
+class CssPropertyList : public lout::misc::SimpleVector <CssProperty> {
public:
- CssPropertyList() : lout::misc::SimpleVector <CssProperty*> (1) {};
- void apply (dw::core::style::StyleAttrs *styleAttr);
+ CssPropertyList() : lout::misc::SimpleVector <CssProperty> (1) {};
+
+ void set (CssProperty::Name name, CssProperty::Value value);
+ void apply (CssPropertyList *props);
};
/** \todo proper implementation */
@@ -152,13 +149,13 @@ class CssRule {
};
~CssRule ();
- void apply (dw::core::style::StyleAttrs *styleAttrs, Doctree *docTree);
+ void apply (CssPropertyList *props, Doctree *docTree);
};
class CssStyleSheet : public lout::misc::SimpleVector <CssRule*> {
public:
CssStyleSheet() : lout::misc::SimpleVector <CssRule*> (1) {};
- void apply (dw::core::style::StyleAttrs *styleAttrs, Doctree *docTree);
+ void apply (CssPropertyList *props, Doctree *docTree);
};
class CssContext {
@@ -176,7 +173,7 @@ class CssContext {
public:
void addRule (CssRule *rule, PrimaryOrder order);
- void apply (dw::core::style::StyleAttrs *styleAttrs,
+ void apply (CssPropertyList *props,
Doctree *docTree,
CssPropertyList *tagStyle, CssPropertyList *nonCss);
};