LCOV - code coverage report
Current view: top level - dom/xslt/xslt - txXSLTEnvironmentFunctionCall.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 78 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 4 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 "txIXPathContext.h"
       7             : #include "nsGkAtoms.h"
       8             : #include "nsError.h"
       9             : #include "txXMLUtils.h"
      10             : #include "txXSLTFunctions.h"
      11             : #include "txExpandedName.h"
      12             : #include "txNamespaceMap.h"
      13             : 
      14             : nsresult
      15           0 : txXSLTEnvironmentFunctionCall::evaluate(txIEvalContext* aContext,
      16             :                                         txAExprResult** aResult)
      17             : {
      18           0 :     *aResult = nullptr;
      19             : 
      20           0 :     if (!requireParams(1, 1, aContext)) {
      21           0 :         return NS_ERROR_XPATH_BAD_ARGUMENT_COUNT;
      22             :     }
      23             : 
      24           0 :     nsAutoString property;
      25           0 :     nsresult rv = mParams[0]->evaluateToString(aContext, property);
      26           0 :     NS_ENSURE_SUCCESS(rv, rv);
      27             : 
      28           0 :     txExpandedName qname;
      29           0 :     rv = qname.init(property, mMappings, mType != FUNCTION_AVAILABLE);
      30           0 :     NS_ENSURE_SUCCESS(rv, rv);
      31             : 
      32           0 :     switch (mType) {
      33             :         case SYSTEM_PROPERTY:
      34             :         {
      35           0 :             if (qname.mNamespaceID == kNameSpaceID_XSLT) {
      36           0 :                 if (qname.mLocalName == nsGkAtoms::version) {
      37           0 :                     return aContext->recycler()->getNumberResult(1.0, aResult);
      38             :                 }
      39           0 :                 if (qname.mLocalName == nsGkAtoms::vendor) {
      40           0 :                     return aContext->recycler()->getStringResult(
      41           0 :                           NS_LITERAL_STRING("Transformiix"), aResult);
      42             :                 }
      43           0 :                 if (qname.mLocalName == nsGkAtoms::vendorUrl) {
      44           0 :                     return aContext->recycler()->getStringResult(
      45           0 :                           NS_LITERAL_STRING("http://www.mozilla.org/projects/xslt/"),
      46           0 :                           aResult);
      47             :                 }
      48             :             }
      49           0 :             aContext->recycler()->getEmptyStringResult(aResult);
      50           0 :             break;
      51             :         }
      52             :         case ELEMENT_AVAILABLE:
      53             :         {
      54           0 :             bool val = qname.mNamespaceID == kNameSpaceID_XSLT &&
      55           0 :                          (qname.mLocalName == nsGkAtoms::applyImports ||
      56           0 :                           qname.mLocalName == nsGkAtoms::applyTemplates ||
      57           0 :                           qname.mLocalName == nsGkAtoms::attribute ||
      58           0 :                           qname.mLocalName == nsGkAtoms::attributeSet ||
      59           0 :                           qname.mLocalName == nsGkAtoms::callTemplate ||
      60           0 :                           qname.mLocalName == nsGkAtoms::choose ||
      61           0 :                           qname.mLocalName == nsGkAtoms::comment ||
      62           0 :                           qname.mLocalName == nsGkAtoms::copy ||
      63           0 :                           qname.mLocalName == nsGkAtoms::copyOf ||
      64           0 :                           qname.mLocalName == nsGkAtoms::decimalFormat ||
      65           0 :                           qname.mLocalName == nsGkAtoms::element ||
      66           0 :                           qname.mLocalName == nsGkAtoms::fallback ||
      67           0 :                           qname.mLocalName == nsGkAtoms::forEach ||
      68           0 :                           qname.mLocalName == nsGkAtoms::_if ||
      69           0 :                           qname.mLocalName == nsGkAtoms::import ||
      70           0 :                           qname.mLocalName == nsGkAtoms::include ||
      71           0 :                           qname.mLocalName == nsGkAtoms::key ||
      72           0 :                           qname.mLocalName == nsGkAtoms::message ||
      73             :                           //qname.mLocalName == nsGkAtoms::namespaceAlias ||
      74           0 :                           qname.mLocalName == nsGkAtoms::number ||
      75           0 :                           qname.mLocalName == nsGkAtoms::otherwise ||
      76           0 :                           qname.mLocalName == nsGkAtoms::output ||
      77           0 :                           qname.mLocalName == nsGkAtoms::param ||
      78           0 :                           qname.mLocalName == nsGkAtoms::preserveSpace ||
      79           0 :                           qname.mLocalName == nsGkAtoms::processingInstruction ||
      80           0 :                           qname.mLocalName == nsGkAtoms::sort ||
      81           0 :                           qname.mLocalName == nsGkAtoms::stripSpace ||
      82           0 :                           qname.mLocalName == nsGkAtoms::stylesheet ||
      83           0 :                           qname.mLocalName == nsGkAtoms::_template ||
      84           0 :                           qname.mLocalName == nsGkAtoms::text ||
      85           0 :                           qname.mLocalName == nsGkAtoms::transform ||
      86           0 :                           qname.mLocalName == nsGkAtoms::valueOf ||
      87           0 :                           qname.mLocalName == nsGkAtoms::variable ||
      88           0 :                           qname.mLocalName == nsGkAtoms::when ||
      89           0 :                           qname.mLocalName == nsGkAtoms::withParam);
      90             : 
      91           0 :             aContext->recycler()->getBoolResult(val, aResult);
      92           0 :             break;
      93             :         }
      94             :         case FUNCTION_AVAILABLE:
      95             :         {
      96             :             extern bool TX_XSLTFunctionAvailable(nsIAtom* aName,
      97             :                                                    int32_t aNameSpaceID);
      98             : 
      99             :             txCoreFunctionCall::eType type;
     100           0 :             bool val = (qname.mNamespaceID == kNameSpaceID_None &&
     101           0 :                           txCoreFunctionCall::getTypeFromAtom(qname.mLocalName,
     102           0 :                                                               type)) ||
     103           0 :                          TX_XSLTFunctionAvailable(qname.mLocalName,
     104           0 :                                                   qname.mNamespaceID);
     105             : 
     106           0 :             aContext->recycler()->getBoolResult(val, aResult);
     107           0 :             break;
     108             :         }
     109             :     }
     110             : 
     111           0 :     return NS_OK;
     112             : }
     113             : 
     114             : Expr::ResultType
     115           0 : txXSLTEnvironmentFunctionCall::getReturnType()
     116             : {
     117           0 :     return mType == SYSTEM_PROPERTY ? (STRING_RESULT | NUMBER_RESULT) :
     118           0 :                                       BOOLEAN_RESULT;
     119             : }
     120             : 
     121             : bool
     122           0 : txXSLTEnvironmentFunctionCall::isSensitiveTo(ContextSensitivity aContext)
     123             : {
     124           0 :     return argsSensitiveTo(aContext);
     125             : }
     126             : 
     127             : #ifdef TX_TO_STRING
     128             : nsresult
     129           0 : txXSLTEnvironmentFunctionCall::getNameAtom(nsIAtom** aAtom)
     130             : {
     131           0 :     *aAtom = mType == SYSTEM_PROPERTY ? nsGkAtoms::systemProperty :
     132           0 :              mType == ELEMENT_AVAILABLE ? nsGkAtoms::elementAvailable :
     133             :              nsGkAtoms::functionAvailable;
     134           0 :     NS_ADDREF(*aAtom);
     135             : 
     136           0 :     return NS_OK;
     137             : }
     138             : #endif

Generated by: LCOV version 1.13