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


C++ StyleRule::shouldConsiderForMatchingRules方法代码示例

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


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

示例1: collectMatchingRulesForList

void ElementRuleCollector::collectMatchingRulesForList(
    const RuleDataListType* rules,
    CascadeOrder cascadeOrder,
    const MatchRequest& matchRequest) {
  if (!rules)
    return;

  SelectorChecker::Init init;
  init.mode = m_mode;
  init.isUARule = m_matchingUARules;
  init.elementStyle = m_style.get();
  init.scrollbar = m_pseudoStyleRequest.scrollbar;
  init.scrollbarPart = m_pseudoStyleRequest.scrollbarPart;
  SelectorChecker checker(init);
  SelectorChecker::SelectorCheckingContext context(
      m_context.element(), SelectorChecker::VisitedMatchEnabled);
  context.scope = matchRequest.scope;
  context.pseudoId = m_pseudoStyleRequest.pseudoId;

  unsigned rejected = 0;
  unsigned fastRejected = 0;
  unsigned matched = 0;

  for (const auto& ruleData : *rules) {
    if (m_canUseFastReject &&
        m_selectorFilter.fastRejectSelector<RuleData::maximumIdentifierCount>(
            ruleData.descendantSelectorIdentifierHashes())) {
      fastRejected++;
      continue;
    }

    // FIXME: Exposing the non-standard getMatchedCSSRules API to web is the
    // only reason this is needed.
    if (m_sameOriginOnly && !ruleData.hasDocumentSecurityOrigin())
      continue;

    StyleRule* rule = ruleData.rule();

    // If the rule has no properties to apply, then ignore it in the non-debug
    // mode.
    if (!rule->shouldConsiderForMatchingRules(m_includeEmptyRules))
      continue;

    SelectorChecker::MatchResult result;
    context.selector = &ruleData.selector();
    if (!checker.match(context, result)) {
      rejected++;
      continue;
    }
    if (m_pseudoStyleRequest.pseudoId != PseudoIdNone &&
        m_pseudoStyleRequest.pseudoId != result.dynamicPseudo) {
      rejected++;
      continue;
    }

    matched++;
    didMatchRule(ruleData, result, cascadeOrder, matchRequest);
  }

  StyleEngine& styleEngine = m_context.element()->document().styleEngine();
  if (!styleEngine.stats())
    return;

  INCREMENT_STYLE_STATS_COUNTER(styleEngine, rulesRejected, rejected);
  INCREMENT_STYLE_STATS_COUNTER(styleEngine, rulesFastRejected, fastRejected);
  INCREMENT_STYLE_STATS_COUNTER(styleEngine, rulesMatched, matched);
}
开发者ID:,项目名称:,代码行数:67,代码来源:


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