content/base/src/nsNodeInfo.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 /*
michael@0 8 * Class that represents a prefix/namespace/localName triple; a single
michael@0 9 * nodeinfo is shared by all elements in a document that have that
michael@0 10 * prefix, namespace, and localName.
michael@0 11 */
michael@0 12
michael@0 13 #ifndef nsNodeInfo_h___
michael@0 14 #define nsNodeInfo_h___
michael@0 15
michael@0 16 #include "mozilla/Attributes.h"
michael@0 17 #include "nsINodeInfo.h"
michael@0 18 #include "nsNodeInfoManager.h"
michael@0 19 #include "plhash.h"
michael@0 20 #include "nsIAtom.h"
michael@0 21 #include "nsCOMPtr.h"
michael@0 22 #include "nsIDOMNode.h"
michael@0 23 #include "nsGkAtoms.h"
michael@0 24
michael@0 25 class nsNodeInfo : public nsINodeInfo
michael@0 26 {
michael@0 27 public:
michael@0 28 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
michael@0 29 NS_DECL_CYCLE_COLLECTION_SKIPPABLE_CLASS(nsNodeInfo)
michael@0 30
michael@0 31 // nsINodeInfo
michael@0 32 virtual void GetNamespaceURI(nsAString& aNameSpaceURI) const;
michael@0 33 virtual bool NamespaceEquals(const nsAString& aNamespaceURI) const MOZ_OVERRIDE;
michael@0 34
michael@0 35 // nsNodeInfo
michael@0 36 public:
michael@0 37 /*
michael@0 38 * aName and aOwnerManager may not be null.
michael@0 39 */
michael@0 40 nsNodeInfo(nsIAtom *aName, nsIAtom *aPrefix, int32_t aNamespaceID,
michael@0 41 uint16_t aNodeType, nsIAtom *aExtraName,
michael@0 42 nsNodeInfoManager *aOwnerManager);
michael@0 43
michael@0 44 private:
michael@0 45 nsNodeInfo(); // Unimplemented
michael@0 46 nsNodeInfo(const nsNodeInfo& aOther); // Unimplemented
michael@0 47 protected:
michael@0 48 virtual ~nsNodeInfo();
michael@0 49
michael@0 50 public:
michael@0 51 bool CanSkip();
michael@0 52
michael@0 53 private:
michael@0 54 /**
michael@0 55 * This method gets called by Release() when it's time to delete
michael@0 56 * this object.
michael@0 57 */
michael@0 58 void LastRelease();
michael@0 59 };
michael@0 60
michael@0 61 inline void
michael@0 62 CheckValidNodeInfo(uint16_t aNodeType, nsIAtom *aName, int32_t aNamespaceID,
michael@0 63 nsIAtom* aExtraName)
michael@0 64 {
michael@0 65 NS_ABORT_IF_FALSE(aNodeType == nsIDOMNode::ELEMENT_NODE ||
michael@0 66 aNodeType == nsIDOMNode::ATTRIBUTE_NODE ||
michael@0 67 aNodeType == nsIDOMNode::TEXT_NODE ||
michael@0 68 aNodeType == nsIDOMNode::CDATA_SECTION_NODE ||
michael@0 69 aNodeType == nsIDOMNode::PROCESSING_INSTRUCTION_NODE ||
michael@0 70 aNodeType == nsIDOMNode::COMMENT_NODE ||
michael@0 71 aNodeType == nsIDOMNode::DOCUMENT_NODE ||
michael@0 72 aNodeType == nsIDOMNode::DOCUMENT_TYPE_NODE ||
michael@0 73 aNodeType == nsIDOMNode::DOCUMENT_FRAGMENT_NODE ||
michael@0 74 aNodeType == UINT16_MAX,
michael@0 75 "Invalid nodeType");
michael@0 76 NS_ABORT_IF_FALSE((aNodeType == nsIDOMNode::PROCESSING_INSTRUCTION_NODE ||
michael@0 77 aNodeType == nsIDOMNode::DOCUMENT_TYPE_NODE) ==
michael@0 78 !!aExtraName,
michael@0 79 "Supply aExtraName for and only for PIs and doctypes");
michael@0 80 NS_ABORT_IF_FALSE(aNodeType == nsIDOMNode::ELEMENT_NODE ||
michael@0 81 aNodeType == nsIDOMNode::ATTRIBUTE_NODE ||
michael@0 82 aNodeType == UINT16_MAX ||
michael@0 83 aNamespaceID == kNameSpaceID_None,
michael@0 84 "Only attributes and elements can be in a namespace");
michael@0 85 NS_ABORT_IF_FALSE(aName && aName != nsGkAtoms::_empty, "Invalid localName");
michael@0 86 NS_ABORT_IF_FALSE(((aNodeType == nsIDOMNode::TEXT_NODE) ==
michael@0 87 (aName == nsGkAtoms::textTagName)) &&
michael@0 88 ((aNodeType == nsIDOMNode::CDATA_SECTION_NODE) ==
michael@0 89 (aName == nsGkAtoms::cdataTagName)) &&
michael@0 90 ((aNodeType == nsIDOMNode::COMMENT_NODE) ==
michael@0 91 (aName == nsGkAtoms::commentTagName)) &&
michael@0 92 ((aNodeType == nsIDOMNode::DOCUMENT_NODE) ==
michael@0 93 (aName == nsGkAtoms::documentNodeName)) &&
michael@0 94 ((aNodeType == nsIDOMNode::DOCUMENT_FRAGMENT_NODE) ==
michael@0 95 (aName == nsGkAtoms::documentFragmentNodeName)) &&
michael@0 96 ((aNodeType == nsIDOMNode::DOCUMENT_TYPE_NODE) ==
michael@0 97 (aName == nsGkAtoms::documentTypeNodeName)) &&
michael@0 98 ((aNodeType == nsIDOMNode::PROCESSING_INSTRUCTION_NODE) ==
michael@0 99 (aName == nsGkAtoms::processingInstructionTagName)),
michael@0 100 "Wrong localName for nodeType");
michael@0 101 }
michael@0 102
michael@0 103 #endif /* nsNodeInfo_h___ */

mercurial