本文整理汇总了C++中TreeScope::hasElementWithId方法的典型用法代码示例。如果您正苦于以下问题:C++ TreeScope::hasElementWithId方法的具体用法?C++ TreeScope::hasElementWithId怎么用?C++ TreeScope::hasElementWithId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeScope
的用法示例。
在下文中一共展示了TreeScope::hasElementWithId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: namedItem
Node* HTMLCollection::namedItem(const AtomicString& name) const
{
// http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/nameditem.asp
// This method first searches for an object with a matching id
// attribute. If a match is not found, the method then searches for an
// object with a matching name attribute, but only on those elements
// that are allowed a name attribute.
ContainerNode* root = rootContainerNode();
if (name.isEmpty() || !root)
return 0;
if (!overridesItemAfter() && root->isInTreeScope()) {
TreeScope* treeScope = root->treeScope();
Element* candidate = 0;
if (treeScope->hasElementWithId(name.impl())) {
if (!treeScope->containsMultipleElementsWithId(name))
candidate = treeScope->getElementById(name);
} else if (treeScope->hasElementWithName(name.impl())) {
if (!treeScope->containsMultipleElementsWithName(name)) {
candidate = treeScope->getElementByName(name);
if (candidate && type() == DocAll && (!candidate->isHTMLElement() || !nameShouldBeVisibleInDocumentAll(toHTMLElement(candidate))))
candidate = 0;
}
} else
return 0;
if (candidate
&& isMatchingElement(this, candidate)
&& (shouldOnlyIncludeDirectChildren() ? candidate->parentNode() == root : candidate->isDescendantOf(root)))
return candidate;
}
// The pathological case. We need to walk the entire subtree.
updateNameCache();
if (Vector<Element*>* idResults = idCache(name)) {
if (idResults->size())
return idResults->at(0);
}
if (Vector<Element*>* nameResults = nameCache(name)) {
if (nameResults->size())
return nameResults->at(0);
}
return 0;
}