зеркало из https://github.com/mozilla/gecko-dev.git
Bug 936562 - Open new tabs to the right of the parent tab [r=sfoster]
This commit is contained in:
Родитель
4e64836e63
Коммит
1d6ab9226c
|
@ -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);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче