Bug 1461388 - Migrate XUL deck from a XBL binding to a Custom Element;r=timdream
authorBrian Grinstead <bgrinstead@mozilla.com>
Wed, 04 Apr 2018 21:29:06 -0700
changeset 418244 1dcadcb948ddeaa9109898cc2dfea286f3b9370e
parent 418243 9a2af4dad8113d6cfabb7308339e19a6c5dd2309
child 418245 9d64158bdbf34177b896997ce0a75abfa43c1f7a
push id33996
push userncsoregi@mozilla.com
push dateTue, 15 May 2018 09:52:38 +0000
treeherdermozilla-central@2fa8aedae0ff [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstimdream
bugs1461388
milestone62.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 1461388 - Migrate XUL deck from a XBL binding to a Custom Element;r=timdream MozReview-Commit-ID: F95i9H9FvYv
toolkit/components/processsingleton/MainProcessSingleton.js
toolkit/content/jar.mn
toolkit/content/widgets/general.js
toolkit/content/widgets/general.xml
toolkit/content/xul.css
--- a/toolkit/components/processsingleton/MainProcessSingleton.js
+++ b/toolkit/components/processsingleton/MainProcessSingleton.js
@@ -81,16 +81,17 @@ MainProcessSingleton.prototype = {
       // in the document. Anything loaded here should be considered part of
       // core XUL functionality. Any window-specific elements can be registered
       // via <script> tags at the top of individual documents.
       const doc = subject;
       if (doc.nodePrincipal.isSystemPrincipal &&
           doc.contentType == "application/vnd.mozilla.xul+xml") {
         for (let script of [
           "chrome://global/content/elements/stringbundle.js",
+          "chrome://global/content/elements/general.js",
         ]) {
           Services.scriptloader.loadSubScript(script, doc.ownerGlobal);
         }
       }
       break;
 
     case "xpcom-shutdown":
       Services.mm.removeMessageListener("Search:AddEngine", this.addSearchEngine);
--- a/toolkit/content/jar.mn
+++ b/toolkit/content/jar.mn
@@ -95,14 +95,15 @@ toolkit.jar:
 *  content/global/bindings/textbox.xml         (widgets/textbox.xml)
    content/global/bindings/timekeeper.js       (widgets/timekeeper.js)
    content/global/bindings/timepicker.js       (widgets/timepicker.js)
    content/global/bindings/toolbar.xml         (widgets/toolbar.xml)
    content/global/bindings/toolbarbutton.xml   (widgets/toolbarbutton.xml)
 *  content/global/bindings/tree.xml            (widgets/tree.xml)
    content/global/bindings/videocontrols.xml   (widgets/videocontrols.xml)
 *  content/global/bindings/wizard.xml          (widgets/wizard.xml)
+   content/global/elements/general.js           (widgets/general.js)
    content/global/elements/stringbundle.js     (widgets/stringbundle.js)
 #ifdef XP_MACOSX
    content/global/macWindowMenu.js
 #endif
    content/global/gmp-sources/openh264.json    (gmp-sources/openh264.json)
    content/global/gmp-sources/widevinecdm.json (gmp-sources/widevinecdm.json)
new file mode 100644
--- /dev/null
+++ b/toolkit/content/widgets/general.js
@@ -0,0 +1,38 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * 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/. */
+
+"use strict";
+
+{
+
+class MozDeck extends XULElement {
+  set selectedIndex(val) {
+    if (this.selectedIndex == val) return val;
+    this.setAttribute("selectedIndex", val);
+    var event = document.createEvent("Events");
+    event.initEvent("select", true, true);
+    this.dispatchEvent(event);
+    return val;
+  }
+
+  get selectedIndex() {
+    return this.getAttribute("selectedIndex") || "0";
+  }
+
+  set selectedPanel(val) {
+    var selectedIndex = -1;
+    for (var panel = val; panel != null; panel = panel.previousSibling)
+      ++selectedIndex;
+    this.selectedIndex = selectedIndex;
+    return val;
+  }
+
+  get selectedPanel() {
+    return this.childNodes[this.selectedIndex];
+  }
+}
+
+customElements.define("deck", MozDeck);
+
+}
--- a/toolkit/content/widgets/general.xml
+++ b/toolkit/content/widgets/general.xml
@@ -75,53 +75,16 @@
       <property name="webNavigation"
                 onget="return this.docShell.QueryInterface(Components.interfaces.nsIWebNavigation);"
                 readonly="true"/>
       <property name="contentDocument" readonly="true"
                 onget="return this.webNavigation.document;"/>
     </implementation>
   </binding>
 
-  <binding id="deck">
-    <implementation>
-      <property name="selectedIndex"
-                onget="return this.getAttribute('selectedIndex') || '0'">
-        <setter>
-        <![CDATA[
-          if (this.selectedIndex == val)
-            return val;
-          this.setAttribute("selectedIndex", val);
-          var event = document.createEvent("Events");
-          event.initEvent("select", true, true);
-          this.dispatchEvent(event);
-          return val;
-        ]]>
-        </setter>
-      </property>
-
-      <property name="selectedPanel">
-        <getter>
-          <![CDATA[
-            return this.childNodes[this.selectedIndex];
-          ]]>
-        </getter>
-
-        <setter>
-          <![CDATA[
-            var selectedIndex = -1;
-            for (var panel = val; panel != null; panel = panel.previousSibling)
-              ++selectedIndex;
-            this.selectedIndex = selectedIndex;
-            return val;
-          ]]>
-        </setter>
-      </property>
-    </implementation>
-  </binding>
-
   <binding id="dropmarker" extends="xul:button">
     <resources>
       <stylesheet src="chrome://global/skin/dropmarker.css"/>
     </resources>
 
     <content>
       <xul:image class="dropmarker-icon"/>
     </content>
--- a/toolkit/content/xul.css
+++ b/toolkit/content/xul.css
@@ -653,17 +653,16 @@ tree:not([treelines="true"]) > treechild
 treechildren::-moz-tree-cell(ltr) {
   direction: ltr !important;
 }
 
 /********** deck & stack *********/
 
 deck {
   display: -moz-deck;
-  -moz-binding: url("chrome://global/content/bindings/general.xml#deck");
 }
 
 stack {
   display: -moz-stack;
 }
 
 /********** tabbox *********/