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


C++ WillBeHeapVector::first方法代码示例

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


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

示例1: getNamedElements

void HTMLFormElement::getNamedElements(const AtomicString& name, WillBeHeapVector<RefPtrWillBeMember<Element>>& namedItems)
{
    // http://www.whatwg.org/specs/web-apps/current-work/multipage/forms.html#dom-form-nameditem
    elements()->namedItems(name, namedItems);

    Element* elementFromPast = elementFromPastNamesMap(name);
    if (namedItems.size() && namedItems.first() != elementFromPast) {
        addToPastNamesMap(namedItems.first().get(), name);
    } else if (elementFromPast && namedItems.isEmpty()) {
        namedItems.append(elementFromPast);
        UseCounter::count(document(), UseCounter::FormNameAccessForPastNamesMap);
    }
}
开发者ID:shaoboyan,项目名称:chromium-crosswalk,代码行数:13,代码来源:HTMLFormElement.cpp

示例2: namedItem

Element* HTMLCollection::namedItem(const AtomicString& name) const
{
    // http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/nameditem.asp
    // This method first searches for an object with a matching id
    // attribute. If a match is not found, the method then searches for an
    // object with a matching name attribute, but only on those elements
    // that are allowed a name attribute.
    updateIdNameCache();

    const NamedItemCache& cache = namedItemCache();
    WillBeHeapVector<RawPtrWillBeMember<Element>>* idResults = cache.getElementsById(name);
    if (idResults && !idResults->isEmpty())
        return idResults->first();

    WillBeHeapVector<RawPtrWillBeMember<Element>>* nameResults = cache.getElementsByName(name);
    if (nameResults && !nameResults->isEmpty())
        return nameResults->first();

    return nullptr;
}
开发者ID:OctiumBrowser,项目名称:octium-main,代码行数:20,代码来源:HTMLCollection.cpp

示例3: anonymousNamedGetter

void HTMLFormElement::anonymousNamedGetter(const AtomicString& name, RadioNodeListOrElement& returnValue)
{
    // Call getNamedElements twice, first time check if it has a value
    // and let HTMLFormElement update its cache.
    // See issue: 867404
    {
        WillBeHeapVector<RefPtrWillBeMember<Element>> elements;
        getNamedElements(name, elements);
        if (elements.isEmpty())
            return;
    }

    // Second call may return different results from the first call,
    // but if the first the size cannot be zero.
    WillBeHeapVector<RefPtrWillBeMember<Element>> elements;
    getNamedElements(name, elements);
    ASSERT(!elements.isEmpty());

    bool onlyMatchImg = !elements.isEmpty() && isHTMLImageElement(*elements.first());
    if (onlyMatchImg) {
        UseCounter::count(document(), UseCounter::FormNameAccessForImageElement);
        // The following code has performance impact, but it should be small
        // because <img> access via <form> name getter is rarely used.
        for (auto& element : elements) {
            if (isHTMLImageElement(*element) && !element->isDescendantOf(this)) {
                UseCounter::count(document(), UseCounter::FormNameAccessForNonDescendantImageElement);
                break;
            }
        }
    }
    if (elements.size() == 1) {
        returnValue.setElement(elements.at(0));
        return;
    }

    returnValue.setRadioNodeList(radioNodeList(name, onlyMatchImg));
}
开发者ID:shaoboyan,项目名称:chromium-crosswalk,代码行数:37,代码来源:HTMLFormElement.cpp

示例4: doApply

void BreakBlockquoteCommand::doApply()
{
    if (endingSelection().isNone())
        return;

    // Delete the current selection.
    if (endingSelection().isRange())
        deleteSelection(false, false);

    // This is a scenario that should never happen, but we want to
    // make sure we don't dereference a null pointer below.

    ASSERT(!endingSelection().isNone());

    if (endingSelection().isNone())
        return;

    VisiblePosition visiblePos = endingSelection().visibleStart();

    // pos is a position equivalent to the caret.  We use downstream() so that pos will
    // be in the first node that we need to move (there are a few exceptions to this, see below).
    Position pos = mostForwardCaretPosition(endingSelection().start());

    // Find the top-most blockquote from the start.
    HTMLQuoteElement* topBlockquote = toHTMLQuoteElement(highestEnclosingNodeOfType(pos, isMailHTMLBlockquoteElement));
    if (!topBlockquote || !topBlockquote->parentNode())
        return;

    RefPtrWillBeRawPtr<HTMLBRElement> breakElement = createBreakElement(document());

    bool isLastVisPosInNode = isLastVisiblePositionInNode(visiblePos, topBlockquote);

    // If the position is at the beginning of the top quoted content, we don't need to break the quote.
    // Instead, insert the break before the blockquote, unless the position is as the end of the the quoted content.
    if (isFirstVisiblePositionInNode(visiblePos, topBlockquote) && !isLastVisPosInNode) {
        insertNodeBefore(breakElement.get(), topBlockquote);
        setEndingSelection(VisibleSelection(positionBeforeNode(breakElement.get()), TextAffinity::Downstream, endingSelection().isDirectional()));
        rebalanceWhitespace();
        return;
    }

    // Insert a break after the top blockquote.
    insertNodeAfter(breakElement.get(), topBlockquote);

    // If we're inserting the break at the end of the quoted content, we don't need to break the quote.
    if (isLastVisPosInNode) {
        setEndingSelection(VisibleSelection(positionBeforeNode(breakElement.get()), TextAffinity::Downstream, endingSelection().isDirectional()));
        rebalanceWhitespace();
        return;
    }

    // Don't move a line break just after the caret.  Doing so would create an extra, empty paragraph
    // in the new blockquote.
    if (lineBreakExistsAtVisiblePosition(visiblePos)) {
        // TODO(yosin) We should use |PositionMoveType::Character| for
        // |nextPositionOf()| to avoid editing middle of character.
        pos = nextPositionOf(pos, PositionMoveType::CodePoint);
    }

    // Adjust the position so we don't split at the beginning of a quote.
    while (isFirstVisiblePositionInNode(createVisiblePosition(pos), toHTMLQuoteElement(enclosingNodeOfType(pos, isMailHTMLBlockquoteElement)))) {
        // TODO(yosin) We should use |PositionMoveType::Character| for
        // |previousPositionOf()| to avoid editing middle character.
        pos = previousPositionOf(pos, PositionMoveType::CodePoint);
    }

    // startNode is the first node that we need to move to the new blockquote.
    Node* startNode = pos.anchorNode();
    ASSERT(startNode);

    // Split at pos if in the middle of a text node.
    if (startNode->isTextNode()) {
        Text* textNode = toText(startNode);
        int textOffset = pos.computeOffsetInContainerNode();
        if ((unsigned)textOffset >= textNode->length()) {
            startNode = NodeTraversal::next(*startNode);
            ASSERT(startNode);
        } else if (textOffset > 0) {
            splitTextNode(textNode, textOffset);
        }
    } else if (pos.computeEditingOffset() > 0) {
        Node* childAtOffset = NodeTraversal::childAt(*startNode, pos.computeEditingOffset());
        startNode = childAtOffset ? childAtOffset : NodeTraversal::next(*startNode);
        ASSERT(startNode);
    }

    // If there's nothing inside topBlockquote to move, we're finished.
    if (!startNode->isDescendantOf(topBlockquote)) {
        setEndingSelection(VisibleSelection(createVisiblePosition(firstPositionInOrBeforeNode(startNode)), endingSelection().isDirectional()));
        return;
    }

    // Build up list of ancestors in between the start node and the top blockquote.
    WillBeHeapVector<RefPtrWillBeMember<Element>> ancestors;
    for (Element* node = startNode->parentElement(); node && node != topBlockquote; node = node->parentElement())
        ancestors.append(node);

    // Insert a clone of the top blockquote after the break.
    RefPtrWillBeRawPtr<Element> clonedBlockquote = topBlockquote->cloneElementWithoutChildren();
    insertNodeAfter(clonedBlockquote.get(), breakElement.get());
//.........这里部分代码省略.........
开发者ID:howardroark2018,项目名称:chromium,代码行数:101,代码来源:BreakBlockquoteCommand.cpp


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