Create a gist now

Instantly share code, notes, and snippets.

Vimperator 2.3 patch for Tree Style Tab
<?xml version="1.0"?>
<!--
Firefox 2 compatible tab structure library for Firefox 3 or later
Usage:
<?xul-overlay href="tabFx2Compatible.xul"?>
lisence: The MIT License, Copyright (c) 2009 SHIMODA "Piro" Hiroshi
http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/license.txt
original:
http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/tabFx2Compatible.xul
http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/tabFx2Compatible.xml
http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/tabFx2Compatible.css
-->
<!DOCTYPE bindings [
<!ENTITY % tabBrowserDTD SYSTEM "chrome://browser/locale/tabbrowser.dtd" >
%tabBrowserDTD;
<!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
%globalDTD;
]>
<bindings id="tabFx2CompatibleBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="tabbrowser-tab"
extends="chrome://browser/content/tabbrowser.xml#tabbrowser-tab">
<content chromedir="&locale.dir;"
closetabtext="&closeTab.label;">
<xul:hbox class="tab-image-left" xbl:inherits="selected"/>
<xul:hbox flex="1" class="tab-image-middle" align="center" xbl:inherits="selected">
<xul:stack class="tab-icon">
<xul:image xbl:inherits="validate,src=image" class="tab-icon-image"/>
<xul:image class="tab-extra-status"/>
</xul:stack>
<xul:label flex="1" xbl:inherits="value=label,crop,accesskey" class="tab-text"/>
</xul:hbox>
<xul:toolbarbutton anonid="close-button" tabindex="-1" class="tab-close-button"/>
<xul:hbox class="tab-image-right" xbl:inherits="selected"/>
</content>
</binding>
</bindings>
<binding id="tab-mac"
extends="chrome://browser/content/tabbrowser.xml#tabbrowser-tab">
<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">
<xul:stack class="tab-icon liberator-tab-stack">
<xul:image xbl:inherits="validate,src=image" class="tab-icon-image" liberator:highlight="TabIcon"/>
<xul:image class="tab-extra-status"/>
<xul:vbox>
<xul:spring flex="1"/>
<xul:label xbl:inherits="value=ordinal" liberator:highlight="TabIconNumber"/>
<xul:spring flex="1"/>
</xul:vbox>
</xul:stack>
<xul:stack class="tab-text-stack">
<xul:label xbl:inherits="value=ordinal" class="tab-text" liberator:highlight="TabNumber"/>
</xul:stack>
<xul:stack class="tab-text-stack" flex="1">
<xul:label flex="1" xbl:inherits="value=label,crop,accesskey" crop="right" class="tab-text" liberator:highlight="TabText"/>
</xul:stack>
</xul:hbox>
<xul:toolbarbutton anonid="close-button" tabindex="-1" class="tab-close-button" liberator:highlight="TabClose"/>
<xul:hbox class="tab-image-right" xbl:inherits="selected"/>
</content>
</binding>
diff -r b2dd97daf059 -r 413568f2f8b9 common/content/liberator.js
--- a/common/content/liberator.js Mon Mar 29 00:57:55 2010 +0200
+++ b/common/content/liberator.js Tue Jun 08 19:54:23 2010 +0900
@@ -1163,7 +1163,7 @@
let classes = [v[1] for ([k, v] in Iterator(this.opts)) if (opts.indexOf(k) < 0)];
let css = classes.length ? classes.join(",") + "{ display: none; }" : "";
styles.addSheet(true, "taboptions", "chrome://*", css);
- tabs.tabsBound = Array.some(opts, function (k) k in self.opts);
+ // tabs.tabsBound = Array.some(opts, function (k) k in self.opts);
statusline.updateTabCount();
}
}
@@ -1854,6 +1854,7 @@
autocommands.trigger(config.name + "Enter", {});
}, 0);
+ tabs.initAllTabs();
statusline.update();
liberator.log(config.name + " fully initialized", 0);
}
diff -r b2dd97daf059 -r 413568f2f8b9 common/content/statusline.js
--- a/common/content/statusline.js Mon Mar 29 00:57:55 2010 +0200
+++ b/common/content/statusline.js Tue Jun 08 19:54:23 2010 +0900
@@ -159,7 +159,11 @@
// update the ordinal which is used for numbered tabs
if (options.get("guioptions").has("n", "N"))
for (let [i, tab] in util.Array.iteritems(config.browser.mTabs))
- tab.setAttribute("ordinal", i + 1);
+ {
+ let order = i + 1;
+ document.getAnonymousElementByAttribute(tab, "anonid", "TabIconNumber").value = order;
+ document.getAnonymousElementByAttribute(tab, "anonid", "TabNumber").value = order;
+ }
this._tabCountWidget.value = "[" + (tabs.index() + 1) + "/" + tabs.count + "]";
}
diff -r b2dd97daf059 -r 413568f2f8b9 common/content/tabFx2Compatible/tabFx2Compatible.css
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/content/tabFx2Compatible/tabFx2Compatible.css Tue Jun 08 19:54:23 2010 +0900
@@ -0,0 +1,88 @@
+/*
+ Firefox 2 compatible tab structure library for Firefox 3 or later
+
+ Usage:
+ <?xul-overlay href="tabFx2Compatible.xul"?>
+
+ lisence: The MIT License, Copyright (c) 2009 SHIMODA "Piro" Hiroshi
+ http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/license.txt
+ original:
+ http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/tabFx2Compatible.xul
+ http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/tabFx2Compatible.xml
+ http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/tabFx2Compatible.css
+*/
+
+@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
+
+:root[tabFx2Compatible="6"]
+ .tabbrowser-tab {
+ -moz-binding: url(tabFx2Compatible.xml#tabbrowser-tab) !important;
+}
+
+:root[tabFx2Compatible="6"]:not([tabFx2Compatible-flags~="png-throbber"])
+ .tabbrowser-tab[busy] > hbox > stack > .tab-icon-image {
+ list-style-image: url("chrome://global/skin/throbber/Throbber-small.gif") !important;
+ opacity: 0.6;
+}
+
+:root[tabFx2Compatible="6"][tabFx2Compatible-flags~="png-throbber"]
+ .tabbrowser-tab[busy] > hbox > stack > .tab-icon-image {
+ list-style-image: url("chrome://global/skin/icons/loading_16.png") !important;
+}
+
+:root[tabFx2Compatible="6"][tabFx2Compatible-flags~="mac"][tabFx2Compatible-flags~="png-throbber"]
+ .tabbrowser-tab .tab-icon-image {
+ list-style-image: url("chrome://global/skin/tree/item.png");
+}
+
+:root[tabFx2Compatible="6"][tabFx2Compatible-flags~="mac"]
+ .tabbrowser-tab:not(:hover):not([selected="true"]) .tab-icon-image {
+ opacity: 0.6;
+}
+
+:root[tabFx2Compatible="6"][tabFx2Compatible-flags~="pie"]
+ .tabbrowser-tab[busy] > hbox > stack > .tab-icon-image {
+ list-style-image: url("chrome://browser/skin/tabbrowser/progress.png") !important;
+ -moz-image-region: rect(0, 16px, 16px, 0);
+}
+:root[tabFx2Compatible="6"][tabFx2Compatible-flags~="pie"]
+ .tabbrowser-tab[busy][stalled] > hbox > stack > .tab-icon-image {
+ list-style-image: url("chrome://browser/skin/tabbrowser/progress-pulsing.png") !important;
+}
+:root[tabFx2Compatible="6"][tabFx2Compatible-flags~="pie"]
+ .tabbrowser-tab[busy][progress="1"] > hbox > stack > .tab-icon-image {
+ -moz-image-region: rect(0, 32px, 16px, 16px);
+}
+:root[tabFx2Compatible="6"][tabFx2Compatible-flags~="pie"]
+ .tabbrowser-tab[busy][progress="2"] > hbox > stack > .tab-icon-image {
+ -moz-image-region: rect(0, 48px, 16px, 32px);
+}
+:root[tabFx2Compatible="6"][tabFx2Compatible-flags~="pie"]
+ .tabbrowser-tab[busy][progress="3"] > hbox > stack > .tab-icon-image {
+ -moz-image-region: rect(0, 64px, 16px, 48px);
+}
+:root[tabFx2Compatible="6"][tabFx2Compatible-flags~="pie"]
+ .tabbrowser-tab[busy][progress="4"] > hbox > stack > .tab-icon-image {
+ -moz-image-region: rect(0, 80px, 16px, 64px);
+}
+:root[tabFx2Compatible="6"][tabFx2Compatible-flags~="pie"]
+ .tabbrowser-tab[busy][progress="5"] > hbox > stack > .tab-icon-image {
+ -moz-image-region: rect(0, 96px, 16px, 80px);
+}
+:root[tabFx2Compatible="6"][tabFx2Compatible-flags~="pie"]
+ .tabbrowser-tab[busy][progress="6"] > hbox > stack > .tab-icon-image {
+ -moz-image-region: rect(0, 112px, 16px, 96px);
+}
+:root[tabFx2Compatible="6"][tabFx2Compatible-flags~="pie"]
+ .tabbrowser-tab[busy][progress="7"] > hbox > stack > .tab-icon-image {
+ -moz-image-region: rect(0, 128px, 16px, 112px);
+}
+:root[tabFx2Compatible="6"][tabFx2Compatible-flags~="pie"]
+ .tabbrowser-tab[busy][progress="8"] > hbox > stack > .tab-icon-image {
+ -moz-image-region: rect(0, 144px, 16px, 128px);
+}
+
+:root[tabFx2Compatible="6"]
+ .tabbrowser-tab[selected="true"]:focus > hbox > .tab-text {
+ border: 1px dotted -moz-DialogText;
+}
diff -r b2dd97daf059 -r 413568f2f8b9 common/content/tabFx2Compatible/tabFx2Compatible.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/content/tabFx2Compatible/tabFx2Compatible.xml Tue Jun 08 19:54:23 2010 +0900
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<!--
+ Firefox 2 compatible tab structure library for Firefox 3 or later
+
+ Usage:
+ <?xul-overlay href="tabFx2Compatible.xul"?>
+
+ lisence: The MIT License, Copyright (c) 2009 SHIMODA "Piro" Hiroshi
+ http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/license.txt
+ original:
+ http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/tabFx2Compatible.xul
+ http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/tabFx2Compatible.xml
+ http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/tabFx2Compatible.css
+-->
+
+<!DOCTYPE bindings [
+<!ENTITY % tabBrowserDTD SYSTEM "chrome://browser/locale/tabbrowser.dtd" >
+%tabBrowserDTD;
+<!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd">
+%globalDTD;
+]>
+
+<bindings id="tabFx2CompatibleBindings"
+ xmlns="http://www.mozilla.org/xbl"
+ xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ xmlns:xbl="http://www.mozilla.org/xbl">
+
+ <binding id="tabbrowser-tab"
+ extends="chrome://browser/content/tabbrowser.xml#tabbrowser-tab">
+ <content chromedir="&locale.dir;"
+ closetabtext="&closeTab.label;">
+ <xul:hbox class="tab-image-left" xbl:inherits="selected"/>
+ <xul:hbox flex="1" class="tab-image-middle" align="center" xbl:inherits="selected">
+ <xul:stack class="tab-icon">
+ <xul:image xbl:inherits="validate,src=image" class="tab-icon-image"/>
+ <xul:image class="tab-extra-status"/>
+ </xul:stack>
+ <xul:label flex="1" xbl:inherits="value=label,crop,accesskey" class="tab-text"/>
+ </xul:hbox>
+ <xul:toolbarbutton anonid="close-button" tabindex="-1" class="tab-close-button"/>
+ <xul:hbox class="tab-image-right" xbl:inherits="selected"/>
+ </content>
+ </binding>
+
+</bindings>
diff -r b2dd97daf059 -r 413568f2f8b9 common/content/tabFx2Compatible/tabFx2Compatible.xul
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common/content/tabFx2Compatible/tabFx2Compatible.xul Tue Jun 08 19:54:23 2010 +0900
@@ -0,0 +1,79 @@
+<?xml version="1.0"?>
+<!--
+ Firefox 2 compatible tab structure library for Firefox 3 or later
+
+ Usage:
+ <?xul-overlay href="tabFx2Compatible.xul"?>
+
+ lisence: The MIT License, Copyright (c) 2009 SHIMODA "Piro" Hiroshi
+ http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/license.txt
+ original:
+ http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/tabFx2Compatible.xul
+ http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/tabFx2Compatible.xml
+ http://www.cozmixng.org/repos/piro/fx3-compatibility-lib/trunk/tabFx2Compatible.css
+-->
+<?xml-stylesheet href="tabFx2Compatible.css" type="text/css"?>
+<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+<script type="application/javascript"><![CDATA[
+
+window.addEventListener('DOMContentLoaded', function() {
+ window.removeEventListener('DOMContentLoaded', arguments.callee, true);
+
+ const currentRevision = 6;
+
+ var b = document.getElementById('content');
+ if (!b || b.localName != 'tabbrowser') return;
+
+ var root = document.documentElement;
+
+ var loadedRevision = root.getAttribute('tabFx2Compatible');
+ if (loadedRevision) {
+ loadedRevision = Number(loadedRevision);
+ if (loadedRevision >= currentRevision) {
+ return;
+ }
+ else if (loadedRevision < currentRevision) {
+ root.setAttribute('tabFx2Compatible', currentRevision);
+ return;
+ }
+ }
+
+ var url = window.getComputedStyle(b.selectedTab, '').getPropertyValue('-moz-binding');
+ url = url.match(/url\((.+)\)/);
+ if (url) {
+ url = url[1];
+ if (url && url.indexOf('"') == 0)
+ url = url.replace(/^"|"$/g, '');
+ else if (url && url.indexOf("'") == 0)
+ url = url.replace(/^'|'$/g, '');
+ }
+ switch (url)
+ {
+ case 'chrome://browser/skin/browser.xml#tabbrowser-tab': // defied by theme
+ const Pref = Components.classes['@mozilla.org/preferences;1']
+ .getService(Components.interfaces.nsIPrefBranch);
+ var skin = decodeURIComponent(escape(Pref.getCharPref('general.skins.selectedSkin')));
+ switch (skin.toLowerCase())
+ {
+ case 'classic/1.0': // Default
+ case 'chromifox': // Chromifox Basic: https://addons.mozilla.org/firefox/addon/8782
+ break;
+ default:
+ return;
+ }
+ case 'chrome://browser/content/tabbrowser.xml#tabbrowser-tab': // built-in
+ root.setAttribute('tabFx2Compatible', currentRevision);
+ var flags = [];
+ if (navigator.platform.toLowerCase().indexOf('mac') > -1)
+ flags.push('mac');
+ if ('nsPIPlacesDatabase' in Components.interfaces)
+ flags.push('png-throbber');
+ if (b.mTabProgressListener.toSource().indexOf('_startStalledTimer') > -1)
+ flags.push('pie');
+ root.setAttribute('tabFx2Compatible-flags', flags.join(' '));
+ break;
+ }
+}, true);
+
+]]></script>
+</overlay>
diff -r b2dd97daf059 -r 413568f2f8b9 common/content/tabs.js
--- a/common/content/tabs.js Mon Mar 29 00:57:55 2010 +0200
+++ b/common/content/tabs.js Tue Jun 08 19:54:23 2010 +0900
@@ -29,7 +29,8 @@
config.tabbrowser.mTabContainer.collapsed = true; // FIXME: see 'stal' comment
},
- _updateTabCount: function () {
+ _updateTabCount: function (event) {
+ tabs.initTab(event.originalTarget);
statusline.updateTabCount(true);
},
@@ -512,6 +513,79 @@
*/
updateSelectionHistory: function (tabs) {
this._alternates = tabs || [this.getTab(), this._alternates[0]];
+ },
+
+ initTab: function (tab) {
+ // check the tab has already been initialized or not
+ let tabIconNumber = document.getAnonymousElementByAttribute(tab, "anonid", "TabIconNumber");
+ let tabNumber = document.getAnonymousElementByAttribute(tab, "anonid", "TabNumber");
+ if(tabIconNumber && tabNumber) return;
+
+ // get elements
+ let tabIcon = document.getAnonymousElementByAttribute(tab, "class", "tab-icon");
+ let tabImageMiddle = document.getAnonymousElementByAttribute(tab, "class", "tab-image-middle");
+ let iconImage = document.getAnonymousElementByAttribute(tab, "class", "tab-icon-image");
+ let tabText = document.getAnonymousElementByAttribute(tab, "class", "tab-text");
+ let tabClose = document.getAnonymousElementByAttribute(tab, "class", "tab-close-button");
+
+ // set attributes
+ tabIcon.setAttribute("class", "tab-icon liberator-tab-stack");
+ iconImage.setAttributeNS(NS.uri, "highlight", "TabIcon");
+ tabClose.setAttributeNS(NS.uri, "highlight", "TabClose");
+
+ // create TabIconNumber
+ let tabIconNumberVBox = document.createElement("vbox");
+ let tabIconNumberSpring = document.createElement("spring");
+ tabIconNumberSpring.setAttribute("flex", "1");
+
+ tabIconNumber = document.createElement("label");
+ tabIconNumber.setAttributeNS(NS.uri, "highlight", "TabIconNumber");
+ tabIconNumber.setAttribute("anonid", "TabIconNumber");
+
+ tabIconNumberVBox.appendChild(tabIconNumberSpring);
+ tabIconNumberVBox.appendChild(tabIconNumber);
+ tabIconNumberVBox.appendChild(tabIconNumberSpring.cloneNode(true));
+ tabIcon.appendChild(tabIconNumberVBox);
+
+ // craete TabNumber
+ let tabNumberStack = document.createElement("stack");
+
+ tabNumber = document.createElement("label");
+ tabNumber.setAttributeNS(NS.uri, "highlight", "TabNumber");
+ tabNumber.setAttribute("anonid", "TabNumber");
+
+ // hack for InformationalTab
+ if (!("InformationalTabService" in window))
+ {
+ tabNumberStack.setAttribute("class", "tab-text-stack");
+ tabNumber.setAttribute("class", "tab-text");
+ }
+
+ tabNumberStack.appendChild(tabNumber);
+ tabImageMiddle.appendChild(tabNumberStack);
+
+ // this doesn't work well {{{
+ // tabImageMiddle.insertBefore(tabNumberStack, tabText);
+ // }}}
+
+ // move original tab text: this also doesn't work... {{{
+ // let tabTextStack = document.createElement("stack");
+ // tabTextStack.setAttribute("class", "tab-text-stack");
+ // tabTextStack.setAttribute("flex", "1");
+ // tabText.setAttributeNS(NS.uri, "highlight", "TabText");
+ // tabText.setAttribute("crop", "right");
+ // tabTextStack.appendChild(tabText);
+ // tabImageMiddle.appendChild(tabTextStack);
+ // }}}
+
+ // hack for InformationalTab
+ if ("InformationalTabService" in window)
+ setTimeout(function() InformationalTabService.repositionThumbnail(getBrowser()), 0);
+ },
+
+ initAllTabs: function() {
+ for (let tab in util.Array.itervalues(getBrowser().mTabs))
+ this.initTab(tab);
}
}, {
copyTab: function (to, from) {
diff -r b2dd97daf059 -r 413568f2f8b9 vimperator/Makefile
--- a/vimperator/Makefile Mon Mar 29 00:57:55 2010 +0200
+++ b/vimperator/Makefile Tue Jun 08 19:54:23 2010 +0900
@@ -1,6 +1,6 @@
#### configuration
-VERSION = 2.3
+VERSION = 2.3_tabFx2Compatible
NAME = vimperator
include ../common/Makefile
diff -r b2dd97daf059 -r 413568f2f8b9 vimperator/chrome.manifest
--- a/vimperator/chrome.manifest Mon Mar 29 00:57:55 2010 +0200
+++ b/vimperator/chrome.manifest Tue Jun 08 19:54:23 2010 +0900
@@ -13,4 +13,5 @@
overlay chrome://browser/content/browser.xul chrome://liberator/content/liberator.xul
overlay chrome://browser/content/browser.xul chrome://vimperator/content/vimperator.xul
+overlay chrome://browser/content/browser.xul chrome://liberator/content/tabFx2Compatible/tabFx2Compatible.xul
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment