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 250238 41929a7c55f5
parent 250237 003b419b893f
child 250239 10eff960b898
push id4524
push userryanvm@gmail.com
push date2015-03-04 18:49 +0000
treeherdermozilla-beta@666a1aafecfd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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;