LCOV - code coverage report
Current view: top level - dom/base - NodeInfoInlines.h (source / functions) Hit Total Coverage
Test: output.info Lines: 15 18 83.3 %
Date: 2017-07-14 16:53:18 Functions: 3 4 75.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
       3             : /* This Source Code Form is subject to the terms of the Mozilla Public
       4             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #ifndef mozilla_dom_NodeInfoInlines_h___
       8             : #define mozilla_dom_NodeInfoInlines_h___
       9             : 
      10             : #include "nsIAtom.h"
      11             : #include "nsIDOMNode.h"
      12             : #include "nsDOMString.h"
      13             : #include "nsGkAtoms.h"
      14             : 
      15             : namespace mozilla {
      16             : namespace dom {
      17             : 
      18             : inline bool
      19           1 : NodeInfo::Equals(NodeInfo *aNodeInfo) const
      20             : {
      21           1 :   return aNodeInfo == this || aNodeInfo->Equals(mInner.mName, mInner.mPrefix,
      22           1 :                                                 mInner.mNamespaceID);
      23             : }
      24             : 
      25             : inline bool
      26           0 : NodeInfo::NameAndNamespaceEquals(NodeInfo *aNodeInfo) const
      27             : {
      28           0 :   return aNodeInfo == this || aNodeInfo->Equals(mInner.mName,
      29           0 :                                                 mInner.mNamespaceID);
      30             : }
      31             : 
      32             : inline bool
      33             : NodeInfo::Equals(const nsAString& aName) const
      34             : {
      35             :   return mInner.mName->Equals(aName);
      36             : }
      37             : 
      38             : inline bool
      39             : NodeInfo::Equals(const nsAString& aName, const nsAString& aPrefix) const
      40             : {
      41             :   return mInner.mName->Equals(aName) &&
      42             :     (mInner.mPrefix ? mInner.mPrefix->Equals(aPrefix) : aPrefix.IsEmpty());
      43             : }
      44             : 
      45             : inline bool
      46             : NodeInfo::Equals(const nsAString& aName, int32_t aNamespaceID) const
      47             : {
      48             :   return mInner.mNamespaceID == aNamespaceID &&
      49             :     mInner.mName->Equals(aName);
      50             : }
      51             : 
      52             : inline bool
      53             : NodeInfo::Equals(const nsAString& aName, const nsAString& aPrefix,
      54             :                  int32_t aNamespaceID) const
      55             : {
      56             :   return mInner.mName->Equals(aName) && mInner.mNamespaceID == aNamespaceID &&
      57             :     (mInner.mPrefix ? mInner.mPrefix->Equals(aPrefix) : aPrefix.IsEmpty());
      58             : }
      59             : 
      60             : inline bool
      61           5 : NodeInfo::QualifiedNameEquals(nsIAtom* aNameAtom) const
      62             : {
      63           5 :   MOZ_ASSERT(aNameAtom, "Must have name atom");
      64           5 :   if (!GetPrefixAtom()) {
      65           1 :     return Equals(aNameAtom);
      66             :   }
      67             : 
      68           4 :   return aNameAtom->Equals(mQualifiedName);
      69             : }
      70             : 
      71             : } // namespace dom
      72             : } // namespace mozilla
      73             : 
      74             : inline void
      75        5415 : CheckValidNodeInfo(uint16_t aNodeType, nsIAtom *aName, int32_t aNamespaceID,
      76             :                    nsIAtom* aExtraName)
      77             : {
      78        5415 :   MOZ_ASSERT(aNodeType == nsIDOMNode::ELEMENT_NODE ||
      79             :              aNodeType == nsIDOMNode::ATTRIBUTE_NODE ||
      80             :              aNodeType == nsIDOMNode::TEXT_NODE ||
      81             :              aNodeType == nsIDOMNode::CDATA_SECTION_NODE ||
      82             :              aNodeType == nsIDOMNode::PROCESSING_INSTRUCTION_NODE ||
      83             :              aNodeType == nsIDOMNode::COMMENT_NODE ||
      84             :              aNodeType == nsIDOMNode::DOCUMENT_NODE ||
      85             :              aNodeType == nsIDOMNode::DOCUMENT_TYPE_NODE ||
      86             :              aNodeType == nsIDOMNode::DOCUMENT_FRAGMENT_NODE ||
      87             :              aNodeType == UINT16_MAX,
      88             :              "Invalid nodeType");
      89        5415 :   MOZ_ASSERT((aNodeType == nsIDOMNode::PROCESSING_INSTRUCTION_NODE ||
      90             :               aNodeType == nsIDOMNode::DOCUMENT_TYPE_NODE) ==
      91             :              !!aExtraName,
      92             :              "Supply aExtraName for and only for PIs and doctypes");
      93        5415 :   MOZ_ASSERT(aNodeType == nsIDOMNode::ELEMENT_NODE ||
      94             :              aNodeType == nsIDOMNode::ATTRIBUTE_NODE ||
      95             :              aNodeType == UINT16_MAX ||
      96             :              aNamespaceID == kNameSpaceID_None,
      97             :              "Only attributes and elements can be in a namespace");
      98        5415 :   MOZ_ASSERT(aName && aName != nsGkAtoms::_empty, "Invalid localName");
      99        5415 :   MOZ_ASSERT(((aNodeType == nsIDOMNode::TEXT_NODE) ==
     100             :               (aName == nsGkAtoms::textTagName)) &&
     101             :              ((aNodeType == nsIDOMNode::CDATA_SECTION_NODE) ==
     102             :               (aName == nsGkAtoms::cdataTagName)) &&
     103             :              ((aNodeType == nsIDOMNode::COMMENT_NODE) ==
     104             :               (aName == nsGkAtoms::commentTagName)) &&
     105             :              ((aNodeType == nsIDOMNode::DOCUMENT_NODE) ==
     106             :               (aName == nsGkAtoms::documentNodeName)) &&
     107             :              ((aNodeType == nsIDOMNode::DOCUMENT_FRAGMENT_NODE) ==
     108             :               (aName == nsGkAtoms::documentFragmentNodeName)) &&
     109             :              ((aNodeType == nsIDOMNode::DOCUMENT_TYPE_NODE) ==
     110             :               (aName == nsGkAtoms::documentTypeNodeName)) &&
     111             :              ((aNodeType == nsIDOMNode::PROCESSING_INSTRUCTION_NODE) ==
     112             :               (aName == nsGkAtoms::processingInstructionTagName)),
     113             :              "Wrong localName for nodeType");
     114        5415 : }
     115             : 
     116             : #endif /* mozilla_dom_NodeInfoInlines_h___ */

Generated by: LCOV version 1.13