mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 11:48:00 +01:00
Defer some initialization until the first window is visible.
This commit is contained in:
@@ -26,6 +26,10 @@
|
|||||||
|
|
||||||
<binding id="tab" display="xul:hbox"
|
<binding id="tab" display="xul:hbox"
|
||||||
extends="chrome://browser/content/tabbrowser.xml#tabbrowser-tab">
|
extends="chrome://browser/content/tabbrowser.xml#tabbrowser-tab">
|
||||||
|
<implementation>
|
||||||
|
<property name="dactylOrdinal" onget="parseInt(this.getAttribute('dactylOrdinal'))"
|
||||||
|
onset="this.setAttribute('dactylOrdinal', val)"/>
|
||||||
|
</implementation>
|
||||||
<content closetabtext="Close Tab">
|
<content closetabtext="Close Tab">
|
||||||
<xul:stack class="tab-icon dactyl-tab-stack">
|
<xul:stack class="tab-icon dactyl-tab-stack">
|
||||||
<xul:image xbl:inherits="validate,src=image" role="presentation" class="tab-icon-image"/>
|
<xul:image xbl:inherits="validate,src=image" role="presentation" class="tab-icon-image"/>
|
||||||
@@ -45,6 +49,10 @@
|
|||||||
|
|
||||||
<binding id="tab-mac"
|
<binding id="tab-mac"
|
||||||
extends="chrome://browser/content/tabbrowser.xml#tabbrowser-tab">
|
extends="chrome://browser/content/tabbrowser.xml#tabbrowser-tab">
|
||||||
|
<implementation>
|
||||||
|
<property name="dactylOrdinal" onget="parseInt(this.getAttribute('dactylOrdinal'))"
|
||||||
|
onset="this.setAttribute('dactylOrdinal', val)"/>
|
||||||
|
</implementation>
|
||||||
<content chromedir="ltr" closetabtext="Close Tab">
|
<content chromedir="ltr" closetabtext="Close Tab">
|
||||||
<xul:hbox class="tab-image-left" xbl:inherits="selected"/>
|
<xul:hbox class="tab-image-left" xbl:inherits="selected"/>
|
||||||
<xul:hbox class="tab-image-middle" flex="1" align="center" xbl:inherits="selected">
|
<xul:hbox class="tab-image-middle" flex="1" align="center" xbl:inherits="selected">
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
delete window.dactyl;
|
delete window.dactyl;
|
||||||
delete window.liberator;
|
delete window.liberator;
|
||||||
|
|
||||||
|
// Prevents box ordering bugs after our stylesheet is removed.
|
||||||
styles.system.add("cleanup-sheet", config.styleableChrome, <![CDATA[
|
styles.system.add("cleanup-sheet", config.styleableChrome, <![CDATA[
|
||||||
#TabsToolbar tab { display: none; }
|
#TabsToolbar tab { display: none; }
|
||||||
]]>);
|
]]>);
|
||||||
|
|||||||
@@ -72,6 +72,9 @@ var Tabs = Module("tabs", {
|
|||||||
for (let elem in values(["dactyl-tab-icon-number", "dactyl-tab-number"].map(node)))
|
for (let elem in values(["dactyl-tab-icon-number", "dactyl-tab-number"].map(node)))
|
||||||
if (elem)
|
if (elem)
|
||||||
elem.parentNode.parentNode.removeChild(elem.parentNode);
|
elem.parentNode.parentNode.removeChild(elem.parentNode);
|
||||||
|
|
||||||
|
delete tab.dactylOrdinal;
|
||||||
|
tab.removeAttribute("dactylOrdinal");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -82,16 +85,21 @@ var Tabs = Module("tabs", {
|
|||||||
if (!node("dactyl-tab-number")) {
|
if (!node("dactyl-tab-number")) {
|
||||||
let img = node("tab-icon-image");
|
let img = node("tab-icon-image");
|
||||||
if (img) {
|
if (img) {
|
||||||
let dom = DOM(<xul xmlns:xul={XUL} xmlns:html={XHTML}
|
let dom = DOM(<xul xmlns:xul={XUL} xmlns:html={XHTML}>
|
||||||
><xul:hbox highlight="tab-number"><xul:label key="icon" align="center" highlight="TabIconNumber" class="dactyl-tab-icon-number"/></xul:hbox
|
<xul:hbox highlight="tab-number"><xul:label key="icon" align="center" highlight="TabIconNumber" class="dactyl-tab-icon-number"/></xul:hbox>
|
||||||
><xul:hbox highlight="tab-number"><html:div key="label" highlight="TabNumber" class="dactyl-tab-number"/></xul:hbox
|
<xul:hbox highlight="tab-number"><html:div key="label" highlight="TabNumber" class="dactyl-tab-number"/></xul:hbox>
|
||||||
></xul>.*, document).appendTo(img.parentNode);
|
</xul>.elements(), document).appendTo(img.parentNode);
|
||||||
tab.__defineGetter__("dactylOrdinal", function () Number(dom.nodes.icon.value));
|
|
||||||
tab.__defineSetter__("dactylOrdinal", function (i) dom.nodes.icon.value = dom.nodes.label.textContent = i);
|
update(tab, {
|
||||||
|
get dactylOrdinal() Number(dom.nodes.icon.value),
|
||||||
|
set dactylOrdinal(i) {
|
||||||
|
dom.nodes.icon.value = dom.nodes.label.textContent = i;
|
||||||
|
this.setAttribute("dactylOrdinal", i);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tab.setAttribute("dactylOrdinal", i + 1);
|
|
||||||
tab.dactylOrdinal = i + 1;
|
tab.dactylOrdinal = i + 1;
|
||||||
}
|
}
|
||||||
statusline.updateTabCount(true);
|
statusline.updateTabCount(true);
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
|
|||||||
util.addObserver(this);
|
util.addObserver(this);
|
||||||
this.overlays = {};
|
this.overlays = {};
|
||||||
|
|
||||||
|
this.onWindowVisible = [];
|
||||||
|
|
||||||
config.loadStyles();
|
config.loadStyles();
|
||||||
|
|
||||||
this.timeout(this.initialize);
|
this.timeout(this.initialize);
|
||||||
@@ -287,13 +289,20 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Module.list.forEach(load);
|
function finish() {
|
||||||
frob("load");
|
// Module.list.forEach(load);
|
||||||
modules.times = update({}, defineModule.times);
|
frob("load");
|
||||||
|
modules.times = update({}, defineModule.times);
|
||||||
|
|
||||||
defineModule.loadLog.push("Loaded in " + (Date.now() - start) + "ms");
|
defineModule.loadLog.push("Loaded in " + (Date.now() - start) + "ms");
|
||||||
|
|
||||||
overlay.windows = array.uniq(overlay.windows.concat(window), true);
|
overlay.windows = array.uniq(overlay.windows.concat(window), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (overlay.onWindowVisible)
|
||||||
|
overlay.onWindowVisible.push(finish);
|
||||||
|
else
|
||||||
|
finish();
|
||||||
|
|
||||||
modules.events.listen(window, "unload", function onUnload() {
|
modules.events.listen(window, "unload", function onUnload() {
|
||||||
window.removeEventListener("unload", onUnload.wrapped, false);
|
window.removeEventListener("unload", onUnload.wrapped, false);
|
||||||
@@ -337,7 +346,13 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
|
|||||||
}), true);
|
}), true);
|
||||||
},
|
},
|
||||||
"chrome-document-global-created": function (window, uri) { this.observe(window, "toplevel-window-ready", null); },
|
"chrome-document-global-created": function (window, uri) { this.observe(window, "toplevel-window-ready", null); },
|
||||||
"content-document-global-created": function (window, uri) { this.observe(window, "toplevel-window-ready", null); }
|
"content-document-global-created": function (window, uri) { this.observe(window, "toplevel-window-ready", null); },
|
||||||
|
"xul-window-visible": function () {
|
||||||
|
if (this.onWindowVisible) {
|
||||||
|
this.onWindowVisible.forEach(function (f) f.call(this), this);
|
||||||
|
this.onWindowVisible = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
overlayWindow: function (url, fn) {
|
overlayWindow: function (url, fn) {
|
||||||
@@ -351,8 +366,10 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
|
|||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
for (let doc in util.iterDocuments())
|
for (let doc in util.iterDocuments())
|
||||||
if (["interactive", "complete"].indexOf(doc.readyState) >= 0)
|
if (~["interactive", "complete"].indexOf(doc.readyState)) {
|
||||||
|
this.onWindowVisible = null;
|
||||||
this._loadOverlays(doc.defaultView);
|
this._loadOverlays(doc.defaultView);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
this.observe(doc.defaultView, "toplevel-window-ready");
|
this.observe(doc.defaultView, "toplevel-window-ready");
|
||||||
}
|
}
|
||||||
@@ -363,7 +380,7 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
|
|||||||
window.dactylOverlays = [];
|
window.dactylOverlays = [];
|
||||||
|
|
||||||
for each (let obj in overlay.overlays[window.document.documentURI] || []) {
|
for each (let obj in overlay.overlays[window.document.documentURI] || []) {
|
||||||
if (window.dactylOverlays.indexOf(obj) >= 0)
|
if (~window.dactylOverlays.indexOf(obj))
|
||||||
continue;
|
continue;
|
||||||
window.dactylOverlays.push(obj);
|
window.dactylOverlays.push(obj);
|
||||||
this._loadOverlay(window, obj(window));
|
this._loadOverlay(window, obj(window));
|
||||||
|
|||||||
Reference in New Issue
Block a user