mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 865356 - Restrict caret move coords within text inputs when invoking text selection. r=mbrubeck
This commit is contained in:
parent
c0edb4439d
commit
f0048f6c2c
@ -323,7 +323,14 @@ var SelectionHandler = {
|
||||
this._onFail("Unexpected, caret position isn't supported with non-inputs.");
|
||||
return;
|
||||
}
|
||||
let cp = this._contentWindow.document.caretPositionFromPoint(aX, aY);
|
||||
|
||||
// SelectionHelperUI sends text input tap coordinates and a caret move
|
||||
// event at the start of a monocle drag. caretPositionFromPoint isn't
|
||||
// going to give us correct info if the coord is outside the edit bounds,
|
||||
// so restrict the coordinates before we call cpfp.
|
||||
let containedCoords = this._restrictCoordinateToEditBounds(aX, aY);
|
||||
let cp = this._contentWindow.document.caretPositionFromPoint(containedCoords.xPos,
|
||||
containedCoords.yPos);
|
||||
let input = cp.offsetNode;
|
||||
let offset = cp.offset;
|
||||
input.selectionStart = input.selectionEnd = offset;
|
||||
@ -603,6 +610,24 @@ var SelectionHandler = {
|
||||
this._cache.caret.yPos = bounds.bottom;
|
||||
},
|
||||
|
||||
_restrictCoordinateToEditBounds: function _restrictCoordinateToEditBounds(aX, aY) {
|
||||
let result = {
|
||||
xPos: aX,
|
||||
yPos: aY
|
||||
};
|
||||
if (!this._targetIsEditable)
|
||||
return result;
|
||||
let bounds = this._getTargetBrowserRect();
|
||||
if (aX <= bounds.left)
|
||||
result.xPos = bounds.left + 1;
|
||||
if (aX >= bounds.right)
|
||||
result.xPos = bounds.right - 1;
|
||||
if (aY <= bounds.top)
|
||||
result.yPos = bounds.top + 1;
|
||||
if (aY >= bounds.bottom)
|
||||
result.yPos = bounds.bottom - 1;
|
||||
},
|
||||
|
||||
/*
|
||||
* _handleSelectionPoint(aMarker, aPoint, aEndOfSelection)
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user