1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
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 nsresult
txNodeTypeTest::matches(const txXPathNode
& aNode
,
12 txIMatchContext
* aContext
, bool& aMatched
) {
15 aMatched
= txXPathNodeUtils::isComment(aNode
);
19 aMatched
= txXPathNodeUtils::isText(aNode
);
22 nsresult rv
= aContext
->isStripSpaceAllowed(aNode
, allowed
);
23 NS_ENSURE_SUCCESS(rv
, rv
);
31 txXPathNodeUtils::isProcessingInstruction(aNode
) &&
32 (!mNodeName
|| txXPathNodeUtils::localNameEquals(aNode
, mNodeName
));
36 if (txXPathNodeUtils::isText(aNode
)) {
38 nsresult rv
= aContext
->isStripSpaceAllowed(aNode
, allowed
);
39 NS_ENSURE_SUCCESS(rv
, rv
);
49 MOZ_ASSERT_UNREACHABLE("Didn't deal with all values of the NodeType enum!");
55 txNodeTest::NodeTestType
txNodeTypeTest::getType() { return NODETYPE_TEST
; }
58 * Returns the default priority of this txNodeTest
60 double txNodeTypeTest::getDefaultPriority() { return mNodeName
? 0 : -0.5; }
62 bool txNodeTypeTest::isSensitiveTo(Expr::ContextSensitivity aContext
) {
63 return !!(aContext
& Expr::NODE_CONTEXT
);
67 void txNodeTypeTest::toString(nsAString
& aDest
) {
70 aDest
.AppendLiteral("comment()");
73 aDest
.AppendLiteral("text()");
76 aDest
.AppendLiteral("processing-instruction(");
79 mNodeName
->ToString(str
);
80 aDest
.Append(char16_t('\''));
82 aDest
.Append(char16_t('\''));
84 aDest
.Append(char16_t(')'));
87 aDest
.AppendLiteral("node()");