michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * Implementation of DOM Core's nsIDOMDocumentType node. michael@0: */ michael@0: michael@0: #ifndef DocumentType_h michael@0: #define DocumentType_h michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsIDOMDocumentType.h" michael@0: #include "nsIContent.h" michael@0: #include "nsGenericDOMDataNode.h" michael@0: #include "nsString.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: // XXX DocumentType is currently implemented by inheriting the generic michael@0: // CharacterData object, even though DocumentType is not character michael@0: // data. This is done simply for convenience and should be changed if michael@0: // this restricts what should be done for character data. michael@0: michael@0: class DocumentTypeForward : public nsGenericDOMDataNode, michael@0: public nsIDOMDocumentType michael@0: { michael@0: public: michael@0: DocumentTypeForward(already_AddRefed& aNodeInfo) michael@0: : nsGenericDOMDataNode(aNodeInfo) michael@0: { michael@0: } michael@0: michael@0: // nsIDOMNode michael@0: NS_FORWARD_NSIDOMNODE_TO_NSINODE michael@0: }; michael@0: michael@0: class DocumentType MOZ_FINAL : public DocumentTypeForward michael@0: { michael@0: public: michael@0: DocumentType(already_AddRefed& aNodeInfo, michael@0: const nsAString& aPublicId, michael@0: const nsAString& aSystemId, michael@0: const nsAString& aInternalSubset); michael@0: michael@0: virtual ~DocumentType(); michael@0: michael@0: // nsISupports michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: michael@0: // nsIDOMNode michael@0: // Forwarded by base class michael@0: michael@0: // nsIDOMDocumentType michael@0: NS_DECL_NSIDOMDOCUMENTTYPE michael@0: michael@0: // nsINode michael@0: virtual bool IsNodeOfType(uint32_t aFlags) const MOZ_OVERRIDE; michael@0: virtual void GetNodeValueInternal(nsAString& aNodeValue) MOZ_OVERRIDE michael@0: { michael@0: SetDOMStringToNull(aNodeValue); michael@0: } michael@0: virtual void SetNodeValueInternal(const nsAString& aNodeValue, michael@0: mozilla::ErrorResult& aError) MOZ_OVERRIDE michael@0: { michael@0: } michael@0: michael@0: // nsIContent overrides michael@0: virtual const nsTextFragment* GetText() MOZ_OVERRIDE; michael@0: michael@0: virtual nsGenericDOMDataNode* CloneDataNode(nsINodeInfo *aNodeInfo, michael@0: bool aCloneText) const MOZ_OVERRIDE; michael@0: michael@0: virtual nsIDOMNode* AsDOMNode() MOZ_OVERRIDE { return this; } michael@0: michael@0: protected: michael@0: virtual JSObject* WrapNode(JSContext *cx) MOZ_OVERRIDE; michael@0: michael@0: nsString mPublicId; michael@0: nsString mSystemId; michael@0: nsString mInternalSubset; michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: already_AddRefed michael@0: NS_NewDOMDocumentType(nsNodeInfoManager* aNodeInfoManager, michael@0: nsIAtom *aName, michael@0: const nsAString& aPublicId, michael@0: const nsAString& aSystemId, michael@0: const nsAString& aInternalSubset, michael@0: mozilla::ErrorResult& rv); michael@0: michael@0: nsresult michael@0: NS_NewDOMDocumentType(nsIDOMDocumentType** aDocType, michael@0: nsNodeInfoManager* aNodeInfoManager, michael@0: nsIAtom *aName, michael@0: const nsAString& aPublicId, michael@0: const nsAString& aSystemId, michael@0: const nsAString& aInternalSubset); michael@0: michael@0: #endif // DocumentType_h