summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKris Maglione <maglione.k@gmail.com>2011-08-21 11:52:55 -0400
committerKris Maglione <maglione.k@gmail.com>2011-08-21 11:52:55 -0400
commitf830771283f088caa2bf923dcb7afa8e06b5632e (patch)
treeb44322b00a1a3f527d0e8b4779dacf818ada29aa
parent5f42595f651cd12ae34bf66fab5dc3f8577c27a1 (diff)
downloadpentadactyl-f830771283f088caa2bf923dcb7afa8e06b5632e.tar.gz
Defer some initialization until the first window is visible.
-rw-r--r--common/content/bindings.xml8
-rw-r--r--common/content/dactyl.js1
-rw-r--r--common/content/tabs.js22
-rw-r--r--common/modules/overlay.jsm33
4 files changed, 49 insertions, 15 deletions
diff --git a/common/content/bindings.xml b/common/content/bindings.xml
index 800230de..587c7a87 100644
--- a/common/content/bindings.xml
+++ b/common/content/bindings.xml
@@ -26,6 +26,10 @@
<binding id="tab" display="xul:hbox"
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">
<xul:stack class="tab-icon dactyl-tab-stack">
<xul:image xbl:inherits="validate,src=image" role="presentation" class="tab-icon-image"/>
@@ -45,6 +49,10 @@
<binding id="tab-mac"
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">
<xul:hbox class="tab-image-left" xbl:inherits="selected"/>
<xul:hbox class="tab-image-middle" flex="1" align="center" xbl:inherits="selected">
diff --git a/common/content/dactyl.js b/common/content/dactyl.js
index 168173ae..17fed031 100644
--- a/common/content/dactyl.js
+++ b/common/content/dactyl.js
@@ -56,6 +56,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
delete window.dactyl;
delete window.liberator;
+ // Prevents box ordering bugs after our stylesheet is removed.
styles.system.add("cleanup-sheet", config.styleableChrome, <![CDATA[
#TabsToolbar tab { display: none; }
]]>);
diff --git a/common/content/tabs.js b/common/content/tabs.js
index 092ec1f3..ddd22fd6 100644
--- a/common/content/tabs.js
+++ b/common/content/tabs.js
@@ -72,6 +72,9 @@ var Tabs = Module("tabs", {
for (let elem in values(["dactyl-tab-icon-number", "dactyl-tab-number"].map(node)))
if (elem)
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")) {
let img = node("tab-icon-image");
if (img) {
- 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"><html:div key="label" highlight="TabNumber" class="dactyl-tab-number"/></xul:hbox
- ></xul>.*, 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);
+ 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"><html:div key="label" highlight="TabNumber" class="dactyl-tab-number"/></xul:hbox>
+ </xul>.elements(), document).appendTo(img.parentNode);
+
+ 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;
}
statusline.updateTabCount(true);
diff --git a/common/modules/overlay.jsm b/common/modules/overlay.jsm
index 10e20a8a..5d6f36d3 100644
--- a/common/modules/overlay.jsm
+++ b/common/modules/overlay.jsm
@@ -41,6 +41,8 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
util.addObserver(this);
this.overlays = {};
+ this.onWindowVisible = [];
+
config.loadStyles();
this.timeout(this.initialize);
@@ -287,13 +289,20 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
});
});
- // Module.list.forEach(load);
- frob("load");
- modules.times = update({}, defineModule.times);
+ function finish() {
+ // Module.list.forEach(load);
+ 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() {
window.removeEventListener("unload", onUnload.wrapped, false);
@@ -337,7 +346,13 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
}), true);
},
"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) {
@@ -351,8 +366,10 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
}, this);
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);
+ }
else
this.observe(doc.defaultView, "toplevel-window-ready");
}
@@ -363,7 +380,7 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
window.dactylOverlays = [];
for each (let obj in overlay.overlays[window.document.documentURI] || []) {
- if (window.dactylOverlays.indexOf(obj) >= 0)
+ if (~window.dactylOverlays.indexOf(obj))
continue;
window.dactylOverlays.push(obj);
this._loadOverlay(window, obj(window));