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