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


C++ ContainerNode::removeChild方法代码示例

本文整理汇总了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();
}
开发者ID:13W,项目名称:phantomjs,代码行数:35,代码来源:Text.cpp

示例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);
}
开发者ID:1833183060,项目名称:wke,代码行数:20,代码来源:ReplaceNodeWithSpanCommand.cpp


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