diff --git a/content/xml/content/src/CDATASection.cpp b/content/xml/content/src/CDATASection.cpp new file mode 100644 index 000000000000..832162270bff --- /dev/null +++ b/content/xml/content/src/CDATASection.cpp @@ -0,0 +1,95 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. */ + +#include "mozilla/dom/CDATASection.h" + +nsresult +NS_NewXMLCDATASection(nsIContent** aInstancePtrResult, + nsNodeInfoManager *aNodeInfoManager) +{ + using mozilla::dom::CDATASection; + + NS_PRECONDITION(aNodeInfoManager, "Missing nodeinfo manager"); + + *aInstancePtrResult = nullptr; + + nsCOMPtr ni; + ni = aNodeInfoManager->GetNodeInfo(nsGkAtoms::cdataTagName, + nullptr, kNameSpaceID_None, + nsIDOMNode::CDATA_SECTION_NODE); + NS_ENSURE_TRUE(ni, NS_ERROR_OUT_OF_MEMORY); + + CDATASection *instance = new CDATASection(ni.forget()); + if (!instance) { + return NS_ERROR_OUT_OF_MEMORY; + } + + NS_ADDREF(*aInstancePtrResult = instance); + + return NS_OK; +} + +DOMCI_NODE_DATA(CDATASection, mozilla::dom::CDATASection) + +namespace mozilla { +namespace dom { + +CDATASection::~CDATASection() +{ +} + + +// QueryInterface implementation for CDATASection +NS_INTERFACE_TABLE_HEAD(CDATASection) + NS_NODE_INTERFACE_TABLE4(CDATASection, nsIDOMNode, nsIDOMCharacterData, + nsIDOMText, nsIDOMCDATASection) + NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CDATASection) +NS_INTERFACE_MAP_END_INHERITING(nsGenericDOMDataNode) + +NS_IMPL_ADDREF_INHERITED(CDATASection, nsGenericDOMDataNode) +NS_IMPL_RELEASE_INHERITED(CDATASection, nsGenericDOMDataNode) + +bool +CDATASection::IsNodeOfType(uint32_t aFlags) const +{ + return !(aFlags & ~(eCONTENT | eTEXT | eDATA_NODE)); +} + +nsGenericDOMDataNode* +CDATASection::CloneDataNode(nsINodeInfo *aNodeInfo, bool aCloneText) const +{ + nsCOMPtr ni = aNodeInfo; + CDATASection *it = new CDATASection(ni.forget()); + if (it && aCloneText) { + it->mText = mText; + } + + return it; +} + +#ifdef DEBUG +void +CDATASection::List(FILE* out, int32_t aIndent) const +{ + int32_t index; + for (index = aIndent; --index >= 0; ) fputs(" ", out); + + fprintf(out, "CDATASection refcount=%d<", mRefCnt.get()); + + nsAutoString tmp; + ToCString(tmp, 0, mText.GetLength()); + fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out); + + fputs(">\n", out); +} + +void +CDATASection::DumpContent(FILE* out, int32_t aIndent, + bool aDumpAll) const { +} +#endif + +} // namespace mozilla +} // namespace dom diff --git a/content/xml/content/src/CDATASection.h b/content/xml/content/src/CDATASection.h new file mode 100644 index 000000000000..5997358ed11b --- /dev/null +++ b/content/xml/content/src/CDATASection.h @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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/. */ + +#ifndef mozilla_dom_CDATASection_h +#define mozilla_dom_CDATASection_h + +#include "nsIDOMCDATASection.h" +#include "nsGenericDOMDataNode.h" + +namespace mozilla { +namespace dom { + +class CDATASection : public nsGenericDOMDataNode, + public nsIDOMCDATASection +{ +public: + CDATASection(already_AddRefed aNodeInfo) + : nsGenericDOMDataNode(aNodeInfo) + { + NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::CDATA_SECTION_NODE, + "Bad NodeType in aNodeInfo"); + } + virtual ~CDATASection(); + + // nsISupports + NS_DECL_ISUPPORTS_INHERITED + + // nsIDOMNode + NS_FORWARD_NSIDOMNODE_TO_NSINODE + + // nsIDOMCharacterData + NS_FORWARD_NSIDOMCHARACTERDATA(nsGenericDOMDataNode::) + + // nsIDOMText + NS_FORWARD_NSIDOMTEXT(nsGenericDOMDataNode::) + + // nsIDOMCDATASection + // Empty interface + + // nsINode + virtual bool IsNodeOfType(uint32_t aFlags) const; + + virtual nsGenericDOMDataNode* CloneDataNode(nsINodeInfo *aNodeInfo, + bool aCloneText) const; + + virtual nsXPCClassInfo* GetClassInfo(); + + virtual nsIDOMNode* AsDOMNode() { return this; } +#ifdef DEBUG + virtual void List(FILE* out, int32_t aIndent) const; + virtual void DumpContent(FILE* out, int32_t aIndent,bool aDumpAll) const; +#endif +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_CDATASection_h diff --git a/content/xml/content/src/Makefile.in b/content/xml/content/src/Makefile.in index 46f30b02e1f8..0ecaf4080ffd 100644 --- a/content/xml/content/src/Makefile.in +++ b/content/xml/content/src/Makefile.in @@ -15,9 +15,15 @@ LIBRARY_NAME = gkconxmlcon_s LIBXUL_LIBRARY = 1 FAIL_ON_WARNINGS = 1 +EXPORTS_NAMESPACES = mozilla/dom + +EXPORTS_mozilla/dom = \ + CDATASection.h \ + $(NULL) + CPPSRCS = \ nsXMLElement.cpp \ - nsXMLCDATASection.cpp \ + CDATASection.cpp \ nsXMLProcessingInstruction.cpp \ nsXMLStylesheetPI.cpp \ $(NULL) diff --git a/content/xml/content/src/nsXMLCDATASection.cpp b/content/xml/content/src/nsXMLCDATASection.cpp deleted file mode 100644 index 572e6fe964b3..000000000000 --- a/content/xml/content/src/nsXMLCDATASection.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* 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/. */ - -#include "nsIDOMCDATASection.h" -#include "nsGenericDOMDataNode.h" -#include "nsGkAtoms.h" - -class nsXMLCDATASection : public nsGenericDOMDataNode, - public nsIDOMCDATASection -{ -public: - nsXMLCDATASection(already_AddRefed aNodeInfo); - virtual ~nsXMLCDATASection(); - - // nsISupports - NS_DECL_ISUPPORTS_INHERITED - - // nsIDOMNode - NS_FORWARD_NSIDOMNODE_TO_NSINODE - - // nsIDOMCharacterData - NS_FORWARD_NSIDOMCHARACTERDATA(nsGenericDOMDataNode::) - - // nsIDOMText - NS_FORWARD_NSIDOMTEXT(nsGenericDOMDataNode::) - - // nsIDOMCDATASection - // Empty interface - - // nsINode - virtual bool IsNodeOfType(uint32_t aFlags) const; - - virtual nsGenericDOMDataNode* CloneDataNode(nsINodeInfo *aNodeInfo, - bool aCloneText) const; - - virtual nsXPCClassInfo* GetClassInfo(); - - virtual nsIDOMNode* AsDOMNode() { return this; } -#ifdef DEBUG - virtual void List(FILE* out, int32_t aIndent) const; - virtual void DumpContent(FILE* out, int32_t aIndent,bool aDumpAll) const; -#endif -}; - -nsresult -NS_NewXMLCDATASection(nsIContent** aInstancePtrResult, - nsNodeInfoManager *aNodeInfoManager) -{ - NS_PRECONDITION(aNodeInfoManager, "Missing nodeinfo manager"); - - *aInstancePtrResult = nullptr; - - nsCOMPtr ni; - ni = aNodeInfoManager->GetNodeInfo(nsGkAtoms::cdataTagName, - nullptr, kNameSpaceID_None, - nsIDOMNode::CDATA_SECTION_NODE); - NS_ENSURE_TRUE(ni, NS_ERROR_OUT_OF_MEMORY); - - nsXMLCDATASection *instance = new nsXMLCDATASection(ni.forget()); - if (!instance) { - return NS_ERROR_OUT_OF_MEMORY; - } - - NS_ADDREF(*aInstancePtrResult = instance); - - return NS_OK; -} - -nsXMLCDATASection::nsXMLCDATASection(already_AddRefed aNodeInfo) - : nsGenericDOMDataNode(aNodeInfo) -{ - NS_ABORT_IF_FALSE(mNodeInfo->NodeType() == nsIDOMNode::CDATA_SECTION_NODE, - "Bad NodeType in aNodeInfo"); -} - -nsXMLCDATASection::~nsXMLCDATASection() -{ -} - - -DOMCI_NODE_DATA(CDATASection, nsXMLCDATASection) - -// QueryInterface implementation for nsXMLCDATASection -NS_INTERFACE_TABLE_HEAD(nsXMLCDATASection) - NS_NODE_INTERFACE_TABLE4(nsXMLCDATASection, nsIDOMNode, nsIDOMCharacterData, - nsIDOMText, nsIDOMCDATASection) - NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CDATASection) -NS_INTERFACE_MAP_END_INHERITING(nsGenericDOMDataNode) - -NS_IMPL_ADDREF_INHERITED(nsXMLCDATASection, nsGenericDOMDataNode) -NS_IMPL_RELEASE_INHERITED(nsXMLCDATASection, nsGenericDOMDataNode) - - -bool -nsXMLCDATASection::IsNodeOfType(uint32_t aFlags) const -{ - return !(aFlags & ~(eCONTENT | eTEXT | eDATA_NODE)); -} - -nsGenericDOMDataNode* -nsXMLCDATASection::CloneDataNode(nsINodeInfo *aNodeInfo, bool aCloneText) const -{ - nsCOMPtr ni = aNodeInfo; - nsXMLCDATASection *it = new nsXMLCDATASection(ni.forget()); - if (it && aCloneText) { - it->mText = mText; - } - - return it; -} - -#ifdef DEBUG -void -nsXMLCDATASection::List(FILE* out, int32_t aIndent) const -{ - int32_t index; - for (index = aIndent; --index >= 0; ) fputs(" ", out); - - fprintf(out, "CDATASection refcount=%d<", mRefCnt.get()); - - nsAutoString tmp; - ToCString(tmp, 0, mText.GetLength()); - fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out); - - fputs(">\n", out); -} - -void -nsXMLCDATASection::DumpContent(FILE* out, int32_t aIndent, - bool aDumpAll) const { -} -#endif