void CSSStyleSheetImpl::deleteRule(unsigned long index, int &exceptioncode) { exceptioncode = 0; if (index + 1 > (unsigned) m_lstChildren->count()) { exceptioncode = DOMException::INDEX_SIZE_ERR; return; } StyleBaseImpl *b = m_lstChildren->takeAt(index); if (b->isRule() && static_cast<CSSRuleImpl *>(b)->type() == DOM::CSSRule::NAMESPACE_RULE) { dirtyNamespaceInfo(); if (static_cast<CSSNamespaceRuleImpl *>(b)->isDefault()) { recomputeNamespaceInfo(); // default may have changed } // ### too late for some rules? } // TreeShared requires delete not deref when removed from tree b->setParent(0); if (!b->refCount()) { delete b; } if (m_doc) { m_doc->updateStyleSelector(true /*shallow*/); } }
void CSSStyleSheetImpl::recomputeNamespaceInfo() { assert(!m_namespaces); m_namespaces = new QList<CSSNamespaceRuleImpl *>; m_defaultNamespace = NamespaceName::fromId(anyNamespace); // Compute list of all the @namespace nodes, as well as the default one. for (int i = 0; i < m_lstChildren->count(); ++i) { StyleBaseImpl *b = m_lstChildren->at(i); if (b->isRule() && static_cast<CSSRuleImpl *>(b)->type() == DOM::CSSRule::NAMESPACE_RULE) { CSSNamespaceRuleImpl *nr = static_cast<CSSNamespaceRuleImpl *>(b); DOM::DOMString prefix = nr->prefix(); DOM::DOMString uri = nr->namespaceURI(); if (uri.isNull()) { continue; } if (nr->isDefault()) { m_defaultNamespace = NamespaceName::fromString(uri); } m_namespaces->append(nr); } } }
CSSRuleList::CSSRuleList(StyleListImpl *lst) { impl = new CSSRuleListImpl; impl->ref(); if (lst) { for( unsigned long i = 0; i < lst->length() ; ++i ) { StyleBaseImpl* style = lst->item( i ); if ( style->isRule() ) impl->insertRule( static_cast<CSSRuleImpl *>(style), impl->length() ); } } }