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 
12 class nsIContent;
13 class nsIDocument;
14 class nsAString;
15 
16 namespace mozilla {
17 namespace dom {
18 class Element;
19 } // namespace dom
20 } // namespace mozilla
21 
22 #define NS_ICONTENTSERIALIZER_IID \
23 { 0xb1ee32f2, 0xb8c4, 0x49b9, \
24   { 0x93, 0xdf, 0xb6, 0xfa, 0xb5, 0xd5, 0x46, 0x88 } }
25 
26 class nsIContentSerializer : public nsISupports {
27  public:
28 
29   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENTSERIALIZER_IID)
30 
31   NS_IMETHOD Init(uint32_t flags, uint32_t aWrapColumn,
32                   const char* aCharSet, bool aIsCopying,
33                   bool aIsWholeDocument) = 0;
34 
35   NS_IMETHOD AppendText(nsIContent* aText, int32_t aStartOffset,
36                         int32_t aEndOffset, nsAString& aStr) = 0;
37 
38   NS_IMETHOD AppendCDATASection(nsIContent* aCDATASection,
39                                 int32_t aStartOffset, int32_t aEndOffset,
40                                 nsAString& aStr) = 0;
41 
42   NS_IMETHOD AppendProcessingInstruction(nsIContent* aPI,
43                                          int32_t aStartOffset,
44                                          int32_t aEndOffset,
45                                          nsAString& aStr) = 0;
46 
47   NS_IMETHOD AppendComment(nsIContent* aComment, int32_t aStartOffset,
48                            int32_t aEndOffset, nsAString& aStr) = 0;
49 
50   NS_IMETHOD AppendDoctype(nsIContent *aDoctype,
51                            nsAString& aStr) = 0;
52 
53   NS_IMETHOD AppendElementStart(mozilla::dom::Element* aElement,
54                                 mozilla::dom::Element* aOriginalElement,
55                                 nsAString& aStr) = 0;
56 
57   NS_IMETHOD AppendElementEnd(mozilla::dom::Element* aElement,
58                               nsAString& aStr) = 0;
59 
60   NS_IMETHOD Flush(nsAString& aStr) = 0;
61 
62   /**
63    * Append any items in the beginning of the document that won't be
64    * serialized by other methods. XML declaration is the most likely
65    * thing this method can produce.
66    */
67   NS_IMETHOD AppendDocumentStart(nsIDocument *aDocument,
68                                  nsAString& aStr) = 0;
69 };
70 
71 NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentSerializer, NS_ICONTENTSERIALIZER_IID)
72 
73 #define NS_CONTENTSERIALIZER_CONTRACTID_PREFIX \
74 "@mozilla.org/layout/contentserializer;1?mimetype="
75 
76 #endif /* nsIContentSerializer_h */
77