Bug 443609, key usage for scales isn't intuitive, r=neil
authorNeil Deakin <neil@mozilla.com>
Thu, 15 Jan 2009 13:44:38 -0500
changeset 23753 40d354793ca67da2cd46362fb235794dc6d04bd3
parent 23752 5011a32be5d314ce9aec8f40e49ce6c4aab51093
child 23754 59f4175487b696280856d1b1d496ce87a2563d18
push id4704
push userneil@mozilla.com
push dateThu, 15 Jan 2009 18:45:03 +0000
treeherdermozilla-central@40d354793ca6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersneil
bugs443609
milestone1.9.2a1pre
Bug 443609, key usage for scales isn't intuitive, r=neil
toolkit/content/tests/widgets/test_scale.xul
toolkit/content/widgets/scale.xml
--- a/toolkit/content/tests/widgets/test_scale.xul
+++ b/toolkit/content/tests/widgets/test_scale.xul
@@ -97,27 +97,29 @@ function testtag_scale_UI(element, testi
   element.min = 0;
   element.max = 20;
   element.value = 7;
   element.increment = 2;
   element.pageIncrement = 4;
 
   element.focus();
 
+  var leftIncrements = horiz && reverse;
+  var upDecrements = !horiz && !reverse;
   synthesizeKeyExpectEvent("VK_LEFT", { }, element, "change", testid + "key left");
-  is(element.value, reverse ? 9 : 5, testid + " key left");
+  is(element.value, leftIncrements ? 9 : 5, testid + " key left");
   synthesizeKeyExpectEvent("VK_RIGHT", { }, element, "change", testid + "key right");
   is(element.value, 7, testid + " key right");
   synthesizeKeyExpectEvent("VK_UP", { }, element, "change", testid + "key up");
-  is(element.value, reverse ? 9 : 5, testid + " key up");
+  is(element.value, upDecrements ? 5 : 9, testid + " key up");
   synthesizeKeyExpectEvent("VK_DOWN", { }, element, "change", testid + "key down");
   is(element.value, 7, testid + " key down");
 
   synthesizeKeyExpectEvent("VK_PAGE_UP", { }, element, "change", testid + "key page up");
-  is(element.value, reverse ? 11 : 3, testid + " key page up");
+  is(element.value, upDecrements ? 3 : 11, testid + " key page up");
   synthesizeKeyExpectEvent("VK_PAGE_DOWN", { }, element, "change", testid + "key page down");
   is(element.value, 7, testid + " key page down");
 
   synthesizeKeyExpectEvent("VK_HOME", { }, element, "change", testid + "key home");
   is(element.value, reverse ? 20 : 0, testid + " key home");
   synthesizeKeyExpectEvent("VK_END", { }, element, "change", testid + "key end");
   is(element.value, reverse ? 0 : 20, testid + " key end");
 
--- a/toolkit/content/widgets/scale.xml
+++ b/toolkit/content/widgets/scale.xml
@@ -176,45 +176,57 @@
           }
         ]]>
         </body>
       </method>
 
     </implementation>
 
     <handlers>
-      <handler event="keypress" keycode="VK_UP" preventdefault="true">
-        this._userChanged = true;
-        (this.dir == "reverse") ? this.increase() : this.decrease();
-        this._userChanged = false;
+      <handler event="keypress" keycode="VK_LEFT" preventdefault="true">
+        <![CDATA[
+          this._userChanged = true;
+          (this.orient != "vertical" && this.dir == "reverse") ? this.increase() : this.decrease();
+          this._userChanged = false;
+        ]]>
       </handler>
-      <handler event="keypress" keycode="VK_LEFT" preventdefault="true">
-        this._userChanged = true;
-        (this.dir == "reverse") ? this.increase() : this.decrease();
-        this._userChanged = false;
+      <handler event="keypress" keycode="VK_RIGHT" preventdefault="true">
+        <![CDATA[
+          this._userChanged = true;
+          (this.orient != "vertical" && this.dir == "reverse") ? this.decrease() : this.increase();
+          this._userChanged = false;
+        ]]>
+      </handler>
+      <handler event="keypress" keycode="VK_UP" preventdefault="true">
+        <![CDATA[
+          this._userChanged = true;
+          (this.orient == "vertical" && this.dir != "reverse") ? this.decrease() : this.increase();
+          this._userChanged = false;
+        ]]>
       </handler>
       <handler event="keypress" keycode="VK_DOWN" preventdefault="true">
-        this._userChanged = true;
-        (this.dir == "reverse") ? this.decrease() : this.increase();
-        this._userChanged = false;
-      </handler>
-      <handler event="keypress" keycode="VK_RIGHT" preventdefault="true">
-        this._userChanged = true;
-        (this.dir == "reverse") ? this.decrease() : this.increase();
-        this._userChanged = false;
+        <![CDATA[
+          this._userChanged = true;
+          (this.orient == "vertical" && this.dir != "reverse") ? this.increase() : this.decrease();
+          this._userChanged = false;
+        ]]>
       </handler>
       <handler event="keypress" keycode="VK_PAGE_UP" preventdefault="true">
-        this._userChanged = true;
-        (this.dir == "reverse") ? this.increasePage() : this.decreasePage();
-        this._userChanged = false;
+        <![CDATA[
+          this._userChanged = true;
+          (this.orient == "vertical" && this.dir != "reverse") ? this.decreasePage() : this.increasePage();
+          this._userChanged = false;
+        ]]>
       </handler>
       <handler event="keypress" keycode="VK_PAGE_DOWN" preventdefault="true">
-        this._userChanged = true;
-        (this.dir == "reverse") ? this.decreasePage() : this.increasePage();
-        this._userChanged = false;
+        <![CDATA[
+          this._userChanged = true;
+          (this.orient == "vertical" && this.dir != "reverse") ? this.increasePage() : this.decreasePage();
+          this._userChanged = false;
+        ]]>
       </handler>
       <handler event="keypress" keycode="VK_HOME" preventdefault="true">
         this._userChanged = true;
         this.value = (this.dir == "reverse") ? this.max : this.min;
         this._userChanged = false;
       </handler>
       <handler event="keypress" keycode="VK_END" preventdefault="true">
         this._userChanged = true;