LCOV - code coverage report
Current view: top level - dom/xslt/xpath - txNodeTypeTest.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 47 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 "txExpr.h"
       7             : #include "nsIAtom.h"
       8             : #include "txIXPathContext.h"
       9             : #include "txXPathTreeWalker.h"
      10             : 
      11             : nsresult
      12           0 : txNodeTypeTest::matches(const txXPathNode& aNode, txIMatchContext* aContext,
      13             :                         bool& aMatched)
      14             : {
      15           0 :     switch (mNodeType) {
      16             :         case COMMENT_TYPE:
      17             :         {
      18           0 :             aMatched = txXPathNodeUtils::isComment(aNode);
      19           0 :             return NS_OK;
      20             :         }
      21             :         case TEXT_TYPE:
      22             :         {
      23           0 :             aMatched = txXPathNodeUtils::isText(aNode);
      24           0 :             if (aMatched) {
      25             :                 bool allowed;
      26           0 :                 nsresult rv = aContext->isStripSpaceAllowed(aNode, allowed);
      27           0 :                 NS_ENSURE_SUCCESS(rv, rv);
      28             : 
      29           0 :                 aMatched = !allowed;
      30             :             }
      31           0 :             return NS_OK;
      32             :         }
      33             :         case PI_TYPE:
      34             :         {
      35           0 :             aMatched = txXPathNodeUtils::isProcessingInstruction(aNode) &&
      36           0 :                        (!mNodeName ||
      37           0 :                         txXPathNodeUtils::localNameEquals(aNode, mNodeName));
      38           0 :             return NS_OK;
      39             :         }
      40             :         case NODE_TYPE:
      41             :         {
      42           0 :             if (txXPathNodeUtils::isText(aNode)) {
      43             :                 bool allowed;
      44           0 :                 nsresult rv = aContext->isStripSpaceAllowed(aNode, allowed);
      45           0 :                 NS_ENSURE_SUCCESS(rv, rv);
      46             : 
      47           0 :                 aMatched = !allowed;
      48             :             } else {
      49           0 :                 aMatched = true;
      50             :             }
      51           0 :             return NS_OK;
      52             :         }
      53             :     }
      54             : 
      55           0 :     NS_NOTREACHED("Didn't deal with all values of the NodeType enum!");
      56             : 
      57           0 :     aMatched = false;
      58           0 :     return NS_OK;
      59             : }
      60             : 
      61             : txNodeTest::NodeTestType
      62           0 : txNodeTypeTest::getType()
      63             : {
      64           0 :     return NODETYPE_TEST;
      65             : }
      66             : 
      67             : /*
      68             :  * Returns the default priority of this txNodeTest
      69             :  */
      70           0 : double txNodeTypeTest::getDefaultPriority()
      71             : {
      72           0 :     return mNodeName ? 0 : -0.5;
      73             : }
      74             : 
      75             : bool
      76           0 : txNodeTypeTest::isSensitiveTo(Expr::ContextSensitivity aContext)
      77             : {
      78           0 :     return !!(aContext & Expr::NODE_CONTEXT);
      79             : }
      80             : 
      81             : #ifdef TX_TO_STRING
      82             : void
      83           0 : txNodeTypeTest::toString(nsAString& aDest)
      84             : {
      85           0 :     switch (mNodeType) {
      86             :         case COMMENT_TYPE:
      87           0 :             aDest.AppendLiteral("comment()");
      88           0 :             break;
      89             :         case TEXT_TYPE:
      90           0 :             aDest.AppendLiteral("text()");
      91           0 :             break;
      92             :         case PI_TYPE:
      93           0 :             aDest.AppendLiteral("processing-instruction(");
      94           0 :             if (mNodeName) {
      95           0 :                 nsAutoString str;
      96           0 :                 mNodeName->ToString(str);
      97           0 :                 aDest.Append(char16_t('\''));
      98           0 :                 aDest.Append(str);
      99           0 :                 aDest.Append(char16_t('\''));
     100             :             }
     101           0 :             aDest.Append(char16_t(')'));
     102           0 :             break;
     103             :         case NODE_TYPE:
     104           0 :             aDest.AppendLiteral("node()");
     105           0 :             break;
     106             :     }
     107           0 : }
     108             : #endif

Generated by: LCOV version 1.13