aboutsummaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-24 21:03:50 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-28 17:03:42 -0400
commit8c5240d7a6cc325a628b32cf9e73ac6221517049 (patch)
tree127ec2db9f5090b4c95e890361640a5b9cfceda2 /ext
parente91bcf5f553eb4199fff067044413064c46d1844 (diff)
Simplify how touch events use onAfterSearch
Diffstat (limited to 'ext')
-rw-r--r--ext/fg/js/frontend.js45
1 files changed, 18 insertions, 27 deletions
diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js
index 5ab69b9a..07c1f0dc 100644
--- a/ext/fg/js/frontend.js
+++ b/ext/fg/js/frontend.js
@@ -32,7 +32,6 @@ class Frontend {
};
this.primaryTouchIdentifier = null;
- this.contextMenuChecking = false;
this.contextMenuPrevent = false;
this.contextMenuPreviousRange = null;
this.mouseDownPrevent = false;
@@ -212,26 +211,6 @@ class Frontend {
}
}
- onAfterSearch(newRange, cause) {
- if (cause === 'mouse') {
- return;
- }
-
- if (
- !this.contextMenuChecking ||
- (this.contextMenuPreviousRange === null ? newRange === null : this.contextMenuPreviousRange.equals(newRange))) {
- return;
- }
-
- if (cause === 'touchStart' && newRange !== null) {
- this.scrollPrevent = true;
- }
-
- this.setContextMenuPrevent(true, false);
- this.setMouseDownPrevent(true, false);
- this.contextMenuChecking = false;
- }
-
onRuntimeMessage({action, params}, sender, callback) {
const handlers = Frontend.runtimeMessageHandlers;
if (handlers.hasOwnProperty(action)) {
@@ -367,7 +346,6 @@ class Frontend {
}
this.pendingLookup = false;
- this.onAfterSearch(this.textSourceCurrent, cause);
}
return results !== null;
@@ -456,7 +434,6 @@ class Frontend {
if (touch === null) {
this.primaryTouchIdentifier = null;
this.contextMenuPreviousRange = null;
- this.contextMenuChecking = false;
this.scrollPrevent = false;
this.setContextMenuPrevent(false, true);
this.setMouseDownPrevent(false, true);
@@ -465,13 +442,27 @@ class Frontend {
else {
this.primaryTouchIdentifier = touch.identifier;
this.contextMenuPreviousRange = this.textSourceCurrent !== null ? this.textSourceCurrent.clone() : null;
- this.contextMenuChecking = true;
this.scrollPrevent = false;
this.setContextMenuPrevent(false, false);
this.setMouseDownPrevent(false, false);
this.setClickPrevent(false);
- this.searchFromTouch(touch.clientX, touch.clientY, 'touchStart');
+ const textSourceCurrentPrevious = this.textSourceCurrent !== null ? this.textSourceCurrent.clone() : null;
+
+ this.searchFromTouch(touch.clientX, touch.clientY, 'touchStart')
+ .then(() => {
+ if (
+ this.pendingLookup ||
+ this.textSourceCurrent === null ||
+ this.textSourceCurrent.equals(textSourceCurrentPrevious)
+ ) {
+ return;
+ }
+
+ this.scrollPrevent = true;
+ this.setContextMenuPrevent(true, false);
+ this.setMouseDownPrevent(true, false);
+ });
}
}
@@ -495,10 +486,10 @@ class Frontend {
this.popupTimerClear();
if (this.pendingLookup) {
- return;
+ return Promise.resolve();
}
- this.searchAt(x, y, cause);
+ return this.searchAt(x, y, cause);
}
selectionContainsPoint(selection, x, y) {