2007-04-01 03:03:27 +04:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
|
|
|
|
<!--
|
|
|
|
- The contents of this file are subject to the Mozilla Public
|
|
|
|
- License Version 1.1 (the "License"); you may not use this file
|
|
|
|
- except in compliance with the License. You may obtain a copy of
|
|
|
|
- the License at http://www.mozilla.org/MPL/
|
|
|
|
-
|
|
|
|
- Software distributed under the License is distributed on an "AS
|
|
|
|
- IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
- implied. See the License for the specific language governing
|
|
|
|
- rights and limitations under the License.
|
|
|
|
-
|
|
|
|
- The Original Code is this file as it was released on
|
|
|
|
- March 28, 2001.
|
|
|
|
-
|
|
|
|
- The Initial Developer of the Original Code is Peter Annema.
|
|
|
|
- Portions created by Peter Annema are Copyright (C) 2001
|
|
|
|
- Peter Annema. All Rights Reserved.
|
|
|
|
-
|
|
|
|
- Contributor(s):
|
|
|
|
- David Hyatt <hyatt@netscape.com> (Original Author of <tabbrowser>)
|
|
|
|
-
|
|
|
|
- Alternatively, the contents of this file may be used under the
|
|
|
|
- terms of the GNU General Public License Version 2 or later (the
|
|
|
|
- "GPL"), in which case the provisions of the GPL are applicable
|
|
|
|
- instead of those above. If you wish to allow use of your
|
|
|
|
- version of this file only under the terms of the GPL and not to
|
|
|
|
- allow others to use your version of this file under the MPL,
|
|
|
|
- indicate your decision by deleting the provisions above and
|
|
|
|
- replace them with the notice and other provisions required by
|
|
|
|
- the GPL. If you do not delete the provisions above, a recipient
|
|
|
|
- may use your version of this file under either the MPL or the
|
|
|
|
- GPL.
|
|
|
|
-->
|
|
|
|
|
2007-04-01 03:06:16 +04:00
|
|
|
<!DOCTYPE bindings [
|
|
|
|
<!ENTITY % tabBrowserDTD SYSTEM "chrome://global/locale/tabbrowser.dtd" >
|
|
|
|
%tabBrowserDTD;
|
|
|
|
]>
|
|
|
|
|
2007-04-01 03:03:27 +04:00
|
|
|
<bindings id="tabBrowserBindings"
|
|
|
|
xmlns="http://www.mozilla.org/xbl"
|
|
|
|
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
|
|
|
|
|
|
<binding id="tabbrowser">
|
|
|
|
<resources>
|
|
|
|
<stylesheet src="chrome://global/skin/browser.css"/>
|
|
|
|
</resources>
|
|
|
|
|
|
|
|
<content>
|
2007-04-01 03:06:29 +04:00
|
|
|
<xul:stringbundle src="chrome://global/locale/tabbrowser.properties"/>
|
XUL/theme simplification changes - removing unnecessary boxes and re-writing large portions of the themes to use new -moz-border-colors and -moz-image-region css features. Also cleans up the classic skin quite a bit for both mac and win. Fixes bugs 113024, 113043, 113585, 113586, 115943, 113643, 114475, 99787, 110214, 113977, 113966, 114802, 64894, 90724, 103173, 103199, 103298, 110442, 111472, 111989, 113027, 113041, 109180, 109204, 81581, 81903, 103324, 110108, 114540, and probably more I forgot to mention. r=ben, sr=hyatt
2007-04-01 03:06:39 +04:00
|
|
|
<xul:tabbox flex="1"
|
|
|
|
onselect="if (event.target.localName != 'tabpanels') return; this.parentNode.updateCurrentBrowser();">
|
|
|
|
<xul:hbox class="tabbrowser-strip" collapsed="true" tooltip="_child" context="_child">
|
|
|
|
<xul:tooltip onpopupshowing="event.preventBubble(); if (document.tooltipNode.hasAttribute('label')) { this.setAttribute('label', document.tooltipNode.getAttribute('label')); return true; } return false;"/>
|
2007-04-01 03:06:46 +04:00
|
|
|
<xul:menupopup onpopupshowing="this.parentNode.parentNode.parentNode.mContextTab = document.popupNode;">
|
XUL/theme simplification changes - removing unnecessary boxes and re-writing large portions of the themes to use new -moz-border-colors and -moz-image-region css features. Also cleans up the classic skin quite a bit for both mac and win. Fixes bugs 113024, 113043, 113585, 113586, 115943, 113643, 114475, 99787, 110214, 113977, 113966, 114802, 64894, 90724, 103173, 103199, 103298, 110442, 111472, 111989, 113027, 113041, 109180, 109204, 81581, 81903, 103324, 110108, 114540, and probably more I forgot to mention. r=ben, sr=hyatt
2007-04-01 03:06:39 +04:00
|
|
|
<xul:menuitem label="&newTab.label;" accesskey="&newTab.accesskey;"
|
|
|
|
oncommand="var tabbrowser = this.parentNode.parentNode.parentNode.parentNode;
|
|
|
|
tabbrowser.selectedTab = tabbrowser.addTab('about:blank');"/>
|
2007-04-01 03:06:16 +04:00
|
|
|
<xul:menuseparator/>
|
XUL/theme simplification changes - removing unnecessary boxes and re-writing large portions of the themes to use new -moz-border-colors and -moz-image-region css features. Also cleans up the classic skin quite a bit for both mac and win. Fixes bugs 113024, 113043, 113585, 113586, 115943, 113643, 114475, 99787, 110214, 113977, 113966, 114802, 64894, 90724, 103173, 103199, 103298, 110442, 111472, 111989, 113027, 113041, 109180, 109204, 81581, 81903, 103324, 110108, 114540, and probably more I forgot to mention. r=ben, sr=hyatt
2007-04-01 03:06:39 +04:00
|
|
|
<xul:menuitem label="&reloadTab.label;" accesskey="&reloadTab.accesskey;"
|
|
|
|
oncommand="var tabbrowser = this.parentNode.parentNode.parentNode.parentNode;
|
2007-04-01 03:06:46 +04:00
|
|
|
tabbrowser.reloadTab(tabbrowser.mContextTab);"/>
|
XUL/theme simplification changes - removing unnecessary boxes and re-writing large portions of the themes to use new -moz-border-colors and -moz-image-region css features. Also cleans up the classic skin quite a bit for both mac and win. Fixes bugs 113024, 113043, 113585, 113586, 115943, 113643, 114475, 99787, 110214, 113977, 113966, 114802, 64894, 90724, 103173, 103199, 103298, 110442, 111472, 111989, 113027, 113041, 109180, 109204, 81581, 81903, 103324, 110108, 114540, and probably more I forgot to mention. r=ben, sr=hyatt
2007-04-01 03:06:39 +04:00
|
|
|
<xul:menuitem label="&reloadAllTabs.label;" accesskey="&reloadAllTabs.accesskey;"
|
|
|
|
oncommand="var tabbrowser = this.parentNode.parentNode.parentNode.parentNode;
|
2007-04-01 03:06:46 +04:00
|
|
|
tabbrowser.reloadAllTabs(tabbrowser.mContextTab);"/>
|
2007-04-01 03:06:23 +04:00
|
|
|
<xul:menuseparator/>
|
XUL/theme simplification changes - removing unnecessary boxes and re-writing large portions of the themes to use new -moz-border-colors and -moz-image-region css features. Also cleans up the classic skin quite a bit for both mac and win. Fixes bugs 113024, 113043, 113585, 113586, 115943, 113643, 114475, 99787, 110214, 113977, 113966, 114802, 64894, 90724, 103173, 103199, 103298, 110442, 111472, 111989, 113027, 113041, 109180, 109204, 81581, 81903, 103324, 110108, 114540, and probably more I forgot to mention. r=ben, sr=hyatt
2007-04-01 03:06:39 +04:00
|
|
|
<xul:menuitem label="&closeTab.label;" accesskey="&closeTab.accesskey;"
|
|
|
|
oncommand="var tabbrowser = this.parentNode.parentNode.parentNode.parentNode;
|
2007-04-01 03:06:46 +04:00
|
|
|
tabbrowser.removeTab(tabbrowser.mContextTab);"/>
|
2007-04-01 03:06:25 +04:00
|
|
|
<xul:menuseparator/>
|
XUL/theme simplification changes - removing unnecessary boxes and re-writing large portions of the themes to use new -moz-border-colors and -moz-image-region css features. Also cleans up the classic skin quite a bit for both mac and win. Fixes bugs 113024, 113043, 113585, 113586, 115943, 113643, 114475, 99787, 110214, 113977, 113966, 114802, 64894, 90724, 103173, 103199, 103298, 110442, 111472, 111989, 113027, 113041, 109180, 109204, 81581, 81903, 103324, 110108, 114540, and probably more I forgot to mention. r=ben, sr=hyatt
2007-04-01 03:06:39 +04:00
|
|
|
<xul:menuitem label="&closeOtherTabs.label;" accesskey="&closeOtherTabs.accesskey;"
|
|
|
|
oncommand="var tabbrowser = this.parentNode.parentNode.parentNode.parentNode;
|
2007-04-01 03:06:46 +04:00
|
|
|
tabbrowser.removeAllTabsBut(tabbrowser.mContextTab);"/>
|
2007-04-01 03:06:16 +04:00
|
|
|
</xul:menupopup>
|
XUL/theme simplification changes - removing unnecessary boxes and re-writing large portions of the themes to use new -moz-border-colors and -moz-image-region css features. Also cleans up the classic skin quite a bit for both mac and win. Fixes bugs 113024, 113043, 113585, 113586, 115943, 113643, 114475, 99787, 110214, 113977, 113966, 114802, 64894, 90724, 103173, 103199, 103298, 110442, 111472, 111989, 113027, 113041, 109180, 109204, 81581, 81903, 103324, 110108, 114540, and probably more I forgot to mention. r=ben, sr=hyatt
2007-04-01 03:06:39 +04:00
|
|
|
|
2007-04-01 03:06:49 +04:00
|
|
|
<xul:tabs class="tabbrowser-tabs" closebutton="true" disableclose="true" flex="1"
|
XUL/theme simplification changes - removing unnecessary boxes and re-writing large portions of the themes to use new -moz-border-colors and -moz-image-region css features. Also cleans up the classic skin quite a bit for both mac and win. Fixes bugs 113024, 113043, 113585, 113586, 115943, 113643, 114475, 99787, 110214, 113977, 113966, 114802, 64894, 90724, 103173, 103199, 103298, 110442, 111472, 111989, 113027, 113041, 109180, 109204, 81581, 81903, 103324, 110108, 114540, and probably more I forgot to mention. r=ben, sr=hyatt
2007-04-01 03:06:39 +04:00
|
|
|
onclick="if (event.button != 1 || event.target.localName != 'tab') return;
|
|
|
|
this.parentNode.parentNode.parentNode.removeTab(event.target);"
|
|
|
|
ondragover="nsDragAndDrop.dragOver(event, this.parentNode.parentNode.parentNode);
|
|
|
|
event.stopPropagation();"
|
|
|
|
ondragdrop="nsDragAndDrop.drop(event, this.parentNode.parentNode.parentNode);
|
|
|
|
event.stopPropagation();"
|
|
|
|
onclosetab="var node = this.parentNode;
|
|
|
|
while (node.localName != 'tabbrowser')
|
|
|
|
node = node.parentNode;
|
|
|
|
node.removeCurrentTab();">
|
|
|
|
|
|
|
|
<xul:tab validate="never"
|
2007-04-01 03:06:42 +04:00
|
|
|
onerror="this.parentNode.parentNode.parentNode.parentNode.addToMissedIconCache(this.getAttribute('image'));
|
XUL/theme simplification changes - removing unnecessary boxes and re-writing large portions of the themes to use new -moz-border-colors and -moz-image-region css features. Also cleans up the classic skin quite a bit for both mac and win. Fixes bugs 113024, 113043, 113585, 113586, 115943, 113643, 114475, 99787, 110214, 113977, 113966, 114802, 64894, 90724, 103173, 103199, 103298, 110442, 111472, 111989, 113027, 113041, 109180, 109204, 81581, 81903, 103324, 110108, 114540, and probably more I forgot to mention. r=ben, sr=hyatt
2007-04-01 03:06:39 +04:00
|
|
|
this.removeAttribute('image');"
|
2007-04-01 03:06:44 +04:00
|
|
|
maxwidth="250" width="0" minwidth="30" flex="100"
|
XUL/theme simplification changes - removing unnecessary boxes and re-writing large portions of the themes to use new -moz-border-colors and -moz-image-region css features. Also cleans up the classic skin quite a bit for both mac and win. Fixes bugs 113024, 113043, 113585, 113586, 115943, 113643, 114475, 99787, 110214, 113977, 113966, 114802, 64894, 90724, 103173, 103199, 103298, 110442, 111472, 111989, 113027, 113041, 109180, 109204, 81581, 81903, 103324, 110108, 114540, and probably more I forgot to mention. r=ben, sr=hyatt
2007-04-01 03:06:39 +04:00
|
|
|
class="tabbrowser-tab" label="&untitledTab;" crop="end"/>
|
2007-04-01 03:03:27 +04:00
|
|
|
</xul:tabs>
|
XUL/theme simplification changes - removing unnecessary boxes and re-writing large portions of the themes to use new -moz-border-colors and -moz-image-region css features. Also cleans up the classic skin quite a bit for both mac and win. Fixes bugs 113024, 113043, 113585, 113586, 115943, 113643, 114475, 99787, 110214, 113977, 113966, 114802, 64894, 90724, 103173, 103199, 103298, 110442, 111472, 111989, 113027, 113041, 109180, 109204, 81581, 81903, 103324, 110108, 114540, and probably more I forgot to mention. r=ben, sr=hyatt
2007-04-01 03:06:39 +04:00
|
|
|
</xul:hbox>
|
|
|
|
<xul:tabpanels flex="1" class="plain">
|
2007-04-01 03:03:27 +04:00
|
|
|
<xul:browser type="content-primary" inherits="tooltip=contenttooltip,contextmenu=contentcontextmenu"/>
|
|
|
|
</xul:tabpanels>
|
|
|
|
</xul:tabbox>
|
|
|
|
<children/>
|
|
|
|
</content>
|
|
|
|
<implementation>
|
2007-04-01 03:06:45 +04:00
|
|
|
<field name="mPrefs" readonly="true">
|
|
|
|
Components.classes['@mozilla.org/preferences-service;1']
|
|
|
|
.getService(Components.interfaces.nsIPrefService)
|
|
|
|
.getBranch(null);
|
|
|
|
</field>
|
2007-04-01 03:03:27 +04:00
|
|
|
<field name="mTabBox">
|
2007-04-01 03:06:29 +04:00
|
|
|
document.getAnonymousNodes(this)[1]
|
2007-04-01 03:03:27 +04:00
|
|
|
</field>
|
|
|
|
<field name="mStrip">
|
|
|
|
this.mTabBox.firstChild
|
|
|
|
</field>
|
|
|
|
<field name="mTabContainer">
|
2007-04-01 03:06:16 +04:00
|
|
|
this.mStrip.childNodes[2]
|
2007-04-01 03:03:27 +04:00
|
|
|
</field>
|
|
|
|
<field name="mPanelContainer">
|
|
|
|
this.mTabBox.childNodes[1]
|
|
|
|
</field>
|
2007-04-01 03:06:29 +04:00
|
|
|
<field name="mStringBundle">
|
|
|
|
document.getAnonymousNodes(this)[0]
|
|
|
|
</field>
|
2007-04-01 03:03:27 +04:00
|
|
|
<field name="mCurrentTab">
|
|
|
|
null
|
|
|
|
</field>
|
|
|
|
<field name="mCurrentBrowser">
|
|
|
|
null
|
|
|
|
</field>
|
|
|
|
<field name="mProgressListeners">
|
|
|
|
null
|
|
|
|
</field>
|
|
|
|
<field name="mTabListeners">
|
|
|
|
new Array()
|
|
|
|
</field>
|
|
|
|
<field name="mTabbedMode">
|
|
|
|
false
|
|
|
|
</field>
|
|
|
|
<field name="mIsBusy">
|
|
|
|
false
|
|
|
|
</field>
|
2007-04-01 03:06:33 +04:00
|
|
|
<field name="mMissedIconCache">
|
|
|
|
null
|
|
|
|
</field>
|
2007-04-01 03:06:46 +04:00
|
|
|
<field name="mContextTab">
|
|
|
|
null
|
|
|
|
</field>
|
2007-04-01 03:03:27 +04:00
|
|
|
|
|
|
|
<!-- A web progress listener object definition for a given tab. -->
|
|
|
|
<method name="mTabProgressListener">
|
|
|
|
<parameter name="aTabBrowser"/>
|
|
|
|
<parameter name="aTab"/>
|
2007-04-01 03:06:24 +04:00
|
|
|
<parameter name="aStartsBlank"/>
|
2007-04-01 03:03:27 +04:00
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
return ({
|
|
|
|
mTabBrowser: aTabBrowser,
|
|
|
|
mTab: aTab,
|
2007-04-01 03:06:24 +04:00
|
|
|
mBlank: aStartsBlank,
|
2007-04-01 03:06:32 +04:00
|
|
|
mIcon: "",
|
2007-04-01 03:03:27 +04:00
|
|
|
|
|
|
|
onProgressChange : function (aWebProgress, aRequest,
|
|
|
|
aCurSelfProgress, aMaxSelfProgress,
|
|
|
|
aCurTotalProgress, aMaxTotalProgress) {
|
2007-04-01 03:06:24 +04:00
|
|
|
if (!this.mBlank && this.mTabBrowser.mCurrentTab == this.mTab) {
|
2007-04-01 03:03:27 +04:00
|
|
|
for (var i = 0; i < this.mTabBrowser.mProgressListeners.length; i++) {
|
|
|
|
var p = this.mTabBrowser.mProgressListeners[i];
|
|
|
|
if (p)
|
|
|
|
p.onProgressChange(aWebProgress, aRequest,
|
|
|
|
aCurSelfProgress, aMaxSelfProgress,
|
|
|
|
aCurTotalProgress, aMaxTotalProgress);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onStateChange : function(aWebProgress, aRequest, aStateFlags, aStatus)
|
|
|
|
{
|
|
|
|
if (!aRequest)
|
|
|
|
return;
|
|
|
|
|
|
|
|
//ignore local/resource:/chrome: files
|
|
|
|
if (aStatus == NS_NET_STATUS_READ_FROM || aStatus == NS_NET_STATUS_WROTE_TO)
|
|
|
|
return;
|
|
|
|
|
2007-04-01 03:06:24 +04:00
|
|
|
var oldBlank = this.mBlank;
|
|
|
|
|
2007-04-01 03:03:27 +04:00
|
|
|
const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
|
|
|
|
const nsIChannel = Components.interfaces.nsIChannel;
|
2007-04-01 03:06:24 +04:00
|
|
|
if (!this.mBlank && aStateFlags & nsIWebProgressListener.STATE_START &&
|
2007-04-01 03:03:27 +04:00
|
|
|
aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
|
|
|
|
this.mTab.setAttribute("busy", "true");
|
2007-04-01 03:06:29 +04:00
|
|
|
this.mTab.label = this.mTabBrowser.mStringBundle.getString("tabs.loading");
|
2007-04-01 03:06:32 +04:00
|
|
|
this.mTab.removeAttribute("image");
|
|
|
|
this.mIcon = "";
|
|
|
|
|
2007-04-01 03:03:27 +04:00
|
|
|
if (this.mTabBrowser.mCurrentTab == this.mTab)
|
|
|
|
this.mTabBrowser.mIsBusy = true;
|
|
|
|
}
|
|
|
|
else if (aStateFlags & nsIWebProgressListener.STATE_STOP &&
|
|
|
|
aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
|
2007-04-01 03:06:24 +04:00
|
|
|
if (this.mBlank)
|
|
|
|
this.mBlank = false;
|
2007-04-01 03:03:27 +04:00
|
|
|
|
2007-04-01 03:06:32 +04:00
|
|
|
this.mTab.removeAttribute("busy");
|
|
|
|
|
|
|
|
var location = aRequest.QueryInterface(nsIChannel).URI;
|
|
|
|
if (this.mIcon) {
|
|
|
|
this.mTab.setAttribute("image", this.mIcon);
|
|
|
|
mIcon = "";
|
2007-04-01 03:06:24 +04:00
|
|
|
}
|
2007-04-01 03:06:33 +04:00
|
|
|
else if (this.mTabBrowser.shouldLoadFavIcon(location))
|
|
|
|
this.mTabBrowser.loadFavIcon(location, "image", this.mTab);
|
|
|
|
|
2007-04-01 03:06:32 +04:00
|
|
|
if (this.mTab.label == this.mTabBrowser.mStringBundle.getString("tabs.loading"))
|
|
|
|
this.mTab.label = this.mTabBrowser.mStringBundle.getString("tabs.untitled")
|
|
|
|
|
|
|
|
if (this.mTabBrowser.mCurrentTab == this.mTab)
|
|
|
|
this.mTabBrowser.mIsBusy = false;
|
2007-04-01 03:03:27 +04:00
|
|
|
}
|
|
|
|
|
2007-04-01 03:06:24 +04:00
|
|
|
if (!oldBlank && this.mTabBrowser.mCurrentTab == this.mTab) {
|
2007-04-01 03:03:27 +04:00
|
|
|
for (var i = 0; i < this.mTabBrowser.mProgressListeners.length; i++) {
|
|
|
|
var p = this.mTabBrowser.mProgressListeners[i];
|
|
|
|
if (p)
|
|
|
|
p.onStateChange(aWebProgress, aRequest, aStateFlags, aStatus);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
,
|
|
|
|
|
|
|
|
onLocationChange : function(aWebProgress, aRequest, aLocation) {
|
2007-04-01 03:06:24 +04:00
|
|
|
if (!this.mBlank && this.mTabBrowser.mCurrentTab == this.mTab) {
|
2007-04-01 03:03:27 +04:00
|
|
|
for (var i = 0; i < this.mTabBrowser.mProgressListeners.length; i++) {
|
|
|
|
var p = this.mTabBrowser.mProgressListeners[i];
|
|
|
|
if (p)
|
|
|
|
p.onLocationChange(aWebProgress, aRequest, aLocation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage) {
|
|
|
|
//ignore local/resource:/chrome: files
|
2007-04-01 03:06:24 +04:00
|
|
|
if (this.mBlank || aStatus == NS_NET_STATUS_READ_FROM || aStatus == NS_NET_STATUS_WROTE_TO)
|
2007-04-01 03:03:27 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (this.mTabBrowser.mCurrentTab == this.mTab) {
|
|
|
|
for (var i = 0; i < this.mTabBrowser.mProgressListeners.length; i++) {
|
|
|
|
var p = this.mTabBrowser.mProgressListeners[i];
|
|
|
|
if (p)
|
|
|
|
p.onStatusChange(aWebProgress, aRequest, aStatus, aMessage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onSecurityChange : function(aWebProgress, aRequest, aState) {
|
2007-04-01 03:06:31 +04:00
|
|
|
if (!this.mBlank && this.mTabBrowser.mCurrentTab == this.mTab) {
|
2007-04-01 03:03:27 +04:00
|
|
|
for (var i = 0; i < this.mTabBrowser.mProgressListeners.length; i++) {
|
|
|
|
var p = this.mTabBrowser.mProgressListeners[i];
|
|
|
|
if (p)
|
|
|
|
p.onSecurityChange(aWebProgress, aRequest, aState);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
QueryInterface : function(aIID)
|
|
|
|
{
|
|
|
|
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
|
|
|
|
aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
|
|
|
|
aIID.equals(Components.interfaces.nsISupports))
|
|
|
|
return this;
|
|
|
|
throw Components.results.NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2007-04-01 03:06:32 +04:00
|
|
|
<method name="buildFavIconString">
|
|
|
|
<parameter name="aURI"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var end = (aURI.port == -1) ? "/favicon.ico" : (":" + aURI.port + "/favicon.ico");
|
|
|
|
return aURI.scheme + "://" + aURI.host + end;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2007-04-01 03:06:33 +04:00
|
|
|
<method name="shouldLoadFavIcon">
|
|
|
|
<parameter name="aURI"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2007-04-01 03:06:45 +04:00
|
|
|
return (aURI && this.mPrefs.getBoolPref("browser.chrome.site_icons") &&
|
|
|
|
this.mPrefs.getBoolPref("browser.chrome.favicons") &&
|
2007-04-01 03:06:33 +04:00
|
|
|
("schemeIs" in aURI) && (aURI.schemeIs("http") || aURI.schemeIs("https")));
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="loadFavIcon">
|
|
|
|
<parameter name="aURI"/>
|
|
|
|
<parameter name="aAttr"/>
|
|
|
|
<parameter name="aElt"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var iconURL = this.buildFavIconString(aURI);
|
|
|
|
if (!this.mMissedIconCache) {
|
|
|
|
var cacheService = Components.classes['@mozilla.org/network/cache-service;1'].getService(Components.interfaces.nsICacheService);
|
2007-04-01 03:06:35 +04:00
|
|
|
this.mMissedIconCache = cacheService.createSession("MissedIconCache", Components.interfaces.nsICache.STORE_ANYWHERE, true);
|
2007-04-01 03:06:33 +04:00
|
|
|
if (!this.mMissedIconCache)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
var entry = this.mMissedIconCache.openCacheEntry(iconURL, Components.interfaces.nsICache.ACCESS_READ, true);
|
|
|
|
}
|
|
|
|
catch (exc) {}
|
|
|
|
if (!entry)
|
|
|
|
aElt.setAttribute(aAttr, iconURL);
|
2007-04-01 03:06:34 +04:00
|
|
|
else {
|
|
|
|
entry.close();
|
2007-04-01 03:06:33 +04:00
|
|
|
entry = null;
|
2007-04-01 03:06:34 +04:00
|
|
|
}
|
2007-04-01 03:06:33 +04:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="addToMissedIconCache">
|
|
|
|
<parameter name="aURI"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var entry = this.mMissedIconCache.openCacheEntry(aURI, Components.interfaces.nsICache.ACCESS_READ_WRITE, true);
|
|
|
|
if (entry.accessGranted == Components.interfaces.nsICache.ACCESS_WRITE)
|
|
|
|
// It's a new entry. Just write a bit of metadata in to the entry.
|
|
|
|
entry.setMetaDataElement("Icon", "Missed");
|
|
|
|
entry.markValid();
|
|
|
|
entry.close();
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2007-04-01 03:03:27 +04:00
|
|
|
<method name="updateTitlebar">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var newTitle = "";
|
|
|
|
var docTitle;
|
|
|
|
if (this.docShell.contentViewer)
|
|
|
|
docTitle = this.contentDocument.title;
|
|
|
|
|
|
|
|
if (docTitle) {
|
|
|
|
newTitle += this.ownerDocument.documentElement.getAttribute("titlepreface");
|
|
|
|
newTitle += docTitle;
|
|
|
|
newTitle += this.ownerDocument.documentElement.getAttribute("titlemenuseparator");
|
|
|
|
}
|
|
|
|
newTitle += this.ownerDocument.documentElement.getAttribute("titlemodifier");
|
|
|
|
window.title = newTitle;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="updateCurrentBrowser">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2007-04-01 03:06:20 +04:00
|
|
|
var newBrowser = this.mPanelContainer.childNodes[this.mPanelContainer.selectedIndex];
|
2007-04-01 03:03:27 +04:00
|
|
|
if (this.mCurrentBrowser)
|
|
|
|
this.mCurrentBrowser.setAttribute("type", "content");
|
|
|
|
|
|
|
|
newBrowser.setAttribute("type", "content-primary");
|
|
|
|
this.mCurrentBrowser = newBrowser;
|
|
|
|
this.mCurrentTab = this.selectedTab;
|
|
|
|
|
|
|
|
// Update the URL bar.
|
2007-04-01 03:06:32 +04:00
|
|
|
var loc = this.mCurrentBrowser.currentURI;
|
|
|
|
if (!loc)
|
|
|
|
loc = ({ spec: "" });
|
2007-04-01 03:06:24 +04:00
|
|
|
|
2007-04-01 03:03:27 +04:00
|
|
|
var webProgress = this.mCurrentBrowser.webProgress;
|
2007-04-01 03:06:17 +04:00
|
|
|
var i, p;
|
|
|
|
for (i = 0; i < this.mProgressListeners.length; i++) {
|
|
|
|
p = this.mProgressListeners[i];
|
2007-04-01 03:06:32 +04:00
|
|
|
if (p) {
|
2007-04-01 03:03:27 +04:00
|
|
|
p.onLocationChange(webProgress, null, loc);
|
2007-04-01 03:06:32 +04:00
|
|
|
var listener = this.mTabListeners[this.mPanelContainer.selectedIndex];
|
|
|
|
if (listener.mIcon)
|
|
|
|
p.onLinkIconAvailable(listener.mIcon);
|
|
|
|
}
|
2007-04-01 03:03:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update the window title.
|
|
|
|
this.updateTitlebar();
|
|
|
|
|
|
|
|
// If the new tab is busy, and our current state is not busy, then
|
|
|
|
// we need to fire a start to all progress listeners.
|
|
|
|
const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
|
2007-04-01 03:06:38 +04:00
|
|
|
if (this.mCurrentTab.hasAttribute("busy") && !this.mIsBusy) {
|
2007-04-01 03:03:27 +04:00
|
|
|
this.mIsBusy = true;
|
2007-04-01 03:06:37 +04:00
|
|
|
webProgress = this.mCurrentBrowser.webProgress;
|
2007-04-01 03:06:17 +04:00
|
|
|
for (i = 0; i < this.mProgressListeners.length; i++) {
|
|
|
|
p = this.mProgressListeners[i];
|
2007-04-01 03:03:27 +04:00
|
|
|
if (p)
|
|
|
|
p.onStateChange(webProgress, null, nsIWebProgressListener.STATE_START | nsIWebProgressListener.STATE_IS_NETWORK, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the new tab is not busy, and our current state is busy, then
|
|
|
|
// we need to fire a stop to all progress listeners.
|
2007-04-01 03:06:38 +04:00
|
|
|
if (!this.mCurrentTab.hasAttribute("busy") && this.mIsBusy) {
|
2007-04-01 03:03:27 +04:00
|
|
|
this.mIsBusy = false;
|
2007-04-01 03:06:37 +04:00
|
|
|
webProgress = this.mCurrentBrowser.webProgress;
|
2007-04-01 03:06:17 +04:00
|
|
|
for (i = 0; i < this.mProgressListeners.length; i++) {
|
|
|
|
p = this.mProgressListeners[i];
|
2007-04-01 03:03:27 +04:00
|
|
|
if (p)
|
|
|
|
p.onStateChange(webProgress, null, nsIWebProgressListener.STATE_STOP | nsIWebProgressListener.STATE_IS_NETWORK, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Focus our new content area.
|
|
|
|
setTimeout("window._content.focus()", 0);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2007-04-01 03:06:32 +04:00
|
|
|
<method name="onLinkAdded">
|
|
|
|
<parameter name="event"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2007-04-01 03:06:45 +04:00
|
|
|
var tabBrowser = this.parentNode.parentNode;
|
|
|
|
if (!tabBrowser.mPrefs.getBoolPref("browser.chrome.site_icons"))
|
2007-04-01 03:06:33 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (!event.target.rel.match((/(?:^|\s)icon(?:\s|$)/i)))
|
2007-04-01 03:06:32 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
// We have an icon.
|
|
|
|
var href = event.target.href;
|
|
|
|
if (!href)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Verify that the load of this icon is legal. We use the same
|
|
|
|
// content policy that is used for a Web page loading images.
|
|
|
|
var contentPolicy = Components.classes['@mozilla.org/layout/content-policy;1'].getService(Components.interfaces.nsIContentPolicy);
|
|
|
|
if (!contentPolicy)
|
|
|
|
return; // Refuse to load if we can't do a security check.
|
|
|
|
|
|
|
|
// Make a URI out of our href.
|
|
|
|
var uri = Components.classes['@mozilla.org/network/standard-url;1'].createInstance();
|
|
|
|
uri = uri.QueryInterface(Components.interfaces.nsIURI);
|
|
|
|
|
|
|
|
var notifyListeners = true;
|
2007-04-01 03:06:37 +04:00
|
|
|
var i;
|
|
|
|
|
2007-04-01 03:06:32 +04:00
|
|
|
if (tabBrowser.mTabbedMode) {
|
|
|
|
// We need to update a tab.
|
2007-04-01 03:06:37 +04:00
|
|
|
for (i = 0; i < this.childNodes.length; i++) {
|
2007-04-01 03:06:32 +04:00
|
|
|
if (this.childNodes[i].contentDocument == event.target.ownerDocument) {
|
|
|
|
if (!contentPolicy.shouldLoad(Components.interfaces.nsIContentPolicy.IMAGE,
|
|
|
|
uri, event.target, this.childNodes[i].contentWindow))
|
|
|
|
return;
|
|
|
|
|
|
|
|
var listener = tabBrowser.mTabListeners[i];
|
|
|
|
listener.mIcon = href;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
notifyListeners = (this.childNodes[i] == tabBrowser.mCurrentBrowser);
|
|
|
|
}
|
|
|
|
else if (!contentPolicy.shouldLoad(Components.interfaces.nsIContentPolicy.IMAGE,
|
|
|
|
uri, event.target, tabBrowser.mCurrentBrowser.contentWindow))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (notifyListeners && tabBrowser.mProgressListeners) {
|
2007-04-01 03:06:37 +04:00
|
|
|
for (i = 0; i < tabBrowser.mProgressListeners.length; i++) {
|
2007-04-01 03:06:32 +04:00
|
|
|
var p = tabBrowser.mProgressListeners[i];
|
|
|
|
if (p)
|
|
|
|
p.onLinkIconAvailable(href);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2007-04-01 03:03:27 +04:00
|
|
|
<method name="onTitleChanged">
|
|
|
|
<parameter name="evt"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
if (evt.target != this.contentDocument)
|
|
|
|
return;
|
|
|
|
|
|
|
|
var i = 0;
|
|
|
|
for ( ; i < this.parentNode.childNodes.length; i++) {
|
|
|
|
if (this.parentNode.childNodes[i] == this)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
var tabBrowser = this.parentNode.parentNode.parentNode;
|
|
|
|
var tab = tabBrowser.mTabContainer.childNodes[i];
|
2007-04-01 03:06:41 +04:00
|
|
|
|
|
|
|
if (this.contentDocument.title)
|
|
|
|
tab.setAttribute("label", this.contentDocument.title);
|
2007-04-01 03:03:27 +04:00
|
|
|
|
|
|
|
if (tab == tabBrowser.mCurrentTab)
|
|
|
|
this.parentNode.parentNode.parentNode.updateTitlebar();
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2007-04-01 03:06:29 +04:00
|
|
|
<method name="setStripVisibilityTo">
|
|
|
|
<parameter name="aShow"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
this.mStrip.collapsed = !aShow;
|
|
|
|
if (aShow) {
|
|
|
|
// XXXdwh temporary unclean dependency on specific menu items in navigator.xul
|
|
|
|
document.getElementById("menu_closeWindow").hidden = false;
|
|
|
|
document.getElementById("menu_closeSeparator").hidden = false;
|
|
|
|
document.getElementById("menu_close").setAttribute("label", this.mStringBundle.getString("tabs.closeTab"));
|
2007-04-01 03:06:48 +04:00
|
|
|
if (!this.mTabbedMode)
|
|
|
|
this.enterTabbedMode();
|
2007-04-01 03:06:29 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// XXXdwh temporary unclean dependency on specific menu items in navigator.xul
|
|
|
|
document.getElementById("menu_closeWindow").hidden = true;
|
|
|
|
document.getElementById("menu_closeSeparator").hidden = true;
|
|
|
|
document.getElementById("menu_close").setAttribute("label", this.mStringBundle.getString("tabs.close"));
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2007-04-01 03:06:47 +04:00
|
|
|
<method name="getStripVisibility">
|
|
|
|
<body>
|
|
|
|
return !this.mStrip.collapsed;
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2007-04-01 03:06:48 +04:00
|
|
|
<method name="enterTabbedMode">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
this.mTabbedMode = true; // Welcome to multi-tabbed mode.
|
|
|
|
|
|
|
|
// Get the first tab all hooked up with a title listener.
|
|
|
|
this.mCurrentBrowser.addEventListener("DOMTitleChanged", this.onTitleChanged, false);
|
|
|
|
|
|
|
|
if (this.mCurrentBrowser.contentDocument.title != "")
|
|
|
|
this.mCurrentTab.label = this.mCurrentBrowser.contentDocument.title;
|
|
|
|
|
|
|
|
// Hook up our favicon.
|
|
|
|
var uri = this.mCurrentBrowser.currentURI;
|
|
|
|
if (this.shouldLoadFavIcon(uri))
|
|
|
|
this.loadFavIcon(uri, "image", this.mCurrentTab);
|
|
|
|
|
|
|
|
// Remove all our progress listeners from the active browser.
|
|
|
|
if (this.mProgressListeners) {
|
|
|
|
for (var i = 0; i < this.mProgressListeners.length; i++) {
|
|
|
|
var p = this.mProgressListeners[i];
|
|
|
|
if (p)
|
|
|
|
this.mCurrentBrowser.webProgress.removeProgressListener(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Wire up a progress listener to our tab.
|
|
|
|
var listener = (this.mTabProgressListener)(this, this.mCurrentTab, false);
|
|
|
|
this.webProgress.addProgressListener(listener);
|
|
|
|
this.mTabListeners[0] = listener;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2007-04-01 03:03:27 +04:00
|
|
|
<method name="addTab">
|
|
|
|
<parameter name="aURI"/>
|
2007-04-01 03:06:43 +04:00
|
|
|
<parameter name="aReferrerURI"/>
|
2007-04-01 03:03:27 +04:00
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2007-04-01 03:06:49 +04:00
|
|
|
// Enable the close box
|
|
|
|
this.mTabContainer.removeAttribute("disableclose");
|
|
|
|
|
2007-04-01 03:06:24 +04:00
|
|
|
var blank = (aURI == "about:blank");
|
2007-04-01 03:03:27 +04:00
|
|
|
|
2007-04-01 03:06:48 +04:00
|
|
|
if (!this.mTabbedMode)
|
|
|
|
this.enterTabbedMode();
|
2007-04-01 03:03:27 +04:00
|
|
|
|
|
|
|
var b = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
|
|
|
|
"browser");
|
|
|
|
var t = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
|
|
|
|
"tab");
|
|
|
|
|
2007-04-01 03:06:24 +04:00
|
|
|
if (blank)
|
2007-04-01 03:06:29 +04:00
|
|
|
t.setAttribute("label", this.mStringBundle.getString("tabs.untitled"));
|
2007-04-01 03:03:27 +04:00
|
|
|
else
|
|
|
|
t.setAttribute("label", aURI);
|
|
|
|
|
2007-04-01 03:06:19 +04:00
|
|
|
t.setAttribute("crop", "end");
|
2007-04-01 03:06:24 +04:00
|
|
|
t.maxWidth = 250;
|
|
|
|
t.minWidth = 30;
|
|
|
|
t.width = 0;
|
2007-04-01 03:06:44 +04:00
|
|
|
t.setAttribute("flex", "100");
|
2007-04-01 03:06:32 +04:00
|
|
|
t.setAttribute("validate", "never");
|
2007-04-01 03:06:33 +04:00
|
|
|
t.setAttribute("onerror", "this.parentNode.parentNode.parentNode.parentNode.addToMissedIconCache(this.getAttribute('image')); this.removeAttribute('image');");
|
2007-04-01 03:03:27 +04:00
|
|
|
this.mTabContainer.appendChild(t);
|
|
|
|
|
|
|
|
b.setAttribute("type", "content");
|
|
|
|
b.setAttribute("contextmenu", this.getAttribute("contentcontextmenu"));
|
|
|
|
b.setAttribute("tooltip", this.getAttribute("contenttooltip"));
|
|
|
|
|
|
|
|
this.mPanelContainer.appendChild(b);
|
|
|
|
|
|
|
|
b.addEventListener("DOMTitleChanged", this.onTitleChanged, false);
|
2007-04-01 03:06:29 +04:00
|
|
|
|
2007-04-01 03:03:27 +04:00
|
|
|
if (this.mStrip.collapsed)
|
2007-04-01 03:06:29 +04:00
|
|
|
this.setStripVisibilityTo(true);
|
|
|
|
|
2007-04-01 03:03:27 +04:00
|
|
|
// wire up a progress listener for the new browser object.
|
|
|
|
var position = this.mTabContainer.childNodes.length-1;
|
2007-04-01 03:06:24 +04:00
|
|
|
var tabListener = (this.mTabProgressListener)(this, t, blank);
|
2007-04-01 03:03:27 +04:00
|
|
|
b.webProgress.addProgressListener(tabListener);
|
|
|
|
this.mTabListeners[position] = tabListener;
|
2007-04-01 03:06:43 +04:00
|
|
|
|
2007-04-01 03:06:24 +04:00
|
|
|
if (!blank)
|
2007-04-01 03:06:43 +04:00
|
|
|
b.loadURIWithFlags(aURI, nsIWebNavigation.LOAD_FLAGS_NONE,
|
|
|
|
aReferrerURI, null, null);
|
2007-04-01 03:03:27 +04:00
|
|
|
|
|
|
|
return t;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2007-04-01 03:06:16 +04:00
|
|
|
<method name="removeAllTabsBut">
|
|
|
|
<parameter name="aTab"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
if (aTab.localName == 'tabs')
|
|
|
|
aTab = this.mCurrentTab;
|
|
|
|
|
|
|
|
var l = this.mTabContainer.childNodes.length;
|
|
|
|
if (l == 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (var i = 0; i < l; i++) {
|
|
|
|
var tab = this.mTabContainer.childNodes[i];
|
|
|
|
if (tab != aTab) {
|
|
|
|
this.removeTab(tab);
|
|
|
|
i--;
|
|
|
|
l--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2007-04-01 03:03:27 +04:00
|
|
|
<method name="removeCurrentTab">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2007-04-01 03:06:16 +04:00
|
|
|
return this.removeTab(this.mCurrentTab);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="removeTab">
|
|
|
|
<parameter name="aTab"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
if (aTab.localName == 'tabs')
|
|
|
|
aTab = this.mCurrentTab;
|
|
|
|
|
2007-04-01 03:03:27 +04:00
|
|
|
var l = this.mTabContainer.childNodes.length;
|
|
|
|
if (l == 1)
|
|
|
|
return; // Don't allow the last tab to close.
|
|
|
|
|
2007-04-01 03:06:32 +04:00
|
|
|
if (l == 2) {
|
2007-04-01 03:06:45 +04:00
|
|
|
var autohide = this.mPrefs.getBoolPref("browser.tabs.autoHide");
|
2007-04-01 03:06:24 +04:00
|
|
|
if (autohide)
|
2007-04-01 03:06:29 +04:00
|
|
|
this.setStripVisibilityTo(false);
|
2007-04-01 03:06:49 +04:00
|
|
|
else
|
|
|
|
// Disable the close box
|
|
|
|
this.mTabContainer.setAttribute("disableclose", "true");
|
2007-04-01 03:06:24 +04:00
|
|
|
}
|
2007-04-01 03:03:27 +04:00
|
|
|
|
2007-04-01 03:06:16 +04:00
|
|
|
var index = -1;
|
|
|
|
if (this.mCurrentTab == aTab)
|
2007-04-01 03:06:20 +04:00
|
|
|
index = this.mPanelContainer.selectedIndex;
|
2007-04-01 03:06:16 +04:00
|
|
|
else {
|
|
|
|
// Find and locate the tab in our list.
|
|
|
|
for (var i = 0; i < l; i++)
|
|
|
|
if (this.mTabContainer.childNodes[i] == aTab)
|
|
|
|
index = i;
|
|
|
|
}
|
2007-04-01 03:03:27 +04:00
|
|
|
|
2007-04-01 03:06:16 +04:00
|
|
|
// Remove the tab's progress listener.
|
|
|
|
var oldBrowser = this.mPanelContainer.childNodes[index];
|
|
|
|
oldBrowser.webProgress.removeProgressListener(this.mTabListeners[index]);
|
2007-04-01 03:03:27 +04:00
|
|
|
this.mTabListeners.splice(index, 1);
|
|
|
|
|
|
|
|
// Remove our title change listener
|
2007-04-01 03:06:16 +04:00
|
|
|
oldBrowser.removeEventListener("DOMTitleChanged", this.onTitleChanged, false);
|
2007-04-01 03:06:32 +04:00
|
|
|
|
2007-04-01 03:03:27 +04:00
|
|
|
// We are no longer the primary content area.
|
2007-04-01 03:06:16 +04:00
|
|
|
oldBrowser.setAttribute("type", "content");
|
2007-04-01 03:03:27 +04:00
|
|
|
|
|
|
|
// Now select the new tab before nuking the old one.
|
2007-04-01 03:06:20 +04:00
|
|
|
var currentIndex = this.mPanelContainer.selectedIndex;
|
2007-04-01 03:06:16 +04:00
|
|
|
|
|
|
|
var newIndex = -1;
|
|
|
|
if (currentIndex > index)
|
|
|
|
newIndex = currentIndex-1;
|
|
|
|
else if (currentIndex < index)
|
|
|
|
newIndex = currentIndex;
|
|
|
|
else if (index > 0)
|
|
|
|
newIndex = index-1;
|
|
|
|
else
|
|
|
|
newIndex = index;
|
2007-04-01 03:03:27 +04:00
|
|
|
|
2007-04-01 03:06:16 +04:00
|
|
|
var oldTab = aTab;
|
|
|
|
|
2007-04-01 03:03:27 +04:00
|
|
|
this.mTabContainer.removeChild(oldTab);
|
|
|
|
this.mPanelContainer.removeChild(oldBrowser);
|
|
|
|
|
|
|
|
this.selectedTab = this.mTabContainer.childNodes[newIndex];
|
|
|
|
|
2007-04-01 03:06:16 +04:00
|
|
|
if (newIndex == index) {
|
2007-04-01 03:03:27 +04:00
|
|
|
// No select event is going to fire. We need to just call updateCurrentBrowser()
|
|
|
|
// by hand.
|
|
|
|
this.updateCurrentBrowser();
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2007-04-01 03:06:23 +04:00
|
|
|
<method name="reloadAllTabs">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var l = this.mPanelContainer.childNodes.length;
|
|
|
|
for (var i = 0; i < l; i++)
|
|
|
|
this.mPanelContainer.childNodes[i].webNavigation.reload(true);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="reloadTab">
|
|
|
|
<parameter name="aTab"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var l = this.mPanelContainer.childNodes.length;
|
|
|
|
for (var i = 0; i < l; i++)
|
|
|
|
if (this.mTabContainer.childNodes[i] == aTab)
|
|
|
|
this.mPanelContainer.childNodes[i].webNavigation.reload(true);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2007-04-01 03:03:27 +04:00
|
|
|
<method name="addProgressListener">
|
|
|
|
<parameter name="aListener"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2007-04-01 03:06:24 +04:00
|
|
|
if (!this.mProgressListeners) {
|
2007-04-01 03:03:27 +04:00
|
|
|
this.mProgressListeners = new Array();
|
2007-04-01 03:06:45 +04:00
|
|
|
var autohide = this.mPrefs.getBoolPref("browser.tabs.autoHide");
|
2007-04-01 03:06:24 +04:00
|
|
|
if (!autohide) {
|
2007-04-01 03:06:29 +04:00
|
|
|
this.setStripVisibilityTo(true);
|
|
|
|
|
2007-04-01 03:06:24 +04:00
|
|
|
this.mTabbedMode = true;
|
|
|
|
this.mCurrentBrowser.addEventListener("DOMTitleChanged", this.onTitleChanged, false);
|
2007-04-01 03:06:32 +04:00
|
|
|
|
2007-04-01 03:06:24 +04:00
|
|
|
// Wire up a progress listener to our tab.
|
|
|
|
var listener = (this.mTabProgressListener)(this, this.mCurrentTab);
|
|
|
|
this.webProgress.addProgressListener(listener);
|
|
|
|
this.mTabListeners[0] = listener;
|
|
|
|
}
|
2007-04-01 03:06:32 +04:00
|
|
|
|
|
|
|
// Hook up a listener for <link>s.
|
|
|
|
this.mPanelContainer.addEventListener("DOMLinkAdded", this.onLinkAdded, false);
|
2007-04-01 03:06:24 +04:00
|
|
|
}
|
|
|
|
|
2007-04-01 03:03:27 +04:00
|
|
|
this.mProgressListeners.push(aListener);
|
|
|
|
|
|
|
|
if (!this.mTabbedMode)
|
|
|
|
// Just perform a direct wiring to the single active browser.
|
|
|
|
this.mCurrentBrowser.addProgressListener(aListener);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="removeProgressListener">
|
|
|
|
<parameter name="aListener"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
if (!this.mProgressListeners) return;
|
|
|
|
for (var i = 0; i < this.mProgressListeners.length; i++) {
|
|
|
|
if (this.mProgressListeners[i] == aListener) {
|
|
|
|
this.mProgressListeners[i] = null;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this.mTabbedMode)
|
|
|
|
// Just do a direct removal.
|
|
|
|
this.mCurrentBrowser.removeProgressListener(aListener);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2007-04-01 03:06:26 +04:00
|
|
|
<method name="getBrowserForTab">
|
|
|
|
<parameter name="aTab"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
if (this.mCurrentTab == aTab)
|
|
|
|
return this.mCurrentBrowser;
|
|
|
|
|
2007-04-01 03:06:37 +04:00
|
|
|
for (var i = 0; i < this.mTabContainer.childNodes.length; i++) {
|
|
|
|
if (this.mTabContainer.childNodes[i] == aTab) {
|
|
|
|
return this.mPanelContainer.childNodes[i];
|
|
|
|
}
|
2007-04-01 03:06:26 +04:00
|
|
|
}
|
|
|
|
|
2007-04-01 03:06:37 +04:00
|
|
|
return null;
|
2007-04-01 03:06:26 +04:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2007-04-01 03:03:27 +04:00
|
|
|
<property name="selectedTab">
|
|
|
|
<getter>
|
|
|
|
return this.mTabBox.selectedTab;
|
|
|
|
</getter>
|
|
|
|
<setter>
|
|
|
|
<![CDATA[
|
|
|
|
// Update the tab
|
|
|
|
this.mTabBox.selectedTab = val;
|
|
|
|
return val;
|
|
|
|
]]>
|
|
|
|
</setter>
|
|
|
|
</property>
|
|
|
|
|
2007-04-01 03:06:26 +04:00
|
|
|
<!-- Drag and drop observer API -->
|
|
|
|
<!--<method name="onDragStart">
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
<parameter name="aXferData"/>
|
|
|
|
<parameter name="aDragAction"/>
|
|
|
|
<body/>
|
|
|
|
</method>-->
|
|
|
|
|
|
|
|
<method name="onDragOver">
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
<parameter name="aFlavour"/>
|
|
|
|
<parameter name="aDragSession"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
return; // Just having this makes our feedback correct.
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="onDrop">
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
<parameter name="aXferData"/>
|
|
|
|
<parameter name="aDragSession"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var url = retrieveURLFromData(aXferData.data, aXferData.flavour.contentType);
|
|
|
|
|
|
|
|
// valid urls don't contain spaces ' '; if we have a space it isn't a valid url so bail out
|
|
|
|
if (!url || !url.length || url.indexOf(" ", 0) != -1)
|
|
|
|
return;
|
|
|
|
|
2007-04-01 03:06:45 +04:00
|
|
|
var bgLoad = this.mPrefs.getBoolPref("browser.tabs.loadInBackground");
|
2007-04-01 03:06:26 +04:00
|
|
|
|
|
|
|
if (aEvent.target.localName == "tabs") {
|
|
|
|
// We're adding a new tab.
|
|
|
|
var tab = this.addTab(getShortcutOrURI(url));
|
|
|
|
if (!bgLoad)
|
|
|
|
this.selectedTab = tab;
|
|
|
|
}
|
|
|
|
else if (aEvent.target.localName == "tab") {
|
|
|
|
// Load in an existing tab.
|
|
|
|
this.getBrowserForTab(aEvent.target).loadURI(getShortcutOrURI(url));
|
|
|
|
if (this.mCurrentTab != aEvent.target && !bgLoad)
|
|
|
|
this.selectedTab = aEvent.target;
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="getSupportedFlavours">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var flavourSet = new FlavourSet();
|
|
|
|
flavourSet.appendFlavour("text/x-moz-url");
|
|
|
|
flavourSet.appendFlavour("text/unicode");
|
|
|
|
flavourSet.appendFlavour("application/x-moz-file", "nsIFile");
|
|
|
|
return flavourSet;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="retrieveURLFromData">
|
|
|
|
<parameter name="aData"/>
|
|
|
|
<parameter name="aFlavour"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
switch (aFlavour) {
|
|
|
|
case "text/unicode":
|
|
|
|
// this might not be a url, but we'll return it anyway
|
|
|
|
return aData;
|
|
|
|
case "text/x-moz-url":
|
|
|
|
var data = aData.toString();
|
|
|
|
var separator = data.indexOf("\n");
|
|
|
|
if (separator != -1)
|
|
|
|
data = data.substr(0, separator);
|
|
|
|
return data;
|
|
|
|
case "application/x-moz-file":
|
2007-04-01 03:06:40 +04:00
|
|
|
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIIOService);
|
|
|
|
return ioService.getURLSpecFromFile(aData);
|
2007-04-01 03:06:26 +04:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2007-04-01 03:03:27 +04:00
|
|
|
<!-- BEGIN FORWARDED BROWSER PROPERTIES. IF YOU ADD A PROPERTY TO THE BROWSER ELEMENT
|
|
|
|
MAKE SURE TO ADD IT HERE AS WELL. -->
|
|
|
|
<property name="canGoBack"
|
|
|
|
onget="return this.mCurrentBrowser.canGoBack;"
|
|
|
|
readonly="true"/>
|
|
|
|
|
|
|
|
<property name="canGoForward"
|
|
|
|
onget="return this.mCurrentBrowser.canGoForward;"
|
|
|
|
readonly="true"/>
|
|
|
|
|
|
|
|
<method name="goBack">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
return this.mCurrentBrowser.goBack();
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="goForward">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
return this.mCurrentBrowser.goForward();
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="reload">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
return this.mCurrentBrowser.reload();
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="reloadWithFlags">
|
|
|
|
<parameter name="aFlags"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
return this.mCurrentBrowser.reloadWithFlags(aFlags);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="stop">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
return this.mCurrentBrowser.stop();
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<!-- throws exception for unknown schemes -->
|
|
|
|
<method name="loadURI">
|
|
|
|
<parameter name="aURI"/>
|
2007-04-01 03:06:43 +04:00
|
|
|
<parameter name="aReferrerURI"/>
|
2007-04-01 03:03:27 +04:00
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2007-04-01 03:06:43 +04:00
|
|
|
return this.mCurrentBrowser.loadURI(aURI, aReferrerURI);
|
2007-04-01 03:03:27 +04:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<!-- throws exception for unknown schemes -->
|
|
|
|
<method name="loadURIWithFlags">
|
|
|
|
<parameter name="aURI"/>
|
|
|
|
<parameter name="aFlags"/>
|
2007-04-01 03:06:43 +04:00
|
|
|
<parameter name="aReferrerURI"/>
|
2007-04-01 03:03:27 +04:00
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2007-04-01 03:06:43 +04:00
|
|
|
return this.mCurrentBrowser.loadURIWithFlags(aURI, aFlags, aReferrerURI);
|
2007-04-01 03:03:27 +04:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="goHome">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
return this.mCurrentBrowser.goHome();
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<property name="homePage">
|
|
|
|
<getter>
|
|
|
|
<![CDATA[
|
|
|
|
return this.mCurrentBrowser.homePage;
|
|
|
|
]]>
|
|
|
|
</getter>
|
|
|
|
<setter>
|
|
|
|
<![CDATA[
|
|
|
|
this.mCurrentBrowser.homePage = val;
|
|
|
|
return val;
|
|
|
|
]]>
|
|
|
|
</setter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<method name="gotoIndex">
|
|
|
|
<parameter name="aIndex"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
return this.mCurrentBrowser.gotoIndex(aIndex);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<property name="currentURI"
|
|
|
|
onget="return this.mCurrentBrowser.currentURI;"
|
|
|
|
readonly="true"/>
|
|
|
|
|
|
|
|
<property name="docShell"
|
|
|
|
onget="return this.mCurrentBrowser.docShell"
|
|
|
|
readonly="true"/>
|
|
|
|
|
|
|
|
<property name="webNavigation"
|
|
|
|
onget="return this.mCurrentBrowser.webNavigation"
|
|
|
|
readonly="true"/>
|
|
|
|
|
|
|
|
<property name="webBrowserFind"
|
|
|
|
readonly="true"
|
|
|
|
onget="return this.mCurrentBrowser.webBrowserFind"/>
|
|
|
|
|
|
|
|
<property name="webProgress"
|
|
|
|
readonly="true"
|
|
|
|
onget="return this.mCurrentBrowser.webProgress"/>
|
|
|
|
|
|
|
|
<property name="contentWindow"
|
|
|
|
readonly="true"
|
|
|
|
onget="return this.mCurrentBrowser.contentWindow"/>
|
|
|
|
|
|
|
|
<property name="sessionHistory"
|
|
|
|
onget="return this.mCurrentBrowser.sessionHistory;"
|
|
|
|
readonly="true"/>
|
|
|
|
|
|
|
|
<property name="markupDocumentViewer"
|
|
|
|
onget="return this.mCurrentBrowser.markupDocumentViewer;"
|
|
|
|
readonly="true"/>
|
|
|
|
|
|
|
|
<property name="contentViewerEdit"
|
|
|
|
onget="return this.mCurrentBrowser.contentViewerEdit;"
|
|
|
|
readonly="true"/>
|
|
|
|
|
|
|
|
<property name="contentViewerFile"
|
|
|
|
onget="return this.mCurrentBrowser.contentViewerFile;"
|
|
|
|
readonly="true"/>
|
|
|
|
|
|
|
|
<property name="documentCharsetInfo"
|
|
|
|
onget="return this.mCurrentBrowser.documentCharsetInfo;"
|
|
|
|
readonly="true"/>
|
|
|
|
|
|
|
|
<property name="contentDocument"
|
|
|
|
onget="return this.mCurrentBrowser.contentDocument;"
|
|
|
|
readonly="true"/>
|
|
|
|
|
|
|
|
<constructor>
|
2007-04-01 03:06:24 +04:00
|
|
|
<![CDATA[
|
2007-04-01 03:03:27 +04:00
|
|
|
this.mCurrentBrowser = this.mPanelContainer.firstChild;
|
|
|
|
this.mCurrentTab = this.mTabContainer.firstChild;
|
2007-04-01 03:06:21 +04:00
|
|
|
this.mTabBox.setAttribute("handleCtrlTab", "false");
|
2007-04-01 03:06:24 +04:00
|
|
|
]]>
|
2007-04-01 03:03:27 +04:00
|
|
|
</constructor>
|
|
|
|
|
|
|
|
<destructor>
|
|
|
|
<![CDATA[
|
|
|
|
if (this.mTabListeners) {
|
|
|
|
for (var i = 0; i < this.mTabListeners.length; i++) {
|
|
|
|
this.mPanelContainer.childNodes[i].webProgress.removeProgressListener(this.mTabListeners[i]);
|
|
|
|
this.mTabListeners[i] = null;
|
|
|
|
this.mPanelContainer.childNodes[i].removeEventListener("DOMTitleChanged", this.onTitleChanged, false);
|
|
|
|
}
|
|
|
|
}
|
2007-04-01 03:06:32 +04:00
|
|
|
this.mPanelContainer.removeEventListener("DOMLinkAdded", this.onLinkAdded, false);
|
2007-04-01 03:03:27 +04:00
|
|
|
]]>
|
|
|
|
</destructor>
|
|
|
|
</implementation>
|
2007-04-01 03:06:16 +04:00
|
|
|
|
|
|
|
<handlers>
|
|
|
|
<handler event="keypress" modifiers="control" keycode="vk_f4" action="this.removeCurrentTab();"/>
|
|
|
|
</handlers>
|
2007-04-01 03:03:27 +04:00
|
|
|
</binding>
|
|
|
|
|
|
|
|
</bindings>
|