本文整理汇总了C++中HeapVector::size方法的典型用法代码示例。如果您正苦于以下问题:C++ HeapVector::size方法的具体用法?C++ HeapVector::size怎么用?C++ HeapVector::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HeapVector
的用法示例。
在下文中一共展示了HeapVector::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: didReceiveResults
void SpeechRecognition::didReceiveResults(const HeapVector<Member<SpeechRecognitionResult>>& newFinalResults, const HeapVector<Member<SpeechRecognitionResult>>& currentInterimResults)
{
size_t resultIndex = m_finalResults.size();
for (size_t i = 0; i < newFinalResults.size(); ++i)
m_finalResults.append(newFinalResults[i]);
HeapVector<Member<SpeechRecognitionResult>> results = m_finalResults;
for (size_t i = 0; i < currentInterimResults.size(); ++i)
results.append(currentInterimResults[i]);
dispatchEvent(SpeechRecognitionEvent::createResult(resultIndex, results));
}
示例2: resolveAndApplyVariableReferences
void CSSVariableResolver::resolveAndApplyVariableReferences(StyleResolverState& state, CSSPropertyID id, const CSSVariableReferenceValue& value)
{
CSSVariableResolver resolver(state.style()->variables());
Vector<CSSParserToken> tokens;
if (resolver.resolveTokenRange(value.variableDataValue()->tokens(), tokens)) {
CSSParserContext context(HTMLStandardMode, 0);
HeapVector<CSSProperty, 256> parsedProperties;
// TODO: Non-shorthands should just call CSSPropertyParser::parseSingleValue
if (CSSPropertyParser::parseValue(id, false, CSSParserTokenRange(tokens), context, parsedProperties, StyleRule::RuleType::Style)) {
unsigned parsedPropertiesCount = parsedProperties.size();
for (unsigned i = 0; i < parsedPropertiesCount; ++i)
StyleBuilder::applyProperty(parsedProperties[i].id(), state, parsedProperties[i].value());
return;
}
}
RawPtr<CSSUnsetValue> unset = cssValuePool().createUnsetValue();
if (isShorthandProperty(id)) {
StylePropertyShorthand shorthand = shorthandForProperty(id);
for (unsigned i = 0; i < shorthand.length(); i++)
StyleBuilder::applyProperty(shorthand.properties()[i], state, unset.get());
return;
}
StyleBuilder::applyProperty(id, state, unset.get());
}
示例3: dispatch
DispatchEventResult IDBEventDispatcher::dispatch(Event* event, HeapVector<Member<EventTarget>>& eventTargets)
{
size_t size = eventTargets.size();
ASSERT(size);
event->setEventPhase(Event::CAPTURING_PHASE);
for (size_t i = size - 1; i; --i) { // Don't do the first element.
event->setCurrentTarget(eventTargets[i].get());
eventTargets[i]->fireEventListeners(event);
if (event->propagationStopped())
goto doneDispatching;
}
event->setEventPhase(Event::AT_TARGET);
event->setCurrentTarget(eventTargets[0].get());
eventTargets[0]->fireEventListeners(event);
if (event->propagationStopped() || !event->bubbles() || event->cancelBubble())
goto doneDispatching;
event->setEventPhase(Event::BUBBLING_PHASE);
for (size_t i = 1; i < size; ++i) { // Don't do the first element.
event->setCurrentTarget(eventTargets[i].get());
eventTargets[i]->fireEventListeners(event);
if (event->propagationStopped() || event->cancelBubble())
goto doneDispatching;
}
doneDispatching:
event->setCurrentTarget(nullptr);
event->setEventPhase(Event::NONE);
return EventTarget::dispatchEventResult(*event);
}
示例4: createElementWithId
TEST_F(CustomElementUpgradeSorterTest, sorter_shadow) {
// A*
// + {ShadowRoot}
// | + B
// | + C*
// + D*
Element* a = createElementWithId("a-a", "a");
Element* b = createElementWithId("a-a", "b");
Element* c = createElementWithId("a-a", "c");
Element* d = createElementWithId("a-a", "d");
document()->documentElement()->appendChild(a);
ShadowRoot* s = attachShadowTo(a);
a->appendChild(d);
s->appendChild(b);
b->appendChild(c);
CustomElementUpgradeSorter sort;
sort.add(a);
sort.add(c);
sort.add(d);
HeapVector<Member<Element>> elements;
sort.sorted(&elements, document());
EXPECT_EQ(3u, elements.size());
EXPECT_EQ(a, elements[0].get());
EXPECT_EQ(c, elements[1].get());
EXPECT_EQ(d, elements[2].get());
}
示例5: errorOccurred
void GeolocationController::errorOccurred(GeolocationError* error)
{
HeapVector<Member<Geolocation>> observersVector;
copyToVector(m_observers, observersVector);
for (size_t i = 0; i < observersVector.size(); ++i)
observersVector[i]->setError(error);
}
示例6: notifyOrientationChanged
void ScreenOrientationController::notifyOrientationChanged() {
if (!isActiveAndVisible())
return;
updateOrientation();
// Keep track of the frames that need to be notified before notifying the
// current frame as it will prevent side effects from the change event
// handlers.
HeapVector<Member<LocalFrame>> childFrames;
for (Frame* child = frame()->tree().firstChild(); child;
child = child->tree().nextSibling()) {
if (child->isLocalFrame())
childFrames.append(toLocalFrame(child));
}
// Notify current orientation object.
if (!m_dispatchEventTimer.isActive())
m_dispatchEventTimer.startOneShot(0, BLINK_FROM_HERE);
// ... and child frames, if they have a ScreenOrientationController.
for (size_t i = 0; i < childFrames.size(); ++i) {
if (ScreenOrientationController* controller =
ScreenOrientationController::from(*childFrames[i]))
controller->notifyOrientationChanged();
}
}
示例7: ResourceRequest
TEST_F(MemoryCacheTest, ResourceMapIsolation) {
FakeResource* resource1 = FakeResource::create(
ResourceRequest("http://test/resource"), Resource::Raw);
memoryCache()->add(resource1);
FakeResource* resource2 = FakeResource::create(
ResourceRequest("http://test/resource"), Resource::Raw);
resource2->setCacheIdentifier("foo");
memoryCache()->add(resource2);
EXPECT_TRUE(memoryCache()->contains(resource1));
EXPECT_TRUE(memoryCache()->contains(resource2));
const KURL url = KURL(ParsedURLString, "http://test/resource");
EXPECT_EQ(resource1, memoryCache()->resourceForURL(url));
EXPECT_EQ(resource1, memoryCache()->resourceForURL(
url, memoryCache()->defaultCacheIdentifier()));
EXPECT_EQ(resource2, memoryCache()->resourceForURL(url, "foo"));
EXPECT_EQ(0, memoryCache()->resourceForURL(KURL()));
FakeResource* resource3 = FakeResource::create(
ResourceRequest("http://test/resource"), Resource::Raw);
resource3->setCacheIdentifier("foo");
memoryCache()->remove(resource2);
memoryCache()->add(resource3);
EXPECT_TRUE(memoryCache()->contains(resource1));
EXPECT_FALSE(memoryCache()->contains(resource2));
EXPECT_TRUE(memoryCache()->contains(resource3));
HeapVector<Member<Resource>> resources = memoryCache()->resourcesForURL(url);
EXPECT_EQ(2u, resources.size());
memoryCache()->evictResources();
EXPECT_FALSE(memoryCache()->contains(resource1));
EXPECT_FALSE(memoryCache()->contains(resource3));
}
示例8: callbackProxyOnMainThread
void WebCLEvent::callbackProxyOnMainThread(PassOwnPtr<WebCLEventHolder> holder)
{
ASSERT(isMainThread());
RefPtr<WebCLEvent> webEvent(static_cast<WebCLEvent*>(holder->event.get()));
#ifndef NDEBUG
cl_event event = holder->event2;
#endif
cl_int type = holder->type2;
if (!webEvent)
return;
// Ignore the callback if the WebCLEvent is released or OpenCL event is abnormally terminated.
if (webEvent->isReleased() || type != holder->type) {
webEvent->m_callbacks.clear();
return;
}
ASSERT(event == webEvent->getEvent());
HeapVector<Member<WebCLCallback>> callbacks = webEvent->m_callbacks;
ASSERT(callbacks.size());
for (auto callback : callbacks)
callback->handleEvent();
webEvent->m_callbacks.clear();
}
示例9: distributeTo
void DistributionPool::distributeTo(InsertionPoint* insertionPoint,
ElementShadowV0* elementShadow) {
DistributedNodes distributedNodes;
for (size_t i = 0; i < m_nodes.size(); ++i) {
if (m_distributed[i])
continue;
if (isHTMLContentElement(*insertionPoint) &&
!toHTMLContentElement(insertionPoint)->canSelectNode(m_nodes, i))
continue;
Node* node = m_nodes[i];
distributedNodes.append(node);
elementShadow->didDistributeNode(node, insertionPoint);
m_distributed[i] = true;
}
// Distributes fallback elements
if (insertionPoint->isContentInsertionPoint() && distributedNodes.isEmpty()) {
for (Node* fallbackNode = insertionPoint->firstChild(); fallbackNode;
fallbackNode = fallbackNode->nextSibling()) {
distributedNodes.append(fallbackNode);
elementShadow->didDistributeNode(fallbackNode, insertionPoint);
}
}
insertionPoint->setDistributedNodes(distributedNodes);
}
示例10: childRulesHaveFailedOrCanceledSubresources
static bool childRulesHaveFailedOrCanceledSubresources(
const HeapVector<Member<StyleRuleBase>>& rules) {
for (unsigned i = 0; i < rules.size(); ++i) {
const StyleRuleBase* rule = rules[i].get();
switch (rule->type()) {
case StyleRuleBase::Style:
if (toStyleRule(rule)->propertiesHaveFailedOrCanceledSubresources())
return true;
break;
case StyleRuleBase::FontFace:
if (toStyleRuleFontFace(rule)
->properties()
.hasFailedOrCanceledSubresources())
return true;
break;
case StyleRuleBase::Media:
if (childRulesHaveFailedOrCanceledSubresources(
toStyleRuleMedia(rule)->childRules()))
return true;
break;
case StyleRuleBase::Charset:
case StyleRuleBase::Import:
case StyleRuleBase::Namespace:
ASSERT_NOT_REACHED();
case StyleRuleBase::Page:
case StyleRuleBase::Keyframes:
case StyleRuleBase::Keyframe:
case StyleRuleBase::Supports:
case StyleRuleBase::Viewport:
break;
}
}
return false;
}
示例11: invalidateTrackIndexesAfterTrack
void TextTrackList::invalidateTrackIndexesAfterTrack(TextTrack* track)
{
HeapVector<Member<TextTrack>>* tracks = nullptr;
if (track->trackType() == TextTrack::TrackElement) {
tracks = &m_elementTracks;
for (size_t i = 0; i < m_addTrackTracks.size(); ++i)
m_addTrackTracks[i]->invalidateTrackIndex();
for (size_t i = 0; i < m_inbandTracks.size(); ++i)
m_inbandTracks[i]->invalidateTrackIndex();
} else if (track->trackType() == TextTrack::AddTrack) {
tracks = &m_addTrackTracks;
for (size_t i = 0; i < m_inbandTracks.size(); ++i)
m_inbandTracks[i]->invalidateTrackIndex();
} else if (track->trackType() == TextTrack::InBand) {
tracks = &m_inbandTracks;
} else {
ASSERT_NOT_REACHED();
}
size_t index = tracks->find(track);
if (index == kNotFound)
return;
for (size_t i = index; i < tracks->size(); ++i)
tracks->at(index)->invalidateTrackIndex();
}
示例12: addRegions
void LoadableTextTrack::addRegions(const HeapVector<Member<VTTRegion>>& newRegions)
{
for (size_t i = 0; i < newRegions.size(); ++i) {
newRegions[i]->setTrack(this);
regions()->add(newRegions[i]);
}
}
示例13: createSheet
TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_Mutated) {
ActiveStyleSheetVector oldSheets;
ActiveStyleSheetVector newSheets;
HeapVector<Member<RuleSet>> changedRuleSets;
CSSStyleSheet* sheet1 = createSheet();
CSSStyleSheet* sheet2 = createSheet();
CSSStyleSheet* sheet3 = createSheet();
oldSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
oldSheets.append(std::make_pair(sheet2, &sheet2->contents()->ruleSet()));
oldSheets.append(std::make_pair(sheet3, &sheet3->contents()->ruleSet()));
sheet2->contents()->clearRuleSet();
sheet2->contents()->ensureRuleSet(MediaQueryEvaluator(),
RuleHasDocumentSecurityOrigin);
EXPECT_NE(oldSheets[1].second, &sheet2->contents()->ruleSet());
newSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
newSheets.append(std::make_pair(sheet2, &sheet2->contents()->ruleSet()));
newSheets.append(std::make_pair(sheet3, &sheet3->contents()->ruleSet()));
EXPECT_EQ(ActiveSheetsChanged,
compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets));
ASSERT_EQ(2u, changedRuleSets.size());
EXPECT_EQ(&sheet2->contents()->ruleSet(), changedRuleSets[0]);
EXPECT_EQ(oldSheets[1].second, changedRuleSets[1]);
}
示例14: deliver
void MutationObserver::deliver() {
DCHECK(!shouldBeSuspended());
// Calling clearTransientRegistrations() can modify m_registrations, so it's
// necessary to make a copy of the transient registrations before operating on
// them.
HeapVector<Member<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);
// Report the first (earliest) stack as the async cause.
InspectorInstrumentation::AsyncTask asyncTask(
m_callback->getExecutionContext(), records.first());
m_callback->call(records, this);
}
示例15: descriptor
TEST_F(CustomElementRegistryTest,
collectCandidates_shouldOnlyIncludeCandidatesMatchingDescriptor) {
CustomElementDescriptor descriptor("hello-world", "hello-world");
// Does not match: namespace is not HTML
Element* elementA = CreateElement("hello-world")
.inDocument(&document())
.inNamespace("data:text/date,1981-03-10");
// Matches
Element* elementB = CreateElement("hello-world").inDocument(&document());
// Does not match: local name is not hello-world
Element* elementC = CreateElement("button")
.inDocument(&document())
.withIsAttribute("hello-world");
document().documentElement()->appendChild(elementA);
elementA->appendChild(elementB);
elementA->appendChild(elementC);
registry().addCandidate(elementA);
registry().addCandidate(elementB);
registry().addCandidate(elementC);
HeapVector<Member<Element>> elements;
collectCandidates(descriptor, &elements);
EXPECT_EQ(1u, elements.size())
<< "only one candidates should have been found";
EXPECT_EQ(elementB, elements[0])
<< "the matching element should have been found";
}