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


C++ HeapVector::size方法代码示例

本文整理汇总了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));
}
开发者ID:dstockwell,项目名称:blink,代码行数:13,代码来源:SpeechRecognition.cpp

示例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());
}
开发者ID:aobzhirov,项目名称:ChromiumGStreamerBackend,代码行数:29,代码来源:CSSVariableResolver.cpp

示例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);
}
开发者ID:aobzhirov,项目名称:ChromiumGStreamerBackend,代码行数:32,代码来源:IDBEventDispatcher.cpp

示例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());
}
开发者ID:mirror,项目名称:chromium,代码行数:30,代码来源:CustomElementUpgradeSorterTest.cpp

示例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);
}
开发者ID:aobzhirov,项目名称:ChromiumGStreamerBackend,代码行数:7,代码来源:GeolocationController.cpp

示例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();
  }
}
开发者ID:mirror,项目名称:chromium,代码行数:27,代码来源:ScreenOrientationController.cpp

示例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));
}
开发者ID:,项目名称:,代码行数:35,代码来源:

示例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();
}
开发者ID:astojilj,项目名称:chromium-crosswalk,代码行数:26,代码来源:WebCLEvent.cpp

示例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);
}
开发者ID:,项目名称:,代码行数:28,代码来源:

示例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;
}
开发者ID:mirror,项目名称:chromium,代码行数:34,代码来源:StyleSheetContents.cpp

示例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();
}
开发者ID:aobzhirov,项目名称:ChromiumGStreamerBackend,代码行数:27,代码来源:TextTrackList.cpp

示例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]);
    }
}
开发者ID:dstockwell,项目名称:blink,代码行数:7,代码来源:LoadableTextTrack.cpp

示例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]);
}
开发者ID:ollie314,项目名称:chromium,代码行数:29,代码来源:ActiveStyleSheetsTest.cpp

示例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);
}
开发者ID:mirror,项目名称:chromium,代码行数:25,代码来源:MutationObserver.cpp

示例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";
}
开发者ID:,项目名称:,代码行数:30,代码来源:


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