Bug 1935611 - Fix libyuv/libpng link failed for loongarch64. r=glandium,tnikkel,ng
[gecko.git] / dom / xslt / xpath / txNamedAttributeStep.cpp
blob18938e1dd355046f1409048045ebbf6a70cd793e
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/. */
6 #include "nsAtom.h"
7 #include "txIXPathContext.h"
8 #include "txNodeSet.h"
9 #include "txExpr.h"
10 #include "txXPathTreeWalker.h"
12 txNamedAttributeStep::txNamedAttributeStep(int32_t aNsID, nsAtom* aPrefix,
13 nsAtom* aLocalName)
14 : mNamespace(aNsID), mPrefix(aPrefix), mLocalName(aLocalName) {}
16 nsresult txNamedAttributeStep::evaluate(txIEvalContext* aContext,
17 txAExprResult** aResult) {
18 *aResult = nullptr;
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);
31 return NS_OK;
34 TX_IMPL_EXPR_STUBS_0(txNamedAttributeStep, NODESET_RESULT)
36 bool txNamedAttributeStep::isSensitiveTo(ContextSensitivity aContext) {
37 return !!(aContext & NODE_CONTEXT);
40 #ifdef TX_TO_STRING
41 void txNamedAttributeStep::toString(nsAString& aDest) {
42 aDest.Append(char16_t('@'));
43 if (mPrefix) {
44 nsAutoString prefix;
45 mPrefix->ToString(prefix);
46 aDest.Append(prefix);
47 aDest.Append(char16_t(':'));
49 nsAutoString localName;
50 mLocalName->ToString(localName);
51 aDest.Append(localName);
53 #endif