aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2011-12-30 21:44:31 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2011-12-30 21:44:31 +0100
commit7c3b1795f94aacce1c44c3c7c821cefc2fe2b671 (patch)
treed97dc5689eb08479fb798725a7a0c2e9d4c72a0d
parentddf5219e77dd82b760bdb2338badb207794355cf (diff)
cleanup CssStyleSheet a bit
-rw-r--r--src/css.cc37
-rw-r--r--src/css.hh8
2 files changed, 12 insertions, 33 deletions
diff --git a/src/css.cc b/src/css.cc
index 588d996d..976f7244 100644
--- a/src/css.cc
+++ b/src/css.cc
@@ -362,23 +362,6 @@ void CssStyleSheet::RuleList::insert (CssRule *rule) {
*getRef (i) = rule;
}
-CssStyleSheet::CssStyleSheet () {
- for (int i = 0; i < ntags; i++)
- elementTable[i] = new RuleList ();
-
- idTable = new RuleMap ();
- classTable = new RuleMap ();
- anyTable = new RuleList ();
-}
-
-CssStyleSheet::~CssStyleSheet () {
- for (int i = 0; i < ntags; i++)
- delete elementTable[i];
- delete idTable;
- delete classTable;
- delete anyTable;
-}
-
/**
* \brief Insert a rule into CssStyleSheet.
*
@@ -392,26 +375,26 @@ void CssStyleSheet::addRule (CssRule *rule) {
if (top->getId ()) {
string = new lout::object::ConstString (top->getId ());
- ruleList = idTable->get (string);
+ ruleList = idTable.get (string);
if (ruleList == NULL) {
ruleList = new RuleList ();
- idTable->put (string, ruleList);
+ idTable.put (string, ruleList);
} else {
delete string;
}
} else if (top->getClass () && top->getClass ()->size () > 0) {
string = new lout::object::ConstString (top->getClass ()->get (0));
- ruleList = classTable->get (string);
+ ruleList = classTable.get (string);
if (ruleList == NULL) {
ruleList = new RuleList;
- classTable->put (string, ruleList);
+ classTable.put (string, ruleList);
} else {
delete string;
}
} else if (top->getElement () >= 0 && top->getElement () < ntags) {
- ruleList = elementTable[top->getElement ()];
+ ruleList = &elementTable[top->getElement ()];
} else if (top->getElement () == CssSimpleSelector::ELEMENT_ANY) {
- ruleList = anyTable;
+ ruleList = &anyTable;
}
if (ruleList) {
@@ -437,7 +420,7 @@ void CssStyleSheet::apply (CssPropertyList *props,
if (node->id) {
lout::object::ConstString idString (node->id);
- ruleList[numLists] = idTable->get (&idString);
+ ruleList[numLists] = idTable.get (&idString);
if (ruleList[numLists])
numLists++;
}
@@ -451,17 +434,17 @@ void CssStyleSheet::apply (CssPropertyList *props,
lout::object::ConstString classString (node->klass->get (i));
- ruleList[numLists] = classTable->get (&classString);
+ ruleList[numLists] = classTable.get (&classString);
if (ruleList[numLists])
numLists++;
}
}
- ruleList[numLists] = elementTable[node->element];
+ ruleList[numLists] = &elementTable[node->element];
if (ruleList[numLists])
numLists++;
- ruleList[numLists] = anyTable;
+ ruleList[numLists] = &anyTable;
if (ruleList[numLists])
numLists++;
diff --git a/src/css.hh b/src/css.hh
index 94a57cf0..394f7add 100644
--- a/src/css.hh
+++ b/src/css.hh
@@ -439,15 +439,11 @@ class CssStyleSheet {
};
static const int ntags = 90; // \todo replace 90
- RuleList *elementTable[ntags];
- RuleMap *idTable;
- RuleMap *classTable;
- RuleList *anyTable;
+ RuleList elementTable[ntags], anyTable;
+ RuleMap idTable, classTable;
public:
- CssStyleSheet();
- ~CssStyleSheet();
void addRule (CssRule *rule);
void apply (CssPropertyList *props,
Doctree *docTree, const DoctreeNode *node);