diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-12-16 21:48:25 +0100 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-12-16 21:48:25 +0100 |
commit | f44234155a8f974fb00523ed62e9d16cfc72a2c6 (patch) | |
tree | c03c85ab0edaf1ad4cadcbd2561bd28f04fbb890 /src/css.hh | |
parent | 827a18d5e381c594871eb44468e7ca8976a446c4 (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.hh | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -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); |