nsIContentSerializer.h (3240B)
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 #ifndef nsIContentSerializer_h 8 #define nsIContentSerializer_h 9 10 #include "nsISupports.h" 11 #include "nsStringFwd.h" 12 13 class nsIContent; 14 15 namespace mozilla { 16 class Encoding; 17 namespace dom { 18 class Comment; 19 class Document; 20 class DocumentType; 21 class Element; 22 class ProcessingInstruction; 23 class Text; 24 } // namespace dom 25 } // namespace mozilla 26 27 #define NS_ICONTENTSERIALIZER_IID \ 28 {0xb1ee32f2, 0xb8c4, 0x49b9, {0x93, 0xdf, 0xb6, 0xfa, 0xb5, 0xd5, 0x46, 0x88}} 29 30 class nsIContentSerializer : public nsISupports { 31 public: 32 NS_INLINE_DECL_STATIC_IID(NS_ICONTENTSERIALIZER_IID) 33 34 /** 35 * @param aOutput The `Append*` methods will append to this string. The 36 * reference to it will be dropped with `Finish`. 37 */ 38 NS_IMETHOD Init(uint32_t flags, uint32_t aWrapColumn, 39 const mozilla::Encoding* aEncoding, bool aIsCopying, 40 bool aIsWholeDocument, bool* aNeedsPerformatScanning, 41 nsAString& aOutput) = 0; 42 43 NS_IMETHOD AppendText(mozilla::dom::Text* aText, int32_t aStartOffset, 44 int32_t aEndOffset) = 0; 45 46 NS_IMETHOD AppendCDATASection(mozilla::dom::Text* aCDATASection, 47 int32_t aStartOffset, int32_t aEndOffset) = 0; 48 49 NS_IMETHOD AppendProcessingInstruction( 50 mozilla::dom::ProcessingInstruction* aPI, int32_t aStartOffset, 51 int32_t aEndOffset) = 0; 52 53 NS_IMETHOD AppendComment(mozilla::dom::Comment* aComment, 54 int32_t aStartOffset, int32_t aEndOffset) = 0; 55 56 NS_IMETHOD AppendDoctype(mozilla::dom::DocumentType* aDoctype) = 0; 57 58 NS_IMETHOD AppendElementStart(mozilla::dom::Element* aElement, 59 mozilla::dom::Element* aOriginalElement) = 0; 60 61 NS_IMETHOD AppendElementEnd(mozilla::dom::Element* aElement, 62 mozilla::dom::Element* aOriginalElement) = 0; 63 64 NS_IMETHOD FlushAndFinish() = 0; 65 66 /** 67 * Drops the reference to the output buffer. 68 */ 69 NS_IMETHOD Finish() = 0; 70 71 NS_IMETHOD GetOutputLength(uint32_t& aLength) const = 0; 72 73 /** 74 * Append any items in the beginning of the document that won't be 75 * serialized by other methods. XML declaration is the most likely 76 * thing this method can produce. 77 */ 78 NS_IMETHOD AppendDocumentStart(mozilla::dom::Document* aDocument) = 0; 79 80 // If Init() sets *aNeedsPerformatScanning to true, then these methods are 81 // called when elements are started and ended, before AppendElementStart 82 // and AppendElementEnd, respectively. They are supposed to be used to 83 // allow the implementer to keep track of whether the element is 84 // preformatted. 85 NS_IMETHOD ScanElementForPreformat(mozilla::dom::Element* aElement) = 0; 86 NS_IMETHOD ForgetElementForPreformat(mozilla::dom::Element* aElement) = 0; 87 }; 88 89 #define NS_CONTENTSERIALIZER_CONTRACTID_PREFIX \ 90 "@mozilla.org/layout/contentserializer;1?mimetype=" 91 92 #endif /* nsIContentSerializer_h */