LCOV - app.info - content/xslt/src/xpath/txNameTest.cpp

LCOV - code coverage report
| Current view: | directory - content/xslt/src/xpath - txNameTest.cpp (source / functions) |  | Found | Hit | Coverage |
| Test: | app.info | Lines: | 41 | 0 | 0.0 %
| Date: | 2012-06-02 | Functions: | 6 | 0 | 0.0 %

           1                 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
           2                 : /* ***** BEGIN LICENSE BLOCK *****
           3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
           4                 :  *
           5                 :  * The contents of this file are subject to the Mozilla Public License Version
           6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
           7                 :  * the License. You may obtain a copy of the License at
           8                 :  * http://www.mozilla.org/MPL/
           9                 :  *
          10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
          11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
          12                 :  * for the specific language governing rights and limitations under the
          13                 :  * License.
          14                 :  *
          15                 :  * The Original Code is TransforMiiX XSLT processor code.
          16                 :  *
          17                 :  * The Initial Developer of the Original Code is
          18                 :  * The MITRE Corporation.
          19                 :  * Portions created by the Initial Developer are Copyright (C) 1999
          20                 :  * the Initial Developer. All Rights Reserved.
          21                 :  *
          22                 :  * Contributor(s):
          23                 :  *   Keith Visco <kvisco@ziplink.net> (Original Author)
          24                 :  *
          25                 :  * Alternatively, the contents of this file may be used under the terms of
          26                 :  * either the GNU General Public License Version 2 or later (the "GPL"), or
          27                 :  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
          28                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
          29                 :  * of those above. If you wish to allow use of your version of this file only
          30                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
          31                 :  * use your version of this file under the terms of the MPL, indicate your
          32                 :  * decision by deleting the provisions above and replace them with the notice
          33                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
          34                 :  * the provisions above, a recipient may use your version of this file under
          35                 :  * the terms of any one of the MPL, the GPL or the LGPL.
          36                 :  *
          37                 :  * ***** END LICENSE BLOCK ***** */
          38                 :
          39                 : #include "txExpr.h"
          40                 : #include "nsIAtom.h"
          41                 : #include "nsGkAtoms.h"
          42                 : #include "txXPathTreeWalker.h"
          43                 : #include "txIXPathContext.h"
          44                 :
          45               0 : txNameTest::txNameTest(nsIAtom* aPrefix, nsIAtom* aLocalName, PRInt32 aNSID,
          46                 :                        PRUint16 aNodeType)
          47                 :     :mPrefix(aPrefix), mLocalName(aLocalName), mNamespace(aNSID),
          48               0 :      mNodeType(aNodeType)
          49                 : {
          50               0 :     if (aPrefix == nsGkAtoms::_empty)
          51               0 :         mPrefix = 0;
          52               0 :     NS_ASSERTION(aLocalName, "txNameTest without a local name?");
          53               0 :     NS_ASSERTION(aNodeType == txXPathNodeType::DOCUMENT_NODE ||
          54                 :                  aNodeType == txXPathNodeType::ELEMENT_NODE ||
          55                 :                  aNodeType == txXPathNodeType::ATTRIBUTE_NODE,
          56                 :                  "Go fix txNameTest::matches");
          57               0 : }
          58                 :
          59               0 : bool txNameTest::matches(const txXPathNode& aNode, txIMatchContext* aContext)
          60                 : {
          61               0 :     if ((mNodeType == txXPathNodeType::ELEMENT_NODE &&
          62               0 :          !txXPathNodeUtils::isElement(aNode)) ||
          63                 :         (mNodeType == txXPathNodeType::ATTRIBUTE_NODE &&
          64               0 :          !txXPathNodeUtils::isAttribute(aNode)) ||
          65                 :         (mNodeType == txXPathNodeType::DOCUMENT_NODE &&
          66               0 :          !txXPathNodeUtils::isRoot(aNode))) {
          67               0 :         return false;
          68                 :     }
          69                 :
          70                 :     // Totally wild?
          71               0 :     if (mLocalName == nsGkAtoms::_asterix && !mPrefix)
          72               0 :         return true;
          73                 :
          74                 :     // Compare namespaces
          75               0 :     if (mNamespace != txXPathNodeUtils::getNamespaceID(aNode)
          76                 :         && !(mNamespace == kNameSpaceID_None &&
          77               0 :              txXPathNodeUtils::isHTMLElementInHTMLDocument(aNode))
          78                 :        )
          79               0 :         return false;
          80                 :
          81                 :     // Name wild?
          82               0 :     if (mLocalName == nsGkAtoms::_asterix)
          83               0 :         return true;
          84                 :
          85                 :     // Compare local-names
          86               0 :     return txXPathNodeUtils::localNameEquals(aNode, mLocalName);
          87                 : }
          88                 :
          89                 : /*
          90                 :  * Returns the default priority of this txNodeTest
          91                 :  */
          92               0 : double txNameTest::getDefaultPriority()
          93                 : {
          94               0 :     if (mLocalName == nsGkAtoms::_asterix) {
          95               0 :         if (!mPrefix)
          96               0 :             return -0.5;
          97               0 :         return -0.25;
          98                 :     }
          99               0 :     return 0;
         100                 : }
         101                 :
         102                 : txNodeTest::NodeTestType
         103               0 : txNameTest::getType()
         104                 : {
         105               0 :     return NAME_TEST;
         106                 : }
         107                 :
         108                 : bool
         109               0 : txNameTest::isSensitiveTo(Expr::ContextSensitivity aContext)
         110                 : {
         111               0 :     return !!(aContext & Expr::NODE_CONTEXT);
         112                 : }
         113                 :
         114                 : #ifdef TX_TO_STRING
         115                 : void
         116               0 : txNameTest::toString(nsAString& aDest)
         117                 : {
         118               0 :     if (mPrefix) {
         119               0 :         nsAutoString prefix;
         120               0 :         mPrefix->ToString(prefix);
         121               0 :         aDest.Append(prefix);
         122               0 :         aDest.Append(PRUnichar(':'));
         123                 :     }
         124               0 :     nsAutoString localName;
         125               0 :     mLocalName->ToString(localName);
         126               0 :     aDest.Append(localName);
         127               0 : }
         128                 : #endif

Generated by: LCOV version 1.7