From 8eaa5e94fbbd68fe45b1920b633174bdb963505c Mon Sep 17 00:00:00 2001 From: Alex Kaminskii Date: Wed, 5 Apr 2023 13:20:28 +0200 Subject: [PATCH] style(player): few renamings; comments improved --- frontend/app/player/common/ListWalker.ts | 21 ++++++---- .../app/player/web/managers/DOM/DOMManager.ts | 41 +++++++++++-------- .../app/player/web/managers/DOM/VirtualDOM.ts | 33 +++++++++++---- 3 files changed, 61 insertions(+), 34 deletions(-) diff --git a/frontend/app/player/common/ListWalker.ts b/frontend/app/player/common/ListWalker.ts index ca3d409ac..61f93f8df 100644 --- a/frontend/app/player/common/ListWalker.ts +++ b/frontend/app/player/common/ListWalker.ts @@ -105,11 +105,11 @@ export default class ListWalker { : null } - /* - Returns last message with the time <= t. - Assumed that the current message is already handled so - if pointer doesn't cahnge is returned. - */ + /** + * @returns last message with the time <= t. + * Assumed that the current message is already handled so + * if pointer doesn't cahnge is returned. + */ moveGetLast(t: number, index?: number): T | null { let key: string = "time"; //TODO let val = t; @@ -130,7 +130,13 @@ export default class ListWalker { return changed ? this.list[ this.p - 1 ] : null; } - async moveWait(t: number, callback: (msg: T) => Promise | undefined): Promise { + /** + * Moves over the messages starting from the current+1 to the last one with the time <= t + * applying callback on each of them + * @param t - max message time to move to; will move & apply callback while msg.time <= t + * @param callback - a callback to apply on each message passing by while moving + */ + moveApply(t: number, callback: (msg: T) => void): void { // Applying only in increment order for now if (t < this.timeNow) { this.reset(); @@ -138,8 +144,7 @@ export default class ListWalker { const list = this.list while (list[this.p] && list[this.p].time <= t) { - const maybePromise = callback(this.list[ this.p++ ]); - if (maybePromise) { await maybePromise } + callback(this.list[ this.p++ ]) } } diff --git a/frontend/app/player/web/managers/DOM/DOMManager.ts b/frontend/app/player/web/managers/DOM/DOMManager.ts index 542e22b0a..c646aef5f 100644 --- a/frontend/app/player/web/managers/DOM/DOMManager.ts +++ b/frontend/app/player/web/managers/DOM/DOMManager.ts @@ -22,8 +22,8 @@ import { deleteRule, insertRule } from './safeCSSRules'; type HTMLElementWithValue = HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement; -const IGNORED_ATTRS = [ "autocomplete" ]; -const ATTR_NAME_REGEXP = /([^\t\n\f \/>"'=]+)/; // regexp costs ~ +const IGNORED_ATTRS = [ "autocomplete" ] +const ATTR_NAME_REGEXP = /([^\t\n\f \/>"'=]+)/ export default class DOMManager extends ListWalker { private readonly vTexts: Map = new Map() // map vs object here? @@ -31,7 +31,7 @@ export default class DOMManager extends ListWalker { private readonly olVRoots: Map = new Map() /** Constructed StyleSheets https://developer.mozilla.org/en-US/docs/Web/API/Document/adoptedStyleSheets * as well as