Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/xslt/xpath/txPredicatedNodeTest.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 "txExpr.h"
7
#include "txExprResult.h"
8
#include "txSingleNodeContext.h"
9
10
txPredicatedNodeTest::txPredicatedNodeTest(txNodeTest* aNodeTest,
11
                                           Expr* aPredicate)
12
    : mNodeTest(aNodeTest),
13
      mPredicate(aPredicate)
14
0
{
15
0
    NS_ASSERTION(!mPredicate->isSensitiveTo(Expr::NODESET_CONTEXT),
16
0
                 "predicate must not be context-nodeset-sensitive");
17
0
}
18
19
nsresult
20
txPredicatedNodeTest::matches(const txXPathNode& aNode,
21
                              txIMatchContext* aContext,
22
                              bool& aMatched)
23
0
{
24
0
    nsresult rv = mNodeTest->matches(aNode, aContext, aMatched);
25
0
    NS_ENSURE_SUCCESS(rv, rv);
26
0
27
0
    if (!aMatched) {
28
0
        return NS_OK;
29
0
    }
30
0
31
0
    txSingleNodeContext context(aNode, aContext);
32
0
    RefPtr<txAExprResult> res;
33
0
    rv = mPredicate->evaluate(&context, getter_AddRefs(res));
34
0
    NS_ENSURE_SUCCESS(rv, rv);
35
0
36
0
    aMatched = res->booleanValue();
37
0
    return NS_OK;
38
0
}
39
40
double
41
txPredicatedNodeTest::getDefaultPriority()
42
0
{
43
0
    return 0.5;
44
0
}
45
46
bool
47
txPredicatedNodeTest::isSensitiveTo(Expr::ContextSensitivity aContext)
48
0
{
49
0
    return mNodeTest->isSensitiveTo(aContext) ||
50
0
           mPredicate->isSensitiveTo(aContext);
51
0
}
52
53
#ifdef TX_TO_STRING
54
void
55
txPredicatedNodeTest::toString(nsAString& aDest)
56
{
57
    mNodeTest->toString(aDest);
58
    aDest.Append(char16_t('['));
59
    mPredicate->toString(aDest);
60
    aDest.Append(char16_t(']'));
61
}
62
#endif