diff options
author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-11-13 21:06:26 +0100 |
---|---|---|
committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2008-11-13 21:06:26 +0100 |
commit | b45b1791eee02392840984d6836368c004fbfb5a (patch) | |
tree | c9dab6fd9507d1ac398ea33170a7e563969fcf4c /src/css.cc | |
parent | 4661f54cf597fa8edb724ee5bf82fbb350975719 (diff) |
add reference counting for CssPropertyList and CssSelector
Diffstat (limited to 'src/css.cc')
-rw-r--r-- | src/css.cc | 30 |
1 files changed, 28 insertions, 2 deletions
@@ -44,6 +44,15 @@ void CssPropertyList::print () { getRef (i)->print (); } +CssSelector::CssSelector (int element, const char *klass, + const char *pseudo, const char *id) { + refCount = 0; + this->element = element; + this->klass = klass; + this->pseudo = pseudo; + this->id = id; +}; + /** \todo implement all selection option CSS offers */ bool CssSelector::match (Doctree *docTree) { const DoctreeNode *n = docTree-> top (); @@ -67,6 +76,18 @@ void CssSelector::print () { element, klass, pseudo, id); } +CssRule::CssRule (CssSelector *selector, CssPropertyList *props) { + this->selector = selector; + this->selector->ref (); + this->props = props; + this->props->ref (); +}; + +CssRule::~CssRule () { + this->selector->unref (); + this->props->unref (); +}; + void CssRule::apply (CssPropertyList *props, Doctree *docTree) { if (selector->match (docTree)) this->props->apply (props); @@ -92,6 +113,11 @@ void CssStyleSheet::apply (CssPropertyList *props, Doctree *docTree) { get (i)->apply (props, docTree); } +CssStyleSheet::~CssStyleSheet () { + for (int i = 0; i < size (); i++) + delete get (i); +} + CssStyleSheet *CssContext::userAgentStyle; CssStyleSheet *CssContext::userStyle; CssStyleSheet *CssContext::userImportantStyle; @@ -142,8 +168,8 @@ void CssContext::addRule (CssRule *rule, CssPrimaryOrder order) { sheet[order]->addRule (rule); - fprintf(stderr, "Adding Rule (%d)\n", order); - rule->print (); +// fprintf(stderr, "Adding Rule (%d)\n", order); +// rule->print (); } void CssContext::buildUserAgentStyle () { |