Skip to content

Commit

Permalink
Trick to update context tab, if used hotkey while menu is opened
Browse files Browse the repository at this point in the history
(related to #237)
  • Loading branch information
Infocatcher committed Jan 24, 2017
1 parent 2209158 commit 2364507
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -2524,6 +2524,10 @@ var privateTab = {
}
return contextTab || cm && cm.triggerNode && window.gBrowser.mContextTab;
},
updateContextTab: function(window, tab) {
if("TabContextMenu" in window)
window.TabContextMenu.contextTab = tab;
},
get toggleUsingDupTab() {
// Unable to toggle in Firefox 51+, see https://bugzilla.mozilla.org/show_bug.cgi?id=1318388#c39
delete this.toggleUsingDupTab;
Expand All @@ -2541,10 +2545,16 @@ var privateTab = {
var updateState = function() {
if(!tab.selected) // Only for hotkey
return;
if(useDupTab) { // Trick to set correct state right now (duplication is still in progress)
var origIsPrivate = tab.hasAttribute(this.privateAttr);
this.setPrivate(tab, isPrivate);
}
this.updateTabContext(window);
this.updateTabTooltip(window);
if("TabScope" in window && "_updateTitle" in window.TabScope && window.TabScope._tab)
window.TabScope._updateTitle();
if(useDupTab) // Restore initial state
this.setPrivate(tab, origIsPrivate);
}.bind(this);

if(this.isPendingTab(tab)) {
Expand Down Expand Up @@ -2576,12 +2586,14 @@ var privateTab = {
delete tab._privateTabWaitInitialize;
_log("toggleContextTabPrivate(): wait done in " + (Date.now() - startTime) + " ms");
tab = this.replaceTabAndTogglePrivate(tab, isPrivate);
this.updateContextTab(window, tab);
window.setTimeout(updateState, 0);
}.bind(this), 20);
return;
}
_log("toggleContextTabPrivate() -> will use gBrowser.duplicateTab()");
tab = this.replaceTabAndTogglePrivate(tab, isPrivate);
this.updateContextTab(window, tab);
// Duplicated tab will be reloaded anyway
autoReload = stopLoading = false;
}
Expand Down

0 comments on commit 2364507

Please sign in to comment.