Bug 1500268 - remove customizableui toolbar's insertItem method, r=bgrins
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Mon, 22 Oct 2018 16:02:05 +0000
changeset 442413 9b894301f1fd348275e16569334aef00a336a751
parent 442412 3428510869a9b347639d3f79506d7225be92c191
child 442414 c78192e00cf32a15c41d57eabdec3c1687348d17
push id34907
push userebalazs@mozilla.com
push dateTue, 23 Oct 2018 09:23:56 +0000
treeherdermozilla-central@dfa1eb1d036f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1500268
milestone64.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 1500268 - remove customizableui toolbar's insertItem method, r=bgrins Differential Revision: https://phabricator.services.mozilla.com/D9173
browser/components/customizableui/CustomizableUI.jsm
browser/components/customizableui/content/toolbar.xml
browser/components/customizableui/test/browser_968565_insert_before_hidden_items.js
--- a/browser/components/customizableui/CustomizableUI.jsm
+++ b/browser/components/customizableui/CustomizableUI.jsm
@@ -3238,21 +3238,17 @@ var CustomizableUI = {
    *                  respectively the first or last position.
    */
   moveWidgetWithinArea(aWidgetId, aPosition) {
     CustomizableUIInternal.moveWidgetWithinArea(aWidgetId, aPosition);
   },
   /**
    * Ensure a XUL-based widget created in a window after areas were
    * initialized moves to its correct position.
-   * This is roughly equivalent to manually looking up the position and using
-   * insertItem in the old API, but a lot less work for consumers.
-   * Always prefer this over using toolbar.insertItem (which might no-op
-   * because it delegates to addWidgetToArea) or, worse, moving items in the
-   * DOM yourself.
+   * Always prefer this over moving items in the DOM yourself.
    *
    * @param aWidgetId the ID of the widget that was just created
    * @param aWindow the window in which you want to ensure it was added.
    *
    * NB: why is this API per-window, you wonder? Because if you need this,
    * presumably you yourself need to create the widget in all the windows
    * and need to loop through them anyway.
    */
--- a/browser/components/customizableui/content/toolbar.xml
+++ b/browser/components/customizableui/content/toolbar.xml
@@ -31,57 +31,26 @@
 
           // pass the current set of children for comparison with placements:
           let children = Array.from(this.children)
                               .filter(node => node.getAttribute("skipintoolbarset") != "true" && node.id)
                               .map(node => node.id);
           CustomizableUI.registerToolbarNode(this, children);
       ]]></constructor>
 
-      <method name="insertItem">
-        <parameter name="aId"/>
-        <parameter name="aBeforeElt"/>
-        <parameter name="aWrapper"/>
-        <body><![CDATA[
-          if (aWrapper) {
-            Cu.reportError("Can't insert " + aId + ": using insertItem " +
-                           "no longer supports wrapper elements.");
-            return null;
-          }
-
-          // Hack, the customizable UI code makes this be the last position
-          let pos = null;
-          if (aBeforeElt) {
-            let beforeInfo = CustomizableUI.getPlacementOfWidget(aBeforeElt.id);
-            if (beforeInfo.area != this.id) {
-              Cu.reportError("Can't insert " + aId + " before " +
-                             aBeforeElt.id + " which isn't in this area (" +
-                             this.id + ").");
-              return null;
-            }
-            pos = beforeInfo.position;
-          }
-
-          CustomizableUI.addWidgetToArea(aId, this.id, pos);
-          return this.ownerDocument.getElementById(aId);
-        ]]></body>
-      </method>
-
       <property name="customizationTarget" readonly="true">
         <getter><![CDATA[
           if (this._customizationTarget)
             return this._customizationTarget;
 
           let id = this.getAttribute("customizationtarget");
           if (id)
             this._customizationTarget = document.getElementById(id);
 
-          if (this._customizationTarget)
-            this._customizationTarget.insertItem = this.insertItem.bind(this);
-          else
+          if (!this._customizationTarget)
             this._customizationTarget = this;
 
           return this._customizationTarget;
         ]]></getter>
       </property>
 
       <property name="currentSet">
         <getter><![CDATA[
@@ -148,21 +117,16 @@
 
   <binding id="toolbar-menubar-stub">
     <implementation>
       <property name="currentSet" readonly="true">
         <getter><![CDATA[
           return this.getAttribute("defaultset");
         ]]></getter>
       </property>
-      <method name="insertItem">
-        <body><![CDATA[
-          return null;
-        ]]></body>
-      </method>
     </implementation>
   </binding>
 
   <!-- The toolbar-drag binding is almost a verbatim copy of its toolkit counterpart,
        but it inherits from the customizableui's toolbar binding instead of toolkit's.
        This functionality will move into CustomizableUI proper as part of our move
        away from XBL. -->
   <binding id="toolbar-drag"
--- a/browser/components/customizableui/test/browser_968565_insert_before_hidden_items.js
+++ b/browser/components/customizableui/test/browser_968565_insert_before_hidden_items.js
@@ -33,18 +33,18 @@ add_task(async function() {
 
   info("The last visible item in the nav-bar has ID: " + lastVisible.id);
 
   let hidden1 = createDummyXULButton(kHidden1Id, "You can't see me");
   let hidden2 = createDummyXULButton(kHidden2Id, "You can't see me either.");
   hidden1.hidden = hidden2.hidden = true;
 
   // Make sure we have some hidden items at the end of the nav-bar.
-  navbar.insertItem(hidden1.id);
-  navbar.insertItem(hidden2.id);
+  CustomizableUI.addWidgetToArea(kHidden1Id, "nav-bar");
+  CustomizableUI.addWidgetToArea(kHidden2Id, "nav-bar");
 
   // Drag an item and drop it onto the nav-bar customization target, but
   // not over a particular item.
   await startCustomizing();
   let homeButton = document.getElementById("home-button");
   simulateItemDrag(homeButton, navbar.customizationTarget, "end");
 
   await endCustomizing();