当前位置: 首页>>代码示例>>C++>>正文


C++ NodeImpl::attach方法代码示例

本文整理汇总了C++中NodeImpl::attach方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeImpl::attach方法的具体用法?C++ NodeImpl::attach怎么用?C++ NodeImpl::attach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NodeImpl的用法示例。


在下文中一共展示了NodeImpl::attach方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: attach

void NodeBaseImpl::attach(KHTMLView *w)
{
    NodeImpl *child = _first;
    while(child != 0)
    {
	child->attach(w);
	child = child->nextSibling();
    }
    NodeWParentImpl::attach(w);
}
开发者ID:BackupTheBerlios,项目名称:nirvana-svn,代码行数:10,代码来源:dom_nodeimpl.cpp

示例2: enterText

bool XMLHandler::enterText()
{
    NodeImpl *newNode = m_doc->createTextNode("");
    if (m_currentNode->addChild(newNode)) {
	if (m_view)
	    newNode->attach(m_view);
	m_currentNode = newNode;
	return TRUE;
    }
    else {
	delete newNode;
	return FALSE;
    }
}
开发者ID:BackupTheBerlios,项目名称:nirvana-svn,代码行数:14,代码来源:xml_tokenizer.cpp

示例3: startCDATA

bool XMLHandler::startCDATA()
{
    if (m_currentNode->nodeType() == Node::TEXT_NODE)
	exitText();

    NodeImpl *newNode = m_doc->createCDATASection("");
    if (m_currentNode->addChild(newNode)) {
	if (m_view)
	    newNode->attach(m_view);
	m_currentNode = newNode;
	return TRUE;
    }
    else {
	delete newNode;
	return FALSE;
    }

}
开发者ID:BackupTheBerlios,项目名称:nirvana-svn,代码行数:18,代码来源:xml_tokenizer.cpp

示例4: startCDATA

bool XMLHandler::startCDATA()
{
    if(currentNode()->nodeType() == Node::TEXT_NODE)
        exitText();

    NodeImpl *newNode = m_doc->createCDATASection(new DOMStringImpl(""));
    if(currentNode()->addChild(newNode))
    {
        if(m_view && !newNode->attached() && !m_doc->hasPendingSheets())
            newNode->attach();
        pushNode(newNode);
        return true;
    }
    else
    {
        delete newNode;
        return false;
    }
}
开发者ID:,项目名称:,代码行数:19,代码来源:

示例5: checkReadOnly

NodeImpl *NodeBaseImpl::appendChild ( NodeImpl *newChild, int &exceptioncode )
{
//    kdDebug(6010) << "NodeBaseImpl::appendChild( " << newChild << " );" <<endl;
    checkReadOnly();
    if (!newChild || (newChild->nodeType() == Node::DOCUMENT_FRAGMENT_NODE && !newChild->firstChild())) {
	exceptioncode = DOMException::NOT_FOUND_ERR;
	return 0;
    }
    if( checkSameDocument(newChild, exceptioncode) )
	return 0;
    if( checkNoOwner(newChild, exceptioncode) )
	return 0;

    if(newChild->parentNode() == this)
	removeChild(newChild, exceptioncode);
    if ( exceptioncode )
	return 0;

    bool isFragment = newChild->nodeType() == Node::DOCUMENT_FRAGMENT_NODE;
    NodeImpl *nextChild;
    NodeImpl *child = isFragment ? newChild->firstChild() : newChild;

    while (child) {
	nextChild = isFragment ? child->nextSibling() : 0;

	if (checkNoOwner(child, exceptioncode) )
	    return 0;
	if(!childAllowed(child)) {
	    exceptioncode = DOMException::HIERARCHY_REQUEST_ERR;
	    return 0;
	}

	// if already in the tree, remove it first!
	NodeImpl *oldParent = child->parentNode();
	if(oldParent)
	    oldParent->removeChild( child, exceptioncode );
	if ( exceptioncode )
	    return 0;

	// lets append it
	child->setParent(this);

	if(_last)
	{
	    child->setPreviousSibling(_last);
	    _last->setNextSibling(child);
	    _last = child;
	}
	else
	{
	    _first = _last = child;
	}
	if (attached() && !child->attached())
	    child->attach(document ? document->view() : static_cast<DocumentImpl*>(this)->view());

	child = nextChild;
    }

    setChanged(true);
    // ### set style in case it's attached
    return newChild;
}
开发者ID:BackupTheBerlios,项目名称:nirvana-svn,代码行数:62,代码来源:dom_nodeimpl.cpp

示例6: while

NodeImpl *NodeBaseImpl::replaceChild ( NodeImpl *newChild, NodeImpl *oldChild, int &exceptioncode )
{
    exceptioncode = 0;
    if (checkReadOnly()) {
	exceptioncode = DOMException::NO_MODIFICATION_ALLOWED_ERR;
	return 0;
    }
    if (!newChild || (newChild->nodeType() == Node::DOCUMENT_FRAGMENT_NODE && !newChild->firstChild())) {
	exceptioncode = DOMException::NOT_FOUND_ERR;
	return 0;
    }
    if( checkSameDocument(newChild, exceptioncode) )
	return 0;
    if( checkIsChild(oldChild, exceptioncode) )
	return 0;
    if( checkNoOwner(newChild, exceptioncode) )
	return 0;

    bool isFragment = newChild->nodeType() == Node::DOCUMENT_FRAGMENT_NODE;
    NodeImpl *nextChild;
    NodeImpl *child = isFragment ? newChild->firstChild() : newChild;

    // make sure we will be able to insert the first node before we go removing the old one
    if( checkNoOwner(isFragment ? newChild->firstChild() : newChild, exceptioncode) )
	return 0;
    if(!childAllowed(isFragment ? newChild->firstChild() : newChild)) {
	exceptioncode = DOMException::HIERARCHY_REQUEST_ERR;
	return 0;
    }

    NodeImpl *prev = oldChild->previousSibling();
    NodeImpl *next = oldChild->nextSibling();
    oldChild->setPreviousSibling(0);
    oldChild->setNextSibling(0);
    oldChild->setParent(0);
    if (m_render && oldChild->renderer())
	m_render->removeChild(oldChild->renderer());

    while (child) {
	nextChild = isFragment ? child->nextSibling() : 0;

	if( checkNoOwner(child, exceptioncode ) )
	    return 0;
	if(!childAllowed(child)) {
	    exceptioncode = DOMException::HIERARCHY_REQUEST_ERR;
	    return 0;
	}

	// if already in the tree, remove it first!
	NodeImpl *newParent = child->parentNode();
	if(newParent)
	    newParent->removeChild( child, exceptioncode );
	if ( exceptioncode )
	    return 0;

	// seems ok, lets's insert it.
	if (prev) prev->setNextSibling(child);
	if (next) next->setPreviousSibling(child);
	if(!prev) _first = child;
	if(!next) _last = child;

	child->setParent(this);
	child->setPreviousSibling(prev);
	child->setNextSibling(next);
	if (attached() && !child->attached())
	    child->attach(document ? document->view() : static_cast<DocumentImpl*>(this)->view());
	prev = child;
	child = nextChild;
    }

    // ### set style in case it's attached
    setChanged(true);

    return oldChild;
}
开发者ID:BackupTheBerlios,项目名称:nirvana-svn,代码行数:75,代码来源:dom_nodeimpl.cpp

示例7: appendChild

NodeImpl *NodeBaseImpl::insertBefore ( NodeImpl *newChild, NodeImpl *refChild, int &exceptioncode )
{
    exceptioncode = 0;
    if (checkReadOnly()) {
	exceptioncode = DOMException::NO_MODIFICATION_ALLOWED_ERR;
	return 0;
    }
    if (!newChild || (newChild->nodeType() == Node::DOCUMENT_FRAGMENT_NODE && !newChild->firstChild())) {
	exceptioncode = DOMException::NOT_FOUND_ERR;
	return 0;
    }

    if(!refChild)
	return appendChild(newChild, exceptioncode);

    if( checkSameDocument(newChild, exceptioncode) )
	return 0;
    if( checkNoOwner(newChild, exceptioncode) )
	return 0;
    if( checkIsChild(refChild, exceptioncode) )
	return 0;

    if(newChild->parentNode() == this)
	removeChild(newChild, exceptioncode);
    if( exceptioncode )
	return 0;

    bool isFragment = newChild->nodeType() == Node::DOCUMENT_FRAGMENT_NODE;
    NodeImpl *nextChild;
    NodeImpl *child = isFragment ? newChild->firstChild() : newChild;

    NodeImpl *prev = refChild->previousSibling();
    while (child) {
	nextChild = isFragment ? child->nextSibling() : 0;

	if( checkNoOwner(child, exceptioncode) )
	    return 0;
	if(!childAllowed(child)) {
	    exceptioncode = DOMException::HIERARCHY_REQUEST_ERR;
	    return 0;
	}
	// if already in the tree, remove it first!
	NodeImpl *newParent = child->parentNode();
	if(newParent)
	    newParent->removeChild( child, exceptioncode );
	if ( exceptioncode )
	    return 0;

	// seems ok, lets's insert it.
	if (prev)
	    prev->setNextSibling(child);
	else
	    _first = child;
	refChild->setPreviousSibling(child);
	child->setParent(this);
	child->setPreviousSibling(prev);
	child->setNextSibling(refChild);
	if (attached() && !child->attached())
	    child->attach(document ? document->view() : static_cast<DocumentImpl*>(this)->view());

	prev = child;
	child = nextChild;
    }

    // ### set style in case it's attached
    setChanged(true);

    return newChild;
}
开发者ID:BackupTheBerlios,项目名称:nirvana-svn,代码行数:69,代码来源:dom_nodeimpl.cpp

示例8: insertNode

bool KHTMLParser::insertNode(NodeImpl *n, bool flat)
{
    int id = n->id();

    // let's be stupid and just try to insert it.
    // this should work if the document is wellformed
#ifdef PARSER_DEBUG
    NodeImpl *tmp = current;
#endif
    NodeImpl *newNode = current->addChild(n);
    if ( newNode ) {
#ifdef PARSER_DEBUG
        kdDebug( 6035 ) << "added " << n->nodeName().string() << " to " << tmp->nodeName().string() << ", new current=" << newNode->nodeName().string() << endl;
#endif

	// have to do this here (and not when creating the node, as we don't know before where we add the LI element to.
	if ( id == ID_LI && n->isElementNode() ) {
	    int cid = current->id();
	    if ( cid != ID_UL && cid != ID_OL )
	    static_cast<HTMLElementImpl*>(n)->addCSSProperty(CSS_PROP_LIST_STYLE_POSITION, CSS_VAL_INSIDE);
	}

	// don't push elements without end tag on the stack
        if(tagPriority[id] != 0 && !flat) {
#if SPEED_DEBUG < 2
            if(!n->attached() && HTMLWidget )
                n->attach();
#endif
	    if(n->isInline()) m_inline = true;
            pushBlock(id, tagPriority[id]);
            current = newNode;
        } else {
#if SPEED_DEBUG < 2
            if(!n->attached() && HTMLWidget)
                n->attach();
            if (n->maintainsState()) {
                document->document()->registerMaintainsState(n);
                QString state(document->document()->nextState());
                if (!state.isNull()) n->restoreState(state);
            }
            if(n->renderer())
                n->renderer()->close();
#endif
	    if(n->isInline()) m_inline = true;
        }

#if SPEED_DEBUG < 1
        if(tagPriority[id] == 0 && n->renderer())
            n->renderer()->calcMinMaxWidth();
#endif
        return true;
    } else {
#ifdef PARSER_DEBUG
        kdDebug( 6035 ) << "ADDING NODE FAILED!!!! current = " << current->nodeName().string() << ", new = " << n->nodeName().string() << endl;
#endif
        // error handling...
        HTMLElementImpl *e;
        bool handled = false;

	// never create anonymous objects just to hold a space.
	if ( id == ID_TEXT &&
	     static_cast<TextImpl *>(n)->string()->l == 1 &&
	     static_cast<TextImpl *>(n)->string()->s[0] == " " )
	    return false;

        // switch according to the element to insert
        switch(id)
        {
        case ID_COMMENT:
            break;
        case ID_HEAD:
            // ### alllow not having <HTML> in at all, as per HTML spec
            if (!current->isDocumentNode() && current->id() != ID_HTML )
                return false;
            break;
        case ID_META:
        case ID_LINK:
        case ID_ISINDEX:
        case ID_BASE:
            if( !head )
                createHead();
            if( head ) {
                if ( head->addChild(n) ) {
#if SPEED_DEBUG < 2
                    if(!n->attached() && HTMLWidget)
                        n->attach();
#endif
		}

                return true;
            }

            break;
        case ID_HTML:
            if (!current->isDocumentNode() ) {
		if ( doc()->firstChild()->id() == ID_HTML) {
		    // we have another <HTML> element.... apply attributes to existing one
		    // make sure we don't overwrite already existing attributes
		    NamedAttrMapImpl *map = static_cast<ElementImpl*>(n)->attributes(true);
		    NamedAttrMapImpl *bmap = static_cast<ElementImpl*>(doc()->firstChild())->attributes(false);
//.........这里部分代码省略.........
开发者ID:crutchwalkfactory,项目名称:motocakerteam,代码行数:101,代码来源:htmlparser.cpp


注:本文中的NodeImpl::attach方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。