Bug 938563 - Select all + copy on textarea doesn't copy linebreaks. r=margaret, a=bajaj
authorMark Capella <markcapella@twcny.rr.com>
Wed, 20 Nov 2013 13:57:20 -0500
changeset 166579 b9bc63061c9c2c4826ee087e13ca58783eaa659a
parent 166578 8bd6eb01394e2f5e1f9c3df06c428513884ef817
child 166580 c61b077e100a7faff3290c813081967c973017f3
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret, bajaj
bugs938563
milestone27.0a2
Bug 938563 - Select all + copy on textarea doesn't copy linebreaks. r=margaret, a=bajaj
mobile/android/chrome/content/SelectionHandler.js
--- a/mobile/android/chrome/content/SelectionHandler.js
+++ b/mobile/android/chrome/content/SelectionHandler.js
@@ -317,19 +317,25 @@ var SelectionHandler = {
       return this._contentWindow.getSelection();
   },
 
   _getSelectedText: function sh_getSelectedText() {
     if (!this._contentWindow)
       return "";
 
     let selection = this._getSelection();
-    if (selection)
-      return selection.toString().trim();
-    return "";
+    if (!selection)
+      return "";
+
+    if (this._targetElement instanceof Ci.nsIDOMHTMLTextAreaElement) {
+      return selection.QueryInterface(Ci.nsISelectionPrivate).
+        toStringWithFormat("text/plain", Ci.nsIDocumentEncoder.OutputPreformatted | Ci.nsIDocumentEncoder.OutputRaw, 0);
+    }
+
+    return selection.toString().trim();
   },
 
   _getSelectionController: function sh_getSelectionController() {
     if (this._targetElement instanceof Ci.nsIDOMNSEditableElement)
       return this._targetElement.QueryInterface(Ci.nsIDOMNSEditableElement).editor.selectionController;
     else
       return this._contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).
                                  getInterface(Ci.nsIWebNavigation).