本文整理汇总了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);
}
}
示例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;
}
示例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));
}
示例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());
//.........这里部分代码省略.........