dom/xslt/xslt/txCurrentFunctionCall.cpp
author Gerald Squelart <gsquelart@mozilla.com>
Fri, 11 Nov 2016 11:25:52 +1100
changeset 367314 680467d99ed63d1b3a37e5c61d3c4302f5181418
parent 179346 67ff9392766b53c51bb876b5f74e5e6602347668
child 418830 6a629adbb62a299d7208373d1c6f375149d2afdb
permissions -rw-r--r--
Bug 1316524 - Use 'media.wmf.skip-blacklist' to set some gfxVars - r=mattwoodrow Reversing bug 1313343, as MediaPrefs are not available from the UI process. Instead media.wmf.skip-blacklist is used when setting D3D-blacklisting gfxVars, leaving them empty if we want to skip these blacklists. MozReview-Commit-ID: JYED4ovC0jq

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsGkAtoms.h"
#include "txXSLTFunctions.h"
#include "txExecutionState.h"

/*
  Implementation of XSLT 1.0 extension function: current
*/

/**
 * Creates a new current function call
**/
CurrentFunctionCall::CurrentFunctionCall() 
{
}

/*
 * Evaluates this Expr
 *
 * @return NodeSet containing the context node used for the complete
 * Expr or Pattern.
 */
nsresult
CurrentFunctionCall::evaluate(txIEvalContext* aContext, txAExprResult** aResult)
{
    *aResult = nullptr;

    if (!requireParams(0, 0, aContext))
        return NS_ERROR_XPATH_BAD_ARGUMENT_COUNT;

    txExecutionState* es = 
        static_cast<txExecutionState*>(aContext->getPrivateContext());
    if (!es) {
        NS_ERROR(
            "called xslt extension function \"current\" with wrong context");
        return NS_ERROR_UNEXPECTED;
    }
    return aContext->recycler()->getNodeSet(
           es->getEvalContext()->getContextNode(), aResult);
}

Expr::ResultType
CurrentFunctionCall::getReturnType()
{
    return NODESET_RESULT;
}

bool
CurrentFunctionCall::isSensitiveTo(ContextSensitivity aContext)
{
    return !!(aContext & PRIVATE_CONTEXT);
}

#ifdef TX_TO_STRING
nsresult
CurrentFunctionCall::getNameAtom(nsIAtom** aAtom)
{
    *aAtom = nsGkAtoms::current;
    NS_ADDREF(*aAtom);
    return NS_OK;
}
#endif