Bug 1817013 - ESMified browser/components/touchbar/MacTouchBar.jsm. r=kpatenio

Differential Revision: https://phabricator.services.mozilla.com/D176082
This commit is contained in:
Bilal 2023-04-24 16:27:34 +00:00
parent 24231c094d
commit cfcf4ebb8e
4 changed files with 9 additions and 13 deletions

View File

@ -2,11 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var EXPORTED_SYMBOLS = ["TouchBarHelper", "TouchBarInput"];
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
const lazy = {};
@ -244,7 +240,7 @@ const kHelperObservers = new Set([
* JS-implemented TouchBarHelper class.
* Provides services to the Mac Touch Bar.
*/
class TouchBarHelper {
export class TouchBarHelper {
constructor() {
for (let topic of kHelperObservers) {
Services.obs.addObserver(this, topic);
@ -560,7 +556,7 @@ helperProto._l10n = new Localization(["browser/touchbar/touchbar.ftl"]);
* this input. Available only for types KInputTypes.POPOVER and
* kInputTypes.SCROLLVIEW.
*/
class TouchBarInput {
export class TouchBarInput {
constructor(input) {
this._key = input.key || input.title;
this._title = localizedStrings[input.title] || "";

View File

@ -8,13 +8,13 @@ Classes = [
{
'cid': '{ea109912-3acc-48de-b679-c23b6a122da5}',
'contract_ids': ['@mozilla.org/widget/touchbarhelper;1'],
'jsm': 'resource:///modules/MacTouchBar.jsm',
'esModule': 'resource:///modules/MacTouchBar.sys.mjs',
'constructor': 'TouchBarHelper',
},
{
'cid': '{77441d17-f29c-49d7-982f-f20a5ab5a900}',
'contract_ids': ['@mozilla.org/widget/touchbarinput;1'],
'jsm': 'resource:///modules/MacTouchBar.jsm',
'esModule': 'resource:///modules/MacTouchBar.sys.mjs',
'constructor': 'TouchBarInput',
},
]

View File

@ -51,7 +51,7 @@ when needed.
JavaScript API
~~~~~~~~~~~~~~
``browser/components/touchbar/MacTouchBar.jsm`` defines what specific inputs are
``browser/components/touchbar/MacTouchBar.sys.mjs`` defines what specific inputs are
available to the user, what icon they will have, what action they will perform,
and so on. Inputs are defined in the ``gBuiltInInputs`` object `in that file`_.
When creating a new object in ``gBuiltInInputs``, the available properties are
@ -85,11 +85,11 @@ documented in the JSDoc for ``TouchBarInput``:
Clarification on some of these properties is warranted.
* ``title`` is the key to a Fluent translation defined in ``browser/locales/<LOCALE>/browser/touchbar/touchbar.ftl``.
* ``type`` must be a value from the ``kInputTypes`` enum in ``MacTouchBar.jsm``.
* ``type`` must be a value from the ``kInputTypes`` enum in ``MacTouchBar.sys.mjs``.
For example, ``kInputTypes.BUTTON``. More information on input types follows
below.
* ``callback`` points to a JavaScript function. Any chrome-level JavaScript can
be executed. ``execCommand`` is a convenience method in ``MacTouchBar.jsm``
be executed. ``execCommand`` is a convenience method in ``MacTouchBar.sys.mjs``
that takes a XUL command as a string and executes that command. For instance,
one input sets ``callback`` to ``execCommand("Browser:Back")``.
* ``children`` is an array of objects with the same properties as members of

View File

@ -8,7 +8,7 @@ with Files("**"):
BROWSER_CHROME_MANIFESTS += ["tests/browser/browser.ini"]
EXTRA_JS_MODULES += [
"MacTouchBar.jsm",
"MacTouchBar.sys.mjs",
]
XPCOM_MANIFESTS += [