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/. */
8 #include "txIXPathContext.h"
9 #include "txXPathTreeWalker.h"
11 bool txNodeTypeTest::matches(const txXPathNode
& aNode
,
12 txIMatchContext
* aContext
)
17 return txXPathNodeUtils::isComment(aNode
);
21 return txXPathNodeUtils::isText(aNode
) &&
22 !aContext
->isStripSpaceAllowed(aNode
);
26 return txXPathNodeUtils::isProcessingInstruction(aNode
) &&
28 txXPathNodeUtils::localNameEquals(aNode
, mNodeName
));
32 return !txXPathNodeUtils::isText(aNode
) ||
33 !aContext
->isStripSpaceAllowed(aNode
);
39 txNodeTest::NodeTestType
40 txNodeTypeTest::getType()
46 * Returns the default priority of this txNodeTest
48 double txNodeTypeTest::getDefaultPriority()
50 return mNodeName
? 0 : -0.5;
54 txNodeTypeTest::isSensitiveTo(Expr::ContextSensitivity aContext
)
56 return !!(aContext
& Expr::NODE_CONTEXT
);
61 txNodeTypeTest::toString(nsAString
& aDest
)
65 aDest
.AppendLiteral("comment()");
68 aDest
.AppendLiteral("text()");
71 aDest
.AppendLiteral("processing-instruction(");
74 mNodeName
->ToString(str
);
75 aDest
.Append(char16_t('\''));
77 aDest
.Append(char16_t('\''));
79 aDest
.Append(char16_t(')'));
82 aDest
.AppendLiteral("node()");