Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lieser committed Feb 6, 2022
1 parent 0b4279f commit 8cd2939
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"es2020": true
},
"parserOptions": {
"ecmaVersion": 2020,
"ecmaVersion": 2022,
"ecmaFeatures": {},
"sourceType": "module"
},
Expand Down
19 changes: 18 additions & 1 deletion content/table.mjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ class TableCellEditable extends HTMLTableCellElement {
constructor() {
super();

/** @private */
this._span = document.createElement("span");

/** @private */
this._input = document.createElement("input");
this._input.hidden = true;
this._input.type = "text";
Expand Down Expand Up @@ -134,18 +136,27 @@ export default class DataTable {
* @param {DeleteRowCallback} [deleteRowCallback]
*/
constructor(tableElement, editable = false, updatedCellValueCallback = undefined, deleteRowCallback = undefined) {
/** @private */
this._tbody = tableElement.getElementsByTagName("tbody")[0];
if (!this._tbody) {
throw new Error("No tbody element found.");
}
/** @private */
this._isEditable = editable;
/** @private */
this._isEditing = false;
/** @private */
this._updatedCellValueCallback = updatedCellValueCallback;
/** @private */
this._deleteRowCallback = deleteRowCallback;

/** @type {HTMLTableRowElement[]} */
/**
* @private
* @type {HTMLTableRowElement[]}
*/
this._selectedRows = [];

/** @private */
this._columns = Array.from(tableElement.getElementsByTagName("th")).
map(th => ({ name: th.dataset.name, type: th.dataset.type ?? "string" }));
}
Expand Down Expand Up @@ -240,6 +251,7 @@ export default class DataTable {
}

/**
* @private
* @param {Event} event
* @returns {void}
*/
Expand All @@ -255,6 +267,7 @@ export default class DataTable {
}

/**
* @private
* @returns {void}
*/
_unselect() {
Expand All @@ -265,6 +278,7 @@ export default class DataTable {
}

/**
* @private
* @param {Event} event
* @returns {void}
*/
Expand All @@ -279,6 +293,7 @@ export default class DataTable {
}

/**
* @private
* @param {TableCellEditable} cell
* @returns {Promise<void>}
*/
Expand Down Expand Up @@ -328,6 +343,7 @@ export default class DataTable {
}

/**
* @private
* @param {FocusEvent} event
* @returns {void}
*/
Expand All @@ -341,6 +357,7 @@ export default class DataTable {
}

/**
* @private
* @param {KeyboardEvent} event
* @returns {void}
*/
Expand Down
40 changes: 30 additions & 10 deletions experiments/dkimHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ class DKIMTooltip {
* @memberof DKIMTooltip
*/
constructor(document, element) {
// whether a separator should be added before the warnings
/**
* Whether a separator should be added before the warnings.
*
* @protected
*/
this._warningsSeparator = false;

if (element) {
Expand Down Expand Up @@ -116,6 +120,7 @@ class DkimResultTooltip extends DKIMTooltip {
*/
constructor(document, element) {
super(document, element);
/** @protected */
this._warningsSeparator = true;
if (element) {
return;
Expand Down Expand Up @@ -188,6 +193,7 @@ class DKIMHeaderField {
this.element._dkimValue.style.userSelect = "text";

// DKIM warning icon
/** @private */
this._dkimWarningTooltip = new DKIMWarningsTooltip(document);
this.element._dkimWarningTooltip = this._dkimWarningTooltip.element;
this.element._dkimWarningTooltip.id = "dkim-verifier-header-tooltip-warnings";
Expand Down Expand Up @@ -443,6 +449,7 @@ class DkimHeaderRow {
* Should be added to the `expandedHeaders2` element.
*
* @static
* @private
* @param {Document} document
* @returns {HTMLElement}
* @memberof DkimHeaderRow
Expand Down Expand Up @@ -472,6 +479,7 @@ class DkimHeaderRow {
* Should be added to the `extraHeadersArea` element.
*
* @static
* @private
* @param {Document} document
* @returns {HTMLElement}
* @memberof DkimHeaderRow
Expand Down Expand Up @@ -523,7 +531,7 @@ class DkimFavicon {

this.element.id = DkimFavicon._id;
this.element.classList.add("headerValue");
this.element.setAttribute("tooltip", DkimFavicon._idTooltip);
this.element.setAttribute("tooltip", DkimFavicon.idTooltip);
// dummy text for align baseline
this.element.textContent = "";
this.element.style.setProperty("min-width", "0px", "important");
Expand All @@ -534,10 +542,11 @@ class DkimFavicon {
this.element.style.backgroundRepeat = "no-repeat";

// DKIM tooltip
/** @private */
this._dkimTooltipFrom = new DkimResultTooltip(document);
this.element._dkimTooltipFromElement = this._dkimTooltipFrom.element;
this.element._dkimTooltipFromElement.id = DkimFavicon._idTooltip;
this.element.setAttribute("tooltip", DkimFavicon._idTooltip);
this.element._dkimTooltipFromElement.id = DkimFavicon.idTooltip;
this.element.setAttribute("tooltip", DkimFavicon.idTooltip);

this.reset();
}
Expand Down Expand Up @@ -638,9 +647,15 @@ class DkimFavicon {
favicon._dkimTooltipFrom.element.remove();
}
}

/**
* @private
* @readonly
*/
static _id = "dkimFavicon";
/** @readonly */
static idTooltip = "dkim-verifier-header-tooltip-from";
}
DkimFavicon._id = "dkimFavicon";
DkimFavicon._idTooltip = "dkim-verifier-header-tooltip-from";

/**
* DKIM specific modifications of the from address:
Expand All @@ -652,6 +667,7 @@ class DkimFromAddress {
* Get the element containing the from address (without the following star).
*
* @static
* @private
* @param {Document} document
* @returns {XULElement?}
*/
Expand Down Expand Up @@ -718,9 +734,9 @@ class DkimFromAddress {
}
emailValue.removeAttribute("tooltiptext");
// set DKIM tooltip
emailValue.setAttribute("tooltip", DkimFavicon._idTooltip);
emailValue.setAttribute("tooltip", DkimFavicon.idTooltip);
} else {
if (emailValue.getAttribute("tooltip") === DkimFavicon._idTooltip) {
if (emailValue.getAttribute("tooltip") === DkimFavicon.idTooltip) {
// remove DKIM tooltip
emailValue.removeAttribute("tooltip");
// restore saved tooltip
Expand Down Expand Up @@ -828,9 +844,13 @@ class DkimResetMessageListener {
onEndHeaders() { }
// eslint-disable-next-line no-empty-function
onEndAttachments() { }

/**
* @private
* @type {Map<Window, DkimResetMessageListener>}
*/
static _mapping = new Map();
}
/** @type {Map<Window, DkimResetMessageListener>} */
DkimResetMessageListener._mapping = new Map();

// eslint-disable-next-line no-invalid-this
this.dkimHeader = class extends ExtensionCommon.ExtensionAPI {
Expand Down
7 changes: 6 additions & 1 deletion experiments/libunbound.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ class Deferred {

class LibunboundWorker {
constructor() {
/** @private */
this._maxCallId = 0;
/** @type {Map<number, Deferred<ub_result|void>>} */
/**
* @private
* @type {Map<number, Deferred<ub_result|void>>}
*/
this._openCalls = new Map();

/** @type {Libunbound.LibunboundWorker} */
Expand Down Expand Up @@ -208,6 +212,7 @@ class LibunboundWorker {
/**
* Handle the callbacks from the ChromeWorker.
*
* @private
* @param {Libunbound.WorkerResponse} msg
* @returns {void}
*/
Expand Down
2 changes: 2 additions & 0 deletions experiments/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ this.migration = class extends ExtensionCommon.ExtensionAPI {
/**
* Returns the preferences set in a preference branch.
*
* @private
* @param {nsIPrefBranch} prefBranch
* @returns {Object.<string, boolean|number|string>}
*/
Expand Down Expand Up @@ -60,6 +61,7 @@ this.migration = class extends ExtensionCommon.ExtensionAPI {
/**
* Open connection to an SQLite database if it exist.
*
* @private
* @param {string} fileName
* @returns {Promise<any>?}
*/
Expand Down
1 change: 1 addition & 0 deletions experiments/storageMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// eslint-disable-next-line no-invalid-this
this.storageMessage = class extends ExtensionCommon.ExtensionAPI {
/**
* @private
* @param {number} messageId
* @returns {nsIMsgDBHdr}
*/
Expand Down
1 change: 1 addition & 0 deletions modules/dkim/signRules.mjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,7 @@ export default class SignRules {
/**
* Adds should be signed rule if no enabled rule for fromAddress is found.
*
* @private
* @param {string} fromAddress
* @param {VerifierModule.dkimSigResultV2} dkimResult
* @returns {Promise<void>}
Expand Down
12 changes: 9 additions & 3 deletions modules/logging.mjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Logger {
*/
constructor(loggerName) {
this.name = loggerName;
/** @private */
this._logLevel = Logging.logLevel;
this.logLevel = Logging.logLevel;
}
Expand Down Expand Up @@ -163,7 +164,12 @@ export default class Logging {
}
});
}

/** @private */
static _logLevel = Logging.Level.Debug;
/**
* @private
* @type {Logger[]}
*/
static _loggers = [];
}
Logging._logLevel = Logging.Level.Debug;
/** @type {Logger[]} */
Logging._loggers = [];
22 changes: 17 additions & 5 deletions modules/preferences.mjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,15 @@ export class BasePreferences {
* @memberof BasePreferences
*/
constructor(valueGetter, valueSetter) {
/**
* @protected
* @type {Object.<string, boolean|number|string|undefined>}
*/
this._prefs = {};

/** @private */
this._valueGetter = valueGetter;
/** @private */
this._valueSetter = valueSetter;
}

Expand All @@ -71,6 +79,7 @@ export class BasePreferences {
}

/**
* @private
* @param {string} name
* @param {boolean} defaultValue
* @returns {boolean}
Expand All @@ -88,6 +97,7 @@ export class BasePreferences {
}

/**
* @private
* @param {string} name
* @param {number} defaultValue
* @returns {number}
Expand All @@ -105,6 +115,7 @@ export class BasePreferences {
}

/**
* @private
* @param {string} name
* @param {string} defaultValue
* @returns {string}
Expand Down Expand Up @@ -509,6 +520,7 @@ export class BasePreferences {
/**
* Get an boolean account preference that has a global default.
*
* @private
* @param {string} name
* @param {string} account
* @returns {boolean}
Expand Down Expand Up @@ -568,8 +580,6 @@ export class ObjPreferences extends BasePreferences {
(name) => { return this._prefs[name]; },
(name, value) => { this._prefs[name] = value; return Promise.resolve(); },
);
/** @type {Object.<string, boolean|number|string|undefined>} */
this._prefs = {};
}
}

Expand Down Expand Up @@ -597,9 +607,8 @@ export class StorageLocalPreferences extends BasePreferences {
return promise;
},
);
/** @private */
this._isInitialized = false;
/** @type {Object.<string, boolean|number|string|undefined>} */
this._prefs = {};
}

/**
Expand All @@ -609,7 +618,10 @@ export class StorageLocalPreferences extends BasePreferences {
if (this._isInitializedDeferred) {
return this._isInitializedDeferred.promise;
}
/** @type {Deferred<void>} */
/**
* @private
* @type {Deferred<void>}
*/
this._isInitializedDeferred = new Deferred();
try {
const preferences = await ExtensionUtils.safeGetLocalStorage();
Expand Down

0 comments on commit 8cd2939

Please sign in to comment.