本文整理汇总了C++中ContainerNode::removeChild方法的典型用法代码示例。如果您正苦于以下问题:C++ ContainerNode::removeChild方法的具体用法?C++ ContainerNode::removeChild怎么用?C++ ContainerNode::removeChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContainerNode
的用法示例。
在下文中一共展示了ContainerNode::removeChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: protectedThis
PassRefPtr<Text> Text::replaceWholeText(const String& newText, ExceptionCode&)
{
// Remove all adjacent text nodes, and replace the contents of this one.
// Protect startText and endText against mutation event handlers removing the last ref
RefPtr<Text> startText = const_cast<Text*>(earliestLogicallyAdjacentTextNode(this));
RefPtr<Text> endText = const_cast<Text*>(latestLogicallyAdjacentTextNode(this));
RefPtr<Text> protectedThis(this); // Mutation event handlers could cause our last ref to go away
ContainerNode* parent = parentNode(); // Protect against mutation handlers moving this node during traversal
ExceptionCode ignored = 0;
for (RefPtr<Node> n = startText; n && n != this && n->isTextNode() && n->parentNode() == parent;) {
RefPtr<Node> nodeToRemove(n.release());
n = nodeToRemove->nextSibling();
parent->removeChild(nodeToRemove.get(), ignored);
}
if (this != endText) {
Node* onePastEndText = endText->nextSibling();
for (RefPtr<Node> n = nextSibling(); n && n != onePastEndText && n->isTextNode() && n->parentNode() == parent;) {
RefPtr<Node> nodeToRemove(n.release());
n = nodeToRemove->nextSibling();
parent->removeChild(nodeToRemove.get(), ignored);
}
}
if (newText.isEmpty()) {
if (parent && parentNode() == parent)
parent->removeChild(this, ignored);
return 0;
}
setData(newText, ignored);
return protectedThis.release();
}
示例2: swapInNodePreservingAttributesAndChildren
static void swapInNodePreservingAttributesAndChildren(HTMLElement* newNode, HTMLElement* nodeToReplace)
{
ASSERT(nodeToReplace->inDocument());
ExceptionCode ec = 0;
ContainerNode* parentNode = nodeToReplace->parentNode();
parentNode->insertBefore(newNode, nodeToReplace, ec);
ASSERT(!ec);
RefPtr<Node> nextChild;
for (Node* child = nodeToReplace->firstChild(); child; child = nextChild.get()) {
nextChild = child->nextSibling();
newNode->appendChild(child, ec);
ASSERT(!ec);
}
newNode->attributes()->setAttributes(*nodeToReplace->attributes());
parentNode->removeChild(nodeToReplace, ec);
ASSERT(!ec);
}