Bumping gaia.json for 2 gaia revision(s) a=gaia-bump
[gecko.git] / dom / base / NodeInfoInlines.h
blobb4f5f7f4870f5f0669196b0337e213ca7747968d
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 #ifndef mozilla_dom_NodeInfoInlines_h___
8 #define mozilla_dom_NodeInfoInlines_h___
10 #include "nsIAtom.h"
11 #include "nsIDOMNode.h"
12 #include "nsDOMString.h"
13 #include "nsGkAtoms.h"
15 namespace mozilla {
16 namespace dom {
18 inline bool
19 NodeInfo::Equals(NodeInfo *aNodeInfo) const
21 return aNodeInfo == this || aNodeInfo->Equals(mInner.mName, mInner.mPrefix,
22 mInner.mNamespaceID);
25 inline bool
26 NodeInfo::NameAndNamespaceEquals(NodeInfo *aNodeInfo) const
28 return aNodeInfo == this || aNodeInfo->Equals(mInner.mName,
29 mInner.mNamespaceID);
32 inline bool
33 NodeInfo::Equals(const nsAString& aName) const
35 return mInner.mName->Equals(aName);
38 inline bool
39 NodeInfo::Equals(const nsAString& aName, const nsAString& aPrefix) const
41 return mInner.mName->Equals(aName) &&
42 (mInner.mPrefix ? mInner.mPrefix->Equals(aPrefix) : aPrefix.IsEmpty());
45 inline bool
46 NodeInfo::Equals(const nsAString& aName, int32_t aNamespaceID) const
48 return mInner.mNamespaceID == aNamespaceID &&
49 mInner.mName->Equals(aName);
52 inline bool
53 NodeInfo::Equals(const nsAString& aName, const nsAString& aPrefix,
54 int32_t aNamespaceID) const
56 return mInner.mName->Equals(aName) && mInner.mNamespaceID == aNamespaceID &&
57 (mInner.mPrefix ? mInner.mPrefix->Equals(aPrefix) : aPrefix.IsEmpty());
60 inline bool
61 NodeInfo::QualifiedNameEquals(nsIAtom* aNameAtom) const
63 MOZ_ASSERT(aNameAtom, "Must have name atom");
64 if (!GetPrefixAtom()) {
65 return Equals(aNameAtom);
68 return aNameAtom->Equals(mQualifiedName);
71 } // namespace dom
72 } // namespace mozilla
74 inline void
75 CheckValidNodeInfo(uint16_t aNodeType, nsIAtom *aName, int32_t aNamespaceID,
76 nsIAtom* aExtraName)
78 NS_ABORT_IF_FALSE(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 NS_ABORT_IF_FALSE((aNodeType == nsIDOMNode::PROCESSING_INSTRUCTION_NODE ||
90 aNodeType == nsIDOMNode::DOCUMENT_TYPE_NODE) ==
91 !!aExtraName,
92 "Supply aExtraName for and only for PIs and doctypes");
93 NS_ABORT_IF_FALSE(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 NS_ABORT_IF_FALSE(aName && aName != nsGkAtoms::_empty, "Invalid localName");
99 NS_ABORT_IF_FALSE(((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");
116 #endif /* mozilla_dom_NodeInfoInlines_h___ */