Skip to content

Commit

Permalink
Merge branch 'nightly'
Browse files Browse the repository at this point in the history
Conflicts:
	chrome/content/tabutils-st.js
	chrome/content/tabutils.js
  • Loading branch information
ithinc committed Mar 20, 2014
2 parents 4d025f1 + 62c0cf6 commit e854a91
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 27 deletions.
4 changes: 2 additions & 2 deletions chrome/content/tabutils-pt.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ tabutils._phantomTabs = function() {
}

if (!aRestoring) {
tabutils._ss.setTabValue(aTab, "pinned", true);
tabutils._ss.setTabValue(aTab, "bookmarkId", aTab.bookmarkId);
tabutils._ss.setTabValue(aTab, "pinned", "true");
tabutils._ss.setTabValue(aTab, "bookmarkId", String(aTab.bookmarkId || "")); // Bug 961646
}
aTab.dispatchEvent(new CustomEvent("TabPinning", {bubbles: true}));

Expand Down
73 changes: 55 additions & 18 deletions chrome/content/tabutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,10 +582,38 @@ tabutils._tabOpeningOptions = function() {
let win = aWebProgress.DOMWindow;
win._closeTimer = win.setTimeout(function() {
this.mTabBrowser.isBlankTab(this.mTab) && this.mTabBrowser.removeTab(this.mTab);
}.bind(this), 250);
}.bind(this), 750);
}
});

let tmp = {};
Cu.import("resource://gre/modules/DownloadLastDir.jsm", tmp);

if (tmp.DownloadLastDir && // Bug 722995 [Fx19]
tmp.DownloadLastDir.prototype.getFileAsync && // Bug 854299 [Fx23]
tmp.DownloadLastDir.prototype.getFileAsync.name != "TU_getFileAsync")
tmp.DownloadLastDir.prototype.getFileAsync = (function() {
let getFileAsync = tmp.DownloadLastDir.prototype.getFileAsync;
return function TU_getFileAsync(aURI, aCallback) {
let win = this.window;
if (win._closeTimer) {
win.clearTimeout(win._closeTimer);
win._closeTimer = null;

aCallback = (function() {
let lastDirCallback = aCallback;
return function TU_LastDirCallback(lastDir) {
lastDirCallback(lastDir);
if (!win.closed) {
win.setTimeout(win.close, 250);
}
};
})();
}
getFileAsync.apply(this, arguments);
};
})();

//在当前标签页的右侧打开新标签页
//连续打开后台标签时保持原有顺序
TU_hookCode("gBrowser.addTab",
Expand All @@ -602,7 +630,7 @@ tabutils._tabOpeningOptions = function() {

if (TU_getPref("extensions.tabutils.openTabNext.keepOrder", true)) {
let tab = lastRelatedTab.nextSibling;
let panelId = this.mCurrentTab.linkedPanel;
let panelId = this.mCurrentTab.linkedPanel + "#";
for (; tab && tab.pinned; tab = tab.nextSibling);
for (; tab && tab.getAttribute("opener") == panelId && tab != t && (!willStack || shouldStack(tab)); tab = tab.nextSibling)
lastRelatedTab = tab;
Expand All @@ -624,7 +652,7 @@ tabutils._tabOpeningOptions = function() {
default: return false; //None
}
})()) {
aTab.setAttribute("opener", this.mCurrentTab.linkedPanel);
aTab.setAttribute("opener", this.mCurrentTab.linkedPanel + "#");
}
});

Expand Down Expand Up @@ -766,7 +794,7 @@ tabutils._tabClosingOptions = function() {

//关闭标签页时选择亲属标签
TU_hookCode("gBrowser.onTabSelect", "}", function() {
var panelId = aTab.linkedPanel;
var panelId = aTab.linkedPanel + "#";
Array.forEach(this.visibleTabs, function(aTab) {
if (aTab.getAttribute("opener").startsWith(panelId))
aTab.setAttribute("opener", panelId + (+aTab.getAttribute("opener").slice(panelId.length) + 1));
Expand All @@ -776,7 +804,7 @@ tabutils._tabClosingOptions = function() {
TU_hookCode("gBrowser.onTabClose", "}", function() {
if (aTab.hasAttribute("opener")) {
let opener = aTab.getAttribute("opener");
let panelId = aTab.linkedPanel;
let panelId = aTab.linkedPanel + "#";
Array.forEach(this.visibleTabs, function(aTab) {
if (aTab.getAttribute("opener").startsWith(panelId))
aTab.setAttribute("opener", opener);
Expand All @@ -794,8 +822,8 @@ tabutils._tabClosingOptions = function() {
bTab = this.mCurrentTab;

return aTab.hasAttribute("opener") && aTab.getAttribute("opener") == bTab.getAttribute("opener")
|| aTab.getAttribute("opener").startsWith(bTab.linkedPanel)
|| bTab.getAttribute("opener").startsWith(aTab.linkedPanel);
|| aTab.getAttribute("opener").startsWith(bTab.linkedPanel + "#")
|| bTab.getAttribute("opener").startsWith(aTab.linkedPanel + "#");
};

//关闭标签页时选择上次浏览的标签
Expand Down Expand Up @@ -2360,17 +2388,11 @@ tabutils._miscFeatures = function() {
switch (sheet.href) {
case "chrome://browser/skin/browser.css":
for (let cssRule of Array.slice(sheet.cssRules)) {
if (/> .tabbrowser-tab/.test(cssRule.selectorText)) {
tabutils.insertRule(cssRule.cssText.replace(RegExp.lastMatch, ".tabbrowser-tab"));
continue;
}

if (/> .tabbrowser-arrowscrollbox > .arrowscrollbox-scrollbox/.test(cssRule.selectorText)) {
tabutils.insertRule(cssRule.cssText.replace(RegExp.lastMatch, "#PinnedTabsBarItems"));
continue;
}

switch (cssRule.selectorText) {
case "#tabbrowser-tabs[positionpinnedtabs] > .tabbrowser-tab[pinned]:before": // Bug 877368 [Fx29]
case "#tabbrowser-tabs[positionpinnedtabs] > .tabbrowser-tab[pinned]::before":
tabutils.insertRule(cssRule.cssText.replace("#tabbrowser-tabs[positionpinnedtabs] >", ""));
break;
case ".tabbrowser-arrowscrollbox > .arrowscrollbox-scrollbox":
tabutils.insertRule(cssRule.cssText.replace(cssRule.selectorText, ".tabbrowser-tabs[orient='horizontal']:not([overflow]):not([multirow]) $&"))
.style.MozMarginStart = "-" + cssRule.style.MozPaddingStart;
Expand All @@ -2382,6 +2404,16 @@ tabutils._miscFeatures = function() {
case ".tab-throbber[pinned], .tab-icon-image[pinned], .tabs-newtab-button > .toolbarbutton-icon":
tabutils.insertRule(cssRule.cssText.replace(cssRule.selectorText, '.tabbrowser-tabs[orient="horizontal"] > .tabbrowser-tab[faviconized] :-moz-any(.tab-throbber, .tab-icon-image)'));
break;
default:
if (/> .tabbrowser-tab/.test(cssRule.selectorText)) {
tabutils.insertRule(cssRule.cssText.replace(RegExp.lastMatch, ".tabbrowser-tab"));
continue;
}

if (/> .tabbrowser-arrowscrollbox > .arrowscrollbox-scrollbox/.test(cssRule.selectorText)) {
tabutils.insertRule(cssRule.cssText.replace(RegExp.lastMatch, "#PinnedTabsBarItems"));
continue;
}
}
}
break;
Expand Down Expand Up @@ -2714,6 +2746,11 @@ tabutils._hideTabBar = function() {
toolbarNodes.push(tabsToolbar);
});

if ("getTogglableToolbars" in window) // Bug 940669 [Fx29]
TU_hookCode("getTogglableToolbars", /(?=.*return.*)/, function() {
toolbarNodes = [...new Set(toolbarNodes)];
});

TU_hookCode("setToolbarVisibility", /.*setAttribute.*/, 'if (toolbar.id == "TabsToolbar") gBrowser.mTabContainer.visible = isVisible; else $&');
TU_hookCode("gBrowser.mTabContainer.updateVisibility", "{", 'if (!TU_getPref("browser.tabs.autoHide")) return;');
};
Expand Down Expand Up @@ -2785,7 +2822,7 @@ tabutils._undoCloseTabButton = function() {
document.getElementById("History:UndoCloseTab").removeAttribute("disabled");
gBrowser._lastClosedTabsCount = null;
};
//tabutils.updateUndoCloseTabCommand();
document.getElementById("History:UndoCloseTab").setAttribute("disabled", true);
TU_hookCode("gBrowser.onTabClose", "}", "tabutils.updateUndoCloseTabCommand();");
TU_hookCode("gBrowser.onTabRestoring", "}", "tabutils.updateUndoCloseTabCommand();");
TU_hookCode("gSessionHistoryObserver.observe", "}", "tabutils.updateUndoCloseTabCommand();");
Expand Down
9 changes: 5 additions & 4 deletions chrome/content/tabutils.xul
Original file line number Diff line number Diff line change
Expand Up @@ -419,13 +419,14 @@

<vbox id="browser-panel">
<hbox id="fullscr-toggler" collapsed="true" insertbefore="browser"/>
<hbox id="browser">
<vbox id="fullscr-toggler-left" collapsed="true" insertbefore="appcontent"/>
<vbox id="fullscr-toggler-right" collapsed="true" insertafter="appcontent"/>
</hbox>
<hbox id="fullscr-toggler-bottom" collapsed="true" insertafter="browser"/>
</vbox>

<hbox id="browser">
<vbox id="fullscr-toggler-left" collapsed="true" insertbefore="appcontent"/>
<vbox id="fullscr-toggler-right" collapsed="true" insertafter="appcontent"/>
</hbox>

<statusbar id="status-bar">
<statusbarpanel id="statusbar-openintab"
class="statusbarpanel-iconic-text"
Expand Down
3 changes: 2 additions & 1 deletion chrome/content/unknownContentType.xul
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
if (win && win._closeTimer) {
win.clearTimeout(win._closeTimer);
window.addEventListener("unload", function() {
win && win.setTimeout(function() {this.close();}, 250);
if (win._closeTimer && !win.closed)
win._closeTimer = win.setTimeout(win.close, 250);
}, false);
}
]]>
Expand Down
4 changes: 2 additions & 2 deletions chrome/skin/tabutils.css
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ menuseparator:last-child {
}

.tabbrowser-tab[locked] .tab-throbber:not([busy]) {
-moz-margin-end: -8px;
-moz-margin-end: -8px !important;
}

.tabbrowser-tab[locked] .tab-throbber:not([busy]) + .tab-icon-image {
-moz-margin-start: -8px;
-moz-margin-start: -8px !important;
position: relative;
z-index: -1;
}
Expand Down

0 comments on commit e854a91

Please sign in to comment.