summaryrefslogtreecommitdiff
path: root/ext/fg/js/frontend.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/js/frontend.js')
-rw-r--r--ext/fg/js/frontend.js63
1 files changed, 10 insertions, 53 deletions
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index 6002dfcb..9a1d507b 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -80,7 +80,7 @@ class Frontend {
onMouseMove(e) {
this.popupTimerClear();
- if (this.pendingLookup || Frontend.isMouseButtonDown('primary', e)) {
+ if (this.pendingLookup || DOM.isMouseButtonDown(e, 'primary')) {
return;
}
@@ -88,7 +88,7 @@ class Frontend {
const scanningModifier = scanningOptions.modifier;
if (!(
Frontend.isScanningModifierPressed(scanningModifier, e) ||
- (scanningOptions.middleMouse && Frontend.isMouseButtonDown('auxiliary', e))
+ (scanningOptions.middleMouse && DOM.isMouseButtonDown(e, 'auxiliary'))
)) {
return;
}
@@ -122,7 +122,7 @@ class Frontend {
}
}
- onMouseOut(e) {
+ onMouseOut() {
this.popupTimerClear();
}
@@ -135,7 +135,7 @@ class Frontend {
}
}
- onAuxClick(e) {
+ onAuxClick() {
this.preventNextContextMenu = false;
}
@@ -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;
}
@@ -237,7 +237,7 @@ class Frontend {
onWindowMessage(e) {
const action = e.data;
const handlers = Frontend.windowMessageHandlers;
- if (handlers.hasOwnProperty(action)) {
+ if (hasOwn(handlers, action)) {
const handler = handlers[action];
handler(this);
}
@@ -245,7 +245,7 @@ class Frontend {
onRuntimeMessage({action, params}, sender, callback) {
const handlers = Frontend.runtimeMessageHandlers;
- if (handlers.hasOwnProperty(action)) {
+ if (hasOwn(handlers, action)) {
const handler = handlers[action];
const result = handler(this, params);
callback(result);
@@ -398,7 +398,7 @@ class Frontend {
textSource.getRect(),
textSource.getWritingMode(),
type,
- {definitions, context: {sentence, url, focus}}
+ {definitions, context: {sentence, url, focus, disableHistory: true}}
);
this.textSourceCurrent = textSource;
@@ -447,8 +447,8 @@ class Frontend {
}
getIndexOfTouch(touchList, identifier) {
- for (let i in touchList) {
- let t = touchList[i];
+ for (const i in touchList) {
+ const t = touchList[i];
if (t.identifier === identifier) {
return i;
}
@@ -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) {
@@ -499,37 +487,6 @@ class Frontend {
default: return false;
}
}
-
- static isMouseButton(button, mouseEvent) {
- switch (mouseEvent.type) {
- case 'mouseup':
- case 'mousedown':
- case 'click':
- return Frontend.isMouseButtonPressed(button, mouseEvent);
- default:
- return Frontend.isMouseButtonDown(button, mouseEvent);
- }
- }
-
- static isMouseButtonPressed(button, mouseEvent) {
- const mouseEventButton = mouseEvent.button;
- switch (button) {
- case 'primary': return mouseEventButton === 0;
- case 'secondary': return mouseEventButton === 2;
- case 'auxiliary': return mouseEventButton === 1;
- default: return false;
- }
- }
-
- static isMouseButtonDown(button, mouseEvent) {
- const mouseEventButtons = mouseEvent.buttons;
- switch (button) {
- case 'primary': return (mouseEventButtons & 0x1) !== 0x0;
- case 'secondary': return (mouseEventButtons & 0x2) !== 0x0;
- case 'auxiliary': return (mouseEventButtons & 0x4) !== 0x0;
- default: return false;
- }
- }
}
Frontend.windowMessageHandlers = {