Omit containsPoint check on searchAt
The range returned by docRangeFromPoint is now guaranteed to contain the point due to the addition of isPointInRange checks.
This commit is contained in:
parent
4ac55da7dd
commit
5c793180d0
@ -286,7 +286,7 @@ class Frontend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const textSource = docRangeFromPoint(point, this.options);
|
const textSource = docRangeFromPoint(point, this.options);
|
||||||
let hideResults = !textSource || !textSource.containsPoint(point);
|
let hideResults = textSource === null;
|
||||||
let searched = false;
|
let searched = false;
|
||||||
let success = false;
|
let success = false;
|
||||||
|
|
||||||
|
@ -59,11 +59,6 @@ class TextSourceRange {
|
|||||||
return length - state.remainder;
|
return length - state.remainder;
|
||||||
}
|
}
|
||||||
|
|
||||||
containsPoint(point) {
|
|
||||||
const rect = this.getPaddedRect();
|
|
||||||
return point.x >= rect.left && point.x <= rect.right;
|
|
||||||
}
|
|
||||||
|
|
||||||
getRect() {
|
getRect() {
|
||||||
return this.range.getBoundingClientRect();
|
return this.range.getBoundingClientRect();
|
||||||
}
|
}
|
||||||
@ -72,18 +67,6 @@ class TextSourceRange {
|
|||||||
return TextSourceRange.getElementWritingMode(TextSourceRange.getParentElement(this.range.startContainer));
|
return TextSourceRange.getElementWritingMode(TextSourceRange.getParentElement(this.range.startContainer));
|
||||||
}
|
}
|
||||||
|
|
||||||
getPaddedRect() {
|
|
||||||
const range = this.range.cloneRange();
|
|
||||||
const startOffset = range.startOffset;
|
|
||||||
const endOffset = range.endOffset;
|
|
||||||
const node = range.startContainer;
|
|
||||||
|
|
||||||
range.setStart(node, Math.max(0, startOffset - 1));
|
|
||||||
range.setEnd(node, Math.min(node.length, endOffset + 1));
|
|
||||||
|
|
||||||
return range.getBoundingClientRect();
|
|
||||||
}
|
|
||||||
|
|
||||||
select() {
|
select() {
|
||||||
const selection = window.getSelection();
|
const selection = window.getSelection();
|
||||||
selection.removeAllRanges();
|
selection.removeAllRanges();
|
||||||
@ -290,11 +273,6 @@ class TextSourceElement {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
containsPoint(point) {
|
|
||||||
const rect = this.getRect();
|
|
||||||
return point.x >= rect.left && point.x <= rect.right;
|
|
||||||
}
|
|
||||||
|
|
||||||
getRect() {
|
getRect() {
|
||||||
return this.element.getBoundingClientRect();
|
return this.element.getBoundingClientRect();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user