|
@ -684,7 +684,7 @@ var winWatcher = (function() { |
|
|
/******************************************************************************/ |
|
|
/******************************************************************************/ |
|
|
|
|
|
|
|
|
var getTabBrowser = function(win) { |
|
|
var getTabBrowser = function(win) { |
|
|
return win.gBrowser || null; |
|
|
|
|
|
|
|
|
return win && win.gBrowser || null; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/******************************************************************************/ |
|
|
/******************************************************************************/ |
|
@ -889,9 +889,6 @@ vAPI.tabs.open = function(details) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
var win = winWatcher.getCurrentWindow(); |
|
|
|
|
|
var tabBrowser = getTabBrowser(win); |
|
|
|
|
|
|
|
|
|
|
|
// Open in a standalone window
|
|
|
// Open in a standalone window
|
|
|
if ( details.popup === true ) { |
|
|
if ( details.popup === true ) { |
|
|
Services.ww.openWindow( |
|
|
Services.ww.openWindow( |
|
@ -904,6 +901,12 @@ vAPI.tabs.open = function(details) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var win = winWatcher.getCurrentWindow(); |
|
|
|
|
|
var tabBrowser = getTabBrowser(win); |
|
|
|
|
|
if ( tabBrowser === null ) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if ( details.index === -1 ) { |
|
|
if ( details.index === -1 ) { |
|
|
details.index = tabBrowser.browsers.indexOf(tabBrowser.selectedBrowser) + 1; |
|
|
details.index = tabBrowser.browsers.indexOf(tabBrowser.selectedBrowser) + 1; |
|
|
} |
|
|
} |
|
@ -936,7 +939,9 @@ vAPI.tabs.replace = function(tabId, url) { |
|
|
/******************************************************************************/ |
|
|
/******************************************************************************/ |
|
|
|
|
|
|
|
|
vAPI.tabs._remove = function(tab, tabBrowser) { |
|
|
vAPI.tabs._remove = function(tab, tabBrowser) { |
|
|
tabBrowser.removeTab(tab); |
|
|
|
|
|
|
|
|
if ( tabBrowser ) { |
|
|
|
|
|
tabBrowser.removeTab(tab); |
|
|
|
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/******************************************************************************/ |
|
|
/******************************************************************************/ |
|
@ -979,7 +984,9 @@ vAPI.tabs.select = function(tab) { |
|
|
win.focus(); |
|
|
win.focus(); |
|
|
|
|
|
|
|
|
var tabBrowser = getTabBrowser(win); |
|
|
var tabBrowser = getTabBrowser(win); |
|
|
tabBrowser.selectedTab = tab; |
|
|
|
|
|
|
|
|
if ( tabBrowser ) { |
|
|
|
|
|
tabBrowser.selectedTab = tab; |
|
|
|
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
/******************************************************************************/ |
|
|
/******************************************************************************/ |
|
@ -1031,17 +1038,17 @@ var tabWatcher = (function() { |
|
|
if ( !win ) { |
|
|
if ( !win ) { |
|
|
return -1; |
|
|
return -1; |
|
|
} |
|
|
} |
|
|
var tabbrowser = getTabBrowser(win); |
|
|
|
|
|
if ( !tabbrowser ) { |
|
|
|
|
|
|
|
|
var tabBrowser = getTabBrowser(win); |
|
|
|
|
|
if ( tabBrowser === null ) { |
|
|
return -1; |
|
|
return -1; |
|
|
} |
|
|
} |
|
|
// This can happen, for example, the `view-source:` window, there is
|
|
|
// This can happen, for example, the `view-source:` window, there is
|
|
|
// no tabbrowser object, the browser object sits directly in the
|
|
|
// no tabbrowser object, the browser object sits directly in the
|
|
|
// window.
|
|
|
// window.
|
|
|
if ( tabbrowser === browser ) { |
|
|
|
|
|
|
|
|
if ( tabBrowser === browser ) { |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
return tabbrowser.browsers.indexOf(browser); |
|
|
|
|
|
|
|
|
return tabBrowser.browsers.indexOf(browser); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
var indexFromTarget = function(target) { |
|
|
var indexFromTarget = function(target) { |
|
@ -1057,14 +1064,14 @@ var tabWatcher = (function() { |
|
|
if ( !win ) { |
|
|
if ( !win ) { |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
var tabbrowser = getTabBrowser(win); |
|
|
|
|
|
if ( !tabbrowser ) { |
|
|
|
|
|
|
|
|
var tabBrowser = getTabBrowser(win); |
|
|
|
|
|
if ( tabBrowser === null ) { |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
if ( !tabbrowser.tabs || i >= tabbrowser.tabs.length ) { |
|
|
|
|
|
|
|
|
if ( !tabBrowser.tabs || i >= tabBrowser.tabs.length ) { |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
return tabbrowser.tabs[i]; |
|
|
|
|
|
|
|
|
return tabBrowser.tabs[i]; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
var browserFromTarget = function(target) { |
|
|
var browserFromTarget = function(target) { |
|
@ -1300,7 +1307,7 @@ var tabWatcher = (function() { |
|
|
vAPI.contextMenu.unregister(win.document); |
|
|
vAPI.contextMenu.unregister(win.document); |
|
|
|
|
|
|
|
|
var tabBrowser = getTabBrowser(win); |
|
|
var tabBrowser = getTabBrowser(win); |
|
|
if ( !tabBrowser ) { |
|
|
|
|
|
|
|
|
if ( tabBrowser === null ) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -1413,7 +1420,11 @@ vAPI.setIcon = function(tabId, iconId, badge) { |
|
|
} else { |
|
|
} else { |
|
|
win = winWatcher.getCurrentWindow(); |
|
|
win = winWatcher.getCurrentWindow(); |
|
|
} |
|
|
} |
|
|
var curTabId = tabWatcher.tabIdFromTarget(getTabBrowser(win).selectedTab); |
|
|
|
|
|
|
|
|
var tabBrowser = getTabBrowser(win); |
|
|
|
|
|
if ( tabBrowser === null ) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
var curTabId = tabWatcher.tabIdFromTarget(tabBrowser.selectedTab); |
|
|
var tb = vAPI.toolbarButton; |
|
|
var tb = vAPI.toolbarButton; |
|
|
|
|
|
|
|
|
// from 'TabSelect' event
|
|
|
// from 'TabSelect' event
|
|
|