Bug 1603573 - Remove context function from JS TouchBarInputs. r=mikedeboer
authorHarry Twyford <htwyford@mozilla.com>
Thu, 12 Dec 2019 22:09:59 +0000
changeset 506912 d6c02f97fda99a7e722e6b825ff868e41d74aeda
parent 506911 23808202b408ca1479305b7e7cbff3e089cede6c
child 506913 dc97cf74084d7ae872e278535895684e94b48bf7
push id36915
push userrgurzau@mozilla.com
push dateFri, 13 Dec 2019 21:43:22 +0000
treeherdermozilla-central@f09f24f2b545 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmikedeboer
bugs1603573
milestone73.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1603573 - Remove context function from JS TouchBarInputs. r=mikedeboer Differential Revision: https://phabricator.services.mozilla.com/D56998
browser/components/touchbar/MacTouchBar.js
browser/components/touchbar/docs/index.rst
--- a/browser/components/touchbar/MacTouchBar.js
+++ b/browser/components/touchbar/MacTouchBar.js
@@ -287,19 +287,16 @@ class TouchBarHelper {
   }
 
   get allItems() {
     let layoutItems = Cc["@mozilla.org/array;1"].createInstance(
       Ci.nsIMutableArray
     );
 
     for (let inputName of Object.keys(kBuiltInInputs)) {
-      if (typeof kBuiltInInputs[inputName].context == "function") {
-        inputName = kBuiltInInputs[inputName].context();
-      }
       let input = this.getTouchBarInput(inputName);
       if (!input) {
         continue;
       }
       layoutItems.appendElement(input);
     }
 
     // Every input must be updated at least once so that all assets (titles,
@@ -331,26 +328,16 @@ class TouchBarHelper {
       : null;
   }
 
   getTouchBarInput(inputName) {
     if (inputName == "SearchPopover" && this._searchPopover) {
       return this._searchPopover;
     }
 
-    // inputName might be undefined if an input's context() returns undefined.
-    if (!inputName || !kBuiltInInputs.hasOwnProperty(inputName)) {
-      return null;
-    }
-
-    // context() may specify that one named input "point" to another.
-    if (typeof kBuiltInInputs[inputName].context == "function") {
-      inputName = kBuiltInInputs[inputName].context();
-    }
-
     if (!inputName || !kBuiltInInputs.hasOwnProperty(inputName)) {
       return null;
     }
 
     let inputData = kBuiltInInputs[inputName];
 
     let item = new TouchBarInput(inputData);
 
--- a/browser/components/touchbar/docs/index.rst
+++ b/browser/components/touchbar/docs/index.rst
@@ -96,22 +96,16 @@ Clarification on some of these propertie
   Telemetry.
 * ``children`` is an array of objects with the same properties as members of
   ``kBuiltInInputs``. When used with an input of type
   ``kInputTypes.SCROLLVIEW``, ``children`` can only contain inputs of type
   ``kInputTypes.BUTTON``. When used with an input of type
   ``kInputTypes.POPOVER``, any input type except another ``kInputTypes.POPOVER``
   can be used.
 
-A final property, ``context``, is also accepted. ``context`` is a function that
-returns a string. The returned string should be the name of a key in
-``kBuiltInInputs``. ``context`` is a useful property if you want to show one
-input in the Touch Bar in one context, and another input in a different context.
-An example of its use follows below.
-
 .. _in that file: https://searchfox.org/mozilla-central/rev/ebe492edacc75bb122a2b380e4cafcca3470864c/browser/components/touchbar/MacTouchBar.js#82
 
 Input types
 -----------
 
 Button
   A simple button. If ``image`` is not specified, the buttons displays the text
   label from ``title``. If both ``image`` and ``title`` are specified, only the
@@ -176,53 +170,16 @@ A simple button
       image: "chrome://browser/skin/back.svg",
       type: kInputTypes.BUTTON,
       callback: () => execCommand("Browser:Back", "Back"),
     },
 
   A button is defined with a title, icon, type, and a callback. The callback
   simply calls the XUL command to go back.
 
-Using ``context``
-  In this example, two main buttons are defined. One focuses the address bar
-  and the other closes the current window. The OpenLocationOrClosePrivateWindow
-  object uses the ``context`` property to display the former in Normal
-  Browsing Mode and the latter in Private Browsing Mode. Note also that
-  ClosePrivateWindow uses ``image`` and ``color`` to be consistent with
-  PBM styling. By including OpenLocationOrClosePrivateWindow as a default input
-  in ``nsTouchBar.mm``, the user can be shown a different Touch Bar depending on
-  whether they are in Normal or Private Browsing Mode.
-
-  .. highlight:: JavaScript
-  .. code::
-
-    OpenLocation: {
-      title: "open-location",
-      image: "chrome://browser/skin/search-glass.svg",
-      type: kInputTypes.MAIN_BUTTON,
-      callback: () => execCommand("Browser:OpenLocation", "OpenLocation"),
-    },
-    ClosePrivateWindow: {
-      title: "close-private-window",
-      image: "hrome://browser/skin/privateBrowsing.svg",
-      type: kInputTypes.MAIN_BUTTON,
-      callback: () => execCommand("cmd_closeWindow", "ClosePrivateWindow"),
-      color: "#8000D7",
-    },
-    OpenLocationOrClosePrivateWindow: {
-      // This is just a forwarder to other inputs.
-      context: () => {
-        if (PrivateBrowsingUtils.isWindowPrivate(BrowserWindowTracker.getTopWindow())) {
-          return "ClosePrivateWindow";
-        } else {
-          return "OpenLocation";
-        }
-      },
-    },
-
 The search popover
   This is the input that occupies the Touch Bar when the address bar is focused.
 
   .. highlight:: JavaScript
   .. code::
 
     SearchPopover: {
       title: "search-popover",