diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-02-28 14:29:43 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-28 14:29:43 -0500 |
commit | 704db45e29287718cbfbe7b0a4a2c261aef8a71d (patch) | |
tree | d196c838b0212c4b3acdff5f57970af1228cef8c /ext/js/input | |
parent | 75d7e5dc325e3cff8dc530ea48459e214088c1ea (diff) |
Remove the now-unused hotkey forwarding functionality (#1466)
Diffstat (limited to 'ext/js/input')
-rw-r--r-- | ext/js/input/hotkey-handler.js | 51 |
1 files changed, 6 insertions, 45 deletions
diff --git a/ext/js/input/hotkey-handler.js b/ext/js/input/hotkey-handler.js index f0e44426..d3b82d48 100644 --- a/ext/js/input/hotkey-handler.js +++ b/ext/js/input/hotkey-handler.js @@ -34,22 +34,6 @@ class HotkeyHandler extends EventDispatcher { this._eventListeners = new EventListenerCollection(); this._isPrepared = false; this._hasEventListeners = false; - this._forwardFrameId = null; - } - - /** - * Gets the frame ID used for forwarding hotkeys. - */ - get forwardFrameId() { - return this._forwardFrameId; - } - - /** - * Sets the frame ID used for forwarding hotkeys. - */ - set forwardFrameId(value) { - this._forwardFrameId = value; - this._updateHotkeyRegistrations(); } /** @@ -156,7 +140,7 @@ class HotkeyHandler extends EventDispatcher { const hotkeyInfo = this._hotkeys.get(key); return ( typeof hotkeyInfo !== 'undefined' && - this._invokeHandlers(key, modifiers, hotkeyInfo, false) + this._invokeHandlers(modifiers, hotkeyInfo) ); } @@ -173,7 +157,7 @@ class HotkeyHandler extends EventDispatcher { const hotkeyInfo = this._hotkeys.get(key); if (typeof hotkeyInfo !== 'undefined') { const eventModifiers = DocumentUtil.getActiveModifiers(e); - if (this._invokeHandlers(key, eventModifiers, hotkeyInfo, false)) { + if (this._invokeHandlers(eventModifiers, hotkeyInfo)) { e.preventDefault(); return; } @@ -181,7 +165,7 @@ class HotkeyHandler extends EventDispatcher { this.trigger('keydownNonHotkey', e); } - _invokeHandlers(key, modifiers, hotkeyInfo, canForward) { + _invokeHandlers(modifiers, hotkeyInfo) { for (const {modifiers: handlerModifiers, action} of hotkeyInfo.handlers) { if (!this._areSame(handlerModifiers, modifiers)) { continue; } @@ -194,11 +178,6 @@ class HotkeyHandler extends EventDispatcher { } } - if (canForward && hotkeyInfo.forward) { - this._forwardHotkey(key, modifiers); - return true; - } - return false; } @@ -215,26 +194,18 @@ class HotkeyHandler extends EventDispatcher { _updateHotkeyRegistrations() { if (this._hotkeys.size === 0 && this._hotkeyRegistrations.size === 0) { return; } - const canForward = (this._forwardFrameId !== null); this._hotkeys.clear(); for (const [scope, registrations] of this._hotkeyRegistrations.entries()) { for (const {action, key, modifiers, scopes, enabled} of registrations) { - if (!(enabled && key !== null && action !== '')) { continue; } - - const correctScope = scopes.includes(scope); - if (!correctScope && !canForward) { continue; } + if (!(enabled && key !== null && action !== '' && scopes.includes(scope))) { continue; } let hotkeyInfo = this._hotkeys.get(key); if (typeof hotkeyInfo === 'undefined') { - hotkeyInfo = {handlers: [], forward: false}; + hotkeyInfo = {handlers: []}; this._hotkeys.set(key, hotkeyInfo); } - if (correctScope) { - hotkeyInfo.handlers.push({modifiers: new Set(modifiers), action}); - } else { - hotkeyInfo.forward = true; - } + hotkeyInfo.handlers.push({modifiers: new Set(modifiers), action}); } } this._updateEventHandlers(); @@ -252,14 +223,4 @@ class HotkeyHandler extends EventDispatcher { this._eventListeners.removeAllEventListeners(); } } - - async _forwardHotkey(key, modifiers) { - const frameId = this._forwardFrameId; - if (frameId === null) { throw new Error('No forwarding target'); } - try { - await yomichan.crossFrame.invoke(frameId, 'hotkeyHandler.forwardHotkey', {key, modifiers}); - } catch (e) { - // NOP - } - } } |