diff options
Diffstat (limited to 'ext/fg/js/document.js')
-rw-r--r-- | ext/fg/js/document.js | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/ext/fg/js/document.js b/ext/fg/js/document.js index a168705e..10dea7df 100644 --- a/ext/fg/js/document.js +++ b/ext/fg/js/document.js @@ -17,7 +17,7 @@ */ -const REGEX_TRANSPARENT_COLOR = /rgba\s*\([^\)]*,\s*0(?:\.0+)?\s*\)/; +const REGEX_TRANSPARENT_COLOR = /rgba\s*\([^)]*,\s*0(?:\.0+)?\s*\)/; function docSetImposterStyle(style, propertyName, value) { style.setProperty(propertyName, value, 'important'); @@ -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 @@ -359,7 +344,7 @@ function isElementTransparent(element) { } const style = window.getComputedStyle(element); return ( - parseFloat(style.opacity) < 0 || + parseFloat(style.opacity) <= 0 || style.visibility === 'hidden' || (style.backgroundImage === 'none' && isColorTransparent(style.backgroundColor)) ); |