From 6e8df6adb8e5b71d179602c4451a09db74a289d0 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Tue, 14 Mar 2006 17:12:41 +0000 Subject: [PATCH] nsIDocumentEncoder should be IDL-ized. Bug 305710, patch by jpl24 , r=sicking, sr=bzbarsky --- content/base/public/Makefile.in | 2 +- content/base/public/nsContentCID.h | 14 + content/base/public/nsIDocumentEncoder.h | 273 ----------------- content/base/public/nsIDocumentEncoder.idl | 282 ++++++++++++++++++ content/base/src/nsContentAreaDragDrop.cpp | 5 +- content/base/src/nsCopySupport.cpp | 5 +- content/base/src/nsDocumentEncoder.cpp | 24 +- editor/libeditor/html/nsHTMLDataTransfer.cpp | 2 +- .../text/nsPlaintextDataTransfer.cpp | 2 +- editor/libeditor/text/nsPlaintextEditor.cpp | 2 +- .../src/nsWebBrowserPersist.cpp | 1 + .../xmlextras/base/src/nsDOMSerializer.cpp | 1 + 12 files changed, 320 insertions(+), 293 deletions(-) delete mode 100644 content/base/public/nsIDocumentEncoder.h create mode 100644 content/base/public/nsIDocumentEncoder.idl diff --git a/content/base/public/Makefile.in b/content/base/public/Makefile.in index 8d3160d4a312..cfb09f4d0a23 100644 --- a/content/base/public/Makefile.in +++ b/content/base/public/Makefile.in @@ -54,7 +54,6 @@ nsContentErrors.h \ nsContentPolicyUtils.h \ nsContentUtils.h \ nsIDocument.h \ -nsIDocumentEncoder.h \ nsIDocumentObserver.h \ nsIDOMGCParticipant.h \ nsINameSpaceManager.h \ @@ -83,6 +82,7 @@ SDK_XPIDLSRCS = \ XPIDLSRCS = \ nsIChromeRegistry.idl \ nsIContentPolicy.idl \ + nsIDocumentEncoder.idl \ nsISelectionController.idl \ nsISelectionDisplay.idl \ nsISelectionListener.idl \ diff --git a/content/base/public/nsContentCID.h b/content/base/public/nsContentCID.h index ae72aa0fd493..583c6e6a8977 100644 --- a/content/base/public/nsContentCID.h +++ b/content/base/public/nsContentCID.h @@ -42,6 +42,12 @@ #include "nsIFactory.h" #include "nsIComponentManager.h" +#define NS_DOC_ENCODER_CONTRACTID_BASE \ +"@mozilla.org/layout/documentEncoder;1?type=" + +#define NS_HTMLCOPY_ENCODER_CONTRACTID \ +"@mozilla.org/layout/htmlCopyEncoder;1" + // {1691E1F7-EE41-11d4-9885-00C04FA0CF4B} #define NS_STYLESET_CID \ { 0x1691e1f7, 0xee41, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } } @@ -82,6 +88,14 @@ 0xe11a6080, 0x4daa, 0x11d2, \ {0xb3, 0x28, 0x00, 0x80, 0x5f, 0x8a, 0x38, 0x59}} +// {e7ba1480-1dea-11d3-830f-00104bed045e} +#define NS_TEXT_ENCODER_CID \ +{ 0xe7ba1480, 0x1dea, 0x11d3, {0x83, 0x0f, 0x00, 0x10, 0x4b, 0xed, 0x04, 0x5e} } + + // {7f915b01-98fc-11d4-8eb0-a803f80ff1bc} +#define NS_HTMLCOPY_TEXT_ENCODER_CID \ +{ 0x7f915b01, 0x98fc, 0x11d4, { 0x8e, 0xb0, 0xa8, 0x03, 0xf8, 0x0f, 0xf1, 0xbc } } + // {A1FDE864-E802-11d4-9885-00C04FA0CF4B} #define NS_HTMLHRELEMENT_CID \ { 0xa1fde864, 0xe802, 0x11d4, { 0x98, 0x85, 0x0, 0xc0, 0x4f, 0xa0, 0xcf, 0x4b } } diff --git a/content/base/public/nsIDocumentEncoder.h b/content/base/public/nsIDocumentEncoder.h deleted file mode 100644 index a66955b1924d..000000000000 --- a/content/base/public/nsIDocumentEncoder.h +++ /dev/null @@ -1,273 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsIDocumentEncoder_h__ -#define nsIDocumentEncoder_h__ - -#include "nsISupports.h" -#include "nsStringGlue.h" - -class nsIDocumentEncoder; -class nsIDocument; -class nsIDOMRange; -class nsISelection; -class nsIOutputStream; -class nsISupportsArray; -class nsIDOMNode; - - -#define NS_IDOCUMENT_ENCODER_IID \ -{ /* a6cf9103-15b3-11d2-932e-00805f8add32 */ \ - 0xa6cf9103, \ - 0x15b3, \ - 0x11d2, \ - {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} \ - } - -#define NS_TEXT_ENCODER_CID \ -{ /* e7ba1480-1dea-11d3-830f-00104bed045e */ \ - 0xe7ba1480, \ - 0x1dea, \ - 0x11d3, \ - {0x83, 0x0f, 0x00, 0x10, 0x4b, 0xed, 0x04, 0x5e} \ -} - -#define NS_DOC_ENCODER_CONTRACTID_BASE "@mozilla.org/layout/documentEncoder;1?type=" - -// {7f915b01-98fc-11d4-8eb0-a803f80ff1bc} -#define NS_HTMLCOPY_TEXT_ENCODER_CID \ -{ 0x7f915b01, 0x98fc, 0x11d4, { 0x8e, 0xb0, 0xa8, 0x03, 0xf8, 0x0f, 0xf1, 0xbc } } - -// {0BC1FAC0-B710-11d4-959F-0020183BF181} -#define NS_IDOCUMENTENCODERNODEFIXUP_IID \ -{ 0xbc1fac0, 0xb710, 0x11d4, { 0x95, 0x9f, 0x0, 0x20, 0x18, 0x3b, 0xf1, 0x81 } } - -#define NS_HTMLCOPY_ENCODER_CONTRACTID "@mozilla.org/layout/htmlCopyEncoder;1" - -class nsIDocumentEncoderNodeFixup : public nsISupports -{ -public: - - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOCUMENTENCODERNODEFIXUP_IID) - - /** - * Create a fixed up version of a node. This method is called before - * each node in a document is about to be persisted. The implementor - * may return a new node with fixed up attributes or nsnull. - */ - NS_IMETHOD FixupNode(nsIDOMNode *aNode, nsIDOMNode **aOutNode) = 0; -}; - -NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentEncoderNodeFixup, - NS_IDOCUMENTENCODERNODEFIXUP_IID) - -class nsIDocumentEncoder : public nsISupports -{ -public: - - NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDOCUMENT_ENCODER_IID) - - /** - * Output methods flag bits. - * - * There are a frightening number of these, - * because everyone wants something a little bit different! - * - * These should move to an idl file so that Javascript can - * have access to the symbols, not just the constants. - */ - enum { - // Output only the selection (as opposed to the whole document). - OutputSelectionOnly = 1, - - // Plaintext output: Convert html to plaintext that looks like the html. - // Implies wrap (except inside
), since html wraps.
-    // HTML output: always do prettyprinting, ignoring existing formatting.
-    // (Probably not well tested for HTML output.)
-    OutputFormatted     = 2,
-
-    // Don't do prettyprinting of HTML.  Don't do any wrapping that's not in
-    // the existing HTML source.  This option overrides OutputFormatted if both
-    // are set.  Note that this option does not affect entity conversion.
-    OutputRaw           = 4,
-
-    // No html head tags
-    OutputBodyOnly      = 8,
-
-    // Wrap even if we're not doing formatted output (e.g. for text fields)
-    // XXXbz this doesn't seem to be used by all serializers... document?  How
-    // does this interact with
-    // OutputFormatted/OutputRaw/OutputWrap/OutputFormatFlowed?
-    OutputPreformatted  = 16,
-
-    // Output as though the content is preformatted
-    // (e.g. maybe it's wrapped in a MOZ_PRE or MOZ_PRE_WRAP style tag)
-    // XXXbz this doesn't seem to be used by all serializers... document?  How
-    // does this interact with
-    // OutputFormatted/OutputRaw/OutputPreformatted/OutputFormatFlowed?
-    OutputWrap          = 32,
-
-    // Output for format flowed (RFC 2646). This is used when converting
-    // to text for mail sending. This differs just slightly
-    // but in an important way from normal formatted, and that is that
-    // lines are space stuffed. This can't (correctly) be done later.
-    // XXXbz this doesn't seem to be used by all serializers... document?  How
-    // does this interact with
-    // OutputFormatted/OutputRaw/OutputPreformatted/OutputWrap?
-    OutputFormatFlowed  = 64,
-
-    // Convert links, image src, and script src to absolute URLs when possible
-    OutputAbsoluteLinks = 128,
-
-    // Attempt to encode entities standardized at W3C (HTML, MathML, etc).
-    // This is a catch-all flag for documents with mixed contents. Beware of
-    // interoperability issues. See below for other flags which might likely
-    // do what you want.
-    OutputEncodeW3CEntities = 256,
-
-    // LineBreak processing: we can do either platform line breaks,
-    // CR, LF, or CRLF.  If neither of these flags is set, then we
-    // will use platform line breaks.
-    OutputCRLineBreak = 512,
-    OutputLFLineBreak = 1024,
-
-    // Output the content of noscript elements (only for serializing
-    // to plaintext).
-    OutputNoScriptContent = 2048,
-
-    // Output the content of noframes elements (only for serializing
-    // to plaintext).
-    OutputNoFramesContent = 4096,
-
-    // Don't allow any formatting nodes (e.g. 
, ) inside a
.
-    // This is used primarily by mail.
-    OutputNoFormattingInPre = 8192,
-
-    // Encode entities when outputting to a string.
-    // E.g. If set, we'll output   if clear, we'll output 0xa0.
-    // The basic set is just   & < > " for interoperability
-    // with older products that don't support α and friends.
-    // The Latin1 entity set additionally includes 8bit accented letters
-    // between 128 and 255.
-    // The HTML entity set additionally includes accented letters, greek
-    // letters, and other special markup symbols as defined in HTML4.
-    OutputEncodeBasicEntities = 16384,
-    OutputEncodeLatin1Entities = 32768,
-    OutputEncodeHTMLEntities = 65536
-  };
-
-  /**
-   *  Initialize with a pointer to the document and the mime type.
-   */
-  NS_IMETHOD Init(nsIDocument* aDocument, const nsAString& aMimeType,
-                  PRUint32 flags) = 0;
-
-  /**
-   *  If the selection is set to a non-null value, then the
-   *  selection is used for encoding, otherwise the entire
-   *  document is encoded.
-   */
-  NS_IMETHOD SetSelection(nsISelection* aSelection) = 0;
-
-  /**
-   *  If the range is set to a non-null value, then the
-   *  range is used for encoding, otherwise the entire
-   *  document or selection is encoded.
-   */
-  NS_IMETHOD SetRange(nsIDOMRange* aRange) = 0;
-
-  /**
-   *  If the node is set to a non-null value, then the
-   *  node is used for encoding, otherwise the entire
-   *  document or range or selection is encoded.
-   */
-  NS_IMETHOD SetNode(nsIDOMNode* aNode) = 0;
-
-  /**
-   *  Documents typically have an intrinsic character set.
-   *  If no intrinsic value is found, the platform character set
-   *  is used.
-   *  aCharset overrides the both the intrinsic or platform
-   *  character set when encoding the document.
-   *
-   *  Possible result codes: NS_ERROR_NO_CHARSET_CONVERTER
-   */
-  NS_IMETHOD SetCharset(const nsACString& aCharset) = 0;
-
-  /**
-   *  Set a wrap column.  This may have no effect in some types of encoders.
-   */
-  NS_IMETHOD SetWrapColumn(PRUint32 aWC) = 0;
-
-  /**
-   *  Get the mime type preferred by the encoder.  This piece of api was
-   *  added because the copy encoder may need to switch mime types on you
-   *  if you ask it to copy html that really represents plaintext content.
-   *  Call this AFTER Init() and SetSelection() have both been called.
-   */
-  NS_IMETHOD GetMimeType(nsAString& aMimeType) = 0;
-  
-  /**
-   *  The document is encoded, the result is sent to the 
-   *  to nsIOutputStream.
-   * 
-   *  Possible result codes are passing along whatever stream errors
-   *  might have been encountered.
-   */
-  NS_IMETHOD EncodeToStream(nsIOutputStream* aStream) = 0;
-  NS_IMETHOD EncodeToString(nsAString& aOutputString) = 0;
-
-  /**
-   *  The document is encoded, the result is sent to the 
-   *  to aEncodedString.  Parent heirarchy information is encoded
-   *  to aContextString.  Extra context info is encoded in aInfoString.
-   * 
-   */
-  NS_IMETHOD EncodeToStringWithContext(nsAString& aEncodedString, 
-                                       nsAString& aContextString, 
-                                       nsAString& aInfoString) = 0;
-
-  /**
-   * Set the fixup object associated with node persistence.
-   */
-  NS_IMETHOD SetNodeFixup(nsIDocumentEncoderNodeFixup *aFixup) = 0;
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentEncoder, NS_IDOCUMENT_ENCODER_IID)
-
-#endif /* nsIDocumentEncoder_h__ */
-
diff --git a/content/base/public/nsIDocumentEncoder.idl b/content/base/public/nsIDocumentEncoder.idl
new file mode 100644
index 000000000000..2d849c29609d
--- /dev/null
+++ b/content/base/public/nsIDocumentEncoder.idl
@@ -0,0 +1,282 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+* 
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * the Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2006
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Josh Lurz 
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "nsISupports.idl"
+
+interface nsIDocument;
+interface nsIDOMRange;
+interface nsISelection;
+interface nsIDOMNode;
+interface nsIOutputStream;
+
+[scriptable, uuid(cfc33b4f-6ba0-11da-9531-00e08161165f)]
+interface nsIDocumentEncoderNodeFixup : nsISupports
+{
+  /**
+   * Create a fixed up version of a node. This method is called before
+   * each node in a document is about to be persisted. The implementor
+   * may return a new node with fixed up attributes or null. If null is
+   * returned the node should be used as-is.
+   * @param aNode Node to fixup.
+   * @return The resulting fixed up node.
+   */
+  nsIDOMNode fixupNode(in nsIDOMNode aNode);
+};
+
+[scriptable, uuid(ea9f3938-6ba0-11da-9531-00e08161165f)]
+interface nsIDocumentEncoder : nsISupports
+{
+  // Output methods flag bits. There are a frightening number of these,
+  // because everyone wants something a little bit different
+   
+
+  /** 
+   * Output only the selection (as opposed to the whole document).
+   */
+  const unsigned long OutputSelectionOnly = (1 << 0);
+
+  /** Plaintext output: Convert html to plaintext that looks like the html.
+    * Implies wrap (except inside 
), since html wraps.
+    * HTML output: always do prettyprinting, ignoring existing formatting.
+    * (Probably not well tested for HTML output.)
+    */
+  const unsigned long OutputFormatted     = (1 << 1);
+
+  /** Don't do prettyprinting of HTML.  Don't do any wrapping that's not in
+   * the existing HTML source.  This option overrides OutputFormatted if both
+   * are set.
+   * @note This option does not affect entity conversion.
+   */
+  const unsigned long OutputRaw           = (1 << 2);
+
+  /** 
+   * Do not print html head tags.
+   */
+  const unsigned long OutputBodyOnly      = (1 << 3);
+
+  /**
+   * Wrap even if we're not doing formatted output (e.g. for text fields)
+   * XXXbz this doesn't seem to be used by all serializers... document?  How
+   * does this interact with
+   * OutputFormatted/OutputRaw/OutputWrap/OutputFormatFlowed?
+   */
+  const unsigned long OutputPreformatted  = (1 << 4);
+
+  /**
+   * Output as though the content is preformatted
+   * (e.g. maybe it's wrapped in a MOZ_PRE or MOZ_PRE_WRAP style tag)
+   * XXXbz this doesn't seem to be used by all serializers... document?  How
+   * does this interact with
+   * OutputFormatted/OutputRaw/OutputPreformatted/OutputFormatFlowed?
+   */
+  const unsigned long OutputWrap          = (1 << 5);
+
+  /**
+   * Output for format flowed (RFC 2646). This is used when converting
+   * to text for mail sending. This differs just slightly
+   * but in an important way from normal formatted, and that is that
+   * lines are space stuffed. This can't (correctly) be done later.
+   * XXXbz this doesn't seem to be used by all serializers... document?  How
+   * does this interact with
+   * OutputFormatted/OutputRaw/OutputPreformatted/OutputWrap?
+   */
+  const unsigned long OutputFormatFlowed  = (1 << 6);
+
+  /**
+   * Convert links, image src, and script src to absolute URLs when possible
+   */
+  const unsigned long OutputAbsoluteLinks = (1 << 7);
+
+  /**
+   * Attempt to encode entities standardized at W3C (HTML, MathML, etc).
+   * This is a catch-all flag for documents with mixed contents. Beware of
+   * interoperability issues. See below for other flags which might likely
+   * do what you want.
+   */
+  const unsigned long OutputEncodeW3CEntities = (1 << 8);
+
+  /** 
+   * LineBreak processing: if this flag is set than CR line breaks will
+   * be written. If neither this nor OutputLFLineBreak is set, then we
+   * will use platform line breaks. The combination of the two flags will
+   * cause CRLF line breaks to be written.
+   */
+  const unsigned long OutputCRLineBreak = (1 << 9);
+
+  /** 
+   * LineBreak processing: if this flag is set than LF line breaks will
+   * be written. If neither this nor OutputCRLineBreak is set, then we
+   * will use platform line breaks. The combination of the two flags will
+   * cause CRLF line breaks to be written.
+   */
+  const unsigned long OutputLFLineBreak = (1 << 10);
+
+  /**
+   * Output the content of noscript elements (only for serializing
+   * to plaintext).
+   */
+  const unsigned long OutputNoScriptContent = (1 << 11);
+
+  /**
+   * Output the content of noframes elements (only for serializing
+   * to plaintext).
+   */
+  const unsigned long OutputNoFramesContent = (1 << 12);
+
+  /**
+   * Don't allow any formatting nodes (e.g. 
, ) inside a
.
+   * This is used primarily by mail.
+   */
+  const unsigned long OutputNoFormattingInPre = (1 << 13);
+
+  /**
+   * Encode entities when outputting to a string.
+   * E.g. If set, we'll output   if clear, we'll output 0xa0.
+   * The basic set is just   & < > " for interoperability
+   * with older products that don't support α and friends.
+   */
+  const unsigned long OutputEncodeBasicEntities = (1 << 14);
+    
+  /**
+   * Encode entities when outputting to a string.
+   * The Latin1 entity set additionally includes 8bit accented letters
+   * between 128 and 255.
+   */
+  const unsigned long OutputEncodeLatin1Entities = (1 << 15);
+  
+  /**
+   * Encode entities when outputting to a string.
+   * The HTML entity set additionally includes accented letters, greek
+   * letters, and other special markup symbols as defined in HTML4.
+   */
+  const unsigned long OutputEncodeHTMLEntities = (1 << 16);
+
+  /**
+   * Initialize with a pointer to the document and the mime type.
+   * @param aDocument Document to encode.
+   * @param aMimeType MimeType to use. May also be set by SetMimeType.
+   * @param aFlags Flags to use while encoding. May also be set by SetFlags.
+   * XXXjlurz Change nsIDocument to nsIDOMDocument and make this scriptable.
+   */
+  [noscript] void init(in nsIDocument aDocument, in AString aMimeType, in unsigned long aFlags);
+
+  /**
+   *  If the selection is set to a non-null value, then the
+   *  selection is used for encoding, otherwise the entire
+   *  document is encoded.
+   * @param aSelection The selection to encode.
+   */
+  void setSelection(in nsISelection aSelection);
+
+  /**
+   *  If the range is set to a non-null value, then the
+   *  range is used for encoding, otherwise the entire
+   *  document or selection is encoded.
+   * @param aRange The range to encode.
+   */
+  void setRange(in nsIDOMRange aRange);
+
+  /**
+   *  If the node is set to a non-null value, then the
+   *  node is used for encoding, otherwise the entire
+   *  document or range or selection is encoded.
+   * @param aNode The node to encode.
+   */
+  void setNode(in nsIDOMNode aNode);
+
+  /**
+   *  Documents typically have an intrinsic character set,
+   *  but if no intrinsic value is found, the platform character set
+   *  is used. This function overrides both the intrinisc and platform
+   *  charset.
+   *  @param aCharset Overrides the both the intrinsic or platform
+   *  character set when encoding the document.
+   *
+   *  Possible result codes: NS_ERROR_NO_CHARSET_CONVERTER
+   */
+  void setCharset(in ACString aCharset);
+
+  /**
+   *  Set a wrap column.  This may have no effect in some types of encoders.
+   * @param aWrapColumn Column to which to wrap.
+   */
+  void setWrapColumn(in unsigned long aWrapColumn);
+
+  /**
+   *  The mime type preferred by the encoder.  This piece of api was
+   *  added because the copy encoder may need to switch mime types on you
+   *  if you ask it to copy html that really represents plaintext content.
+   *  Call this AFTER Init() and SetSelection() have both been called.
+   */
+  readonly attribute AString mimeType;
+  
+  /**
+   *  Encode the document and send the result to the nsIOutputStream.
+   *
+   *  Possible result codes are the stream errors which might have
+   *  been encountered.
+   * @param aStream Stream into which to encode.
+   */
+  void encodeToStream(in nsIOutputStream aStream);
+
+  /**
+   * Encode the document into a string.
+   *
+   * @return The document encoded into a string.
+   */
+  AString encodeToString();
+
+  /**
+   * Encode the document into a string. Stores the extra context information
+   * into the two arguments.
+   * @param [OUT] aContextString The string where the parent heirarchy
+   *              information will be stored.
+   * @param [OUT] aInfoString The string where extra context info will
+   *              be stored.
+   * @return The document encoded as a string.
+   * 
+   */
+  AString encodeToStringWithContext( out AString aContextString,
+                                     out AString aInfoString);
+
+  /**
+   * Set the fixup object associated with node persistence.
+   * @param aFixup The fixup object.
+   */
+  void setNodeFixup(in nsIDocumentEncoderNodeFixup aFixup);
+};
diff --git a/content/base/src/nsContentAreaDragDrop.cpp b/content/base/src/nsContentAreaDragDrop.cpp
index a6b4424a0c5b..dad177781247 100644
--- a/content/base/src/nsContentAreaDragDrop.cpp
+++ b/content/base/src/nsContentAreaDragDrop.cpp
@@ -99,6 +99,7 @@
 #include "nsContentUtils.h"
 #include "nsIMIMEService.h"
 #include "imgIRequest.h"
+#include "nsContentCID.h"
 
 // private clipboard data flavors for html copy, used by editor when pasting
 #define kHTMLContext   "text/_moz_htmlcontext"
@@ -1742,6 +1743,6 @@ nsTransferableFactory::SerializeNodeOrSelection(serializationMode inMode,
     return encoder->EncodeToString(outResultString);
   }
 
-  return encoder->EncodeToStringWithContext(outResultString, outContext,
-                                            outInfo);
+  return encoder->EncodeToStringWithContext(outContext, outInfo,
+                                            outResultString);
 }
diff --git a/content/base/src/nsCopySupport.cpp b/content/base/src/nsCopySupport.cpp
index 48fc0806fe40..941efd55e4c0 100644
--- a/content/base/src/nsCopySupport.cpp
+++ b/content/base/src/nsCopySupport.cpp
@@ -67,6 +67,7 @@
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIImage.h"
 #include "nsContentUtils.h"
+#include "nsContentCID.h"
 
 static NS_DEFINE_CID(kCClipboardCID,           NS_CLIPBOARD_CID);
 static NS_DEFINE_CID(kCTransferableCID,        NS_TRANSFERABLE_CID);
@@ -151,7 +152,7 @@ nsresult nsCopySupport::HTMLCopy(nsISelection *aSel, nsIDocument *aDoc, PRInt16
     NS_ENSURE_SUCCESS(rv, rv);
 
     // encode the selection as html with contextual info
-    rv = docEncoder->EncodeToStringWithContext(buffer, parents, info);
+    rv = docEncoder->EncodeToStringWithContext(parents, info, buffer);
     NS_ENSURE_SUCCESS(rv, rv);
   }
   
@@ -516,7 +517,7 @@ static nsresult AppendDOMNode(nsITransferable *aTransferable,
 
   // serialize to string
   nsAutoString html, context, info;
-  rv = docEncoder->EncodeToStringWithContext(html, context, info);
+  rv = docEncoder->EncodeToStringWithContext(context, info, html);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // copy them to the transferable
diff --git a/content/base/src/nsDocumentEncoder.cpp b/content/base/src/nsDocumentEncoder.cpp
index 2cd296150423..523b2926a13c 100644
--- a/content/base/src/nsDocumentEncoder.cpp
+++ b/content/base/src/nsDocumentEncoder.cpp
@@ -101,9 +101,9 @@ public:
   NS_IMETHOD GetMimeType(nsAString& aMimeType);
   NS_IMETHOD EncodeToStream(nsIOutputStream* aStream);
   NS_IMETHOD EncodeToString(nsAString& aOutputString);
-  NS_IMETHOD EncodeToStringWithContext(nsAString& aEncodedString, 
-                                       nsAString& aContextString,
-                                       nsAString& aInfoString);
+  NS_IMETHOD EncodeToStringWithContext(nsAString& aContextString,
+                                       nsAString& aInfoString,
+                                       nsAString& aEncodedString);
   NS_IMETHOD SetNodeFixup(nsIDocumentEncoderNodeFixup *aFixup);
                                        
 protected:
@@ -968,9 +968,9 @@ nsDocumentEncoder::EncodeToStream(nsIOutputStream* aStream)
 }
 
 NS_IMETHODIMP
-nsDocumentEncoder::EncodeToStringWithContext(nsAString& aEncodedString, 
-                                             nsAString& aContextString,
-                                             nsAString& aInfoString)
+nsDocumentEncoder::EncodeToStringWithContext(nsAString& aContextString,
+                                             nsAString& aInfoString,
+                                             nsAString& aEncodedString)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
@@ -1006,9 +1006,9 @@ public:
 
   // overridden methods from nsDocumentEncoder
   NS_IMETHOD SetSelection(nsISelection* aSelection);
-  NS_IMETHOD EncodeToStringWithContext(nsAString& aEncodedString, 
-                                       nsAString& aContextString,
-                                       nsAString& aInfoString);
+  NS_IMETHOD EncodeToStringWithContext(nsAString& aContextString,
+                                       nsAString& aInfoString,
+                                       nsAString& aEncodedString);
 
 protected:
 
@@ -1186,9 +1186,9 @@ nsHTMLCopyEncoder::SetSelection(nsISelection* aSelection)
 }
 
 NS_IMETHODIMP
-nsHTMLCopyEncoder::EncodeToStringWithContext(nsAString& aEncodedString, 
-                                             nsAString& aContextString,
-                                             nsAString& aInfoString)
+nsHTMLCopyEncoder::EncodeToStringWithContext(nsAString& aContextString,
+                                             nsAString& aInfoString,
+                                             nsAString& aEncodedString)
 {
   nsresult rv = EncodeToString(aEncodedString);
   NS_ENSURE_SUCCESS(rv, rv);
diff --git a/editor/libeditor/html/nsHTMLDataTransfer.cpp b/editor/libeditor/html/nsHTMLDataTransfer.cpp
index f5b25564879b..865246b401b4 100644
--- a/editor/libeditor/html/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/html/nsHTMLDataTransfer.cpp
@@ -1683,7 +1683,7 @@ nsHTMLEditor::PutDragDataInTransferable(nsITransferable **aTransferable)
   if (!bIsPlainTextControl)
   {
     // encode the selection as html with contextual info
-    rv = docEncoder->EncodeToStringWithContext(buffer, parents, info);
+    rv = docEncoder->EncodeToStringWithContext(parents, info, buffer);
     if (NS_FAILED(rv)) return rv;
   }
   else
diff --git a/editor/libeditor/text/nsPlaintextDataTransfer.cpp b/editor/libeditor/text/nsPlaintextDataTransfer.cpp
index cc54ab584f0a..ed7a4c930e65 100644
--- a/editor/libeditor/text/nsPlaintextDataTransfer.cpp
+++ b/editor/libeditor/text/nsPlaintextDataTransfer.cpp
@@ -63,7 +63,7 @@
 
 // Misc
 #include "nsEditorUtils.h"
-
+#include "nsContentCID.h"
 
 NS_IMETHODIMP nsPlaintextEditor::PrepareTransferable(nsITransferable **transferable)
 {
diff --git a/editor/libeditor/text/nsPlaintextEditor.cpp b/editor/libeditor/text/nsPlaintextEditor.cpp
index baa6262063a9..8f04df45879e 100644
--- a/editor/libeditor/text/nsPlaintextEditor.cpp
+++ b/editor/libeditor/text/nsPlaintextEditor.cpp
@@ -75,7 +75,7 @@
 #include "nsIPrefBranch.h"
 #include "nsIPrefService.h"
 #include "nsUnicharUtils.h"
-
+#include "nsContentCID.h"
 #include "nsAOLCiter.h"
 #include "nsInternetCiter.h"
 
diff --git a/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp b/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp
index 3ce8cf69f161..745281784e1c 100644
--- a/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp
+++ b/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp
@@ -60,6 +60,7 @@
 #include "nsCRT.h"
 #include "nsSupportsArray.h"
 #include "nsInt64.h"
+#include "nsContentCID.h"
 #include "nsStreamUtils.h"
 
 #include "nsCExternalHandlerService.h"
diff --git a/extensions/xmlextras/base/src/nsDOMSerializer.cpp b/extensions/xmlextras/base/src/nsDOMSerializer.cpp
index b2ef3a82e70e..8eac659810d5 100644
--- a/extensions/xmlextras/base/src/nsDOMSerializer.cpp
+++ b/extensions/xmlextras/base/src/nsDOMSerializer.cpp
@@ -47,6 +47,7 @@
 #include "nsIContentSerializer.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
+#include "nsContentCID.h"
 
 #include "nsIJSContextStack.h"
 #include "nsIScriptSecurityManager.h"