From 1b2c2dc75a062987f826ebb8100defa9eceb4435 Mon Sep 17 00:00:00 2001 From: Margaret Leibovic Date: Tue, 7 Aug 2012 11:20:11 -0700 Subject: [PATCH] Bug 778263 - Clean up SelectionHandler data when we bail in startSelection. r=mfinkle --- mobile/android/chrome/content/browser.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mobile/android/chrome/content/browser.js b/mobile/android/chrome/content/browser.js index cdcfefb1d4b8..19947abfd769 100644 --- a/mobile/android/chrome/content/browser.js +++ b/mobile/android/chrome/content/browser.js @@ -1683,13 +1683,14 @@ var SelectionHandler = { selectionController.wordMove(!this._isRTL, true); } catch(e) { // If we couldn't select the word at the given point, bail - Cu.reportError("Error selecting word: " + e); + this._cleanUp(); return; } // If there isn't an appropriate selection, bail if (!selection.rangeCount || !selection.getRangeAt(0) || !selection.toString().trim().length) { selection.collapseToStart(); + this._cleanUp(); return; } @@ -1838,13 +1839,17 @@ var SelectionHandler = { } } + this._cleanUp(); + + return selectedText; + }, + + _cleanUp: function sh_cleanUp() { this._view.removeEventListener("pagehide", this, false); this._view = null; this._target = null; this._isRTL = false; this.cache = null; - - return selectedText; }, _getViewOffset: function sh_getViewOffset() {