content/base/public/nsIDocumentEncoder.idl

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "nsISupports.idl"
michael@0 7
michael@0 8 interface nsIDOMDocument;
michael@0 9 interface nsIDOMRange;
michael@0 10 interface nsISelection;
michael@0 11 interface nsIDOMNode;
michael@0 12 interface nsIOutputStream;
michael@0 13
michael@0 14 %{ C++
michael@0 15 class nsINode;
michael@0 16 class nsIDocument;
michael@0 17 %}
michael@0 18 [ptr] native nsINodePtr(nsINode);
michael@0 19 [ptr] native nsIDocumentPtr(nsIDocument);
michael@0 20
michael@0 21 [scriptable, uuid(3d9371d8-a2ad-403e-8b0e-8885ad3562e3)]
michael@0 22 interface nsIDocumentEncoderNodeFixup : nsISupports
michael@0 23 {
michael@0 24 /**
michael@0 25 * Create a fixed up version of a node. This method is called before
michael@0 26 * each node in a document is about to be persisted. The implementor
michael@0 27 * may return a new node with fixed up attributes or null. If null is
michael@0 28 * returned the node should be used as-is.
michael@0 29 * @param aNode Node to fixup.
michael@0 30 * @param [OUT] aSerializeCloneKids True if the document encoder should
michael@0 31 * apply recursive serialization to the children of the fixed up node
michael@0 32 * instead of the children of the original node.
michael@0 33 * @return The resulting fixed up node.
michael@0 34 */
michael@0 35 nsIDOMNode fixupNode(in nsIDOMNode aNode, out boolean aSerializeCloneKids);
michael@0 36 };
michael@0 37
michael@0 38 [scriptable, uuid(1158bd7e-a08b-4ff6-9417-6f99144cfccc)]
michael@0 39 interface nsIDocumentEncoder : nsISupports
michael@0 40 {
michael@0 41 // Output methods flag bits. There are a frightening number of these,
michael@0 42 // because everyone wants something a little bit different
michael@0 43
michael@0 44
michael@0 45 /**
michael@0 46 * Output only the selection (as opposed to the whole document).
michael@0 47 */
michael@0 48 const unsigned long OutputSelectionOnly = (1 << 0);
michael@0 49
michael@0 50 /** Plaintext output: Convert html to plaintext that looks like the html.
michael@0 51 * Implies wrap (except inside <pre>), since html wraps.
michael@0 52 * HTML, XHTML and XML output: do prettyprinting, ignoring existing formatting.
michael@0 53 * XML output : it doesn't implicitly wrap
michael@0 54 */
michael@0 55 const unsigned long OutputFormatted = (1 << 1);
michael@0 56
michael@0 57 /** Don't do prettyprinting. Don't do any wrapping that's not in the existing
michael@0 58 * HTML/XML source. This option overrides OutputFormatted if both are set.
michael@0 59 * HTML/XHTML output: If neither are set, there won't be prettyprinting too, but
michael@0 60 * long lines will be wrapped.
michael@0 61 * Supported also in XML and Plaintext output.
michael@0 62 * @note This option does not affect entity conversion.
michael@0 63 */
michael@0 64 const unsigned long OutputRaw = (1 << 2);
michael@0 65
michael@0 66 /**
michael@0 67 * Do not print html head tags.
michael@0 68 * XHTML/HTML output only.
michael@0 69 */
michael@0 70 const unsigned long OutputBodyOnly = (1 << 3);
michael@0 71
michael@0 72 /**
michael@0 73 * Output as though the content is preformatted
michael@0 74 * (e.g. maybe it's wrapped in a PRE or PRE_WRAP style tag)
michael@0 75 * Plaintext output only.
michael@0 76 * XXXbz How does this interact with
michael@0 77 * OutputFormatted/OutputRaw/OutputPreformatted/OutputFormatFlowed?
michael@0 78 */
michael@0 79 const unsigned long OutputPreformatted = (1 << 4);
michael@0 80
michael@0 81 /**
michael@0 82 * Wrap even if we're not doing formatted output (e.g. for text fields).
michael@0 83 * Supported in XML, XHTML, HTML and Plaintext output.
michael@0 84 * Set implicitly in HTML/XHTML output when no OutputRaw.
michael@0 85 * Ignored when OutputRaw.
michael@0 86 * XXXLJ: set implicitly in HTML/XHTML output, to keep compatible behaviors
michael@0 87 * for old callers of this interface
michael@0 88 * XXXbz How does this interact with OutputFormatFlowed?
michael@0 89 */
michael@0 90 const unsigned long OutputWrap = (1 << 5);
michael@0 91
michael@0 92 /**
michael@0 93 * Output for format flowed (RFC 2646). This is used when converting
michael@0 94 * to text for mail sending. This differs just slightly
michael@0 95 * but in an important way from normal formatted, and that is that
michael@0 96 * lines are space stuffed. This can't (correctly) be done later.
michael@0 97 * PlainText output only.
michael@0 98 * XXXbz How does this interact with
michael@0 99 * OutputFormatted/OutputRaw/OutputPreformatted/OutputWrap?
michael@0 100 */
michael@0 101 const unsigned long OutputFormatFlowed = (1 << 6);
michael@0 102
michael@0 103 /**
michael@0 104 * Convert links, image src, and script src to absolute URLs when possible.
michael@0 105 * XHTML/HTML output only.
michael@0 106 */
michael@0 107 const unsigned long OutputAbsoluteLinks = (1 << 7);
michael@0 108
michael@0 109 /**
michael@0 110 * Attempt to encode entities standardized at W3C (HTML, MathML, etc).
michael@0 111 * This is a catch-all flag for documents with mixed contents. Beware of
michael@0 112 * interoperability issues. See below for other flags which might likely
michael@0 113 * do what you want.
michael@0 114 * HTML output only.
michael@0 115 */
michael@0 116 const unsigned long OutputEncodeW3CEntities = (1 << 8);
michael@0 117
michael@0 118 /**
michael@0 119 * LineBreak processing: if this flag is set than CR line breaks will
michael@0 120 * be written. If neither this nor OutputLFLineBreak is set, then we
michael@0 121 * will use platform line breaks. The combination of the two flags will
michael@0 122 * cause CRLF line breaks to be written.
michael@0 123 */
michael@0 124 const unsigned long OutputCRLineBreak = (1 << 9);
michael@0 125
michael@0 126 /**
michael@0 127 * LineBreak processing: if this flag is set than LF line breaks will
michael@0 128 * be written. If neither this nor OutputCRLineBreak is set, then we
michael@0 129 * will use platform line breaks. The combination of the two flags will
michael@0 130 * cause CRLF line breaks to be written.
michael@0 131 */
michael@0 132 const unsigned long OutputLFLineBreak = (1 << 10);
michael@0 133
michael@0 134 /**
michael@0 135 * Output the content of noscript elements (only for serializing
michael@0 136 * to plaintext).
michael@0 137 */
michael@0 138 const unsigned long OutputNoScriptContent = (1 << 11);
michael@0 139
michael@0 140 /**
michael@0 141 * Output the content of noframes elements (only for serializing
michael@0 142 * to plaintext). (Used only internally in the plain text serializer;
michael@0 143 * ignored if passed by the caller.)
michael@0 144 */
michael@0 145 const unsigned long OutputNoFramesContent = (1 << 12);
michael@0 146
michael@0 147 /**
michael@0 148 * Don't allow any formatting nodes (e.g. <br>, <b>) inside a <pre>.
michael@0 149 * This is used primarily by mail. XHTML/HTML output only.
michael@0 150 */
michael@0 151 const unsigned long OutputNoFormattingInPre = (1 << 13);
michael@0 152
michael@0 153 /**
michael@0 154 * Encode entities when outputting to a string.
michael@0 155 * E.g. If set, we'll output &nbsp; if clear, we'll output 0xa0.
michael@0 156 * The basic set is just &nbsp; &amp; &lt; &gt; &quot; for interoperability
michael@0 157 * with older products that don't support &alpha; and friends.
michael@0 158 * HTML output only.
michael@0 159 */
michael@0 160 const unsigned long OutputEncodeBasicEntities = (1 << 14);
michael@0 161
michael@0 162 /**
michael@0 163 * Encode entities when outputting to a string.
michael@0 164 * The Latin1 entity set additionally includes 8bit accented letters
michael@0 165 * between 128 and 255.
michael@0 166 * HTML output only.
michael@0 167 */
michael@0 168 const unsigned long OutputEncodeLatin1Entities = (1 << 15);
michael@0 169
michael@0 170 /**
michael@0 171 * Encode entities when outputting to a string.
michael@0 172 * The HTML entity set additionally includes accented letters, greek
michael@0 173 * letters, and other special markup symbols as defined in HTML4.
michael@0 174 * HTML output only.
michael@0 175 */
michael@0 176 const unsigned long OutputEncodeHTMLEntities = (1 << 16);
michael@0 177
michael@0 178 /**
michael@0 179 * Normally &nbsp; is replaced with a space character when
michael@0 180 * encoding data as plain text, set this flag if that's
michael@0 181 * not desired.
michael@0 182 * Plaintext output only.
michael@0 183 */
michael@0 184 const unsigned long OutputPersistNBSP = (1 << 17);
michael@0 185
michael@0 186 /**
michael@0 187 * Normally when serializing the whole document using the HTML or
michael@0 188 * XHTML serializer, the encoding declaration is rewritten to match.
michael@0 189 * This flag suppresses that behavior.
michael@0 190 */
michael@0 191 const unsigned long OutputDontRewriteEncodingDeclaration = (1 << 18);
michael@0 192
michael@0 193 /**
michael@0 194 * When using the HTML or XHTML serializer, skip elements that are not
michael@0 195 * visible when this flag is set. Elements are not visible when they
michael@0 196 * have CSS style display:none or visibility:collapse, for example.
michael@0 197 */
michael@0 198 const unsigned long SkipInvisibleContent = (1 << 19);
michael@0 199
michael@0 200 /**
michael@0 201 * Output for delsp=yes (RFC 3676). This is used with OutputFormatFlowed
michael@0 202 * when converting to text for mail sending.
michael@0 203 * PlainText output only.
michael@0 204 */
michael@0 205 const unsigned long OutputFormatDelSp = (1 << 20);
michael@0 206
michael@0 207 /**
michael@0 208 * Drop <br> elements considered "invisible" by the editor. OutputPreformatted
michael@0 209 * implies this flag.
michael@0 210 */
michael@0 211 const unsigned long OutputDropInvisibleBreak = (1 << 21);
michael@0 212
michael@0 213 /**
michael@0 214 * Don't check for _moz_dirty attributes when deciding whether to
michael@0 215 * pretty-print if this flag is set (bug 599983).
michael@0 216 */
michael@0 217 const unsigned long OutputIgnoreMozDirty = (1 << 22);
michael@0 218
michael@0 219 /**
michael@0 220 * Output the content of non-text elements as the placehodler character
michael@0 221 * U+FFFC (OBJECT REPLACEMENT CHARACTER, only for serializing to plaintext).
michael@0 222 */
michael@0 223 const unsigned long OutputNonTextContentAsPlaceholder = (1 << 23);
michael@0 224
michael@0 225 /**
michael@0 226 * Don't Strip ending spaces from a line (only for serializing to plaintext).
michael@0 227 */
michael@0 228 const unsigned long OutputDontRemoveLineEndingSpaces = (1 << 24);
michael@0 229
michael@0 230 /**
michael@0 231 * Initialize with a pointer to the document and the mime type.
michael@0 232 * @param aDocument Document to encode.
michael@0 233 * @param aMimeType MimeType to use. May also be set by SetMimeType.
michael@0 234 * @param aFlags Flags to use while encoding. May also be set by SetFlags.
michael@0 235 */
michael@0 236 void init(in nsIDOMDocument aDocument,
michael@0 237 in AString aMimeType,
michael@0 238 in unsigned long aFlags);
michael@0 239 [noscript] void nativeInit(in nsIDocumentPtr aDocument,
michael@0 240 in AString aMimeType,
michael@0 241 in unsigned long aFlags);
michael@0 242
michael@0 243 /**
michael@0 244 * If the selection is set to a non-null value, then the
michael@0 245 * selection is used for encoding, otherwise the entire
michael@0 246 * document is encoded.
michael@0 247 * @param aSelection The selection to encode.
michael@0 248 */
michael@0 249 void setSelection(in nsISelection aSelection);
michael@0 250
michael@0 251 /**
michael@0 252 * If the range is set to a non-null value, then the
michael@0 253 * range is used for encoding, otherwise the entire
michael@0 254 * document or selection is encoded.
michael@0 255 * @param aRange The range to encode.
michael@0 256 */
michael@0 257 void setRange(in nsIDOMRange aRange);
michael@0 258
michael@0 259 /**
michael@0 260 * If the node is set to a non-null value, then the
michael@0 261 * node is used for encoding, otherwise the entire
michael@0 262 * document or range or selection is encoded.
michael@0 263 * @param aNode The node to encode.
michael@0 264 */
michael@0 265 void setNode(in nsIDOMNode aNode);
michael@0 266 [noscript] void setNativeNode(in nsINodePtr aNode);
michael@0 267
michael@0 268 /**
michael@0 269 * If the container is set to a non-null value, then its
michael@0 270 * child nodes are used for encoding, otherwise the entire
michael@0 271 * document or range or selection or node is encoded.
michael@0 272 * @param aContainer The node which child nodes will be encoded.
michael@0 273 */
michael@0 274 void setContainerNode(in nsIDOMNode aContainer);
michael@0 275 [noscript] void setNativeContainerNode(in nsINodePtr aContainer);
michael@0 276
michael@0 277 /**
michael@0 278 * Documents typically have an intrinsic character set,
michael@0 279 * but if no intrinsic value is found, the platform character set
michael@0 280 * is used. This function overrides both the intrinisc and platform
michael@0 281 * charset.
michael@0 282 * @param aCharset Overrides the both the intrinsic or platform
michael@0 283 * character set when encoding the document.
michael@0 284 *
michael@0 285 * Possible result codes: NS_ERROR_NO_CHARSET_CONVERTER
michael@0 286 */
michael@0 287 void setCharset(in ACString aCharset);
michael@0 288
michael@0 289 /**
michael@0 290 * Set a wrap column. This may have no effect in some types of encoders.
michael@0 291 * @param aWrapColumn Column to which to wrap.
michael@0 292 */
michael@0 293 void setWrapColumn(in unsigned long aWrapColumn);
michael@0 294
michael@0 295 /**
michael@0 296 * The mime type preferred by the encoder. This piece of api was
michael@0 297 * added because the copy encoder may need to switch mime types on you
michael@0 298 * if you ask it to copy html that really represents plaintext content.
michael@0 299 * Call this AFTER Init() and SetSelection() have both been called.
michael@0 300 */
michael@0 301 readonly attribute AString mimeType;
michael@0 302
michael@0 303 /**
michael@0 304 * Encode the document and send the result to the nsIOutputStream.
michael@0 305 *
michael@0 306 * Possible result codes are the stream errors which might have
michael@0 307 * been encountered.
michael@0 308 * @param aStream Stream into which to encode.
michael@0 309 */
michael@0 310 void encodeToStream(in nsIOutputStream aStream);
michael@0 311
michael@0 312 /**
michael@0 313 * Encode the document into a string.
michael@0 314 *
michael@0 315 * @return The document encoded into a string.
michael@0 316 */
michael@0 317 AString encodeToString();
michael@0 318
michael@0 319 /**
michael@0 320 * Encode the document into a string. Stores the extra context information
michael@0 321 * into the two arguments.
michael@0 322 * @param [OUT] aContextString The string where the parent hierarchy
michael@0 323 * information will be stored.
michael@0 324 * @param [OUT] aInfoString The string where extra context info will
michael@0 325 * be stored.
michael@0 326 * @return The document encoded as a string.
michael@0 327 *
michael@0 328 */
michael@0 329 AString encodeToStringWithContext( out AString aContextString,
michael@0 330 out AString aInfoString);
michael@0 331
michael@0 332 /**
michael@0 333 * Encode the document into a string of limited size.
michael@0 334 * @param aMaxLength After aMaxLength characters, the encoder will stop
michael@0 335 * encoding new data.
michael@0 336 * Only values > 0 will be considered.
michael@0 337 * The returned string may be slightly larger than
michael@0 338 * aMaxLength because some serializers (eg. HTML)
michael@0 339 * may need to close some tags after they stop
michael@0 340 * encoding new data, or finish a line (72 columns
michael@0 341 * by default for the plain text serializer).
michael@0 342 *
michael@0 343 * @return The document encoded into a string.
michael@0 344 */
michael@0 345 AString encodeToStringWithMaxLength(in unsigned long aMaxLength);
michael@0 346
michael@0 347 /**
michael@0 348 * Set the fixup object associated with node persistence.
michael@0 349 * @param aFixup The fixup object.
michael@0 350 */
michael@0 351 void setNodeFixup(in nsIDocumentEncoderNodeFixup aFixup);
michael@0 352 };

mercurial