Bug 936562 - Open new tabs to the right of the parent tab [r=sfoster]

This commit is contained in:
Matt Brubeck 2013-11-08 15:39:14 -08:00
Родитель 4e64836e63
Коммит 1d6ab9226c
5 изменённых файлов: 42 добавлений и 5 удалений

Просмотреть файл

@ -170,8 +170,9 @@ var ContextCommands = {
// Link specific
openLinkInNewTab: function cc_openLinkInNewTab() {
Browser.addTab(ContextMenuUI.popupState.linkURL, false, Browser.selectedTab);
let tab = Browser.addTab(ContextMenuUI.popupState.linkURL, false, Browser.selectedTab);
ContextUI.peekTabs(kOpenInNewTabAnimationDelayMsec);
Elements.tabList.strip.ensureElementIsVisible(tab.chromeTab);
},
copyLink: function cc_copyLink() {

Просмотреть файл

@ -22,7 +22,6 @@ var ContextUI = {
Elements.browsers.addEventListener('URLChanged', this, true);
Elements.browsers.addEventListener("AlertActive", this, true);
Elements.browsers.addEventListener("AlertClose", this, true);
Elements.tabList.addEventListener('TabSelect', this, true);
Elements.panelUI.addEventListener('ToolPanelShown', this, false);
Elements.panelUI.addEventListener('ToolPanelHidden', this, false);

Просмотреть файл

@ -159,10 +159,16 @@
</property>
<method name="addTab">
<parameter name="aIndex"/>
<body>
<![CDATA[
let tab = document.createElement("documenttab");
if (aIndex >= 0) {
let child = this.strip.children[aIndex];
this.strip.insertBefore(tab, child);
} else {
this.strip.appendChild(tab);
}
return tab;
]]>
</body>

Просмотреть файл

@ -433,6 +433,7 @@ var BrowserUI = {
/**
* Open a new tab in the foreground in response to a user action.
* See Browser.addTab for more documentation.
*/
addAndShowTab: function (aURI, aOwner) {
ContextUI.peekTabs(kNewTabAnimationDelayMsec);

Просмотреть файл

@ -446,10 +446,40 @@ var Browser = {
return this._tabId++;
},
/**
* Create a new tab and add it to the tab list.
*
* If you are opening a new foreground tab in response to a user action, use
* BrowserUI.addAndShowTab which will also show the tab strip.
*
* @param aURI String specifying the URL to load.
* @param aBringFront Boolean (optional) Open the new tab in the foreground?
* @param aOwner Tab object (optional) The "parent" of the new tab.
* This is the tab responsible for opening the new tab. When the new tab
* is closed, we will return to a parent or "sibling" tab if possible.
* @param aParams Object (optional) with optional properties:
* index: Number specifying where in the tab list to insert the new tab.
* flags, postData, charset, referrerURI: See loadURIWithFlags.
*/
addTab: function browser_addTab(aURI, aBringFront, aOwner, aParams) {
let params = aParams || {};
if (aOwner && !('index' in params)) {
// Position the new tab to the right of its owner...
params.index = this._tabs.indexOf(aOwner) + 1;
// ...and to the right of any siblings.
while (this._tabs[params.index] && this._tabs[params.index].owner == aOwner) {
params.index++;
}
}
let newTab = new Tab(aURI, params, aOwner);
if (params.index >= 0) {
this._tabs.splice(params.index, 0, newTab);
} else {
this._tabs.push(newTab);
}
if (aBringFront)
this.selectedTab = newTab;
@ -1299,7 +1329,7 @@ Tab.prototype = {
create: function create(aURI, aParams, aOwner) {
this._eventDeferred = Promise.defer();
this._chromeTab = Elements.tabList.addTab();
this._chromeTab = Elements.tabList.addTab(aParams.index);
this._id = Browser.createTabId();
let browser = this._createBrowser(aURI, null);