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


C++ HeapVector类代码示例

本文整理汇总了C++中HeapVector的典型用法代码示例。如果您正苦于以下问题:C++ HeapVector类的具体用法?C++ HeapVector怎么用?C++ HeapVector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了HeapVector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TEST_F

TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_AppendedToNonEmpty) {
  ActiveStyleSheetVector oldSheets;
  ActiveStyleSheetVector newSheets;
  HeapVector<Member<RuleSet>> changedRuleSets;

  CSSStyleSheet* sheet1 = createSheet();
  CSSStyleSheet* sheet2 = createSheet();

  oldSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
  newSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
  newSheets.append(std::make_pair(sheet2, &sheet2->contents()->ruleSet()));

  EXPECT_EQ(ActiveSheetsAppended,
            compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets));
  EXPECT_EQ(1u, changedRuleSets.size());
}
开发者ID:ollie314,项目名称:chromium,代码行数:16,代码来源:ActiveStyleSheetsTest.cpp

示例2: 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

示例3: addRules

static void addRules(RuleSet* ruleSet,
                     const HeapVector<MinimalRuleData>& rules) {
  for (unsigned i = 0; i < rules.size(); ++i) {
    const MinimalRuleData& info = rules[i];
    ruleSet->addRule(info.m_rule, info.m_selectorIndex, info.m_flags);
  }
}
开发者ID:ollie314,项目名称:chromium,代码行数:7,代码来源:ScopedStyleResolver.cpp

示例4: TEST_F

TEST_F(CustomElementUpgradeSorterTest, oneCandidate) {
  NonThrowableExceptionState noExceptions;
  Element* element =
      document()->createElement("a-a", StringOrDictionary(), noExceptions);
  document()->documentElement()->appendChild(element);

  CustomElementUpgradeSorter sorter;
  sorter.add(element);

  HeapVector<Member<Element>> elements;
  sorter.sorted(&elements, document());
  EXPECT_EQ(1u, elements.size())
      << "exactly one candidate should be in the result set";
  EXPECT_TRUE(elements.contains(element))
      << "the candidate should be the element that was added";
}
开发者ID:mirror,项目名称:chromium,代码行数:16,代码来源:CustomElementUpgradeSorterTest.cpp

示例5: 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

示例6: styleEngine

StyleEngineTest::RuleSetInvalidation
StyleEngineTest::scheduleInvalidationsForRules(TreeScope& treeScope,
                                               const String& cssText) {
  StyleSheetContents* sheet =
      StyleSheetContents::create(CSSParserContext(HTMLStandardMode, nullptr));
  sheet->parseString(cssText);
  HeapVector<Member<RuleSet>> ruleSets;
  RuleSet& ruleSet = sheet->ensureRuleSet(MediaQueryEvaluator(),
                                          RuleHasDocumentSecurityOrigin);
  ruleSet.compactRulesIfNeeded();
  if (ruleSet.needsFullRecalcForRuleSetInvalidation())
    return RuleSetInvalidationFullRecalc;
  ruleSets.append(&ruleSet);
  styleEngine().scheduleInvalidationsForRuleSets(treeScope, ruleSets);
  return RuleSetInvalidationsScheduled;
}
开发者ID:,项目名称:,代码行数:16,代码来源:

示例7: requestMediaKeySystemAccess

ScriptPromise NavigatorRequestMediaKeySystemAccess::requestMediaKeySystemAccess(
    ScriptState* scriptState,
    Navigator& navigator,
    const String& keySystem,
    const HeapVector<MediaKeySystemConfiguration>& supportedConfigurations)
{
    WTF_LOG(Media, "NavigatorRequestMediaKeySystemAccess::requestMediaKeySystemAccess()");

    // From https://w3c.github.io/encrypted-media/#requestMediaKeySystemAccess
    // When this method is invoked, the user agent must run the following steps:
    // 1. If keySystem is an empty string, return a promise rejected with a
    //    new DOMException whose name is InvalidAccessError.
    if (keySystem.isEmpty()) {
        return ScriptPromise::rejectWithDOMException(
            scriptState, DOMException::create(InvalidAccessError, "The keySystem parameter is empty."));
    }

    // 2. If supportedConfigurations was provided and is empty, return a
    //    promise rejected with a new DOMException whose name is
    //    InvalidAccessError.
    if (!supportedConfigurations.size()) {
        return ScriptPromise::rejectWithDOMException(
            scriptState, DOMException::create(InvalidAccessError, "The supportedConfigurations parameter is empty."));
    }

    // 3-4. 'May Document use powerful features?' check.
    ExecutionContext* executionContext = scriptState->executionContext();
    String errorMessage;
    if (executionContext->isPrivilegedContext(errorMessage)) {
        UseCounter::count(executionContext, UseCounter::EncryptedMediaSecureOrigin);
    } else {
        UseCounter::countDeprecation(executionContext, UseCounter::EncryptedMediaInsecureOrigin);
        // TODO(ddorwin): Implement the following:
        // Reject promise with a new DOMException whose name is NotSupportedError.
    }


    // 5. Let origin be the origin of document.
    //    (Passed with the execution context in step 7.)

    // 6. Let promise be a new promise.
    Document* document = toDocument(executionContext);
    if (!document->page()) {
        return ScriptPromise::rejectWithDOMException(
            scriptState, DOMException::create(InvalidStateError, "The context provided is not associated with a page."));
    }

    MediaKeySystemAccessInitializer* initializer = new MediaKeySystemAccessInitializer(scriptState, keySystem, supportedConfigurations);
    ScriptPromise promise = initializer->promise();

    // 7. Asynchronously determine support, and if allowed, create and
    //    initialize the MediaKeySystemAccess object.
    MediaKeysController* controller = MediaKeysController::from(document->page());
    WebEncryptedMediaClient* mediaClient = controller->encryptedMediaClient(executionContext);
    mediaClient->requestMediaKeySystemAccess(WebEncryptedMediaRequest(initializer));

    // 8. Return promise.
    return promise;
}
开发者ID:dstockwell,项目名称:blink,代码行数:59,代码来源:NavigatorRequestMediaKeySystemAccess.cpp

示例8: inputs

MIDIInputMap* MIDIAccess::inputs() const
{
    HeapVector<Member<MIDIInput>> inputs;
    HashSet<String> ids;
    for (size_t i = 0; i < m_inputs.size(); ++i) {
        MIDIInput* input = m_inputs[i];
        if (input->getState() != PortState::MIDIPortStateDisconnected) {
            inputs.append(input);
            ids.add(input->id());
        }
    }
    if (inputs.size() != ids.size()) {
        // There is id duplication that violates the spec.
        inputs.clear();
    }
    return new MIDIInputMap(inputs);
}
开发者ID:endlessm,项目名称:chromium-browser,代码行数:17,代码来源:MIDIAccess.cpp

示例9: treeScope

void ScopedStyleResolver::addFontFaceRules(const RuleSet& ruleSet) {
  // FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets for
  // the moment.
  if (!treeScope().rootNode().isDocumentNode())
    return;

  Document& document = treeScope().document();
  CSSFontSelector* cssFontSelector = document.styleEngine().fontSelector();
  const HeapVector<Member<StyleRuleFontFace>> fontFaceRules =
      ruleSet.fontFaceRules();
  for (auto& fontFaceRule : fontFaceRules) {
    if (FontFace* fontFace = FontFace::create(&document, fontFaceRule))
      cssFontSelector->fontFaceCache()->add(cssFontSelector, fontFaceRule,
                                            fontFace);
  }
  if (fontFaceRules.size())
    document.styleResolver()->invalidateMatchedPropertiesCache();
}
开发者ID:ollie314,项目名称:chromium,代码行数:18,代码来源:ScopedStyleResolver.cpp

示例10: pool

void ElementShadowV0::distribute() {
  HeapVector<Member<HTMLShadowElement>, 32> shadowInsertionPoints;
  DistributionPool pool(m_elementShadow->host());

  for (ShadowRoot* root = &youngestShadowRoot(); root;
       root = root->olderShadowRoot()) {
    HTMLShadowElement* shadowInsertionPoint = 0;
    for (const auto& point : root->descendantInsertionPoints()) {
      if (!point->isActive())
        continue;
      if (isHTMLShadowElement(*point)) {
        DCHECK(!shadowInsertionPoint);
        shadowInsertionPoint = toHTMLShadowElement(point);
        shadowInsertionPoints.append(shadowInsertionPoint);
      } else {
        pool.distributeTo(point, this);
        if (ElementShadow* shadow =
                shadowWhereNodeCanBeDistributedForV0(*point))
          shadow->setNeedsDistributionRecalc();
      }
    }
  }

  for (size_t i = shadowInsertionPoints.size(); i > 0; --i) {
    HTMLShadowElement* shadowInsertionPoint = shadowInsertionPoints[i - 1];
    ShadowRoot* root = shadowInsertionPoint->containingShadowRoot();
    DCHECK(root);
    if (root->isOldest()) {
      pool.distributeTo(shadowInsertionPoint, this);
    } else if (root->olderShadowRoot()->type() == root->type()) {
      // Only allow reprojecting older shadow roots between the same type to
      // disallow reprojecting UA elements into author shadows.
      DistributionPool olderShadowRootPool(*root->olderShadowRoot());
      olderShadowRootPool.distributeTo(shadowInsertionPoint, this);
      root->olderShadowRoot()->setShadowInsertionPointOfYoungerShadowRoot(
          shadowInsertionPoint);
    }
    if (ElementShadow* shadow =
            shadowWhereNodeCanBeDistributedForV0(*shadowInsertionPoint))
      shadow->setNeedsDistributionRecalc();
  }
  InspectorInstrumentation::didPerformElementShadowDistribution(
      &m_elementShadow->host());
}
开发者ID:,项目名称:,代码行数:44,代码来源:

示例11: encodeAndNormalize

HeapVector<FormDataEntryValue> FormData::getAll(const String& name)
{
    HeapVector<FormDataEntryValue> results;

    const CString encodedName = encodeAndNormalize(name);
    for (const auto& entry : entries()) {
        if (entry->name() != encodedName)
            continue;
        FormDataEntryValue value;
        if (entry->isString()) {
            value.setUSVString(decode(entry->value()));
        } else {
            ASSERT(entry->isFile());
            value.setFile(entry->file());
        }
        results.append(value);
    }
    return results;
}
开发者ID:azureplus,项目名称:chromium,代码行数:19,代码来源:FormData.cpp

示例12: startIteration

FontFaceSetIterable::IterationSource* FontFaceSet::startIteration(
    ScriptState*,
    ExceptionState&) {
  // Setlike should iterate each item in insertion order, and items should
  // be keep on up to date. But since blink does not have a way to hook up CSS
  // modification, take a snapshot here, and make it ordered as follows.
  HeapVector<Member<FontFace>> fontFaces;
  if (inActiveDocumentContext()) {
    const HeapListHashSet<Member<FontFace>>& cssConnectedFaces =
        cssConnectedFontFaceList();
    fontFaces.reserveInitialCapacity(cssConnectedFaces.size() +
                                     m_nonCSSConnectedFaces.size());
    for (const auto& fontFace : cssConnectedFaces)
      fontFaces.append(fontFace);
    for (const auto& fontFace : m_nonCSSConnectedFaces)
      fontFaces.append(fontFace);
  }
  return new IterationSource(fontFaces);
}
开发者ID:mirror,项目名称:chromium,代码行数:19,代码来源:FontFaceSet.cpp

示例13: completeURLs

static void completeURLs(DocumentFragment& fragment, const String& baseURL) {
  HeapVector<AttributeChange> changes;

  KURL parsedBaseURL(ParsedURLString, baseURL);

  for (Element& element : ElementTraversal::descendantsOf(fragment)) {
    AttributeCollection attributes = element.attributes();
    // AttributeCollection::iterator end = attributes.end();
    for (const auto& attribute : attributes) {
      if (element.isURLAttribute(attribute) && !attribute.value().isEmpty())
        changes.append(AttributeChange(
            &element, attribute.name(),
            KURL(parsedBaseURL, attribute.value()).getString()));
    }
  }

  for (auto& change : changes)
    change.apply();
}
开发者ID:,项目名称:,代码行数:19,代码来源:

示例14: namedGetter

void HTMLFormControlsCollection::namedGetter(
    const AtomicString& name,
    RadioNodeListOrElement& returnValue) {
  HeapVector<Member<Element>> namedItems;
  this->namedItems(name, namedItems);

  if (namedItems.isEmpty())
    return;

  if (namedItems.size() == 1) {
    if (!isHTMLImageElement(*namedItems[0]))
      returnValue.setElement(namedItems.at(0));
    return;
  }

  // This path never returns a RadioNodeList for <img> because
  // onlyMatchingImgElements flag is false by default.
  returnValue.setRadioNodeList(ownerNode().radioNodeList(name));
}
开发者ID:,项目名称:,代码行数:19,代码来源:

示例15: TEST_F

TEST_F(CustomElementRegistryTest,
       collectCandidates_shouldNotIncludeElementsInDifferentDocument) {
  Element* element = CreateElement("a-a").inDocument(&document());
  registry().addCandidate(element);

  Document* otherDocument = HTMLDocument::create();
  otherDocument->appendChild(element);
  EXPECT_EQ(otherDocument, element->ownerDocument())
      << "sanity: another document should have adopted an element on append";

  HeapVector<Member<Element>> elements;
  collectCandidates(CustomElementDescriptor("a-a", "a-a"), &elements);

  EXPECT_TRUE(elements.isEmpty())
      << "no candidates should have been found, but we have "
      << elements.size();
  EXPECT_FALSE(elements.contains(element))
      << "the adopted-away candidate should not have been found";
}
开发者ID:,项目名称:,代码行数:19,代码来源:


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