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/. */
7 #include "txIXPathContext.h"
10 #include "txXPathTreeWalker.h"
12 txNamedAttributeStep::txNamedAttributeStep(int32_t aNsID
, nsAtom
* aPrefix
,
14 : mNamespace(aNsID
), mPrefix(aPrefix
), mLocalName(aLocalName
) {}
16 nsresult
txNamedAttributeStep::evaluate(txIEvalContext
* aContext
,
17 txAExprResult
** aResult
) {
20 RefPtr
<txNodeSet
> nodes
;
21 nsresult rv
= aContext
->recycler()->getNodeSet(getter_AddRefs(nodes
));
22 NS_ENSURE_SUCCESS(rv
, rv
);
24 txXPathTreeWalker
walker(aContext
->getContextNode());
25 if (walker
.moveToNamedAttribute(mLocalName
, mNamespace
)) {
26 rv
= nodes
->append(walker
.getCurrentPosition());
27 NS_ENSURE_SUCCESS(rv
, rv
);
29 NS_ADDREF(*aResult
= nodes
);
34 TX_IMPL_EXPR_STUBS_0(txNamedAttributeStep
, NODESET_RESULT
)
36 bool txNamedAttributeStep::isSensitiveTo(ContextSensitivity aContext
) {
37 return !!(aContext
& NODE_CONTEXT
);
41 void txNamedAttributeStep::toString(nsAString
& aDest
) {
42 aDest
.Append(char16_t('@'));
45 mPrefix
->ToString(prefix
);
47 aDest
.Append(char16_t(':'));
49 nsAutoString localName
;
50 mLocalName
->ToString(localName
);
51 aDest
.Append(localName
);