本文整理汇总了C++中txXPathNode::isContent方法的典型用法代码示例。如果您正苦于以下问题:C++ txXPathNode::isContent方法的具体用法?C++ txXPathNode::isContent怎么用?C++ txXPathNode::isContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类txXPathNode
的用法示例。
在下文中一共展示了txXPathNode::isContent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
/* static */
int
txXPathNodeUtils::comparePosition(const txXPathNode& aNode,
const txXPathNode& aOtherNode)
{
// First check for equal nodes or attribute-nodes on the same element.
if (aNode.mNode == aOtherNode.mNode) {
if (aNode.mIndex == aOtherNode.mIndex) {
return 0;
}
NS_ASSERTION(!aNode.isDocument() && !aOtherNode.isDocument(),
"documents should always have a set index");
if (aNode.isContent() || (!aOtherNode.isContent() &&
aNode.mIndex < aOtherNode.mIndex)) {
return -1;
}
return 1;
}
// Get document for both nodes.
nsIDocument* document = aNode.mNode->GetCurrentDoc();
nsIDocument* otherDocument = aOtherNode.mNode->GetCurrentDoc();
// If the nodes have different current documents, compare the document
// pointers.
if (document != otherDocument) {
return document < otherDocument ? -1 : 1;
}
// Now either both nodes are in orphan trees, or they are both in the
// same tree.
// Get parents up the tree.
nsAutoTArray<nsINode*, 8> parents, otherParents;
nsINode* node = aNode.mNode;
nsINode* otherNode = aOtherNode.mNode;
nsINode* parent, *otherParent;
while (node && otherNode) {
parent = node->GetParentNode();
otherParent = otherNode->GetParentNode();
// Hopefully this is a common case.
if (parent == otherParent) {
if (!parent) {
// Both node and otherNode are root nodes in respective orphan
// tree.
return node < otherNode ? -1 : 1;
}
return parent->IndexOf(node) < parent->IndexOf(otherNode) ?
-1 : 1;
}
parents.AppendElement(node);
otherParents.AppendElement(otherNode);
node = parent;
otherNode = otherParent;
}
while (node) {
parents.AppendElement(node);
node = node->GetParentNode();
}
while (otherNode) {
otherParents.AppendElement(otherNode);
otherNode = otherNode->GetParentNode();
}
// Walk back down along the parent-chains until we find where they split.
int32_t total = parents.Length() - 1;
int32_t otherTotal = otherParents.Length() - 1;
NS_ASSERTION(total != otherTotal, "Can't have same number of parents");
int32_t lastIndex = std::min(total, otherTotal);
int32_t i;
parent = nullptr;
for (i = 0; i <= lastIndex; ++i) {
node = parents.ElementAt(total - i);
otherNode = otherParents.ElementAt(otherTotal - i);
if (node != otherNode) {
if (!parent) {
// The two nodes are in different orphan subtrees.
NS_ASSERTION(i == 0, "this shouldn't happen");
return node < otherNode ? -1 : 1;
}
int32_t index = parent->IndexOf(node);
int32_t otherIndex = parent->IndexOf(otherNode);
NS_ASSERTION(index != otherIndex && index >= 0 && otherIndex >= 0,
"invalid index in compareTreePosition");
return index < otherIndex ? -1 : 1;
}
parent = node;
}
//.........这里部分代码省略.........