]> git.donarmstrong.com Git - dactyl.git/blobdiff - common/content/events.js
Import 1.0 supporting Firefox up to 14.*
[dactyl.git] / common / content / events.js
index 4b1841d916036233bf06ffe07537fbcfc4bf8573..ac846d8ce1cb38cab38a91e81e9dfe02fe6937dc 100644 (file)
@@ -116,7 +116,7 @@ var Events = Module("events", {
         });
 
         this._fullscreen = window.fullScreen;
-        this._lastFocus = null;
+        this._lastFocus = { get: function () null };
         this._macroKeys = [];
         this._lastMacro = "";
 
@@ -143,7 +143,7 @@ var Events = Module("events", {
                         this.active.push(elem);
                 }
 
-                this.active = this.active.filter(function (e) e.popupBoxObject.popupState != "closed");
+                this.active = this.active.filter(function (e) e.popupBoxObject && e.popupBoxObject.popupState != "closed");
 
                 if (!this.active.length && !this.activeMenubar)
                     modes.remove(modes.MENU, true);
@@ -372,8 +372,6 @@ var Events = Module("events", {
             if (quiet)
                 commandline.quiet = quiet;
 
-            keys = mappings.expandLeader(keys);
-
             for (let [, evt_obj] in Iterator(DOM.Event.parse(keys))) {
                 let now = Date.now();
                 let key = DOM.Event.stringify(evt_obj);
@@ -625,7 +623,7 @@ var Events = Module("events", {
             }
 
             if (elem instanceof Element)
-                elem.dactylFocusAllowed = undefined;
+                delete overlay.getData(elem)["focus-allowed"];
         },
 
         /*
@@ -795,9 +793,10 @@ var Events = Module("events", {
                     !this.processor && event.type === "keydown"
                         && options.get("passunknown").getKey(modes.main.allBases)
                         && let (key = DOM.Event.stringify(event))
-                            !modes.main.allBases.some(
+                            !(modes.main.count && /^\d$/.test(key) ||
+                              modes.main.allBases.some(
                                 function (mode) mappings.hives.some(
-                                    function (hive) hive.get(mode, key) || hive.getCandidates(mode, key)));
+                                    function (hive) hive.get(mode, key) || hive.getCandidates(mode, key))));
 
             events.dbg("ON " + event.type.toUpperCase() + " " + DOM.Event.stringify(event) +
                        " passing: " + this.passing + " " +
@@ -902,20 +901,22 @@ var Events = Module("events", {
             }
 
             let urlbar = document.getElementById("urlbar");
-            if (elem == null && urlbar && urlbar.inputField == this._lastFocus)
+            if (elem == null && urlbar && urlbar.inputField == this._lastFocus.get())
                 util.threadYield(true); // Why? --Kris
 
             while (modes.main.ownsFocus
-                    && modes.topOfStack.params.ownsFocus != elem
-                    && modes.topOfStack.params.ownsFocus != win
+                    && let ({ ownsFocus } = modes.topOfStack.params)
+                         (!ownsFocus ||
+                             ownsFocus.get() != elem &&
+                             ownsFocus.get() != win)
                     && !modes.topOfStack.params.holdFocus)
                  modes.pop(null, { fromFocus: true });
         }
         finally {
-            this._lastFocus = elem;
+            this._lastFocus = util.weakReference(elem);
 
             if (modes.main.ownsFocus)
-                modes.topOfStack.params.ownsFocus = elem;
+                modes.topOfStack.params.ownsFocus = util.weakReference(elem);
         }
     }),