1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 23:07:59 +01:00
This commit is contained in:
Kris Maglione
2010-12-26 23:45:28 -05:00
parent 8a5eb69492
commit c7c7ab68ee
2 changed files with 16 additions and 64 deletions

View File

@@ -148,39 +148,12 @@ var Buffer = Module("buffer", {
buffer.viewSource([elem.getAttribute("href"), Number(elem.getAttribute("line"))])
};
this.replaceProgressListener(this.progressListener);
this.cleanupProgressListener = util.overlayObject(window.XULBrowserWindow,
this.progressListener);
},
cleanup: function () {
for (let prop in properties(this.progressListener))
if (!this.progressListener.__lookupGetter__(prop) &&
!callable(this.progressListener[prop]))
this.origProgressListener[prop] = this.progressListener[prop]
this.replaceProgressListener(this.origProgressListener);
},
replaceProgressListener: function (newListener) {
// I hate this whole hack. --Kris
let obj = window.XULBrowserWindow, getter;
for (let prop in properties(obj))
if ((getter = obj.__lookupGetter__(prop)) && !obj.__lookupSetter__(prop)) {
newListener.__defineGetter__(prop, getter);
delete obj[prop];
}
this.origProgressListener = window.XULBrowserWindow;
try {
config.browser.removeProgressListener(window.XULBrowserWindow);
}
catch (e) {} // Why? --djk
config.browser.addProgressListener(newListener, Ci.nsIWebProgress.NOTIFY_ALL);
window.XULBrowserWindow = newListener;
window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem).treeOwner
.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIXULWindow)
.XULBrowserWindow = newListener;
this.cleanupProgressListener();
},
destroy: function () {
@@ -237,11 +210,6 @@ var Buffer = Module("buffer", {
dactyl.initHelp();
config.styleHelp();
}
// mark the buffer as loaded, we can't use buffer.loaded
// since that always refers to the current buffer, while doc can be
// any buffer, even in a background tab
doc.pageIsFullyLoaded = 1;
}
if (doc instanceof HTMLDocument) {
@@ -266,10 +234,8 @@ var Buffer = Module("buffer", {
/**
* @property {Object} The document loading progress listener.
*/
progressListener: update(Object.create(window.XULBrowserWindow), {
QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIWebProgressListener]),
loadCount: 0,
progressListener: {
dactylLoadCount: 0,
// XXX: function may later be needed to detect a canceled synchronous openURL()
onStateChange: function onStateChange(webProgress, request, flags, status) {
@@ -280,12 +246,11 @@ var Buffer = Module("buffer", {
// This fires when the load event is initiated
// only thrown for the current tab, not when another tab changes
if (flags & Ci.nsIWebProgressListener.STATE_START) {
webProgress.DOMWindow.document.pageIsFullyLoaded = 0;
statusline.updateProgress(0);
buffer._triggerLoadAutocmd("PageLoadPre", webProgress.DOMWindow.document);
if (document.commandDispatcher.focusedWindow == webProgress.DOMWindow && this.loadCount++)
if (document.commandDispatcher.focusedWindow == webProgress.DOMWindow && this.dactylLoadCount++)
util.timeout(function () { modes.reset(false); },
dactyl.mode == modes.HINTS ? 500 : 0);
}
@@ -294,8 +259,6 @@ var Buffer = Module("buffer", {
config.browser.mCurrentBrowser.collapsed = false;
if (!dactyl.focusedElement)
dactyl.focusContent();
webProgress.DOMWindow.document.pageIsFullyLoaded = (status == 0 ? 1 : 2);
statusline.updateUrl();
}
}
@@ -366,7 +329,7 @@ var Buffer = Module("buffer", {
break;
}
},
}),
},
/**
* @property {Array} The alternative style sheets for the current
@@ -387,19 +350,12 @@ var Buffer = Module("buffer", {
pageInfo: null,
/**
* @property {number} A value indicating whether the buffer is loaded.
* Values may be:
* 0 - Loading.
* 1 - Fully loaded.
* 2 - Load failed.
* @property {number} True when the buffer is fully loaded.
*/
get loaded()
Math.min.apply(Math,
buffer.allFrames().map(function (frame)
frame.document.pageIsFullyLoaded || 0)),
set loaded(val)
buffer.allFrames().forEach(function (frame)
frame.document.pageIsFullyLoaded = val),
get loaded() Math.min.apply(null,
buffer.allFrames()
.map(function (frame) ["loading", "interactive", "complete"]
.indexOf(frame.document.readyState))),
/**
* @property {Object} The local state store for the currently selected

View File

@@ -192,7 +192,6 @@ var Events = Module("events", {
}
catch (e) {}
buffer.loaded = 1; // even if not a full page load, assume it did load correctly before starting the macro
modes.replaying = true;
res = events.feedkeys(this._macros.get(this._lastMacro).keys, { noremap: true });
modes.replaying = false;
@@ -643,15 +642,14 @@ var Events = Module("events", {
commandline.clear();
// TODO: allow macros to be continued when page does not fully load with an option
let ret = (buffer.loaded == 1);
if (!ret)
if (!buffer.loaded)
dactyl.echoerr("Page did not load completely in " + maxWaitTime + " seconds. Macro stopped.");
// sometimes the input widget had focus when replaying a macro
// maybe this call should be moved somewhere else?
// dactyl.focusContent(true);
return ret;
return buffer.loaded;
},
onDOMMenuBarActive: function () {
@@ -1092,7 +1090,6 @@ var Events = Module("events", {
else if (this.pendingArgMap) {
let map = this.pendingArgMap;
if (!Events.isEscape(key))
if (!modes.replaying || this.waitForPageLoad())
execute(map, null, this.count, key);
return true;
}
@@ -1122,8 +1119,7 @@ var Events = Module("events", {
if (modes.replaying && !this.waitForPageLoad())
return true;
let ret = execute(map, null, this.count);
return !(map.route && ret);
return !execute(map, null, this.count) || !map.route
}
}
else if (mappings.getCandidates(this.main, candidateCommand).length > 0 && !event.skipmap) {