本文整理汇总了C++中WillBeHeapVector类的典型用法代码示例。如果您正苦于以下问题:C++ WillBeHeapVector类的具体用法?C++ WillBeHeapVector怎么用?C++ WillBeHeapVector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WillBeHeapVector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ASSERT
void MutationObserver::deliver()
{
ASSERT(!shouldBeSuspended());
// Calling clearTransientRegistrations() can modify m_registrations, so it's necessary
// to make a copy of the transient registrations before operating on them.
WillBeHeapVector<RawPtrWillBeMember<MutationObserverRegistration>, 1> transientRegistrations;
for (auto& registration : m_registrations) {
if (registration->hasTransientRegistrations())
transientRegistrations.append(registration);
}
for (size_t i = 0; i < transientRegistrations.size(); ++i)
transientRegistrations[i]->clearTransientRegistrations();
if (m_records.isEmpty())
return;
MutationRecordVector records;
records.swap(m_records);
InspectorInstrumentation::willDeliverMutationRecords(m_callback->executionContext(), this);
m_callback->call(records, this);
InspectorInstrumentation::didDeliverMutationRecords(m_callback->executionContext());
}
示例2: getNamedItems
static v8::Handle<v8::Value> getNamedItems(HTMLAllCollection* collection, AtomicString name, const CallbackInfo& info)
{
WillBeHeapVector<RefPtrWillBeMember<Element> > namedItems;
collection->namedItems(name, namedItems);
if (!namedItems.size())
return v8Undefined();
if (namedItems.size() == 1)
return toV8(namedItems.at(0).release(), info.Holder(), info.GetIsolate());
// FIXME: HTML5 specification says this should be a HTMLCollection.
// http://www.whatwg.org/specs/web-apps/current-work/multipage/common-dom-interfaces.html#htmlallcollection
//
// FIXME: Oilpan: explicitly convert adopt()'s result so as to
// disambiguate the (implicit) conversion of its
// PassRefPtrWillBeRawPtr<StaticElementList> result -- the
// other toV8() overload that introduces the ambiguity is
// toV8(NodeList*, ...).
//
// When adopt() no longer uses transition types, the conversion
// can be removed.
return toV8(PassRefPtrWillBeRawPtr<NodeList>(StaticElementList::adopt(namedItems)), info.Holder(), info.GetIsolate());
}
示例3: interpolateLists
bool AnimatableRepeatable::interpolateLists(const WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> >& fromValues, const WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> >& toValues, double fraction, WillBeHeapVector<RefPtrWillBeMember<AnimatableValue> >& interpolatedValues)
{
// Interpolation behaviour spec: http://www.w3.org/TR/css3-transitions/#animtype-repeatable-list
ASSERT(interpolatedValues.isEmpty());
ASSERT(!fromValues.isEmpty() && !toValues.isEmpty());
size_t size = lowestCommonMultiple(fromValues.size(), toValues.size());
ASSERT(size > 0);
for (size_t i = 0; i < size; ++i) {
const AnimatableValue* from = fromValues[i % fromValues.size()].get();
const AnimatableValue* to = toValues[i % toValues.size()].get();
// Spec: If a pair of values cannot be interpolated, then the lists are not interpolable.
if (AnimatableValue::usesDefaultInterpolation(from, to))
return false;
interpolatedValues.append(interpolate(from, to, fraction));
}
return true;
}
示例4: activeLoadingStyleSheetLoaded
bool TreeScopeStyleSheetCollection::activeLoadingStyleSheetLoaded(const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>>& newStyleSheets)
{
// StyleSheets of <style> elements that @import stylesheets are active but loading. We need to trigger a full recalc when such loads are done.
bool hasActiveLoadingStylesheet = false;
unsigned newStylesheetCount = newStyleSheets.size();
for (unsigned i = 0; i < newStylesheetCount; ++i) {
if (newStyleSheets[i]->isLoading())
hasActiveLoadingStylesheet = true;
}
if (m_hadActiveLoadingStylesheet && !hasActiveLoadingStylesheet) {
m_hadActiveLoadingStylesheet = false;
return true;
}
m_hadActiveLoadingStylesheet = hasActiveLoadingStylesheet;
return false;
}
示例5: collectDestinationInsertionPoints
void collectDestinationInsertionPoints(const Node& node, WillBeHeapVector<RawPtrWillBeMember<InsertionPoint>, 8>& results)
{
const Node* current = &node;
ElementShadow* lastElementShadow = 0;
while (true) {
ElementShadow* shadow = shadowWhereNodeCanBeDistributed(*current);
if (!shadow || shadow == lastElementShadow)
return;
lastElementShadow = shadow;
const DestinationInsertionPoints* insertionPoints = shadow->destinationInsertionPointsFor(&node);
if (!insertionPoints)
return;
for (size_t i = 0; i < insertionPoints->size(); ++i)
results.append(insertionPoints->at(i).get());
ASSERT(current != insertionPoints->last().get());
current = insertionPoints->last().get();
}
}
示例6: adjustTouchList
void EventPath::adjustTouchList(const TouchList* touchList, WillBeHeapVector<RawPtrWillBeMember<TouchList>> adjustedTouchList, const WillBeHeapVector<RawPtrWillBeMember<TreeScope>>& treeScopes)
{
if (!touchList)
return;
for (size_t i = 0; i < touchList->length(); ++i) {
const Touch& touch = *touchList->item(i);
if (!touch.target())
continue;
Node* targetNode = touch.target()->toNode();
if (!targetNode)
continue;
RelatedTargetMap relatedNodeMap;
buildRelatedNodeMap(*targetNode, relatedNodeMap);
for (size_t j = 0; j < treeScopes.size(); ++j) {
adjustedTouchList[j]->append(touch.cloneWithNewTarget(findRelatedNode(*treeScopes[j], relatedNodeMap)));
}
}
}
示例7: ASSERT
void IdTargetObserverRegistry::notifyObserversInternal(const AtomicString& id)
{
ASSERT(!id.isEmpty());
ASSERT(!m_registry.isEmpty());
m_notifyingObserversInSet = m_registry.get(id.impl());
if (!m_notifyingObserversInSet)
return;
WillBeHeapVector<RawPtrWillBeMember<IdTargetObserver> > copy;
copyToVector(*m_notifyingObserversInSet, copy);
for (WillBeHeapVector<RawPtrWillBeMember<IdTargetObserver> >::const_iterator it = copy.begin(); it != copy.end(); ++it) {
if (m_notifyingObserversInSet->contains(*it))
(*it)->idTargetChanged();
}
if (m_notifyingObserversInSet->isEmpty())
m_registry.remove(id.impl());
m_notifyingObserversInSet = nullptr;
}
示例8: getNamedElements
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));
}
示例9: pruneSubsequentAncestorsToRemove
int SimplifyMarkupCommand::pruneSubsequentAncestorsToRemove(WillBeHeapVector<RefPtrWillBeMember<ContainerNode>>& nodesToRemove, size_t startNodeIndex)
{
size_t pastLastNodeToRemove = startNodeIndex + 1;
for (; pastLastNodeToRemove < nodesToRemove.size(); ++pastLastNodeToRemove) {
if (nodesToRemove[pastLastNodeToRemove - 1]->parentNode() != nodesToRemove[pastLastNodeToRemove])
break;
ASSERT(nodesToRemove[pastLastNodeToRemove]->firstChild() == nodesToRemove[pastLastNodeToRemove]->lastChild());
}
ContainerNode* highestAncestorToRemove = nodesToRemove[pastLastNodeToRemove - 1].get();
RefPtrWillBeRawPtr<ContainerNode> parent = highestAncestorToRemove->parentNode();
if (!parent) // Parent has already been removed.
return -1;
if (pastLastNodeToRemove == startNodeIndex + 1)
return 0;
removeNode(nodesToRemove[startNodeIndex], AssumeContentIsAlwaysEditable);
insertNodeBefore(nodesToRemove[startNodeIndex], highestAncestorToRemove, AssumeContentIsAlwaysEditable);
removeNode(highestAncestorToRemove, AssumeContentIsAlwaysEditable);
return pastLastNodeToRemove - startNodeIndex - 1;
}
示例10: updateIdNameCache
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;
}
示例11: protector
void PageAnimator::serviceScriptedAnimations(double monotonicAnimationStartTime)
{
RefPtrWillBeRawPtr<PageAnimator> protector(this);
m_animationFramePending = false;
TemporaryChange<bool> servicing(m_servicingAnimations, true);
WillBeHeapVector<RefPtrWillBeMember<Document>> documents;
for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
if (frame->isLocalFrame())
documents.append(toLocalFrame(frame)->document());
}
for (size_t i = 0; i < documents.size(); ++i) {
if (documents[i]->frame()) {
documents[i]->view()->serviceScrollAnimations(monotonicAnimationStartTime);
if (const FrameView::ScrollableAreaSet* animatingScrollableAreas = documents[i]->view()->animatingScrollableAreas()) {
// Iterate over a copy, since ScrollableAreas may deregister
// themselves during the iteration.
Vector<ScrollableArea*> animatingScrollableAreasCopy;
copyToVector(*animatingScrollableAreas, animatingScrollableAreasCopy);
for (ScrollableArea* scrollableArea : animatingScrollableAreasCopy)
scrollableArea->serviceScrollAnimations(monotonicAnimationStartTime);
}
}
}
for (size_t i = 0; i < documents.size(); ++i) {
DocumentAnimations::updateAnimationTimingForAnimationFrame(*documents[i], monotonicAnimationStartTime);
SVGDocumentExtensions::serviceOnAnimationFrame(*documents[i], monotonicAnimationStartTime);
}
for (size_t i = 0; i < documents.size(); ++i)
documents[i]->serviceScriptedAnimations(monotonicAnimationStartTime);
#if ENABLE(OILPAN)
documents.clear();
#endif
}
示例12: ASSERT
void EventPath::calculatePath()
{
ASSERT(m_node);
ASSERT(m_nodeEventContexts.isEmpty());
m_node->updateDistribution();
// For performance and memory usage reasons we want to store the
// path using as few bytes as possible and with as few allocations
// as possible which is why we gather the data on the stack before
// storing it in a perfectly sized m_nodeEventContexts Vector.
WillBeHeapVector<RawPtrWillBeMember<Node>, 64> nodesInPath;
Node* current = m_node;
nodesInPath.append(current);
while (current) {
if (m_event && current->keepEventInNode(m_event))
break;
WillBeHeapVector<RawPtrWillBeMember<InsertionPoint>, 8> insertionPoints;
collectDestinationInsertionPoints(*current, insertionPoints);
if (!insertionPoints.isEmpty()) {
for (const auto& insertionPoint : insertionPoints) {
if (insertionPoint->isShadowInsertionPoint()) {
ShadowRoot* containingShadowRoot = insertionPoint->containingShadowRoot();
ASSERT(containingShadowRoot);
if (!containingShadowRoot->isOldest())
nodesInPath.append(containingShadowRoot->olderShadowRoot());
}
nodesInPath.append(insertionPoint);
}
current = insertionPoints.last();
continue;
}
if (current->isShadowRoot()) {
if (m_event && shouldStopAtShadowRoot(*m_event, *toShadowRoot(current), *m_node))
break;
current = current->shadowHost();
#if !ENABLE(OILPAN)
// TODO(kochi): crbug.com/507413 This check is necessary when some asynchronous event
// is queued while its shadow host is removed and the shadow root gets the event
// immediately after it. When Oilpan is enabled, this situation does not happen.
// Except this case, shadow root's host is assumed to be non-null.
if (current)
nodesInPath.append(current);
#else
nodesInPath.append(current);
#endif
} else {
current = current->parentNode();
if (current)
nodesInPath.append(current);
}
}
m_nodeEventContexts.reserveCapacity(nodesInPath.size());
for (Node* nodeInPath : nodesInPath) {
m_nodeEventContexts.append(NodeEventContext(nodeInPath, eventTargetRespectingTargetRules(*nodeInPath)));
}
}
示例13: ASSERT
void AutomaticTrackSelection::performAutomaticTextTrackSelection(const TrackGroup& group)
{
ASSERT(group.tracks.size());
// First, find the track in the group that should be enabled (if any).
WillBeHeapVector<RefPtrWillBeMember<TextTrack>> currentlyEnabledTracks;
RefPtrWillBeRawPtr<TextTrack> trackToEnable = nullptr;
RefPtrWillBeRawPtr<TextTrack> defaultTrack = nullptr;
RefPtrWillBeRawPtr<TextTrack> preferredTrack = nullptr;
RefPtrWillBeRawPtr<TextTrack> fallbackTrack = nullptr;
int highestTrackScore = 0;
for (size_t i = 0; i < group.tracks.size(); ++i) {
RefPtrWillBeRawPtr<TextTrack> textTrack = group.tracks[i];
if (m_configuration.disableCurrentlyEnabledTracks && textTrack->mode() == TextTrack::showingKeyword())
currentlyEnabledTracks.append(textTrack);
int trackScore = textTrackSelectionScore(*textTrack);
if (textTrack->kind() == preferredTrackKind())
trackScore += 1;
if (trackScore) {
// * If the text track kind is subtitles or captions and the user has indicated an interest in having a
// track with this text track kind, text track language, and text track label enabled, and there is no
// other text track in the media element's list of text tracks with a text track kind of either subtitles
// or captions whose text track mode is showing
// Let the text track mode be showing.
if (trackScore > highestTrackScore) {
preferredTrack = textTrack;
highestTrackScore = trackScore;
}
if (!defaultTrack && textTrack->isDefault())
defaultTrack = textTrack;
if (!fallbackTrack)
fallbackTrack = textTrack;
} else if (!group.visibleTrack && !defaultTrack && textTrack->isDefault()) {
// * If the track element has a default attribute specified, and there is no other text track in the media
// element's list of text tracks whose text track mode is showing or showing by default
// Let the text track mode be showing by default.
defaultTrack = textTrack;
}
}
if (m_configuration.textTrackKindUserPreference != TextTrackKindUserPreference::Default)
trackToEnable = preferredTrack;
if (!trackToEnable && defaultTrack)
trackToEnable = defaultTrack;
if (!trackToEnable && m_configuration.forceEnableSubtitleOrCaptionTrack && group.kind == TrackGroup::CaptionsAndSubtitles)
trackToEnable = fallbackTrack ? fallbackTrack : group.tracks[0];
if (currentlyEnabledTracks.size()) {
for (size_t i = 0; i < currentlyEnabledTracks.size(); ++i) {
RefPtrWillBeRawPtr<TextTrack> textTrack = currentlyEnabledTracks[i];
if (textTrack != trackToEnable)
textTrack->setMode(TextTrack::disabledKeyword());
}
}
if (trackToEnable)
trackToEnable->setMode(TextTrack::showingKeyword());
}
示例14: deleteSelection
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());
//.........这里部分代码省略.........
示例15: analyzeStyleSheet
StyleSheetInvalidationAnalysis::StyleSheetInvalidationAnalysis(const TreeScope& treeScope, const WillBeHeapVector<RawPtrWillBeMember<StyleSheetContents>>& sheets)
: m_treeScope(&treeScope)
{
for (unsigned i = 0; i < sheets.size() && !m_dirtiesAllStyle; ++i)
analyzeStyleSheet(sheets[i]);
}