home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GameStar 2005 October
/
Gamestar_77_2005-10_dvd.iso
/
Programy
/
nsb-install-8-0.exe
/
chrome
/
toolkit.jar
/
content
/
global
/
bindings
/
tabbrowser.xml
< prev
next >
Wrap
Extensible Markup Language
|
2005-07-29
|
126KB
|
3,244 lines
<?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 David Hyatt
- Portions created by David Hyatt are Copyright (C) 2001
- David Hyatt. 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.
-->
<!DOCTYPE bindings [
<!ENTITY % tabBrowserDTD SYSTEM "chrome://global/locale/tabbrowser.dtd" >
%tabBrowserDTD;
]>
<bindings id="tabBrowserBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="tabbrowser">
<resources>
<stylesheet src="chrome://global/skin/browser.css"/>
</resources>
<content>
<xul:stringbundle src="chrome://global/locale/tabbrowser.properties"/>
<xul:tabbox flex="1" eventnode="document" xbl:inherits="handleCtrlPageUpDown"
onselect="if (!('updateCurrentBrowser' in this.parentNode) || event.target.localName != 'tabpanels') return; this.parentNode.updateCurrentBrowser();">
<xul:hbox class="tabbrowser-strip chromeclass-toolbar" collapsed="true" tooltip="_child" context="_child">
<xul:tooltip onpopupshowing="event.preventBubble();"/>
<xul:menupopup anonid="tabContextMenu"
onpopupshowing="var tabbrowser = this.parentNode.parentNode.parentNode;
tabbrowser.updateTabContextMenu();">
<xul:menuitem anonid="sitecontrolmenuContainer" label="Show Site Controls"
oncommand="var x=this.parentNode.boxObject.screenX;var y=this.parentNode.boxObject.screenY;dump('x='+x+', y='+y+'\n');setTimeout('showSiteControlsPopup('+x+','+y+');',100);"/>
<xul:menuseparator anonid="activemenuSeparator"/>
<xul:menuitem label="&closeTab.label;" accesskey="&closeTab.accesskey;"
tbattr="tabbrowser-multiple"
oncommand="var tabbrowser = this.parentNode.parentNode.parentNode.parentNode;
tabbrowser.removeTab(tabbrowser.mContextTab);"/>
<xul:menu anonid="activemenuContainer" label="&tab-closebutton.closeother.label;">
<xul:menupopup anonid="activemenu"
onpopupshowing="tabbrowser = this.parentNode;
while (tabbrowser.localName != 'tabbrowser')
tabbrowser = tabbrowser.parentNode;
tabbrowser.updateTabPopupMenu(this, tabbrowser.mContextTab);">
<xul:menuitem label="&tab-closebutton.closeallother.label;"
oncommand="BrowserDelayRemoveAllTabsBut();"/>
<xul:menuitem label="&tab-closebutton.closeallfromsite.label;"
oncommand="DelayCloseAllTabsFromSameSite();"/>
<xul:menuitem label="&tab-closebutton.closeallnotfromsite.label;"
oncommand="DelayCloseAllTabsExceptFromSameSite();"/>
</xul:menupopup>
</xul:menu>
<xul:menuseparator/>
<xul:menuitem label="&newTab.label;" accesskey="&newTab.accesskey;"
xbl:inherits="oncommand=onnewpreftab"/>
<xul:menuitem label="&bookmarkThisPage.label;" accesskey="&bookmarkThisPage.accesskey;"
xbl:inherits="oncommand=onbookmarkpage"/>
<xul:menuitem label="&bookmarkThisGroupOfTabs.label;" accesskey="&bookmarkThisGroupOfTabs.accesskey;"
anonid="bookmarkGroupMenuItem"
tbattr="tabbrowser-multiple"
xbl:inherits="oncommand=onbookmarktabs"/>
<xul:menuitem label="&appendTabToHomePage.label;" accesskey="&appendTabToHomePage.accesskey;"
oncommand="var tabbrowser = this.parentNode.parentNode.parentNode.parentNode;
tabbrowser.appendTabToHomePage(tabbrowser.mContextTab);"/>
<xul:menuseparator/>
<xul:menuitem label="&aboutTabbedBrowsing.label;" accesskey="&aboutTabbedBrowsing.accesskey;"
oncommand="AboutTabBrowsing();"/>
<!-- /MERC -->
</xul:menupopup>
<xul:tabs id="browsertabs" class="tabbrowser-tabs" closebutton="true" flex="1"
browsertabs="true"
setfocus="false"
onclick="this.parentNode.parentNode.parentNode.onTabClick(event);"
onmousedown="this.parentNode.parentNode.parentNode.updateContextTab(event);"
ondragover="nsDragAndDrop.dragOver(event, this.parentNode.parentNode.parentNode);
event.stopPropagation();"
ondragdrop="nsDragAndDrop.drop(event, this.parentNode.parentNode.parentNode);
event.stopPropagation();"
xbl:inherits="onnewtab,tabs-newdropdown,onhometab,onnewcurrenttab,onnetscapetab,onnewpreftab,onbookmarkpage,onbookmarktabs"
ondblclick="if (event.originalTarget.localName != 'tab') {
if (event.button == 0) {
if (this.parentNode.parentNode.parentNode
.mPrefs.getBoolPref('browser.tabs.doubleClickTabBarToOpen'))
{
this.parentNode.parentNode.parentNode.selectedTab =
this.parentNode.parentNode.parentNode.addPrefTab();
}
}
}"
onclosetab="var node = this.parentNode;
while (node.localName != 'tabbrowser')
node = node.parentNode;
node.removeCurrentTab();">
<xul:tab validate="never"
onerror="this.parentNode.parentNode.parentNode.parentNode.addToMissedIconCache(this.getAttribute('image'));
this.removeAttribute('image');"
maxwidth="250" width="0" minwidth="50" flex="100"
xbl:inherits="onnewpreftab"
class="tabbrowser-tab" label="&untitledTab;" crop="end"/>
</xul:tabs>
</xul:hbox>
<xul:tabpanels flex="1" class="plain">
<xul:vbox flex="1">
<xul:browsermessage hidden="true" type="top"/>
<xul:browser flex="1" type="content-primary" message="true" disablehistory="true" xbl:inherits="tooltip=contenttooltip,contextmenu=contentcontextmenu,autocompletepopup"/>
<xul:browsermessage hidden="true" type="bottom"/>
</xul:vbox>
</xul:tabpanels>
</xul:tabbox>
<children/>
</content>
<implementation>
<field name="mPrefs" readonly="true">
Components.classes['@mozilla.org/preferences-service;1']
.getService(Components.interfaces.nsIPrefService)
.getBranch(null);
</field>
<field name="mTabBox">
document.getAnonymousNodes(this)[1]
</field>
<field name="mStrip">
this.mTabBox.firstChild
</field>
<field name="mTabContainer">
this.mStrip.childNodes[2]
</field>
<field name="mPanelContainer">
this.mTabBox.childNodes[1]
</field>
<field name="mStringBundle">
document.getAnonymousNodes(this)[0]
</field>
<field name="mCurrentTab">
null
</field>
<field name="mCurrentBrowser">
null
</field>
<field name="mProgressListeners">
null
</field>
<field name="mTabListeners">
new Array()
</field>
<field name="mTabFilters">
new Array()
</field>
<field name="mTabbedMode">
false
</field>
<field name="mIsBusy">
false
</field>
<field name="mMissedIconCache">
null
</field>
<field name="mContextTab">
null
</field>
<field name="mModalDialogShowing">
false
</field>
<method name="getBrowserAtIndex">
<parameter name="aIndex"/>
<body>
<![CDATA[
return this.mPanelContainer.childNodes[aIndex].firstChild.nextSibling;
]]>
</body>
</method>
<method name="getBrowserIndexForDocument">
<parameter name="aDocument"/>
<body>
<![CDATA[
for (var i = 0; i < this.mPanelContainer.childNodes.length; i++) {
if (this.getBrowserAtIndex(i).contentDocument == aDocument) {
return i;
}
}
return -1;
]]>
</body>
</method>
<method name="getMessageForBrowser">
<parameter name="aBrowser"/>
<parameter name="aTopBottom"/>
<body>
<![CDATA[
return aBrowser[aTopBottom == "top" ? "previousSibling" : "nextSibling"];
]]>
</body>
</method>
<method name="showMessage">
<parameter name="aBrowser"/>
<parameter name="aIconURL"/>
<parameter name="aMessage"/>
<parameter name="aButtonLabel"/>
<parameter name="aDocShell"/>
<parameter name="aSource"/>
<parameter name="aPopup"/>
<parameter name="aTopBottom"/>
<parameter name="aShowCloseButton"/>
<parameter name="aDeckPick"/>
<body>
<![CDATA[
if (aDeckPick == null) aDeckPick = 0;
var message = this.getMessageForBrowser(aBrowser, aTopBottom);
if (aDeckPick > -1 && aDeckPick <= 6) {
var theDeck = document.getAnonymousElementByAttribute(message, 'anonid', 'browsermessageDeck');
theDeck.selectedIndex = aDeckPick;
if (aDeckPick == 1) {
var pcCheckbox = document.getAnonymousElementByAttribute(message, 'anonid', 'messagePasscardCheckBox');
var menu = document.getAnonymousElementByAttribute(message, 'anonid', 'messagePasscardList');
menu.removeAllItems();
// keep track of number of passcards found for the specific realm
var passcardCount = 0;
var passcardIndex = -1;
var foundSitePasscards = false;
var addDefaultPasscard = false;
var defaultName = "";
var defaultUniqueID = -1;
// MERC - JCH: Make sure checkbox is set correctly.
// msgBarVal = 0 show notification bar.
// msgBarVal = 3 don't show notification bar.
var msgBarVal = null;
try {
var passwordManager =
Components.classes["@mozilla.org/passwordmanager;1"]
.getService(Components.interfaces.nsIPasswordManager);
var enumerator = passwordManager.enumerator;
while (enumerator.hasMoreElements()) {
var nextPasscard = enumerator.getNext();
nextPasscard = nextPasscard.QueryInterface(Components.interfaces.nsIPassword);
// get all info for the passcard
if (this.currentURI.asciiHost.indexOf(nextPasscard.host) > -1) {
var uniqueID = nextPasscard.uniqueID;
var passcard = nextPasscard.passcard;
var lastUsed = nextPasscard.lastUsed;
//dump("***Passcard -- passcard: " + passcard +
// " uniqueID: " + uniqueID + " lastUsed: " + lastUsed + "\n");
// find the default passcard for realm
if (eval(lastUsed)) {
passcardIndex = passcardCount;
}
msgBarVal = nextPasscard.autologin;
menu.appendItem(passcard,uniqueID);
passcardCount++;
foundSitePasscards = true;
}
else if ("DefaultPasscard" == nextPasscard.host) {
//dump("***Passcard -- passcard: " + nextPasscard.host + "\n");
defaultName = nextPasscard.passcard;
defaultUniqueID = nextPasscard.uniqueID;
// if it is protected, we will assume that the user has a valid Default Passcard
if (nextPasscard.protect == 0 &&
(nextPasscard.user.length < 1 || nextPasscard.password.length < 1))
{
addDefaultPasscard = false;
}
else {
addDefaultPasscard = true;
}
msgBarVal = nextPasscard.autologin;
}
} // while
} catch(e) {
dump ("PASSCARD Notify exception : " + e + "\n");
}
if (addDefaultPasscard && !foundSitePasscards &&
defaultName.length > 0 && defaultUniqueID != -1)
{
//dump("***Default Passcard -- passcard: " + defaultName +
// " uniqueID: " + defaultUniqueID + "\n");
menu.appendItem(defaultName, defaultUniqueID);
passcardIndex = 0;
}
menu.selectedIndex = passcardIndex;
// Set the "Don't Show Again" checkbox
if (msgBarVal == 0) {
pcCheckbox.checked = false;
} else {
pcCheckbox.checked = true;
}
if (passcardCount < 1 && !addDefaultPasscard)
return;
} else if (aDeckPick == 2) {
// See if the datacard message bar should be suppressed
if (gPrefService.getPrefType('datacard.messagebar.enable') &&
!gPrefService.getBoolPref('datacard.messagebar.enable'))
{
return;
}
document.getAnonymousElementByAttribute(message, 'anonid', 'datacardDoNotShow').checked = false;
// HACK: init the Datacard menulist
var menulist = document.getAnonymousElementByAttribute(message, 'anonid', 'datacardList');
menulist.removeAllItems();
var datacards = datacardUtils.GetDatacardList();
var defaultDatacard = datacardUtils.GetDefaultDatacard();
// Bail out if there are not datacards
if (!datacards.length) return;
var cardForSite = datacardUtils.FindDatacardForURI(this.currentURI);
for (var i = 0; i < datacards.length; i++) {
var item = menulist.appendItem(datacards[i], datacards[i]);
if (datacards[i] == defaultDatacard)
item.setAttribute('defaultDatacard','true');
if (datacards[i] == cardForSite)
menulist.selectedIndex = i;
}
// final sanity
if (menulist.menupopup.childNodes.length < 1)
return;
} else if (aDeckPick == 3) {
message.phishText = aMessage;
// Phishing site warning
dump('>> Showing Phishing site warning messagebar.\n')
} else if (aDeckPick == 4) {
message.spywareText = aMessage;
// Spyware site warning
dump('>> Showing Spyware site warning messagebar.\n')
} else if (aDeckPick == 5) {
// Webmail message
message.webmailImage = aIconURL;
message.webmailText = aMessage;
} else if (aDeckPick == 6) {
// See if the popups message bar should be suppressed
if (gPrefService.getPrefType('popups.messagebar.enable') &&
!gPrefService.getBoolPref('popups.messagebar.enable'))
{
return;
}
// Popup blocker message
message.popupblockerText = aMessage;
}
}
// dump('tabbrowser.xml: ShowMessage, about to show message : ' + aMessage + '\n');
message.image = aIconURL;
message.text = aMessage;
message.buttonText = aButtonLabel;
message.hidden = false;
if (aSource) {
message.source = aSource;
message.popup = null;
}
else if (aPopup) {
message.popup = aPopup;
message.source = null;
}
message.docShell = aDocShell;
message.closeButton = aShowCloseButton;
aBrowser.isShowingMessage = true;
]]>
</body>
</method>
<method name="hideMessage">
<parameter name="aBrowser"/>
<parameter name="aTopBottom"/>
<body>
<![CDATA[
if (aTopBottom != "both")
this.getMessageForBrowser(aBrowser, aTopBottom).hidden = true;
else {
this.getMessageForBrowser(aBrowser, "top").hidden = true;
this.getMessageForBrowser(aBrowser, "bottom").hidden = true;
}
]]>
</body>
</method>
<!-- A web progress listener object definition for a given tab. -->
<method name="mTabProgressListener">
<parameter name="aTab"/>
<parameter name="aBrowser"/>
<parameter name="aStartsBlank"/>
<body>
<![CDATA[
return ({
mTabBrowser: this,
mTab: aTab,
mBrowser: aBrowser,
mBlank: aStartsBlank,
mIcon: null,
mLastURI: null,
onProgressChange : function (aWebProgress, aRequest,
aCurSelfProgress, aMaxSelfProgress,
aCurTotalProgress, aMaxTotalProgress)
{
if (!this.mBlank && this.mTabBrowser.mCurrentTab == this.mTab) {
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;
var oldBlank = this.mBlank;
const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
const nsIChannel = Components.interfaces.nsIChannel;
if (aStateFlags & nsIWebProgressListener.STATE_START)
this.mBrowser.mFavIconURL = null;
if (aStateFlags & nsIWebProgressListener.STATE_START &&
aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
// It's okay to clear what the user typed when we start
// loading a document. If the user types, this flag gets
// set to false, if the document load ends without an
// onLocationChange, this flag also gets set to false
// (so we keep it while switching tabs after failed load
if (aWebProgress.DOMWindow == this.mBrowser.contentWindow)
this.mBrowser.userTypedClear = true;
if (!this.mBlank) {
this.mTab.setAttribute("busy", "true");
this.mTab.label = this.mTabBrowser.mStringBundle.getString("tabs.loading");
this.mTab.removeAttribute("image");
this.mIcon = null;
if (this.mTabBrowser.mCurrentTab == this.mTab)
this.mTabBrowser.mIsBusy = true;
}
}
else if (aStateFlags & nsIWebProgressListener.STATE_STOP &&
aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
// The document is done loading, it's okay to clear
// the value again.
if (aWebProgress.DOMWindow == this.mBrowser.contentWindow)
this.mBrowser.userTypedClear = false;
if (this.mBlank)
this.mBlank = false;
this.mTab.removeAttribute("busy");
var location = aRequest.QueryInterface(nsIChannel).URI;
// For keyword URIs clear the user typed value since they will be changed into real URIs
if (location.scheme == "keyword")
this.mBrowser.userTypedValue = null;
if (this.mTabBrowser.shouldLoadFavIcon(location)) {
if (this.mIcon)
this.mTab.setAttribute("image", this.mIcon);
else
this.mTabBrowser.loadFavIcon(location, "image", this.mTab);
this.mBrowser.mFavIconURL = this.mTab.getAttribute("image");
this.mIcon = this.mTab.getAttribute("image");
SetPageProxyState( "valid", location );
}
if (this.mTab.label == this.mTabBrowser.mStringBundle.getString("tabs.loading"))
this.mTabBrowser.setTabTitle(this.mTab);
if (this.mTabBrowser.mCurrentTab == this.mTab)
this.mTabBrowser.mIsBusy = false;
}
if (!oldBlank && this.mTabBrowser.mCurrentTab == this.mTab) {
for (var i = 0; i < this.mTabBrowser.mProgressListeners.length; i++) {
var p = this.mTabBrowser.mProgressListeners[i];
if (p)
p.onStateChange(aWebProgress, aRequest, aStateFlags, aStatus);
}
}
// MERC - JCH: Set the title and icon of the non-user-initiated tab
if (this.mTab.isNonUserInitPopupTab)
{
this.mTab.label = "POP-UPS";
this.mTab.setAttribute("image", "chrome://browser/skin/icons/popuponsm_n.png");
}
},
onLocationChange : function(aWebProgress, aRequest, aLocation) {
// The document loaded correctly, clear the value if we should
if (this.mBrowser.userTypedClear)
this.mBrowser.userTypedValue = null;
if (!this.mBlank && this.mTabBrowser.mCurrentTab == this.mTab) {
for (var i = 0; i < this.mTabBrowser.mProgressListeners.length; i++) {
var p = this.mTabBrowser.mProgressListeners[i];
if (p)
p.onLocationChange(aWebProgress, aRequest, aLocation);
}
}
// MERC (DP): update icon to match security level AND engine.
// function is defined in browser.js since we need to call it
// as well when the browser reloads on Trident side.
UpdateSiteControlIcon(this.mTab);
},
onStatusChange : function(aWebProgress, aRequest, aStatus, aMessage) {
if (this.mBlank)
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)
{
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.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>
<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>
<method name="shouldLoadFavIcon">
<parameter name="aURI"/>
<body>
<![CDATA[
return (aURI && this.mPrefs.getBoolPref("browser.chrome.site_icons") &&
this.mPrefs.getBoolPref("browser.chrome.favicons") &&
("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.isFavIconKnownMissing(iconURL)) {
aElt.setAttribute(aAttr, iconURL);
}
// MERC - JCH: Set icon of the non-user-initiated popup tab
if (aElt.isNonUserInitPopupTab) {
aElt.setAttribute("image", "chrome://browser/skin/icons/popuponsm_n.png");
}
]]>
</body>
</method>
<method name="addToMissedIconCache">
<parameter name="aURI"/>
<body>
<![CDATA[
var entry = this.openCacheEntry(aURI, Components.interfaces.nsICache.ACCESS_READ_WRITE);
if (!entry)
return;
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>
<method name="openCacheEntry">
<parameter name="key"/>
<parameter name="access"/>
<body>
<![CDATA[
try {
if (!this.mMissedIconCache) {
var cacheService = Components.classes['@mozilla.org/network/cache-service;1'].getService(Components.interfaces.nsICacheService);
this.mMissedIconCache = cacheService.createSession("MissedIconCache", Components.interfaces.nsICache.STORE_ANYWHERE, true);
if (!this.mMissedIconCache)
return null;
}
return this.mMissedIconCache.openCacheEntry(key, access, true);
}
catch (e) {
return null;
}
]]>
</body>
</method>
<method name="isFavIconKnownMissing">
<parameter name="key"/>
<body>
<![CDATA[
var e = this.openCacheEntry(key, Components.interfaces.nsICache.ACCESS_READ);
if (e) {
e.close();
return true;
}
return false;
]]>
</body>
</method>
<method name="updateTitlebar">
<body>
<![CDATA[
var newTitle = "";
var docTitle;
var docElement = this.ownerDocument.documentElement;
if (this.docShell.contentViewer)
docTitle = this.contentTitle;
if (!docTitle)
docTitle = docElement.getAttribute("titledefault");
var modifier = docElement.getAttribute("titlemodifier");
var sep = docElement.getAttribute("titlemenuseparator");
if (docTitle) {
newTitle += docElement.getAttribute("titlepreface");
newTitle += docTitle;
if (modifier)
newTitle += sep;
}
newTitle += modifier;
// if location bar is hidden and the URL type supports a host
// then add the scheme and host to the title to prevent spoofing
try {
if (docElement.getAttribute("chromehidden").indexOf("location") != -1) {
var host = this.mURIFixup.createExposableURI(
this.mCurrentBrowser.currentURI).prePath;
if (host)
newTitle = host + sep + newTitle;
}
} catch (e) {}
window.title = newTitle;
]]>
</body>
</method>
<method name="updateContextTab">
<parameter name="aEvent"/>
<body>
<![CDATA[
if (aEvent.originalTarget.localName == "tab")
this.mContextTab = aEvent.originalTarget;
else
this.mContextTab = this.mCurrentTab;
//this.mContextTab = document.popupNode;
]]>
</body>
</method>
<!-- MERC (DP): update the site controls tab menu when the icon is visible -->
<method name="updateSiteControlsSubmenu">
<body>
<![CDATA[
//dump('tabbrowser.xml: updateSiteControlsSubmenu()\n');
var currentEngine = this.mCurrentBrowser.webNavigation.browserEngine;
var url = this.getBrowserForTab(this.mCurrentTab).currentURI.spec;
var scMenu = document.getAnonymousElementByAttribute(this.mCurrentTab, 'anonid', 'menu');
var sc = sitecontrols.SCSVC;
if (!sc.isControllableURI(url)) {
// This is not a controllable URI, so we will disable most menu items
var menuitem;
for (var j = 0; j < scMenu.childNodes.length; j++) {
menuitem = scMenu.childNodes[j];
// disable all menu items
if (menuitem.localName == 'menuitem' || menuitem.localName == 'menu') {
menuitem.setAttribute('disabled', 'true');
}
}
// make sure 'openSiteControls' menu item is enabled
var openSiteControls =
document.getAnonymousElementByAttribute(this.mCurrentTab, 'anonid', 'openSiteControls');
openSiteControls.removeAttribute('disabled');
// Update 'displayEngine' menu item label
var displayEngineItem =
document.getAnonymousElementByAttribute(this.mCurrentTab, 'anonid', 'displayEngine');
// if about:blank page, let user toggle engine
if (url == 'about:blank') {
displayEngineItem.removeAttribute('disabled');
}
if (currentEngine == 'Trident') {
displayEngineItem.setAttribute('label', 'Display like Netscape');
} else {
displayEngineItem.setAttribute('label', 'Display like Internet Explorer');
}
} else {
// This *is* a controllable URI, so we enable most menu items
var menuitem;
for (var j = 0; j < scMenu.childNodes.length; j++) {
menuitem = scMenu.childNodes[j];
// enable all menu items
if (menuitem.localName == 'menuitem' || menuitem.localName == 'menu') {
menuitem.removeAttribute('disabled');
}
}
var site = sc.getResourceForURI(url);
var displayEngine = sc.readSiteControlResource(site, 'displayEngine');
var allowPopups = sc.readSiteControlResource(site, 'allowPopups');
var requestedPopupsInTab = sc.readSiteControlResource(site, 'requestedPopupsInTab');
var enableActiveX = sc.readSiteControlResource(site, 'enableActiveX');
var enableJava = sc.readSiteControlResource(site, 'enableJava');
var enableJavaScript = sc.readSiteControlResource(site, 'enableJavaScript');
var allowCookies = sc.readSiteControlResource(site, 'allowCookies');
var securityLevel = sc.readSiteControlResource(site, 'securityLevel');
// Update 'allowPopups' menu item
var allowPopupsItem =
document.getAnonymousElementByAttribute(this.mCurrentTab, 'anonid', 'allowPopups');
allowPopupsItem.setAttribute('checked',allowPopups);
// Update 'requestedPopupsInTab' menu item
var requestedPopupsInTabItem =
document.getAnonymousElementByAttribute(this.mCurrentTab, 'anonid', 'requestedPopupsInTab');
if(allowPopups == 'true') {
requestedPopupsInTabItem.setAttribute('checked',requestedPopupsInTab);
requestedPopupsInTabItem.removeAttribute('disabled');
} else {
requestedPopupsInTabItem.setAttribute('checked', 'false');
requestedPopupsInTabItem.setAttribute('disabled', 'true');
}
// Update 'allowCookies' menu item
var allowCookiesItem =
document.getAnonymousElementByAttribute(this.mCurrentTab, 'anonid', 'allowCookies');
allowCookiesItem.setAttribute('checked',allowCookies);
// Update 'allowJavascript' menu item
var enableJavaScriptItem =
document.getAnonymousElementByAttribute(this.mCurrentTab, 'anonid', 'enableJavaScript');
enableJavaScriptItem.setAttribute('checked', enableJavaScript);
// Update 'allowJava' menu item
var enableJavaItem =
document.getAnonymousElementByAttribute(this.mCurrentTab, 'anonid', 'enableJava');
enableJavaItem.setAttribute('checked', enableJava);
var enableActiveXItem =
document.getAnonymousElementByAttribute(this.mCurrentTab, 'anonid', 'enableActiveX');
var displayEngineItem =
document.getAnonymousElementByAttribute(this.mCurrentTab, 'anonid', 'displayEngine');
if (currentEngine == 'Trident') {
// Update 'allowActiveX' menu item
enableActiveXItem.removeAttribute('disabled');
enableActiveXItem.setAttribute('checked', enableActiveX);
// Update 'displayEngine' menu item label
displayEngineItem.setAttribute('label', 'Display like Netscape');
} else {
// Update 'allowActiveX' menu item
enableActiveXItem.setAttribute('checked', 'false');
enableActiveXItem.setAttribute('disabled', 'true');
// Update 'displayEngine' menu item label
displayEngineItem.setAttribute('label', 'Display like Internet Explorer');
}
// check mark the appropriate security level menu item
var lowSecurityMenuItem =
document.getAnonymousElementByAttribute(this.mCurrentTab, 'anonid', 'displaySecurityLow');
var mediumSecurityMenuItem =
document.getAnonymousElementByAttribute(this.mCurrentTab, 'anonid', 'displaySecurityMedium');
var highSecurityMenuItem =
document.getAnonymousElementByAttribute(this.mCurrentTab, 'anonid', 'displaySecurityHigh');
lowSecurityMenuItem.setAttribute('checked', 'false');
mediumSecurityMenuItem.setAttribute('checked', 'false');
highSecurityMenuItem.setAttribute('checked', 'false');
switch(securityLevel) {
case 'Low':
lowSecurityMenuItem.setAttribute('checked', 'true');
break;
case 'Medium':
mediumSecurityMenuItem.setAttribute('checked', 'true');
break;
case 'High':
highSecurityMenuItem.setAttribute('checked', 'true');
break;
default:
break;
}
}
]]>
</body>
</method>
<!-- MERC (DP): called to update site control menu when SC icon is hidden and the SC menu
is displayed in the tab context menu
-->
<method name="updateSiteControlsSubmenu2">
<parameter name="aPopupMenu"/>
<body>
<![CDATA[
//dump('tabbrowser.xml: updateSiteControlsSubmenu2()\n');
var contextBrowser = this.getBrowserForTab(this.mContextTab);
var currentEngine = contextBrowser.webNavigation.browserEngine;
var url = this.getBrowserForTab(this.mContextTab).currentURI.spec;
//var scMenu = document.getAnonymousElementByAttribute(this.mContextTab, 'anonid', 'sitecontrolTabMenu');
var scMenu = aPopupMenu;
var sc = sitecontrols.SCSVC;
if (!sc.isControllableURI(url)) {
// This is not a controllable URI, so we will disable most menu items
var menuitem;
for (var j = 0; j < scMenu.childNodes.length; j++) {
menuitem = scMenu.childNodes[j];
// disable all menu items
if (menuitem.localName == 'menuitem' || menuitem.localName == 'menu') {
menuitem.setAttribute('disabled', 'true');
}
}
// make sure 'openSiteControls' menu item is enabled
var openSiteControls = scMenu.getElementsByAttribute("anonid", "openSiteControls");
openSiteControls = openSiteControls[0];
openSiteControls.removeAttribute('disabled');
// Update 'displayEngine' menu item label
var displayEngineItem = scMenu.getElementsByAttribute("anonid", "displayEngine");
displayEngineItem = displayEngineItem[0];
// if about:blank page, let user toggle engine
if (url == 'about:blank') {
displayEngineItem.removeAttribute('disabled');
}
if (currentEngine == 'Trident') {
displayEngineItem.setAttribute('label', 'Display like Netscape');
} else {
displayEngineItem.setAttribute('label', 'Display like Internet Explorer');
}
} else {
// This *is* a controllable URI, so we enable most menu items
var menuitem;
for (var j = 0; j < scMenu.childNodes.length; j++) {
menuitem = scMenu.childNodes[j];
// enable all menu items
if (menuitem.localName == 'menuitem' || menuitem.localName == 'menu') {
menuitem.removeAttribute('disabled');
}
}
var site = sc.getResourceForURI(url);
var displayEngine = sc.readSiteControlResource(site, 'displayEngine');
var allowPopups = sc.readSiteControlResource(site, 'allowPopups');
var requestedPopupsInTab = sc.readSiteControlResource(site, 'requestedPopupsInTab');
var enableActiveX = sc.readSiteControlResource(site, 'enableActiveX');
var enableJava = sc.readSiteControlResource(site, 'enableJava');
var enableJavaScript = sc.readSiteControlResource(site, 'enableJavaScript');
var allowCookies = sc.readSiteControlResource(site, 'allowCookies');
var securityLevel = sc.readSiteControlResource(site, 'securityLevel');
// Update 'allowPopups' menu item
//var allowPopupsItem =
// document.getAnonymousElementByAttribute(this.mContextTab, 'anonid', 'allowPopups');
//allowPopupsItem.setAttribute('checked',allowPopups);
var allowPopupsItem = scMenu.getElementsByAttribute("anonid", "allowPopups");
allowPopupsItem = allowPopupsItem[0];
allowPopupsItem.setAttribute('checked',allowPopups);
// Update 'requestedPopupsInTab' menu item
//var requestedPopupsInTabItem =
// document.getAnonymousElementByAttribute(this.mContextTab, 'anonid', 'requestedPopupsInTab');
//requestedPopupsInTabItem.setAttribute('checked',requestedPopupsInTab);
var requestedPopupsInTabItem = scMenu.getElementsByAttribute("anonid", "requestedPopupsInTab");
requestedPopupsInTabItem = requestedPopupsInTabItem[0];
if(allowPopups == 'true') {
requestedPopupsInTabItem.setAttribute('checked',requestedPopupsInTab);
requestedPopupsInTabItem.removeAttribute('disabled');
} else {
requestedPopupsInTabItem.setAttribute('checked', 'false');
requestedPopupsInTabItem.setAttribute('disabled', 'true');
}
// Update 'allowCookies' menu item
var allowCookiesItem = scMenu.getElementsByAttribute("anonid", "allowCookies");
allowCookiesItem = allowCookiesItem[0];
allowCookiesItem.setAttribute('checked',allowCookies);
// Update 'allowJavascript' menu item
var enableJavaScriptItem = scMenu.getElementsByAttribute("anonid", "enableJavaScript");
enableJavaScriptItem = enableJavaScriptItem[0];
enableJavaScriptItem.setAttribute('checked', enableJavaScript);
// Update 'allowJava' menu item
var enableJavaItem = scMenu.getElementsByAttribute("anonid", "enableJava");
enableJavaItem = enableJavaItem[0];
enableJavaItem.setAttribute('checked', enableJava);
var enableActiveXItem = scMenu.getElementsByAttribute("anonid", "enableActiveX");
enableActiveXItem = enableActiveXItem[0];
var displayEngineItem =
scMenu.getElementsByAttribute("anonid", "displayEngine");
displayEngineItem = displayEngineItem[0];
if (currentEngine == 'Trident') {
// Update 'allowActiveX' menu item
enableActiveXItem.removeAttribute('disabled');
enableActiveXItem.setAttribute('checked', enableActiveX);
// Update 'displayEngine' menu item label
displayEngineItem.setAttribute('label', 'Display like Netscape');
} else {
// Update 'allowActiveX' menu item
enableActiveXItem.setAttribute('checked', 'false');
enableActiveXItem.setAttribute('disabled', 'true');
// Update 'displayEngine' menu item label
displayEngineItem.setAttribute('label', 'Display like Internet Explorer');
}
// check mark the appropriate security level menu item
var lowSecurityMenuItem = scMenu.getElementsByAttribute("anonid", "displaySecurityLow");
lowSecurityMenuItem = lowSecurityMenuItem[0];
var mediumSecurityMenuItem = scMenu.getElementsByAttribute("anonid", "displaySecurityMedium");
mediumSecurityMenuItem = mediumSecurityMenuItem[0];
var highSecurityMenuItem = scMenu.getElementsByAttribute("anonid", "displaySecurityHigh");
highSecurityMenuItem = highSecurityMenuItem[0];
lowSecurityMenuItem.setAttribute('checked', 'false');
mediumSecurityMenuItem.setAttribute('checked', 'false');
highSecurityMenuItem.setAttribute('checked', 'false');
switch(securityLevel) {
case 'Low':
lowSecurityMenuItem.setAttribute('checked', 'true');
break;
case 'Medium':
mediumSecurityMenuItem.setAttribute('checked', 'true');
break;
case 'High':
highSecurityMenuItem.setAttribute('checked', 'true');
break;
default:
break;
}
}
]]>
</body>
</method>
<!-- MERC (DP): update the context tab menu -->
<method name="updatePopupMenu">
<parameter name="aPopupMenu"/>
<parameter name="aTab"/>
<body>
<![CDATA[
if (aTab.localName != "tab") {
aTab = this.mCurrentTab;
}
var disabled = this.mPanelContainer.childNodes.length == 1;
var menuItems = aPopupMenu.getElementsByAttribute("tbattr", "tabbrowser-multiple");
for (var i = 0; i < menuItems.length; i++)
menuItems[i].setAttribute("disabled", disabled);
// if there is only 1 tab, disable activemenu in the context menu
var menuContainer = aPopupMenu.getElementsByAttribute("anonid", "activemenuContainer");
if(disabled)
menuContainer[0].setAttribute("disabled", "true");
else
menuContainer[0].removeAttribute("disabled");
// if we are hiding the site control button, show the site control menu as part of the tab context menu
// on the active tab only
menuContainer = aPopupMenu.getElementsByAttribute("anonid", "sitecontrolmenuContainer");
var menuSeparator = aPopupMenu.getElementsByAttribute("anonid", "activemenuSeparator");
if(this.mPrefs.getBoolPref("browser.tabs.showSiteControlButtonOnTab")) {
menuContainer[0].setAttribute("hidden", "true");
menuSeparator[0].setAttribute("hidden", "true");
} else {
if(this.mContextTab == this.mCurrentTab) {
menuContainer[0].removeAttribute("hidden");
menuSeparator[0].removeAttribute("hidden");
} else {
menuContainer[0].setAttribute("hidden", "true");
menuSeparator[0].setAttribute("hidden", "true");
}
}
]]>
</body>
</method>
<!-- MERC (DP): update the tab context menu -->
<method name="updateTabContextMenu">
<body>
<![CDATA[
var closeOtherMenuItem = document.getAnonymousElementByAttribute(this, 'anonid', 'activemenuContainer');
var bookmarkGroupMenuItem = document.getAnonymousElementByAttribute(this, 'anonid', 'bookmarkGroupMenuItem');
var numTabs = this.mTabContainer.childNodes.length;
if(numTabs < 2) {
closeOtherMenuItem.setAttribute('disabled', 'true');
bookmarkGroupMenuItem.setAttribute('disabled', 'true');
} else {
closeOtherMenuItem.removeAttribute('disabled');
bookmarkGroupMenuItem.removeAttribute('disabled');
}
// MERC - JCH: Addresses BLT# 156478. Make sure that the site controls dialog option is
// disabled in the right-click context menu when the tab is a blank tab.
var scDialogMenuItem = document.getAnonymousElementByAttribute(this, 'anonid', 'sitecontrolmenuContainer');
if (this.mCurrentTab.label == "(Untitled)") {
scDialogMenuItem.setAttribute('disabled', 'true');
} else {
scDialogMenuItem.setAttribute('disabled', 'false');
}
]]>
</body>
</method>
<!-- MERC (DP): update the right tab menu -->
<method name="updateTabPopupMenu">
<parameter name="aPopupMenu"/>
<parameter name="aTab"/>
<body>
<![CDATA[
if (aTab.localName != "tab") {
aTab = this.mCurrentTab;
}
/*
var disabled = this.mPanelContainer.childNodes.length == 1;
// get the elements to disable
// *** we have to pass in the parent of the menu popup object (toolbarbutton) - not sure why?!
leftItem = document.getAnonymousElementByAttribute(aPopupMenu.parentNode, "anonid", "closeAllTabsToLeftMenuItem");
rightItem = document.getAnonymousElementByAttribute(aPopupMenu.parentNode, "anonid", "closeAllTabsToRightMenuItem");
clearBlankItem = document.getAnonymousElementByAttribute(aPopupMenu.parentNode, "anonid", "closeAllBlankTabsMenuItem");
// disable menu items if clicked on first or last tab
if(disabled) {
leftItem.setAttribute("disabled", true);
rightItem.setAttribute("disabled", true);
} else {
if(this.mTabContainer.childNodes[0] == aTab) {
leftItem.setAttribute("disabled", true);
} else {
leftItem.removeAttribute("disabled");
}
if(this.mTabContainer.childNodes[this.mPanelContainer.childNodes.length - 1] == aTab) {
rightItem.setAttribute("disabled", true);
} else {
rightItem.removeAttribute("disabled");
}
}
// ***
// disable clear all blank tabs menu item if there are no blanks tabs
// ***
var browsers = this.mPanelContainer.childNodes
var found = 0;
for(var j = 0; j < browsers.length; j++) {
if(this.getBrowserAtIndex(j).currentURI.spec == "about:blank") {
found = 1;
break;
}
}
if(found) {
clearBlankItem.removeAttribute("disabled");
} else {
clearBlankItem.setAttribute("disabled", true);
}
*/
]]>
</body>
</method>
<!-- MERC (DP): update the right tab list menu -->
<method name="updateTabListMenu">
<parameter name="aPopupMenu"/>
<body>
<![CDATA[
// clear old menuitems
var children = aPopupMenu.childNodes;
while(children.length) {
aPopupMenu.removeChild(children[0]);
children = aPopupMenu.childNodes;
}
// go thru list of tabs and add a menu item for each one
var menuitem;
var string;
var tab;
var favicon;
for(var j = 0; j < this.mTabContainer.childNodes.length; j++) {
tab = this.mTabContainer.childNodes[j];
if(this.mTabListeners[j].mIcon) {
favicon = this.mTabListeners[j].mIcon;
} else {
favicon = "chrome://global/skin/icons/default-favicon.png";
}
menuitem = document.createElement("menuitem");
menuitem.setAttribute('label', tab.label);
menuitem.setAttribute('type', 'checkbox');
menuitem.setAttribute('favsrc', favicon);
string = "var tabs = this; while(tabs.localName != 'tabs') tabs = tabs.parentNode; tabs.selectTabByIndex(" + j + ");"
menuitem.setAttribute('oncommand', string);
if(tab == this.mCurrentTab)
menuitem.setAttribute('checked', 'true');
aPopupMenu.appendChild(menuitem);
}
]]>
</body>
</method>
<method name="updateCurrentBrowser">
<parameter name="forceUpdate"/>
<body>
<![CDATA[
var newBrowser = this.getBrowserAtIndex(this.mPanelContainer.selectedIndex);
dump ("UpdateCurrentBrowser to index " + this.mPanelContainer.selectedIndex + "\n");
if (this.mCurrentBrowser == newBrowser && !forceUpdate) {
// MERC (DP): update tab chrome
this.updateChromeWhenLastTab();
// MERC
UpdateStatusbarPartnerIcons();
return;
}
if (this.mCurrentBrowser) {
this.mCurrentBrowser.focusedWindow = document.commandDispatcher.focusedWindow;
this.mCurrentBrowser.focusedElement = document.commandDispatcher.focusedElement;
this.mCurrentBrowser.setAttribute("type", "content");
}
newBrowser.setAttribute("type", "content-primary");
this.mCurrentBrowser = newBrowser;
this.mCurrentTab = this.selectedTab;
// Update the URL bar.
var loc = this.mCurrentBrowser.currentURI;
if (!loc)
loc = ({ spec: "" });
var webProgress = this.mCurrentBrowser.webProgress;
var securityUI = this.mCurrentBrowser.securityUI;
// Remember the current clear state, then set it to false
// so we don't clear the userTypedValue when just switching
// tabs. Set it back to its old state after we're done.
var userTypedClear = this.mCurrentBrowser.userTypedClear;
this.mCurrentBrowser.userTypedClear = false;
var i, p;
for (i = 0; i < this.mProgressListeners.length; i++) {
p = this.mProgressListeners[i];
if (p) {
p.onLocationChange(webProgress, null, loc);
if (securityUI)
p.onSecurityChange(webProgress, null, securityUI.state);
var listener = this.mTabListeners[this.mPanelContainer.selectedIndex];
if (listener.mIcon) {
if (this.isFavIconKnownMissing(listener.mIcon))
listener.mIcon = null;
else
p.onLinkIconAvailable(newBrowser, listener.mIcon);
}
}
}
this.mCurrentBrowser.userTypedClear = userTypedClear;
this._fastFind.setDocShell(this.mCurrentBrowser.docShell);
// 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;
if (this.mCurrentTab.hasAttribute("busy") && !this.mIsBusy) {
this.mIsBusy = true;
webProgress = this.mCurrentBrowser.webProgress;
for (i = 0; i < this.mProgressListeners.length; i++) {
p = this.mProgressListeners[i];
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.
if (!this.mCurrentTab.hasAttribute("busy") && this.mIsBusy) {
this.mIsBusy = false;
webProgress = this.mCurrentBrowser.webProgress;
for (i = 0; i < this.mProgressListeners.length; i++) {
p = this.mProgressListeners[i];
if (p)
p.onStateChange(webProgress, null, nsIWebProgressListener.STATE_STOP | nsIWebProgressListener.STATE_IS_NETWORK, 0);
}
}
if (!this.mCurrentTab.hasAttribute("busy")) {
window.XULBrowserWindow.onStateChange(webProgress, null, nsIWebProgressListener.STATE_STOP | nsIWebProgressListener.STATE_IS_NETWORK, 0);
} else {
window.XULBrowserWindow.onStateChange(webProgress, null, nsIWebProgressListener.STATE_START | nsIWebProgressListener.STATE_IS_NETWORK, 0);
}
function setFocus(element) {
// dump ("In tabbrowser.xml, using setFocus with " + element + ", id of " + element.id + "\t\t\t");
// showStack();
Components.lookupMethod(element, "focus").call(element);
}
// Focus the previously focused element or window
document.commandDispatcher.suppressFocusScroll = true;
if (newBrowser.focusedElement) {
try {
setFocus(newBrowser.focusedElement);
} catch (e) {
setFocus(newBrowser.focusedWindow);
}
}
else if (newBrowser.focusedWindow)
setFocus(newBrowser.focusedWindow);
else // new tab, focus our new content area
{
// setTimeout(setFocus, 0, window.content);
dump ("JMC: Just set focus to window.content, within tabbrowser.xml\n");
}
document.commandDispatcher.suppressFocusScroll = false;
// MERC (DP): switch to the right toggle engine icon
var currentEngine = this.mCurrentBrowser.webNavigation.browserEngine;
var button = document.getElementById('enginetoggle-button');
if(button) {
if (currentEngine == 'Trident') {
button.style.listStyleImage = "url(chrome://browser/skin/Engine-Trident.png)";
} else {
button.style.listStyleImage = "url(chrome://browser/skin/Engine-Gecko.png)";
}
}
// update tab chrome
this.updateChromeWhenLastTab();
// MERC
UpdateStatusbarPartnerIcons();
// MERC (rpaul) updating the statusbar engine icon for the current tab
UpdateStatusBarEngineIcon();
]]>
</body>
</method>
<method name="onTabClick">
<parameter name="event"/>
<body>
<![CDATA[
if (event.button > 1) return; // Ignore right-clicks
// MERC (rpaul) click handler for new tab drop down popup menu
var tabsNewDropDown = document.getElementById('tabs-newdropdown');
if ((tabsNewDropDown.boxObject.screenX <= event.screenX)
&& (event.screenX - tabsNewDropDown.boxObject.screenX <= tabsNewDropDown.boxObject.width)
&& (tabsNewDropDown.boxObject.screenY <= event.screenY)
&& (event.screenY - tabsNewDropDown.boxObject.screenY <= tabsNewDropDown.boxObject.height))
{
//anchor the new tab popup menu to the new tab button
var newTabButton = document.getElementById('tabNewButton');
var newTabButtonPopup = document.getElementById('tabsNewButtonPopup');
newTabButtonPopup.showPopup(newTabButton, -1, -1, "popup", "bottomleft", "topleft");
}
if (event.button != 1 || event.target.localName != 'tab' ||
this.mPrefs.getBoolPref("middlemouse.contentLoadURL"))
return;
this.removeTab(event.target);
event.stopPropagation();
]]>
</body>
</method>
<method name="onLinkAdded">
<parameter name="event"/>
<body>
<![CDATA[
if (!event.isTrusted)
return;
// mechanism for reading properties of the underlying XPCOM object
// (ignoring potential getters/setters added by malicious content)
var safeGetProperty = function(obj, propname) {
return Components.lookupMethod(obj, propname).call(obj);
};
var tabBrowser = this.parentNode.parentNode;
if (!tabBrowser.mPrefs.getBoolPref("browser.chrome.site_icons"))
return;
if (!event.target.rel.match((/(?:^|\s)icon(?:\s|$)/i)))
return;
// We have an icon.
var href = event.target.href;
if (!href)
return;
const nsIContentPolicy = Components.interfaces.nsIContentPolicy;
try {
var contentPolicy =
Components.classes['@mozilla.org/layout/content-policy;1']
.getService(nsIContentPolicy);
} catch(e) {
return; // Refuse to load if we can't do a security check.
}
// Verify that the load of this icon is legal.
// We check first with the security manager
const secMan =
Components.classes["@mozilla.org/scriptsecuritymanager;1"]
.getService(Components.interfaces.nsIScriptSecurityManager);
// Get the IOService so we can make URIs
const ioService =
Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
const targetDoc = safeGetProperty(event.target, "ownerDocument");
// Make a URI out of our href.
var docCharset = safeGetProperty(targetDoc, "characterSet");
var uri = ioService.newURI(href, docCharset, null);
var origURIStr = safeGetProperty(targetDoc, "documentURI");
var origURI = ioService.newURI(origURIStr, docCharset, null);
const nsIScriptSecMan =
Components.interfaces.nsIScriptSecurityManager;
try {
secMan.checkLoadURI(origURI, uri,
nsIScriptSecMan.DISALLOW_SCRIPT);
} catch(e) {
return;
}
// Security says okay, now ask content policy
if (contentPolicy.shouldLoad(nsIContentPolicy.TYPE_IMAGE,
uri, origURI, event.target,
safeGetProperty(event.target, "type"),
null) != nsIContentPolicy.ACCEPT)
return;
var browserIndex = tabBrowser.getBrowserIndexForDocument(targetDoc);
// no browser? no favicon.
if (browserIndex == -1)
return;
var listener = tabBrowser.mTabListeners[browserIndex];
// there's no tab listener for non-tabbed mode browser 0
if (tabBrowser.isFavIconKnownMissing(href)) {
if (listener)
listener.mIcon = null;
return;
}
if (listener)
listener.mIcon = href;
if (tabBrowser.mProgressListeners) {
var targetBrowser = tabBrowser.getBrowserAtIndex(browserIndex);
for (i = 0; i < tabBrowser.mProgressListeners.length; i++) {
var p = tabBrowser.mProgressListeners[i];
if (p)
p.onLinkIconAvailable(targetBrowser, href);
}
}
]]>
</body>
</method>
<method name="onTitleChanged">
<parameter name="evt"/>
<body>
<![CDATA[
if (evt.target != this.contentDocument)
return;
var i = 0;
for ( ; i < this.parentNode.parentNode.childNodes.length; i++) {
if (this.parentNode.parentNode.childNodes[i].firstChild.nextSibling == this)
break;
}
var tabBrowser = this.parentNode.parentNode.parentNode.parentNode;
var tab = tabBrowser.mTabContainer.childNodes[i];
tabBrowser.setTabTitle(tab);
if (tab == tabBrowser.mCurrentTab)
tabBrowser.updateTitlebar();
]]>
</body>
</method>
<method name="setTabTitle">
<parameter name="aTab"/>
<body>
<![CDATA[
// dump ("setTabTitle called\t\t\t");
// showStack();
var browser = this.getBrowserForTab(aTab);
var crop = "end";
var title = browser.contentTitle;
if (!title) {
if (browser.currentURI.spec) {
try {
title = this.mURIFixup.createExposableURI(browser.currentURI).spec;
} catch(ex) {
title = browser.currentURI.spec;
}
}
if (title && title != "about:blank") {
// At this point, we now have a URI.
// Let's try to unescape it using a character set
// in case the URI is not ASCII.
try {
var characterSet = Components.lookupMethod(browser.contentDocument, 'characterSet')
.call(browser.contentDocument);
const textToSubURI = Components.classes["@mozilla.org/intl/texttosuburi;1"]
.getService(Components.interfaces.nsITextToSubURI);
title = textToSubURI.unEscapeNonAsciiURI(characterSet, title);
} catch(ex) { /* Do nothing. */ }
crop = "center";
} else // Still no title? Fall back to our untitled string.
title = this.mStringBundle.getString("tabs.untitled");
}
aTab.label = title;
aTab.setAttribute("crop", crop);
// MERC - JCH: Set special title and icon if tab is the non-user-initiated tab
if (aTab.isNonUserInitPopupTab)
{
aTab.label = "POP-UPS";
aTab.setAttribute("image", "chrome://browser/skin/icons/popuponsm_n.png");
}
//JA
for (var i = 0; i < this.mTabContainer.childNodes.length; i++) {
if (this.mTabContainer.childNodes[i] == aTab)
{
window.onTabAction(3,i,title);//notify about title change on tab
break;
}
}
//end JA
]]>
</body>
</method>
// MERC - JCH: Get the tab that holds the non-user-initiated popups tab if
// it exists. If it doesn't, create a new tab and return it.
<method name="getNonUserInitPopupTab">
<parameter name="aURI"/>
<parameter name="aReferrerURI"/>
<parameter name="aCharset"/>
<body>
<![CDATA[
var tab;
var found = false;
var childCount = this.mTabContainer.childNodes.length;
// Search the tabs for the non-user-initiated-popups tab
for (var i=0; i < childCount; i++)
{
tab = this.mTabContainer.childNodes[i];
if (tab && tab.isNonUserInitPopupTab)//JA true if tab not
{
//dump("\n\n\n~~~~~~~~~~~isNonUserInitPopupTab = "+i);
found = true;
break;
}
}
// If the non-user-initiated popups tab is found, load it with current pop-up
// page, otherwise create a new tab and init isNonUserInitPopupTab to true.
if (found) {
var browser = this.getBrowserForTab(tab);
//dump("\n~~~~~~~~~~~browser = "+browser+"tab = "+tab+"\n\n\n");
browser.loadURI(aURI,aReferrerURI,aCharset);
// This is the first non-user-initiated popup so create a tab and
// set property isNonUserInitPopupTab to true
} else {
tab = this.addTab(aURI,aReferrerURI,aCharset,null);
tab.isNonUserInitPopupTab = true;
}
return tab;
]]>
</body>
</method>
// MERC - JCH: Check if non-user-initiated popups tab exists
<method name="nonUserInitPopupTabExists">
<body>
<![CDATA[
var found = false;
var childCount = this.mTabContainer.childNodes.length;
// Search the tabs for the non-user-initiated-popups tab
for (var i=0; i < childCount; i++) {
if (this.mTabContainer.childNodes[i].isNonUserInitPopupTab) {
found = true;
break;
}
}
return found;
]]>
</body>
</method>
<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_close").setAttribute("label", this.mStringBundle.getString("tabs.closeTab"));
if (!this.mTabbedMode)
this.enterTabbedMode();
}
else {
// XXXdwh temporary unclean dependency on specific menu items in navigator.xul
document.getElementById("menu_closeWindow").hidden = true;
document.getElementById("menu_close").setAttribute("label", this.mStringBundle.getString("tabs.close"));
}
]]>
</body>
</method>
<method name="getStripVisibility">
<body>
return !this.mStrip.collapsed;
</body>
</method>
<method name="enterTabbedMode">
<body>
<![CDATA[
this.mTabbedMode = true; // Welcome to multi-tabbed mode.
// Get the first tab all hooked up with a title listener and popup blocking listener.
this.mCurrentBrowser.addEventListener("DOMTitleChanged", this.onTitleChanged, false);
this.setTabTitle(this.mCurrentTab);
// Hook up our favicon.
var uri = this.mCurrentBrowser.currentURI;
if (this.shouldLoadFavIcon(uri))
this.loadFavIcon(uri, "image", this.mCurrentTab);
var filter;
if (this.mTabFilters.length > 0) {
// Use the filter hooked up in our addProgressListener
filter = this.mTabFilters[0];
} else {
// create a filter and hook it up to our first browser
filter = Components.classes["@mozilla.org/appshell/component/browser-status-filter;1"]
.createInstance(Components.interfaces.nsIWebProgress);
this.mTabFilters[0] = filter;
this.mCurrentBrowser.webProgress.addProgressListener(filter, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
}
// Remove all our progress listeners from the active browser's filter.
if (this.mProgressListeners) {
for (var i = 0; i < this.mProgressListeners.length; i++) {
var p = this.mProgressListeners[i];
if (p)
filter.removeProgressListener(p);
}
}
// Wire up a progress listener to our filter.
const listener = this.mTabProgressListener(this.mCurrentTab, this.mCurrentBrowser, false);
filter.addProgressListener(listener, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
this.mTabListeners[0] = listener;
]]>
</body>
</method>
<method name="_createMessage">
<parameter name="aType"/>
<body>
<![CDATA[
var message = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"browsermessage");
message.hidden = true;
message.setAttribute("type", aType);
return message;
]]>
</body>
</method>
<method name="addTab">
<parameter name="aURI"/>
<parameter name="aReferrerURI"/>
<parameter name="aCharset"/>
<parameter name="aPostData"/>
<body>
<![CDATA[
var blank = (aURI == "about:blank");
if (!this.mTabbedMode)
this.enterTabbedMode();
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");
if (blank)
t.setAttribute("label", this.mStringBundle.getString("tabs.untitled"));
else
t.setAttribute("label", aURI);
t.setAttribute("crop", "end");
t.maxWidth = 250;
t.minWidth = 50;
t.width = 0;
t.setAttribute("flex", "100");
t.setAttribute("validate", "never");
t.setAttribute("onerror", "this.parentNode.parentNode.parentNode.parentNode.addToMissedIconCache(this.getAttribute('image')); this.removeAttribute('image');");
// MERC (DP) ***********
t.setAttribute("onnewpreftab", "BrowserOpenPrefTab();");
// *********************
// MERC - JCH: If the nuip tab exists then add new tab to the left of this
// otherwise just add to far right
if (this.nonUserInitPopupTabExists()) {
this.mTabContainer.insertBefore(t, this.mTabContainer.childNodes[this.mPanelContainer.childNodes.length-1]);
} else {
this.mTabContainer.appendChild(t);
}
b.setAttribute("type", "content");
b.setAttribute("message", "true");
b.setAttribute("contextmenu", this.getAttribute("contentcontextmenu"));
b.setAttribute("tooltip", this.getAttribute("contenttooltip"));
b.setAttribute("autocompletepopup", this.getAttribute("autocompletepopup"));
// Add the Message and the Browser to the box
var vbox = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"vbox");
vbox.setAttribute("flex", "1");
vbox.appendChild(this._createMessage("top"));
vbox.appendChild(b);
vbox.appendChild(this._createMessage("bottom"));
b.setAttribute("flex", "1");
// this.mPanelContainer.appendChild(vbox);
// MERC - JCH: If the nuip tab exists then add new tab to the left of this
// otherwise just add to far right
if (this.nonUserInitPopupTabExists()) {
this.mPanelContainer.insertBefore(vbox, this.mPanelContainer.childNodes[this.mPanelContainer.childNodes.length-1]);
} else {
this.mPanelContainer.appendChild(vbox);
}
b.addEventListener("DOMTitleChanged", this.onTitleChanged, false);
if (this.mStrip.collapsed)
this.setStripVisibilityTo(true);
this.mPrefs.setBoolPref("browser.tabs.forceHide", false);
// wire up a progress listener for the new browser object.
var tabListener = this.mTabProgressListener(t, b, blank);
// JMC - Note: this causes the currently selected tab to refresh it's title and favicon,
// In the case where we're loading a new tab into the background
const filter = Components.classes["@mozilla.org/appshell/component/browser-status-filter;1"]
.createInstance(Components.interfaces.nsIWebProgress);
filter.addProgressListener(tabListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
b.webProgress.addProgressListener(filter, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
var position;
// MERC - JCH: If the nuip tab exists, then position the
// listeners and filters correctly
if (this.nonUserInitPopupTabExists()) {
position = this.mTabContainer.childNodes.length-2;
this.mTabListeners.splice(position, 0, tabListener);
this.mTabFilters.splice(position, 0, filter);
} else {
position = this.mTabContainer.childNodes.length-1;
this.mTabListeners[position] = tabListener;
this.mTabFilters[position] = filter;
}
b._fastFind = this.fastFind;
if (!blank) {
// pretend the user typed this so it'll be available till
// the document successfully loads
b.userTypedValue = aURI;
if (aPostData === undefined)
aPostData = null;
try {
b.loadURIWithFlags(aURI, nsIWebNavigation.LOAD_FLAGS_NONE,
aReferrerURI, aPostData, null);
} catch( e ) {
// Clean up for bad scheme exception thrown by loadURIWithFlags().
b.userTypedValue = "";
t.setAttribute("label", this.mStringBundle.getString("tabs.untitled"));
}
}
this.updateCurrentBrowser();
window.onTabAction(0,position,null);//JA
return t;
]]>
</body>
</method>
<method name="addTabAt">
<parameter name="aURI"/>
<parameter name="atPref"/> <!-- set to undefined to read pref: browser.tabs.newTabLocation -->
<parameter name="aReferrerURI"/>
<parameter name="aCharset"/>
<parameter name="aPostData"/>
<body>
<![CDATA[
return this.addTabAtWithFlag(1, aURI, atPref, aReferrerURI, aCharset, aPostData);
]]>
</body>
</method>
<method name="addTabAtWithFlag">
<parameter name="aAddSessionHistory"/>
<parameter name="aURI"/>
<parameter name="atPref"/> <!-- set to undefined to read pref: browser.tabs.newTabLocation -->
<parameter name="aReferrerURI"/>
<parameter name="aCharset"/>
<parameter name="aPostData"/>
<body>
<![CDATA[
var blank = (aURI == "about:blank");
if (!this.mTabbedMode)
this.enterTabbedMode();
var forceUpdate;
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");
if (blank)
t.setAttribute("label", this.mStringBundle.getString("tabs.untitled"));
else
t.setAttribute("label", aURI);
t.setAttribute("crop", "end");
t.maxWidth = 250;
t.minWidth = 50;
t.width = 0;
t.setAttribute("flex", "100");
t.setAttribute("validate", "never");
t.setAttribute("onerror", "this.parentNode.parentNode.parentNode.parentNode.addToMissedIconCache(this.getAttribute('image')); this.removeAttribute('image');");
// MERC (DP) ***********
t.setAttribute("onnewpreftab", "BrowserOpenPrefTab();");
// *********************
// this pref determines where a new tab is openned
// choices are: left, right, farleft, farright.
// if the pref is passed in, use it. otherwise get the user pref
var newTabLocation;
if(atPref === undefined) {
newTabLocation = this.mPrefs.getCharPref("browser.tabs.newTabLocation");
} else {
newTabLocation = atPref;
}
switch(newTabLocation) {
case 'left':
this.mTabContainer.insertBefore(t, this.mCurrentTab);
forceUpdate = true;
break;
case 'right':
// MERC - JCH: If the nuip tab exists then new tab is placed to its left
if (this.nonUserInitPopupTabExists()) {
this.mTabContainer.insertBefore(t, this.mTabContainer.childNodes[this.mPanelContainer.childNodes.length-1]);
break;
}
// if the current tab is the last tab
if(this.mPanelContainer.selectedIndex == this.mPanelContainer.childNodes.length) {
this.mTabContainer.appendChild(t);
} else {
this.mTabContainer.insertBefore(t, this.mTabContainer.childNodes[this.mPanelContainer.selectedIndex + 1]);
}
break;
case 'farleft':
this.mTabContainer.insertBefore(t, this.mTabContainer.childNodes[0]);
break;
case 'farright':
// MERC - JCH: If the nuip tab exists then new tab is placed to its left
if (this.nonUserInitPopupTabExists()) {
this.mTabContainer.insertBefore(t, this.mTabContainer.childNodes[this.mPanelContainer.childNodes.length-1]);
break;
}
default:
this.mTabContainer.appendChild(t);
break;
}
b.setAttribute("type", "content");
b.setAttribute("message", "true");
b.setAttribute("contextmenu", this.getAttribute("contentcontextmenu"));
b.setAttribute("tooltip", this.getAttribute("contenttooltip"));
b.setAttribute("autocompletepopup", this.getAttribute("autocompletepopup"));
// To avoid unnecessary string compares on pageload in <browser>, only set the
// autocomplete attribute if autocomplete is actually enabled, so we can
// just test with |hasAttribute| in <browser>'s load handler.
if (this.getAttribute("autocompleteenabled") == "true")
b.setAttribute("autocompleteenabled", "true");
// Add the Message and the Browser to the box
var vbox = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"vbox");
vbox.setAttribute("flex", "1");
vbox.appendChild(this._createMessage("top"));
vbox.appendChild(b);
vbox.appendChild(this._createMessage("bottom"));
b.setAttribute("flex", "1");
switch(newTabLocation) {
case 'left':
//this.mPanelContainer.insertBefore(vbox, this.getBrowserForTab(this.mCurrentTab));
this.mPanelContainer.insertBefore(vbox, this.mPanelContainer.childNodes[this.mPanelContainer.selectedIndex]);
break;
case 'right':
// MERC - JCH: If the nuip tab exists then new tab is placed to its left
if (this.nonUserInitPopupTabExists()) {
this.mPanelContainer.insertBefore(vbox, this.mPanelContainer.childNodes[this.mPanelContainer.childNodes.length-1]);
break;
}
// if the current tab is the last tab
if(this.mPanelContainer.selectedIndex == this.mPanelContainer.childNodes.length) {
this.mPanelContainer.appendChild(vbox);
} else {
this.mPanelContainer.insertBefore(vbox, this.mPanelContainer.childNodes[this.mPanelContainer.selectedIndex + 1]);
}
break;
case 'farleft':
this.mPanelContainer.insertBefore(vbox, this.mPanelContainer.childNodes[0]);
break;
case 'farright':
// MERC - JCH: If the nuip tab exists then new tab is placed to its left
if (this.nonUserInitPopupTabExists()) {
this.mPanelContainer.insertBefore(vbox, this.mPanelContainer.childNodes[this.mPanelContainer.childNodes.length-1]);
break;
}
default:
this.mPanelContainer.appendChild(vbox);
break;
}
b.addEventListener("DOMTitleChanged", this.onTitleChanged, false);
if (this.mStrip.collapsed)
this.setStripVisibilityTo(true);
this.mPrefs.setBoolPref("browser.tabs.forceHide", false);
// wire up a progress listener for the new browser object.
var tabListener = this.mTabProgressListener(t, b, blank);
const filter = Components.classes["@mozilla.org/appshell/component/browser-status-filter;1"]
.createInstance(Components.interfaces.nsIWebProgress);
filter.addProgressListener(tabListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
b.webProgress.addProgressListener(filter, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
var position;
switch(newTabLocation) {
case 'left':
position = this.mPanelContainer.selectedIndex;
this.mTabListeners.splice(position, 0, tabListener);
this.mTabFilters.splice(position, 0, filter);
break;
case 'right':
// MERC - JCH: If the nuip tab exists, position the listeners and filters
// correctly for the new tab
if (this.nonUserInitPopupTabExists()) {
position = this.mTabContainer.childNodes.length-2;
this.mTabListeners.splice(position, 0, tabListener);
this.mTabFilters.splice(position, 0, filter);
break;
}
// if the current tab is the last tab
if(this.mPanelContainer.selectedIndex == this.mPanelContainer.childNodes.length) {
position = this.mTabContainer.childNodes.length-1;
this.mTabListeners[position] = tabListener;
this.mTabFilters[position] = filter;
} else {
position = this.mPanelContainer.selectedIndex + 1;
this.mTabListeners.splice(position, 0, tabListener);
this.mTabFilters.splice(position, 0, filter);
}
break;
case 'farleft':
position = 0;
this.mTabListeners.splice(position, 0, tabListener);
this.mTabFilters.splice(position, 0, filter);
break;
case 'farright':
// MERC - JCH: If the nuip tab exists, position the listeners and filters
// correctly for the new tab
if (this.nonUserInitPopupTabExists()) {
position = this.mTabContainer.childNodes.length-2;
this.mTabListeners.splice(position, 0, tabListener);
this.mTabFilters.splice(position, 0, filter);
break;
}
default:
position = this.mTabContainer.childNodes.length-1;
this.mTabListeners[position] = tabListener;
this.mTabFilters[position] = filter;
break;
}
if (!blank) {
if (aPostData === undefined)
aPostData = null;
// Full back/forward history already duplicated; do not clobber with current URI.
var wnLoadType = nsIWebNavigation.LOAD_FLAGS_NONE;
if (aAddSessionHistory) {
wnLoadType = nsIWebNavigation.LOAD_FLAGS_NONE;
} else {
wnLoadType = nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY;
}
try {
b.loadURIWithFlags(aURI, wnLoadType, aReferrerURI, aPostData, null);
} catch( e ) {
t.setAttribute("label", this.mStringBundle.getString("tabs.untitled"));
}
}
// if (!forceUpdate)
// {
// dump ("Calling update Current Browser");
// this.updateCurrentBrowser();
// }
window.onTabAction(0,position,null);//JA
return t;
]]>
</body>
</method>
<method name="addPrefTab">
<body>
<![CDATA[
// 4 cases:
// a) 'blank' - open a new blank tab
// b) 'homepage' - open new tabs with home page entries
// c) 'current' - open a new tab with the current site loaded
// d) 'netscape' - open a new tab with netscape.com
var newTabPref;
try {
newTabPref = this.mPrefs.getCharPref("browser.tabs.newTabChoice");
} catch(e) {
newTabPref = 'blank';
}
var addedTab;
switch(newTabPref) {
case 'homepage':
BrowserHome(true);
addedTab = this.mCurrentTab;
break;
case 'current':
currentTab = this.mCurrentTab;
var curTabBrowser=this.getBrowserForTab(currentTab);
var sHistory=curTabBrowser.sessionHistory;
addedTab = this.addTabAtWithFlag(0,this.getBrowserForTab(this.mCurrentTab).currentURI.spec);
var newTabBrowser=this.getBrowserForTab(addedTab);
newTabBrowser.sessionHistory.appendFrom(sHistory);
break;
case 'netscape':
var url;
try {
url = gPrefService.getComplexValue("browser.netscape.homepage",
Components.interfaces.nsIPrefLocalizedString).data;
} catch (e) {
}
addedTab = this.addTabAt(url);
break;
case 'blank':
default:
addedTab = this.addTabAt("about:blank");
break;
}
return addedTab;
]]>
</body>
</method>
<method name="warnAboutClosingTabs">
<parameter name="aAll"/>
<body>
<![CDATA[
var numTabs = this.mTabContainer.childNodes.length;
var reallyClose = true;
if (numTabs <= 1)
return reallyClose;
const pref = "browser.tabs.warnOnClose";
var shouldPrompt = this.mPrefs.getBoolPref(pref);
var reallyClose = true;
if (shouldPrompt) {
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
//default to true: if it were false, we wouldn't get this far
var warnOnClose = { value:true };
var bundle = this.mStringBundle;
var tabsToClose = numTabs; //number of tabs to be removed
if (!aAll)
--tabsToClose;
var messageKey = (tabsToClose == 1) ? "tabs.closeWarningOne" : "tabs.closeWarningMultiple";
var closeKey = (tabsToClose == 1) ? "tabs.closeButtonOne" : "tabs.closeButtonMultiple";
var buttonPressed = promptService.confirmEx(window,
bundle.getString('tabs.closeWarningTitle'),
bundle.getFormattedString(messageKey, [tabsToClose]),
(promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0)
+ (promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1),
bundle.getString(closeKey),
null, null,
bundle.getString('tabs.closeWarningPromptMe'),
warnOnClose);
reallyClose = (buttonPressed == 0);
// don't set the pref unless they press OK and it's false
if (reallyClose && !warnOnClose.value)
this.mPrefs.setBoolPref(pref, false);
}
return reallyClose;
]]>
</body>
</method>
<method name="removeAllTabsBut">
<parameter name="aTab"/>
<body>
<![CDATA[
if (this.warnAboutClosingTabs(false)) {
if (aTab.localName != "tab")
aTab = this.mCurrentTab;
else
this.mTabContainer.selectedItem = aTab;
var childNodes = this.mTabContainer.childNodes;
for (var i = childNodes.length - 1; i >= 0; --i) {
if (childNodes[i] != aTab)
this.removeTab(childNodes[i]);
}
}
}
]]>
</body>
</method>
<method name="removeCurrentTab">
<body>
<![CDATA[
// MERC (DP): hide site control popup for the case when tab is closed on dbl click
document.getElementById('SiteControlsPopup').hidePopup();
return this.removeTab(this.mCurrentTab);
]]>
</body>
</method>
<method name="removeTab">
<parameter name="aTab"/>
<body>
<![CDATA[
if (aTab.localName != "tab")
aTab = this.mCurrentTab;
// if we are deleting the tab associated to lastSelectedTab, set lastSelectedTab = null;
if(this.mTabContainer.lastSelectedTab != null && aTab == this.mTabContainer.lastSelectedTab) {
this.mTabContainer.lastSelectedTab = null;
}
var l = this.mTabContainer.childNodes.length;
if (l == 1) {
if (aTab.isNonUserInitPopupTab)
aTab.isNonUserInitPopupTab = false;
if (!this.mPrefs.getBoolPref("browser.tabs.autoHide")) {
// blank the tab
this.loadURI("about:blank");
return;
}
// hide the tab bar
/* MERC (DP): never allow the case when there are zero tabs open
i.e. there must always be at least one tab
this.mPrefs.setBoolPref("browser.tabs.forceHide", true);
this.setStripVisibilityTo(false);
*/
return;
}
var ds = this.getBrowserForTab(aTab).docShell;
if (ds.contentViewer && !ds.contentViewer.permitUnload())
return;
if (l == 2) {
var autohide = this.mPrefs.getBoolPref("browser.tabs.autoHide");
if (autohide)
this.setStripVisibilityTo(false);
}
var index = -1;
if (this.mCurrentTab == aTab)
index = this.mPanelContainer.selectedIndex;
else {
// Find and locate the tab in our list.
for (var i = 0; i < l; i++)
if (this.mTabContainer.childNodes[i] == aTab)
index = i;
}
// Remove the tab's filter and progress listener.
const filter = this.mTabFilters[index];
var oldBrowser = this.getBrowserAtIndex(index);
oldBrowser.webProgress.removeProgressListener(filter);
filter.removeProgressListener(this.mTabListeners[index]);
this.mTabFilters.splice(index, 1);
this.mTabListeners.splice(index, 1);
// Remove our title change and blocking listeners
oldBrowser.removeEventListener("DOMTitleChanged", this.onTitleChanged, false);
// We are no longer the primary content area.
oldBrowser.setAttribute("type", "content");
// get the preference that determines which tab is focused after removal
var focusAfterRemoval = this.mPrefs.getCharPref("browser.tabs.focusAfterRemoval");
// Now select the new tab before nuking the old one.
var currentIndex = this.mPanelContainer.selectedIndex;
var bUseLastTab = false;
var newIndex = -1;
if (currentIndex > index) {
newIndex = currentIndex-1;
} else if (currentIndex < index) {
newIndex = currentIndex;
} else {
switch(focusAfterRemoval) {
case 'right':
newIndex = currentIndex;
break;
case 'lastSelected':
if(this.mTabContainer.lastSelectedTab == null) {
// if there is no last selected tab, we focus the tab to the left
newIndex = currentIndex - 1;
} else {
bUseLastTab = true;
}
break;
case 'left':
default:
newIndex = currentIndex - 1;
break;
}
}
var newLength = l - 2;
if(newIndex < 0) {
newIndex = 0;
}
if(newIndex > newLength) {
newIndex = newLength;
}
var oldTab = aTab;
// clean up the before/afterselected attributes before removing the tab
oldTab.selected = false;
// XXX browser's destructor isn't always called, so we force a cleanup ourselves
oldBrowser.destroy();
window.onTabAction(1,index,null);//JA
this.mTabContainer.removeChild(oldTab);
this.mPanelContainer.removeChild(this.mPanelContainer.childNodes[index]);
if(bUseLastTab) {
for (var i = 0; i < l; i++) {
if (this.mTabContainer.childNodes[i] == this.mTabContainer.lastSelectedTab) {
newIndex = i;
}
}
}
this.selectedTab = this.mTabContainer.childNodes[newIndex];
this.mPanelContainer.selectedIndex = newIndex;
this.updateCurrentBrowser();
}
]]>
</body>
</method>
<method name="reloadAllTabs">
<body>
<![CDATA[
var l = this.mPanelContainer.childNodes.length;
for (var i = 0; i < l; i++) {
try {
this.getBrowserAtIndex(i).reload();
} catch (e) {
// ignore failure to reload so others will be reloaded
}
}
]]>
</body>
</method>
<method name="reloadTab">
<parameter name="aTab"/>
<body>
<![CDATA[
if (aTab.localName != "tab")
aTab = this.mCurrentTab;
this.getBrowserForTab(aTab).reload();
]]>
</body>
</method>
// MERC (DP)
<method name="closeAllTabsToLeft">
<parameter name="aTab"/>
<body>
<![CDATA[
if (aTab.localName != "tab") {
aTab = this.mCurrentTab;
}
// get the number of tabs
var l = this.mTabContainer.childNodes.length;
// find the index of the context tab (not necessarily the selected tab)
var index = -1;
if (this.mCurrentTab == aTab) {
index = this.mPanelContainer.selectedIndex;
} else {
// Find and locate the tab in our list.
for (var i = 0; i < l; i++) {
if (this.mTabContainer.childNodes[i] == aTab) {
index = i;
break;
} // if
} // for
} // if
for(var j = 0; j < index; j++) {
// remove the first tab
this.removeTab(this.mTabContainer.childNodes[0]);
}
]]>
</body>
</method>
<method name="closeAllTabsToRight">
<parameter name="aTab"/>
<body>
<![CDATA[
if (aTab.localName != "tab") {
aTab = this.mCurrentTab;
}
// get the number of tabs
var l = this.mTabContainer.childNodes.length;
// find the index of the context tab (not necessarily the selected tab)
var index = -1;
if (this.mCurrentTab == aTab) {
index = this.mPanelContainer.selectedIndex;
} else {
// Find and locate the tab in our list.
for (var i = 0; i < l; i++) {
if (this.mTabContainer.childNodes[i] == aTab) {
index = i;
break;
} // if
} // for
} // if
for(var j = 0; j < l - index - 1; j++) {
// remove the last tab
this.removeTab(this.mTabContainer.childNodes[this.mTabContainer.childNodes.length - 1]);
}
]]>
</body>
</method>
// MERC (DP)
<!--
Will return true if the host string of the first URI param is a direct subdomain
of the second URI param
e.g. www.google.com , mail.google.com => true
slashdot.org/main.html , news.slashdot.org/index.html => true
foobar.asdf.com , hello.asdf.com => false
-->
<method name="compareURISubdomain">
<parameter name="aURI1"/>
<parameter name="aURI2"/>
<body>
<![CDATA[
var host1;
var host2;
try {
host1 = aURI1.host;
} catch(e) {
host1 = aURI1.spec;
}
// strip 'www.' from the first host, if present
if(host1.match(/^www\./)) {
host1 = host1.substring(4);
}
try {
host2 = aURI2.host;
} catch(e) {
host2 = aURI2.spec;
}
var dotHost1 = '.' + host1;
var dotHost2 = '.' + host2;
if(dotHost2.indexOf(dotHost1) > -1) {
return true;
} else {
return false;
}
]]>
</body>
</method>
<!--
Will return true if the host string of the URIs are the same
e.g. www.foobar.com/index.html == www.foobar.com/help.html
-->
<method name="compareURI">
<parameter name="aURI1"/>
<parameter name="aURI2"/>
<body>
<![CDATA[
var host1;
var host2;
try {
host1 = aURI1.host;
} catch(e) {
host1 = aURI1.spec;
}
try {
host2 = aURI2.host;
} catch(e) {
host2 = aURI2.spec;
}
if(host1 == host2) {
return true;
} else {
return false;
}
]]>
</body>
</method>
<method name="closeAllTabsFromSameSite">
<parameter name="aTab"/>
<body>
<![CDATA[
if (aTab.localName != "tab") {
aTab = this.mCurrentTab;
}
var contextBrowser = this.getBrowserForTab(aTab);
var browserPanels = this.mPanelContainer.childNodes;
var tabs = this.mTabContainer.childNodes;
for(var i = tabs.length - 1; i >= 0; --i) {
// don't remove the context tab until the very end. otherwise you get error
if( (this.compareURISubdomain(contextBrowser.currentURI, this.getBrowserAtIndex(i).currentURI)) && (tabs[i] != aTab) ) {
this.removeTab(tabs[i]);
}
}
// remove context tab
this.removeTab(aTab); // remove this line for now as it seems to crash when u select from dropdown menu
]]>
</body>
</method>
<method name="closeAllTabsExceptFromSameSite">
<parameter name="aTab"/>
<body>
<![CDATA[
if (aTab.localName != "tab") {
aTab = this.mCurrentTab;
}
var contextBrowser = this.getBrowserForTab(aTab);
var browserPanels = this.mPanelContainer.childNodes;
var tabs = this.mTabContainer.childNodes;
for(var i = tabs.length - 1; i >= 0; --i) {
if(!this.compareURISubdomain(contextBrowser.currentURI, this.getBrowserAtIndex(i).currentURI)) {
this.removeTab(tabs[i]);
}
}
]]>
</body>
</method>
<method name="closeAllBlankTabs">
<body>
<![CDATA[
var tabs = this.mTabContainer.childNodes;
for(var i = tabs.length - 1; i >= 0; --i) {
if(this.getBrowserForTab(tabs[i]).currentURI.spec == "about:blank") {
this.removeTab(tabs[i]);
}
}
]]>
</body>
</method>
<method name="appendTabToHomePage">
<parameter name="aTab"/>
<body>
<![CDATA[
if (aTab.localName != "tab") {
aTab = this.mCurrentTab;
}
this.mTabContainer.selectedItem = aTab;
var homePage = this.mPrefs.getComplexValue("browser.startup.homepage", Components.interfaces.nsIPrefLocalizedString).data;
if(homePage) {
newHomePage = homePage + "|" + this.getBrowserForTab(aTab).currentURI.spec;
} else {
newHomePage = this.getBrowserForTab(aTab).currentURI.spec;
}
this.mPrefs.setCharPref("browser.startup.homepage", newHomePage);
]]>
</body>
</method>
<method name="setTabAsHomePage">
<parameter name="aTab"/>
<body>
<![CDATA[
if (aTab.localName != "tab") {
aTab = this.mCurrentTab;
}
this.mTabContainer.selectedItem = aTab;
this.mPrefs.setCharPref("browser.startup.homepage", this.getBrowserForTab(aTab).currentURI.spec);
]]>
</body>
</method>
<method name="setAllTabsAsHomePage">
<parameter name="aTab"/>
<body>
<![CDATA[
if (aTab.localName != "tab") {
aTab = this.mCurrentTab;
}
var newHPValue = "";
var tabs = this.mTabContainer.childNodes;
var browsers = this.mPanelContainer.childNodes;
this.mTabContainer.selectedItem = aTab;
for (var i = 0; i < tabs.length; i++) {
if (i) {
newHPValue += '|';
}
newHPValue += this.getBrowserAtIndex(i).currentURI.spec;
}
this.mPrefs.setCharPref("browser.startup.homepage", newHPValue);
]]>
</body>
</method>
<method name="onTabBarDblClick">
<parameter name="aEvent"/>
<body>
<![CDATA[
if (aEvent.originalTarget.localName != 'tab' && aEvent.button == 0)
this.selectedTab = this.addTab();
]]>
</body>
</method>
// we need to call this function whenever tabs are added and remove and
// on startup. if there is only one tab, we hide:
// tab close button, tabs dropdown menu, tabs close all button
<method name="updateChromeWhenLastTab">
<body>
<![CDATA[
var tabs = this.mTabContainer.childNodes;
if(tabs.length == 1) {
var closebutton = document.getAnonymousElementByAttribute(tabs[0],'anonid','closebutton-box');
/*var activemenubutton = document.getAnonymousElementByAttribute(tabs[0],'anonid','activemenubutton');*/
if (!closebutton.hasAttribute("hidden")) {
closebutton.setAttribute("hidden", true);
}
/*if (!activemenubutton.hasAttribute("hidden")) {
activemenubutton.setAttribute("hidden", true);
}*/
//document.getElementById('cmd_close').setAttribute('disabled', 'true');
//document.getAnonymousElementByAttribute(this.mTabContainer,'anonid','tabs-dropdown').setAttribute("hidden", true);
//document.getAnonymousElementByAttribute(this.mTabContainer,'anonid','tabs-closeall').setAttribute("hidden", true);
} else {
var closebutton;
var activemenubutton;
for (var k = 0; k < tabs.length; k++) {
closebutton = document.getAnonymousElementByAttribute(tabs[k],'anonid','closebutton-box');
/*activemenubutton = document.getAnonymousElementByAttribute(tabs[k],'anonid','activemenubutton');*/
closebutton.removeAttribute("hidden");
/*activemenubutton.removeAttribute("hidden");*/
}
//document.getElementById('cmd_close').removeAttribute('disabled');
//document.getAnonymousElementByAttribute(this.mTabContainer,'anonid','tabs-dropdown').removeAttribute("hidden");
//document.getAnonymousElementByAttribute(this.mTabContainer,'anonid','tabs-closeall').removeAttribute("hidden");
}
]]>
</body>
</method>
// MERC
<method name="addProgressListener">
<parameter name="aListener"/>
<parameter name="aMask"/>
<body>
<![CDATA[
if (!this.mProgressListeners) {
this.mProgressListeners = [];
const autoHide = this.mPrefs.getBoolPref("browser.tabs.autoHide");
const forceHide = this.mPrefs.getBoolPref("browser.tabs.forceHide");
if (!autoHide && !forceHide)
this.setStripVisibilityTo(true);
// Hook up a listener for <link>s.
this.mPanelContainer.addEventListener("DOMLinkAdded", this.onLinkAdded, false);
}
if (!this.mTabbedMode && this.mProgressListeners.length == 1) {
// If we are adding a 2nd progress listener, we need to enter tabbed mode
// because the browser status filter can only handle one progress listener.
// In tabbed mode, mTabProgressListener is used which will iterate over all listeners.
this.enterTabbedMode();
}
this.mProgressListeners.push(aListener);
if (!this.mTabbedMode) {
// If someone does this:
// addProgressListener, removeProgressListener, addProgressListener
// don't create a new filter; reuse the existing filter.
if (this.mTabFilters.length == 0) {
// hook a filter up to our first browser
const filter = Components.classes["@mozilla.org/appshell/component/browser-status-filter;1"]
.createInstance(Components.interfaces.nsIWebProgress);
this.mTabFilters[0] = filter;
this.mCurrentBrowser.webProgress.addProgressListener(filter, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
}
// Directly hook the listener up to the filter for better performance
this.mTabFilters[0].addProgressListener(aListener, aMask);
}
]]>
</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)
// Don't forget to remove it from the filter we hooked it up to
this.mTabFilters[0].removeProgressListener(aListener);
]]>
</body>
</method>
<method name="getBrowserForTab">
<parameter name="aTab"/>
<body>
<![CDATA[
if (this.mCurrentTab == aTab)
return this.mCurrentBrowser;
for (var i = 0; i < this.mTabContainer.childNodes.length; i++) {
if (this.mTabContainer.childNodes[i] == aTab) {
return this.getBrowserAtIndex(i);
}
}
return null;
]]>
</body>
</method>
<property name="tabContainer">
<getter>
return this.mTabContainer;
</getter>
</property>
<property name="selectedTab">
<getter>
return this.mTabBox.selectedTab;
</getter>
<setter>
<![CDATA[
// Update the tab
this.mTabBox.selectedTab = val;
return val;
]]>
</setter>
</property>
<property name="selectedBrowser"
onget="return this.mCurrentBrowser;"
readonly="true"/>
<property name="browsers"
onget="return this.mPanelContainer.getElementsByTagName('browser');"
readonly="true"/>
<!-- 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 = transferUtils.retrieveURLFromData(aXferData.data, aXferData.flavour.contentType);
// valid urls don't contain spaces ' '; if we have a space it isn't a valid url.
// Also disallow dropping javascript: or data: urls--bail out
if (!url || !url.length || url.indexOf(" ", 0) != -1 ||
/^\s*(javascript|data):/.test(url))
return;
this.dragDropSecurityCheck(aEvent, aDragSession, url);
var bgLoad = this.mPrefs.getBoolPref("browser.tabs.loadInBackground");
var tab = null;
if (aEvent.originalTarget.localName != "tab") {
// We're adding a new tab.
tab = this.addTabAt(getShortcutOrURI(url));
}
else {
// Load in an existing tab.
tab = aEvent.originalTarget;
this.getBrowserForTab(tab).loadURI(getShortcutOrURI(url));
}
if (this.mCurrentTab != tab && !bgLoad)
this.selectedTab = tab;
]]>
</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>
<!-- 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"/>
<parameter name="aReferrerURI"/>
<parameter name="aCharset"/>
<body>
<![CDATA[
return this.mCurrentBrowser.loadURI(aURI, aReferrerURI, aCharset);
]]>
</body>
</method>
<!-- throws exception for unknown schemes -->
<method name="loadURIWithFlags">
<parameter name="aURI"/>
<parameter name="aFlags"/>
<parameter name="aReferrerURI"/>
<parameter name="aCharset"/>
<body>
<![CDATA[
return this.mCurrentBrowser.loadURIWithFlags(aURI, aFlags, aReferrerURI, aCharset);
]]>
</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>
<method name="attachFormFill">
<body><![CDATA[
for (var i = 0; i < this.mPanelContainer.childNodes.length; ++i) {
var cb = this.getBrowserAtIndex(i);
cb.attachFormFill();
}
]]></body>
</method>
<method name="detachFormFill">
<body><![CDATA[
for (var i = 0; i < this.mPanelContainer.childNodes.length; ++i) {
var cb = this.getBrowserAtIndex(i);
cb.detachFormFill();
}
]]></body>
</method>
<property name="pageReport"
onget="return this.mCurrentBrowser.pageReport;"
readonly="true"/>
<property name="currentURI"
onget="return this.mCurrentBrowser.currentURI;"
readonly="true"/>
<field name="_fastFind">null</field>
<property name="fastFind"
readonly="true">
<getter>
<![CDATA[
if (!this._fastFind) {
this._fastFind = Components.classes["@mozilla.org/typeaheadfind;1"]
.createInstance(Components.interfaces.nsITypeAheadFind);
this._fastFind.init(this.docShell);
}
return this._fastFind;
]]>
</getter>
</property>
<property name="findString"
onget="return this.mCurrentBrowser.findString;"
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"/>
<property name="contentTitle"
onget="return this.mCurrentBrowser.contentTitle;"
readonly="true"/>
<property name="securityUI"
onget="return this.mCurrentBrowser.securityUI;"
readonly="true"/>
<method name="find">
<body>
<![CDATA[
return this.mCurrentBrowser.find();
]]>
</body>
</method>
<method name="findAgain">
<body>
<![CDATA[
return this.mCurrentBrowser.findAgain();
]]>
</body>
</method>
<method name="findPrevious">
<body>
<![CDATA[
return this.mCurrentBrowser.findPrevious();
]]>
</body>
</method>
<method name="dragDropSecurityCheck">
<parameter name="aEvent"/>
<parameter name="aDragSession"/>
<parameter name="aUrl"/>
<body>
<![CDATA[
// Do a security check for drag n' drop. Make sure the
// source document can load the dragged link.
var sourceDoc = aDragSession.sourceDocument;
if (sourceDoc) {
var sourceURI = sourceDoc.documentURI;
const nsIScriptSecurityManager =
Components.interfaces.nsIScriptSecurityManager;
var secMan =
Components.classes["@mozilla.org/scriptsecuritymanager;1"]
.getService(nsIScriptSecurityManager);
try {
secMan.checkLoadURIStr(sourceURI, aUrl,
nsIScriptSecurityManager.STANDARD);
} catch (e) {
// Stop even propagation right here.
aEvent.stopPropagation();
throw "Drop of " + aUrl + " denied.";
}
}
]]>
</body>
</method>
<field name="_keyEventHandler" readonly="true">
<![CDATA[({
tabbrowser: this,
handleEvent: function handleEvent(aEvent) {
if (!aEvent.isTrusted) {
// Don't let untrusted events mess with tabs.
return;
}
if (aEvent.ctrlKey && aEvent.keyCode == KeyEvent.DOM_VK_F4 &&
this.tabbrowser.mTabBox.handleCtrlPageUpDown)
this.tabbrowser.removeCurrentTab();
}
})]]>
</field>
<property name="canFindAgain"
onget="return this.mCurrentBrowser.canFindAgain;"
readonly="true"/>
<property name="userTypedClear"
onget="return this.mCurrentBrowser.userTypedClear;"
onset="return this.mCurrentBrowser.userTypedClear = val;"/>
<property name="userTypedValue"
onget="return this.mCurrentBrowser.userTypedValue;"
onset="return this.mCurrentBrowser.userTypedValue = val;"/>
<property name="forceSyncURLBarUpdate"
onget="return this.mModalDialogShowing;"/>
<!-- MERC - JCH : needed for counting blocked popups -->
<property name="numberBlocked"
onget="return this.getAttribute('numberBlocked');"
onset="this.setAttribute('numberBlocked', val); return val;"/>
<constructor>
<![CDATA[
this.mCurrentBrowser = this.getBrowserAtIndex(0);
this.mCurrentTab = this.mTabContainer.firstChild;
this.setAttribute("numberBlocked", "0");
document.addEventListener("keypress", this._keyEventHandler, false);
]]>
</constructor>
<destructor>
<![CDATA[
for (var i = 0; i < this.mTabListeners.length; ++i) {
this.getBrowserAtIndex(i).webProgress.removeProgressListener(this.mTabFilters[i]);
this.mTabFilters[i].removeProgressListener(this.mTabListeners[i]);
this.mTabFilters[i] = null;
this.mTabListeners[i] = null;
this.getBrowserAtIndex(i).removeEventListener("DOMTitleChanged", this.onTitleChanged, false);
}
this.mPanelContainer.removeEventListener("DOMLinkAdded", this.onLinkAdded, false);
document.removeEventListener("keypress", this._keyEventHandler, false);
]]>
</destructor>
</implementation>
<handlers>
<handler event="DOMWindowClose">
<![CDATA[
if (!event.isTrusted)
return;
const browsers = this.mPanelContainer.childNodes;
if (browsers.length == 1) {
// There's only one browser left. If a window is being
// closed and the window is *not* the window in the
// browser that's still around, prevent the event's default
// action to prevent closing a window that's being closed
// already.
if (this.getBrowserAtIndex(0).contentWindow != event.target)
event.preventDefault();
return;
}
for (var i = 0; i < browsers.length; ++i) {
if (this.getBrowserAtIndex(i).contentWindow == event.target) {
this.removeTab(this.mTabContainer.childNodes[i]);
//JA event.preventDefault();
break;
}
}
// JA tmp fix for bug 403: always prevent .close() from script if
// target window was not found : as it happens when tab gets
// removed by clicking on [x] or dblclick
event.preventDefault();
]]>
</handler>
<handler event="DOMWillOpenModalDialog">
<![CDATA[
if (!event.isTrusted)
return;
// We're about to open a modal dialog, make sure the opening
// tab is brought to the front.
for (var i = 0; i < browsers.length; ++i) {
if (this.getBrowserAtIndex(i).contentWindow == event.target) {
this.mModalDialogShowing = true;
this.selectedTab = this.mTabContainer.childNodes[i];
break;
}
}
]]>
</handler>
<handler event="DOMModalDialogClosed">
<![CDATA[
if (!event.isTrusted)
return;
this.mModalDialogShowing = false;
]]>
</handler>
</handlers>
</binding>
</bindings>