Exemplo n.º 1
0
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);
        }
    }
}
Exemplo n.º 2
0
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*/);
    }
}
Exemplo n.º 3
0
StyleSheetImpl* StyleBaseImpl::stylesheet()
{
    StyleBaseImpl* b = this;
    while(b && !b->isStyleSheet())
        b = b->m_parent;
    return static_cast<StyleSheetImpl *>(b);
}
void CSSStyleSheetImpl::setNonCSSHints()
{
    StyleBaseImpl *rule = m_lstChildren->first();
    while(rule) {
        if(rule->isStyleRule()) {
            static_cast<CSSStyleRuleImpl *>(rule)->setNonCSSHints();
        }
        rule = m_lstChildren->next();
    }
}
void CSSStyleSheetImpl::deleteRule( unsigned long index, int &exceptioncode )
{
    exceptioncode = 0;
    StyleBaseImpl *b = m_lstChildren->take(index);
    if(!b) {
        exceptioncode = DOMException::INDEX_SIZE_ERR;
        return;
    }
    b->deref();
}
Exemplo n.º 6
0
StyleListImpl::~StyleListImpl()
{
    StyleBaseImpl *n;

    if(!m_lstChildren) return;

    for( n = m_lstChildren->first(); n != 0; n = m_lstChildren->next() )
    {
        n->setParent(0);
        if( !n->refCount() ) delete n;
    }
    delete m_lstChildren;
}
CSSStyleSheetImpl::CSSStyleSheetImpl(CSSRuleImpl *ownerRule, CSSStyleSheetImpl *orig)
    : StyleSheetImpl(ownerRule, orig->m_strHref)
{
    m_lstChildren = new QPtrList<StyleBaseImpl>;
    StyleBaseImpl *rule;
    for ( rule = orig->m_lstChildren->first(); rule != 0; rule = orig->m_lstChildren->next() )
    {
        m_lstChildren->append(rule);
        rule->setParent(this);
    }
    m_doc  = 0;
    m_implicit = false;
}
CSSStyleSheetImpl::CSSStyleSheetImpl(DOM::NodeImpl *parentNode, CSSStyleSheetImpl *orig)
    : StyleSheetImpl(parentNode, orig->m_strHref)
{
    m_lstChildren = new QPtrList<StyleBaseImpl>;
    StyleBaseImpl *rule;
    for ( rule = orig->m_lstChildren->first(); rule != 0; rule = orig->m_lstChildren->next() )
    {
        m_lstChildren->append(rule);
        rule->setParent(this);
    }
    m_doc = parentNode->getDocument();
    m_implicit = false;
}
Exemplo n.º 9
0
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() );
        }
    }
}
Exemplo n.º 10
0
void CSSStyleSheetImpl::deleteRule( unsigned long index, int &exceptioncode )
{
    exceptioncode = 0;
    StyleBaseImpl *b = m_lstChildren->take(index);
    if(!b) {
        exceptioncode = DOMException::INDEX_SIZE_ERR;
        return;
    }
    // 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 CSSStyleDeclarationImpl::setChanged()
{
    if (m_node) {
        m_node->setChanged();
        return;
    }

    // ### quick&dirty hack for KDE 3.0... make this MUCH better! (Dirk)
    for (StyleBaseImpl* stylesheet = this; stylesheet; stylesheet = stylesheet->parent())
        if (stylesheet->isCSSStyleSheet()) {
            static_cast<CSSStyleSheetImpl*>(stylesheet)->doc()->updateStyleSelector();
            break;
        }
}
Exemplo n.º 12
0
StyleListImpl::~StyleListImpl()
{
    StyleBaseImpl *n;

    if(!m_lstChildren) return;

    QListIterator<StyleBaseImpl*> it( *m_lstChildren );
    while ( it.hasNext() )
    {
        n = it.next();
        n->setParent(0);
        if( !n->refCount() ) delete n;
    }
    delete m_lstChildren;
}
Exemplo n.º 13
0
CSSStyleSheetImpl::CSSStyleSheetImpl(CSSRuleImpl *ownerRule, CSSStyleSheetImpl *orig)
    : StyleSheetImpl(ownerRule, orig->m_strHref)
{
    // m_lstChildren is deleted in StyleListImpl
    m_lstChildren = new QPtrList<StyleBaseImpl>;
    StyleBaseImpl *rule;
    for ( rule = orig->m_lstChildren->first(); rule != 0; rule = orig->m_lstChildren->next() )
    {
        m_lstChildren->append(rule);
        rule->setParent(this);
    }
    m_doc = static_cast<CSSStyleSheetImpl*>(ownerRule->stylesheet())->doc();
    m_implicit = false;
    m_namespaces = 0;
    m_defaultNamespace = anyNamespace;
}
Exemplo n.º 14
0
CSSImageValueImpl::CSSImageValueImpl(const DOMString &url, const DOMString &baseurl, StyleBaseImpl *style)
    : CSSPrimitiveValueImpl(url, CSSPrimitiveValue::CSS_URI)
{
    khtml::DocLoader *docLoader = 0;
    StyleBaseImpl *root = style;
    while (root->parent())
	root = root->parent();
    if (root->isCSSStyleSheet())
	docLoader = static_cast<CSSStyleSheetImpl*>(root)->docLoader();

    if (docLoader)
	m_image = docLoader->requestImage(url, baseurl);
    else
	m_image = khtml::Cache::requestImage(url, baseurl);

    if(m_image) m_image->ref(this);
}
Exemplo n.º 15
0
CSSStyleSheetImpl::CSSStyleSheetImpl(DOM::NodeImpl *parentNode, CSSStyleSheetImpl *orig)
    : StyleSheetImpl(parentNode, orig->m_strHref)
{
    m_lstChildren = new QList<StyleBaseImpl *>;
    StyleBaseImpl *rule;
    QListIterator<StyleBaseImpl *> it(*orig->m_lstChildren);
    while (it.hasNext()) {
        rule = it.next();
        m_lstChildren->append(rule);
        rule->setParent(this);
    }
    m_doc = parentNode->document();
    m_implicit = false;
    m_namespaces = 0;
    m_defaultNamespace = NamespaceName::fromId(anyNamespace);
    m_loadedHint = false;

    recomputeNamespaceInfo(); // as we cloned kids
}
Exemplo n.º 16
0
CSSStyleSheetImpl::CSSStyleSheetImpl(CSSRuleImpl *ownerRule, CSSStyleSheetImpl *orig)
    : StyleSheetImpl(ownerRule, orig->m_strHref)
{
    // m_lstChildren is deleted in StyleListImpl
    m_lstChildren = new QList<StyleBaseImpl *>;
    StyleBaseImpl *rule;
    QListIterator<StyleBaseImpl *> it(*orig->m_lstChildren);
    while (it.hasNext()) {
        rule = it.next();
        m_lstChildren->append(rule);
        rule->setParent(this);
    }
    m_doc = static_cast<CSSStyleSheetImpl *>(ownerRule->stylesheet())->doc();
    m_implicit = false;
    m_namespaces = 0;
    m_defaultNamespace = NamespaceName::fromId(anyNamespace);
    m_loadedHint = false;

    recomputeNamespaceInfo(); // as we cloned kids
}
bool CSSStyleSheetImpl::isLoading()
{
    StyleBaseImpl *rule;
    for ( rule = m_lstChildren->first(); rule != 0; rule = m_lstChildren->next() )
    {
        if(rule->isImportRule())
        {
            CSSImportRuleImpl *import = static_cast<CSSImportRuleImpl *>(rule);
#ifdef CSS_STYLESHEET_DEBUG
            kdDebug( 6080 ) << "found import" << endl;
#endif
            if(import->isLoading())
            {
#ifdef CSS_STYLESHEET_DEBUG
                kdDebug( 6080 ) << "--> not loaded" << endl;
#endif
                return true;
            }
        }
    }
    return false;
}
Exemplo n.º 18
0
bool CSSStyleSheetImpl::isLoading() const
{
    StyleBaseImpl *rule;
    QListIterator<StyleBaseImpl *> it(*m_lstChildren);
    while (it.hasNext()) {
        rule = it.next();
        if (rule->isImportRule()) {
            CSSImportRuleImpl *import = static_cast<CSSImportRuleImpl *>(rule);
#ifdef CSS_STYLESHEET_DEBUG
            qDebug() << "found import";
#endif
            if (import->isLoading()) {
#ifdef CSS_STYLESHEET_DEBUG
                qDebug() << "--> not loaded";
#endif
                m_loadedHint = false;
                return true;
            }
        }
    }
    m_loadedHint = true;
    return false;
}