Bug 1276553 - Part 3: Add groupedSHistory related functions to nsIBrowser. r=smaug

Add swapBrowsers() for frameloader or other platform components to swap frameloaders
and <xul:browser> listeners.

Add closeBrowser() for chrome process top-level frameloader to correctly remove /
close a tab.

MozReview-Commit-ID: KzM0xL8goUN

--HG--
extra : rebase_source : 87fe1a611b8d5094b0cdc09d503e6793799bab03
This commit is contained in:
Samael Wang 2016-10-18 16:15:32 -04:00
Родитель 421b32c7bd
Коммит 8216d5293a
2 изменённых файлов: 61 добавлений и 2 удалений

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

@ -24,4 +24,23 @@ interface nsIBrowser : nsISupports
*/
void dropLinks(in unsigned long linksCount,
[array, size_is(linksCount)] in wstring links);
/**
* Swapping of frameloaders are usually initiated from a frameloader owner
* or other components operating on frameloader owners. This is done by calling
* swapFrameLoaders at MozFrameLoaderOwner webidl interface.
*
* This function aimed to provide the other way around -
* if the swapping is initiated from frameloader itself or other platform level
* components, it uses this interface to delegate the swapping request to
* frameloader owners and ask them to re-initiate frameloader swapping, so that
* frameloader owners such as <xul:browser> can setup their properties and /
* or listeners properly on swapping.
*/
void swapBrowsers(in nsIBrowser aOtherBrowser);
/**
* Close the browser (usually means to remove a tab).
*/
void closeBrowser();
};

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

@ -1202,6 +1202,47 @@
</body>
</method>
<method name="closeBrowser">
<body>
<![CDATA[
// The request comes from a XPCOM component, we'd want to redirect
// the request to tabbrowser.
let tabbrowser = this.getTabBrowser();
if (tabbrowser) {
let tab = tabbrowser.getTabForBrowser(this);
if (tab) {
tabbrowser.removeTab(tab);
return;
}
}
throw new Error("Closing a browser which was not attached to a tabbrowser is unsupported.");
]]>
</body>
</method>
<method name="swapBrowsers">
<parameter name="aOtherBrowser"/>
<body>
<![CDATA[
// The request comes from a XPCOM component, we'd want to redirect
// the request to tabbrowser so tabbrowser will be setup correctly,
// and it will eventually call swapDocShells.
let tabbrowser = this.getTabBrowser();
if (tabbrowser) {
let tab = tabbrowser.getTabForBrowser(this);
if (tab) {
tabbrowser.swapBrowsers(tab, aOtherBrowser);
return;
}
}
// If we're not attached to a tabbrowser, just swap.
this.swapDocShells(aOtherBrowser);
]]>
</body>
</method>
<method name="swapDocShells">
<parameter name="aOtherBrowser"/>
<body>
@ -1275,8 +1316,7 @@
PopupNotifications._swapBrowserNotifications(aOtherBrowser, this);
try {
this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner)
.swapFrameLoaders(aOtherBrowser);
this.swapFrameLoaders(aOtherBrowser);
} catch (ex) {
// This may not be implemented for browser elements that are not
// attached to a BrowserDOMWindow.