Bumping manifests a=b2g-bump
[gecko.git] / dom / xslt / xpath / txNodeTypeTest.cpp
blob650a1ae5fefc43889c7be61d7fa80e282b59fb96
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "txExpr.h"
7 #include "nsIAtom.h"
8 #include "txIXPathContext.h"
9 #include "txXPathTreeWalker.h"
11 bool txNodeTypeTest::matches(const txXPathNode& aNode,
12 txIMatchContext* aContext)
14 switch (mNodeType) {
15 case COMMENT_TYPE:
17 return txXPathNodeUtils::isComment(aNode);
19 case TEXT_TYPE:
21 return txXPathNodeUtils::isText(aNode) &&
22 !aContext->isStripSpaceAllowed(aNode);
24 case PI_TYPE:
26 return txXPathNodeUtils::isProcessingInstruction(aNode) &&
27 (!mNodeName ||
28 txXPathNodeUtils::localNameEquals(aNode, mNodeName));
30 case NODE_TYPE:
32 return !txXPathNodeUtils::isText(aNode) ||
33 !aContext->isStripSpaceAllowed(aNode);
36 return true;
39 txNodeTest::NodeTestType
40 txNodeTypeTest::getType()
42 return NODETYPE_TEST;
46 * Returns the default priority of this txNodeTest
48 double txNodeTypeTest::getDefaultPriority()
50 return mNodeName ? 0 : -0.5;
53 bool
54 txNodeTypeTest::isSensitiveTo(Expr::ContextSensitivity aContext)
56 return !!(aContext & Expr::NODE_CONTEXT);
59 #ifdef TX_TO_STRING
60 void
61 txNodeTypeTest::toString(nsAString& aDest)
63 switch (mNodeType) {
64 case COMMENT_TYPE:
65 aDest.AppendLiteral("comment()");
66 break;
67 case TEXT_TYPE:
68 aDest.AppendLiteral("text()");
69 break;
70 case PI_TYPE:
71 aDest.AppendLiteral("processing-instruction(");
72 if (mNodeName) {
73 nsAutoString str;
74 mNodeName->ToString(str);
75 aDest.Append(char16_t('\''));
76 aDest.Append(str);
77 aDest.Append(char16_t('\''));
79 aDest.Append(char16_t(')'));
80 break;
81 case NODE_TYPE:
82 aDest.AppendLiteral("node()");
83 break;
86 #endif