summaryrefslogtreecommitdiff
path: root/ext/fg
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg')
-rw-r--r--ext/fg/float.html1
-rw-r--r--ext/fg/js/document.js19
-rw-r--r--ext/fg/js/frontend.js14
3 files changed, 4 insertions, 30 deletions
diff --git a/ext/fg/float.html b/ext/fg/float.html
index e04c1402..38439c79 100644
--- a/ext/fg/float.html
+++ b/ext/fg/float.html
@@ -32,6 +32,7 @@
</div>
<script src="/mixed/js/core.js"></script>
+ <script src="/mixed/js/dom.js"></script>
<script src="/fg/js/api.js"></script>
<script src="/fg/js/util.js"></script>
diff --git a/ext/fg/js/document.js b/ext/fg/js/document.js
index 8161c85a..3dd12a40 100644
--- a/ext/fg/js/document.js
+++ b/ext/fg/js/document.js
@@ -223,7 +223,7 @@ function isPointInRange(x, y, range) {
const {node, offset, content} = TextSourceRange.seekForward(range.endContainer, range.endOffset, 1);
range.setEnd(node, offset);
- if (!isWhitespace(content) && isPointInAnyRect(x, y, range.getClientRects())) {
+ if (!isWhitespace(content) && DOM.isPointInAnyRect(x, y, range.getClientRects())) {
return true;
}
} finally {
@@ -234,7 +234,7 @@ function isPointInRange(x, y, range) {
const {node, offset, content} = TextSourceRange.seekBackward(range.startContainer, range.startOffset, 1);
range.setStart(node, offset);
- if (!isWhitespace(content) && isPointInAnyRect(x, y, range.getClientRects())) {
+ if (!isWhitespace(content) && DOM.isPointInAnyRect(x, y, range.getClientRects())) {
// This purposefully leaves the starting offset as modified and sets the range length to 0.
range.setEnd(node, offset);
return true;
@@ -248,21 +248,6 @@ function isWhitespace(string) {
return string.trim().length === 0;
}
-function isPointInAnyRect(x, y, rects) {
- for (const rect of rects) {
- if (isPointInRect(x, y, rect)) {
- return true;
- }
- }
- return false;
-}
-
-function isPointInRect(x, y, rect) {
- return (
- x >= rect.left && x < rect.right &&
- y >= rect.top && y < rect.bottom);
-}
-
const caretRangeFromPoint = (() => {
if (typeof document.caretRangeFromPoint === 'function') {
// Chrome, Edge
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index 6002dfcb..81c159db 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -159,7 +159,7 @@ class Frontend {
this.preventNextClick = false;
const primaryTouch = e.changedTouches[0];
- if (Frontend.selectionContainsPoint(window.getSelection(), primaryTouch.clientX, primaryTouch.clientY)) {
+ if (DOM.isPointInSelection(primaryTouch.clientX, primaryTouch.clientY, window.getSelection())) {
return;
}
@@ -456,18 +456,6 @@ class Frontend {
return -1;
}
- static selectionContainsPoint(selection, x, y) {
- for (let i = 0; i < selection.rangeCount; ++i) {
- const range = selection.getRangeAt(i);
- for (const rect of range.getClientRects()) {
- if (x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom) {
- return true;
- }
- }
- }
- return false;
- }
-
setTextSourceScanLength(textSource, length) {
textSource.setEndOffset(length);
if (this.ignoreNodes === null || !textSource.range) {