本文整理汇总了C++中WillBeHeapVector::size方法的典型用法代码示例。如果您正苦于以下问题:C++ WillBeHeapVector::size方法的具体用法?C++ WillBeHeapVector::size怎么用?C++ WillBeHeapVector::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WillBeHeapVector
的用法示例。
在下文中一共展示了WillBeHeapVector::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FakeResource
TEST_F(MemoryCacheTest, ResourceMapIsolation)
{
ResourcePtr<FakeResource> resource1 = new FakeResource(ResourceRequest("http://test/resource"), Resource::Raw);
memoryCache()->add(resource1.get());
ResourcePtr<FakeResource> resource2 = new FakeResource(ResourceRequest("http://test/resource"), Resource::Raw);
resource2->setCacheIdentifier("foo");
memoryCache()->add(resource2.get());
EXPECT_TRUE(memoryCache()->contains(resource1.get()));
EXPECT_TRUE(memoryCache()->contains(resource2.get()));
const KURL url = KURL(ParsedURLString, "http://test/resource");
EXPECT_EQ(resource1.get(), memoryCache()->resourceForURL(url));
EXPECT_EQ(resource1.get(), memoryCache()->resourceForURL(url, memoryCache()->defaultCacheIdentifier()));
EXPECT_EQ(resource2.get(), memoryCache()->resourceForURL(url, "foo"));
EXPECT_EQ(0, memoryCache()->resourceForURL(KURL()));
ResourcePtr<FakeResource> resource3 = new FakeResource(ResourceRequest("http://test/resource"), Resource::Raw);
resource3->setCacheIdentifier("foo");
memoryCache()->remove(resource2.get());
memoryCache()->add(resource3.get());
EXPECT_TRUE(memoryCache()->contains(resource1.get()));
EXPECT_FALSE(memoryCache()->contains(resource2.get()));
EXPECT_TRUE(memoryCache()->contains(resource3.get()));
ResourcePtr<FakeResource> resource4 = new FakeResource(ResourceRequest("http://test/resource"), Resource::Raw);
resource4->setCacheIdentifier("foo");
memoryCache()->replace(resource4.get(), resource3.get());
EXPECT_TRUE(memoryCache()->contains(resource1.get()));
EXPECT_FALSE(memoryCache()->contains(resource3.get()));
EXPECT_TRUE(memoryCache()->contains(resource4.get()));
WillBeHeapVector<RawPtrWillBeMember<Resource>> resources = memoryCache()->resourcesForURL(url);
EXPECT_EQ(2u, resources.size());
memoryCache()->evictResources();
EXPECT_FALSE(memoryCache()->contains(resource1.get()));
EXPECT_FALSE(memoryCache()->contains(resource3.get()));
}
示例2: reportValidity
bool HTMLFormControlElement::reportValidity()
{
WillBeHeapVector<RefPtrWillBeMember<HTMLFormControlElement>> unhandledInvalidControls;
bool isValid = checkValidity(&unhandledInvalidControls, CheckValidityDispatchInvalidEvent);
if (isValid || unhandledInvalidControls.isEmpty())
return isValid;
ASSERT(unhandledInvalidControls.size() == 1);
ASSERT(unhandledInvalidControls[0].get() == this);
// Update layout now before calling isFocusable(), which has
// !layoutObject()->needsLayout() assertion.
document().updateLayoutIgnorePendingStylesheets();
if (isFocusable()) {
showValidationMessage();
return false;
}
if (document().frame()) {
String message("An invalid form control with name='%name' is not focusable.");
message.replace("%name", name());
document().addConsoleMessage(ConsoleMessage::create(RenderingMessageSource, ErrorMessageLevel, message));
}
return false;
}
示例3: parser
PassRefPtrWillBeRawPtr<MHTMLArchive> MHTMLArchive::create(const KURL& url, SharedBuffer* data)
{
// For security reasons we only load MHTML pages from local URLs.
if (!SchemeRegistry::shouldTreatURLSchemeAsLocal(url.protocol()))
return nullptr;
MHTMLParser parser(data);
WillBeHeapVector<RefPtrWillBeMember<ArchiveResource>> resources = parser.parseArchive();
if (resources.isEmpty())
return nullptr; // Invalid MHTML file.
RefPtrWillBeRawPtr<MHTMLArchive> archive = adoptRefWillBeNoop(new MHTMLArchive);
// The first document suitable resource is the main resource of the top frame.
for (size_t i = 0; i < resources.size(); ++i) {
const AtomicString& mimeType = resources[i]->mimeType();
if (archive->mainResource() || !MIMETypeRegistry::isSupportedNonImageMIMEType(mimeType) || MIMETypeRegistry::isSupportedJavaScriptMIMEType(mimeType) || mimeType == "text/css")
archive->addSubresource(resources[i].get());
else
archive->setMainResource(resources[i].get());
}
return archive.release();
}
示例4: setLoadStatus
void FontFace::setLoadStatus(LoadStatus status)
{
m_status = status;
ASSERT(m_status != Error || m_error);
if (m_status == Loaded || m_status == Error) {
if (m_loadedProperty) {
if (m_status == Loaded)
m_loadedProperty->resolve(this);
else
m_loadedProperty->reject(m_error.get());
}
WillBeHeapVector<RefPtrWillBeMember<LoadFontCallback>> callbacks;
m_callbacks.swap(callbacks);
for (size_t i = 0; i < callbacks.size(); ++i) {
if (m_status == Loaded)
callbacks[i]->notifyLoaded(this);
else
callbacks[i]->notifyError(this);
}
}
}
示例5: selectMisspellingAsync
static String selectMisspellingAsync(LocalFrame* selectedFrame, DocumentMarker& marker)
{
VisibleSelection selection = selectedFrame->selection().selection();
if (!selection.isCaretOrRange())
return String();
// Caret and range selections always return valid normalized ranges.
RefPtrWillBeRawPtr<Range> selectionRange = selection.toNormalizedRange();
WillBeHeapVector<DocumentMarker*> markers = selectedFrame->document()->markers().markersInRange(selectionRange.get(), DocumentMarker::MisspellingMarkers());
if (markers.size() != 1)
return String();
marker = *markers[0];
// Cloning a range fails only for invalid ranges.
RefPtrWillBeRawPtr<Range> markerRange = selectionRange->cloneRange();
markerRange->setStart(markerRange->startContainer(), marker.startOffset());
markerRange->setEnd(markerRange->endContainer(), marker.endOffset());
if (markerRange->text().stripWhiteSpace(&IsWhiteSpaceOrPunctuation) != selectionRange->text().stripWhiteSpace(&IsWhiteSpaceOrPunctuation))
return String();
return markerRange->text();
}
示例6: 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;
}
示例7: checkInvalidControlsAndCollectUnhandled
bool HTMLFormElement::checkInvalidControlsAndCollectUnhandled(WillBeHeapVector<RefPtrWillBeMember<HTMLFormControlElement>>* unhandledInvalidControls, CheckValidityEventBehavior eventBehavior)
{
RefPtrWillBeRawPtr<HTMLFormElement> protector(this);
// Copy associatedElements because event handlers called from
// HTMLFormControlElement::checkValidity() might change associatedElements.
const FormAssociatedElement::List& associatedElements = this->associatedElements();
WillBeHeapVector<RefPtrWillBeMember<FormAssociatedElement>> elements;
elements.reserveCapacity(associatedElements.size());
for (unsigned i = 0; i < associatedElements.size(); ++i)
elements.append(associatedElements[i]);
int invalidControlsCount = 0;
for (unsigned i = 0; i < elements.size(); ++i) {
if (elements[i]->form() == this && elements[i]->isFormControlElement()) {
HTMLFormControlElement* control = toHTMLFormControlElement(elements[i].get());
if (control->isSubmittableElement() && !control->checkValidity(unhandledInvalidControls, eventBehavior) && control->formOwner() == this) {
++invalidControlsCount;
if (!unhandledInvalidControls && eventBehavior == CheckValidityDispatchNoEvent)
return true;
}
}
}
return invalidControlsCount;
}
示例8: 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));
}
示例9: deliver
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());
}
示例10: serviceScriptedAnimations
void PageAnimator::serviceScriptedAnimations(double monotonicAnimationStartTime)
{
m_animationFramePending = false;
TemporaryChange<bool> servicing(m_servicingAnimations, true);
for (RefPtr<Frame> frame = m_page->mainFrame(); frame; frame = frame->tree().traverseNext()) {
if (frame->isLocalFrame()) {
RefPtr<LocalFrame> localFrame = toLocalFrame(frame.get());
localFrame->view()->serviceScrollAnimations();
DocumentAnimations::updateAnimationTimingForAnimationFrame(*localFrame->document(), monotonicAnimationStartTime);
SVGDocumentExtensions::serviceOnAnimationFrame(*localFrame->document(), monotonicAnimationStartTime);
}
}
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)
documents[i]->serviceScriptedAnimations(monotonicAnimationStartTime);
}
示例11: setDefaultValue
void HTMLTextAreaElement::setDefaultValue(const String& defaultValue)
{
RefPtrWillBeRawPtr<Node> protectFromMutationEvents(this);
// To preserve comments, remove only the text nodes, then add a single text node.
WillBeHeapVector<RefPtrWillBeMember<Node>> textNodes;
for (Node* n = firstChild(); n; n = n->nextSibling()) {
if (n->isTextNode())
textNodes.append(n);
}
size_t size = textNodes.size();
for (size_t i = 0; i < size; ++i)
removeChild(textNodes[i].get(), IGNORE_EXCEPTION);
// Normalize line endings.
String value = defaultValue;
value.replace("\r\n", "\n");
value.replace('\r', '\n');
insertBefore(document().createTextNode(value), firstChild(), IGNORE_EXCEPTION);
if (!m_isDirty)
setNonDirtyValue(value);
}
示例12: doApply
//.........这里部分代码省略.........
// 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());
// Clone startNode's ancestors into the cloned blockquote.
// On exiting this loop, clonedAncestor is the lowest ancestor
// that was cloned (i.e. the clone of either ancestors.last()
// or clonedBlockquote if ancestors is empty).
RefPtrWillBeRawPtr<Element> clonedAncestor = clonedBlockquote;
for (size_t i = ancestors.size(); i != 0; --i) {
RefPtrWillBeRawPtr<Element> clonedChild = ancestors[i - 1]->cloneElementWithoutChildren();
// Preserve list item numbering in cloned lists.
if (isHTMLOListElement(*clonedChild)) {
Node* listChildNode = i > 1 ? ancestors[i - 2].get() : startNode;
// The first child of the cloned list might not be a list item element,
// find the first one so that we know where to start numbering.
while (listChildNode && !isHTMLLIElement(*listChildNode))
listChildNode = listChildNode->nextSibling();
if (isListItem(listChildNode))
setNodeAttribute(clonedChild, startAttr, AtomicString::number(toLayoutListItem(listChildNode->layoutObject())->value()));
}
appendNode(clonedChild.get(), clonedAncestor.get());
clonedAncestor = clonedChild;
}
moveRemainingSiblingsToNewParent(startNode, 0, clonedAncestor);
if (!ancestors.isEmpty()) {
// Split the tree up the ancestor chain until the topBlockquote
// Throughout this loop, clonedParent is the clone of ancestor's parent.
// This is so we can clone ancestor's siblings and place the clones
// into the clone corresponding to the ancestor's parent.
RefPtrWillBeRawPtr<Element> ancestor = nullptr;
RefPtrWillBeRawPtr<Element> clonedParent = nullptr;
for (ancestor = ancestors.first(), clonedParent = clonedAncestor->parentElement();
ancestor && ancestor != topBlockquote;
ancestor = ancestor->parentElement(), clonedParent = clonedParent->parentElement())
moveRemainingSiblingsToNewParent(ancestor->nextSibling(), 0, clonedParent);
// If the startNode's original parent is now empty, remove it
Element* originalParent = ancestors.first().get();
if (!originalParent->hasChildren())
removeNode(originalParent);
}
// Make sure the cloned block quote renders.
addBlockPlaceholderIfNeeded(clonedBlockquote.get());
// Put the selection right before the break.
setEndingSelection(VisibleSelection(positionBeforeNode(breakElement.get()), TextAffinity::Downstream, endingSelection().isDirectional()));
rebalanceWhitespace();
}
示例13: performAutomaticTextTrackSelection
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: addKeyframeRules
void ScopedStyleResolver::addKeyframeRules(const RuleSet& ruleSet)
{
const WillBeHeapVector<RawPtrWillBeMember<StyleRuleKeyframes>> keyframesRules = ruleSet.keyframesRules();
for (unsigned i = 0; i < keyframesRules.size(); ++i)
addKeyframeStyle(keyframesRules[i]);
}
示例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]);
}