1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 * Implementation of DOM Core's nsIDOMDocumentType node.
10 #ifndef DocumentType_h
11 #define DocumentType_h
13 #include "mozilla/Attributes.h"
15 #include "nsIDOMDocumentType.h"
16 #include "nsIContent.h"
17 #include "nsGenericDOMDataNode.h"
23 // XXX DocumentType is currently implemented by inheriting the generic
24 // CharacterData object, even though DocumentType is not character
25 // data. This is done simply for convenience and should be changed if
26 // this restricts what should be done for character data.
28 class DocumentTypeForward
: public nsGenericDOMDataNode
,
29 public nsIDOMDocumentType
32 explicit DocumentTypeForward(already_AddRefed
<mozilla::dom::NodeInfo
>& aNodeInfo
)
33 : nsGenericDOMDataNode(aNodeInfo
)
38 NS_FORWARD_NSIDOMNODE_TO_NSINODE
41 class DocumentType MOZ_FINAL
: public DocumentTypeForward
44 DocumentType(already_AddRefed
<mozilla::dom::NodeInfo
>& aNodeInfo
,
45 const nsAString
& aPublicId
,
46 const nsAString
& aSystemId
,
47 const nsAString
& aInternalSubset
);
50 NS_DECL_ISUPPORTS_INHERITED
53 // Forwarded by base class
56 NS_DECL_NSIDOMDOCUMENTTYPE
59 virtual bool IsNodeOfType(uint32_t aFlags
) const MOZ_OVERRIDE
;
60 virtual void GetNodeValueInternal(nsAString
& aNodeValue
) MOZ_OVERRIDE
62 SetDOMStringToNull(aNodeValue
);
64 virtual void SetNodeValueInternal(const nsAString
& aNodeValue
,
65 mozilla::ErrorResult
& aError
) MOZ_OVERRIDE
69 // nsIContent overrides
70 virtual const nsTextFragment
* GetText() MOZ_OVERRIDE
;
72 virtual nsGenericDOMDataNode
* CloneDataNode(mozilla::dom::NodeInfo
*aNodeInfo
,
73 bool aCloneText
) const MOZ_OVERRIDE
;
75 virtual nsIDOMNode
* AsDOMNode() MOZ_OVERRIDE
{ return this; }
78 virtual ~DocumentType();
80 virtual JSObject
* WrapNode(JSContext
*cx
) MOZ_OVERRIDE
;
84 nsString mInternalSubset
;
88 } // namespace mozilla
90 already_AddRefed
<mozilla::dom::DocumentType
>
91 NS_NewDOMDocumentType(nsNodeInfoManager
* aNodeInfoManager
,
93 const nsAString
& aPublicId
,
94 const nsAString
& aSystemId
,
95 const nsAString
& aInternalSubset
,
96 mozilla::ErrorResult
& rv
);
99 NS_NewDOMDocumentType(nsIDOMDocumentType
** aDocType
,
100 nsNodeInfoManager
* aNodeInfoManager
,
102 const nsAString
& aPublicId
,
103 const nsAString
& aSystemId
,
104 const nsAString
& aInternalSubset
);
106 #endif // DocumentType_h