michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=8 sts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * Class that represents a prefix/namespace/localName triple; a single michael@0: * nodeinfo is shared by all elements in a document that have that michael@0: * prefix, namespace, and localName. michael@0: */ michael@0: michael@0: #ifndef nsNodeInfo_h___ michael@0: #define nsNodeInfo_h___ michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsINodeInfo.h" michael@0: #include "nsNodeInfoManager.h" michael@0: #include "plhash.h" michael@0: #include "nsIAtom.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsIDOMNode.h" michael@0: #include "nsGkAtoms.h" michael@0: michael@0: class nsNodeInfo : public nsINodeInfo michael@0: { michael@0: public: michael@0: NS_DECL_CYCLE_COLLECTING_ISUPPORTS michael@0: NS_DECL_CYCLE_COLLECTION_SKIPPABLE_CLASS(nsNodeInfo) michael@0: michael@0: // nsINodeInfo michael@0: virtual void GetNamespaceURI(nsAString& aNameSpaceURI) const; michael@0: virtual bool NamespaceEquals(const nsAString& aNamespaceURI) const MOZ_OVERRIDE; michael@0: michael@0: // nsNodeInfo michael@0: public: michael@0: /* michael@0: * aName and aOwnerManager may not be null. michael@0: */ michael@0: nsNodeInfo(nsIAtom *aName, nsIAtom *aPrefix, int32_t aNamespaceID, michael@0: uint16_t aNodeType, nsIAtom *aExtraName, michael@0: nsNodeInfoManager *aOwnerManager); michael@0: michael@0: private: michael@0: nsNodeInfo(); // Unimplemented michael@0: nsNodeInfo(const nsNodeInfo& aOther); // Unimplemented michael@0: protected: michael@0: virtual ~nsNodeInfo(); michael@0: michael@0: public: michael@0: bool CanSkip(); michael@0: michael@0: private: michael@0: /** michael@0: * This method gets called by Release() when it's time to delete michael@0: * this object. michael@0: */ michael@0: void LastRelease(); michael@0: }; michael@0: michael@0: inline void michael@0: CheckValidNodeInfo(uint16_t aNodeType, nsIAtom *aName, int32_t aNamespaceID, michael@0: nsIAtom* aExtraName) michael@0: { michael@0: NS_ABORT_IF_FALSE(aNodeType == nsIDOMNode::ELEMENT_NODE || michael@0: aNodeType == nsIDOMNode::ATTRIBUTE_NODE || michael@0: aNodeType == nsIDOMNode::TEXT_NODE || michael@0: aNodeType == nsIDOMNode::CDATA_SECTION_NODE || michael@0: aNodeType == nsIDOMNode::PROCESSING_INSTRUCTION_NODE || michael@0: aNodeType == nsIDOMNode::COMMENT_NODE || michael@0: aNodeType == nsIDOMNode::DOCUMENT_NODE || michael@0: aNodeType == nsIDOMNode::DOCUMENT_TYPE_NODE || michael@0: aNodeType == nsIDOMNode::DOCUMENT_FRAGMENT_NODE || michael@0: aNodeType == UINT16_MAX, michael@0: "Invalid nodeType"); michael@0: NS_ABORT_IF_FALSE((aNodeType == nsIDOMNode::PROCESSING_INSTRUCTION_NODE || michael@0: aNodeType == nsIDOMNode::DOCUMENT_TYPE_NODE) == michael@0: !!aExtraName, michael@0: "Supply aExtraName for and only for PIs and doctypes"); michael@0: NS_ABORT_IF_FALSE(aNodeType == nsIDOMNode::ELEMENT_NODE || michael@0: aNodeType == nsIDOMNode::ATTRIBUTE_NODE || michael@0: aNodeType == UINT16_MAX || michael@0: aNamespaceID == kNameSpaceID_None, michael@0: "Only attributes and elements can be in a namespace"); michael@0: NS_ABORT_IF_FALSE(aName && aName != nsGkAtoms::_empty, "Invalid localName"); michael@0: NS_ABORT_IF_FALSE(((aNodeType == nsIDOMNode::TEXT_NODE) == michael@0: (aName == nsGkAtoms::textTagName)) && michael@0: ((aNodeType == nsIDOMNode::CDATA_SECTION_NODE) == michael@0: (aName == nsGkAtoms::cdataTagName)) && michael@0: ((aNodeType == nsIDOMNode::COMMENT_NODE) == michael@0: (aName == nsGkAtoms::commentTagName)) && michael@0: ((aNodeType == nsIDOMNode::DOCUMENT_NODE) == michael@0: (aName == nsGkAtoms::documentNodeName)) && michael@0: ((aNodeType == nsIDOMNode::DOCUMENT_FRAGMENT_NODE) == michael@0: (aName == nsGkAtoms::documentFragmentNodeName)) && michael@0: ((aNodeType == nsIDOMNode::DOCUMENT_TYPE_NODE) == michael@0: (aName == nsGkAtoms::documentTypeNodeName)) && michael@0: ((aNodeType == nsIDOMNode::PROCESSING_INSTRUCTION_NODE) == michael@0: (aName == nsGkAtoms::processingInstructionTagName)), michael@0: "Wrong localName for nodeType"); michael@0: } michael@0: michael@0: #endif /* nsNodeInfo_h___ */