|
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 "txNodeSet.h" |
|
8 #include "txIXPathContext.h" |
|
9 #include "txXPathTreeWalker.h" |
|
10 |
|
11 /** |
|
12 * Evaluates this Expr based on the given context node and processor state |
|
13 * @param context the context node for evaluation of this Expr |
|
14 * @param ps the ContextState containing the stack information needed |
|
15 * for evaluation |
|
16 * @return the result of the evaluation |
|
17 **/ |
|
18 nsresult |
|
19 RootExpr::evaluate(txIEvalContext* aContext, txAExprResult** aResult) |
|
20 { |
|
21 txXPathTreeWalker walker(aContext->getContextNode()); |
|
22 walker.moveToRoot(); |
|
23 |
|
24 return aContext->recycler()->getNodeSet(walker.getCurrentPosition(), |
|
25 aResult); |
|
26 } |
|
27 |
|
28 TX_IMPL_EXPR_STUBS_0(RootExpr, NODESET_RESULT) |
|
29 |
|
30 bool |
|
31 RootExpr::isSensitiveTo(ContextSensitivity aContext) |
|
32 { |
|
33 return !!(aContext & NODE_CONTEXT); |
|
34 } |
|
35 |
|
36 #ifdef TX_TO_STRING |
|
37 void |
|
38 RootExpr::toString(nsAString& dest) |
|
39 { |
|
40 if (mSerialize) |
|
41 dest.Append(char16_t('/')); |
|
42 } |
|
43 #endif |