From 82ca56eba98a0927cd63ffd2c388bed56d492377 Mon Sep 17 00:00:00 2001 From: Mark Capella Date: Mon, 28 Apr 2014 20:21:19 -0400 Subject: [PATCH] Bug 864582 - (p0) Rename _sendMouseEvents method to _moveCaret, r=margaret --- .../chrome/content/SelectionHandler.js | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/mobile/android/chrome/content/SelectionHandler.js b/mobile/android/chrome/content/SelectionHandler.js index c3ae399f1279..eb6d0af72484 100644 --- a/mobile/android/chrome/content/SelectionHandler.js +++ b/mobile/android/chrome/content/SelectionHandler.js @@ -147,9 +147,7 @@ var SelectionHandler = { // Ignore IMM composition notifications when caret movement starts this._ignoreCompositionChanges = true; - - // Send a click event to the text box, which positions the caret - this._sendMouseEvents(data.x, data.y); + this._moveCaret(data.x, data.y); // Move the handle directly under the caret this._positionHandles(); @@ -763,7 +761,7 @@ var SelectionHandler = { */ _moveSelection: function sh_moveSelection(aIsStartHandle, aX, aY) { // XXX We should be smarter about the coordinates we pass to caretPositionFromPoint, especially - // in editable targets. We should factor out the logic that's currently in _sendMouseEvents. + // in editable targets. We should factor out the logic that's currently in _moveCaret. let viewOffset = this._getViewOffset(); let caretPos = this._contentWindow.document.caretPositionFromPoint(aX - viewOffset.x, aY - viewOffset.y); if (!caretPos) { @@ -810,10 +808,7 @@ var SelectionHandler = { } }, - _sendMouseEvents: function sh_sendMouseEvents(aX, aY, useShift) { - // If we're positioning a cursor in an input field, make sure the handle - // stays within the bounds of the field - if (this._activeType == this.TYPE_CURSOR) { + _moveCaret: function sh_moveCaret(aX, aY) { // Get rect of text inside element let range = document.createRange(); range.selectNodeContents(this._targetElement.QueryInterface(Ci.nsIDOMNSEditableElement).editor.rootElement); @@ -853,13 +848,9 @@ var SelectionHandler = { aX = rect.x + rect.width; this._getSelectionController().scrollCharacter(true); } - } else if (this._activeType == this.TYPE_SELECTION) { - // Send mouse event 1px too high to prevent selection from entering the line below where it should be - aY -= 1; - } - this._domWinUtils.sendMouseEventToWindow("mousedown", aX, aY, 0, 0, useShift ? Ci.nsIDOMNSEvent.SHIFT_MASK : 0, true); - this._domWinUtils.sendMouseEventToWindow("mouseup", aX, aY, 0, 0, useShift ? Ci.nsIDOMNSEvent.SHIFT_MASK : 0, true); + this._domWinUtils.sendMouseEventToWindow("mousedown", aX, aY, 0, 0, 0, true); + this._domWinUtils.sendMouseEventToWindow("mouseup", aX, aY, 0, 0, 0, true); }, copySelection: function sh_copySelection() {