本文整理汇总了C++中ContainerNode::updateDistribution方法的典型用法代码示例。如果您正苦于以下问题:C++ ContainerNode::updateDistribution方法的具体用法?C++ ContainerNode::updateDistribution怎么用?C++ ContainerNode::updateDistribution使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContainerNode
的用法示例。
在下文中一共展示了ContainerNode::updateDistribution方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
void SelectorDataList::execute(ContainerNode& rootNode, typename SelectorQueryTrait::OutputType& output) const
{
if (!canUseFastQuery(rootNode)) {
if (m_needsUpdatedDistribution)
rootNode.updateDistribution();
if (m_crossesTreeBoundary) {
executeSlowTraversingShadowTree<SelectorQueryTrait>(rootNode, output);
} else {
executeSlow<SelectorQueryTrait>(rootNode, output);
}
return;
}
ASSERT(m_selectors.size() == 1);
const CSSSelector& selector = *m_selectors[0];
const CSSSelector& firstSelector = selector;
// Fast path for querySelector*('#id'), querySelector*('tag#id').
if (const CSSSelector* idSelector = selectorForIdLookup(firstSelector)) {
const AtomicString& idToMatch = idSelector->value();
if (rootNode.treeScope().containsMultipleElementsWithId(idToMatch)) {
const WillBeHeapVector<RawPtrWillBeMember<Element>>& elements = rootNode.treeScope().getAllElementsById(idToMatch);
size_t count = elements.size();
for (size_t i = 0; i < count; ++i) {
Element& element = *elements[i];
if (!(isTreeScopeRoot(rootNode) || element.isDescendantOf(&rootNode)))
continue;
if (selectorMatches(selector, element, rootNode)) {
SelectorQueryTrait::appendElement(output, element);
if (SelectorQueryTrait::shouldOnlyMatchFirstElement)
return;
}
}
return;
}
Element* element = rootNode.treeScope().getElementById(idToMatch);
if (!element || !(isTreeScopeRoot(rootNode) || element->isDescendantOf(&rootNode)))
return;
if (selectorMatches(selector, *element, rootNode))
SelectorQueryTrait::appendElement(output, *element);
return;
}
if (!firstSelector.tagHistory()) {
// Fast path for querySelector*('.foo'), and querySelector*('div').
switch (firstSelector.match()) {
case CSSSelector::Class:
collectElementsByClassName<SelectorQueryTrait>(rootNode, firstSelector.value(), output);
return;
case CSSSelector::Tag:
collectElementsByTagName<SelectorQueryTrait>(rootNode, firstSelector.tagQName(), output);
return;
default:
break; // If we need another fast path, add here.
}
}
findTraverseRootsAndExecute<SelectorQueryTrait>(rootNode, output);
}