From 8f4ee1cb7d86b5a8a5bd575b4a5e13f54430e2a8 Mon Sep 17 00:00:00 2001 From: Mark Capella Date: Wed, 20 Nov 2013 13:57:20 -0500 Subject: [PATCH] Bug 938563 - Select all + copy on textarea doesn't copy linebreaks, r=margaret --- mobile/android/chrome/content/SelectionHandler.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mobile/android/chrome/content/SelectionHandler.js b/mobile/android/chrome/content/SelectionHandler.js index 777048e6d7d..91f2873e1df 100644 --- a/mobile/android/chrome/content/SelectionHandler.js +++ b/mobile/android/chrome/content/SelectionHandler.js @@ -331,9 +331,15 @@ var SelectionHandler = { 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() {