Bug 501496 part.12 tilt-visualizer should use keydown event handler instead of keypress event handler for Escape key r=vp
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 25 Jul 2013 15:09:29 +0900
changeset 152209 3bab9863c657c6eb7bc8191d078c04bc4a673143
parent 152208 998d70e156bde2a4d0eab547f8126772f8285c2c
child 152210 949a5e125a8d117473010c920dc08ae8426c7afd
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvp
bugs501496
milestone25.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 501496 part.12 tilt-visualizer should use keydown event handler instead of keypress event handler for Escape key r=vp
browser/devtools/tilt/tilt-visualizer.js
--- a/browser/devtools/tilt/tilt-visualizer.js
+++ b/browser/devtools/tilt/tilt-visualizer.js
@@ -1222,17 +1222,16 @@ TiltVisualizer.Controller.prototype = {
     canvas.addEventListener("mousedown", this._onMouseDown, false);
     canvas.addEventListener("mouseup", this._onMouseUp, false);
     canvas.addEventListener("mousemove", this._onMouseMove, false);
     canvas.addEventListener("mouseover", this._onMouseOver, false);
     canvas.addEventListener("mouseout", this._onMouseOut, false);
     canvas.addEventListener("MozMousePixelScroll", this._onMozScroll, false);
     canvas.addEventListener("keydown", this._onKeyDown, false);
     canvas.addEventListener("keyup", this._onKeyUp, false);
-    canvas.addEventListener("keypress", this._onKeyPress, true);
     canvas.addEventListener("blur", this._onBlur, false);
 
     // handle resize events to change the arcball dimensions
     presenter.contentWindow.addEventListener("resize", this._onResize, false);
   },
 
   /**
    * Removes all added events listeners required by this controller.
@@ -1245,17 +1244,16 @@ TiltVisualizer.Controller.prototype = {
     canvas.removeEventListener("mousedown", this._onMouseDown, false);
     canvas.removeEventListener("mouseup", this._onMouseUp, false);
     canvas.removeEventListener("mousemove", this._onMouseMove, false);
     canvas.removeEventListener("mouseover", this._onMouseOver, false);
     canvas.removeEventListener("mouseout", this._onMouseOut, false);
     canvas.removeEventListener("MozMousePixelScroll", this._onMozScroll, false);
     canvas.removeEventListener("keydown", this._onKeyDown, false);
     canvas.removeEventListener("keyup", this._onKeyUp, false);
-    canvas.removeEventListener("keypress", this._onKeyPress, true);
     canvas.removeEventListener("blur", this._onBlur, false);
 
     // Closing the tab would result in contentWindow being a dead object,
     // so operations like removing event listeners won't work anymore.
     if (presenter.contentWindow == presenter.chromeWindow.content) {
       presenter.contentWindow.removeEventListener("resize", this._onResize, false);
     }
   },
@@ -1387,16 +1385,25 @@ TiltVisualizer.Controller.prototype = {
 
     if (!e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey) {
       e.preventDefault();
       e.stopPropagation();
       this.arcball.keyDown(code);
     } else {
       this.arcball.cancelKeyEvents();
     }
+
+    if (e.keyCode === e.DOM_VK_ESCAPE) {
+      let {TiltManager} = require("devtools/tilt/tilt");
+      let tilt =
+        TiltManager.getTiltForBrowser(this.presenter.chromeWindow);
+      e.preventDefault();
+      e.stopPropagation();
+      tilt.destroy(tilt.currentWindowId, true);
+    }
   },
 
   /**
    * Called when a key is released.
    */
   _onKeyUp: function TVC__onKeyUp(e)
   {
     let code = e.keyCode || e.which;
@@ -1415,31 +1422,16 @@ TiltVisualizer.Controller.prototype = {
     if (!e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey) {
       e.preventDefault();
       e.stopPropagation();
       this.arcball.keyUp(code);
     }
   },
 
   /**
-   * Called when a key is pressed.
-   */
-  _onKeyPress: function TVC__onKeyPress(e)
-  {
-    if (e.keyCode === e.DOM_VK_ESCAPE) {
-      let {TiltManager} = require("devtools/tilt/tilt");
-      let tilt =
-        TiltManager.getTiltForBrowser(this.presenter.chromeWindow);
-      e.preventDefault();
-      e.stopPropagation();
-      tilt.destroy(tilt.currentWindowId, true);
-    }
-  },
-
-  /**
    * Called when the canvas looses focus.
    */
   _onBlur: function TVC__onBlur(e) {
     this.arcball.cancelKeyEvents();
   },
 
   /**
    * Called when the content window of the current browser is resized.