Bug 1921551 - React to sync sign in flow correctly r=android-reviewers,matt-tighe
[gecko.git] / dom / serializers / nsIDocumentEncoder.idl
blob76f5974c83085cf077ac5f42c3dd30ade9f042f7
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/. */
6 #include "nsISupports.idl"
8 interface nsIOutputStream;
10 webidl Document;
11 webidl Node;
12 webidl Range;
13 webidl Selection;
15 %{ C++
16 class nsINode;
19 [ptr] native nsINodePtr(nsINode);
21 [scriptable, uuid(3d9371d8-a2ad-403e-8b0e-8885ad3562e3)]
22 interface nsIDocumentEncoderNodeFixup : nsISupports
24 /**
25 * Create a fixed up version of a node. This method is called before
26 * each node in a document is about to be persisted. The implementor
27 * may return a new node with fixed up attributes or null. If null is
28 * returned the node should be used as-is.
29 * @param aNode Node to fixup.
30 * @param [OUT] aSerializeCloneKids True if the document encoder should
31 * apply recursive serialization to the children of the fixed up node
32 * instead of the children of the original node.
33 * @return The resulting fixed up node.
35 Node fixupNode(in Node aNode, out boolean aSerializeCloneKids);
38 [scriptable, uuid(21f112df-d96f-47da-bfcb-5331273003d1)]
39 interface nsIDocumentEncoder : nsISupports
41 // Output methods flag bits. There are a frightening number of these,
42 // because everyone wants something a little bit different
45 /**
46 * Output only the selection (as opposed to the whole document).
48 const unsigned long OutputSelectionOnly = (1 << 0);
50 /**
51 * Plaintext output:
52 * - Convert html to plaintext that looks like the html.
53 * - Can't be used in conjunction with `OutputPreformatted`.
54 * - Implies wrap (except inside <pre>), since html wraps.
55 * HTML and XHTML output:
56 * - Do prettyprinting, ignoring existing formatting.
57 * - Implies wrap (except in attribute values and inside <pre>).
58 * XML output:
59 * - Do prettyprinting, ignoring existing formatting.
60 * - Doesn't implicitly wrap
62 * If `OutputFormatFlowed` is set, exactly one of `OutputFormatted`
63 * or `OutputWrap` must be set as well.
65 const unsigned long OutputFormatted = (1 << 1);
67 /** Don't do prettyprinting. Don't do any wrapping that's not in the existing
68 * HTML/XML source. This option overrides OutputFormatted if both are set.
69 * HTML/XHTML output: If neither are set, there won't be prettyprinting too, but
70 * long lines will be wrapped.
71 * Supported also in XML and Plaintext output.
72 * @note This option does not affect entity conversion.
74 const unsigned long OutputRaw = (1 << 2);
76 /**
77 * Do not print html head tags.
78 * XHTML/HTML output only.
80 const unsigned long OutputBodyOnly = (1 << 3);
82 /**
83 * Output as though the content is preformatted
84 * (e.g. maybe it's wrapped in a PRE or PRE_WRAP style tag)
85 * Plaintext output only.
86 * Can't be used together with `OutputFormatted`/`OutputFormatFlowed`.
87 * XXXbz How does this interact with OutputRaw?
89 const unsigned long OutputPreformatted = (1 << 4);
91 /**
92 * Wrap even if we're not doing formatted output (e.g. for text fields).
93 * Supported in XML, XHTML, HTML and Plaintext output.
94 * Set implicitly in HTML/XHTML output when no OutputRaw.
95 * Ignored when OutputRaw.
96 * For XML, XHTML and HTML: does not wrap values in attributes.
98 * If `OutputFormatFlowed` is set, exactly one of `OutputFormatted`
99 * or `OutputWrap` must be set as well.
101 * XXXLJ: set implicitly in HTML/XHTML output, to keep compatible behaviors
102 * for old callers of this interface
104 const unsigned long OutputWrap = (1 << 5);
107 * Output for format flowed (RFC 2646). This is used when converting
108 * to text for mail sending. This differs just slightly
109 * but in an important way from normal formatted, and that is that
110 * lines are space stuffed. This can't (correctly) be done later.
111 * PlainText output only.
113 * If this flag is set, exactly one of `OutputFormatted` or `OutputWrap`
114 * must be set as well.
116 * XXXbz: How does this interact with OutputRaw?
118 const unsigned long OutputFormatFlowed = (1 << 6);
121 * Convert links, image src, and script src to absolute URLs when possible.
122 * XHTML/HTML output only.
124 const unsigned long OutputAbsoluteLinks = (1 << 7);
127 * LineBreak processing: if this flag is set than CR line breaks will
128 * be written. If neither this nor OutputLFLineBreak is set, then we
129 * will use platform line breaks. The combination of the two flags will
130 * cause CRLF line breaks to be written.
132 const unsigned long OutputCRLineBreak = (1 << 9);
135 * LineBreak processing: if this flag is set than LF line breaks will
136 * be written. If neither this nor OutputCRLineBreak is set, then we
137 * will use platform line breaks. The combination of the two flags will
138 * cause CRLF line breaks to be written.
140 const unsigned long OutputLFLineBreak = (1 << 10);
143 * Output the content of noscript elements (only for serializing
144 * to plaintext).
146 const unsigned long OutputNoScriptContent = (1 << 11);
149 * Output the content of noframes elements (only for serializing
150 * to plaintext). (Used only internally in the plain text serializer;
151 * ignored if passed by the caller.)
153 const unsigned long OutputNoFramesContent = (1 << 12);
156 * Don't allow any formatting nodes (e.g. <br>, <b>) inside a <pre>.
157 * This is used primarily by mail. XHTML/HTML output only.
159 const unsigned long OutputNoFormattingInPre = (1 << 13);
162 * Encode entities when outputting to a string.
163 * E.g. If set, we'll output &nbsp; if clear, we'll output 0xa0.
164 * The basic set is just &nbsp; &amp; &lt; &gt; &quot; for interoperability
165 * with older products that don't support &alpha; and friends.
166 * HTML output only.
168 const unsigned long OutputEncodeBasicEntities = (1 << 14);
171 * Normally &nbsp; is replaced with a space character when
172 * encoding data as plain text, set this flag if that's
173 * not desired.
174 * Plaintext output only.
176 const unsigned long OutputPersistNBSP = (1 << 17);
179 * Normally when serializing the whole document using the HTML or
180 * XHTML serializer, the encoding declaration is rewritten to match.
181 * This flag suppresses that behavior.
183 const unsigned long OutputDontRewriteEncodingDeclaration = (1 << 18);
186 * When using the HTML or XHTML serializer, skip elements that are not
187 * visible when this flag is set. Elements are not visible when they
188 * have CSS style display:none or visibility:collapse, for example.
190 const unsigned long SkipInvisibleContent = (1 << 19);
193 * Output for delsp=yes (RFC 3676). This is used with OutputFormatFlowed
194 * when converting to text for mail sending.
195 * PlainText output only.
197 const unsigned long OutputFormatDelSp = (1 << 20);
200 * Drop <br> elements considered "invisible" by the editor. OutputPreformatted
201 * implies this flag.
203 const unsigned long OutputDropInvisibleBreak = (1 << 21);
206 * Don't check for _moz_dirty attributes when deciding whether to
207 * pretty-print if this flag is set (bug 599983).
209 const unsigned long OutputIgnoreMozDirty = (1 << 22);
212 * Serialize in a way that is suitable for copying a plaintext version of the
213 * document to the clipboard. This can for example cause line endings to be
214 * injected at preformatted block element boundaries.
216 const unsigned long OutputForPlainTextClipboardCopy = (1 << 25);
219 * Include ruby annotations and ruby parentheses in the output.
220 * PlainText output only.
222 const unsigned long OutputRubyAnnotation = (1 << 26);
225 * Disallow breaking of long character strings. This is important
226 * for serializing e-mail which contains CJK strings. These must
227 * not be broken just as "normal" longs strings aren't broken.
229 const unsigned long OutputDisallowLineBreaking = (1 << 27);
232 * Release reference of Document after using encodeTo* method to recycle
233 * this encoder without holding Document. To use this encoder again,
234 * we have to call init again.
236 const unsigned long RequiresReinitAfterOutput = (1 << 28);
238 const unsigned long AllowCrossShadowBoundary = (1 << 29);
240 * Initialize with a pointer to the document and the mime type.
241 * Resets wrap column to 72 and resets node fixup.
242 * @param aDocument Document to encode.
243 * @param aMimeType MimeType to use. May also be set by SetMimeType.
244 * @param aFlags Flags to use while encoding. May also be set by SetFlags.
246 void init(in Document aDocument,
247 in AString aMimeType,
248 in unsigned long aFlags);
249 [noscript] void nativeInit(in Document aDocument,
250 in AString aMimeType,
251 in unsigned long aFlags);
254 * If the selection is set to a non-null value, then the
255 * selection is used for encoding, otherwise the entire
256 * document is encoded.
257 * @param aSelection The selection to encode.
259 void setSelection(in Selection aSelection);
262 * If the range is set to a non-null value, then the
263 * range is used for encoding, otherwise the entire
264 * document or selection is encoded.
265 * @param aRange The range to encode.
267 void setRange(in Range aRange);
270 * If the node is set to a non-null value, then the
271 * node is used for encoding, otherwise the entire
272 * document or range or selection is encoded.
273 * @param aNode The node to encode.
275 void setNode(in Node aNode);
278 * If the container is set to a non-null value, then its
279 * child nodes are used for encoding, otherwise the entire
280 * document or range or selection or node is encoded.
281 * @param aContainer The node which child nodes will be encoded.
283 void setContainerNode(in Node aContainer);
286 * Documents typically have an intrinsic character set,
287 * but if no intrinsic value is found, the platform character set
288 * is used. This function overrides both the intrinisc and platform
289 * charset.
290 * @param aCharset Overrides the both the intrinsic or platform
291 * character set when encoding the document.
293 * Possible result codes: NS_ERROR_NO_CHARSET_CONVERTER
295 void setCharset(in ACString aCharset);
298 * Set a wrap column. This may have no effect in some types of encoders.
299 * @param aWrapColumn Column to which to wrap. If 0, wrapping is disabled.
301 void setWrapColumn(in unsigned long aWrapColumn);
304 * The mime type preferred by the encoder. This piece of api was
305 * added because the copy encoder may need to switch mime types on you
306 * if you ask it to copy html that really represents plaintext content.
307 * Call this AFTER Init() and SetSelection() have both been called.
309 readonly attribute AString mimeType;
312 * Encode the document and send the result to the nsIOutputStream.
314 * Possible result codes are the stream errors which might have
315 * been encountered.
316 * @param aStream Stream into which to encode.
318 void encodeToStream(in nsIOutputStream aStream);
321 * Encode the document into a string.
323 * @return The document encoded into a string.
325 AString encodeToString();
328 * Encode the document into a string. Stores the extra context information
329 * into the two arguments.
330 * @param [OUT] aContextString The string where the parent hierarchy
331 * information will be stored.
332 * @param [OUT] aInfoString The string where extra context info will
333 * be stored.
334 * @return The document encoded as a string.
337 AString encodeToStringWithContext( out AString aContextString,
338 out AString aInfoString);
341 * Encode the document into a string of limited size.
342 * @param aMaxLength After aMaxLength characters, the encoder will stop
343 * encoding new data.
344 * Only values > 0 will be considered.
345 * The returned string may be slightly larger than
346 * aMaxLength because some serializers (eg. HTML)
347 * may need to close some tags after they stop
348 * encoding new data, or finish a line (72 columns
349 * by default for the plain text serializer).
351 * @return The document encoded into a string.
353 AString encodeToStringWithMaxLength(in unsigned long aMaxLength);
356 * Set the fixup object associated with node persistence.
357 * @param aFixup The fixup object.
359 void setNodeFixup(in nsIDocumentEncoderNodeFixup aFixup);
362 %{ C++
363 template<class T> struct already_AddRefed;
365 bool
366 do_getDocumentTypeSupportedForEncoding(const char* aContentType);
367 already_AddRefed<nsIDocumentEncoder>
368 do_createDocumentEncoder(const char* aContentType);
369 already_AddRefed<nsIDocumentEncoder>
370 do_createHTMLCopyEncoder();