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/. */
8 * Implementation of DOM Core's DocumentType node.
11 #ifndef DocumentType_h
12 #define DocumentType_h
14 #include "mozilla/Attributes.h"
15 #include "mozilla/dom/CharacterData.h"
17 #include "nsIContent.h"
20 namespace mozilla::dom
{
22 // XXX DocumentType is currently implemented by inheriting the generic
23 // CharacterData object, even though DocumentType is not character
24 // data. This is done simply for convenience and should be changed if
25 // this restricts what should be done for character data.
27 class DocumentType final
: public CharacterData
{
29 DocumentType(already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
,
30 const nsAString
& aPublicId
, const nsAString
& aSystemId
,
31 const nsAString
& aInternalSubset
);
34 NS_INLINE_DECL_REFCOUNTING_INHERITED(DocumentType
, CharacterData
)
37 void GetNodeValueInternal(nsAString
& aNodeValue
) override
{
38 SetDOMStringToNull(aNodeValue
);
40 void SetNodeValueInternal(const nsAString
& aNodeValue
,
41 mozilla::ErrorResult
& aError
) override
{}
43 // nsIContent overrides
44 virtual const nsTextFragment
* GetText() override
;
46 virtual already_AddRefed
<CharacterData
> CloneDataNode(
47 mozilla::dom::NodeInfo
* aNodeInfo
, bool aCloneText
) const override
;
50 void GetName(nsAString
& aName
) const;
51 void GetPublicId(nsAString
& aPublicId
) const;
52 void GetSystemId(nsAString
& aSystemId
) const;
53 void GetInternalSubset(nsAString
& aInternalSubset
) const;
56 virtual ~DocumentType();
58 virtual JSObject
* WrapNode(JSContext
* cx
,
59 JS::Handle
<JSObject
*> aGivenProto
) override
;
63 nsString mInternalSubset
;
66 } // namespace mozilla::dom
68 already_AddRefed
<mozilla::dom::DocumentType
> NS_NewDOMDocumentType(
69 nsNodeInfoManager
* aNodeInfoManager
, nsAtom
* aName
,
70 const nsAString
& aPublicId
, const nsAString
& aSystemId
,
71 const nsAString
& aInternalSubset
);
73 #endif // DocumentType_h