本文整理汇总了C++中NodeImpl::attached方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeImpl::attached方法的具体用法?C++ NodeImpl::attached怎么用?C++ NodeImpl::attached使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeImpl
的用法示例。
在下文中一共展示了NodeImpl::attached方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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);
//.........这里部分代码省略.........