commit 6fc34a866590231a6a9f8def970e297cf071b31d
parent f8304cb9d13daace0fcf98a31811e4a162b21d70
Author: Lorenz A <me@lorenzackermann.xyz>
Date: Mon, 8 Dec 2025 16:47:32 +0000
Bug 2004210 - [devtools] Turn devtools/client/accessibility/panel.js into an ES class. r=devtools-reviewers,nchevobbe
Differential Revision: https://phabricator.services.mozilla.com/D275470
Diffstat:
1 file changed, 39 insertions(+), 40 deletions(-)
diff --git a/devtools/client/accessibility/panel.js b/devtools/client/accessibility/panel.js
@@ -42,25 +42,24 @@ const EVENTS = {
* render Accessibility Tree of the current debugger target and the sidebar that
* displays current relevant accessible details.
*/
-function AccessibilityPanel(iframeWindow, toolbox, commands) {
- this.panelWin = iframeWindow;
- this._toolbox = toolbox;
- this._commands = commands;
-
- this.onPanelVisibilityChange = this.onPanelVisibilityChange.bind(this);
- this.onNewAccessibleFrontSelected =
- this.onNewAccessibleFrontSelected.bind(this);
- this.onAccessibilityInspectorUpdated =
- this.onAccessibilityInspectorUpdated.bind(this);
- this.updateA11YServiceDurationTimer =
- this.updateA11YServiceDurationTimer.bind(this);
- this.forceUpdatePickerButton = this.forceUpdatePickerButton.bind(this);
- this.onLifecycleEvent = this.onLifecycleEvent.bind(this);
-
- EventEmitter.decorate(this);
-}
-
-AccessibilityPanel.prototype = {
+class AccessibilityPanel {
+ constructor(iframeWindow, toolbox, commands) {
+ this.panelWin = iframeWindow;
+ this._toolbox = toolbox;
+ this._commands = commands;
+
+ this.onPanelVisibilityChange = this.onPanelVisibilityChange.bind(this);
+ this.onNewAccessibleFrontSelected =
+ this.onNewAccessibleFrontSelected.bind(this);
+ this.onAccessibilityInspectorUpdated =
+ this.onAccessibilityInspectorUpdated.bind(this);
+ this.updateA11YServiceDurationTimer =
+ this.updateA11YServiceDurationTimer.bind(this);
+ this.forceUpdatePickerButton = this.forceUpdatePickerButton.bind(this);
+ this.onLifecycleEvent = this.onLifecycleEvent.bind(this);
+
+ EventEmitter.decorate(this);
+ }
/**
* Open is effectively an asynchronous constructor.
*/
@@ -120,7 +119,7 @@ AccessibilityPanel.prototype = {
resolver(this);
return this._opening;
- },
+ }
/**
* Retrieve message contexts for the current locales, and return them as an
@@ -140,20 +139,20 @@ AccessibilityPanel.prototype = {
}
return contexts;
- },
+ }
onLifecycleEvent() {
this.updateA11YServiceDurationTimer();
this.forceUpdatePickerButton();
- },
+ }
onNewAccessibleFrontSelected(selected) {
this.emit("new-accessible-front-selected", selected);
- },
+ }
onAccessibilityInspectorUpdated() {
this.emit("accessibility-inspector-updated");
- },
+ }
/**
* Make sure the panel is refreshed when the page is reloaded. The panel is
@@ -170,14 +169,14 @@ AccessibilityPanel.prototype = {
await onUpdated;
this.emit("reloaded");
- },
+ }
/**
* Make sure the panel is refreshed (if needed) when it's selected.
*/
onPanelVisibilityChange() {
this._opening.then(() => this.refresh());
- },
+ }
refresh() {
this.cancelPicker();
@@ -229,7 +228,7 @@ AccessibilityPanel.prototype = {
highlightAccessible,
unhighlightAccessible,
});
- },
+ }
updateA11YServiceDurationTimer() {
if (this.accessibilityProxy.enabled) {
@@ -240,11 +239,11 @@ AccessibilityPanel.prototype = {
);
this._timerID = null;
}
- },
+ }
selectAccessible(accessibleFront) {
this.postContentMessage("selectAccessible", accessibleFront);
- },
+ }
selectAccessibleForNode(nodeFront, reason) {
if (reason) {
@@ -252,11 +251,11 @@ AccessibilityPanel.prototype = {
}
this.postContentMessage("selectNodeAccessible", nodeFront);
- },
+ }
highlightAccessible(accessibleFront) {
this.postContentMessage("highlightAccessible", accessibleFront);
- },
+ }
postContentMessage(type, ...args) {
const event = new this.panelWin.MessageEvent("devtools/chrome/message", {
@@ -266,11 +265,11 @@ AccessibilityPanel.prototype = {
});
this.panelWin.dispatchEvent(event);
- },
+ }
updatePickerButton() {
this.picker && this.picker.updateButton();
- },
+ }
forceUpdatePickerButton() {
// Only update picker button when the panel is selected.
@@ -281,26 +280,26 @@ AccessibilityPanel.prototype = {
this.updatePickerButton();
// Calling setToolboxButtons to make sure toolbar is forced to re-render.
this._toolbox.component.setToolboxButtons(this._toolbox.toolbarButtons);
- },
+ }
togglePicker() {
this.picker && this.picker.toggle();
- },
+ }
cancelPicker() {
this.picker && this.picker.cancel();
- },
+ }
stopPicker() {
this.picker && this.picker.stop();
- },
+ }
/**
* Return true if the Accessibility panel is currently selected.
*/
get isVisible() {
return this._toolbox.currentToolId === "accessibility";
- },
+ }
destroy() {
if (this._destroyed) {
@@ -341,8 +340,8 @@ AccessibilityPanel.prototype = {
this.panelWin.gTelemetry = null;
this.emit("destroyed");
- },
-};
+ }
+}
// Exports from this module
exports.AccessibilityPanel = AccessibilityPanel;