Bug 1125956 - Hack around the broken assumptions of Thunderbird about the HTML copy encoder by disabling the plaintext encoding detection logic. r=roc, a=lizzard
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 26 Feb 2015 14:34:09 -0500
changeset 249113 41929a7c55f522eda19dc56edc9dd7a4afa1880f
parent 249112 003b419b893f76e24261313e25d55a0b4bf44fc1
child 249114 10eff960b898760cb9eb11b01af8b8b240c5a18a
push id970
push userjryans@gmail.com
push dateTue, 10 Mar 2015 15:54:18 +0000
reviewersroc, lizzard
bugs1125956
milestone37.0
Bug 1125956 - Hack around the broken assumptions of Thunderbird about the HTML copy encoder by disabling the plaintext encoding detection logic. r=roc, a=lizzard
dom/base/nsDocumentEncoder.cpp
--- a/dom/base/nsDocumentEncoder.cpp
+++ b/dom/base/nsDocumentEncoder.cpp
@@ -1364,16 +1364,20 @@ nsHTMLCopyEncoder::SetSelection(nsISelec
   // here that multi-range selections are table cell selections, in which case
   // the common parent is somewhere in the table and we don't really care where.
   nsresult rv = aSelection->GetRangeAt(0, getter_AddRefs(range));
   NS_ENSURE_SUCCESS(rv, rv);
   if (!range)
     return NS_ERROR_NULL_POINTER;
   range->GetCommonAncestorContainer(getter_AddRefs(commonParent));
 
+  // Thunderbird's msg compose code abuses the HTML copy encoder and gets
+  // confused if mIsTextWidget ends up becoming true, so for now we skip
+  // this logic in Thunderbird.
+#ifndef MOZ_THUNDERBIRD
   for (nsCOMPtr<nsIContent> selContent(do_QueryInterface(commonParent));
        selContent;
        selContent = selContent->GetParent())
   {
     // checking for selection inside a plaintext form widget
     nsIAtom *atom = selContent->Tag();
     if (atom == nsGkAtoms::input ||
         atom == nsGkAtoms::textarea)
@@ -1390,24 +1394,25 @@ nsHTMLCopyEncoder::SetSelection(nsISelec
         if (textStyle->WhiteSpaceOrNewlineIsSignificant()) {
           // Copy as plaintext for all preformatted elements
           mIsTextWidget = true;
         }
         break;
       }
     }
   }
-  
+
   // normalize selection if we are not in a widget
   if (mIsTextWidget) 
   {
     mSelection = aSelection;
     mMimeType.AssignLiteral("text/plain");
     return NS_OK;
   }
+#endif
 
   // also consider ourselves in a text widget if we can't find an html document
   nsCOMPtr<nsIHTMLDocument> htmlDoc = do_QueryInterface(mDocument);
   if (!(htmlDoc && mDocument->IsHTML())) {
     mIsTextWidget = true;
     mSelection = aSelection;
     // mMimeType is set to text/plain when encoding starts.
     return NS_OK;