Merge f-t to m-c
authorPhil Ringnalda <philringnalda@gmail.com>
Sun, 16 Feb 2014 08:47:19 -0800
changeset 169432 a1cf2184b51dcddabceb26f0f8a0a8474357367f
parent 169428 343913e3297a91bce6be8117fe25a26c3ec6e872 (current diff)
parent 169431 1e176b92c297d6087f22a2fef59b3f672559fb3e (diff)
child 169435 2bddbd180d2d9fa38ac4138267e1cbfebc6bb5ef
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
milestone30.0a1
Merge f-t to m-c
--- a/browser/components/customizableui/src/CustomizeMode.jsm
+++ b/browser/components/customizableui/src/CustomizeMode.jsm
@@ -131,16 +131,21 @@ CustomizeMode.prototype = {
       return;
     }
 
     let window = this.window;
     let document = this.document;
 
     this._handler.isEnteringCustomizeMode = true;
 
+    // Always disable the reset button at the start of customize mode, it'll be re-enabled
+    // if necessary when we finish entering:
+    let resetButton = this.document.getElementById("customization-reset-button");
+    resetButton.setAttribute("disabled", "true");
+
     Task.spawn(function() {
       // We shouldn't start customize mode until after browser-delayed-startup has finished:
       if (!this.window.gBrowserInit.delayedStartupFinished) {
         let delayedStartupDeferred = Promise.defer();
         let delayedStartupObserver = function(aSubject) {
           if (aSubject == this.window) {
             Services.obs.removeObserver(delayedStartupObserver, "browser-delayed-startup-finished");
             delayedStartupDeferred.resolve();
@@ -308,16 +313,21 @@ CustomizeMode.prototype = {
     this.visiblePalette.hidden = true;
     this.paletteEmptyNotice.hidden = true;
 
     // Disable the button-text fade-out mask
     // during the transition for increased perf.
     let panelContents = window.PanelUI.contents;
     panelContents.setAttribute("customize-transitioning", "true");
 
+    // Disable the reset and undo reset buttons while transitioning:
+    let resetButton = this.document.getElementById("customization-reset-button");
+    let undoResetButton = this.document.getElementById("customization-undo-reset-button");
+    undoResetButton.hidden = resetButton.disabled = true;
+
     this._transitioning = true;
 
     Task.spawn(function() {
       yield this.depopulatePalette();
 
       yield this._doTransition(false);
 
       let customizer = document.getElementById("customization-container");
--- a/browser/devtools/sourceeditor/autocomplete.js
+++ b/browser/devtools/sourceeditor/autocomplete.js
@@ -23,49 +23,44 @@ function setupAutoCompletion(ctx, walker
 
   let popup = new AutocompletePopup(win.parent.document, {
     position: "after_start",
     fixedWidth: true,
     theme: "auto",
     autoSelect: true
   });
 
+  let cycle = (reverse) => {
+    if (popup && popup.isOpen) {
+      cycleSuggestions(ed, reverse == true);
+      return;
+    }
+
+    return win.CodeMirror.Pass;
+  };
+
   let keyMap = {
-    "Tab": cm => {
+    "Tab": cycle,
+    "Down": cycle,
+    "Shift-Tab": cycle.bind(this, true),
+    "Up": cycle.bind(this, true),
+    "Enter": () => {
       if (popup && popup.isOpen) {
-        cycleSuggestions(ed);
-        return;
-      }
-
-      return win.CodeMirror.Pass;
-    },
-    "Shift-Tab": cm => {
-      if (popup && popup.isOpen) {
-        cycleSuggestions(ed, true);
+        if (!privates.get(ed).suggestionInsertedOnce) {
+          privates.get(ed).insertingSuggestion = true;
+          let {label, preLabel} = popup.getItemAtIndex(0);
+          let cur = ed.getCursor();
+          ed.replaceText(label.slice(preLabel.length), cur, cur);
+        }
+        popup.hidePopup();
         return;
       }
 
       return win.CodeMirror.Pass;
-    },
-    "Up": cm => {
-      if (popup && popup.isOpen) {
-        cycleSuggestions(ed, true);
-        return;
-      }
-
-      return win.CodeMirror.Pass;
-    },
-    "Down": cm => {
-      if (popup && popup.isOpen) {
-        cycleSuggestions(ed);
-        return;
-      }
-
-      return win.CodeMirror.Pass;
-    },
+    }
   };
   keyMap[Editor.accel("Space")] = cm => autoComplete(ctx);
   cm.addKeyMap(keyMap);
 
   cm.on("keydown", (cm, e) => onEditorKeypress(ed, e));
   ed.on("change", () => autoComplete(ctx));
   ed.on("destroy", () => {
     cm.off("keydown", (cm, e) => onEditorKeypress(ed, e));
@@ -167,17 +162,16 @@ function onEditorKeypress(ed, event) {
       if (private.popup.isOpen)
         event.preventDefault();
     case event.DOM_VK_LEFT:
     case event.DOM_VK_RIGHT:
     case event.DOM_VK_HOME:
     case event.DOM_VK_END:
     case event.DOM_VK_BACK_SPACE:
     case event.DOM_VK_DELETE:
-    case event.DOM_VK_RETURN:
       private.doNotAutocomplete = true;
       private.popup.hidePopup();
       break;
 
     default:
       private.doNotAutocomplete = false;
   }
 }
--- a/browser/devtools/styleeditor/test/browser_styleeditor_autocomplete.js
+++ b/browser/devtools/styleeditor/test/browser_styleeditor_autocomplete.js
@@ -44,17 +44,17 @@ let TEST_CASES = [
   ['VK_TAB', 4, 1, 1],
   ['VK_TAB', 4, 2, 1],
   ['VK_LEFT', -1],
   ['VK_RIGHT', -1],
   ['VK_DOWN', -1],
   ['VK_RETURN', -1],
   ['b', 2, 0],
   ['u', 1, 0],
-  ['VK_TAB', -1],
+  ['VK_RETURN', -1, 0, 1],
   ['{', -1],
   ['VK_HOME', -1],
   ['VK_DOWN', -1],
   ['VK_DOWN', -1],
   ['VK_RIGHT', -1],
   ['VK_RIGHT', -1],
   ['VK_RIGHT', -1],
   ['VK_RIGHT', -1],
@@ -142,16 +142,23 @@ function checkState() {
         let { line, ch } = gEditor.getCursor();
         let lineText = gEditor.getText(line);
         is(lineText.substring(ch - label.length, ch), label,
            "Current suggestion from the popup is inserted into the editor.");
       }
     }
     else {
       ok(!gPopup.isOpen, "Popup is closed for index " + index);
+      if (inserted) {
+        let { preLabel, label } = gPopup.getItemAtIndex(current);
+        let { line, ch } = gEditor.getCursor();
+        let lineText = gEditor.getText(line);
+        is(lineText.substring(ch - label.length, ch), label,
+           "Current suggestion from the popup is inserted into the editor.");
+      }
     }
     index++;
     testState();
   });
 }
 
 function testAutocompletionDisabled() {
   gBrowser.removeCurrentTab();