aboutsummaryrefslogtreecommitdiff
path: root/src/css.hh
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2008-12-16 21:48:25 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2008-12-16 21:48:25 +0100
commitf44234155a8f974fb00523ed62e9d16cfc72a2c6 (patch)
treec03c85ab0edaf1ad4cadcbd2561bd28f04fbb890 /src/css.hh
parent827a18d5e381c594871eb44468e7ca8976a446c4 (diff)
speed up CSS selector matching
A CssStyleSheet is now an array of lists of CssRules. The array holds a list if those rules that might potentially match whith a given element on the top of docTree.
Diffstat (limited to 'src/css.hh')
-rw-r--r--src/css.hh13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/css.hh b/src/css.hh
index 6341f13b..e710633c 100644
--- a/src/css.hh
+++ b/src/css.hh
@@ -241,7 +241,7 @@ class CssSelector {
inline CssSimpleSelector *top () {
return &selectorList->getRef (selectorList->size () - 1)->selector;
};
-
+
bool match (Doctree *dt);
void print ();
inline void ref () { refCount++; }
@@ -255,10 +255,11 @@ class CssSelector {
class CssRule {
private:
int refCount;
- CssSelector *selector;
CssPropertyList *props;
public:
+ CssSelector *selector;
+
CssRule (CssSelector *selector, CssPropertyList *props);
~CssRule ();
@@ -272,9 +273,13 @@ class CssRule {
* \brief A list of CssRules.
* In apply () all matching rules are applied.
*/
-class CssStyleSheet : lout::misc::SimpleVector <CssRule*> {
+class CssStyleSheet {
+ private:
+ static const int ntags = 90; // \todo replace 90
+ lout::misc::SimpleVector <CssRule*> *ruleTable[ntags];
+
public:
- CssStyleSheet() : lout::misc::SimpleVector <CssRule*> (1) {};
+ CssStyleSheet();
~CssStyleSheet();
void addRule (CssRule *rule);
void addRule (CssSelector *selector, CssPropertyList *props);