Line data Source code
1 : /* This Source Code Form is subject to the terms of the Mozilla Public
2 : * License, v. 2.0. If a copy of the MPL was not distributed with this
3 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 :
5 : #include "nsGkAtoms.h"
6 : #include "txXSLTFunctions.h"
7 : #include "txExecutionState.h"
8 :
9 : /*
10 : Implementation of XSLT 1.0 extension function: current
11 : */
12 :
13 : /**
14 : * Creates a new current function call
15 : **/
16 0 : CurrentFunctionCall::CurrentFunctionCall()
17 : {
18 0 : }
19 :
20 : /*
21 : * Evaluates this Expr
22 : *
23 : * @return NodeSet containing the context node used for the complete
24 : * Expr or Pattern.
25 : */
26 : nsresult
27 0 : CurrentFunctionCall::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
28 : {
29 0 : *aResult = nullptr;
30 :
31 0 : if (!requireParams(0, 0, aContext))
32 0 : return NS_ERROR_XPATH_BAD_ARGUMENT_COUNT;
33 :
34 : txExecutionState* es =
35 0 : static_cast<txExecutionState*>(aContext->getPrivateContext());
36 0 : if (!es) {
37 0 : NS_ERROR(
38 : "called xslt extension function \"current\" with wrong context");
39 0 : return NS_ERROR_UNEXPECTED;
40 : }
41 0 : return aContext->recycler()->getNodeSet(
42 0 : es->getEvalContext()->getContextNode(), aResult);
43 : }
44 :
45 : Expr::ResultType
46 0 : CurrentFunctionCall::getReturnType()
47 : {
48 0 : return NODESET_RESULT;
49 : }
50 :
51 : bool
52 0 : CurrentFunctionCall::isSensitiveTo(ContextSensitivity aContext)
53 : {
54 0 : return !!(aContext & PRIVATE_CONTEXT);
55 : }
56 :
57 : #ifdef TX_TO_STRING
58 : nsresult
59 0 : CurrentFunctionCall::getNameAtom(nsIAtom** aAtom)
60 : {
61 0 : *aAtom = nsGkAtoms::current;
62 0 : NS_ADDREF(*aAtom);
63 0 : return NS_OK;
64 : }
65 : #endif
|