DocumentType.h (2430B)
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/. */ 6 7 /* 8 * Implementation of DOM Core's DocumentType node. 9 */ 10 11 #ifndef DocumentType_h 12 #define DocumentType_h 13 14 #include "mozilla/dom/CharacterData.h" 15 #include "nsCOMPtr.h" 16 #include "nsIContent.h" 17 #include "nsString.h" 18 19 namespace mozilla::dom { 20 21 // XXX DocumentType is currently implemented by inheriting the generic 22 // CharacterData object, even though DocumentType is not character 23 // data. This is done simply for convenience and should be changed if 24 // this restricts what should be done for character data. 25 26 class DocumentType final : public CharacterData { 27 public: 28 DocumentType(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo, 29 const nsAString& aPublicId, const nsAString& aSystemId, 30 const nsAString& aInternalSubset); 31 32 // nsISupports 33 NS_INLINE_DECL_REFCOUNTING_INHERITED(DocumentType, CharacterData) 34 35 // nsINode 36 void GetNodeValueInternal(nsAString& aNodeValue) override { 37 SetDOMStringToNull(aNodeValue); 38 } 39 void SetNodeValueInternal(const nsAString& aNodeValue, 40 mozilla::ErrorResult& aError, 41 MutationEffectOnScript) override {} 42 43 // nsIContent overrides 44 virtual const CharacterDataBuffer* GetCharacterDataBuffer() const override; 45 46 virtual already_AddRefed<CharacterData> CloneDataNode( 47 mozilla::dom::NodeInfo* aNodeInfo, bool aCloneText) const override; 48 49 // WebIDL API 50 void GetName(nsAString& aName) const; 51 void GetPublicId(nsAString& aPublicId) const; 52 void GetSystemId(nsAString& aSystemId) const; 53 void GetInternalSubset(nsAString& aInternalSubset) const; 54 55 protected: 56 virtual ~DocumentType(); 57 58 virtual JSObject* WrapNode(JSContext* cx, 59 JS::Handle<JSObject*> aGivenProto) override; 60 61 nsString mPublicId; 62 nsString mSystemId; 63 nsString mInternalSubset; 64 }; 65 66 } // namespace mozilla::dom 67 68 already_AddRefed<mozilla::dom::DocumentType> NS_NewDOMDocumentType( 69 nsNodeInfoManager* aNodeInfoManager, nsAtom* aName, 70 const nsAString& aPublicId, const nsAString& aSystemId, 71 const nsAString& aInternalSubset); 72 73 #endif // DocumentType_h