Merge mozilla-central into holly
authorMike Conley <mconley@mozilla.com>
Fri, 06 Dec 2013 17:17:36 -0500
changeset 174817 85105bb6a540a7b935c30ab72d370f5a16abafcc
parent 174803 ca5206f5c106c4e097d7ae62b2bda021255f181b (current diff)
parent 174816 538e52a54db998662914e3b3f17be88db39f2e28 (diff)
child 174826 7bed4c08d9d3b6c7e929530a21dad97da8ed14f3
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone28.0a1
Merge mozilla-central into holly
--- a/browser/metro/base/content/contenthandlers/FormHelper.js
+++ b/browser/metro/base/content/contenthandlers/FormHelper.js
@@ -124,17 +124,17 @@ FormAssistant.prototype = {
 
     // We only work with choice lists or elements with autocomplete suggestions
     if (!this._isSelectElement(aElement) &&
         !this._isAutocomplete(aElement)) {
       return this.close();
     }
 
     // Don't re-open when navigating to avoid repopulating list when changing selection.
-    if (this._isAutocomplete(aElement) && this._open && this._isNavigationKey(aEvent)) {
+    if (this._isAutocomplete(aElement) && this._open && Util.isNavigationKey(aEvent.keyCode)) {
       return false;
     }
 
     // Enable the assistant
     this.currentElement = aElement;
     return this._open = true;
   },
 
@@ -288,32 +288,16 @@ FormAssistant.prototype = {
       case "text":
         if (this._isAutocomplete(aEvent.target)) {
           this._sendJsonMsgWrapper("FormAssist:AutoComplete");
         }
         break;
     }
   },
 
-  _isNavigationKey: function (aEvent) {
-    // Ignore navigation keys
-    if (aEvent.keyCode) {
-      let navigationKeys = [
-        aEvent.DOM_VK_DOWN,
-        aEvent.DOM_VK_UP,
-        aEvent.DOM_VK_LEFT,
-        aEvent.DOM_VK_RIGHT,
-        aEvent.DOM_VK_PAGE_UP,
-        aEvent.DOM_VK_PAGE_DOWN];
-
-      return navigationKeys.indexOf(aEvent.keyCode) != -1;
-    }
-    return false;
-  },
-
   _executeDelayed: function formHelperExecuteSoon(aCallback) {
     let self = this;
     let timer = new Util.Timeout(function() {
       aCallback(self);
     });
     timer.once(0);
   },
 
--- a/browser/metro/base/content/helperui/MenuUI.js
+++ b/browser/metro/base/content/helperui/MenuUI.js
@@ -45,17 +45,16 @@ var AutofillMenuUI = {
       maxWidth: this._anchorRect.width,
       maxHeight: 350,
       source: Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH
     };
   },
 
   show: function show(aAnchorRect, aSuggestionsList) {
     this.commands.addEventListener("select", this, true);
-    window.addEventListener("keypress", this, true);
 
     this._anchorRect = aAnchorRect;
     this._emptyCommands();
     for (let idx = 0; idx < aSuggestionsList.length; idx++) {
       let item = document.createElement("richlistitem");
       let label = document.createElement("label");
       label.setAttribute("value", aSuggestionsList[idx].label);
       item.setAttribute("value", aSuggestionsList[idx].value);
@@ -67,48 +66,23 @@ var AutofillMenuUI = {
   },
 
   selectByIndex: function mn_selectByIndex(aIndex) {
     this._menuPopup.hide();
     FormHelperUI.doAutoComplete(this.commands.childNodes[aIndex].getAttribute("data"));
   },
 
   hide: function hide () {
-    window.removeEventListener("keypress", this, true);
     this.commands.removeEventListener("select", this, true);
 
     this._menuPopup.hide();
   },
 
   handleEvent: function (aEvent) {
     switch (aEvent.type) {
-      case "keypress":
-        switch (aEvent.keyCode) {
-          case aEvent.DOM_VK_ESCAPE:
-            this.hide();
-            break;
-
-          case aEvent.DOM_VK_DOWN:
-            this.commands.moveByOffset(1, true, false);
-            break;
-
-          case aEvent.DOM_VK_UP:
-            this.commands.moveByOffset(-1, true, false);
-            break;
-
-          case aEvent.DOM_VK_PAGE_DOWN:
-            this.commands.moveByOffset(this.commands.scrollOnePage(1), true, false);
-            break;
-
-          case aEvent.DOM_VK_PAGE_UP:
-            this.commands.moveByOffset(this.commands.scrollOnePage(-1), true, false);
-            break;
-        }
-        break;
-
       case "select":
         FormHelperUI.doAutoComplete(this.commands.value);
         break;
     }
   }
 };
 
 var ContextMenuUI = {
@@ -522,22 +496,57 @@ MenuPopup.prototype = {
     let event = document.createEvent("Events");
     event.initEvent(aName, true, false);
     this._panel.dispatchEvent(event);
   },
 
   handleEvent: function handleEvent(aEvent) {
     switch (aEvent.type) {
       case "keypress":
-        if (!this._wantTypeBehind) {
+        // this.commands is not holding focus and not processing key events.
+        // Proxying events so that they're handled properly.
+
+        // Avoid recursion
+        if (aEvent.mine)
+          break;
+
+        let ev = document.createEvent("KeyboardEvent");
+        ev.initKeyEvent(
+          "keypress",        //  in DOMString typeArg,
+          false,             //  in boolean canBubbleArg,
+          true,              //  in boolean cancelableArg,
+          null,              //  in nsIDOMAbstractView viewArg,  Specifies UIEvent.view. This value may be null.
+          aEvent.ctrlKey,    //  in boolean ctrlKeyArg,
+          aEvent.altKey,     //  in boolean altKeyArg,
+          aEvent.shiftKey,   //  in boolean shiftKeyArg,
+          aEvent.metaKey,    //  in boolean metaKeyArg,
+          aEvent.keyCode,    //  in unsigned long keyCodeArg,
+          aEvent.charCode);  //  in unsigned long charCodeArg);
+
+        ev.mine = true;
+        this.commands.dispatchEvent(ev);
+
+        switch (aEvent.keyCode) {
+          case aEvent.DOM_VK_ESCAPE:
+            this.hide();
+            break;
+
+          case aEvent.DOM_VK_RETURN:
+            this.commands.currentItem.click();
+            break;
+        }
+
+        if (Util.isNavigationKey(aEvent.keyCode)) {
+          aEvent.stopPropagation();
+          aEvent.preventDefault();
+        } else if (!this._wantTypeBehind) {
           // Hide the context menu so you can't type behind it.
           aEvent.stopPropagation();
           aEvent.preventDefault();
-          if (aEvent.keyCode != aEvent.DOM_VK_ESCAPE)
-            this.hide();
+          this.hide();
         }
         break;
       case "blur":
       case "mousedown":
       case "touchstart":
       case "scroll":
         if (!this._popup.contains(aEvent.target)) {
           aEvent.stopPropagation();
--- a/browser/metro/modules/ContentUtil.jsm
+++ b/browser/metro/modules/ContentUtil.jsm
@@ -1,16 +1,17 @@
 /* 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";
 
 this.EXPORTED_SYMBOLS = ["ContentUtil"];
 
 const XHTML_NS = "http://www.w3.org/1999/xhtml";
+const nsIDOMKeyEvent = Components.interfaces.nsIDOMKeyEvent;
 
 this.ContentUtil = {
   populateFragmentFromString: function populateFragmentFromString(fragment, str) {
     let re = /^([^#]*)#(\d+)\b([^#]*)/,
         document = fragment.ownerDocument,
         // the remaining arguments are our {text, className} values
         replacements = Array.slice(arguments, 2),
         match;
@@ -82,11 +83,24 @@ this.ContentUtil = {
           if (copy !== undefined)
             target[name] = copy;
         }
       }
     }
 
     // Return the modified object
     return target;
-  }
+  },
 
+  // Checks if a keycode is used for list navigation.
+  isNavigationKey: function (keyCode) {
+    let navigationKeys = [
+      nsIDOMKeyEvent.DOM_VK_DOWN,
+      nsIDOMKeyEvent.DOM_VK_UP,
+      nsIDOMKeyEvent.DOM_VK_LEFT,
+      nsIDOMKeyEvent.DOM_VK_RIGHT,
+      nsIDOMKeyEvent.DOM_VK_PAGE_UP,
+      nsIDOMKeyEvent.DOM_VK_PAGE_DOWN,
+      nsIDOMKeyEvent.DOM_VK_ESCAPE];
+
+    return navigationKeys.indexOf(keyCode) != -1;
+  }
 };
--- a/mobile/android/base/animation/AnimationUtils.java
+++ b/mobile/android/base/animation/AnimationUtils.java
@@ -4,17 +4,17 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 
 package org.mozilla.gecko.animation;
 
 import android.content.Context;
 
 public class AnimationUtils {
-    private static long mShortDuration;
+    private static long mShortDuration = -1;
 
     public static long getShortDuration(Context context) {
         if (mShortDuration < 0) {
             mShortDuration = context.getResources().getInteger(android.R.integer.config_shortAnimTime);
         }
         return mShortDuration;
     }
 }
--- a/toolkit/devtools/server/actors/script.js
+++ b/toolkit/devtools/server/actors/script.js
@@ -522,22 +522,23 @@ ThreadActor.prototype = {
     eventLoop.enter();
   },
   _popThreadPause: function () {
     const eventLoop = this._threadPauseEventLoops.pop();
     dbg_assert(eventLoop, "Should have an event loop.");
     eventLoop.resolve();
   },
 
+  /**
+   * Remove all debuggees and clear out the thread's sources.
+   */
   clearDebuggees: function () {
     if (this.dbg) {
       this.dbg.removeAllDebuggees();
     }
-    this.conn.removeActorPool(this._threadLifetimePool || undefined);
-    this._threadLifetimePool = null;
     this._sources = null;
   },
 
   /**
    * Add a debuggee global to the Debugger object.
    *
    * @returns the Debugger.Object that corresponds to the global.
    */
@@ -631,16 +632,18 @@ ThreadActor.prototype = {
     dumpn("in ThreadActor.prototype.disconnect");
     if (this._state == "paused") {
       this.onResume();
     }
 
     this._state = "exited";
 
     this.clearDebuggees();
+    this.conn.removeActorPool(this._threadLifetimePool);
+    this._threadLifetimePool = null;
 
     if (this._prettyPrintWorker) {
       this._prettyPrintWorker.removeEventListener(
         "error", this._onPrettyPrintError, false);
       this._prettyPrintWorker.removeEventListener(
         "message", this._onPrettyPrintMsg, false);
       this._prettyPrintWorker.terminate();
       this._prettyPrintWorker = null;