aboutsummaryrefslogtreecommitdiff
path: root/ext/fg
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-09-03 19:15:34 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-09-03 19:17:50 -0400
commit5c793180d04e6b5eafaf01c823f5f5e07639cfa9 (patch)
treeea54398b570663db96719247ca3104b748aaa200 /ext/fg
parent4ac55da7dd5354e6c3495f04583352d0d863b7b6 (diff)
Omit containsPoint check on searchAt
The range returned by docRangeFromPoint is now guaranteed to contain the point due to the addition of isPointInRange checks.
Diffstat (limited to 'ext/fg')
-rw-r--r--ext/fg/js/frontend.js2
-rw-r--r--ext/fg/js/source.js22
2 files changed, 1 insertions, 23 deletions
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index 8a5c48d0..39403bbd 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -286,7 +286,7 @@ class Frontend {
}
const textSource = docRangeFromPoint(point, this.options);
- let hideResults = !textSource || !textSource.containsPoint(point);
+ let hideResults = textSource === null;
let searched = false;
let success = false;
diff --git a/ext/fg/js/source.js b/ext/fg/js/source.js
index e724488d..1febab7e 100644
--- a/ext/fg/js/source.js
+++ b/ext/fg/js/source.js
@@ -59,11 +59,6 @@ class TextSourceRange {
return length - state.remainder;
}
- containsPoint(point) {
- const rect = this.getPaddedRect();
- return point.x >= rect.left && point.x <= rect.right;
- }
-
getRect() {
return this.range.getBoundingClientRect();
}
@@ -72,18 +67,6 @@ class TextSourceRange {
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() {
const selection = window.getSelection();
selection.removeAllRanges();
@@ -290,11 +273,6 @@ class TextSourceElement {
return 0;
}
- containsPoint(point) {
- const rect = this.getRect();
- return point.x >= rect.left && point.x <= rect.right;
- }
-
getRect() {
return this.element.getBoundingClientRect();
}