本文整理汇总了C++中txXPathNode类的典型用法代码示例。如果您正苦于以下问题:C++ txXPathNode类的具体用法?C++ txXPathNode怎么用?C++ txXPathNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了txXPathNode类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: NS_NewAtom
/* static */
already_AddRefed<nsIAtom>
txXPathNodeUtils::getLocalName(const txXPathNode& aNode)
{
if (aNode.isDocument()) {
return nsnull;
}
if (aNode.isContent()) {
if (aNode.mNode->IsElement()) {
nsIAtom* localName = aNode.Content()->Tag();
NS_ADDREF(localName);
return localName;
}
if (aNode.mNode->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) {
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aNode.mNode);
nsAutoString target;
node->GetNodeName(target);
return NS_NewAtom(target);
}
return nsnull;
}
nsIAtom* localName = aNode.Content()->
GetAttrNameAt(aNode.mIndex)->LocalName();
NS_ADDREF(localName);
return localName;
}
开发者ID:almet,项目名称:mozilla-central,代码行数:33,代码来源:txMozillaXPathTreeWalker.cpp
示例2: isText
/* static */
bool
txXPathNodeUtils::isWhitespace(const txXPathNode& aNode)
{
NS_ASSERTION(aNode.isContent() && isText(aNode), "Wrong type!");
return aNode.Content()->TextIsOnlyWhitespace();
}
开发者ID:almet,项目名称:mozilla-central,代码行数:8,代码来源:txMozillaXPathTreeWalker.cpp
示例3:
/* static */
void
txXPathNodeUtils::getNodeName(const txXPathNode& aNode, nsAString& aName)
{
if (aNode.isDocument()) {
aName.Truncate();
return;
}
if (aNode.isContent()) {
// Elements and PIs have a name
if (aNode.mNode->IsElement() ||
aNode.mNode->NodeType() ==
nsIDOMNode::PROCESSING_INSTRUCTION_NODE) {
aName = aNode.Content()->NodeName();
return;
}
aName.Truncate();
return;
}
aNode.Content()->GetAttrNameAt(aNode.mIndex)->GetQualifiedName(aName);
}
开发者ID:almet,项目名称:mozilla-central,代码行数:26,代码来源:txMozillaXPathTreeWalker.cpp
示例4: NS_Atomize
/* static */
already_AddRefed<nsAtom>
txXPathNodeUtils::getLocalName(const txXPathNode& aNode)
{
if (aNode.isDocument()) {
return nullptr;
}
if (aNode.isContent()) {
if (aNode.mNode->IsElement()) {
RefPtr<nsAtom> localName =
aNode.Content()->NodeInfo()->NameAtom();
return localName.forget();
}
if (aNode.mNode->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) {
return NS_Atomize(aNode.mNode->NodeName());
}
return nullptr;
}
// This is an attribute node, so we necessarily come from an element.
RefPtr<nsAtom> localName =
aNode.Content()->AsElement()->GetAttrNameAt(aNode.mIndex)->LocalName();
return localName.forget();
}
开发者ID:luke-chang,项目名称:gecko-1,代码行数:28,代码来源:txMozillaXPathTreeWalker.cpp
示例5: do_QueryInterface
/* static */
PRUint16
txXPathNodeUtils::getNodeType(const txXPathNode& aNode)
{
if (aNode.isDocument()) {
return txXPathNodeType::DOCUMENT_NODE;
}
if (aNode.isContent()) {
PRUint16 type;
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aNode.mNode);
node->GetNodeType(&type);
return type;
}
return txXPathNodeType::ATTRIBUTE_NODE;
}
开发者ID:hungry-r,项目名称:mozilla-central,代码行数:18,代码来源:txMozillaXPathTreeWalker.cpp
示例6: CallQueryInterface
/* static */
nsresult
txXPathNativeNode::getNode(const txXPathNode& aNode, nsIDOMNode** aResult)
{
if (!aNode.isAttribute()) {
return CallQueryInterface(aNode.mNode, aResult);
}
const nsAttrName* name = aNode.Content()->GetAttrNameAt(aNode.mIndex);
nsAutoString namespaceURI;
nsContentUtils::NameSpaceManager()->GetNameSpaceURI(name->NamespaceID(), namespaceURI);
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aNode.mNode);
nsCOMPtr<nsIDOMAttr> attr;
element->GetAttributeNodeNS(namespaceURI,
nsDependentAtomString(name->LocalName()),
getter_AddRefs(attr));
return CallQueryInterface(attr, aResult);
}
开发者ID:almet,项目名称:mozilla-central,代码行数:21,代码来源:txMozillaXPathTreeWalker.cpp
示例7:
/* static */
nsresult
txXPathNodeUtils::getXSLTId(const txXPathNode& aNode,
nsAString& aResult)
{
if (!aNode.isAttribute()) {
CopyASCIItoUTF16(nsPrintfCString(kFmtSize, gPrintfFmt, aNode.mNode),
aResult);
}
else {
CopyASCIItoUTF16(nsPrintfCString(kFmtSizeAttr, gPrintfFmtAttr,
aNode.mNode, aNode.mIndex), aResult);
}
return NS_OK;
}
开发者ID:MozillaOnline,项目名称:gecko-dev,代码行数:16,代码来源:txMozillaXPathTreeWalker.cpp
示例8: ToUpperCase
/* static */
void
txXPathNodeUtils::getNodeName(const txXPathNode& aNode, nsAString& aName)
{
if (aNode.isDocument()) {
aName.Truncate();
return;
}
if (aNode.isContent()) {
if (aNode.mNode->IsNodeOfType(nsINode::eELEMENT)) {
nsINodeInfo* nodeInfo = aNode.Content()->NodeInfo();
nodeInfo->GetQualifiedName(aName);
// Check for html
if (nodeInfo->NamespaceEquals(kNameSpaceID_None) &&
aNode.Content()->IsNodeOfType(nsINode::eHTML)) {
ToUpperCase(aName);
}
return;
}
if (aNode.mNode->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) {
// PIs don't have a nodeinfo but do have a name
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aNode.mNode);
node->GetNodeName(aName);
return;
}
aName.Truncate();
return;
}
aNode.Content()->GetAttrNameAt(aNode.mIndex)->GetQualifiedName(aName);
// Check for html
if (aNode.Content()->NodeInfo()->NamespaceEquals(kNameSpaceID_None) &&
aNode.Content()->IsNodeOfType(nsINode::eHTML)) {
ToUpperCase(aName);
}
}
开发者ID:EdgarChen,项目名称:mozilla-cvs-history,代码行数:45,代码来源:txMozillaXPathTreeWalker.cpp
示例9: ToString
/* static */
void
txXPathNodeUtils::getLocalName(const txXPathNode& aNode, nsAString& aLocalName)
{
if (aNode.isDocument()) {
aLocalName.Truncate();
return;
}
if (aNode.isContent()) {
if (aNode.mNode->IsElement()) {
mozilla::dom::NodeInfo* nodeInfo = aNode.Content()->NodeInfo();
nodeInfo->GetName(aLocalName);
return;
}
if (aNode.mNode->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) {
// PIs don't have a nodeinfo but do have a name
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aNode.mNode);
node->GetNodeName(aLocalName);
return;
}
aLocalName.Truncate();
return;
}
aNode.Content()->GetAttrNameAt(aNode.mIndex)->LocalName()->
ToString(aLocalName);
// Check for html
if (aNode.Content()->NodeInfo()->NamespaceEquals(kNameSpaceID_None) &&
aNode.Content()->IsHTMLElement()) {
nsContentUtils::ASCIIToUpper(aLocalName);
}
}
开发者ID:CuriousLearner,项目名称:gecko-dev,代码行数:39,代码来源:txMozillaXPathTreeWalker.cpp
示例10: ToString
/* static */
void
txXPathNodeUtils::getLocalName(const txXPathNode& aNode, nsAString& aLocalName)
{
if (aNode.isDocument()) {
aLocalName.Truncate();
return;
}
if (aNode.isContent()) {
if (aNode.mNode->IsElement()) {
mozilla::dom::NodeInfo* nodeInfo = aNode.Content()->NodeInfo();
nodeInfo->GetName(aLocalName);
return;
}
if (aNode.mNode->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) {
// PIs don't have a nodeinfo but do have a name
// XXXbz Not actually true, but this function looks like it wants
// different things from elements and PIs for "local name"...
aLocalName = aNode.mNode->NodeName();
return;
}
aLocalName.Truncate();
return;
}
aNode.Content()->AsElement()->GetAttrNameAt(aNode.mIndex)->LocalName()->
ToString(aLocalName);
// Check for html
if (aNode.Content()->NodeInfo()->NamespaceEquals(kNameSpaceID_None) &&
aNode.Content()->IsHTMLElement()) {
nsContentUtils::ASCIIToUpper(aLocalName);
}
}
开发者ID:luke-chang,项目名称:gecko-1,代码行数:39,代码来源:txMozillaXPathTreeWalker.cpp
示例11: while
/* static */
PRIntn
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->GetNodeParent();
otherParent = otherNode->GetNodeParent();
// 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->GetNodeParent();
}
while (otherNode) {
otherParents.AppendElement(otherNode);
otherNode = otherNode->GetNodeParent();
}
// Walk back down along the parent-chains until we find where they split.
PRInt32 total = parents.Length() - 1;
PRInt32 otherTotal = otherParents.Length() - 1;
NS_ASSERTION(total != otherTotal, "Can't have same number of parents");
PRInt32 lastIndex = NS_MIN(total, otherTotal);
PRInt32 i;
parent = nsnull;
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;
}
PRInt32 index = parent->IndexOf(node);
PRInt32 otherIndex = parent->IndexOf(otherNode);
NS_ASSERTION(index != otherIndex && index >= 0 && otherIndex >= 0,
"invalid index in compareTreePosition");
return index < otherIndex ? -1 : 1;
}
parent = node;
}
//.........这里部分代码省略.........
开发者ID:almet,项目名称:mozilla-central,代码行数:101,代码来源:txMozillaXPathTreeWalker.cpp
注:本文中的txXPathNode类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论