Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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/. */
7 /*
8 * Class that represents a prefix/namespace/localName triple; a single
9 * nodeinfo is shared by all elements in a document that have that
10 * prefix, namespace, and localName.
11 */
13 #ifndef nsNodeInfo_h___
14 #define nsNodeInfo_h___
16 #include "mozilla/Attributes.h"
17 #include "nsINodeInfo.h"
18 #include "nsNodeInfoManager.h"
19 #include "plhash.h"
20 #include "nsIAtom.h"
21 #include "nsCOMPtr.h"
22 #include "nsIDOMNode.h"
23 #include "nsGkAtoms.h"
25 class nsNodeInfo : public nsINodeInfo
26 {
27 public:
28 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
29 NS_DECL_CYCLE_COLLECTION_SKIPPABLE_CLASS(nsNodeInfo)
31 // nsINodeInfo
32 virtual void GetNamespaceURI(nsAString& aNameSpaceURI) const;
33 virtual bool NamespaceEquals(const nsAString& aNamespaceURI) const MOZ_OVERRIDE;
35 // nsNodeInfo
36 public:
37 /*
38 * aName and aOwnerManager may not be null.
39 */
40 nsNodeInfo(nsIAtom *aName, nsIAtom *aPrefix, int32_t aNamespaceID,
41 uint16_t aNodeType, nsIAtom *aExtraName,
42 nsNodeInfoManager *aOwnerManager);
44 private:
45 nsNodeInfo(); // Unimplemented
46 nsNodeInfo(const nsNodeInfo& aOther); // Unimplemented
47 protected:
48 virtual ~nsNodeInfo();
50 public:
51 bool CanSkip();
53 private:
54 /**
55 * This method gets called by Release() when it's time to delete
56 * this object.
57 */
58 void LastRelease();
59 };
61 inline void
62 CheckValidNodeInfo(uint16_t aNodeType, nsIAtom *aName, int32_t aNamespaceID,
63 nsIAtom* aExtraName)
64 {
65 NS_ABORT_IF_FALSE(aNodeType == nsIDOMNode::ELEMENT_NODE ||
66 aNodeType == nsIDOMNode::ATTRIBUTE_NODE ||
67 aNodeType == nsIDOMNode::TEXT_NODE ||
68 aNodeType == nsIDOMNode::CDATA_SECTION_NODE ||
69 aNodeType == nsIDOMNode::PROCESSING_INSTRUCTION_NODE ||
70 aNodeType == nsIDOMNode::COMMENT_NODE ||
71 aNodeType == nsIDOMNode::DOCUMENT_NODE ||
72 aNodeType == nsIDOMNode::DOCUMENT_TYPE_NODE ||
73 aNodeType == nsIDOMNode::DOCUMENT_FRAGMENT_NODE ||
74 aNodeType == UINT16_MAX,
75 "Invalid nodeType");
76 NS_ABORT_IF_FALSE((aNodeType == nsIDOMNode::PROCESSING_INSTRUCTION_NODE ||
77 aNodeType == nsIDOMNode::DOCUMENT_TYPE_NODE) ==
78 !!aExtraName,
79 "Supply aExtraName for and only for PIs and doctypes");
80 NS_ABORT_IF_FALSE(aNodeType == nsIDOMNode::ELEMENT_NODE ||
81 aNodeType == nsIDOMNode::ATTRIBUTE_NODE ||
82 aNodeType == UINT16_MAX ||
83 aNamespaceID == kNameSpaceID_None,
84 "Only attributes and elements can be in a namespace");
85 NS_ABORT_IF_FALSE(aName && aName != nsGkAtoms::_empty, "Invalid localName");
86 NS_ABORT_IF_FALSE(((aNodeType == nsIDOMNode::TEXT_NODE) ==
87 (aName == nsGkAtoms::textTagName)) &&
88 ((aNodeType == nsIDOMNode::CDATA_SECTION_NODE) ==
89 (aName == nsGkAtoms::cdataTagName)) &&
90 ((aNodeType == nsIDOMNode::COMMENT_NODE) ==
91 (aName == nsGkAtoms::commentTagName)) &&
92 ((aNodeType == nsIDOMNode::DOCUMENT_NODE) ==
93 (aName == nsGkAtoms::documentNodeName)) &&
94 ((aNodeType == nsIDOMNode::DOCUMENT_FRAGMENT_NODE) ==
95 (aName == nsGkAtoms::documentFragmentNodeName)) &&
96 ((aNodeType == nsIDOMNode::DOCUMENT_TYPE_NODE) ==
97 (aName == nsGkAtoms::documentTypeNodeName)) &&
98 ((aNodeType == nsIDOMNode::PROCESSING_INSTRUCTION_NODE) ==
99 (aName == nsGkAtoms::processingInstructionTagName)),
100 "Wrong localName for nodeType");
101 }
103 #endif /* nsNodeInfo_h___ */