mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 951943 - SelectionHandler._updateCacheForSelection() Error: TypeError: rects[0] is undefined, r=margaret
This commit is contained in:
parent
ee6b3dbd97
commit
1e39c5d4da
@ -125,23 +125,36 @@ var SelectionHandler = {
|
||||
this._ignoreSelectionChanges = true;
|
||||
// Check to see if the handles should be reversed.
|
||||
let isStartHandle = JSON.parse(aData).handleType == this.HANDLE_TYPE_START;
|
||||
let selectionReversed = this._updateCacheForSelection(isStartHandle);
|
||||
if (selectionReversed) {
|
||||
// Reverse the anchor and focus to correspond to the new start and end handles.
|
||||
let selection = this._getSelection();
|
||||
let anchorNode = selection.anchorNode;
|
||||
let anchorOffset = selection.anchorOffset;
|
||||
selection.collapse(selection.focusNode, selection.focusOffset);
|
||||
selection.extend(anchorNode, anchorOffset);
|
||||
|
||||
try {
|
||||
let selectionReversed = this._updateCacheForSelection(isStartHandle);
|
||||
if (selectionReversed) {
|
||||
// Reverse the anchor and focus to correspond to the new start and end handles.
|
||||
let selection = this._getSelection();
|
||||
let anchorNode = selection.anchorNode;
|
||||
let anchorOffset = selection.anchorOffset;
|
||||
selection.collapse(selection.focusNode, selection.focusOffset);
|
||||
selection.extend(anchorNode, anchorOffset);
|
||||
}
|
||||
} catch (e) {
|
||||
// User finished handle positioning with one end off the screen
|
||||
this._closeSelection();
|
||||
break;
|
||||
}
|
||||
|
||||
// Act on selectionChange notifications after handle movement ends
|
||||
this._ignoreSelectionChanges = false;
|
||||
this._positionHandles();
|
||||
|
||||
} else if (this._activeType == this.TYPE_CURSOR) {
|
||||
// Act on IMM composition notifications after caret movement ends
|
||||
this._ignoreCompositionChanges = false;
|
||||
this._positionHandles();
|
||||
|
||||
} else {
|
||||
Cu.reportError("Ignored \"TextSelection:Position\" message during invalid selection status");
|
||||
}
|
||||
this._positionHandles();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -743,8 +756,12 @@ var SelectionHandler = {
|
||||
// Returns true if the selection has been reversed. Takes optional aIsStartHandle
|
||||
// param to decide whether the selection has been reversed.
|
||||
_updateCacheForSelection: function sh_updateCacheForSelection(aIsStartHandle) {
|
||||
let selection = this._getSelection();
|
||||
let rects = selection.getRangeAt(0).getClientRects();
|
||||
let rects = this._getSelection().getRangeAt(0).getClientRects();
|
||||
if (!rects[0]) {
|
||||
// nsISelection object exists, but there's nothing actually selected
|
||||
throw "Failed to update cache for invalid selection";
|
||||
}
|
||||
|
||||
let start = { x: this._isRTL ? rects[0].right : rects[0].left, y: rects[0].bottom };
|
||||
let end = { x: this._isRTL ? rects[rects.length - 1].left : rects[rects.length - 1].right, y: rects[rects.length - 1].bottom };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user