Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/xslt/xpath/txNamedAttributeStep.cpp
Line
Count
Source (jump to first uncovered line)
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/. */
5
6
#include "nsAtom.h"
7
#include "txIXPathContext.h"
8
#include "txNodeSet.h"
9
#include "txExpr.h"
10
#include "txXPathTreeWalker.h"
11
12
txNamedAttributeStep::txNamedAttributeStep(int32_t aNsID,
13
                                           nsAtom* aPrefix,
14
                                           nsAtom* aLocalName)
15
    : mNamespace(aNsID),
16
      mPrefix(aPrefix),
17
      mLocalName(aLocalName)
18
0
{
19
0
}
20
21
nsresult
22
txNamedAttributeStep::evaluate(txIEvalContext* aContext,
23
                               txAExprResult** aResult)
24
0
{
25
0
    *aResult = nullptr;
26
0
27
0
    RefPtr<txNodeSet> nodes;
28
0
    nsresult rv = aContext->recycler()->getNodeSet(getter_AddRefs(nodes));
29
0
    NS_ENSURE_SUCCESS(rv, rv);
30
0
31
0
    txXPathTreeWalker walker(aContext->getContextNode());
32
0
    if (walker.moveToNamedAttribute(mLocalName, mNamespace)) {
33
0
        rv = nodes->append(walker.getCurrentPosition());
34
0
        NS_ENSURE_SUCCESS(rv, rv);
35
0
    }
36
0
    NS_ADDREF(*aResult = nodes);
37
0
38
0
    return NS_OK;
39
0
}
40
41
TX_IMPL_EXPR_STUBS_0(txNamedAttributeStep, NODESET_RESULT)
42
43
bool
44
txNamedAttributeStep::isSensitiveTo(ContextSensitivity aContext)
45
0
{
46
0
    return !!(aContext & NODE_CONTEXT);
47
0
}
48
49
#ifdef TX_TO_STRING
50
void
51
txNamedAttributeStep::toString(nsAString& aDest)
52
{
53
    aDest.Append(char16_t('@'));
54
    if (mPrefix) {
55
        nsAutoString prefix;
56
        mPrefix->ToString(prefix);
57
        aDest.Append(prefix);
58
        aDest.Append(char16_t(':'));
59
    }
60
    nsAutoString localName;
61
    mLocalName->ToString(localName);
62
    aDest.Append(localName);
63
}
64
#endif