aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/document.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-11-26 18:47:16 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-11-26 18:59:52 -0500
commit96aad50340b4d0374979ac981cd1c481cc8dcd94 (patch)
treed378d53debce57c1d60498d08ff8a537c9e0b313 /ext/fg/js/document.js
parentc2ff25b0ec2fdb8764a5e9994c1e37bfed7f05c6 (diff)
Create DOM utility file
Diffstat (limited to 'ext/fg/js/document.js')
-rw-r--r--ext/fg/js/document.js19
1 files changed, 2 insertions, 17 deletions
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