本文整理汇总了C++中NodeImpl::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeImpl::addChild方法的具体用法?C++ NodeImpl::addChild怎么用?C++ NodeImpl::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeImpl
的用法示例。
在下文中一共展示了NodeImpl::addChild方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HTMLFormElementImpl
NodeImpl *KHTMLParser::handleIsindex( Token *t )
{
NodeImpl *n;
HTMLFormElementImpl *myform = form;
if ( !myform ) {
myform = new HTMLFormElementImpl(document, true);
n = myform;
} else
n = new HTMLDivElementImpl( document, ID_DIV );
NodeImpl *child = new HTMLHRElementImpl( document );
n->addChild( child );
AttributeImpl* a = t->attrs ? t->attrs->getAttributeItem(ATTR_PROMPT) : 0;
DOMString text = i18n("This is a searchable index. Enter search keywords: ");
if (a)
text = a->value();
child = new TextImpl(document, text.implementation());
n->addChild( child );
child = new HTMLIsIndexElementImpl(document, myform);
static_cast<ElementImpl *>(child)->setAttribute(ATTR_TYPE, "khtml_isindex");
n->addChild( child );
child = new HTMLHRElementImpl( document );
n->addChild( child );
return n;
}
示例2: HTMLFormElementImpl
NodeImpl *KHTMLParser::handleIsindex( Token *t )
{
NodeImpl *n;
HTMLFormElementImpl *myform = form;
if ( !myform ) {
myform = new HTMLFormElementImpl(document);
n = myform;
} else
n = new HTMLDivElementImpl( document );
NodeImpl *child = new HTMLHRElementImpl( document );
n->addChild( child );
AttributeImpl* a = t->attrs ? t->attrs->getAttributeItem(ATTR_PROMPT) : 0;
#if APPLE_CHANGES && !KWIQ
DOMString text = searchableIndexIntroduction();
#elif KWIQ // FIXME: KWIQ: Internationalization. Hardcoded string.
DOMString text = "This is a searchable index. Enter search keywords: ";
#else
DOMString text = i18n("This is a searchable index. Enter search keywords: ");
#endif
if (a)
text = DOMString(a->value()) + " ";
child = new TextImpl(document, text);
n->addChild( child );
child = new HTMLIsIndexElementImpl(document, myform);
static_cast<ElementImpl *>(child)->setAttribute(ATTR_TYPE, "khtml_isindex");
n->addChild( child );
child = new HTMLHRElementImpl( document );
n->addChild( child );
return n;
}
示例3: startElement
bool XMLHandler::startElement(const QString &namespaceURI, const QString & /*localName*/, const QString &qName, const QXmlAttributes &atts)
{
if(currentNode()->nodeType() == Node::TEXT_NODE)
exitText();
DOMString nsURI;
if(!namespaceURI.isNull())
nsURI = DOMString(namespaceURI);
else
// No namespace declared, default to the no namespace
nsURI = DOMString("");
ElementImpl *newElement = m_doc->createElementNS(nsURI, qName);
if(!newElement)
return false;
int i;
for(i = 0; i < atts.length(); i++)
{
int exceptioncode = 0;
QString uriString = atts.uri(i);
QString qnString = atts.qName(i);
fixUpNSURI(uriString, qnString);
DOMString uri(uriString);
DOMString qn(qnString);
DOMString val(atts.value(i));
newElement->setAttributeNS(uri, qn, val, exceptioncode);
if(exceptioncode) // exception setting attributes
return false;
}
if(newElement->id() == ID_SCRIPT || newElement->id() == makeId(xhtmlNamespace, ID_SCRIPT))
static_cast< HTMLScriptElementImpl * >(newElement)->setCreatedByParser(true);
// this is tricky. in general the node doesn't have to attach to the one it's in. as far
// as standards go this is wrong, but there's literally thousands of documents where
// we see <p><ul>...</ul></p>. the following code is there for those cases.
// when we can't attach to the currently holding us node we try to attach to its parent
bool attached = false;
for(NodeImpl *current = currentNode(); current; current = current->parent())
{
attached = current->addChild(newElement);
if(attached)
break;
}
if(attached)
{
if(m_view && !newElement->attached() && !m_doc->hasPendingSheets())
newElement->attach();
pushNode(newElement);
return true;
}
else
{
delete newElement;
return false;
}
// ### DOM spec states: "if there is no markup inside an element's content, the text is contained in a
// single object implementing the Text interface that is the only child of the element."... do we
// need to ensure that empty elements always have an empty text child?
}