|
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/. */ |
|
5 |
|
6 /* |
|
7 * Implementation of DOM Core's nsIDOMDocumentType node. |
|
8 */ |
|
9 |
|
10 #ifndef DocumentType_h |
|
11 #define DocumentType_h |
|
12 |
|
13 #include "mozilla/Attributes.h" |
|
14 #include "nsCOMPtr.h" |
|
15 #include "nsIDOMDocumentType.h" |
|
16 #include "nsIContent.h" |
|
17 #include "nsGenericDOMDataNode.h" |
|
18 #include "nsString.h" |
|
19 |
|
20 namespace mozilla { |
|
21 namespace dom { |
|
22 |
|
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. |
|
27 |
|
28 class DocumentTypeForward : public nsGenericDOMDataNode, |
|
29 public nsIDOMDocumentType |
|
30 { |
|
31 public: |
|
32 DocumentTypeForward(already_AddRefed<nsINodeInfo>& aNodeInfo) |
|
33 : nsGenericDOMDataNode(aNodeInfo) |
|
34 { |
|
35 } |
|
36 |
|
37 // nsIDOMNode |
|
38 NS_FORWARD_NSIDOMNODE_TO_NSINODE |
|
39 }; |
|
40 |
|
41 class DocumentType MOZ_FINAL : public DocumentTypeForward |
|
42 { |
|
43 public: |
|
44 DocumentType(already_AddRefed<nsINodeInfo>& aNodeInfo, |
|
45 const nsAString& aPublicId, |
|
46 const nsAString& aSystemId, |
|
47 const nsAString& aInternalSubset); |
|
48 |
|
49 virtual ~DocumentType(); |
|
50 |
|
51 // nsISupports |
|
52 NS_DECL_ISUPPORTS_INHERITED |
|
53 |
|
54 // nsIDOMNode |
|
55 // Forwarded by base class |
|
56 |
|
57 // nsIDOMDocumentType |
|
58 NS_DECL_NSIDOMDOCUMENTTYPE |
|
59 |
|
60 // nsINode |
|
61 virtual bool IsNodeOfType(uint32_t aFlags) const MOZ_OVERRIDE; |
|
62 virtual void GetNodeValueInternal(nsAString& aNodeValue) MOZ_OVERRIDE |
|
63 { |
|
64 SetDOMStringToNull(aNodeValue); |
|
65 } |
|
66 virtual void SetNodeValueInternal(const nsAString& aNodeValue, |
|
67 mozilla::ErrorResult& aError) MOZ_OVERRIDE |
|
68 { |
|
69 } |
|
70 |
|
71 // nsIContent overrides |
|
72 virtual const nsTextFragment* GetText() MOZ_OVERRIDE; |
|
73 |
|
74 virtual nsGenericDOMDataNode* CloneDataNode(nsINodeInfo *aNodeInfo, |
|
75 bool aCloneText) const MOZ_OVERRIDE; |
|
76 |
|
77 virtual nsIDOMNode* AsDOMNode() MOZ_OVERRIDE { return this; } |
|
78 |
|
79 protected: |
|
80 virtual JSObject* WrapNode(JSContext *cx) MOZ_OVERRIDE; |
|
81 |
|
82 nsString mPublicId; |
|
83 nsString mSystemId; |
|
84 nsString mInternalSubset; |
|
85 }; |
|
86 |
|
87 } // namespace dom |
|
88 } // namespace mozilla |
|
89 |
|
90 already_AddRefed<mozilla::dom::DocumentType> |
|
91 NS_NewDOMDocumentType(nsNodeInfoManager* aNodeInfoManager, |
|
92 nsIAtom *aName, |
|
93 const nsAString& aPublicId, |
|
94 const nsAString& aSystemId, |
|
95 const nsAString& aInternalSubset, |
|
96 mozilla::ErrorResult& rv); |
|
97 |
|
98 nsresult |
|
99 NS_NewDOMDocumentType(nsIDOMDocumentType** aDocType, |
|
100 nsNodeInfoManager* aNodeInfoManager, |
|
101 nsIAtom *aName, |
|
102 const nsAString& aPublicId, |
|
103 const nsAString& aSystemId, |
|
104 const nsAString& aInternalSubset); |
|
105 |
|
106 #endif // DocumentType_h |