Bug 1446329 - Add the spinbuttons binding to TB after its removal in core. r=jorgk a=jorgk
authorRichard Marti <richard.marti@gmail.com>
Fri, 16 Mar 2018 12:17:03 +0100
changeset 31307 e00eecebce720686e13132f937682f674176ad45
parent 31306 26224b3e60fb60c03a4371552255bcd3f8bd436a
child 31308 2c9749f769d899e14a38fc027551f541c3112a98
push id383
push userclokep@gmail.com
push dateMon, 07 May 2018 21:52:48 +0000
reviewersjorgk, jorgk
bugs1446329
Bug 1446329 - Add the spinbuttons binding to TB after its removal in core. r=jorgk a=jorgk
common/bindings/spinbuttons.xml
mail/base/content/bindings.css
mail/base/jar.mn
mail/themes/linux/jar.mn
mail/themes/linux/mail/spinbuttons.css
mail/themes/osx/jar.mn
mail/themes/osx/mail/spinbuttons.css
mail/themes/windows/jar.mn
mail/themes/windows/mail/spinbuttons.css
new file mode 100644
--- /dev/null
+++ b/common/bindings/spinbuttons.xml
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- 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/. -->
+
+<bindings id="spinbuttonsBindings"
+   xmlns="http://www.mozilla.org/xbl"
+   xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+   xmlns:xbl="http://www.mozilla.org/xbl">
+
+  <binding id="spinbuttons"
+           extends="chrome://global/content/bindings/general.xml#basecontrol">
+
+    <resources>
+#ifdef MOZ_SUITE
+      <stylesheet src="chrome://communicator/skin/spinbuttons.css"/>
+#else
+      <stylesheet src="chrome://messenger/skin/spinbuttons.css"/>
+#endif
+    </resources>
+
+    <content>
+      <xul:vbox class="spinbuttons-box" flex="1">
+        <xul:button anonid="increaseButton" type="repeat" flex="1"
+                    class="spinbuttons-button spinbuttons-up"
+                    xbl:inherits="disabled,disabled=increasedisabled"/>
+        <xul:button anonid="decreaseButton" type="repeat" flex="1"
+                    class="spinbuttons-button spinbuttons-down"
+                    xbl:inherits="disabled,disabled=decreasedisabled"/>
+      </xul:vbox>
+    </content>
+
+    <implementation>
+      <property name="_increaseButton" readonly="true">
+        <getter>
+          return document.getAnonymousElementByAttribute(this, "anonid", "increaseButton");
+        </getter>
+      </property>
+      <property name="_decreaseButton" readonly="true">
+        <getter>
+          return document.getAnonymousElementByAttribute(this, "anonid", "decreaseButton");
+        </getter>
+      </property>
+
+      <property name="increaseDisabled"
+                onget="return this._increaseButton.getAttribute('disabled') == 'true';"
+                onset="if (val) this._increaseButton.setAttribute('disabled', 'true');
+                       else this._increaseButton.removeAttribute('disabled'); return val;"/>
+      <property name="decreaseDisabled"
+                onget="return this._decreaseButton.getAttribute('disabled') == 'true';"
+                onset="if (val) this._decreaseButton.setAttribute('disabled', 'true');
+                       else this._decreaseButton.removeAttribute('disabled'); return val;"/>
+    </implementation>
+
+    <handlers>
+      <handler event="mousedown">
+        <![CDATA[
+          // on the Mac, the native theme draws the spinbutton as a single widget
+          // so a state attribute is set based on where the mouse button was pressed
+          if (event.originalTarget == this._increaseButton)
+            this.setAttribute("state", "up");
+          else if (event.originalTarget == this._decreaseButton)
+            this.setAttribute("state", "down");
+        ]]>
+      </handler>
+
+      <handler event="mouseup">
+        this.removeAttribute("state");
+      </handler>
+      <handler event="mouseout">
+        this.removeAttribute("state");
+      </handler>
+
+      <handler event="command">
+        <![CDATA[
+          var eventname;
+          if (event.originalTarget == this._increaseButton)
+            eventname = "up";
+          else if (event.originalTarget == this._decreaseButton)
+            eventname = "down";
+
+          var evt = document.createEvent("Events");
+          evt.initEvent(eventname, true, true);
+          var cancel = this.dispatchEvent(evt);
+
+          if (this.hasAttribute("on" + eventname)) {
+            var fn = new Function("event", this.getAttribute("on" + eventname));
+            if (fn.call(this, event) == false)
+              cancel = true;
+          }
+
+          return !cancel;
+        ]]>
+      </handler>
+
+    </handlers>
+  </binding>
+
+</bindings>
\ No newline at end of file
--- a/mail/base/content/bindings.css
+++ b/mail/base/content/bindings.css
@@ -39,15 +39,23 @@ datepicker[type="popup"] {
 datepicker[type="grid"] {
   -moz-binding: url('chrome://messenger/content/datetimepicker.xml#datepicker-grid');
 }
 
 timepicker {
   -moz-binding: url('chrome://messenger/content/datetimepicker.xml#timepicker');
 }
 
+spinbuttons {
+  -moz-binding: url("chrome://messenger/content/spinbuttons.xml#spinbuttons");
+}
+
+.spinbuttons-button {
+  -moz-user-focus: ignore;
+}
+
 statusbar {
   -moz-binding: url("chrome://messenger/content/generalBindings.xml#statusbar");
 }
 
 statusbarpanel {
   -moz-binding: url("chrome://messenger/content/generalBindings.xml#statusbarpanel");
 }
--- a/mail/base/jar.mn
+++ b/mail/base/jar.mn
@@ -40,16 +40,17 @@ messenger.jar:
     content/messenger/customizeToolbar.css          (../../common/src/customizeToolbar.css)
     content/messenger/customizeToolbar.js           (../../common/src/customizeToolbar.js)
 *   content/messenger/customizeToolbar.xul          (../../common/src/customizeToolbar.xul)
     content/messenger/viewSource.css                (../../common/src/viewSource.css)
     content/messenger/viewSource.js                 (../../common/src/viewSource.js)
 *   content/messenger/viewSource.xul                (../../common/src/viewSource.xul)
 *   content/messenger/datetimepicker.xml            (../../common/bindings/datetimepicker.xml)
     content/messenger/generalBindings.xml           (../../common/bindings/generalBindings.xml)
+*   content/messenger/spinbuttons.xml               (../../common/bindings/spinbuttons.xml)
 *   content/messenger/toolbar.xml                   (../../common/bindings/toolbar.xml)
 *   content/messenger/bindings.css                  (content/bindings.css)
     content/messenger/nsDragAndDrop.js              (content/nsDragAndDrop.js)
     content/messenger/editContactOverlay.js         (content/editContactOverlay.js)
 *   content/messenger/editContactOverlay.xul        (content/editContactOverlay.xul)
     content/messenger/msgMail3PaneWindow.js         (content/msgMail3PaneWindow.js)
     content/messenger/mail3PaneWindowCommands.js    (content/mail3PaneWindowCommands.js)
     content/messenger/mailCommands.js               (content/mailCommands.js)
--- a/mail/themes/linux/jar.mn
+++ b/mail/themes/linux/jar.mn
@@ -51,16 +51,17 @@ classic.jar:
   skin/classic/messenger/icons/zoomout.png                    (mail/icons/zoomout.png)
   skin/classic/messenger/icons/zoomout-hover.png              (mail/icons/zoomout-hover.png)
   skin/classic/messenger/dialogs.css                          (mail/dialogs.css)
   skin/classic/messenger/filefield.css                        (mail/filefield.css)
   skin/classic/messenger/newmailalert.css                     (mail/newmailalert.css)
   skin/classic/messenger/tabmail.css                          (mail/tabmail.css)
   skin/classic/messenger/editContactOverlay.css               (mail/editContactOverlay.css)
   skin/classic/messenger/quickFilterBar.css                   (mail/quickFilterBar.css)
+  skin/classic/messenger/spinbuttons.css                      (mail/spinbuttons.css)
   skin/classic/messenger/activity/activity.css                (mail/activity/activity.css)
   skin/classic/messenger/activity/buttons.png                 (mail/activity/buttons.png)
   skin/classic/messenger/activity/defaultProcessIcon.png      (mail/activity/defaultProcessIcon.png)
   skin/classic/messenger/activity/defaultEventIcon.png        (mail/activity/defaultEventIcon.png)
   skin/classic/messenger/activity/defaultWarningIcon.png      (mail/activity/defaultWarningIcon.png)
   skin/classic/messenger/activity/undoIcon.png                (mail/activity/undoIcon.png)
   skin/classic/messenger/activity/syncMailIcon.png            (mail/activity/syncMailIcon.png)
   skin/classic/messenger/activity/sendMailIcon.png            (mail/activity/sendMailIcon.png)
new file mode 100644
--- /dev/null
+++ b/mail/themes/linux/mail/spinbuttons.css
@@ -0,0 +1,24 @@
+/* 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/. */
+
+@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
+
+spinbuttons {
+  -moz-appearance: spinner;
+  cursor: default;
+}
+
+.spinbuttons-button {
+  min-width: 13px;
+  min-height: 11px;
+  margin: 0 !important;
+}
+
+.spinbuttons-up {
+  -moz-appearance: spinner-upbutton;
+}
+
+.spinbuttons-down {
+  -moz-appearance: spinner-downbutton;
+}
--- a/mail/themes/osx/jar.mn
+++ b/mail/themes/osx/jar.mn
@@ -45,16 +45,17 @@ classic.jar:
   skin/classic/messenger/folderPane.css                          (mail/folderPane.css)
   skin/classic/messenger/subscribe.css                           (mail/subscribe.css)
   skin/classic/messenger/virtualFolderListDialog.css             (mail/virtualFolderListDialog.css)
   skin/classic/messenger/searchDialog.css                        (mail/searchDialog.css)
   skin/classic/messenger/filterDialog.css                        (mail/filterDialog.css)
   skin/classic/messenger/tabmail.css                             (mail/tabmail.css)
   skin/classic/messenger/editContactOverlay.css                  (mail/editContactOverlay.css)
   skin/classic/messenger/quickFilterBar.css                      (mail/quickFilterBar.css)
+  skin/classic/messenger/spinbuttons.css                         (mail/spinbuttons.css)
   skin/classic/messenger/activity/activity.css                   (mail/activity/activity.css)
   skin/classic/messenger/activity/buttons.png                    (mail/activity/buttons.png)
   skin/classic/messenger/activity/defaultProcessIcon.png         (mail/activity/defaultProcessIcon.png)
   skin/classic/messenger/activity/defaultEventIcon.png           (mail/activity/defaultEventIcon.png)
   skin/classic/messenger/activity/error.png                      (mail/activity/error.png)
   skin/classic/messenger/activity/undoIcon.png                   (mail/activity/undoIcon.png)
   skin/classic/messenger/activity/syncMailIcon.png               (mail/activity/syncMailIcon.png)
   skin/classic/messenger/activity/sendMailIcon.png               (mail/activity/sendMailIcon.png)
new file mode 100644
--- /dev/null
+++ b/mail/themes/osx/mail/spinbuttons.css
@@ -0,0 +1,31 @@
+/* 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/. */
+
+@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
+
+spinbuttons {
+  height: 24px;
+  min-height: 24px;
+  -moz-appearance: spinner;
+  cursor: default;
+}
+
+.spinbuttons-up {
+  -moz-appearance: none;
+  -moz-box-flex: 1;
+  min-width: 1px;
+  min-height: 1px;
+  margin: 0;
+  padding: 0;
+}
+
+.spinbuttons-down {
+  -moz-appearance: none;
+  -moz-box-flex: 1;
+  min-width: 1px;
+  min-height: 1px;
+  margin: 0;
+  padding: 0;
+}
+
--- a/mail/themes/windows/jar.mn
+++ b/mail/themes/windows/jar.mn
@@ -48,16 +48,17 @@ classic.jar:
   skin/classic/messenger/multimessageview.css                 (mail/multimessageview.css)
   skin/classic/messenger/glodaFacetView.css                   (mail/glodaFacetView.css)
   skin/classic/messenger/icons/exclude.png                    (mail/icons/exclude.png)
   skin/classic/messenger/icons/exclude-selected.png           (mail/icons/exclude-selected.png)
   skin/classic/messenger/newmailalert.css                     (mail/newmailalert.css)
   skin/classic/messenger/tabmail.css                          (mail/tabmail.css)
   skin/classic/messenger/editContactOverlay.css               (mail/editContactOverlay.css)
   skin/classic/messenger/quickFilterBar.css                   (mail/quickFilterBar.css)
+  skin/classic/messenger/spinbuttons.css                      (mail/spinbuttons.css)
   skin/classic/messenger/activity/activity.css                (mail/activity/activity.css)
   skin/classic/messenger/activity/addItemIcon.png             (mail/activity/addItemIcon.png)
   skin/classic/messenger/activity/buttons.png                 (mail/activity/buttons.png)
   skin/classic/messenger/activity/compactMailIcon.png         (mail/activity/compactMailIcon.png)
   skin/classic/messenger/activity/copyMailIcon.png            (mail/activity/copyMailIcon.png)
   skin/classic/messenger/activity/defaultEventIcon.png        (mail/activity/defaultEventIcon.png)
   skin/classic/messenger/activity/defaultProcessIcon.png      (mail/activity/defaultProcessIcon.png)
   skin/classic/messenger/activity/deleteMailIcon.png          (mail/activity/deleteMailIcon.png)
new file mode 100644
--- /dev/null
+++ b/mail/themes/windows/mail/spinbuttons.css
@@ -0,0 +1,24 @@
+/* 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/. */
+
+@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
+
+spinbuttons {
+  -moz-appearance: spinner;
+  cursor: default;
+}
+
+.spinbuttons-button {
+  min-width: 13px;
+  min-height: 11px;
+  margin: 0 !important;
+}
+
+.spinbuttons-up {
+  -moz-appearance: spinner-upbutton;
+}
+
+.spinbuttons-down {
+  -moz-appearance: spinner-downbutton;
+}