LCOV - code coverage report
Current view: top level - dom/xslt/xslt - txGenerateIdFunctionCall.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 43 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 "nsGkAtoms.h"
       7             : #include "txIXPathContext.h"
       8             : #include "txNodeSet.h"
       9             : #include "txXPathTreeWalker.h"
      10             : #include "txXSLTFunctions.h"
      11             : #include "txExecutionState.h"
      12             : 
      13             : /*
      14             :   Implementation of XSLT 1.0 extension function: generate-id
      15             : */
      16             : 
      17             : /**
      18             :  * Creates a new generate-id function call
      19             : **/
      20           0 : GenerateIdFunctionCall::GenerateIdFunctionCall()
      21             : {
      22           0 : }
      23             : 
      24             : /**
      25             :  * Evaluates this Expr based on the given context node and processor state
      26             :  * @param context the context node for evaluation of this Expr
      27             :  * @param ps the ContextState containing the stack information needed
      28             :  * for evaluation
      29             :  * @return the result of the evaluation
      30             :  * @see FunctionCall.h
      31             : **/
      32             : nsresult
      33           0 : GenerateIdFunctionCall::evaluate(txIEvalContext* aContext,
      34             :                                  txAExprResult** aResult)
      35             : {
      36           0 :     *aResult = nullptr;
      37           0 :     if (!requireParams(0, 1, aContext))
      38           0 :         return NS_ERROR_XPATH_BAD_ARGUMENT_COUNT;
      39             : 
      40             :     txExecutionState* es =
      41           0 :         static_cast<txExecutionState*>(aContext->getPrivateContext());
      42           0 :     if (!es) {
      43           0 :         NS_ERROR(
      44             :             "called xslt extension function \"generate-id\" with wrong context");
      45           0 :         return NS_ERROR_UNEXPECTED;
      46             :     }
      47             : 
      48           0 :     nsresult rv = NS_OK;
      49           0 :     if (mParams.IsEmpty()) {
      50             :         StringResult* strRes;
      51           0 :         rv = aContext->recycler()->getStringResult(&strRes);
      52           0 :         NS_ENSURE_SUCCESS(rv, rv);
      53             : 
      54           0 :         txXPathNodeUtils::getXSLTId(aContext->getContextNode(),
      55             :                                     es->getSourceDocument(),
      56           0 :                                     strRes->mValue);
      57             : 
      58           0 :         *aResult = strRes;
      59             : 
      60           0 :         return NS_OK;
      61             :     }
      62             : 
      63           0 :     RefPtr<txNodeSet> nodes;
      64           0 :     rv = evaluateToNodeSet(mParams[0], aContext,
      65           0 :                            getter_AddRefs(nodes));
      66           0 :     NS_ENSURE_SUCCESS(rv, rv);
      67             : 
      68           0 :     if (nodes->isEmpty()) {
      69           0 :         aContext->recycler()->getEmptyStringResult(aResult);
      70             : 
      71           0 :         return NS_OK;
      72             :     }
      73             : 
      74             :     StringResult* strRes;
      75           0 :     rv = aContext->recycler()->getStringResult(&strRes);
      76           0 :     NS_ENSURE_SUCCESS(rv, rv);
      77             : 
      78           0 :     txXPathNodeUtils::getXSLTId(nodes->get(0), es->getSourceDocument(),
      79           0 :                                 strRes->mValue);
      80             : 
      81           0 :     *aResult = strRes;
      82             : 
      83           0 :     return NS_OK;
      84             : }
      85             : 
      86             : Expr::ResultType
      87           0 : GenerateIdFunctionCall::getReturnType()
      88             : {
      89           0 :     return STRING_RESULT;
      90             : }
      91             : 
      92             : bool
      93           0 : GenerateIdFunctionCall::isSensitiveTo(ContextSensitivity aContext)
      94             : {
      95           0 :     if (aContext & PRIVATE_CONTEXT) {
      96           0 :         return true;
      97             :     }
      98             : 
      99           0 :     if (mParams.IsEmpty()) {
     100           0 :         return !!(aContext & NODE_CONTEXT);
     101             :     }
     102             : 
     103           0 :     return argsSensitiveTo(aContext);
     104             : }
     105             : 
     106             : #ifdef TX_TO_STRING
     107             : nsresult
     108           0 : GenerateIdFunctionCall::getNameAtom(nsIAtom** aAtom)
     109             : {
     110           0 :     *aAtom = nsGkAtoms::generateId;
     111           0 :     NS_ADDREF(*aAtom);
     112           0 :     return NS_OK;
     113             : }
     114             : #endif

Generated by: LCOV version 1.13