Bug 864582 - (p0) Rename _sendMouseEvents method to _moveCaret, r=margaret

This commit is contained in:
Mark Capella 2014-04-28 20:21:19 -04:00
Родитель ae1acf42df
Коммит 82ca56eba9
1 изменённых файлов: 5 добавлений и 14 удалений

Просмотреть файл

@ -147,9 +147,7 @@ var SelectionHandler = {
// Ignore IMM composition notifications when caret movement starts // Ignore IMM composition notifications when caret movement starts
this._ignoreCompositionChanges = true; this._ignoreCompositionChanges = true;
this._moveCaret(data.x, data.y);
// Send a click event to the text box, which positions the caret
this._sendMouseEvents(data.x, data.y);
// Move the handle directly under the caret // Move the handle directly under the caret
this._positionHandles(); this._positionHandles();
@ -763,7 +761,7 @@ var SelectionHandler = {
*/ */
_moveSelection: function sh_moveSelection(aIsStartHandle, aX, aY) { _moveSelection: function sh_moveSelection(aIsStartHandle, aX, aY) {
// XXX We should be smarter about the coordinates we pass to caretPositionFromPoint, especially // 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 viewOffset = this._getViewOffset();
let caretPos = this._contentWindow.document.caretPositionFromPoint(aX - viewOffset.x, aY - viewOffset.y); let caretPos = this._contentWindow.document.caretPositionFromPoint(aX - viewOffset.x, aY - viewOffset.y);
if (!caretPos) { if (!caretPos) {
@ -810,10 +808,7 @@ var SelectionHandler = {
} }
}, },
_sendMouseEvents: function sh_sendMouseEvents(aX, aY, useShift) { _moveCaret: function sh_moveCaret(aX, aY) {
// 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) {
// Get rect of text inside element // Get rect of text inside element
let range = document.createRange(); let range = document.createRange();
range.selectNodeContents(this._targetElement.QueryInterface(Ci.nsIDOMNSEditableElement).editor.rootElement); range.selectNodeContents(this._targetElement.QueryInterface(Ci.nsIDOMNSEditableElement).editor.rootElement);
@ -853,13 +848,9 @@ var SelectionHandler = {
aX = rect.x + rect.width; aX = rect.x + rect.width;
this._getSelectionController().scrollCharacter(true); 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("mousedown", aX, aY, 0, 0, 0, true);
this._domWinUtils.sendMouseEventToWindow("mouseup", aX, aY, 0, 0, useShift ? Ci.nsIDOMNSEvent.SHIFT_MASK : 0, true); this._domWinUtils.sendMouseEventToWindow("mouseup", aX, aY, 0, 0, 0, true);
}, },
copySelection: function sh_copySelection() { copySelection: function sh_copySelection() {