本文整理汇总了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);
}