summaryrefslogtreecommitdiff
path: root/ext/js/display
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2024-02-20 10:13:57 -0500
committerGitHub <noreply@github.com>2024-02-20 15:13:57 +0000
commitfe875bbd99980b175fc366a2bfd4395be9cbad72 (patch)
tree9eacc919cae0aa32c1a5e25b8493a0e86a21f16e /ext/js/display
parent0e4ae922451af967c78616057ed26b85ba5d4b5c (diff)
Constructor simplification (#713)
* Update AudioDownloader * Update Translator * Update ClipboardMonitor * Update ClipboardReader * Update PanelElement * Update QueryParser * Update DisplayGenerator * Update DisplayHistory * Update DOMDataBinder * Remove unnecessary cast * Update Popup types * One declaration per line * Remove optionals from Frontend constructor * Fix Translator constructor
Diffstat (limited to 'ext/js/display')
-rw-r--r--ext/js/display/display-generator.js5
-rw-r--r--ext/js/display/display-history.js5
-rw-r--r--ext/js/display/display-profile-selection.js5
-rw-r--r--ext/js/display/display.js23
-rw-r--r--ext/js/display/query-parser.js6
-rw-r--r--ext/js/display/search-display-controller.js10
6 files changed, 23 insertions, 31 deletions
diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js
index 65736759..22912e9f 100644
--- a/ext/js/display/display-generator.js
+++ b/ext/js/display/display-generator.js
@@ -26,9 +26,10 @@ import {StructuredContentGenerator} from './sandbox/structured-content-generator
export class DisplayGenerator {
/**
- * @param {import('display').DisplayGeneratorConstructorDetails} details
+ * @param {import('./display-content-manager.js').DisplayContentManager} contentManager
+ * @param {?import('../input/hotkey-help-controller.js').HotkeyHelpController} hotkeyHelpController
*/
- constructor({contentManager, hotkeyHelpController = null}) {
+ constructor(contentManager, hotkeyHelpController) {
/** @type {import('./display-content-manager.js').DisplayContentManager} */
this._contentManager = contentManager;
/** @type {?import('../input/hotkey-help-controller.js').HotkeyHelpController} */
diff --git a/ext/js/display/display-history.js b/ext/js/display/display-history.js
index 255a8536..67690219 100644
--- a/ext/js/display/display-history.js
+++ b/ext/js/display/display-history.js
@@ -24,9 +24,10 @@ import {generateId, isObject} from '../core/utilities.js';
*/
export class DisplayHistory extends EventDispatcher {
/**
- * @param {{clearable?: boolean, useBrowserHistory?: boolean}} details
+ * @param {boolean} clearable
+ * @param {boolean} useBrowserHistory
*/
- constructor({clearable = true, useBrowserHistory = false}) {
+ constructor(clearable, useBrowserHistory) {
super();
/** @type {boolean} */
this._clearable = clearable;
diff --git a/ext/js/display/display-profile-selection.js b/ext/js/display/display-profile-selection.js
index 0aa08b00..6fd25835 100644
--- a/ext/js/display/display-profile-selection.js
+++ b/ext/js/display/display-profile-selection.js
@@ -35,10 +35,7 @@ export class DisplayProfileSelection {
/** @type {HTMLElement} */
const profilePanelElement = querySelectorNotNull(document, '#profile-panel');
/** @type {PanelElement} */
- this._profilePanel = new PanelElement({
- node: profilePanelElement,
- closingAnimationDuration: 375 // Milliseconds; includes buffer
- });
+ this._profilePanel = new PanelElement(profilePanelElement, 375); // Milliseconds; includes buffer
/** @type {boolean} */
this._profileListNeedsUpdate = false;
/** @type {EventListenerCollection} */
diff --git a/ext/js/display/display.js b/ext/js/display/display.js
index d0edd0bd..750e0d69 100644
--- a/ext/js/display/display.js
+++ b/ext/js/display/display.js
@@ -83,16 +83,13 @@ export class Display extends EventDispatcher {
/** @type {HotkeyHelpController} */
this._hotkeyHelpController = new HotkeyHelpController();
/** @type {DisplayGenerator} */
- this._displayGenerator = new DisplayGenerator({
- contentManager: this._contentManager,
- hotkeyHelpController: this._hotkeyHelpController
- });
+ this._displayGenerator = new DisplayGenerator(this._contentManager, this._hotkeyHelpController);
/** @type {import('display').DirectApiMap} */
this._directApiMap = new Map();
/** @type {import('api-map').ApiMap<import('display').WindowApiSurface>} */ // import('display').WindowApiMap
this._windowApiMap = new Map();
/** @type {DisplayHistory} */
- this._history = new DisplayHistory({clearable: true, useBrowserHistory: false});
+ this._history = new DisplayHistory(true, false);
/** @type {boolean} */
this._historyChangeIgnore = false;
/** @type {boolean} */
@@ -126,11 +123,7 @@ export class Display extends EventDispatcher {
/** @type {TextSourceGenerator} */
this._textSourceGenerator = new TextSourceGenerator();
/** @type {QueryParser} */
- this._queryParser = new QueryParser({
- api: application.api,
- getSearchContext: this._getSearchContext.bind(this),
- textSourceGenerator: this._textSourceGenerator
- });
+ this._queryParser = new QueryParser(application.api, this._textSourceGenerator, this._getSearchContext.bind(this));
/** @type {HTMLElement} */
this._contentScrollElement = querySelectorNotNull(document, '#content-scroll');
/** @type {HTMLElement} */
@@ -1712,8 +1705,7 @@ export class Display extends EventDispatcher {
const popupFactory = new PopupFactory(this._application);
popupFactory.prepare();
- /** @type {import('frontend').ConstructorDetails} */
- const setupNestedPopupsOptions = {
+ const frontend = new Frontend({
application: this._application,
useProxyPopup,
parentPopupId,
@@ -1723,10 +1715,9 @@ export class Display extends EventDispatcher {
pageType: this._pageType,
allowRootFramePopupProxy: true,
childrenSupported: this._childrenSupported,
- hotkeyHandler: this._hotkeyHandler
- };
-
- const frontend = new Frontend(setupNestedPopupsOptions);
+ hotkeyHandler: this._hotkeyHandler,
+ canUseWindowPopup: true
+ });
this._frontend = frontend;
await frontend.prepare();
}
diff --git a/ext/js/display/query-parser.js b/ext/js/display/query-parser.js
index 875d9d5a..d27b9394 100644
--- a/ext/js/display/query-parser.js
+++ b/ext/js/display/query-parser.js
@@ -27,9 +27,11 @@ import {TextScanner} from '../language/text-scanner.js';
*/
export class QueryParser extends EventDispatcher {
/**
- * @param {import('display').QueryParserConstructorDetails} details
+ * @param {import('../comm/api.js').API} api
+ * @param {import('../dom/text-source-generator').TextSourceGenerator} textSourceGenerator
+ * @param {import('display').GetSearchContextCallback} getSearchContext
*/
- constructor({api, getSearchContext, textSourceGenerator}) {
+ constructor(api, textSourceGenerator, getSearchContext) {
super();
/** @type {import('../comm/api.js').API} */
this._api = api;
diff --git a/ext/js/display/search-display-controller.js b/ext/js/display/search-display-controller.js
index d8126027..e23d5d50 100644
--- a/ext/js/display/search-display-controller.js
+++ b/ext/js/display/search-display-controller.js
@@ -63,12 +63,12 @@ export class SearchDisplayController {
this._introAnimationTimer = null;
/** @type {boolean} */
this._clipboardMonitorEnabled = false;
+ /** @type {import('clipboard-monitor').ClipboardReaderLike} */
+ const clipboardReader = {
+ getText: this._display.application.api.clipboardGet.bind(this._display.application.api)
+ };
/** @type {ClipboardMonitor} */
- this._clipboardMonitor = new ClipboardMonitor({
- clipboardReader: {
- getText: this._display.application.api.clipboardGet.bind(this._display.application.api)
- }
- });
+ this._clipboardMonitor = new ClipboardMonitor(clipboardReader);
/** @type {import('application').ApiMap} */
this._apiMap = createApiMap([
['searchDisplayControllerGetMode', this._onMessageGetMode.bind(this)],