2013-03-01 06:53:49 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2000-05-08 18:29:44 +04:00
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
#ifndef mozilla_dom_NodeInfoInlines_h___
|
|
|
|
#define mozilla_dom_NodeInfoInlines_h___
|
2006-03-31 12:00:42 +04:00
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
#include "nsAtom.h"
|
2018-01-30 07:10:53 +03:00
|
|
|
#include "nsINode.h"
|
2014-06-20 06:01:40 +04:00
|
|
|
#include "nsDOMString.h"
|
2012-08-16 19:07:55 +04:00
|
|
|
#include "nsGkAtoms.h"
|
2000-05-08 18:29:44 +04:00
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
inline bool
|
|
|
|
NodeInfo::Equals(NodeInfo *aNodeInfo) const
|
|
|
|
{
|
|
|
|
return aNodeInfo == this || aNodeInfo->Equals(mInner.mName, mInner.mPrefix,
|
|
|
|
mInner.mNamespaceID);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool
|
|
|
|
NodeInfo::NameAndNamespaceEquals(NodeInfo *aNodeInfo) const
|
|
|
|
{
|
|
|
|
return aNodeInfo == this || aNodeInfo->Equals(mInner.mName,
|
|
|
|
mInner.mNamespaceID);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool
|
|
|
|
NodeInfo::Equals(const nsAString& aName) const
|
|
|
|
{
|
|
|
|
return mInner.mName->Equals(aName);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool
|
|
|
|
NodeInfo::Equals(const nsAString& aName, const nsAString& aPrefix) const
|
2000-05-08 18:29:44 +04:00
|
|
|
{
|
2014-06-20 06:01:40 +04:00
|
|
|
return mInner.mName->Equals(aName) &&
|
|
|
|
(mInner.mPrefix ? mInner.mPrefix->Equals(aPrefix) : aPrefix.IsEmpty());
|
|
|
|
}
|
2000-05-08 18:29:44 +04:00
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
inline bool
|
|
|
|
NodeInfo::Equals(const nsAString& aName, int32_t aNamespaceID) const
|
|
|
|
{
|
|
|
|
return mInner.mNamespaceID == aNamespaceID &&
|
|
|
|
mInner.mName->Equals(aName);
|
|
|
|
}
|
2000-05-08 18:29:44 +04:00
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
inline bool
|
|
|
|
NodeInfo::Equals(const nsAString& aName, const nsAString& aPrefix,
|
|
|
|
int32_t aNamespaceID) const
|
|
|
|
{
|
|
|
|
return mInner.mName->Equals(aName) && mInner.mNamespaceID == aNamespaceID &&
|
|
|
|
(mInner.mPrefix ? mInner.mPrefix->Equals(aPrefix) : aPrefix.IsEmpty());
|
|
|
|
}
|
2013-03-01 06:53:49 +04:00
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
inline bool
|
2017-10-03 01:05:19 +03:00
|
|
|
NodeInfo::QualifiedNameEquals(nsAtom* aNameAtom) const
|
2014-06-20 06:01:40 +04:00
|
|
|
{
|
|
|
|
MOZ_ASSERT(aNameAtom, "Must have name atom");
|
|
|
|
if (!GetPrefixAtom()) {
|
|
|
|
return Equals(aNameAtom);
|
|
|
|
}
|
2000-05-08 18:29:44 +04:00
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
return aNameAtom->Equals(mQualifiedName);
|
|
|
|
}
|
2013-01-26 02:11:13 +04:00
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2000-05-08 18:29:44 +04:00
|
|
|
|
2012-08-16 19:07:55 +04:00
|
|
|
inline void
|
2017-10-03 01:05:19 +03:00
|
|
|
CheckValidNodeInfo(uint16_t aNodeType, nsAtom *aName, int32_t aNamespaceID,
|
|
|
|
nsAtom* aExtraName)
|
2012-08-16 19:07:55 +04:00
|
|
|
{
|
2018-01-30 07:10:53 +03:00
|
|
|
MOZ_ASSERT(aNodeType == nsINode::ELEMENT_NODE ||
|
|
|
|
aNodeType == nsINode::ATTRIBUTE_NODE ||
|
|
|
|
aNodeType == nsINode::TEXT_NODE ||
|
|
|
|
aNodeType == nsINode::CDATA_SECTION_NODE ||
|
|
|
|
aNodeType == nsINode::PROCESSING_INSTRUCTION_NODE ||
|
|
|
|
aNodeType == nsINode::COMMENT_NODE ||
|
|
|
|
aNodeType == nsINode::DOCUMENT_NODE ||
|
|
|
|
aNodeType == nsINode::DOCUMENT_TYPE_NODE ||
|
|
|
|
aNodeType == nsINode::DOCUMENT_FRAGMENT_NODE ||
|
2015-02-10 01:34:50 +03:00
|
|
|
aNodeType == UINT16_MAX,
|
|
|
|
"Invalid nodeType");
|
2018-01-30 07:10:53 +03:00
|
|
|
MOZ_ASSERT((aNodeType == nsINode::PROCESSING_INSTRUCTION_NODE ||
|
|
|
|
aNodeType == nsINode::DOCUMENT_TYPE_NODE) ==
|
2015-02-10 01:34:50 +03:00
|
|
|
!!aExtraName,
|
|
|
|
"Supply aExtraName for and only for PIs and doctypes");
|
2018-01-30 07:10:53 +03:00
|
|
|
MOZ_ASSERT(aNodeType == nsINode::ELEMENT_NODE ||
|
|
|
|
aNodeType == nsINode::ATTRIBUTE_NODE ||
|
2015-02-10 01:34:50 +03:00
|
|
|
aNodeType == UINT16_MAX ||
|
|
|
|
aNamespaceID == kNameSpaceID_None,
|
|
|
|
"Only attributes and elements can be in a namespace");
|
|
|
|
MOZ_ASSERT(aName && aName != nsGkAtoms::_empty, "Invalid localName");
|
2018-01-30 07:10:53 +03:00
|
|
|
MOZ_ASSERT(((aNodeType == nsINode::TEXT_NODE) ==
|
2015-02-10 01:34:50 +03:00
|
|
|
(aName == nsGkAtoms::textTagName)) &&
|
2018-01-30 07:10:53 +03:00
|
|
|
((aNodeType == nsINode::CDATA_SECTION_NODE) ==
|
2015-02-10 01:34:50 +03:00
|
|
|
(aName == nsGkAtoms::cdataTagName)) &&
|
2018-01-30 07:10:53 +03:00
|
|
|
((aNodeType == nsINode::COMMENT_NODE) ==
|
2015-02-10 01:34:50 +03:00
|
|
|
(aName == nsGkAtoms::commentTagName)) &&
|
2018-01-30 07:10:53 +03:00
|
|
|
((aNodeType == nsINode::DOCUMENT_NODE) ==
|
2015-02-10 01:34:50 +03:00
|
|
|
(aName == nsGkAtoms::documentNodeName)) &&
|
2018-01-30 07:10:53 +03:00
|
|
|
((aNodeType == nsINode::DOCUMENT_FRAGMENT_NODE) ==
|
2015-02-10 01:34:50 +03:00
|
|
|
(aName == nsGkAtoms::documentFragmentNodeName)) &&
|
2018-01-30 07:10:53 +03:00
|
|
|
((aNodeType == nsINode::DOCUMENT_TYPE_NODE) ==
|
2015-02-10 01:34:50 +03:00
|
|
|
(aName == nsGkAtoms::documentTypeNodeName)) &&
|
2018-01-30 07:10:53 +03:00
|
|
|
((aNodeType == nsINode::PROCESSING_INSTRUCTION_NODE) ==
|
2015-02-10 01:34:50 +03:00
|
|
|
(aName == nsGkAtoms::processingInstructionTagName)),
|
|
|
|
"Wrong localName for nodeType");
|
2012-08-16 19:07:55 +04:00
|
|
|
}
|
2011-06-14 11:56:49 +04:00
|
|
|
|
2015-02-10 01:34:50 +03:00
|
|
|
#endif /* mozilla_dom_NodeInfoInlines_h___ */
|