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


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

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


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

示例1: insertAdjacent

Node* HTMLElement::insertAdjacent(const String& where, Node* newChild, ExceptionCode& ec)
{
    // In Internet Explorer if the element has no parent and where is "beforeBegin" or "afterEnd",
    // a document fragment is created and the elements appended in the correct order. This document
    // fragment isn't returned anywhere.
    //
    // This is impossible for us to implement as the DOM tree does not allow for such structures,
    // Opera also appears to disallow such usage.

    if (equalIgnoringCase(where, "beforeBegin")) {
        ContainerNode* parent = this->parentNode();
        return (parent && parent->insertBefore(newChild, this, ec)) ? newChild : 0;
    }

    if (equalIgnoringCase(where, "afterBegin"))
        return insertBefore(newChild, firstChild(), ec) ? newChild : 0;

    if (equalIgnoringCase(where, "beforeEnd"))
        return appendChild(newChild, ec) ? newChild : 0;

    if (equalIgnoringCase(where, "afterEnd")) {
        ContainerNode* parent = this->parentNode();
        return (parent && parent->insertBefore(newChild, nextSibling(), ec)) ? newChild : 0;
    }
    
    // IE throws COM Exception E_INVALIDARG; this is the best DOM exception alternative.
    ec = NOT_SUPPORTED_ERR;
    return 0;
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例2: executeApply

void SplitElementCommand::executeApply() {
  if (m_atChild->parentNode() != m_element2)
    return;

  HeapVector<Member<Node>> children;
  for (Node* node = m_element2->firstChild(); node != m_atChild;
       node = node->nextSibling())
    children.append(node);

  DummyExceptionStateForTesting exceptionState;

  ContainerNode* parent = m_element2->parentNode();
  if (!parent || !hasEditableStyle(*parent))
    return;
  parent->insertBefore(m_element1.get(), m_element2.get(), exceptionState);
  if (exceptionState.hadException())
    return;

  // Delete id attribute from the second element because the same id cannot be
  // used for more than one element
  m_element2->removeAttribute(HTMLNames::idAttr);

  for (const auto& child : children)
    m_element1->appendChild(child, exceptionState);
}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例3: doUnapply

void MergeIdenticalElementsCommand::doUnapply()
{
    ASSERT(m_element1);
    ASSERT(m_element2);

    RefPtr<Node> atChild = m_atChild.release();

    ContainerNode* parent = m_element2->parentNode();
    if (!parent || !parent->rendererIsEditable())
        return;

    TrackExceptionState es;

    parent->insertBefore(m_element1.get(), m_element2.get(), es);
    if (es.hadException())
        return;

    Vector<RefPtr<Node> > children;
    for (Node* child = m_element2->firstChild(); child && child != atChild; child = child->nextSibling())
        children.append(child);

    size_t size = children.size();
    for (size_t i = 0; i < size; ++i)
        m_element1->appendChild(children[i].release(), es);
}
开发者ID:chunywang,项目名称:blink-crosswalk,代码行数:25,代码来源:MergeIdenticalElementsCommand.cpp

示例4: executeApply

void SplitElementCommand::executeApply()
{
    if (m_atChild->parentNode() != m_element2)
        return;
    
    Vector<RefPtr<Node>> children;
    for (Node* node = m_element2->firstChild(); node != m_atChild; node = node->nextSibling())
        children.append(node);
    
    ExceptionCode ec = 0;
    
    ContainerNode* parent = m_element2->parentNode();
    if (!parent || !parent->hasEditableStyle())
        return;
    parent->insertBefore(m_element1.get(), m_element2.get(), ec);
    if (ec)
        return;

    // Delete id attribute from the second element because the same id cannot be used for more than one element
    m_element2->removeAttribute(HTMLNames::idAttr);

    size_t size = children.size();
    for (size_t i = 0; i < size; ++i)
        m_element1->appendChild(children[i], ec);
}
开发者ID:AndriyKalashnykov,项目名称:webkit,代码行数:25,代码来源:SplitElementCommand.cpp

示例5: doApply

void InsertNodeBeforeCommand::doApply()
{
    ContainerNode* parent = m_refChild->parentNode();
    if (!parent || (m_shouldAssumeContentIsAlwaysEditable == DoNotAssumeContentIsAlwaysEditable && !parent->isContentEditable(Node::UserSelectAllIsAlwaysNonEditable)))
        return;
    ASSERT(parent->isContentEditable(Node::UserSelectAllIsAlwaysNonEditable));

    parent->insertBefore(m_insertChild.get(), m_refChild.get(), IGNORE_EXCEPTION);
}
开发者ID:smil-in-javascript,项目名称:blink,代码行数:9,代码来源:InsertNodeBeforeCommand.cpp

示例6: doApply

void InsertNodeBeforeCommand::doApply()
{
    ContainerNode* parent = m_refChild->parentNode();
    if (!parent || (m_shouldAssumeContentIsAlwaysEditable == DoNotAssumeContentIsAlwaysEditable && !isEditableNode(*parent)))
        return;
    ASSERT(isEditableNode(*parent));

    parent->insertBefore(*m_insertChild, m_refChild.get(), IGNORE_EXCEPTION);
}
开发者ID:Comcast,项目名称:WebKitForWayland,代码行数:9,代码来源:InsertNodeBeforeCommand.cpp

示例7: doApply

void InsertNodeBeforeCommand::doApply(EditingState*) {
  ContainerNode* parent = m_refChild->parentNode();
  document().updateStyleAndLayoutTree();
  if (!parent || (m_shouldAssumeContentIsAlwaysEditable ==
                      DoNotAssumeContentIsAlwaysEditable &&
                  !hasEditableStyle(*parent)))
    return;
  DCHECK(hasEditableStyle(*parent)) << parent;

  parent->insertBefore(m_insertChild.get(), m_refChild.get(), IGNORE_EXCEPTION);
}
开发者ID:mirror,项目名称:chromium,代码行数:11,代码来源:InsertNodeBeforeCommand.cpp

示例8: doApply

void InsertNodeBeforeCommand::doApply()
{
    ContainerNode* parent = m_refChild->parentNode();
    if (!parent || (m_shouldAssumeContentIsAlwaysEditable == DoNotAssumeContentIsAlwaysEditable && !parent->isContentEditable(Node::UserSelectAllIsAlwaysNonEditable)))
        return;
    ASSERT(parent->isContentEditable(Node::UserSelectAllIsAlwaysNonEditable));

    parent->insertBefore(m_insertChild.get(), m_refChild.get(), IGNORE_EXCEPTION);

    if (AXObjectCache* cache = document().existingAXObjectCache())
        cache->nodeTextChangeNotification(m_insertChild.get(), AXObjectCache::AXTextInserted, 0, m_insertChild->nodeValue());
}
开发者ID:EliBing,项目名称:webkit,代码行数:12,代码来源:InsertNodeBeforeCommand.cpp

示例9: insertRow

HTMLTableRowElement* HTMLTableElement::insertRow(
    int index,
    ExceptionState& exceptionState) {
  if (index < -1) {
    exceptionState.throwDOMException(
        IndexSizeError,
        "The index provided (" + String::number(index) + ") is less than -1.");
    return nullptr;
  }

  HTMLTableRowElement* lastRow = nullptr;
  HTMLTableRowElement* row = nullptr;
  if (index == -1) {
    lastRow = HTMLTableRowsCollection::lastRow(*this);
  } else {
    for (int i = 0; i <= index; ++i) {
      row = HTMLTableRowsCollection::rowAfter(*this, lastRow);
      if (!row) {
        if (i != index) {
          exceptionState.throwDOMException(
              IndexSizeError,
              "The index provided (" + String::number(index) +
                  ") is greater than the number of rows in the table (" +
                  String::number(i) + ").");
          return nullptr;
        }
        break;
      }
      lastRow = row;
    }
  }

  ContainerNode* parent;
  if (lastRow) {
    parent = row ? row->parentNode() : lastRow->parentNode();
  } else {
    parent = lastBody();
    if (!parent) {
      HTMLTableSectionElement* newBody =
          HTMLTableSectionElement::create(tbodyTag, document());
      HTMLTableRowElement* newRow = HTMLTableRowElement::create(document());
      newBody->appendChild(newRow, exceptionState);
      appendChild(newBody, exceptionState);
      return newRow;
    }
  }

  HTMLTableRowElement* newRow = HTMLTableRowElement::create(document());
  parent->insertBefore(newRow, row, exceptionState);
  return newRow;
}
开发者ID:ollie314,项目名称:chromium,代码行数:51,代码来源:HTMLTableElement.cpp

示例10: doApply

void InsertNodeBeforeCommand::doApply()
{
    ContainerNode* parent = m_refChild->parentNode();
    if (!parent || (m_shouldAssumeContentIsAlwaysEditable == DoNotAssumeContentIsAlwaysEditable && !isEditableNode(*parent)))
        return;
    ASSERT(isEditableNode(*parent));

    parent->insertBefore(*m_insertChild, m_refChild.get(), IGNORE_EXCEPTION);

    if (shouldPostAccessibilityNotification()) {
        Position position = is<Text>(m_insertChild.get()) ? Position(downcast<Text>(m_insertChild.get()), 0) : createLegacyEditingPosition(m_insertChild.get(), 0);
        notifyAccessibilityForTextChange(m_insertChild.get(), applyEditType(), m_insertChild->nodeValue(), VisiblePosition(position));
    }
}
开发者ID:biddyweb,项目名称:switch-oss,代码行数:14,代码来源:InsertNodeBeforeCommand.cpp

示例11: doUnapply

void JoinTextNodesCommand::doUnapply()
{
    if (m_text1->parentNode())
        return;

    ContainerNode* parent = m_text2->parentNode();
    if (!parent || !parent->rendererIsEditable())
        return;

    ExceptionCode ec = 0;

    parent->insertBefore(m_text1.get(), m_text2.get(), ec);
    if (ec)
        return;

    m_text2->deleteData(0, m_text1->length(), ec);
}
开发者ID:0omega,项目名称:platform_external_webkit,代码行数:17,代码来源:JoinTextNodesCommand.cpp

示例12: 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

示例13: doUnapply

void MergeIdenticalElementsCommand::doUnapply()
{
    ASSERT(m_element1);
    ASSERT(m_element2);

    RefPtrWillBeRawPtr<Node> atChild = m_atChild.release();

    ContainerNode* parent = m_element2->parentNode();
    if (!parent || !parent->hasEditableStyle())
        return;

    TrackExceptionState exceptionState;

    parent->insertBefore(m_element1.get(), m_element2.get(), exceptionState);
    if (exceptionState.hadException())
        return;

    WillBeHeapVector<RefPtrWillBeMember<Node>> children;
    for (Node* child = m_element2->firstChild(); child && child != atChild; child = child->nextSibling())
        children.append(child);

    for (auto& child : children)
        m_element1->appendChild(child.release(), exceptionState);
}
开发者ID:dstockwell,项目名称:blink,代码行数:24,代码来源:MergeIdenticalElementsCommand.cpp

示例14: doUnapply

void MergeIdenticalElementsCommand::doUnapply()
{
    ASSERT(m_element1);
    ASSERT(m_element2);

    RefPtr<Node> atChild = m_atChild.release();

    ContainerNode* parent = m_element2->parentNode();
    if (!parent || !parent->hasEditableStyle())
        return;

    ExceptionCode ec = 0;

    parent->insertBefore(*m_element1, m_element2.get(), ec);
    if (ec)
        return;

    Vector<Ref<Node>> children;
    for (Node* child = m_element2->firstChild(); child && child != atChild; child = child->nextSibling())
        children.append(*child);

    for (auto& child : children)
        m_element1->appendChild(WTF::move(child), ec);
}
开发者ID:robvogelaar,项目名称:WebKitForWayland,代码行数:24,代码来源:MergeIdenticalElementsCommand.cpp


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