summaryrefslogtreecommitdiff
path: root/ext/mixed
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mixed')
-rw-r--r--ext/mixed/js/display.js12
-rw-r--r--ext/mixed/js/document-util.js17
-rw-r--r--ext/mixed/js/text-scanner.js3
3 files changed, 21 insertions, 11 deletions
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index 39bd7732..9824c25e 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -205,7 +205,7 @@ class Display extends EventDispatcher {
const eventModifiers = DocumentUtil.getActiveModifiers(e);
for (const {modifiers, action} of handlers) {
- if (getSetDifference(modifiers, eventModifiers).size !== 0) { continue; }
+ if (!this._areSame(modifiers, eventModifiers)) { continue; }
const actionHandler = this._actions.get(action);
if (typeof actionHandler === 'undefined') { continue; }
@@ -1476,4 +1476,14 @@ class Display extends EventDispatcher {
const {expression, reading} = termDetailsList[Math.max(0, bestIndex)];
return {expression, reading};
}
+
+ _areSame(set, array) {
+ if (set.size !== array.size) { return false; }
+ for (const value of array) {
+ if (!set.has(value)) {
+ return false;
+ }
+ }
+ return true;
+ }
}
diff --git a/ext/mixed/js/document-util.js b/ext/mixed/js/document-util.js
index 90add8f9..da27a75d 100644
--- a/ext/mixed/js/document-util.js
+++ b/ext/mixed/js/document-util.js
@@ -170,11 +170,11 @@ class DocumentUtil {
}
static getActiveModifiers(event) {
- const modifiers = new Set();
- if (event.altKey) { modifiers.add('alt'); }
- if (event.ctrlKey) { modifiers.add('ctrl'); }
- if (event.metaKey) { modifiers.add('meta'); }
- if (event.shiftKey) { modifiers.add('shift'); }
+ const modifiers = [];
+ if (event.altKey) { modifiers.push('alt'); }
+ if (event.ctrlKey) { modifiers.push('ctrl'); }
+ if (event.metaKey) { modifiers.push('meta'); }
+ if (event.shiftKey) { modifiers.push('shift'); }
return modifiers;
}
@@ -185,7 +185,7 @@ class DocumentUtil {
}
static getActiveButtons(event) {
- const buttons = new Set();
+ const buttons = [];
this._getActiveButtons(event, buttons);
return buttons;
}
@@ -301,19 +301,18 @@ class DocumentUtil {
return !(browser === 'firefox' || browser === 'firefox-mobile') || os === 'mac';
}
- static _getActiveButtons(event, set) {
+ static _getActiveButtons(event, array) {
let {buttons} = event;
if (typeof buttons === 'number' && buttons > 0) {
for (let i = 0; i < 6; ++i) {
const buttonFlag = (1 << i);
if ((buttons & buttonFlag) !== 0) {
- set.add(`mouse${i}`);
+ array.push(`mouse${i}`);
buttons &= ~buttonFlag;
if (buttons === 0) { break; }
}
}
}
- return set;
}
// Private
diff --git a/ext/mixed/js/text-scanner.js b/ext/mixed/js/text-scanner.js
index f4b8df68..189afd07 100644
--- a/ext/mixed/js/text-scanner.js
+++ b/ext/mixed/js/text-scanner.js
@@ -817,11 +817,12 @@ class TextScanner extends EventDispatcher {
_getMatchingInputGroup(modifiers, type) {
let fallback = null;
+ const modifiersSet = new Set(modifiers);
for (let i = 0, ii = this._inputs.length; i < ii; ++i) {
const input = this._inputs[i];
const {include, exclude, types} = input;
if (!types.has(type)) { continue; }
- if (this._setHasAll(modifiers, include) && (exclude.length === 0 || !this._setHasAll(modifiers, exclude))) {
+ if (this._setHasAll(modifiersSet, include) && (exclude.length === 0 || !this._setHasAll(modifiersSet, exclude))) {
if (include.length > 0) {
return {index: i, empty: false, input};
} else if (fallback === null) {