2007-08-22 08:58:49 +04:00
|
|
|
|
<?xml version="1.0"?>
|
|
|
|
|
|
2007-08-22 08:59:53 +04:00
|
|
|
|
<!-- ***** BEGIN LICENSE BLOCK *****
|
|
|
|
|
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2007-08-22 08:58:49 +04:00
|
|
|
|
-
|
2007-08-22 08:59:53 +04:00
|
|
|
|
- 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/
|
2007-08-22 08:58:49 +04:00
|
|
|
|
-
|
2007-08-22 08:59:53 +04:00
|
|
|
|
- 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.
|
2007-08-22 08:58:49 +04:00
|
|
|
|
-
|
2007-08-22 08:59:53 +04:00
|
|
|
|
- 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 the Initial Developer are Copyright (C) 2001
|
|
|
|
|
- the Initial Developer. All Rights Reserved.
|
2007-08-22 08:58:49 +04:00
|
|
|
|
-
|
|
|
|
|
- Contributor(s):
|
|
|
|
|
- David Hyatt <hyatt@netscape.com> (Original Author of <tabbrowser>)
|
2007-08-22 09:00:10 +04:00
|
|
|
|
- Mike Connor <mconnor@steelgryphon.com>
|
2007-08-22 09:00:20 +04:00
|
|
|
|
- Peter Parente <parente@cs.unc.edu>
|
2007-08-22 09:00:21 +04:00
|
|
|
|
- Giorgio Maone <g.maone@informaction.com>
|
2007-08-22 09:01:33 +04:00
|
|
|
|
- Asaf Romano <mozilla.mano@sent.com>
|
2007-08-22 09:01:34 +04:00
|
|
|
|
- Seth Spitzer <sspitzer@mozilla.org>
|
2007-08-22 09:01:48 +04:00
|
|
|
|
- Simon Bünzli <zeniko@gmail.com>
|
2007-08-22 09:02:20 +04:00
|
|
|
|
- Michael Ventnor <ventnor.bugzilla@yahoo.com.au>
|
2007-08-22 09:02:29 +04:00
|
|
|
|
- Mark Pilgrim <pilgrim@gmail.com>
|
2009-03-24 14:47:06 +03:00
|
|
|
|
- Dão Gottwald <dao@mozilla.com>
|
2009-05-14 20:46:50 +04:00
|
|
|
|
- Paul O’Shannessy <paul@oshannessy.com>
|
2009-10-06 08:26:15 +04:00
|
|
|
|
- Rob Arnold <tellrob@gmail.com>
|
2011-04-12 10:50:56 +04:00
|
|
|
|
- Frank Yan <fyan@mozilla.com>
|
|
|
|
|
- Patrick Walton <pcwalton@mozilla.com>
|
2007-08-22 08:58:49 +04:00
|
|
|
|
-
|
2007-08-22 08:59:53 +04:00
|
|
|
|
- Alternatively, the contents of this file may be used under the terms of
|
|
|
|
|
- either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
|
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
|
- in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
|
- of those above. If you wish to allow use of your version of this file only
|
|
|
|
|
- under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
|
- use your version of this file under the terms of the MPL, indicate your
|
|
|
|
|
- decision by deleting the provisions above and replace them with the notice
|
|
|
|
|
- and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
|
- the provisions above, a recipient may use your version of this file under
|
|
|
|
|
- the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
|
-
|
|
|
|
|
- ***** END LICENSE BLOCK ***** -->
|
2007-08-22 08:58:49 +04:00
|
|
|
|
|
|
|
|
|
<!DOCTYPE bindings [
|
2007-08-23 01:02:02 +04:00
|
|
|
|
<!ENTITY % tabBrowserDTD SYSTEM "chrome://browser/locale/tabbrowser.dtd" >
|
2007-08-22 08:58:49 +04:00
|
|
|
|
%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">
|
bug 213228: new toolkit independence bug, part 7: update and use the new toolkit widgetry. tabbrowser.xml: bug 205341, 112697, 210760 by jag, bug 121234, 133503 by neil, bug 206668 by shliang. not ported: bug 169589, [mac] ctrl-tab no longer moves btwn frames bug 203960, go back group bug 104778, remember what user typed when switching tabs. bug 103720, prefill URI when opening new tab.
2007-08-22 08:59:18 +04:00
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<binding id="tabbrowser">
|
|
|
|
|
<resources>
|
2008-01-15 06:04:37 +03:00
|
|
|
|
<stylesheet src="chrome://browser/content/tabbrowser.css"/>
|
2007-08-22 08:58:49 +04:00
|
|
|
|
</resources>
|
|
|
|
|
|
|
|
|
|
<content>
|
2007-08-23 01:02:02 +04:00
|
|
|
|
<xul:stringbundle anonid="tbstringbundle" src="chrome://browser/locale/tabbrowser.properties"/>
|
2010-03-17 09:36:13 +03:00
|
|
|
|
<xul:tabbox anonid="tabbox" class="tabbrowser-tabbox"
|
|
|
|
|
flex="1" eventnode="document" xbl:inherits="handleCtrlPageUpDown"
|
2010-02-26 10:58:46 +03:00
|
|
|
|
onselect="if (event.target.localName == 'tabpanels') this.parentNode.updateCurrentBrowser();">
|
2007-08-22 09:01:04 +04:00
|
|
|
|
<xul:tabpanels flex="1" class="plain" selectedIndex="0" anonid="panelcontainer">
|
2007-08-22 09:01:12 +04:00
|
|
|
|
<xul:notificationbox flex="1">
|
2010-09-16 07:01:00 +04:00
|
|
|
|
<xul:stack flex="1" anonid="browserStack">
|
|
|
|
|
<xul:browser type="content-primary" message="true" disablehistory="true"
|
|
|
|
|
xbl:inherits="tooltip=contenttooltip,contextmenu=contentcontextmenu,autocompletepopup"/>
|
|
|
|
|
</xul:stack>
|
2007-08-22 09:01:12 +04:00
|
|
|
|
</xul:notificationbox>
|
2007-08-22 08:58:49 +04:00
|
|
|
|
</xul:tabpanels>
|
|
|
|
|
</xul:tabbox>
|
|
|
|
|
<children/>
|
|
|
|
|
</content>
|
2010-02-26 10:58:46 +03:00
|
|
|
|
<implementation implements="nsIDOMEventListener">
|
2010-03-22 20:49:55 +03:00
|
|
|
|
|
|
|
|
|
<property name="tabContextMenu" readonly="true"
|
|
|
|
|
onget="return this.tabContainer.contextMenu;"/>
|
|
|
|
|
|
2010-03-22 17:12:04 +03:00
|
|
|
|
<field name="tabContainer" readonly="true">
|
|
|
|
|
document.getElementById(this.getAttribute("tabcontainer"));
|
|
|
|
|
</field>
|
|
|
|
|
<field name="tabs" readonly="true">
|
|
|
|
|
this.tabContainer.childNodes;
|
|
|
|
|
</field>
|
2010-08-17 22:39:17 +04:00
|
|
|
|
<property name="visibleTabs" readonly="true">
|
|
|
|
|
<getter><![CDATA[
|
|
|
|
|
return Array.filter(this.tabs, function(tab) {
|
2011-05-25 10:50:44 +04:00
|
|
|
|
return !tab.hidden && !tab.closing;
|
2011-07-05 18:57:32 +04:00
|
|
|
|
});
|
2010-08-17 22:39:17 +04:00
|
|
|
|
]]></getter>
|
|
|
|
|
</property>
|
2007-08-22 08:59:55 +04:00
|
|
|
|
<field name="mURIFixup" readonly="true">
|
|
|
|
|
Components.classes["@mozilla.org/docshell/urifixup;1"]
|
|
|
|
|
.getService(Components.interfaces.nsIURIFixup);
|
|
|
|
|
</field>
|
2007-10-10 09:03:52 +04:00
|
|
|
|
<field name="mFaviconService" readonly="true">
|
|
|
|
|
Components.classes["@mozilla.org/browser/favicon-service;1"]
|
|
|
|
|
.getService(Components.interfaces.nsIFaviconService);
|
|
|
|
|
</field>
|
2010-11-29 14:44:43 +03:00
|
|
|
|
<field name="_placesAutocomplete" readonly="true">
|
2010-11-20 03:39:55 +03:00
|
|
|
|
Components.classes["@mozilla.org/autocomplete/search;1?name=history"]
|
|
|
|
|
.getService(Components.interfaces.mozIPlacesAutoComplete);
|
2010-03-27 00:59:02 +03:00
|
|
|
|
</field>
|
2007-08-22 09:01:04 +04:00
|
|
|
|
<field name="mTabBox" readonly="true">
|
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "tabbox");
|
2007-08-22 08:58:49 +04:00
|
|
|
|
</field>
|
2007-08-22 09:01:04 +04:00
|
|
|
|
<field name="mPanelContainer" readonly="true">
|
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "panelcontainer");
|
2007-08-22 09:00:10 +04:00
|
|
|
|
</field>
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<field name="mStringBundle">
|
2007-08-22 09:01:04 +04:00
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "tbstringbundle");
|
2007-08-22 08:58:49 +04:00
|
|
|
|
</field>
|
|
|
|
|
<field name="mCurrentTab">
|
|
|
|
|
null
|
|
|
|
|
</field>
|
2009-09-04 18:37:17 +04:00
|
|
|
|
<field name="_lastRelatedTab">
|
|
|
|
|
null
|
|
|
|
|
</field>
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<field name="mCurrentBrowser">
|
|
|
|
|
null
|
|
|
|
|
</field>
|
|
|
|
|
<field name="mProgressListeners">
|
2007-08-22 09:01:04 +04:00
|
|
|
|
[]
|
2007-08-22 08:58:49 +04:00
|
|
|
|
</field>
|
2008-11-18 13:53:25 +03:00
|
|
|
|
<field name="mTabsProgressListeners">
|
|
|
|
|
[]
|
|
|
|
|
</field>
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<field name="mTabListeners">
|
2011-03-23 14:31:35 +03:00
|
|
|
|
[]
|
2007-08-22 08:58:49 +04:00
|
|
|
|
</field>
|
|
|
|
|
<field name="mTabFilters">
|
2011-03-23 14:31:35 +03:00
|
|
|
|
[]
|
2007-08-22 08:58:49 +04:00
|
|
|
|
</field>
|
|
|
|
|
<field name="mIsBusy">
|
|
|
|
|
false
|
|
|
|
|
</field>
|
2007-08-22 09:00:10 +04:00
|
|
|
|
<field name="arrowKeysShouldWrap" readonly="true">
|
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
|
true
|
|
|
|
|
#else
|
|
|
|
|
false
|
|
|
|
|
#endif
|
2007-08-22 09:00:55 +04:00
|
|
|
|
</field>
|
2011-05-19 13:53:27 +04:00
|
|
|
|
<field name="mAddProgressListenerWasCalled">
|
|
|
|
|
false
|
|
|
|
|
</field>
|
2007-08-22 09:01:17 +04:00
|
|
|
|
<field name="_browsers">
|
|
|
|
|
null
|
|
|
|
|
</field>
|
2007-08-22 09:00:10 +04:00
|
|
|
|
|
2007-08-22 09:02:41 +04:00
|
|
|
|
<field name="_autoScrollPopup">
|
|
|
|
|
null
|
|
|
|
|
</field>
|
2007-08-22 09:01:33 +04:00
|
|
|
|
|
2009-10-06 08:26:15 +04:00
|
|
|
|
<field name="_previewMode">
|
|
|
|
|
false
|
|
|
|
|
</field>
|
|
|
|
|
|
2010-06-24 18:29:02 +04:00
|
|
|
|
<property name="_numPinnedTabs" readonly="true">
|
|
|
|
|
<getter><![CDATA[
|
|
|
|
|
for (var i = 0; i < this.tabs.length; i++) {
|
|
|
|
|
if (!this.tabs[i].pinned)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return i;
|
|
|
|
|
]]></getter>
|
|
|
|
|
</property>
|
|
|
|
|
|
2011-01-17 17:35:32 +03:00
|
|
|
|
<method name="updateWindowResizers">
|
|
|
|
|
<body><![CDATA[
|
|
|
|
|
if (!window.gShowPageResizers)
|
|
|
|
|
return;
|
|
|
|
|
|
2011-01-25 22:21:56 +03:00
|
|
|
|
var show = document.getElementById("addon-bar").collapsed &&
|
|
|
|
|
window.windowState == window.STATE_NORMAL;
|
2011-01-17 17:35:32 +03:00
|
|
|
|
for (let i = 0; i < this.browsers.length; i++) {
|
|
|
|
|
this.browsers[i].showWindowResizer = show;
|
|
|
|
|
}
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2011-02-07 16:54:26 +03:00
|
|
|
|
<method name="_setCloseKeyState">
|
|
|
|
|
<parameter name="aEnabled"/>
|
|
|
|
|
<body><![CDATA[
|
|
|
|
|
let keyClose = document.getElementById("key_close");
|
|
|
|
|
let closeKeyEnabled = keyClose.getAttribute("disabled") != "true";
|
|
|
|
|
if (closeKeyEnabled == aEnabled)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (aEnabled)
|
|
|
|
|
keyClose.removeAttribute("disabled");
|
|
|
|
|
else
|
|
|
|
|
keyClose.setAttribute("disabled", "true");
|
|
|
|
|
|
|
|
|
|
// We also want to remove the keyboard shortcut from the file menu
|
|
|
|
|
// when the shortcut is disabled, and bring it back when it's
|
|
|
|
|
// renabled.
|
|
|
|
|
//
|
|
|
|
|
// Fixing bug 630826 could make that happen automatically.
|
|
|
|
|
// Fixing bug 630830 could avoid the ugly hack below.
|
2011-05-25 10:50:44 +04:00
|
|
|
|
|
2011-02-07 16:54:26 +03:00
|
|
|
|
let closeMenuItem = document.getElementById("menu_close");
|
|
|
|
|
let parentPopup = closeMenuItem.parentNode;
|
|
|
|
|
let nextItem = closeMenuItem.nextSibling;
|
|
|
|
|
let clonedItem = closeMenuItem.cloneNode(true);
|
|
|
|
|
|
|
|
|
|
parentPopup.removeChild(closeMenuItem);
|
|
|
|
|
|
|
|
|
|
if (aEnabled)
|
|
|
|
|
clonedItem.setAttribute("key", "key_close");
|
|
|
|
|
else
|
|
|
|
|
clonedItem.removeAttribute("key");
|
|
|
|
|
|
|
|
|
|
parentPopup.insertBefore(clonedItem, nextItem);
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2010-06-24 18:29:02 +04:00
|
|
|
|
<method name="pinTab">
|
|
|
|
|
<parameter name="aTab"/>
|
|
|
|
|
<body><![CDATA[
|
|
|
|
|
if (aTab.pinned)
|
|
|
|
|
return;
|
|
|
|
|
|
2010-10-11 21:27:05 +04:00
|
|
|
|
if (aTab.hidden)
|
|
|
|
|
this.showTab(aTab);
|
|
|
|
|
|
2010-06-24 18:29:02 +04:00
|
|
|
|
this.moveTabTo(aTab, this._numPinnedTabs);
|
|
|
|
|
aTab.setAttribute("pinned", "true");
|
2011-04-12 10:50:56 +04:00
|
|
|
|
this.tabContainer._unlockTabSizing();
|
2010-06-24 18:29:02 +04:00
|
|
|
|
this.tabContainer._positionPinnedTabs();
|
2010-08-24 00:30:58 +04:00
|
|
|
|
this.tabContainer.adjustTabstrip();
|
2010-09-09 04:15:24 +04:00
|
|
|
|
|
2010-10-29 02:00:31 +04:00
|
|
|
|
this.getBrowserForTab(aTab).docShell.isAppTab = true;
|
|
|
|
|
|
2011-02-07 16:54:26 +03:00
|
|
|
|
if (aTab.selected)
|
|
|
|
|
this._setCloseKeyState(false);
|
|
|
|
|
|
2010-09-09 04:15:24 +04:00
|
|
|
|
let event = document.createEvent("Events");
|
2010-09-11 14:11:25 +04:00
|
|
|
|
event.initEvent("TabPinned", true, false);
|
2010-09-09 04:15:24 +04:00
|
|
|
|
aTab.dispatchEvent(event);
|
2010-06-24 18:29:02 +04:00
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="unpinTab">
|
|
|
|
|
<parameter name="aTab"/>
|
|
|
|
|
<body><![CDATA[
|
|
|
|
|
if (!aTab.pinned)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
this.moveTabTo(aTab, this._numPinnedTabs - 1);
|
2010-08-06 00:18:17 +04:00
|
|
|
|
aTab.setAttribute("fadein", "true");
|
2010-06-24 18:29:02 +04:00
|
|
|
|
aTab.removeAttribute("pinned");
|
|
|
|
|
aTab.style.MozMarginStart = "";
|
2011-04-12 10:50:56 +04:00
|
|
|
|
this.tabContainer._unlockTabSizing();
|
2010-06-24 18:29:02 +04:00
|
|
|
|
this.tabContainer._positionPinnedTabs();
|
2010-08-24 00:30:58 +04:00
|
|
|
|
this.tabContainer.adjustTabstrip();
|
2010-09-09 04:15:24 +04:00
|
|
|
|
|
2010-10-29 02:00:31 +04:00
|
|
|
|
this.getBrowserForTab(aTab).docShell.isAppTab = false;
|
|
|
|
|
|
2011-02-07 16:54:26 +03:00
|
|
|
|
if (aTab.selected)
|
|
|
|
|
this._setCloseKeyState(true);
|
|
|
|
|
|
2010-09-09 04:15:24 +04:00
|
|
|
|
let event = document.createEvent("Events");
|
2010-09-11 14:11:25 +04:00
|
|
|
|
event.initEvent("TabUnpinned", true, false);
|
2010-09-09 04:15:24 +04:00
|
|
|
|
aTab.dispatchEvent(event);
|
2010-06-24 18:29:02 +04:00
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2009-10-06 08:26:15 +04:00
|
|
|
|
<method name="previewTab">
|
|
|
|
|
<parameter name="aTab"/>
|
|
|
|
|
<parameter name="aCallback"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
let currentTab = this.selectedTab;
|
|
|
|
|
try {
|
|
|
|
|
// Suppress focus, ownership and selected tab changes
|
|
|
|
|
this._previewMode = true;
|
|
|
|
|
this.selectedTab = aTab;
|
|
|
|
|
aCallback();
|
|
|
|
|
} finally {
|
|
|
|
|
this.selectedTab = currentTab;
|
|
|
|
|
this._previewMode = false;
|
|
|
|
|
}
|
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2007-08-22 08:59:41 +04:00
|
|
|
|
<method name="getBrowserAtIndex">
|
|
|
|
|
<parameter name="aIndex"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2007-11-20 10:58:58 +03:00
|
|
|
|
return this.browsers[aIndex];
|
2007-08-22 08:59:41 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="getBrowserIndexForDocument">
|
|
|
|
|
<parameter name="aDocument"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2010-02-26 10:58:46 +03:00
|
|
|
|
var tab = this._getTabForContentWindow(aDocument.defaultView);
|
|
|
|
|
return tab ? tab._tPos : -1;
|
2007-08-22 08:59:41 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
2007-08-22 09:00:55 +04:00
|
|
|
|
|
2007-08-22 09:01:15 +04:00
|
|
|
|
<method name="getBrowserForDocument">
|
|
|
|
|
<parameter name="aDocument"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2010-02-26 10:58:46 +03:00
|
|
|
|
var tab = this._getTabForContentWindow(aDocument.defaultView);
|
|
|
|
|
return tab ? tab.linkedBrowser : null;
|
2007-08-22 09:01:15 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2010-02-26 10:58:46 +03:00
|
|
|
|
<method name="_getTabForContentWindow">
|
|
|
|
|
<parameter name="aWindow"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
for (let i = 0; i < this.browsers.length; i++) {
|
|
|
|
|
if (this.browsers[i].contentWindow == aWindow)
|
2010-03-22 17:12:04 +03:00
|
|
|
|
return this.tabs[i];
|
2010-02-26 10:58:46 +03:00
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2007-08-22 09:01:12 +04:00
|
|
|
|
<method name="getNotificationBox">
|
2007-08-22 08:59:41 +04:00
|
|
|
|
<parameter name="aBrowser"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2010-09-16 07:01:00 +04:00
|
|
|
|
return (aBrowser || this.mCurrentBrowser).parentNode.parentNode;
|
2007-08-22 08:59:41 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
2007-08-22 08:58:49 +04:00
|
|
|
|
|
2010-11-20 08:23:25 +03:00
|
|
|
|
<method name="getTabModalPromptBox">
|
|
|
|
|
<parameter name="aBrowser"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
|
|
|
|
let browser = (aBrowser || this.mCurrentBrowser);
|
|
|
|
|
let stack = browser.parentNode;
|
|
|
|
|
let self = this;
|
|
|
|
|
|
|
|
|
|
let promptBox = {
|
|
|
|
|
appendPrompt : function(args, onCloseCallback) {
|
|
|
|
|
let newPrompt = document.createElementNS(XUL_NS, "tabmodalprompt");
|
|
|
|
|
stack.appendChild(newPrompt);
|
2011-04-20 01:18:17 +04:00
|
|
|
|
browser.setAttribute("tabmodalPromptShowing", true);
|
|
|
|
|
|
2010-11-20 08:23:25 +03:00
|
|
|
|
newPrompt.clientTop; // style flush to assure binding is attached
|
|
|
|
|
|
|
|
|
|
let tab = self._getTabForContentWindow(browser.contentWindow);
|
|
|
|
|
newPrompt.init(args, tab, onCloseCallback);
|
|
|
|
|
return newPrompt;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
removePrompt : function(aPrompt) {
|
|
|
|
|
stack.removeChild(aPrompt);
|
2011-04-20 01:18:17 +04:00
|
|
|
|
|
|
|
|
|
let prompts = this.listPrompts();
|
|
|
|
|
if (prompts.length) {
|
|
|
|
|
let prompt = prompts[prompts.length - 1];
|
|
|
|
|
prompt.Dialog.setDefaultFocus();
|
|
|
|
|
} else {
|
|
|
|
|
browser.removeAttribute("tabmodalPromptShowing");
|
|
|
|
|
browser.focus();
|
|
|
|
|
}
|
2010-11-20 08:23:25 +03:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
listPrompts : function(aPrompt) {
|
|
|
|
|
let els = stack.getElementsByTagNameNS(XUL_NS, "tabmodalprompt");
|
|
|
|
|
// NodeList --> real JS array
|
2011-04-20 01:18:17 +04:00
|
|
|
|
let prompts = Array.slice(els);
|
2010-11-20 08:23:25 +03:00
|
|
|
|
return prompts;
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return promptBox;
|
|
|
|
|
]]>
|
2007-08-22 08:59:41 +04:00
|
|
|
|
</body>
|
|
|
|
|
</method>
|
2007-08-22 08:58:49 +04:00
|
|
|
|
|
2010-07-07 08:56:17 +04:00
|
|
|
|
<method name="_callProgressListeners">
|
|
|
|
|
<parameter name="aBrowser"/>
|
|
|
|
|
<parameter name="aMethod"/>
|
|
|
|
|
<parameter name="aArguments"/>
|
|
|
|
|
<parameter name="aCallGlobalListeners"/>
|
|
|
|
|
<parameter name="aCallTabsListeners"/>
|
|
|
|
|
<body><![CDATA[
|
|
|
|
|
var rv = true;
|
|
|
|
|
|
|
|
|
|
if (!aBrowser)
|
|
|
|
|
aBrowser = this.mCurrentBrowser;
|
|
|
|
|
|
|
|
|
|
if (aCallGlobalListeners != false &&
|
|
|
|
|
aBrowser == this.mCurrentBrowser) {
|
|
|
|
|
this.mProgressListeners.forEach(function (p) {
|
|
|
|
|
if (aMethod in p) {
|
|
|
|
|
try {
|
|
|
|
|
if (!p[aMethod].apply(p, aArguments))
|
|
|
|
|
rv = false;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
// don't inhibit other listeners
|
|
|
|
|
Components.utils.reportError(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (aCallTabsListeners != false) {
|
|
|
|
|
aArguments.unshift(aBrowser);
|
|
|
|
|
|
|
|
|
|
this.mTabsProgressListeners.forEach(function (p) {
|
|
|
|
|
if (aMethod in p) {
|
|
|
|
|
try {
|
|
|
|
|
if (!p[aMethod].apply(p, aArguments))
|
|
|
|
|
rv = false;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
// don't inhibit other listeners
|
|
|
|
|
Components.utils.reportError(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
bug 213228: new toolkit independence bug, part 7: update and use the new toolkit widgetry. tabbrowser.xml: bug 205341, 112697, 210760 by jag, bug 121234, 133503 by neil, bug 206668 by shliang. not ported: bug 169589, [mac] ctrl-tab no longer moves btwn frames bug 203960, go back group bug 104778, remember what user typed when switching tabs. bug 103720, prefill URI when opening new tab.
2007-08-22 08:59:18 +04:00
|
|
|
|
<!-- A web progress listener object definition for a given tab. -->
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<method name="mTabProgressListener">
|
|
|
|
|
<parameter name="aTab"/>
|
2007-08-22 08:59:22 +04:00
|
|
|
|
<parameter name="aBrowser"/>
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<parameter name="aStartsBlank"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
return ({
|
2007-08-22 08:59:22 +04:00
|
|
|
|
mTabBrowser: this,
|
2007-08-22 08:58:49 +04:00
|
|
|
|
mTab: aTab,
|
2007-08-22 08:59:22 +04:00
|
|
|
|
mBrowser: aBrowser,
|
2007-08-22 08:58:49 +04:00
|
|
|
|
mBlank: aStartsBlank,
|
|
|
|
|
|
2010-09-16 10:09:27 +04:00
|
|
|
|
// cache flags for correct status UI update after tab switching
|
2007-08-22 09:01:05 +04:00
|
|
|
|
mStateFlags: 0,
|
|
|
|
|
mStatus: 0,
|
|
|
|
|
mMessage: "",
|
|
|
|
|
mTotalProgress: 0,
|
|
|
|
|
|
2007-08-22 09:01:09 +04:00
|
|
|
|
// count of open requests (should always be 0 or 1)
|
|
|
|
|
mRequestCount: 0,
|
|
|
|
|
|
2009-10-01 16:31:24 +04:00
|
|
|
|
destroy: function () {
|
2009-10-01 19:00:06 +04:00
|
|
|
|
delete this.mTab;
|
|
|
|
|
delete this.mBrowser;
|
|
|
|
|
delete this.mTabBrowser;
|
2009-10-01 16:31:24 +04:00
|
|
|
|
},
|
|
|
|
|
|
2010-07-07 08:56:17 +04:00
|
|
|
|
_callProgressListeners: function () {
|
|
|
|
|
Array.unshift(arguments, this.mBrowser);
|
|
|
|
|
return this.mTabBrowser._callProgressListeners.apply(this.mTabBrowser, arguments);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onProgressChange: function (aWebProgress, aRequest,
|
|
|
|
|
aCurSelfProgress, aMaxSelfProgress,
|
|
|
|
|
aCurTotalProgress, aMaxTotalProgress) {
|
2008-11-18 13:53:25 +03:00
|
|
|
|
this.mTotalProgress = aMaxTotalProgress ? aCurTotalProgress / aMaxTotalProgress : 0;
|
|
|
|
|
|
|
|
|
|
if (this.mBlank)
|
|
|
|
|
return;
|
|
|
|
|
|
2010-10-12 07:47:59 +04:00
|
|
|
|
if (this.mTotalProgress)
|
|
|
|
|
this.mTab.setAttribute("progress", "true");
|
2009-10-01 16:31:24 +04:00
|
|
|
|
|
2010-07-07 08:56:17 +04:00
|
|
|
|
this._callProgressListeners("onProgressChange",
|
|
|
|
|
[aWebProgress, aRequest,
|
|
|
|
|
aCurSelfProgress, aMaxSelfProgress,
|
|
|
|
|
aCurTotalProgress, aMaxTotalProgress]);
|
2007-08-22 08:58:49 +04:00
|
|
|
|
},
|
bug 213228: new toolkit independence bug, part 7: update and use the new toolkit widgetry. tabbrowser.xml: bug 205341, 112697, 210760 by jag, bug 121234, 133503 by neil, bug 206668 by shliang. not ported: bug 169589, [mac] ctrl-tab no longer moves btwn frames bug 203960, go back group bug 104778, remember what user typed when switching tabs. bug 103720, prefill URI when opening new tab.
2007-08-22 08:59:18 +04:00
|
|
|
|
|
2010-07-07 08:56:17 +04:00
|
|
|
|
onProgressChange64: function (aWebProgress, aRequest,
|
|
|
|
|
aCurSelfProgress, aMaxSelfProgress,
|
|
|
|
|
aCurTotalProgress, aMaxTotalProgress) {
|
2007-08-22 09:02:29 +04:00
|
|
|
|
return this.onProgressChange(aWebProgress, aRequest,
|
|
|
|
|
aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress,
|
|
|
|
|
aMaxTotalProgress);
|
|
|
|
|
},
|
|
|
|
|
|
2010-07-07 08:56:17 +04:00
|
|
|
|
onStateChange: function (aWebProgress, aRequest, aStateFlags, aStatus) {
|
2007-08-22 08:58:49 +04:00
|
|
|
|
if (!aRequest)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var oldBlank = this.mBlank;
|
|
|
|
|
|
|
|
|
|
const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
|
|
|
|
|
const nsIChannel = Components.interfaces.nsIChannel;
|
|
|
|
|
|
2007-08-22 09:01:09 +04:00
|
|
|
|
if (aStateFlags & nsIWebProgressListener.STATE_START) {
|
|
|
|
|
this.mRequestCount++;
|
|
|
|
|
}
|
|
|
|
|
else if (aStateFlags & nsIWebProgressListener.STATE_STOP) {
|
|
|
|
|
const NS_ERROR_UNKNOWN_HOST = 2152398878;
|
|
|
|
|
if (--this.mRequestCount > 0 && aStatus == NS_ERROR_UNKNOWN_HOST) {
|
|
|
|
|
// to prevent bug 235825: wait for the request handled
|
|
|
|
|
// by the automatic keyword resolver
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// since we (try to) only handle STATE_STOP of the last request,
|
|
|
|
|
// the count of open requests should now be 0
|
|
|
|
|
this.mRequestCount = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-22 08:59:43 +04:00
|
|
|
|
if (aStateFlags & nsIWebProgressListener.STATE_START &&
|
2007-08-22 08:59:22 +04:00
|
|
|
|
aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
|
2007-08-22 08:59:31 +04:00
|
|
|
|
// It's okay to clear what the user typed when we start
|
2007-08-22 09:00:35 +04:00
|
|
|
|
// loading a document. If the user types, this counter gets
|
|
|
|
|
// set to zero, if the document load ends without an
|
|
|
|
|
// onLocationChange, this counter gets decremented
|
|
|
|
|
// (so we keep it while switching tabs after failed loads)
|
2008-01-09 07:07:42 +03:00
|
|
|
|
// We need to add 2 because loadURIWithFlags may have
|
|
|
|
|
// cancelled a pending load which would have cleared
|
|
|
|
|
// its anchor scroll detection temporary increment.
|
2007-08-22 08:59:22 +04:00
|
|
|
|
if (aWebProgress.DOMWindow == this.mBrowser.contentWindow)
|
2008-01-09 07:07:42 +03:00
|
|
|
|
this.mBrowser.userTypedClear += 2;
|
2007-08-22 08:59:22 +04:00
|
|
|
|
|
|
|
|
|
if (!this.mBlank) {
|
2009-09-09 20:31:25 +04:00
|
|
|
|
if (!(aStateFlags & nsIWebProgressListener.STATE_RESTORING)) {
|
|
|
|
|
this.mTab.setAttribute("busy", "true");
|
|
|
|
|
this.mTabBrowser.setTabTitleLoading(this.mTab);
|
|
|
|
|
}
|
2007-08-22 08:59:22 +04:00
|
|
|
|
|
2010-09-10 12:05:36 +04:00
|
|
|
|
if (this.mTab.selected)
|
2007-08-22 08:59:22 +04:00
|
|
|
|
this.mTabBrowser.mIsBusy = true;
|
|
|
|
|
}
|
2007-08-22 08:58:49 +04:00
|
|
|
|
}
|
|
|
|
|
else if (aStateFlags & nsIWebProgressListener.STATE_STOP &&
|
|
|
|
|
aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
|
2007-08-22 09:00:14 +04:00
|
|
|
|
if (aWebProgress.DOMWindow == this.mBrowser.contentWindow) {
|
2007-08-22 09:00:35 +04:00
|
|
|
|
// The document is done loading, we no longer want the
|
|
|
|
|
// value cleared.
|
2008-01-09 07:07:42 +03:00
|
|
|
|
if (this.mBrowser.userTypedClear > 1)
|
|
|
|
|
this.mBrowser.userTypedClear -= 2;
|
|
|
|
|
else if (this.mBrowser.userTypedClear > 0)
|
2007-08-22 09:00:35 +04:00
|
|
|
|
this.mBrowser.userTypedClear--;
|
2007-08-22 08:59:31 +04:00
|
|
|
|
|
2007-08-22 09:00:14 +04:00
|
|
|
|
if (!this.mBrowser.mIconURL)
|
|
|
|
|
this.mTabBrowser.useDefaultIcon(this.mTab);
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
if (this.mBlank)
|
|
|
|
|
this.mBlank = false;
|
bug 213228: new toolkit independence bug, part 7: update and use the new toolkit widgetry. tabbrowser.xml: bug 205341, 112697, 210760 by jag, bug 121234, 133503 by neil, bug 206668 by shliang. not ported: bug 169589, [mac] ctrl-tab no longer moves btwn frames bug 203960, go back group bug 104778, remember what user typed when switching tabs. bug 103720, prefill URI when opening new tab.
2007-08-22 08:59:18 +04:00
|
|
|
|
|
2011-09-16 21:42:32 +04:00
|
|
|
|
if (this.mTab.hasAttribute("busy")) {
|
|
|
|
|
this.mTab.removeAttribute("busy");
|
|
|
|
|
this.mTabBrowser._tabAttrModified(this.mTab);
|
2011-10-08 12:33:45 +04:00
|
|
|
|
if (!this.mTab.selected)
|
|
|
|
|
this.mTab.setAttribute("unread", "true");
|
2011-09-16 21:42:32 +04:00
|
|
|
|
}
|
2010-10-12 07:47:59 +04:00
|
|
|
|
this.mTab.removeAttribute("progress");
|
bug 213228: new toolkit independence bug, part 7: update and use the new toolkit widgetry. tabbrowser.xml: bug 205341, 112697, 210760 by jag, bug 121234, 133503 by neil, bug 206668 by shliang. not ported: bug 169589, [mac] ctrl-tab no longer moves btwn frames bug 203960, go back group bug 104778, remember what user typed when switching tabs. bug 103720, prefill URI when opening new tab.
2007-08-22 08:59:18 +04:00
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
var location = aRequest.QueryInterface(nsIChannel).URI;
|
2007-08-22 08:59:41 +04:00
|
|
|
|
|
|
|
|
|
// For keyword URIs clear the user typed value since they will be changed into real URIs
|
|
|
|
|
if (location.scheme == "keyword")
|
|
|
|
|
this.mBrowser.userTypedValue = null;
|
|
|
|
|
|
2010-10-13 01:25:17 +04:00
|
|
|
|
if (this.mTab.label == this.mTabBrowser.mStringBundle.getString("tabs.connecting"))
|
2007-08-22 08:58:49 +04:00
|
|
|
|
this.mTabBrowser.setTabTitle(this.mTab);
|
|
|
|
|
|
2010-09-10 12:05:36 +04:00
|
|
|
|
if (this.mTab.selected)
|
2007-08-22 08:58:49 +04:00
|
|
|
|
this.mTabBrowser.mIsBusy = false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-07 08:56:17 +04:00
|
|
|
|
if (oldBlank) {
|
|
|
|
|
this._callProgressListeners("onUpdateCurrentBrowser",
|
|
|
|
|
[aStateFlags, aStatus, "", 0],
|
|
|
|
|
true, false);
|
|
|
|
|
} else {
|
|
|
|
|
this._callProgressListeners("onStateChange",
|
|
|
|
|
[aWebProgress, aRequest, aStateFlags, aStatus],
|
|
|
|
|
true, false);
|
2007-08-22 08:58:49 +04:00
|
|
|
|
}
|
2007-08-22 09:01:05 +04:00
|
|
|
|
|
2010-07-07 08:56:17 +04:00
|
|
|
|
this._callProgressListeners("onStateChange",
|
|
|
|
|
[aWebProgress, aRequest, aStateFlags, aStatus],
|
|
|
|
|
false);
|
2008-11-18 13:53:25 +03:00
|
|
|
|
|
2007-08-22 09:01:05 +04:00
|
|
|
|
if (aStateFlags & (nsIWebProgressListener.STATE_START |
|
|
|
|
|
nsIWebProgressListener.STATE_STOP)) {
|
|
|
|
|
// reset cached temporary values at beginning and end
|
|
|
|
|
this.mMessage = "";
|
|
|
|
|
this.mTotalProgress = 0;
|
|
|
|
|
}
|
|
|
|
|
this.mStateFlags = aStateFlags;
|
|
|
|
|
this.mStatus = aStatus;
|
2007-08-22 08:59:43 +04:00
|
|
|
|
},
|
2007-08-22 08:58:49 +04:00
|
|
|
|
|
2010-07-07 08:56:17 +04:00
|
|
|
|
onLocationChange: function (aWebProgress, aRequest, aLocation) {
|
2010-08-09 19:59:31 +04:00
|
|
|
|
// OnLocationChange is called for both the top-level content
|
|
|
|
|
// and the subframes.
|
|
|
|
|
let topLevel = aWebProgress.DOMWindow == this.mBrowser.contentWindow;
|
|
|
|
|
|
|
|
|
|
if (topLevel) {
|
|
|
|
|
// The document loaded correctly, clear the value if we should
|
|
|
|
|
if (this.mBrowser.userTypedClear > 0)
|
|
|
|
|
this.mBrowser.userTypedValue = null;
|
2007-08-22 09:00:14 +04:00
|
|
|
|
|
2010-08-09 19:59:31 +04:00
|
|
|
|
// Clear out the missing plugins list since it's related to the
|
|
|
|
|
// previous location.
|
|
|
|
|
this.mBrowser.missingPlugins = null;
|
2007-08-22 09:01:14 +04:00
|
|
|
|
|
2010-08-09 19:59:31 +04:00
|
|
|
|
// Don't clear the favicon if this onLocationChange was
|
|
|
|
|
// triggered by a pushState or a replaceState. See bug 550565.
|
|
|
|
|
if (aWebProgress.isLoadingDocument &&
|
|
|
|
|
!(this.mBrowser.docShell.loadType & Ci.nsIDocShell.LOAD_CMD_PUSHSTATE))
|
|
|
|
|
this.mBrowser.mIconURL = null;
|
|
|
|
|
|
2010-11-29 14:44:43 +03:00
|
|
|
|
let autocomplete = this.mTabBrowser._placesAutocomplete;
|
2010-08-14 05:52:30 +04:00
|
|
|
|
if (this.mBrowser.registeredOpenURI) {
|
2010-11-20 03:39:55 +03:00
|
|
|
|
autocomplete.unregisterOpenPage(this.mBrowser.registeredOpenURI);
|
2010-08-14 05:52:30 +04:00
|
|
|
|
delete this.mBrowser.registeredOpenURI;
|
|
|
|
|
}
|
2010-11-07 15:59:28 +03:00
|
|
|
|
if (aLocation.spec != "about:blank") {
|
2010-11-20 03:39:55 +03:00
|
|
|
|
autocomplete.registerOpenPage(aLocation);
|
2010-11-07 15:59:28 +03:00
|
|
|
|
this.mBrowser.registeredOpenURI = aLocation;
|
|
|
|
|
}
|
2010-08-09 19:59:31 +04:00
|
|
|
|
}
|
2010-03-27 00:59:02 +03:00
|
|
|
|
|
|
|
|
|
if (!this.mBlank) {
|
2010-07-07 08:56:17 +04:00
|
|
|
|
this._callProgressListeners("onLocationChange",
|
|
|
|
|
[aWebProgress, aRequest, aLocation]);
|
2007-08-22 08:58:49 +04:00
|
|
|
|
}
|
2008-11-18 13:53:25 +03:00
|
|
|
|
|
2010-08-09 19:59:31 +04:00
|
|
|
|
if (topLevel)
|
|
|
|
|
this.mBrowser.lastURI = aLocation;
|
2007-08-22 08:58:49 +04:00
|
|
|
|
},
|
|
|
|
|
|
2010-07-07 08:56:17 +04:00
|
|
|
|
onStatusChange: function (aWebProgress, aRequest, aStatus, aMessage) {
|
bug 213228: new toolkit independence bug, part 7: update and use the new toolkit widgetry. tabbrowser.xml: bug 205341, 112697, 210760 by jag, bug 121234, 133503 by neil, bug 206668 by shliang. not ported: bug 169589, [mac] ctrl-tab no longer moves btwn frames bug 203960, go back group bug 104778, remember what user typed when switching tabs. bug 103720, prefill URI when opening new tab.
2007-08-22 08:59:18 +04:00
|
|
|
|
if (this.mBlank)
|
2007-08-22 08:58:49 +04:00
|
|
|
|
return;
|
bug 213228: new toolkit independence bug, part 7: update and use the new toolkit widgetry. tabbrowser.xml: bug 205341, 112697, 210760 by jag, bug 121234, 133503 by neil, bug 206668 by shliang. not ported: bug 169589, [mac] ctrl-tab no longer moves btwn frames bug 203960, go back group bug 104778, remember what user typed when switching tabs. bug 103720, prefill URI when opening new tab.
2007-08-22 08:59:18 +04:00
|
|
|
|
|
2010-07-07 08:56:17 +04:00
|
|
|
|
this._callProgressListeners("onStatusChange",
|
|
|
|
|
[aWebProgress, aRequest, aStatus, aMessage]);
|
2008-11-18 13:53:25 +03:00
|
|
|
|
|
2007-08-22 09:01:05 +04:00
|
|
|
|
this.mMessage = aMessage;
|
2007-08-22 08:58:49 +04:00
|
|
|
|
},
|
|
|
|
|
|
2010-07-07 08:56:17 +04:00
|
|
|
|
onSecurityChange: function (aWebProgress, aRequest, aState) {
|
|
|
|
|
this._callProgressListeners("onSecurityChange",
|
|
|
|
|
[aWebProgress, aRequest, aState]);
|
2008-11-18 13:53:25 +03:00
|
|
|
|
},
|
|
|
|
|
|
2010-07-07 08:56:17 +04:00
|
|
|
|
onRefreshAttempted: function (aWebProgress, aURI, aDelay, aSameURI) {
|
|
|
|
|
return this._callProgressListeners("onRefreshAttempted",
|
|
|
|
|
[aWebProgress, aURI, aDelay, aSameURI]);
|
2007-08-22 08:58:49 +04:00
|
|
|
|
},
|
|
|
|
|
|
2010-07-07 08:56:17 +04:00
|
|
|
|
QueryInterface: function (aIID) {
|
2007-08-22 08:58:49 +04:00
|
|
|
|
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
|
2007-08-22 09:02:29 +04:00
|
|
|
|
aIID.equals(Components.interfaces.nsIWebProgressListener2) ||
|
2007-08-22 08:58:49 +04:00
|
|
|
|
aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
|
|
|
|
|
aIID.equals(Components.interfaces.nsISupports))
|
|
|
|
|
return this;
|
|
|
|
|
throw Components.results.NS_NOINTERFACE;
|
|
|
|
|
}
|
2007-08-22 08:59:43 +04:00
|
|
|
|
});
|
2007-08-22 08:58:49 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
2007-08-22 09:00:55 +04:00
|
|
|
|
|
2007-08-22 09:00:14 +04:00
|
|
|
|
<method name="setIcon">
|
|
|
|
|
<parameter name="aTab"/>
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<parameter name="aURI"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2007-08-22 09:00:14 +04:00
|
|
|
|
var browser = this.getBrowserForTab(aTab);
|
2009-07-29 09:55:18 +04:00
|
|
|
|
browser.mIconURL = aURI instanceof Ci.nsIURI ? aURI.spec : aURI;
|
2007-08-22 09:00:14 +04:00
|
|
|
|
|
2009-07-29 09:55:18 +04:00
|
|
|
|
if (aURI && this.mFaviconService) {
|
|
|
|
|
if (!(aURI instanceof Ci.nsIURI))
|
|
|
|
|
aURI = makeURI(aURI);
|
|
|
|
|
this.mFaviconService.setAndLoadFaviconForPage(browser.currentURI,
|
|
|
|
|
aURI, false);
|
2007-10-10 09:03:52 +04:00
|
|
|
|
}
|
|
|
|
|
|
2010-09-24 11:29:50 +04:00
|
|
|
|
if ((browser.mIconURL || "") != aTab.getAttribute("image")) {
|
|
|
|
|
if (browser.mIconURL)
|
|
|
|
|
aTab.setAttribute("image", browser.mIconURL);
|
|
|
|
|
else
|
|
|
|
|
aTab.removeAttribute("image");
|
|
|
|
|
this._tabAttrModified(aTab);
|
|
|
|
|
}
|
2007-08-22 09:00:14 +04:00
|
|
|
|
|
2010-07-07 08:56:17 +04:00
|
|
|
|
this._callProgressListeners(browser, "onLinkIconAvailable", [browser.mIconURL]);
|
2007-08-22 09:00:14 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2009-12-15 10:49:08 +03:00
|
|
|
|
<method name="getIcon">
|
|
|
|
|
<parameter name="aTab"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
let browser = aTab ? this.getBrowserForTab(aTab) : this.selectedBrowser;
|
|
|
|
|
return browser.mIconURL;
|
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<method name="shouldLoadFavIcon">
|
|
|
|
|
<parameter name="aURI"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2010-03-21 12:38:08 +03:00
|
|
|
|
return (aURI &&
|
|
|
|
|
Services.prefs.getBoolPref("browser.chrome.site_icons") &&
|
|
|
|
|
Services.prefs.getBoolPref("browser.chrome.favicons") &&
|
2007-08-22 08:58:49 +04:00
|
|
|
|
("schemeIs" in aURI) && (aURI.schemeIs("http") || aURI.schemeIs("https")));
|
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2007-08-22 09:00:14 +04:00
|
|
|
|
<method name="useDefaultIcon">
|
|
|
|
|
<parameter name="aTab"/>
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2007-08-22 09:00:14 +04:00
|
|
|
|
var browser = this.getBrowserForTab(aTab);
|
2010-09-24 11:29:50 +04:00
|
|
|
|
var docURIObject = browser.contentDocument.documentURIObject;
|
|
|
|
|
var icon = null;
|
2007-08-22 09:00:14 +04:00
|
|
|
|
if (browser.contentDocument instanceof ImageDocument) {
|
2010-03-21 12:38:08 +03:00
|
|
|
|
if (Services.prefs.getBoolPref("browser.chrome.site_icons")) {
|
2010-09-24 11:29:50 +04:00
|
|
|
|
let sz = Services.prefs.getIntPref("browser.chrome.image_icons.max_size");
|
2007-08-22 09:00:32 +04:00
|
|
|
|
try {
|
2010-09-24 11:29:50 +04:00
|
|
|
|
let req = browser.contentDocument.imageRequest;
|
|
|
|
|
if (req &&
|
|
|
|
|
req.image &&
|
|
|
|
|
req.image.width <= sz &&
|
|
|
|
|
req.image.height <= sz)
|
|
|
|
|
icon = browser.currentURI;
|
2007-08-22 09:00:32 +04:00
|
|
|
|
} catch (e) { }
|
|
|
|
|
}
|
2007-08-22 09:00:14 +04:00
|
|
|
|
}
|
2008-10-22 00:02:26 +04:00
|
|
|
|
// Use documentURIObject in the check for shouldLoadFavIcon so that we
|
|
|
|
|
// do the right thing with about:-style error pages. Bug 453442
|
2009-09-22 22:13:58 +04:00
|
|
|
|
else if (this.shouldLoadFavIcon(docURIObject)) {
|
2010-09-24 11:29:50 +04:00
|
|
|
|
let url = docURIObject.prePath + "/favicon.ico";
|
2007-10-10 09:03:52 +04:00
|
|
|
|
if (!this.isFailedIcon(url))
|
2010-09-24 11:29:50 +04:00
|
|
|
|
icon = url;
|
2007-08-22 09:00:14 +04:00
|
|
|
|
}
|
2010-09-24 11:29:50 +04:00
|
|
|
|
this.setIcon(aTab, icon);
|
2007-08-22 08:58:49 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2007-10-10 09:03:52 +04:00
|
|
|
|
<method name="isFailedIcon">
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<parameter name="aURI"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2009-07-29 09:55:18 +04:00
|
|
|
|
if (this.mFaviconService) {
|
|
|
|
|
if (!(aURI instanceof Ci.nsIURI))
|
|
|
|
|
aURI = makeURI(aURI);
|
2008-12-30 15:44:55 +03:00
|
|
|
|
return this.mFaviconService.isFailedFavicon(aURI);
|
2009-07-29 09:55:18 +04:00
|
|
|
|
}
|
2008-12-30 15:44:55 +03:00
|
|
|
|
return null;
|
2007-08-22 08:59:41 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2010-01-17 17:04:00 +03:00
|
|
|
|
<method name="getWindowTitleForBrowser">
|
|
|
|
|
<parameter name="aBrowser"/>
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
var newTitle = "";
|
2007-08-22 09:00:43 +04:00
|
|
|
|
var docElement = this.ownerDocument.documentElement;
|
|
|
|
|
var sep = docElement.getAttribute("titlemenuseparator");
|
|
|
|
|
|
2011-06-25 01:32:27 +04:00
|
|
|
|
var docTitle = aBrowser.contentTitle;
|
2007-08-22 09:00:55 +04:00
|
|
|
|
|
2007-08-22 08:59:45 +04:00
|
|
|
|
if (!docTitle)
|
2007-08-22 09:00:43 +04:00
|
|
|
|
docTitle = docElement.getAttribute("titledefault");
|
2007-08-22 08:59:37 +04:00
|
|
|
|
|
2007-08-22 09:00:43 +04:00
|
|
|
|
var modifier = docElement.getAttribute("titlemodifier");
|
2007-08-22 08:58:49 +04:00
|
|
|
|
if (docTitle) {
|
2007-08-22 09:00:43 +04:00
|
|
|
|
newTitle += docElement.getAttribute("titlepreface");
|
2007-08-22 08:58:49 +04:00
|
|
|
|
newTitle += docTitle;
|
2007-08-22 08:59:37 +04:00
|
|
|
|
if (modifier)
|
|
|
|
|
newTitle += sep;
|
2007-08-22 08:58:49 +04:00
|
|
|
|
}
|
2007-08-22 08:59:16 +04:00
|
|
|
|
newTitle += modifier;
|
2007-08-22 09:00:55 +04:00
|
|
|
|
|
2007-08-22 09:00:43 +04:00
|
|
|
|
// If location bar is hidden and the URL type supports a host,
|
|
|
|
|
// add the scheme and host to the title to prevent spoofing.
|
|
|
|
|
// XXX https://bugzilla.mozilla.org/show_bug.cgi?id=22183#c239
|
|
|
|
|
try {
|
|
|
|
|
if (docElement.getAttribute("chromehidden").indexOf("location") != -1) {
|
2007-08-22 09:00:46 +04:00
|
|
|
|
var uri = this.mURIFixup.createExposableURI(
|
2010-01-17 17:04:00 +03:00
|
|
|
|
aBrowser.currentURI);
|
2007-08-22 09:02:33 +04:00
|
|
|
|
if (uri.scheme == "about")
|
|
|
|
|
newTitle = uri.spec + sep + newTitle;
|
|
|
|
|
else
|
2007-08-22 09:00:46 +04:00
|
|
|
|
newTitle = uri.prePath + sep + newTitle;
|
2007-08-22 09:00:43 +04:00
|
|
|
|
}
|
|
|
|
|
} catch (e) {}
|
2007-08-22 09:00:55 +04:00
|
|
|
|
|
2010-01-17 17:04:00 +03:00
|
|
|
|
return newTitle;
|
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="updateTitlebar">
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2011-04-14 08:20:17 +04:00
|
|
|
|
if ("TabView" in window && TabView.isVisible()) {
|
2010-08-11 08:14:53 +04:00
|
|
|
|
// ToDo: this will be removed when we gain ability to draw to the menu bar.
|
|
|
|
|
// Bug 586175
|
2010-08-11 23:17:57 +04:00
|
|
|
|
this.ownerDocument.title = TabView.windowTitle;
|
2010-09-14 01:05:03 +04:00
|
|
|
|
}
|
|
|
|
|
else {
|
2010-07-15 12:41:08 +04:00
|
|
|
|
this.ownerDocument.title = this.getWindowTitleForBrowser(this.mCurrentBrowser);
|
|
|
|
|
}
|
2007-08-22 08:59:41 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<method name="updateCurrentBrowser">
|
2008-11-15 22:47:53 +03:00
|
|
|
|
<parameter name="aForceUpdate"/>
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2010-03-22 17:12:04 +03:00
|
|
|
|
var newBrowser = this.getBrowserAtIndex(this.tabContainer.selectedIndex);
|
2008-11-15 22:47:53 +03:00
|
|
|
|
if (this.mCurrentBrowser == newBrowser && !aForceUpdate)
|
2007-08-22 08:58:59 +04:00
|
|
|
|
return;
|
|
|
|
|
|
2009-12-12 22:31:21 +03:00
|
|
|
|
var oldTab = this.mCurrentTab;
|
|
|
|
|
|
2009-10-06 08:26:15 +04:00
|
|
|
|
// Preview mode should not reset the owner
|
2009-12-12 22:31:21 +03:00
|
|
|
|
if (!this._previewMode && oldTab != this.selectedTab)
|
|
|
|
|
oldTab.owner = null;
|
2009-04-24 12:18:53 +04:00
|
|
|
|
|
2010-09-06 13:39:59 +04:00
|
|
|
|
if (this._lastRelatedTab) {
|
|
|
|
|
if (this._lastRelatedTab != this.selectedTab)
|
|
|
|
|
this._lastRelatedTab.owner = null;
|
|
|
|
|
this._lastRelatedTab = null;
|
|
|
|
|
}
|
2009-09-04 18:37:17 +04:00
|
|
|
|
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
var oldBrowser = this.mCurrentBrowser;
|
2010-08-05 19:27:52 +04:00
|
|
|
|
if (oldBrowser) {
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
oldBrowser.setAttribute("type", "content-targetable");
|
2011-06-25 01:32:27 +04:00
|
|
|
|
oldBrowser.docShellIsActive = false;
|
2010-08-05 19:27:52 +04:00
|
|
|
|
}
|
2007-08-22 09:00:55 +04:00
|
|
|
|
|
2007-08-22 08:59:00 +04:00
|
|
|
|
var updatePageReport = false;
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
if (!oldBrowser ||
|
|
|
|
|
(oldBrowser.pageReport && !newBrowser.pageReport) ||
|
|
|
|
|
(!oldBrowser.pageReport && newBrowser.pageReport))
|
2007-08-22 08:59:00 +04:00
|
|
|
|
updatePageReport = true;
|
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
newBrowser.setAttribute("type", "content-primary");
|
2011-07-11 17:14:08 +04:00
|
|
|
|
newBrowser.docShellIsActive =
|
|
|
|
|
(window.windowState != window.STATE_MINIMIZED);
|
2007-08-22 08:58:49 +04:00
|
|
|
|
this.mCurrentBrowser = newBrowser;
|
|
|
|
|
this.mCurrentTab = this.selectedTab;
|
2010-08-13 22:36:40 +04:00
|
|
|
|
this.showTab(this.mCurrentTab);
|
2007-08-22 09:00:55 +04:00
|
|
|
|
|
2011-10-10 12:01:33 +04:00
|
|
|
|
var backForwardContainer = document.getElementById("unified-back-forward-button");
|
|
|
|
|
if (backForwardContainer)
|
|
|
|
|
backForwardContainer.setAttribute("switchingtabs", "true");
|
|
|
|
|
|
2007-08-22 08:59:00 +04:00
|
|
|
|
if (updatePageReport)
|
|
|
|
|
this.mCurrentBrowser.updatePageReport();
|
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
// Update the URL bar.
|
|
|
|
|
var loc = this.mCurrentBrowser.currentURI;
|
2007-08-22 08:59:00 +04:00
|
|
|
|
|
2011-06-25 01:32:27 +04:00
|
|
|
|
#ifdef MOZ_E10S_COMPAT
|
|
|
|
|
// Bug 666801 - WebProgress support for e10s and
|
|
|
|
|
// Bug 666809 - SecurityUI support for e10s
|
|
|
|
|
#else
|
2007-08-22 08:58:49 +04:00
|
|
|
|
var webProgress = this.mCurrentBrowser.webProgress;
|
|
|
|
|
var securityUI = this.mCurrentBrowser.securityUI;
|
2007-08-22 09:00:50 +04:00
|
|
|
|
|
2010-07-07 08:56:17 +04:00
|
|
|
|
this._callProgressListeners(null, "onLocationChange",
|
|
|
|
|
[webProgress, null, loc], true, false);
|
|
|
|
|
|
|
|
|
|
if (securityUI) {
|
|
|
|
|
this._callProgressListeners(null, "onSecurityChange",
|
|
|
|
|
[webProgress, null, securityUI.state], true, false);
|
|
|
|
|
}
|
2011-06-25 01:32:27 +04:00
|
|
|
|
#endif
|
2010-07-07 08:56:17 +04:00
|
|
|
|
|
|
|
|
|
var listener = this.mTabListeners[this.tabContainer.selectedIndex] || null;
|
|
|
|
|
if (listener && listener.mStateFlags) {
|
|
|
|
|
this._callProgressListeners(null, "onUpdateCurrentBrowser",
|
|
|
|
|
[listener.mStateFlags, listener.mStatus,
|
|
|
|
|
listener.mMessage, listener.mTotalProgress],
|
|
|
|
|
true, false);
|
2007-08-22 08:58:49 +04:00
|
|
|
|
}
|
2007-08-22 09:00:50 +04:00
|
|
|
|
|
2010-01-17 18:48:00 +03:00
|
|
|
|
if (!this._previewMode) {
|
2011-10-08 12:34:20 +04:00
|
|
|
|
this.mCurrentTab.removeAttribute("unread");
|
|
|
|
|
|
2011-06-25 01:32:27 +04:00
|
|
|
|
#ifdef MOZ_E10S_COMPAT
|
|
|
|
|
// Bug 666816 - TypeAheadFind support for e10s
|
|
|
|
|
#else
|
2009-10-06 08:26:15 +04:00
|
|
|
|
this._fastFind.setDocShell(this.mCurrentBrowser.docShell);
|
2011-06-25 01:32:27 +04:00
|
|
|
|
#endif
|
2010-08-11 04:21:05 +04:00
|
|
|
|
|
2010-01-17 18:48:00 +03:00
|
|
|
|
this.updateTitlebar();
|
2010-09-03 00:08:37 +04:00
|
|
|
|
|
|
|
|
|
this.mCurrentTab.removeAttribute("titlechanged");
|
2010-01-17 18:48:00 +03:00
|
|
|
|
}
|
2007-08-22 08:59:43 +04:00
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
// 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;
|
2010-07-07 08:56:17 +04:00
|
|
|
|
this._callProgressListeners(null, "onStateChange",
|
|
|
|
|
[webProgress, null,
|
|
|
|
|
nsIWebProgressListener.STATE_START |
|
|
|
|
|
nsIWebProgressListener.STATE_IS_NETWORK, 0],
|
|
|
|
|
true, false);
|
2007-08-22 08:58:49 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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;
|
2010-07-07 08:56:17 +04:00
|
|
|
|
this._callProgressListeners(null, "onStateChange",
|
|
|
|
|
[webProgress, null,
|
|
|
|
|
nsIWebProgressListener.STATE_STOP |
|
|
|
|
|
nsIWebProgressListener.STATE_IS_NETWORK, 0],
|
|
|
|
|
true, false);
|
2007-08-22 08:58:49 +04:00
|
|
|
|
}
|
|
|
|
|
|
2011-10-10 12:01:33 +04:00
|
|
|
|
if (backForwardContainer)
|
|
|
|
|
backForwardContainer.removeAttribute("switchingtabs");
|
|
|
|
|
|
2011-02-07 16:54:26 +03:00
|
|
|
|
if (this.mCurrentTab.selected)
|
|
|
|
|
this._setCloseKeyState(!this.mCurrentTab.pinned);
|
|
|
|
|
|
2009-10-06 08:26:15 +04:00
|
|
|
|
// TabSelect events are suppressed during preview mode to avoid confusing extensions and other bits of code
|
|
|
|
|
// that might rely upon the other changes suppressed.
|
|
|
|
|
// Focus is suppressed in the event that the main browser window is minimized - focusing a tab would restore the window
|
|
|
|
|
if (!this._previewMode) {
|
|
|
|
|
// We've selected the new tab, so go ahead and notify listeners.
|
2010-11-09 12:25:07 +03:00
|
|
|
|
let event = document.createEvent("Events");
|
2009-10-06 08:26:15 +04:00
|
|
|
|
event.initEvent("TabSelect", true, false);
|
|
|
|
|
this.mCurrentTab.dispatchEvent(event);
|
|
|
|
|
|
2009-12-12 22:31:21 +03:00
|
|
|
|
this._tabAttrModified(oldTab);
|
|
|
|
|
this._tabAttrModified(this.mCurrentTab);
|
|
|
|
|
|
2010-11-09 12:25:07 +03:00
|
|
|
|
// Adjust focus
|
2011-07-01 14:18:23 +04:00
|
|
|
|
oldBrowser._urlbarFocused = (gURLBar && gURLBar.focused);
|
2010-11-09 12:25:07 +03:00
|
|
|
|
do {
|
2011-07-04 22:12:30 +04:00
|
|
|
|
// When focus is in the tab bar, retain it there.
|
|
|
|
|
if (document.activeElement == oldTab) {
|
|
|
|
|
// We need to explicitly focus the new tab, because
|
|
|
|
|
// tabbox.xml does this only in some cases.
|
|
|
|
|
this.mCurrentTab.focus();
|
|
|
|
|
break;
|
|
|
|
|
}
|
2011-04-20 01:18:17 +04:00
|
|
|
|
|
|
|
|
|
// If there's a tabmodal prompt showing, focus it.
|
|
|
|
|
if (newBrowser.hasAttribute("tabmodalPromptShowing")) {
|
|
|
|
|
let XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
|
|
|
|
let prompts = newBrowser.parentNode.getElementsByTagNameNS(XUL_NS, "tabmodalprompt");
|
|
|
|
|
let prompt = prompts[prompts.length - 1];
|
|
|
|
|
prompt.Dialog.setDefaultFocus();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-09 12:25:07 +03:00
|
|
|
|
// Focus the location bar if it was previously focused for that tab.
|
|
|
|
|
// In full screen mode, only bother making the location bar visible
|
|
|
|
|
// if the tab is a blank one.
|
|
|
|
|
if (newBrowser._urlbarFocused && gURLBar) {
|
2011-05-25 12:44:28 +04:00
|
|
|
|
|
|
|
|
|
// Explicitly close the popup if the URL bar retains focus
|
|
|
|
|
gURLBar.closePopup();
|
|
|
|
|
|
2010-11-09 12:25:07 +03:00
|
|
|
|
if (!window.fullScreen) {
|
|
|
|
|
gURLBar.focus();
|
|
|
|
|
break;
|
|
|
|
|
} else if (isTabEmpty(this.mCurrentTab)) {
|
|
|
|
|
focusAndSelectUrlBar();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-04-21 18:53:42 +04:00
|
|
|
|
|
2011-02-28 22:56:56 +03:00
|
|
|
|
// If the find bar is focused, keep it focused.
|
|
|
|
|
if (gFindBarInitialized &&
|
|
|
|
|
!gFindBar.hidden &&
|
|
|
|
|
gFindBar.getElement("findbar-textbox").getAttribute("focused") == "true")
|
|
|
|
|
break;
|
|
|
|
|
|
2010-11-09 12:25:07 +03:00
|
|
|
|
// Otherwise, focus the content area.
|
|
|
|
|
let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
|
|
|
|
|
let newFocusedElement = fm.getFocusedElementForWindow(window.content, true, {});
|
2010-04-21 18:53:42 +04:00
|
|
|
|
|
|
|
|
|
// for anchors, use FLAG_SHOWRING so that it is clear what link was
|
|
|
|
|
// last clicked when switching back to that tab
|
2010-11-09 12:25:07 +03:00
|
|
|
|
let focusFlags = fm.FLAG_NOSCROLL;
|
2010-04-21 18:53:42 +04:00
|
|
|
|
if (newFocusedElement &&
|
|
|
|
|
(newFocusedElement instanceof HTMLAnchorElement ||
|
|
|
|
|
newFocusedElement.getAttributeNS("http://www.w3.org/1999/xlink", "type") == "simple"))
|
|
|
|
|
focusFlags |= fm.FLAG_SHOWRING;
|
|
|
|
|
fm.setFocus(newBrowser, focusFlags);
|
2010-11-09 12:25:07 +03:00
|
|
|
|
} while (false);
|
2009-10-06 08:26:15 +04:00
|
|
|
|
}
|
2007-08-22 08:58:49 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2009-12-12 22:31:21 +03:00
|
|
|
|
<method name="_tabAttrModified">
|
|
|
|
|
<parameter name="aTab"/>
|
|
|
|
|
<body><![CDATA[
|
2011-05-25 10:50:44 +04:00
|
|
|
|
if (aTab.closing)
|
2010-09-20 22:18:04 +04:00
|
|
|
|
return;
|
|
|
|
|
|
2009-12-12 22:31:21 +03:00
|
|
|
|
// This event should be dispatched when any of these attributes change:
|
|
|
|
|
// label, crop, busy, image, selected
|
|
|
|
|
var event = document.createEvent("Events");
|
|
|
|
|
event.initEvent("TabAttrModified", true, false);
|
|
|
|
|
aTab.dispatchEvent(event);
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2007-08-22 09:00:36 +04:00
|
|
|
|
<method name="setTabTitleLoading">
|
|
|
|
|
<parameter name="aTab"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2010-10-13 01:25:17 +04:00
|
|
|
|
aTab.label = this.mStringBundle.getString("tabs.connecting");
|
2010-09-04 22:33:34 +04:00
|
|
|
|
aTab.crop = "end";
|
2009-12-12 22:31:21 +03:00
|
|
|
|
this._tabAttrModified(aTab);
|
2007-08-22 09:00:36 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<method name="setTabTitle">
|
|
|
|
|
<parameter name="aTab"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
var browser = this.getBrowserForTab(aTab);
|
|
|
|
|
var crop = "end";
|
2007-08-22 09:02:16 +04:00
|
|
|
|
var title = browser.contentTitle;
|
2007-08-22 09:00:55 +04:00
|
|
|
|
|
2007-08-22 08:59:55 +04:00
|
|
|
|
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 {
|
2007-08-22 09:00:24 +04:00
|
|
|
|
var characterSet = browser.contentDocument.characterSet;
|
2007-08-22 08:59:55 +04:00
|
|
|
|
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.
|
2010-03-18 10:04:42 +03:00
|
|
|
|
title = this.mStringBundle.getString("tabs.emptyTabTitle");
|
2007-08-22 08:58:49 +04:00
|
|
|
|
}
|
|
|
|
|
|
2010-09-04 20:51:52 +04:00
|
|
|
|
if (aTab.label == title &&
|
|
|
|
|
aTab.crop == crop)
|
|
|
|
|
return false;
|
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
aTab.label = title;
|
2010-09-04 22:33:34 +04:00
|
|
|
|
aTab.crop = crop;
|
2009-12-12 22:31:21 +03:00
|
|
|
|
this._tabAttrModified(aTab);
|
2010-09-10 12:05:36 +04:00
|
|
|
|
|
|
|
|
|
if (aTab.selected)
|
|
|
|
|
this.updateTitlebar();
|
|
|
|
|
|
2010-09-04 20:51:52 +04:00
|
|
|
|
return true;
|
2007-08-22 08:58:49 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2007-08-22 09:00:28 +04:00
|
|
|
|
<method name="loadOneTab">
|
|
|
|
|
<parameter name="aURI"/>
|
|
|
|
|
<parameter name="aReferrerURI"/>
|
|
|
|
|
<parameter name="aCharset"/>
|
|
|
|
|
<parameter name="aPostData"/>
|
|
|
|
|
<parameter name="aLoadInBackground"/>
|
2007-08-22 09:01:08 +04:00
|
|
|
|
<parameter name="aAllowThirdPartyFixup"/>
|
2007-08-22 09:00:28 +04:00
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2010-06-09 00:13:55 +04:00
|
|
|
|
var aFromExternal;
|
2009-09-15 03:33:00 +04:00
|
|
|
|
var aRelatedToCurrent;
|
|
|
|
|
if (arguments.length == 2 &&
|
|
|
|
|
typeof arguments[1] == "object" &&
|
|
|
|
|
!(arguments[1] instanceof Ci.nsIURI)) {
|
|
|
|
|
let params = arguments[1];
|
|
|
|
|
aReferrerURI = params.referrerURI;
|
|
|
|
|
aCharset = params.charset;
|
|
|
|
|
aPostData = params.postData;
|
|
|
|
|
aLoadInBackground = params.inBackground;
|
|
|
|
|
aAllowThirdPartyFixup = params.allowThirdPartyFixup;
|
2010-06-09 00:13:55 +04:00
|
|
|
|
aFromExternal = params.fromExternal;
|
2009-09-15 03:33:00 +04:00
|
|
|
|
aRelatedToCurrent = params.relatedToCurrent;
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-22 09:01:13 +04:00
|
|
|
|
var bgLoad = (aLoadInBackground != null) ? aLoadInBackground :
|
2010-03-21 12:38:08 +03:00
|
|
|
|
Services.prefs.getBoolPref("browser.tabs.loadInBackground");
|
2007-08-22 09:01:43 +04:00
|
|
|
|
var owner = bgLoad ? null : this.selectedTab;
|
2009-09-15 03:33:00 +04:00
|
|
|
|
var tab = this.addTab(aURI, {
|
|
|
|
|
referrerURI: aReferrerURI,
|
|
|
|
|
charset: aCharset,
|
|
|
|
|
postData: aPostData,
|
|
|
|
|
ownerTab: owner,
|
|
|
|
|
allowThirdPartyFixup: aAllowThirdPartyFixup,
|
2010-06-09 00:13:55 +04:00
|
|
|
|
fromExternal: aFromExternal,
|
2009-09-15 03:33:00 +04:00
|
|
|
|
relatedToCurrent: aRelatedToCurrent});
|
2007-08-22 09:00:54 +04:00
|
|
|
|
if (!bgLoad)
|
|
|
|
|
this.selectedTab = tab;
|
2008-02-13 13:21:54 +03:00
|
|
|
|
|
2007-08-22 09:00:28 +04:00
|
|
|
|
return tab;
|
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
2007-08-22 09:00:55 +04:00
|
|
|
|
|
2007-08-22 09:00:54 +04:00
|
|
|
|
<method name="loadTabs">
|
|
|
|
|
<parameter name="aURIs"/>
|
|
|
|
|
<parameter name="aLoadInBackground"/>
|
|
|
|
|
<parameter name="aReplace"/>
|
|
|
|
|
<body><![CDATA[
|
2009-01-18 13:36:01 +03:00
|
|
|
|
if (!aURIs.length)
|
|
|
|
|
return;
|
|
|
|
|
|
2007-08-22 09:00:55 +04:00
|
|
|
|
// The tab selected after this new tab is closed (i.e. the new tab's
|
2007-08-22 09:00:54 +04:00
|
|
|
|
// "owner") is the next adjacent tab (i.e. not the previously viewed tab)
|
|
|
|
|
// when several urls are opened here (i.e. closing the first should select
|
|
|
|
|
// the next of many URLs opened) or if the pref to have UI links opened in
|
|
|
|
|
// the background is set (i.e. the link is not being opened modally)
|
|
|
|
|
//
|
|
|
|
|
// i.e.
|
|
|
|
|
// Number of URLs Load UI Links in BG Focus Last Viewed?
|
|
|
|
|
// == 1 false YES
|
|
|
|
|
// == 1 true NO
|
|
|
|
|
// > 1 false/true NO
|
2010-08-11 17:12:41 +04:00
|
|
|
|
var multiple = aURIs.length > 1;
|
|
|
|
|
var owner = multiple || aLoadInBackground ? null : this.selectedTab;
|
2007-08-22 09:00:54 +04:00
|
|
|
|
var firstTabAdded = null;
|
2009-01-23 14:52:14 +03:00
|
|
|
|
|
|
|
|
|
if (aReplace) {
|
|
|
|
|
try {
|
|
|
|
|
this.loadURI(aURIs[0], null, null);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
// Ignore failure in case a URI is wrong, so we can continue
|
|
|
|
|
// opening the next ones.
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-08-22 09:00:54 +04:00
|
|
|
|
else
|
2010-08-11 17:12:41 +04:00
|
|
|
|
firstTabAdded = this.addTab(aURIs[0], {ownerTab: owner, skipAnimation: multiple});
|
2007-08-22 09:00:54 +04:00
|
|
|
|
|
2010-03-22 17:12:04 +03:00
|
|
|
|
var tabNum = this.tabContainer.selectedIndex;
|
2008-07-10 12:21:01 +04:00
|
|
|
|
for (let i = 1; i < aURIs.length; ++i) {
|
2010-06-14 12:10:54 +04:00
|
|
|
|
let tab = this.addTab(aURIs[i], {skipAnimation: true});
|
2007-08-22 09:01:41 +04:00
|
|
|
|
if (aReplace)
|
|
|
|
|
this.moveTabTo(tab, ++tabNum);
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-22 09:00:54 +04:00
|
|
|
|
if (!aLoadInBackground) {
|
|
|
|
|
if (firstTabAdded) {
|
|
|
|
|
// .selectedTab setter focuses the content area
|
|
|
|
|
this.selectedTab = firstTabAdded;
|
|
|
|
|
}
|
2007-08-22 09:00:55 +04:00
|
|
|
|
else
|
2007-08-22 09:00:54 +04:00
|
|
|
|
window.content.focus();
|
|
|
|
|
}
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
2007-08-22 09:00:28 +04:00
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<method name="addTab">
|
|
|
|
|
<parameter name="aURI"/>
|
|
|
|
|
<parameter name="aReferrerURI"/>
|
2007-08-22 08:59:09 +04:00
|
|
|
|
<parameter name="aCharset"/>
|
2007-08-22 08:59:25 +04:00
|
|
|
|
<parameter name="aPostData"/>
|
2007-08-22 09:00:54 +04:00
|
|
|
|
<parameter name="aOwner"/>
|
2007-08-22 09:01:08 +04:00
|
|
|
|
<parameter name="aAllowThirdPartyFixup"/>
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2010-06-09 00:13:55 +04:00
|
|
|
|
var aFromExternal;
|
2009-09-15 03:33:00 +04:00
|
|
|
|
var aRelatedToCurrent;
|
2010-06-14 12:10:54 +04:00
|
|
|
|
var aSkipAnimation;
|
2009-09-15 03:33:00 +04:00
|
|
|
|
if (arguments.length == 2 &&
|
|
|
|
|
typeof arguments[1] == "object" &&
|
|
|
|
|
!(arguments[1] instanceof Ci.nsIURI)) {
|
|
|
|
|
let params = arguments[1];
|
|
|
|
|
aReferrerURI = params.referrerURI;
|
|
|
|
|
aCharset = params.charset;
|
|
|
|
|
aPostData = params.postData;
|
|
|
|
|
aOwner = params.ownerTab;
|
|
|
|
|
aAllowThirdPartyFixup = params.allowThirdPartyFixup;
|
2010-06-09 00:13:55 +04:00
|
|
|
|
aFromExternal = params.fromExternal;
|
2009-09-15 03:33:00 +04:00
|
|
|
|
aRelatedToCurrent = params.relatedToCurrent;
|
2010-06-14 12:10:54 +04:00
|
|
|
|
aSkipAnimation = params.skipAnimation;
|
2009-09-15 03:33:00 +04:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-22 09:01:17 +04:00
|
|
|
|
this._browsers = null; // invalidate cache
|
|
|
|
|
|
2007-08-22 09:01:25 +04:00
|
|
|
|
// if we're adding tabs, we're past interrupt mode, ditch the owner
|
|
|
|
|
if (this.mCurrentTab.owner)
|
|
|
|
|
this.mCurrentTab.owner = null;
|
|
|
|
|
|
2007-08-22 09:01:34 +04:00
|
|
|
|
var t = document.createElementNS(
|
|
|
|
|
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
|
2007-08-22 08:58:49 +04:00
|
|
|
|
"tab");
|
|
|
|
|
|
2009-10-14 16:50:52 +04:00
|
|
|
|
var blank = !aURI || (aURI == "about:blank");
|
2007-08-22 08:59:43 +04:00
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
if (blank)
|
2010-03-18 10:04:42 +03:00
|
|
|
|
t.setAttribute("label", this.mStringBundle.getString("tabs.emptyTabTitle"));
|
2007-08-22 08:58:49 +04:00
|
|
|
|
else
|
|
|
|
|
t.setAttribute("label", aURI);
|
bug 213228: new toolkit independence bug, part 7: update and use the new toolkit widgetry. tabbrowser.xml: bug 205341, 112697, 210760 by jag, bug 121234, 133503 by neil, bug 206668 by shliang. not ported: bug 169589, [mac] ctrl-tab no longer moves btwn frames bug 203960, go back group bug 104778, remember what user typed when switching tabs. bug 103720, prefill URI when opening new tab.
2007-08-22 08:59:18 +04:00
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
t.setAttribute("crop", "end");
|
|
|
|
|
t.setAttribute("validate", "never");
|
2007-10-10 09:03:52 +04:00
|
|
|
|
t.setAttribute("onerror", "this.removeAttribute('image');");
|
2007-08-22 09:00:54 +04:00
|
|
|
|
t.className = "tabbrowser-tab";
|
2007-08-22 09:01:46 +04:00
|
|
|
|
|
2011-04-12 10:50:56 +04:00
|
|
|
|
this.tabContainer._unlockTabSizing();
|
|
|
|
|
|
2010-06-14 12:10:54 +04:00
|
|
|
|
// When overflowing, new tabs are scrolled into view smoothly, which
|
|
|
|
|
// doesn't go well together with the width transition. So we skip the
|
|
|
|
|
// transition in that case.
|
|
|
|
|
if (aSkipAnimation ||
|
2010-08-07 00:15:18 +04:00
|
|
|
|
this.tabContainer.getAttribute("overflow") == "true" ||
|
|
|
|
|
!Services.prefs.getBoolPref("browser.tabs.animate")) {
|
2010-06-14 12:10:54 +04:00
|
|
|
|
t.setAttribute("fadein", "true");
|
|
|
|
|
setTimeout(function (tabContainer) {
|
|
|
|
|
tabContainer._handleNewTab(t);
|
|
|
|
|
}, 0, this.tabContainer);
|
|
|
|
|
} else {
|
2010-08-06 00:18:17 +04:00
|
|
|
|
setTimeout(function (tabContainer) {
|
|
|
|
|
if (t.pinned)
|
|
|
|
|
tabContainer._handleNewTab(t);
|
|
|
|
|
else
|
|
|
|
|
t.setAttribute("fadein", "true");
|
|
|
|
|
}, 0, this.tabContainer);
|
2010-06-14 12:10:54 +04:00
|
|
|
|
}
|
|
|
|
|
|
2010-03-22 17:12:04 +03:00
|
|
|
|
this.tabContainer.appendChild(t);
|
2007-08-22 09:01:46 +04:00
|
|
|
|
|
2010-03-22 17:12:04 +03:00
|
|
|
|
// invalidate cache, because tabContainer is about to change
|
|
|
|
|
this._browsers = null;
|
2007-08-22 09:01:25 +04:00
|
|
|
|
|
2007-08-22 09:00:54 +04:00
|
|
|
|
// If this new tab is owned by another, assert that relationship
|
2009-04-24 12:18:53 +04:00
|
|
|
|
if (aOwner)
|
2007-08-22 09:00:54 +04:00
|
|
|
|
t.owner = aOwner;
|
2007-08-22 09:00:55 +04:00
|
|
|
|
|
2007-08-22 09:01:34 +04:00
|
|
|
|
var b = document.createElementNS(
|
|
|
|
|
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
|
2007-08-22 08:59:43 +04:00
|
|
|
|
"browser");
|
2007-08-22 09:01:01 +04:00
|
|
|
|
b.setAttribute("type", "content-targetable");
|
2007-08-22 08:59:41 +04:00
|
|
|
|
b.setAttribute("message", "true");
|
2007-08-22 08:58:49 +04:00
|
|
|
|
b.setAttribute("contextmenu", this.getAttribute("contentcontextmenu"));
|
|
|
|
|
b.setAttribute("tooltip", this.getAttribute("contenttooltip"));
|
2011-01-17 17:35:32 +03:00
|
|
|
|
|
2011-06-23 00:43:09 +04:00
|
|
|
|
if (Services.prefs.getPrefType("browser.tabs.remote") == Services.prefs.PREF_BOOL &&
|
|
|
|
|
Services.prefs.getBoolPref("browser.tabs.remote")) {
|
|
|
|
|
b.setAttribute("remote", "true");
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-01 13:14:56 +03:00
|
|
|
|
if (window.gShowPageResizers && document.getElementById("addon-bar").collapsed &&
|
|
|
|
|
window.windowState == window.STATE_NORMAL) {
|
2011-01-17 17:35:32 +03:00
|
|
|
|
b.setAttribute("showresizer", "true");
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-22 09:00:48 +04:00
|
|
|
|
if (this.hasAttribute("autocompletepopup"))
|
|
|
|
|
b.setAttribute("autocompletepopup", this.getAttribute("autocompletepopup"));
|
2007-08-22 09:02:41 +04:00
|
|
|
|
b.setAttribute("autoscrollpopup", this._autoScrollPopup.id);
|
2007-08-22 08:59:49 +04:00
|
|
|
|
|
2010-09-16 07:01:00 +04:00
|
|
|
|
// Create the browserStack container
|
|
|
|
|
var stack = document.createElementNS(
|
|
|
|
|
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
|
|
|
|
|
"stack");
|
|
|
|
|
stack.setAttribute("anonid", "browserStack");
|
|
|
|
|
stack.appendChild(b);
|
|
|
|
|
stack.setAttribute("flex", "1");
|
|
|
|
|
|
2007-08-22 09:00:55 +04:00
|
|
|
|
// Add the Message and the Browser to the box
|
2007-08-22 09:01:12 +04:00
|
|
|
|
var notificationbox = document.createElementNS(
|
|
|
|
|
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
|
|
|
|
|
"notificationbox");
|
|
|
|
|
notificationbox.setAttribute("flex", "1");
|
2010-09-16 07:01:00 +04:00
|
|
|
|
notificationbox.appendChild(stack);
|
2010-08-05 23:38:07 +04:00
|
|
|
|
|
|
|
|
|
var position = this.tabs.length - 1;
|
2011-04-13 17:35:06 +04:00
|
|
|
|
var uniqueId = "panel" + Date.now() + position;
|
2010-08-05 23:38:07 +04:00
|
|
|
|
notificationbox.id = uniqueId;
|
|
|
|
|
t.linkedPanel = uniqueId;
|
|
|
|
|
t.linkedBrowser = b;
|
|
|
|
|
t._tPos = position;
|
|
|
|
|
if (t.previousSibling.selected)
|
|
|
|
|
t.setAttribute("afterselected", true);
|
|
|
|
|
|
|
|
|
|
// NB: this appendChild call causes us to run constructors for the
|
|
|
|
|
// browser element, which fires off a bunch of notifications. Some
|
|
|
|
|
// of those notifications can cause code to run that inspects our
|
|
|
|
|
// state, so it is important that the tab element is fully
|
|
|
|
|
// initialized by this point.
|
2007-08-22 09:01:12 +04:00
|
|
|
|
this.mPanelContainer.appendChild(notificationbox);
|
2007-08-22 08:58:49 +04:00
|
|
|
|
|
2010-03-17 09:36:13 +03:00
|
|
|
|
this.tabContainer.updateVisibility();
|
2007-08-22 08:58:49 +04:00
|
|
|
|
|
|
|
|
|
// wire up a progress listener for the new browser object.
|
2007-08-22 08:59:22 +04:00
|
|
|
|
var tabListener = this.mTabProgressListener(t, b, blank);
|
2007-08-22 08:58:49 +04:00
|
|
|
|
const filter = Components.classes["@mozilla.org/appshell/component/browser-status-filter;1"]
|
|
|
|
|
.createInstance(Components.interfaces.nsIWebProgress);
|
|
|
|
|
filter.addProgressListener(tabListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
|
2011-06-25 01:32:27 +04:00
|
|
|
|
#ifdef MOZ_E10S_COMPAT
|
|
|
|
|
// Bug 666801 - WebProgress support for e10s
|
|
|
|
|
#else
|
2007-08-22 08:58:49 +04:00
|
|
|
|
b.webProgress.addProgressListener(filter, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
|
2011-06-25 01:32:27 +04:00
|
|
|
|
#endif
|
2007-08-22 08:58:49 +04:00
|
|
|
|
this.mTabListeners[position] = tabListener;
|
|
|
|
|
this.mTabFilters[position] = filter;
|
2007-08-22 09:00:55 +04:00
|
|
|
|
|
2007-08-22 08:59:41 +04:00
|
|
|
|
b._fastFind = this.fastFind;
|
2010-04-18 22:27:18 +04:00
|
|
|
|
b.droppedLinkHandler = handleDroppedLink;
|
2007-08-22 08:58:49 +04:00
|
|
|
|
|
2007-08-22 09:01:25 +04:00
|
|
|
|
// Dispatch a new tab notification. We do this once we're
|
|
|
|
|
// entirely done, so that things are in a consistent state
|
|
|
|
|
// even if the event listener opens or closes tabs.
|
|
|
|
|
var evt = document.createEvent("Events");
|
|
|
|
|
evt.initEvent("TabOpen", true, false);
|
|
|
|
|
t.dispatchEvent(evt);
|
2007-08-22 09:01:48 +04:00
|
|
|
|
|
2009-10-09 22:36:06 +04:00
|
|
|
|
if (!blank) {
|
|
|
|
|
// Stop the existing about:blank load. Otherwise, if aURI
|
|
|
|
|
// doesn't stop in-progress loads on its own, we'll get into
|
|
|
|
|
// trouble with multiple parallel loads running at once.
|
|
|
|
|
b.stop();
|
|
|
|
|
|
2010-05-14 21:04:08 +04:00
|
|
|
|
// pretend the user typed this so it'll be available till
|
|
|
|
|
// the document successfully loads
|
|
|
|
|
b.userTypedValue = aURI;
|
|
|
|
|
|
2010-06-09 00:13:55 +04:00
|
|
|
|
let flags = Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
|
|
|
|
|
if (aAllowThirdPartyFixup)
|
|
|
|
|
flags |= Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP;
|
|
|
|
|
if (aFromExternal)
|
|
|
|
|
flags |= Ci.nsIWebNavigation.LOAD_FLAGS_FROM_EXTERNAL;
|
2009-10-09 22:36:06 +04:00
|
|
|
|
try {
|
|
|
|
|
b.loadURIWithFlags(aURI, flags, aReferrerURI, aCharset, aPostData);
|
2011-06-05 21:37:10 +04:00
|
|
|
|
} catch (ex) {
|
|
|
|
|
Cu.reportError(ex);
|
2009-10-09 22:36:06 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-01 07:06:49 +03:00
|
|
|
|
// We start our browsers out as inactive, and then maintain
|
|
|
|
|
// activeness in the tab switcher.
|
2011-06-25 01:32:27 +04:00
|
|
|
|
b.docShellIsActive = false;
|
2010-12-01 07:06:49 +03:00
|
|
|
|
|
2009-09-04 18:37:17 +04:00
|
|
|
|
// Check if we're opening a tab related to the current tab and
|
|
|
|
|
// move it to after the current tab.
|
|
|
|
|
// aReferrerURI is null or undefined if the tab is opened from
|
|
|
|
|
// an external application or bookmark, i.e. somewhere other
|
|
|
|
|
// than the current tab.
|
2011-08-03 22:39:51 +04:00
|
|
|
|
if ((aRelatedToCurrent == null ? aReferrerURI : aRelatedToCurrent) &&
|
|
|
|
|
Services.prefs.getBoolPref("browser.tabs.insertRelatedAfterCurrent")) {
|
2009-09-04 18:37:17 +04:00
|
|
|
|
let newTabPos = (this._lastRelatedTab ||
|
|
|
|
|
this.selectedTab)._tPos + 1;
|
2010-09-06 13:39:59 +04:00
|
|
|
|
if (this._lastRelatedTab)
|
|
|
|
|
this._lastRelatedTab.owner = null;
|
|
|
|
|
else
|
|
|
|
|
t.owner = this.selectedTab;
|
2011-08-03 22:39:51 +04:00
|
|
|
|
this.moveTabTo(t, newTabPos);
|
2009-09-04 18:37:17 +04:00
|
|
|
|
this._lastRelatedTab = t;
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
return t;
|
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
bug 213228: new toolkit independence bug, part 7: update and use the new toolkit widgetry. tabbrowser.xml: bug 205341, 112697, 210760 by jag, bug 121234, 133503 by neil, bug 206668 by shliang. not ported: bug 169589, [mac] ctrl-tab no longer moves btwn frames bug 203960, go back group bug 104778, remember what user typed when switching tabs. bug 103720, prefill URI when opening new tab.
2007-08-22 08:59:18 +04:00
|
|
|
|
|
2007-08-22 08:59:41 +04:00
|
|
|
|
<method name="warnAboutClosingTabs">
|
|
|
|
|
<parameter name="aAll"/>
|
|
|
|
|
<body>
|
2007-08-22 09:00:55 +04:00
|
|
|
|
<![CDATA[
|
2010-08-13 16:40:19 +04:00
|
|
|
|
var tabsToClose = (aAll ? this.tabs.length : this.visibleTabs.length - 1)
|
|
|
|
|
- gBrowser._numPinnedTabs;
|
2010-04-12 12:01:34 +04:00
|
|
|
|
if (tabsToClose <= 1)
|
|
|
|
|
return true;
|
2007-08-22 09:00:55 +04:00
|
|
|
|
|
2007-08-22 08:59:41 +04:00
|
|
|
|
const pref = "browser.tabs.warnOnClose";
|
2010-03-21 12:38:08 +03:00
|
|
|
|
var shouldPrompt = Services.prefs.getBoolPref(pref);
|
2007-08-22 08:59:41 +04:00
|
|
|
|
|
2010-04-12 12:01:34 +04:00
|
|
|
|
if (!shouldPrompt)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
var ps = Services.prompt;
|
|
|
|
|
|
|
|
|
|
// default to true: if it were false, we wouldn't get this far
|
|
|
|
|
var warnOnClose = { value: true };
|
|
|
|
|
var bundle = this.mStringBundle;
|
|
|
|
|
|
|
|
|
|
// focus the window before prompting.
|
|
|
|
|
// this will raise any minimized window, which will
|
|
|
|
|
// make it obvious which window the prompt is for and will
|
|
|
|
|
// solve the problem of windows "obscuring" the prompt.
|
|
|
|
|
// see bug #350299 for more details
|
|
|
|
|
window.focus();
|
|
|
|
|
var buttonPressed =
|
|
|
|
|
ps.confirmEx(window,
|
|
|
|
|
bundle.getString("tabs.closeWarningTitle"),
|
|
|
|
|
bundle.getFormattedString("tabs.closeWarningMultipleTabs",
|
|
|
|
|
[tabsToClose]),
|
|
|
|
|
(ps.BUTTON_TITLE_IS_STRING * ps.BUTTON_POS_0)
|
|
|
|
|
+ (ps.BUTTON_TITLE_CANCEL * ps.BUTTON_POS_1),
|
|
|
|
|
bundle.getString("tabs.closeButtonMultiple"),
|
|
|
|
|
null, null,
|
|
|
|
|
bundle.getString('tabs.closeWarningPromptMe'),
|
|
|
|
|
warnOnClose);
|
|
|
|
|
var reallyClose = (buttonPressed == 0);
|
|
|
|
|
// don't set the pref unless they press OK and it's false
|
|
|
|
|
if (reallyClose && !warnOnClose.value)
|
|
|
|
|
Services.prefs.setBoolPref(pref, false);
|
|
|
|
|
|
2007-08-22 08:59:41 +04:00
|
|
|
|
return reallyClose;
|
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
2007-08-22 09:00:55 +04:00
|
|
|
|
|
2007-08-22 08:59:10 +04:00
|
|
|
|
<method name="removeAllTabsBut">
|
|
|
|
|
<parameter name="aTab"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2010-07-22 19:51:55 +04:00
|
|
|
|
if (aTab.pinned)
|
|
|
|
|
return;
|
|
|
|
|
|
2007-08-22 09:02:03 +04:00
|
|
|
|
if (this.warnAboutClosingTabs(false)) {
|
2010-07-30 03:39:57 +04:00
|
|
|
|
let tabs = this.visibleTabs;
|
2008-10-21 23:57:26 +04:00
|
|
|
|
this.selectedTab = aTab;
|
2007-08-22 08:59:10 +04:00
|
|
|
|
|
2010-07-30 03:39:57 +04:00
|
|
|
|
for (let i = tabs.length - 1; i >= 0; --i) {
|
|
|
|
|
if (tabs[i] != aTab && !tabs[i].pinned)
|
|
|
|
|
this.removeTab(tabs[i]);
|
2007-08-22 08:59:41 +04:00
|
|
|
|
}
|
2007-08-22 08:59:24 +04:00
|
|
|
|
}
|
2007-08-22 08:59:10 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
bug 213228: new toolkit independence bug, part 7: update and use the new toolkit widgetry. tabbrowser.xml: bug 205341, 112697, 210760 by jag, bug 121234, 133503 by neil, bug 206668 by shliang. not ported: bug 169589, [mac] ctrl-tab no longer moves btwn frames bug 203960, go back group bug 104778, remember what user typed when switching tabs. bug 103720, prefill URI when opening new tab.
2007-08-22 08:59:18 +04:00
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<method name="removeCurrentTab">
|
2010-08-07 00:15:18 +04:00
|
|
|
|
<parameter name="aParams"/>
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2010-08-07 00:15:18 +04:00
|
|
|
|
this.removeTab(this.mCurrentTab, aParams);
|
2007-08-22 08:58:49 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
2007-08-22 09:00:55 +04:00
|
|
|
|
|
2009-03-24 14:47:06 +03:00
|
|
|
|
<field name="_removingTabs">
|
|
|
|
|
[]
|
|
|
|
|
</field>
|
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<method name="removeTab">
|
|
|
|
|
<parameter name="aTab"/>
|
2010-08-07 00:15:18 +04:00
|
|
|
|
<parameter name="aParams"/>
|
2008-08-11 12:38:43 +04:00
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2011-04-12 10:50:56 +04:00
|
|
|
|
if (aParams) {
|
2010-08-07 00:15:18 +04:00
|
|
|
|
var animate = aParams.animate;
|
2011-04-12 10:50:56 +04:00
|
|
|
|
var byMouse = aParams.byMouse;
|
|
|
|
|
}
|
2010-08-07 00:15:18 +04:00
|
|
|
|
|
2010-08-11 17:12:54 +04:00
|
|
|
|
// Handle requests for synchronously removing an already
|
|
|
|
|
// asynchronously closing tab.
|
|
|
|
|
if (!animate &&
|
2011-05-25 10:50:44 +04:00
|
|
|
|
aTab.closing) {
|
2010-08-11 17:12:54 +04:00
|
|
|
|
this._endRemoveTab(aTab);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var isLastTab = (this.tabs.length - this._removingTabs.length == 1);
|
|
|
|
|
|
2010-08-07 00:15:18 +04:00
|
|
|
|
if (!this._beginRemoveTab(aTab, false, null, true))
|
|
|
|
|
return;
|
|
|
|
|
|
2011-07-27 09:26:14 +04:00
|
|
|
|
if (this.tabContainer.draggedTab == aTab)
|
|
|
|
|
this.tabContainer._endTabDrag();
|
|
|
|
|
|
2011-04-12 10:50:56 +04:00
|
|
|
|
if (!aTab.pinned && !aTab.hidden && aTab._fullyOpen && byMouse)
|
|
|
|
|
this.tabContainer._lockTabSizing(aTab);
|
|
|
|
|
else
|
|
|
|
|
this.tabContainer._unlockTabSizing();
|
|
|
|
|
|
2010-10-22 10:29:17 +04:00
|
|
|
|
if (!animate /* the caller didn't opt in */ ||
|
2010-08-07 00:15:18 +04:00
|
|
|
|
isLastTab ||
|
|
|
|
|
aTab.pinned ||
|
2010-10-22 10:29:17 +04:00
|
|
|
|
this._removingTabs.length > 3 /* don't want lots of concurrent animations */ ||
|
|
|
|
|
aTab.getAttribute("fadein") != "true" /* fade-in transition hasn't been triggered yet */ ||
|
2010-11-26 14:43:16 +03:00
|
|
|
|
window.getComputedStyle(aTab).maxWidth == "0.1px" /* fade-in transition hasn't moved yet */ ||
|
2010-08-07 00:15:18 +04:00
|
|
|
|
!Services.prefs.getBoolPref("browser.tabs.animate")) {
|
|
|
|
|
this._endRemoveTab(aTab);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this._blurTab(aTab);
|
2011-04-12 10:50:56 +04:00
|
|
|
|
aTab.style.maxWidth = ""; // ensure that fade-out transition happens
|
2010-08-07 00:15:18 +04:00
|
|
|
|
aTab.removeAttribute("fadein");
|
2010-12-24 01:31:03 +03:00
|
|
|
|
|
|
|
|
|
setTimeout(function (tab, tabbrowser) {
|
2011-01-14 13:47:38 +03:00
|
|
|
|
if (tab.parentNode &&
|
|
|
|
|
window.getComputedStyle(tab).maxWidth == "0.1px") {
|
2010-12-24 01:31:03 +03:00
|
|
|
|
NS_ASSERT(false, "Giving up waiting for the tab closing animation to finish (bug 608589)");
|
|
|
|
|
tabbrowser._endRemoveTab(tab);
|
|
|
|
|
}
|
2011-01-07 16:34:28 +03:00
|
|
|
|
}, 3000, aTab, this);
|
2008-08-11 12:38:43 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2009-03-24 14:47:06 +03:00
|
|
|
|
<!-- Tab close requests are ignored if the window is closing anyway,
|
|
|
|
|
e.g. when holding Ctrl+W. -->
|
|
|
|
|
<field name="_windowIsClosing">
|
|
|
|
|
false
|
|
|
|
|
</field>
|
|
|
|
|
|
2008-08-11 12:38:43 +04:00
|
|
|
|
<method name="_beginRemoveTab">
|
|
|
|
|
<parameter name="aTab"/>
|
2009-05-14 20:46:50 +04:00
|
|
|
|
<parameter name="aTabWillBeMoved"/>
|
2008-10-21 22:05:51 +04:00
|
|
|
|
<parameter name="aCloseWindowWithLastTab"/>
|
2009-04-05 12:10:24 +04:00
|
|
|
|
<parameter name="aCloseWindowFastpath"/>
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2011-05-25 10:50:44 +04:00
|
|
|
|
if (aTab.closing || this._windowIsClosing)
|
2010-08-07 00:15:18 +04:00
|
|
|
|
return false;
|
2009-03-24 14:47:06 +03:00
|
|
|
|
|
|
|
|
|
var browser = this.getBrowserForTab(aTab);
|
|
|
|
|
|
2009-05-14 20:46:50 +04:00
|
|
|
|
if (!aTabWillBeMoved) {
|
2009-03-24 14:47:06 +03:00
|
|
|
|
let ds = browser.docShell;
|
2010-03-16 00:58:24 +03:00
|
|
|
|
if (ds && ds.contentViewer && !ds.contentViewer.permitUnload())
|
2010-08-07 00:15:18 +04:00
|
|
|
|
return false;
|
2008-09-17 19:06:54 +04:00
|
|
|
|
}
|
|
|
|
|
|
2008-10-21 22:05:51 +04:00
|
|
|
|
var closeWindow = false;
|
2009-04-25 12:09:39 +04:00
|
|
|
|
var newTab = false;
|
2010-08-13 18:22:31 +04:00
|
|
|
|
if (this.tabs.length - this._removingTabs.length == 1) {
|
2010-08-12 03:51:39 +04:00
|
|
|
|
closeWindow = aCloseWindowWithLastTab != null ? aCloseWindowWithLastTab :
|
|
|
|
|
!window.toolbar.visible ||
|
|
|
|
|
this.tabContainer._closeWindowWithLastTab;
|
|
|
|
|
|
|
|
|
|
// Closing the tab and replacing it with a blank one is notably slower
|
|
|
|
|
// than closing the window right away. If the caller opts in, take
|
|
|
|
|
// the fast path.
|
|
|
|
|
if (closeWindow &&
|
2010-08-12 14:32:07 +04:00
|
|
|
|
aCloseWindowFastpath &&
|
|
|
|
|
this._removingTabs.length == 0 &&
|
|
|
|
|
(this._windowIsClosing = window.closeWindow(true)))
|
2010-08-12 03:51:39 +04:00
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
newTab = true;
|
|
|
|
|
}
|
2007-08-22 08:58:49 +04:00
|
|
|
|
|
2011-05-25 10:50:44 +04:00
|
|
|
|
aTab.closing = true;
|
2009-03-24 14:47:06 +03:00
|
|
|
|
this._removingTabs.push(aTab);
|
2011-05-18 12:04:36 +04:00
|
|
|
|
if (newTab)
|
|
|
|
|
this.addTab("about:blank", {skipAnimation: true});
|
|
|
|
|
else
|
|
|
|
|
this.tabContainer.updateVisibility();
|
2010-03-17 09:36:13 +03:00
|
|
|
|
|
2009-03-24 14:47:06 +03:00
|
|
|
|
// We're committed to closing the tab now.
|
2007-08-22 09:01:44 +04:00
|
|
|
|
// Dispatch a notification.
|
|
|
|
|
// We dispatch it before any teardown so that event listeners can
|
|
|
|
|
// inspect the tab that's about to close.
|
2009-05-14 20:46:50 +04:00
|
|
|
|
var evt = document.createEvent("UIEvent");
|
|
|
|
|
evt.initUIEvent("TabClose", true, false, window, aTabWillBeMoved ? 1 : 0);
|
2007-08-22 09:01:44 +04:00
|
|
|
|
aTab.dispatchEvent(evt);
|
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
// Remove the tab's filter and progress listener.
|
2009-03-24 14:47:06 +03:00
|
|
|
|
const filter = this.mTabFilters[aTab._tPos];
|
2011-06-25 01:32:27 +04:00
|
|
|
|
#ifdef MOZ_E10S_COMPAT
|
|
|
|
|
// Bug 666801 - WebProgress support for e10s
|
|
|
|
|
#else
|
2009-03-24 14:47:06 +03:00
|
|
|
|
browser.webProgress.removeProgressListener(filter);
|
2011-06-25 01:32:27 +04:00
|
|
|
|
#endif
|
2009-03-24 14:47:06 +03:00
|
|
|
|
filter.removeProgressListener(this.mTabListeners[aTab._tPos]);
|
2009-10-01 16:31:24 +04:00
|
|
|
|
this.mTabListeners[aTab._tPos].destroy();
|
2007-08-22 08:58:49 +04:00
|
|
|
|
|
2010-09-06 18:27:29 +04:00
|
|
|
|
if (browser.registeredOpenURI && !aTabWillBeMoved) {
|
2010-11-29 14:44:43 +03:00
|
|
|
|
this._placesAutocomplete.unregisterOpenPage(browser.registeredOpenURI);
|
2010-08-14 05:52:30 +04:00
|
|
|
|
delete browser.registeredOpenURI;
|
|
|
|
|
}
|
2010-03-27 00:59:02 +03:00
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
// We are no longer the primary content area.
|
2009-03-24 14:47:06 +03:00
|
|
|
|
browser.setAttribute("type", "content-targetable");
|
2007-08-22 08:58:49 +04:00
|
|
|
|
|
2008-03-20 12:08:36 +03:00
|
|
|
|
// Remove this tab as the owner of any other tabs, since it's going away.
|
2010-03-22 17:12:04 +03:00
|
|
|
|
Array.forEach(this.tabs, function (tab) {
|
2008-08-11 12:38:43 +04:00
|
|
|
|
if ("owner" in tab && tab.owner == aTab)
|
2008-03-20 12:08:36 +03:00
|
|
|
|
// |tab| is a child of the tab we're removing, make it an orphan
|
|
|
|
|
tab.owner = null;
|
2009-03-24 14:47:06 +03:00
|
|
|
|
});
|
2007-08-22 08:58:49 +04:00
|
|
|
|
|
2010-08-07 00:15:18 +04:00
|
|
|
|
aTab._endRemoveArgs = [closeWindow, newTab];
|
|
|
|
|
return true;
|
2008-08-11 12:38:43 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="_endRemoveTab">
|
2010-08-07 00:15:18 +04:00
|
|
|
|
<parameter name="aTab"/>
|
2008-08-11 12:38:43 +04:00
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2010-08-07 00:15:18 +04:00
|
|
|
|
if (!aTab || !aTab._endRemoveArgs)
|
2008-09-22 17:56:51 +04:00
|
|
|
|
return;
|
2010-08-07 00:15:18 +04:00
|
|
|
|
|
|
|
|
|
var [aCloseWindow, aNewTab] = aTab._endRemoveArgs;
|
|
|
|
|
aTab._endRemoveArgs = null;
|
|
|
|
|
|
|
|
|
|
if (this._windowIsClosing) {
|
|
|
|
|
aCloseWindow = false;
|
|
|
|
|
aNewTab = false;
|
|
|
|
|
}
|
2008-09-17 19:07:26 +04:00
|
|
|
|
|
2009-09-04 18:37:17 +04:00
|
|
|
|
this._lastRelatedTab = null;
|
|
|
|
|
|
2009-03-24 14:47:06 +03:00
|
|
|
|
// update the UI early for responsiveness
|
|
|
|
|
aTab.collapsed = true;
|
|
|
|
|
this.tabContainer._fillTrailingGap();
|
|
|
|
|
this._blurTab(aTab);
|
|
|
|
|
|
|
|
|
|
this._removingTabs.splice(this._removingTabs.indexOf(aTab), 1);
|
|
|
|
|
|
|
|
|
|
if (aCloseWindow) {
|
|
|
|
|
this._windowIsClosing = true;
|
|
|
|
|
while (this._removingTabs.length)
|
2010-08-07 00:15:18 +04:00
|
|
|
|
this._endRemoveTab(this._removingTabs[0]);
|
2009-03-24 14:47:06 +03:00
|
|
|
|
} else if (!this._windowIsClosing) {
|
2009-10-05 17:41:24 +04:00
|
|
|
|
if (aNewTab)
|
|
|
|
|
focusAndSelectUrlBar();
|
2009-07-10 16:19:07 +04:00
|
|
|
|
|
|
|
|
|
// workaround for bug 345399
|
|
|
|
|
this.tabContainer.mTabstrip._updateScrollButtonsDisabledState();
|
2009-03-24 14:47:06 +03:00
|
|
|
|
}
|
2008-08-11 12:38:43 +04:00
|
|
|
|
|
2009-03-24 14:47:06 +03:00
|
|
|
|
// We're going to remove the tab and the browser now.
|
|
|
|
|
// Clean up mTabFilters and mTabListeners now rather than in
|
|
|
|
|
// _beginRemoveTab, so that their size is always in sync with the
|
|
|
|
|
// number of tabs and browsers (the xbl destructor depends on this).
|
|
|
|
|
this.mTabFilters.splice(aTab._tPos, 1);
|
|
|
|
|
this.mTabListeners.splice(aTab._tPos, 1);
|
2008-08-11 12:38:43 +04:00
|
|
|
|
|
2009-03-24 14:47:06 +03:00
|
|
|
|
var browser = this.getBrowserForTab(aTab);
|
2008-08-11 12:38:43 +04:00
|
|
|
|
|
2007-08-22 08:59:56 +04:00
|
|
|
|
// Because of the way XBL works (fields just set JS
|
|
|
|
|
// properties on the element) and the code we have in place
|
|
|
|
|
// to preserve the JS objects for any elements that have
|
|
|
|
|
// JS properties set on them, the browser element won't be
|
|
|
|
|
// destroyed until the document goes away. So we force a
|
|
|
|
|
// cleanup ourselves.
|
2007-08-22 08:59:58 +04:00
|
|
|
|
// This has to happen before we remove the child so that the
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
|
// XBL implementation of nsIObserver still works.
|
2008-08-11 12:38:43 +04:00
|
|
|
|
browser.destroy();
|
2007-08-22 09:00:55 +04:00
|
|
|
|
|
2008-08-11 12:38:43 +04:00
|
|
|
|
if (browser == this.mCurrentBrowser)
|
2007-12-15 03:25:17 +03:00
|
|
|
|
this.mCurrentBrowser = null;
|
|
|
|
|
|
2011-01-18 11:47:48 +03:00
|
|
|
|
var wasPinned = aTab.pinned;
|
|
|
|
|
|
2009-03-24 14:47:06 +03:00
|
|
|
|
// Invalidate browsers cache, as the tab is removed from the
|
|
|
|
|
// tab container.
|
|
|
|
|
this._browsers = null;
|
2007-08-22 09:00:10 +04:00
|
|
|
|
|
2009-03-24 14:47:06 +03:00
|
|
|
|
// Remove the tab ...
|
|
|
|
|
this.tabContainer.removeChild(aTab);
|
2008-03-20 12:08:36 +03:00
|
|
|
|
|
2009-03-24 14:47:06 +03:00
|
|
|
|
// ... and fix up the _tPos properties immediately.
|
2010-03-22 17:12:04 +03:00
|
|
|
|
for (let i = aTab._tPos; i < this.tabs.length; i++)
|
|
|
|
|
this.tabs[i]._tPos = i;
|
2008-10-21 22:05:51 +04:00
|
|
|
|
|
2010-06-24 18:29:02 +04:00
|
|
|
|
if (!this._windowIsClosing) {
|
2011-01-18 11:47:48 +03:00
|
|
|
|
if (wasPinned)
|
|
|
|
|
this.tabContainer._positionPinnedTabs();
|
2010-06-24 18:29:02 +04:00
|
|
|
|
|
|
|
|
|
// update tab close buttons state
|
2009-08-16 04:34:20 +04:00
|
|
|
|
this.tabContainer.adjustTabstrip();
|
2011-04-12 10:50:56 +04:00
|
|
|
|
|
|
|
|
|
setTimeout(function(tabs) {
|
|
|
|
|
tabs._lastTabClosedByMouse = false;
|
|
|
|
|
}, 0, this.tabContainer);
|
2011-07-27 09:26:14 +04:00
|
|
|
|
|
|
|
|
|
this.tabContainer._handleTabDrag(); // Update drag feedback.
|
2010-06-24 18:29:02 +04:00
|
|
|
|
}
|
2009-08-16 04:34:20 +04:00
|
|
|
|
|
2009-03-24 14:47:06 +03:00
|
|
|
|
// update first-tab/last-tab/beforeselected/afterselected attributes
|
|
|
|
|
this.selectedTab._selected = true;
|
|
|
|
|
|
2010-07-30 10:50:08 +04:00
|
|
|
|
// Removing the panel requires fixing up selectedPanel immediately
|
|
|
|
|
// (see below), which would be hindered by the potentially expensive
|
|
|
|
|
// browser removal. So we remove the browser and the panel in two
|
|
|
|
|
// steps.
|
2010-09-16 07:01:00 +04:00
|
|
|
|
var panel = browser.parentNode.parentNode;
|
2010-07-30 10:50:08 +04:00
|
|
|
|
|
2009-03-24 14:47:06 +03:00
|
|
|
|
// This will unload the document. An unload handler could remove
|
|
|
|
|
// dependant tabs, so it's important that the tabbrowser is now in
|
|
|
|
|
// a consistent state (tab removed, tab positions updated, etc.).
|
2010-09-16 07:01:00 +04:00
|
|
|
|
panel.removeChild(browser.parentNode);
|
2008-03-20 12:08:36 +03:00
|
|
|
|
|
2011-06-18 15:03:41 +04:00
|
|
|
|
// Release the browser in case something is erroneously holding a
|
|
|
|
|
// reference to the tab after its removal.
|
|
|
|
|
aTab.linkedBrowser = null;
|
|
|
|
|
|
2010-07-30 10:50:08 +04:00
|
|
|
|
// As the browser is removed, the removal of a dependent document can
|
2009-03-24 14:47:06 +03:00
|
|
|
|
// cause the whole window to close. So at this point, it's possible
|
|
|
|
|
// that the binding is destructed.
|
2010-07-30 10:50:08 +04:00
|
|
|
|
if (this.mTabBox) {
|
|
|
|
|
let selectedPanel = this.mTabBox.selectedPanel;
|
|
|
|
|
|
|
|
|
|
this.mPanelContainer.removeChild(panel);
|
|
|
|
|
|
|
|
|
|
// Under the hood, a selectedIndex attribute controls which panel
|
|
|
|
|
// is displayed. Removing a panel A which precedes the selected
|
|
|
|
|
// panel B makes selectedIndex point to the panel next to B. We
|
|
|
|
|
// need to explicitly preserve B as the selected panel.
|
|
|
|
|
this.mTabBox.selectedPanel = selectedPanel;
|
|
|
|
|
}
|
2007-08-22 08:59:56 +04:00
|
|
|
|
|
2008-10-21 22:05:51 +04:00
|
|
|
|
if (aCloseWindow)
|
2009-03-24 14:47:06 +03:00
|
|
|
|
this._windowIsClosing = closeWindow(true);
|
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="_blurTab">
|
|
|
|
|
<parameter name="aTab"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
if (this.mCurrentTab != aTab)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (aTab.owner &&
|
2011-01-17 12:54:32 +03:00
|
|
|
|
!aTab.owner.hidden &&
|
2011-05-25 10:50:44 +04:00
|
|
|
|
!aTab.owner.closing &&
|
2010-03-21 12:38:08 +03:00
|
|
|
|
Services.prefs.getBoolPref("browser.tabs.selectOwnerOnClose")) {
|
2009-03-24 14:47:06 +03:00
|
|
|
|
this.selectedTab = aTab.owner;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-17 22:39:17 +04:00
|
|
|
|
// Switch to a visible tab unless there aren't any others remaining
|
|
|
|
|
let remainingTabs = this.visibleTabs;
|
|
|
|
|
let numTabs = remainingTabs.length;
|
|
|
|
|
if (numTabs == 0 || numTabs == 1 && remainingTabs[0] == aTab) {
|
|
|
|
|
remainingTabs = Array.filter(this.tabs, function(tab) {
|
2011-05-25 10:50:44 +04:00
|
|
|
|
return !tab.closing;
|
2010-08-17 22:39:17 +04:00
|
|
|
|
}, this);
|
2010-07-30 03:39:57 +04:00
|
|
|
|
}
|
2010-07-30 03:39:57 +04:00
|
|
|
|
|
|
|
|
|
// Try to find a remaining tab that comes after the given tab
|
|
|
|
|
var tab = aTab;
|
2009-03-24 14:47:06 +03:00
|
|
|
|
do {
|
|
|
|
|
tab = tab.nextSibling;
|
2010-07-30 03:39:57 +04:00
|
|
|
|
} while (tab && remainingTabs.indexOf(tab) == -1);
|
2009-03-24 14:47:06 +03:00
|
|
|
|
|
|
|
|
|
if (!tab) {
|
|
|
|
|
tab = aTab;
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
tab = tab.previousSibling;
|
2010-07-30 03:39:57 +04:00
|
|
|
|
} while (tab && remainingTabs.indexOf(tab) == -1);
|
2009-03-24 14:47:06 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.selectedTab = tab;
|
2008-08-11 12:38:43 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="swapBrowsersAndCloseOther">
|
|
|
|
|
<parameter name="aOurTab"/>
|
|
|
|
|
<parameter name="aOtherTab"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2009-04-16 18:44:07 +04:00
|
|
|
|
// That's gBrowser for the other window, not the tab's browser!
|
2010-08-07 00:15:18 +04:00
|
|
|
|
var remoteBrowser = aOtherTab.ownerDocument.defaultView.gBrowser;
|
2008-08-11 12:38:43 +04:00
|
|
|
|
|
|
|
|
|
// First, start teardown of the other browser. Make sure to not
|
2008-10-21 22:05:51 +04:00
|
|
|
|
// fire the beforeunload event in the process. Close the other
|
|
|
|
|
// window if this was its last tab.
|
2010-08-07 00:15:18 +04:00
|
|
|
|
if (!remoteBrowser._beginRemoveTab(aOtherTab, true, true))
|
|
|
|
|
return;
|
2008-08-11 12:38:43 +04:00
|
|
|
|
|
|
|
|
|
// Unhook our progress listener
|
|
|
|
|
var ourIndex = aOurTab._tPos;
|
|
|
|
|
const filter = this.mTabFilters[ourIndex];
|
|
|
|
|
var tabListener = this.mTabListeners[ourIndex];
|
|
|
|
|
var ourBrowser = this.getBrowserForTab(aOurTab);
|
|
|
|
|
ourBrowser.webProgress.removeProgressListener(filter);
|
|
|
|
|
filter.removeProgressListener(tabListener);
|
|
|
|
|
var tabListenerBlank = tabListener.mBlank;
|
|
|
|
|
|
2010-09-06 18:27:29 +04:00
|
|
|
|
var otherBrowser = aOtherTab.linkedBrowser;
|
|
|
|
|
|
|
|
|
|
// Restore current registered open URI.
|
2010-11-20 03:39:55 +03:00
|
|
|
|
if (ourBrowser.registeredOpenURI) {
|
2010-11-29 14:44:43 +03:00
|
|
|
|
this._placesAutocomplete.unregisterOpenPage(ourBrowser.registeredOpenURI);
|
2010-11-20 03:39:55 +03:00
|
|
|
|
delete ourBrowser.registeredOpenURI;
|
|
|
|
|
}
|
|
|
|
|
if (otherBrowser.registeredOpenURI) {
|
2010-09-06 18:27:29 +04:00
|
|
|
|
ourBrowser.registeredOpenURI = otherBrowser.registeredOpenURI;
|
2010-11-20 03:39:55 +03:00
|
|
|
|
delete otherBrowser.registeredOpenURI;
|
|
|
|
|
}
|
2010-09-06 18:27:29 +04:00
|
|
|
|
|
2009-04-16 18:44:07 +04:00
|
|
|
|
// Workarounds for bug 458697
|
|
|
|
|
// Icon might have been set on DOMLinkAdded, don't override that.
|
2010-09-06 18:27:29 +04:00
|
|
|
|
if (!ourBrowser.mIconURL && otherBrowser.mIconURL)
|
|
|
|
|
this.setIcon(aOurTab, otherBrowser.mIconURL);
|
2009-04-16 18:44:07 +04:00
|
|
|
|
var isBusy = aOtherTab.hasAttribute("busy");
|
|
|
|
|
if (isBusy) {
|
|
|
|
|
aOurTab.setAttribute("busy", "true");
|
2009-12-12 22:31:21 +03:00
|
|
|
|
this._tabAttrModified(aOurTab);
|
2009-04-16 18:44:07 +04:00
|
|
|
|
if (aOurTab == this.selectedTab)
|
|
|
|
|
this.mIsBusy = true;
|
|
|
|
|
}
|
|
|
|
|
|
2008-08-11 12:38:43 +04:00
|
|
|
|
// Swap the docshells
|
2010-09-06 18:27:29 +04:00
|
|
|
|
ourBrowser.swapDocShells(otherBrowser);
|
2008-08-11 12:38:43 +04:00
|
|
|
|
|
|
|
|
|
// Finish tearing down the tab that's going away.
|
2010-08-07 00:15:18 +04:00
|
|
|
|
remoteBrowser._endRemoveTab(aOtherTab);
|
2008-08-11 12:38:43 +04:00
|
|
|
|
|
|
|
|
|
// Restore the progress listener
|
|
|
|
|
tabListener = this.mTabProgressListener(aOurTab, ourBrowser,
|
|
|
|
|
tabListenerBlank);
|
|
|
|
|
this.mTabListeners[ourIndex] = tabListener;
|
|
|
|
|
filter.addProgressListener(tabListener,
|
|
|
|
|
Components.interfaces.nsIWebProgress.NOTIFY_ALL);
|
2008-10-21 22:05:51 +04:00
|
|
|
|
|
2008-08-11 12:38:43 +04:00
|
|
|
|
ourBrowser.webProgress.addProgressListener(filter,
|
|
|
|
|
Components.interfaces.nsIWebProgress.NOTIFY_ALL);
|
2008-11-15 22:47:53 +03:00
|
|
|
|
|
2009-04-16 18:44:07 +04:00
|
|
|
|
if (isBusy)
|
|
|
|
|
this.setTabTitleLoading(aOurTab);
|
|
|
|
|
else
|
|
|
|
|
this.setTabTitle(aOurTab);
|
2008-11-15 22:47:53 +03:00
|
|
|
|
|
2009-01-23 06:00:54 +03:00
|
|
|
|
// If the tab was already selected (this happpens in the scenario
|
|
|
|
|
// of replaceTabWithWindow), notify onLocationChange, etc.
|
2008-11-15 22:47:53 +03:00
|
|
|
|
if (aOurTab == this.selectedTab)
|
|
|
|
|
this.updateCurrentBrowser(true);
|
2007-08-22 08:58:49 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="reloadAllTabs">
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2010-07-30 03:39:57 +04:00
|
|
|
|
let tabs = this.visibleTabs;
|
|
|
|
|
let l = tabs.length;
|
bug 213228: new toolkit independence bug, part 7: update and use the new toolkit widgetry. tabbrowser.xml: bug 205341, 112697, 210760 by jag, bug 121234, 133503 by neil, bug 206668 by shliang. not ported: bug 169589, [mac] ctrl-tab no longer moves btwn frames bug 203960, go back group bug 104778, remember what user typed when switching tabs. bug 103720, prefill URI when opening new tab.
2007-08-22 08:59:18 +04:00
|
|
|
|
for (var i = 0; i < l; i++) {
|
|
|
|
|
try {
|
2010-07-30 03:39:57 +04:00
|
|
|
|
this.getBrowserForTab(tabs[i]).reload();
|
bug 213228: new toolkit independence bug, part 7: update and use the new toolkit widgetry. tabbrowser.xml: bug 205341, 112697, 210760 by jag, bug 121234, 133503 by neil, bug 206668 by shliang. not ported: bug 169589, [mac] ctrl-tab no longer moves btwn frames bug 203960, go back group bug 104778, remember what user typed when switching tabs. bug 103720, prefill URI when opening new tab.
2007-08-22 08:59:18 +04:00
|
|
|
|
} catch (e) {
|
|
|
|
|
// ignore failure to reload so others will be reloaded
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-08-22 08:58:49 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="reloadTab">
|
|
|
|
|
<parameter name="aTab"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
bug 213228: new toolkit independence bug, part 7: update and use the new toolkit widgetry. tabbrowser.xml: bug 205341, 112697, 210760 by jag, bug 121234, 133503 by neil, bug 206668 by shliang. not ported: bug 169589, [mac] ctrl-tab no longer moves btwn frames bug 203960, go back group bug 104778, remember what user typed when switching tabs. bug 103720, prefill URI when opening new tab.
2007-08-22 08:59:18 +04:00
|
|
|
|
this.getBrowserForTab(aTab).reload();
|
2007-08-22 08:58:49 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="addProgressListener">
|
|
|
|
|
<parameter name="aListener"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2011-03-25 21:50:00 +03:00
|
|
|
|
if (arguments.length != 1) {
|
|
|
|
|
Components.utils.reportError("gBrowser.addProgressListener was " +
|
|
|
|
|
"called with a second argument, " +
|
|
|
|
|
"which is not supported. See bug " +
|
|
|
|
|
"608628.");
|
|
|
|
|
}
|
2011-03-23 14:35:21 +03:00
|
|
|
|
|
2011-05-19 13:53:27 +04:00
|
|
|
|
if (!this.mAddProgressListenerWasCalled) {
|
|
|
|
|
this.mAddProgressListenerWasCalled = true;
|
|
|
|
|
this.tabContainer.updateVisibility();
|
|
|
|
|
}
|
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
this.mProgressListeners.push(aListener);
|
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="removeProgressListener">
|
|
|
|
|
<parameter name="aListener"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2010-07-07 08:56:17 +04:00
|
|
|
|
this.mProgressListeners =
|
|
|
|
|
this.mProgressListeners.filter(function (l) l != aListener);
|
2007-08-22 08:58:49 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2008-11-18 13:53:25 +03:00
|
|
|
|
<method name="addTabsProgressListener">
|
|
|
|
|
<parameter name="aListener"/>
|
|
|
|
|
<body>
|
|
|
|
|
this.mTabsProgressListeners.push(aListener);
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="removeTabsProgressListener">
|
|
|
|
|
<parameter name="aListener"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2010-07-07 08:56:17 +04:00
|
|
|
|
this.mTabsProgressListeners =
|
|
|
|
|
this.mTabsProgressListeners.filter(function (l) l != aListener);
|
2008-11-18 13:53:25 +03:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<method name="getBrowserForTab">
|
|
|
|
|
<parameter name="aTab"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2007-08-22 09:00:10 +04:00
|
|
|
|
return aTab.linkedBrowser;
|
2007-08-22 08:58:49 +04:00
|
|
|
|
]]>
|
2008-09-02 12:50:22 +04:00
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2010-07-30 03:39:57 +04:00
|
|
|
|
<method name="showOnlyTheseTabs">
|
|
|
|
|
<parameter name="aTabs"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
Array.forEach(this.tabs, function(tab) {
|
2010-08-13 22:36:40 +04:00
|
|
|
|
if (aTabs.indexOf(tab) == -1)
|
|
|
|
|
this.hideTab(tab);
|
|
|
|
|
else
|
|
|
|
|
this.showTab(tab);
|
|
|
|
|
}, this);
|
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="showTab">
|
|
|
|
|
<parameter name="aTab"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
if (aTab.hidden) {
|
2010-10-11 21:27:05 +04:00
|
|
|
|
aTab.removeAttribute("hidden");
|
2010-11-26 11:39:07 +03:00
|
|
|
|
this.tabContainer.adjustTabstrip();
|
2010-08-13 22:36:40 +04:00
|
|
|
|
let event = document.createEvent("Events");
|
|
|
|
|
event.initEvent("TabShow", true, false);
|
|
|
|
|
aTab.dispatchEvent(event);
|
|
|
|
|
}
|
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="hideTab">
|
|
|
|
|
<parameter name="aTab"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2010-08-17 22:39:17 +04:00
|
|
|
|
if (!aTab.hidden && !aTab.pinned && !aTab.selected &&
|
2011-05-25 10:50:44 +04:00
|
|
|
|
!aTab.closing) {
|
2010-10-11 21:27:05 +04:00
|
|
|
|
aTab.setAttribute("hidden", "true");
|
2010-11-26 11:39:07 +03:00
|
|
|
|
this.tabContainer.adjustTabstrip();
|
2010-08-13 22:36:40 +04:00
|
|
|
|
let event = document.createEvent("Events");
|
|
|
|
|
event.initEvent("TabHide", true, false);
|
|
|
|
|
aTab.dispatchEvent(event);
|
|
|
|
|
}
|
2010-07-30 03:39:57 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2008-09-02 12:50:22 +04:00
|
|
|
|
<method name="selectTabAtIndex">
|
|
|
|
|
<parameter name="aIndex"/>
|
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2010-07-30 03:39:57 +04:00
|
|
|
|
let tabs = this.visibleTabs;
|
|
|
|
|
|
2008-09-02 12:50:22 +04:00
|
|
|
|
// count backwards for aIndex < 0
|
|
|
|
|
if (aIndex < 0)
|
2010-07-30 03:39:57 +04:00
|
|
|
|
aIndex += tabs.length;
|
2008-09-02 12:50:22 +04:00
|
|
|
|
|
2010-07-30 03:39:57 +04:00
|
|
|
|
if (aIndex >= 0 && aIndex < tabs.length)
|
|
|
|
|
this.selectedTab = tabs[aIndex];
|
2008-09-02 12:50:22 +04:00
|
|
|
|
|
|
|
|
|
if (aEvent) {
|
|
|
|
|
aEvent.preventDefault();
|
|
|
|
|
aEvent.stopPropagation();
|
|
|
|
|
}
|
|
|
|
|
]]>
|
2007-08-22 08:58:49 +04:00
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<property name="selectedTab">
|
|
|
|
|
<getter>
|
|
|
|
|
return this.mTabBox.selectedTab;
|
|
|
|
|
</getter>
|
|
|
|
|
<setter>
|
|
|
|
|
<![CDATA[
|
2007-08-22 09:00:27 +04:00
|
|
|
|
// Update the tab
|
|
|
|
|
this.mTabBox.selectedTab = val;
|
|
|
|
|
return val;
|
2007-08-22 08:58:49 +04:00
|
|
|
|
]]>
|
|
|
|
|
</setter>
|
|
|
|
|
</property>
|
|
|
|
|
|
|
|
|
|
<property name="selectedBrowser"
|
|
|
|
|
onget="return this.mCurrentBrowser;"
|
|
|
|
|
readonly="true"/>
|
|
|
|
|
|
2007-08-22 09:00:10 +04:00
|
|
|
|
<property name="browsers" readonly="true">
|
|
|
|
|
<getter>
|
|
|
|
|
<![CDATA[
|
2008-09-02 16:15:06 +04:00
|
|
|
|
return this._browsers ||
|
2010-03-22 17:12:04 +03:00
|
|
|
|
(this._browsers = Array.map(this.tabs, function (tab) tab.linkedBrowser));
|
2007-08-22 09:00:10 +04:00
|
|
|
|
]]>
|
|
|
|
|
</getter>
|
|
|
|
|
</property>
|
2007-08-22 08:58:49 +04:00
|
|
|
|
|
2009-03-07 19:03:32 +03:00
|
|
|
|
<!-- Moves a tab to a new browser window, unless it's already the only tab
|
|
|
|
|
in the current window, in which case this will do nothing. -->
|
2009-01-23 06:00:54 +03:00
|
|
|
|
<method name="replaceTabWithWindow">
|
2008-11-15 22:47:53 +03:00
|
|
|
|
<parameter name="aTab"/>
|
2011-07-04 14:51:47 +04:00
|
|
|
|
<parameter name="aOptions"/>
|
2008-11-15 22:47:53 +03:00
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2010-11-10 11:38:08 +03:00
|
|
|
|
if (this.tabs.length == 1)
|
2009-05-15 17:44:05 +04:00
|
|
|
|
return null;
|
2009-03-07 19:03:32 +03:00
|
|
|
|
|
2011-07-04 14:51:47 +04:00
|
|
|
|
var options = "chrome,dialog=no,all";
|
|
|
|
|
for (var name in aOptions)
|
|
|
|
|
options += "," + name + "=" + aOptions[name];
|
|
|
|
|
|
2008-11-15 22:47:53 +03:00
|
|
|
|
// tell a new window to take the "dropped" tab
|
2011-07-04 14:51:47 +04:00
|
|
|
|
return window.openDialog(getBrowserURL(), "_blank", options, aTab);
|
2008-11-15 22:47:53 +03:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2007-08-22 09:00:10 +04:00
|
|
|
|
<method name="moveTabTo">
|
|
|
|
|
<parameter name="aTab"/>
|
|
|
|
|
<parameter name="aIndex"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2010-02-05 10:33:46 +03:00
|
|
|
|
var oldPosition = aTab._tPos;
|
|
|
|
|
if (oldPosition == aIndex)
|
|
|
|
|
return;
|
|
|
|
|
|
2010-06-24 18:29:02 +04:00
|
|
|
|
// Don't allow mixing pinned and unpinned tabs.
|
|
|
|
|
if (aTab.pinned)
|
|
|
|
|
aIndex = Math.min(aIndex, this._numPinnedTabs - 1);
|
|
|
|
|
else
|
|
|
|
|
aIndex = Math.max(aIndex, this._numPinnedTabs);
|
|
|
|
|
if (oldPosition == aIndex)
|
|
|
|
|
return;
|
|
|
|
|
|
2009-09-04 18:37:17 +04:00
|
|
|
|
this._lastRelatedTab = null;
|
2010-06-24 18:29:02 +04:00
|
|
|
|
|
2007-08-22 09:00:10 +04:00
|
|
|
|
this.mTabFilters.splice(aIndex, 0, this.mTabFilters.splice(aTab._tPos, 1)[0]);
|
|
|
|
|
this.mTabListeners.splice(aIndex, 0, this.mTabListeners.splice(aTab._tPos, 1)[0]);
|
|
|
|
|
|
|
|
|
|
aIndex = aIndex < aTab._tPos ? aIndex: aIndex+1;
|
2007-08-22 09:02:31 +04:00
|
|
|
|
this.mCurrentTab._selected = false;
|
2007-08-22 09:02:19 +04:00
|
|
|
|
// use .item() instead of [] because dragging to the end of the strip goes out of
|
|
|
|
|
// bounds: .item() returns null (so it acts like appendChild), but [] throws
|
2010-03-22 17:12:04 +03:00
|
|
|
|
this.tabContainer.insertBefore(aTab, this.tabs.item(aIndex));
|
|
|
|
|
// invalidate cache, because tabContainer is about to change
|
2007-08-22 09:01:25 +04:00
|
|
|
|
this._browsers = null;
|
2007-08-22 09:00:44 +04:00
|
|
|
|
|
2010-03-22 17:12:04 +03:00
|
|
|
|
for (let i = 0; i < this.tabs.length; i++) {
|
|
|
|
|
this.tabs[i]._tPos = i;
|
|
|
|
|
this.tabs[i]._selected = false;
|
2007-08-22 09:00:10 +04:00
|
|
|
|
}
|
2007-08-22 09:02:31 +04:00
|
|
|
|
this.mCurrentTab._selected = true;
|
2010-03-22 17:12:04 +03:00
|
|
|
|
this.tabContainer.mTabstrip.ensureElementIsVisible(this.mCurrentTab, false);
|
2007-08-22 09:01:25 +04:00
|
|
|
|
|
2010-06-24 18:29:02 +04:00
|
|
|
|
if (aTab.pinned)
|
|
|
|
|
this.tabContainer._positionPinnedTabs();
|
|
|
|
|
|
2007-08-22 09:01:25 +04:00
|
|
|
|
var evt = document.createEvent("UIEvents");
|
|
|
|
|
evt.initUIEvent("TabMove", true, false, window, oldPosition);
|
|
|
|
|
aTab.dispatchEvent(evt);
|
2007-08-22 09:00:10 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="moveTabForward">
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
var tabPos = this.mCurrentTab._tPos;
|
|
|
|
|
if (tabPos < this.browsers.length - 1) {
|
|
|
|
|
this.moveTabTo(this.mCurrentTab, tabPos + 1);
|
|
|
|
|
this.mCurrentTab.focus();
|
|
|
|
|
}
|
|
|
|
|
else if (this.arrowKeysShouldWrap)
|
|
|
|
|
this.moveTabToStart();
|
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="moveTabBackward">
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
var tabPos = this.mCurrentTab._tPos;
|
|
|
|
|
if (tabPos > 0) {
|
|
|
|
|
this.moveTabTo(this.mCurrentTab, tabPos - 1);
|
|
|
|
|
this.mCurrentTab.focus();
|
|
|
|
|
}
|
|
|
|
|
else if (this.arrowKeysShouldWrap)
|
|
|
|
|
this.moveTabToEnd();
|
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="moveTabToStart">
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
var tabPos = this.mCurrentTab._tPos;
|
|
|
|
|
if (tabPos > 0) {
|
|
|
|
|
this.moveTabTo(this.mCurrentTab, 0);
|
|
|
|
|
this.mCurrentTab.focus();
|
|
|
|
|
}
|
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
2007-08-22 09:00:55 +04:00
|
|
|
|
|
2007-08-22 09:00:10 +04:00
|
|
|
|
<method name="moveTabToEnd">
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
var tabPos = this.mCurrentTab._tPos;
|
|
|
|
|
if (tabPos < this.browsers.length - 1) {
|
2007-08-22 09:00:55 +04:00
|
|
|
|
this.moveTabTo(this.mCurrentTab,
|
2007-09-18 04:59:41 +04:00
|
|
|
|
this.browsers.length - 1);
|
2007-08-22 09:00:10 +04:00
|
|
|
|
this.mCurrentTab.focus();
|
|
|
|
|
}
|
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
2007-08-22 09:00:55 +04:00
|
|
|
|
|
2007-08-22 09:00:10 +04:00
|
|
|
|
<method name="moveTabOver">
|
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
var direction = window.getComputedStyle(this.parentNode, null).direction;
|
|
|
|
|
if ((direction == "ltr" && aEvent.keyCode == KeyEvent.DOM_VK_RIGHT) ||
|
|
|
|
|
(direction == "rtl" && aEvent.keyCode == KeyEvent.DOM_VK_LEFT))
|
|
|
|
|
this.moveTabForward();
|
|
|
|
|
else
|
|
|
|
|
this.moveTabBackward();
|
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
2007-08-22 09:00:55 +04:00
|
|
|
|
|
2007-12-12 16:19:50 +03:00
|
|
|
|
<method name="duplicateTab">
|
|
|
|
|
<parameter name="aTab"/><!-- can be from a different window as well -->
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2010-09-10 23:57:18 +04:00
|
|
|
|
return Cc["@mozilla.org/browser/sessionstore;1"]
|
|
|
|
|
.getService(Ci.nsISessionStore)
|
|
|
|
|
.duplicateTab(window, aTab);
|
2007-12-12 16:19:50 +03:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<!-- BEGIN FORWARDED BROWSER PROPERTIES. IF YOU ADD A PROPERTY TO THE BROWSER ELEMENT
|
|
|
|
|
MAKE SURE TO ADD IT HERE AS WELL. -->
|
|
|
|
|
<property name="canGoBack"
|
|
|
|
|
onget="return this.mCurrentBrowser.canGoBack;"
|
|
|
|
|
readonly="true"/>
|
|
|
|
|
|
|
|
|
|
<property name="canGoForward"
|
|
|
|
|
onget="return this.mCurrentBrowser.canGoForward;"
|
|
|
|
|
readonly="true"/>
|
|
|
|
|
|
|
|
|
|
<method name="goBack">
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
return this.mCurrentBrowser.goBack();
|
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="goForward">
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
return this.mCurrentBrowser.goForward();
|
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="reload">
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
return this.mCurrentBrowser.reload();
|
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="reloadWithFlags">
|
|
|
|
|
<parameter name="aFlags"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
return this.mCurrentBrowser.reloadWithFlags(aFlags);
|
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="stop">
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
return this.mCurrentBrowser.stop();
|
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<!-- throws exception for unknown schemes -->
|
|
|
|
|
<method name="loadURI">
|
|
|
|
|
<parameter name="aURI"/>
|
|
|
|
|
<parameter name="aReferrerURI"/>
|
2007-08-22 08:59:09 +04:00
|
|
|
|
<parameter name="aCharset"/>
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2007-08-22 08:59:09 +04:00
|
|
|
|
return this.mCurrentBrowser.loadURI(aURI, aReferrerURI, aCharset);
|
2007-08-22 08:58:49 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<!-- throws exception for unknown schemes -->
|
|
|
|
|
<method name="loadURIWithFlags">
|
|
|
|
|
<parameter name="aURI"/>
|
|
|
|
|
<parameter name="aFlags"/>
|
|
|
|
|
<parameter name="aReferrerURI"/>
|
2007-08-22 08:59:09 +04:00
|
|
|
|
<parameter name="aCharset"/>
|
2008-01-18 19:57:14 +03:00
|
|
|
|
<parameter name="aPostData"/>
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2008-01-18 19:57:14 +03:00
|
|
|
|
return this.mCurrentBrowser.loadURIWithFlags(aURI, aFlags, aReferrerURI, aCharset, aPostData);
|
2007-08-22 08:58:49 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="goHome">
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
return this.mCurrentBrowser.goHome();
|
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<property name="homePage">
|
|
|
|
|
<getter>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
return this.mCurrentBrowser.homePage;
|
|
|
|
|
]]>
|
|
|
|
|
</getter>
|
|
|
|
|
<setter>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
this.mCurrentBrowser.homePage = val;
|
|
|
|
|
return val;
|
|
|
|
|
]]>
|
|
|
|
|
</setter>
|
|
|
|
|
</property>
|
|
|
|
|
|
|
|
|
|
<method name="gotoIndex">
|
|
|
|
|
<parameter name="aIndex"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
return this.mCurrentBrowser.gotoIndex(aIndex);
|
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
2007-08-22 09:00:55 +04:00
|
|
|
|
|
2007-08-22 08:59:06 +04:00
|
|
|
|
<method name="attachFormFill">
|
|
|
|
|
<body><![CDATA[
|
2007-08-22 08:59:41 +04:00
|
|
|
|
for (var i = 0; i < this.mPanelContainer.childNodes.length; ++i) {
|
|
|
|
|
var cb = this.getBrowserAtIndex(i);
|
2007-08-22 08:59:15 +04:00
|
|
|
|
cb.attachFormFill();
|
|
|
|
|
}
|
2007-08-22 08:59:06 +04:00
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="detachFormFill">
|
|
|
|
|
<body><![CDATA[
|
2007-08-22 08:59:41 +04:00
|
|
|
|
for (var i = 0; i < this.mPanelContainer.childNodes.length; ++i) {
|
|
|
|
|
var cb = this.getBrowserAtIndex(i);
|
2007-08-22 08:59:15 +04:00
|
|
|
|
cb.detachFormFill();
|
|
|
|
|
}
|
2007-08-22 08:59:06 +04:00
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
2007-08-22 08:58:49 +04:00
|
|
|
|
|
2007-08-22 08:59:00 +04:00
|
|
|
|
<property name="pageReport"
|
|
|
|
|
onget="return this.mCurrentBrowser.pageReport;"
|
|
|
|
|
readonly="true"/>
|
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<property name="currentURI"
|
|
|
|
|
onget="return this.mCurrentBrowser.currentURI;"
|
|
|
|
|
readonly="true"/>
|
|
|
|
|
|
2007-08-22 08:59:41 +04:00
|
|
|
|
<field name="_fastFind">null</field>
|
|
|
|
|
<property name="fastFind"
|
|
|
|
|
readonly="true">
|
|
|
|
|
<getter>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
if (!this._fastFind) {
|
|
|
|
|
this._fastFind = Components.classes["@mozilla.org/typeaheadfind;1"]
|
2007-08-22 09:00:55 +04:00
|
|
|
|
.createInstance(Components.interfaces.nsITypeAheadFind);
|
2007-08-22 08:59:41 +04:00
|
|
|
|
this._fastFind.init(this.docShell);
|
|
|
|
|
}
|
|
|
|
|
return this._fastFind;
|
|
|
|
|
]]>
|
|
|
|
|
</getter>
|
|
|
|
|
</property>
|
2007-08-22 09:00:55 +04:00
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<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"/>
|
|
|
|
|
|
2007-08-22 08:59:35 +04:00
|
|
|
|
<property name="contentTitle"
|
|
|
|
|
onget="return this.mCurrentBrowser.contentTitle;"
|
|
|
|
|
readonly="true"/>
|
|
|
|
|
|
2007-08-22 09:02:30 +04:00
|
|
|
|
<property name="contentPrincipal"
|
|
|
|
|
onget="return this.mCurrentBrowser.contentPrincipal;"
|
|
|
|
|
readonly="true"/>
|
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<property name="securityUI"
|
|
|
|
|
onget="return this.mCurrentBrowser.securityUI;"
|
|
|
|
|
readonly="true"/>
|
|
|
|
|
|
2010-02-26 10:58:46 +03:00
|
|
|
|
<method name="_handleKeyEvent">
|
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
|
<body><![CDATA[
|
2007-08-22 09:00:10 +04:00
|
|
|
|
if (!aEvent.isTrusted) {
|
|
|
|
|
// Don't let untrusted events mess with tabs.
|
|
|
|
|
return;
|
|
|
|
|
}
|
2007-08-22 09:00:17 +04:00
|
|
|
|
|
2010-05-13 19:37:17 +04:00
|
|
|
|
if (aEvent.altKey)
|
2007-08-22 09:00:17 +04:00
|
|
|
|
return;
|
2008-03-29 09:44:15 +03:00
|
|
|
|
|
2010-05-30 13:50:39 +04:00
|
|
|
|
// We need to take care of FAYT-watching as long as the findbar
|
|
|
|
|
// isn't initialized. The checks on aEvent are copied from
|
|
|
|
|
// _shouldFastFind (see findbar.xml).
|
|
|
|
|
if (!gFindBarInitialized &&
|
|
|
|
|
!(aEvent.ctrlKey || aEvent.metaKey) &&
|
|
|
|
|
!aEvent.getPreventDefault()) {
|
|
|
|
|
let charCode = aEvent.charCode;
|
|
|
|
|
if (charCode) {
|
|
|
|
|
let char = String.fromCharCode(charCode);
|
|
|
|
|
if (char == "'" || char == "/" ||
|
|
|
|
|
Services.prefs.getBoolPref("accessibility.typeaheadfind")) {
|
|
|
|
|
gFindBar._onBrowserKeypress(aEvent);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-13 19:37:17 +04:00
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
|
if (!aEvent.metaKey)
|
|
|
|
|
return;
|
2007-08-22 09:01:10 +04:00
|
|
|
|
|
2010-05-13 19:37:17 +04:00
|
|
|
|
var offset = 1;
|
|
|
|
|
switch (aEvent.charCode) {
|
|
|
|
|
case '}'.charCodeAt(0):
|
|
|
|
|
offset = -1;
|
|
|
|
|
case '{'.charCodeAt(0):
|
|
|
|
|
if (window.getComputedStyle(this, null).direction == "ltr")
|
|
|
|
|
offset *= -1;
|
|
|
|
|
this.tabContainer.advanceSelectedTab(offset, true);
|
2007-08-22 09:01:10 +04:00
|
|
|
|
aEvent.stopPropagation();
|
|
|
|
|
aEvent.preventDefault();
|
2007-08-22 09:00:10 +04:00
|
|
|
|
}
|
2010-05-13 19:37:17 +04:00
|
|
|
|
#else
|
|
|
|
|
if (aEvent.ctrlKey && !aEvent.shiftKey && !aEvent.metaKey &&
|
|
|
|
|
aEvent.keyCode == KeyEvent.DOM_VK_F4 &&
|
|
|
|
|
this.mTabBox.handleCtrlPageUpDown) {
|
2010-08-07 00:15:18 +04:00
|
|
|
|
this.removeCurrentTab({animate: true});
|
2010-05-13 19:37:17 +04:00
|
|
|
|
aEvent.stopPropagation();
|
|
|
|
|
aEvent.preventDefault();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2010-02-26 10:58:46 +03:00
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
2007-08-22 08:59:21 +04:00
|
|
|
|
|
2007-08-22 08:59:31 +04:00
|
|
|
|
<property name="userTypedClear"
|
|
|
|
|
onget="return this.mCurrentBrowser.userTypedClear;"
|
|
|
|
|
onset="return this.mCurrentBrowser.userTypedClear = val;"/>
|
|
|
|
|
|
2007-08-22 08:59:22 +04:00
|
|
|
|
<property name="userTypedValue"
|
|
|
|
|
onget="return this.mCurrentBrowser.userTypedValue;"
|
|
|
|
|
onset="return this.mCurrentBrowser.userTypedValue = val;"/>
|
|
|
|
|
|
2007-08-22 09:00:54 +04:00
|
|
|
|
<method name="createTooltip">
|
|
|
|
|
<parameter name="event"/>
|
2010-03-17 09:36:13 +03:00
|
|
|
|
<body><![CDATA[
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
var tab = document.tooltipNode;
|
2011-07-29 08:26:37 +04:00
|
|
|
|
if (tab.localName != "tab" || this.tabContainer.draggedTab) {
|
2010-03-17 09:36:13 +03:00
|
|
|
|
event.preventDefault();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
event.target.setAttribute("label", tab.mOverCloseButton ?
|
|
|
|
|
tab.getAttribute("closetabtext") :
|
|
|
|
|
tab.getAttribute("label"));
|
|
|
|
|
]]></body>
|
2007-08-22 09:00:54 +04:00
|
|
|
|
</method>
|
2007-08-22 08:59:40 +04:00
|
|
|
|
|
2010-02-26 10:58:46 +03:00
|
|
|
|
<method name="handleEvent">
|
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
|
<body><![CDATA[
|
|
|
|
|
switch (aEvent.type) {
|
|
|
|
|
case "keypress":
|
|
|
|
|
this._handleKeyEvent(aEvent);
|
|
|
|
|
break;
|
2011-07-11 17:14:08 +04:00
|
|
|
|
case "sizemodechange":
|
|
|
|
|
if (aEvent.target == window) {
|
|
|
|
|
this.mCurrentBrowser.docShellIsActive =
|
|
|
|
|
(window.windowState != window.STATE_MINIMIZED);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2010-02-26 10:58:46 +03:00
|
|
|
|
}
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<constructor>
|
|
|
|
|
<![CDATA[
|
2010-09-16 07:01:00 +04:00
|
|
|
|
this.mCurrentBrowser = this.mPanelContainer.childNodes[0].firstChild.firstChild;
|
2010-03-22 17:12:04 +03:00
|
|
|
|
this.mCurrentTab = this.tabContainer.firstChild;
|
2010-02-26 10:58:46 +03:00
|
|
|
|
document.addEventListener("keypress", this, false);
|
2011-07-11 17:14:08 +04:00
|
|
|
|
window.addEventListener("sizemodechange", this, false);
|
2007-08-22 09:00:10 +04:00
|
|
|
|
|
2011-04-12 12:29:41 +04:00
|
|
|
|
var uniqueId = "panel" + Date.now();
|
2007-08-22 09:00:10 +04:00
|
|
|
|
this.mPanelContainer.childNodes[0].id = uniqueId;
|
2010-03-17 09:36:13 +03:00
|
|
|
|
this.mCurrentTab.linkedPanel = uniqueId;
|
|
|
|
|
this.mCurrentTab._tPos = 0;
|
2011-04-12 10:50:56 +04:00
|
|
|
|
this.mCurrentTab._fullyOpen = true;
|
2010-03-17 09:36:13 +03:00
|
|
|
|
this.mCurrentTab.linkedBrowser = this.mCurrentBrowser;
|
2007-08-22 09:02:41 +04:00
|
|
|
|
|
|
|
|
|
// set up the shared autoscroll popup
|
|
|
|
|
this._autoScrollPopup = this.mCurrentBrowser._createAutoScrollPopup();
|
2009-03-08 22:05:53 +03:00
|
|
|
|
this._autoScrollPopup.id = "autoscroller";
|
2007-08-22 09:02:41 +04:00
|
|
|
|
this.appendChild(this._autoScrollPopup);
|
|
|
|
|
this.mCurrentBrowser.setAttribute("autoscrollpopup", this._autoScrollPopup.id);
|
2010-04-18 22:27:18 +04:00
|
|
|
|
this.mCurrentBrowser.droppedLinkHandler = handleDroppedLink;
|
2011-01-17 17:35:32 +03:00
|
|
|
|
this.updateWindowResizers();
|
2011-03-23 14:31:35 +03:00
|
|
|
|
|
|
|
|
|
// Hook up the event listeners to the first browser
|
|
|
|
|
var tabListener = this.mTabProgressListener(this.mCurrentTab, this.mCurrentBrowser, true);
|
|
|
|
|
const nsIWebProgress = Components.interfaces.nsIWebProgress;
|
|
|
|
|
const filter = Components.classes["@mozilla.org/appshell/component/browser-status-filter;1"]
|
|
|
|
|
.createInstance(nsIWebProgress);
|
|
|
|
|
filter.addProgressListener(tabListener, nsIWebProgress.NOTIFY_ALL);
|
|
|
|
|
this.mTabListeners[0] = tabListener;
|
|
|
|
|
this.mTabFilters[0] = filter;
|
|
|
|
|
this.init();
|
2011-05-04 11:29:31 +04:00
|
|
|
|
|
|
|
|
|
this.style.backgroundColor =
|
|
|
|
|
Services.prefs.getBoolPref("browser.display.use_system_colors") ?
|
|
|
|
|
"-moz-default-background-color" :
|
|
|
|
|
Services.prefs.getCharPref("browser.display.background_color");
|
2007-08-22 08:58:49 +04:00
|
|
|
|
]]>
|
|
|
|
|
</constructor>
|
|
|
|
|
|
2011-03-23 14:31:35 +03:00
|
|
|
|
<method name="init">
|
|
|
|
|
<body><![CDATA[
|
|
|
|
|
if (!this._initialProgressListenerAdded) {
|
|
|
|
|
this._initialProgressListenerAdded = true;
|
|
|
|
|
try {
|
|
|
|
|
this.webProgress.addProgressListener(this.mTabFilters[0], Components.interfaces.nsIWebProgress.NOTIFY_ALL);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
// The binding was constructed too early, need to try this again later. See bug 463384.
|
|
|
|
|
this._initialProgressListenerAdded = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<destructor>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
for (var i = 0; i < this.mTabListeners.length; ++i) {
|
2010-03-27 00:59:02 +03:00
|
|
|
|
let browser = this.getBrowserAtIndex(i);
|
2010-08-14 05:52:30 +04:00
|
|
|
|
if (browser.registeredOpenURI) {
|
2010-11-29 14:44:43 +03:00
|
|
|
|
this._placesAutocomplete.unregisterOpenPage(browser.registeredOpenURI);
|
2010-08-14 05:52:30 +04:00
|
|
|
|
delete browser.registeredOpenURI;
|
|
|
|
|
}
|
2010-03-27 00:59:02 +03:00
|
|
|
|
browser.webProgress.removeProgressListener(this.mTabFilters[i]);
|
2007-08-22 08:58:49 +04:00
|
|
|
|
this.mTabFilters[i].removeProgressListener(this.mTabListeners[i]);
|
|
|
|
|
this.mTabFilters[i] = null;
|
2009-10-01 16:31:24 +04:00
|
|
|
|
this.mTabListeners[i].destroy();
|
2007-08-22 08:58:49 +04:00
|
|
|
|
this.mTabListeners[i] = null;
|
|
|
|
|
}
|
2010-02-26 10:58:46 +03:00
|
|
|
|
document.removeEventListener("keypress", this, false);
|
2011-07-11 17:14:08 +04:00
|
|
|
|
window.removeEventListener("sizemodechange", this, false);
|
2007-08-22 08:58:49 +04:00
|
|
|
|
]]>
|
|
|
|
|
</destructor>
|
2010-03-17 09:36:13 +03:00
|
|
|
|
|
|
|
|
|
<!-- Deprecated stuff, implemented for backwards compatibility. -->
|
2011-03-23 14:31:35 +03:00
|
|
|
|
<method name="enterTabbedMode">
|
|
|
|
|
<body>
|
|
|
|
|
Application.console.log("enterTabbedMode is an obsolete method and " +
|
|
|
|
|
"will be removed in a future release.");
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
<field name="mTabbedMode" readonly="true">true</field>
|
2010-03-17 09:36:13 +03:00
|
|
|
|
<method name="setStripVisibilityTo">
|
|
|
|
|
<parameter name="aShow"/>
|
|
|
|
|
<body>
|
|
|
|
|
this.tabContainer.visible = aShow;
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
<method name="getStripVisibility">
|
|
|
|
|
<body>
|
|
|
|
|
return this.tabContainer.visible;
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
<property name="mContextTab" readonly="true"
|
2010-03-26 01:02:19 +03:00
|
|
|
|
onget="return TabContextMenu.contextTab;"/>
|
2010-03-21 12:38:08 +03:00
|
|
|
|
<property name="mPrefs" readonly="true"
|
|
|
|
|
onget="return Services.prefs;"/>
|
2010-03-22 17:12:04 +03:00
|
|
|
|
<property name="mTabContainer" readonly="true"
|
|
|
|
|
onget="return this.tabContainer;"/>
|
|
|
|
|
<property name="mTabs" readonly="true"
|
|
|
|
|
onget="return this.tabs;"/>
|
2010-03-22 20:49:55 +03:00
|
|
|
|
<!--
|
|
|
|
|
- Compatibility hack: several extensions depend on this property to
|
|
|
|
|
- access the tab context menu or tab container, so keep that working for
|
|
|
|
|
- now. Ideally we can remove this once extensions are using
|
|
|
|
|
- tabbrowser.tabContextMenu and tabbrowser.tabContainer directly.
|
|
|
|
|
-->
|
|
|
|
|
<property name="mStrip" readonly="true">
|
|
|
|
|
<getter>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
return ({
|
|
|
|
|
self: this,
|
|
|
|
|
childNodes: [null, this.tabContextMenu, this.tabContainer],
|
|
|
|
|
firstChild: { nextSibling: this.tabContextMenu },
|
|
|
|
|
getElementsByAttribute: function (attr, attrValue) {
|
|
|
|
|
if (attr == "anonid" && attrValue == "tabContextMenu")
|
|
|
|
|
return [this.self.tabContextMenu];
|
|
|
|
|
return [];
|
|
|
|
|
},
|
|
|
|
|
// Also support adding event listeners (forward to the tab container)
|
|
|
|
|
addEventListener: function (a,b,c) { this.self.tabContainer.addEventListener(a,b,c); },
|
|
|
|
|
removeEventListener: function (a,b,c) { this.self.tabContainer.removeEventListener(a,b,c); }
|
|
|
|
|
});
|
|
|
|
|
]]>
|
|
|
|
|
</getter>
|
|
|
|
|
</property>
|
2007-08-22 08:58:49 +04:00
|
|
|
|
</implementation>
|
|
|
|
|
|
|
|
|
|
<handlers>
|
2007-08-22 09:01:16 +04:00
|
|
|
|
<handler event="DOMWindowClose" phase="capturing">
|
2007-08-22 08:58:49 +04:00
|
|
|
|
<![CDATA[
|
2007-08-22 08:59:39 +04:00
|
|
|
|
if (!event.isTrusted)
|
|
|
|
|
return;
|
|
|
|
|
|
2010-03-22 17:12:04 +03:00
|
|
|
|
if (this.tabs.length == 1)
|
2010-03-21 14:01:01 +03:00
|
|
|
|
return;
|
|
|
|
|
|
2010-02-26 10:58:46 +03:00
|
|
|
|
var tab = this._getTabForContentWindow(event.target);
|
|
|
|
|
if (tab) {
|
|
|
|
|
this.removeTab(tab);
|
|
|
|
|
event.preventDefault();
|
2007-08-22 08:58:49 +04:00
|
|
|
|
}
|
|
|
|
|
]]>
|
|
|
|
|
</handler>
|
2007-08-22 09:01:16 +04:00
|
|
|
|
<handler event="DOMWillOpenModalDialog" phase="capturing">
|
2007-08-22 08:59:40 +04:00
|
|
|
|
<![CDATA[
|
|
|
|
|
if (!event.isTrusted)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// We're about to open a modal dialog, make sure the opening
|
|
|
|
|
// tab is brought to the front.
|
2010-02-26 10:58:46 +03:00
|
|
|
|
this.selectedTab = this._getTabForContentWindow(event.target.top);
|
|
|
|
|
]]>
|
|
|
|
|
</handler>
|
|
|
|
|
<handler event="DOMTitleChanged">
|
|
|
|
|
<![CDATA[
|
|
|
|
|
if (!event.isTrusted)
|
|
|
|
|
return;
|
2007-08-22 08:59:40 +04:00
|
|
|
|
|
2010-02-26 10:58:46 +03:00
|
|
|
|
var contentWin = event.target.defaultView;
|
|
|
|
|
if (contentWin != contentWin.top)
|
|
|
|
|
return;
|
2007-08-22 08:59:40 +04:00
|
|
|
|
|
2010-02-26 10:58:46 +03:00
|
|
|
|
var tab = this._getTabForContentWindow(contentWin);
|
2010-09-04 20:51:52 +04:00
|
|
|
|
var titleChanged = this.setTabTitle(tab);
|
2010-09-10 12:05:36 +04:00
|
|
|
|
if (titleChanged && !tab.selected && !tab.hasAttribute("busy"))
|
2010-09-03 00:08:37 +04:00
|
|
|
|
tab.setAttribute("titlechanged", "true");
|
2007-08-22 08:59:40 +04:00
|
|
|
|
]]>
|
|
|
|
|
</handler>
|
2007-08-22 08:58:49 +04:00
|
|
|
|
</handlers>
|
|
|
|
|
</binding>
|
2007-08-22 09:00:55 +04:00
|
|
|
|
|
2010-03-17 09:36:13 +03:00
|
|
|
|
<binding id="tabbrowser-tabbox"
|
|
|
|
|
extends="chrome://global/content/bindings/tabbox.xml#tabbox">
|
|
|
|
|
<implementation>
|
|
|
|
|
<property name="tabs" readonly="true"
|
|
|
|
|
onget="return document.getBindingParent(this).tabContainer;"/>
|
|
|
|
|
</implementation>
|
|
|
|
|
</binding>
|
|
|
|
|
|
2007-08-22 09:02:12 +04:00
|
|
|
|
<binding id="tabbrowser-arrowscrollbox" extends="chrome://global/content/bindings/scrollbox.xml#arrowscrollbox-clicktoscroll">
|
2009-01-25 11:06:45 +03:00
|
|
|
|
<implementation>
|
|
|
|
|
<!-- Override scrollbox.xml method, since our scrollbox's children are
|
|
|
|
|
inherited from the binding parent -->
|
|
|
|
|
<method name="_getScrollableElements">
|
|
|
|
|
<body><![CDATA[
|
2010-07-23 02:31:58 +04:00
|
|
|
|
return Array.filter(document.getBindingParent(this).childNodes,
|
|
|
|
|
this._canScrollToElement, this);
|
2009-01-25 11:06:45 +03:00
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
2010-06-24 18:29:02 +04:00
|
|
|
|
<method name="_canScrollToElement">
|
|
|
|
|
<parameter name="tab"/>
|
2010-07-30 03:39:57 +04:00
|
|
|
|
<body><![CDATA[
|
|
|
|
|
return !tab.pinned && !tab.hidden;
|
|
|
|
|
]]></body>
|
2010-06-24 18:29:02 +04:00
|
|
|
|
</method>
|
2009-01-25 11:06:45 +03:00
|
|
|
|
</implementation>
|
|
|
|
|
|
2009-02-12 12:18:37 +03:00
|
|
|
|
<handlers>
|
2011-04-12 10:50:56 +04:00
|
|
|
|
<handler event="underflow" phase="capturing"><![CDATA[
|
2011-07-27 09:26:14 +04:00
|
|
|
|
if (event.originalTarget != this._scrollbox || event.detail == 0)
|
2011-04-12 10:50:56 +04:00
|
|
|
|
return; // Ignore vertical events
|
2009-02-12 12:18:37 +03:00
|
|
|
|
|
2011-04-12 10:50:56 +04:00
|
|
|
|
var tabs = document.getBindingParent(this);
|
|
|
|
|
tabs.removeAttribute("overflow");
|
2010-08-07 00:15:18 +04:00
|
|
|
|
|
2011-04-12 10:50:56 +04:00
|
|
|
|
if (tabs._lastTabClosedByMouse)
|
|
|
|
|
tabs._expandSpacerBy(this._scrollButtonDown.clientWidth);
|
2010-08-07 00:15:18 +04:00
|
|
|
|
|
2011-04-12 10:50:56 +04:00
|
|
|
|
tabs.tabbrowser._removingTabs.forEach(tabs.tabbrowser.removeTab,
|
|
|
|
|
tabs.tabbrowser);
|
|
|
|
|
|
|
|
|
|
tabs._positionPinnedTabs();
|
2009-02-12 12:18:37 +03:00
|
|
|
|
]]></handler>
|
|
|
|
|
<handler event="overflow"><![CDATA[
|
2011-07-27 09:26:14 +04:00
|
|
|
|
if (event.originalTarget != this._scrollbox || event.detail == 0)
|
2011-04-12 10:50:56 +04:00
|
|
|
|
return; // Ignore vertical events
|
2009-02-12 12:18:37 +03:00
|
|
|
|
|
2011-04-12 10:50:56 +04:00
|
|
|
|
var tabs = document.getBindingParent(this);
|
|
|
|
|
tabs.setAttribute("overflow", "true");
|
|
|
|
|
tabs._positionPinnedTabs();
|
2009-02-12 12:18:37 +03:00
|
|
|
|
]]></handler>
|
|
|
|
|
</handlers>
|
2009-01-25 11:06:45 +03:00
|
|
|
|
</binding>
|
2007-08-22 09:02:12 +04:00
|
|
|
|
|
2007-08-22 09:00:55 +04:00
|
|
|
|
<binding id="tabbrowser-tabs"
|
2007-08-22 09:00:54 +04:00
|
|
|
|
extends="chrome://global/content/bindings/tabbox.xml#tabs">
|
2010-03-17 09:36:13 +03:00
|
|
|
|
<resources>
|
|
|
|
|
<stylesheet src="chrome://browser/content/tabbrowser.css"/>
|
|
|
|
|
</resources>
|
|
|
|
|
|
2011-07-27 09:26:14 +04:00
|
|
|
|
<!-- The onpopupshowing/hiding handlers on the panel are to circumvent
|
|
|
|
|
noautohide=true disabling level=top on Linux. See bug 448929. -->
|
2010-03-26 01:02:19 +03:00
|
|
|
|
<content>
|
2011-02-05 10:57:09 +03:00
|
|
|
|
<xul:hbox align="end">
|
2011-07-27 09:26:14 +04:00
|
|
|
|
<xul:panel class="tab-drag-panel" anonid="tab-drag-panel" hidden="true" level="top"
|
|
|
|
|
onpopupshowing="this.setAttribute('noautohide', true);"
|
|
|
|
|
onpopuphiding="this.removeAttribute('noautohide');">
|
|
|
|
|
<xul:label class="tab-drag-label" crop="end"/>
|
|
|
|
|
<xul:box class="tab-drag-preview"/>
|
|
|
|
|
</xul:panel>
|
2010-03-17 09:36:13 +03:00
|
|
|
|
<xul:image class="tab-drop-indicator" anonid="tab-drop-indicator" collapsed="true"/>
|
|
|
|
|
</xul:hbox>
|
|
|
|
|
<xul:arrowscrollbox anonid="arrowscrollbox" orient="horizontal" flex="1"
|
|
|
|
|
style="min-width: 1px;"
|
2007-11-21 15:04:21 +03:00
|
|
|
|
#ifndef XP_MACOSX
|
2010-03-17 09:36:13 +03:00
|
|
|
|
clicktoscroll="true"
|
2007-11-21 15:04:21 +03:00
|
|
|
|
#endif
|
2010-03-17 09:36:13 +03:00
|
|
|
|
class="tabbrowser-arrowscrollbox">
|
2009-01-24 03:41:36 +03:00
|
|
|
|
# This is a hack to circumvent bug 472020, otherwise the tabs show up on the
|
|
|
|
|
# right of the newtab button.
|
2010-03-17 09:36:13 +03:00
|
|
|
|
<children includes="tab"/>
|
2009-01-24 03:41:36 +03:00
|
|
|
|
# This is to ensure anything extensions put here will go before the newtab
|
|
|
|
|
# button, necessary due to the previous hack.
|
2010-03-17 09:36:13 +03:00
|
|
|
|
<children/>
|
|
|
|
|
<xul:toolbarbutton class="tabs-newtab-button"
|
|
|
|
|
command="cmd_newNavigatorTab"
|
2010-05-26 16:51:04 +04:00
|
|
|
|
onclick="checkForMiddleClick(this, event);"
|
2010-03-17 09:36:13 +03:00
|
|
|
|
tooltiptext="&newTabButton.tooltip;"/>
|
2011-04-12 10:50:56 +04:00
|
|
|
|
<xul:spacer class="closing-tabs-spacer" anonid="closing-tabs-spacer"
|
|
|
|
|
style="width: 0;"/>
|
2010-03-17 09:36:13 +03:00
|
|
|
|
</xul:arrowscrollbox>
|
2007-08-22 09:00:54 +04:00
|
|
|
|
</content>
|
2010-03-17 09:36:13 +03:00
|
|
|
|
|
2009-11-05 11:02:12 +03:00
|
|
|
|
<implementation implements="nsIDOMEventListener">
|
2007-08-22 09:00:54 +04:00
|
|
|
|
<constructor>
|
2007-08-22 09:01:27 +04:00
|
|
|
|
<![CDATA[
|
2010-03-21 12:38:08 +03:00
|
|
|
|
this.mTabClipWidth = Services.prefs.getIntPref("browser.tabs.tabClipWidth");
|
|
|
|
|
this.mCloseButtons = Services.prefs.getIntPref("browser.tabs.closeButtons");
|
2010-03-22 18:43:20 +03:00
|
|
|
|
this._closeWindowWithLastTab = Services.prefs.getBoolPref("browser.tabs.closeWindowWithLastTab");
|
2007-08-22 09:00:55 +04:00
|
|
|
|
|
2010-03-17 09:36:13 +03:00
|
|
|
|
var tab = this.firstChild;
|
|
|
|
|
tab.setAttribute("label",
|
2010-03-18 10:04:42 +03:00
|
|
|
|
this.tabbrowser.mStringBundle.getString("tabs.emptyTabTitle"));
|
2010-03-17 09:36:13 +03:00
|
|
|
|
tab.setAttribute("crop", "end");
|
|
|
|
|
tab.setAttribute("validate", "never");
|
|
|
|
|
tab.setAttribute("onerror", "this.removeAttribute('image');");
|
2007-08-22 09:01:56 +04:00
|
|
|
|
this.adjustTabstrip();
|
2007-08-22 09:01:25 +04:00
|
|
|
|
|
2010-07-14 10:50:27 +04:00
|
|
|
|
Services.prefs.addObserver("browser.tabs.", this._prefObserver, false);
|
2007-08-22 09:02:44 +04:00
|
|
|
|
window.addEventListener("resize", this, false);
|
2011-01-07 23:28:02 +03:00
|
|
|
|
|
|
|
|
|
if (window.TabsInTitlebar)
|
|
|
|
|
TabsInTitlebar.allowedBy("tabs-visible", this.visible);
|
2007-08-22 09:01:27 +04:00
|
|
|
|
]]>
|
2007-08-22 09:00:54 +04:00
|
|
|
|
</constructor>
|
2007-08-22 09:00:55 +04:00
|
|
|
|
|
2007-08-22 09:01:34 +04:00
|
|
|
|
<destructor>
|
|
|
|
|
<![CDATA[
|
2010-07-14 10:50:27 +04:00
|
|
|
|
Services.prefs.removeObserver("browser.tabs.", this._prefObserver);
|
2007-08-22 09:01:34 +04:00
|
|
|
|
]]>
|
|
|
|
|
</destructor>
|
|
|
|
|
|
2010-03-17 09:36:13 +03:00
|
|
|
|
<field name="tabbrowser" readonly="true">
|
|
|
|
|
document.getElementById(this.getAttribute("tabbrowser"));
|
|
|
|
|
</field>
|
|
|
|
|
|
|
|
|
|
<field name="tabbox" readonly="true">
|
|
|
|
|
this.tabbrowser.mTabBox;
|
|
|
|
|
</field>
|
|
|
|
|
|
2010-03-22 20:49:55 +03:00
|
|
|
|
<field name="contextMenu" readonly="true">
|
2010-07-17 12:08:43 +04:00
|
|
|
|
document.getElementById("tabContextMenu");
|
2010-03-22 20:49:55 +03:00
|
|
|
|
</field>
|
|
|
|
|
|
2007-08-22 09:01:28 +04:00
|
|
|
|
<field name="mTabstripWidth">0</field>
|
|
|
|
|
|
2007-08-22 09:01:25 +04:00
|
|
|
|
<field name="mTabstrip">
|
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "arrowscrollbox");
|
|
|
|
|
</field>
|
|
|
|
|
|
2010-03-17 09:36:13 +03:00
|
|
|
|
<field name="_prefObserver"><![CDATA[({
|
|
|
|
|
tabContainer: this,
|
|
|
|
|
|
|
|
|
|
observe: function (subject, topic, data) {
|
|
|
|
|
switch (data) {
|
2007-08-22 09:01:25 +04:00
|
|
|
|
case "browser.tabs.closeButtons":
|
2010-03-21 12:38:08 +03:00
|
|
|
|
this.tabContainer.mCloseButtons = Services.prefs.getIntPref(data);
|
2010-03-17 09:36:13 +03:00
|
|
|
|
this.tabContainer.adjustTabstrip();
|
|
|
|
|
break;
|
|
|
|
|
case "browser.tabs.autoHide":
|
|
|
|
|
this.tabContainer.updateVisibility();
|
2007-08-22 09:01:25 +04:00
|
|
|
|
break;
|
2010-03-22 18:43:20 +03:00
|
|
|
|
case "browser.tabs.closeWindowWithLastTab":
|
|
|
|
|
this.tabContainer._closeWindowWithLastTab = Services.prefs.getBoolPref(data);
|
|
|
|
|
this.tabContainer.adjustTabstrip();
|
|
|
|
|
break;
|
2007-08-22 09:01:25 +04:00
|
|
|
|
}
|
2007-08-22 09:01:22 +04:00
|
|
|
|
}
|
2010-03-17 09:36:13 +03:00
|
|
|
|
});]]></field>
|
|
|
|
|
<field name="_blockDblClick">false</field>
|
|
|
|
|
|
|
|
|
|
<field name="_tabDropIndicator">
|
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "tab-drop-indicator");
|
|
|
|
|
</field>
|
|
|
|
|
|
2011-07-27 09:26:14 +04:00
|
|
|
|
<method name="_positionDropIndicator">
|
|
|
|
|
<parameter name="event"/>
|
|
|
|
|
<parameter name="scrollOnly"/>
|
|
|
|
|
<body><![CDATA[
|
|
|
|
|
var effects = event.dataTransfer ? this._setEffectAllowedForDataTransfer(event) : "";
|
|
|
|
|
|
|
|
|
|
var ind = this._tabDropIndicator;
|
|
|
|
|
if (effects == "none") {
|
|
|
|
|
ind.collapsed = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
|
|
|
|
|
var tabStrip = this.mTabstrip;
|
|
|
|
|
var ltr = (window.getComputedStyle(this).direction == "ltr");
|
|
|
|
|
|
|
|
|
|
// Autoscroll the tab strip if we drag over the scroll
|
|
|
|
|
// buttons, even if we aren't dragging a tab, but then
|
|
|
|
|
// return to avoid drawing the drop indicator.
|
|
|
|
|
var pixelsToScroll = 0;
|
|
|
|
|
var target = event.originalTarget;
|
|
|
|
|
if (target.ownerDocument == document &&
|
|
|
|
|
this.getAttribute("overflow") == "true") {
|
|
|
|
|
let targetAnonid = target.getAttribute("anonid");
|
|
|
|
|
switch (targetAnonid) {
|
|
|
|
|
case "scrollbutton-up":
|
|
|
|
|
pixelsToScroll = tabStrip.scrollIncrement * -1;
|
|
|
|
|
break;
|
|
|
|
|
case "scrollbutton-down":
|
|
|
|
|
pixelsToScroll = tabStrip.scrollIncrement;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (pixelsToScroll) {
|
|
|
|
|
if (effects)
|
|
|
|
|
tabStrip.scrollByPixels((ltr ? 1 : -1) * pixelsToScroll);
|
|
|
|
|
else
|
|
|
|
|
tabStrip._startScroll(pixelsToScroll < 0 ? -1 : 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (scrollOnly) {
|
|
|
|
|
ind.collapsed = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (effects == "link") {
|
|
|
|
|
let tab = this._getDragTargetTab(event);
|
|
|
|
|
if (tab) {
|
|
|
|
|
if (!this._dragTime)
|
|
|
|
|
this._dragTime = Date.now();
|
|
|
|
|
if (Date.now() >= this._dragTime + this._dragOverDelay)
|
|
|
|
|
this.selectedItem = tab;
|
|
|
|
|
ind.collapsed = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var newIndex = this._getDropIndex(event);
|
|
|
|
|
var scrollRect = tabStrip.scrollClientRect;
|
|
|
|
|
var rect = this.getBoundingClientRect();
|
|
|
|
|
var minMargin = scrollRect.left - rect.left;
|
|
|
|
|
var maxMargin = Math.min(minMargin + scrollRect.width,
|
|
|
|
|
scrollRect.right);
|
|
|
|
|
if (!ltr)
|
|
|
|
|
[minMargin, maxMargin] = [this.clientWidth - maxMargin,
|
|
|
|
|
this.clientWidth - minMargin];
|
|
|
|
|
var newMargin;
|
|
|
|
|
if (pixelsToScroll) {
|
|
|
|
|
// If we are scrolling, put the drop indicator at the edge,
|
|
|
|
|
// so that it doesn't jump while scrolling.
|
|
|
|
|
newMargin = (pixelsToScroll > 0) ? maxMargin : minMargin;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (newIndex == this.childNodes.length) {
|
|
|
|
|
let tabRect = this.childNodes[newIndex-1].getBoundingClientRect();
|
|
|
|
|
if (ltr)
|
|
|
|
|
newMargin = tabRect.right - rect.left;
|
|
|
|
|
else
|
|
|
|
|
newMargin = rect.right - tabRect.left;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
let tabRect = this.childNodes[newIndex].getBoundingClientRect();
|
|
|
|
|
if (ltr)
|
|
|
|
|
newMargin = tabRect.left - rect.left;
|
|
|
|
|
else
|
|
|
|
|
newMargin = rect.right - tabRect.right;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ind.collapsed = false;
|
|
|
|
|
|
|
|
|
|
newMargin += ind.clientWidth / 2;
|
|
|
|
|
if (!ltr)
|
|
|
|
|
newMargin *= -1;
|
|
|
|
|
|
|
|
|
|
ind.style.MozTransform = "translate(" + Math.round(newMargin) + "px)";
|
|
|
|
|
ind.style.MozMarginStart = (-ind.clientWidth) + "px";
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<field name="_tabDragPanel">
|
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "tab-drag-panel");
|
|
|
|
|
</field>
|
|
|
|
|
|
|
|
|
|
<field name="draggedTab">null</field>
|
|
|
|
|
|
|
|
|
|
<method name="_handleTabDrag">
|
|
|
|
|
<parameter name="event"/>
|
|
|
|
|
<body><![CDATA[
|
|
|
|
|
let draggedTab = this.draggedTab;
|
|
|
|
|
if (!draggedTab)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (event)
|
|
|
|
|
draggedTab._dragData._savedEvent = event;
|
|
|
|
|
else
|
|
|
|
|
event = draggedTab._dragData._savedEvent;
|
|
|
|
|
|
|
|
|
|
if (this._updateTabDetachState(event, draggedTab))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// Keep the dragged tab visually within the region of like tabs.
|
|
|
|
|
let tabs = this.tabbrowser.visibleTabs;
|
|
|
|
|
let numPinned = this.tabbrowser._numPinnedTabs;
|
|
|
|
|
let leftmostTab = draggedTab.pinned ? tabs[0] : tabs[numPinned];
|
|
|
|
|
let rightmostTab = draggedTab.pinned ? tabs[numPinned-1] : tabs[tabs.length-1];
|
|
|
|
|
let tabWidth = draggedTab.getBoundingClientRect().width;
|
|
|
|
|
let ltr = (window.getComputedStyle(this).direction == "ltr");
|
|
|
|
|
if (!ltr)
|
|
|
|
|
[leftmostTab, rightmostTab] = [rightmostTab, leftmostTab];
|
|
|
|
|
let left = leftmostTab.boxObject.screenX;
|
|
|
|
|
let right = rightmostTab.boxObject.screenX + tabWidth;
|
|
|
|
|
let transformX = event.screenX - draggedTab._dragData._dragStartX;
|
|
|
|
|
if (!draggedTab.pinned)
|
|
|
|
|
transformX += this.mTabstrip.scrollPosition;
|
|
|
|
|
let tabX = draggedTab.boxObject.screenX + transformX;
|
|
|
|
|
draggedTab._dragData._dragDistX = transformX;
|
|
|
|
|
if (tabX < left)
|
|
|
|
|
transformX += left - tabX;
|
|
|
|
|
// Prevent unintended overflow, especially in RTL mode.
|
|
|
|
|
else if (tabX + tabWidth > right)
|
|
|
|
|
transformX += right - tabX - tabWidth - (ltr ? 0 : 1);
|
|
|
|
|
draggedTab.style.MozTransform = "translate(" + transformX + "px)";
|
|
|
|
|
|
|
|
|
|
let newIndex = this._getDropIndex(event, draggedTab);
|
|
|
|
|
let tabAtNewIndex = this.childNodes[newIndex > draggedTab._tPos ?
|
|
|
|
|
newIndex-1 : newIndex];
|
|
|
|
|
this._positionDropIndicator(event, tabAtNewIndex.pinned == draggedTab.pinned);
|
|
|
|
|
|
|
|
|
|
if (newIndex == draggedTab._dragData._dropIndex)
|
|
|
|
|
return;
|
|
|
|
|
draggedTab._dragData._dropIndex = newIndex;
|
|
|
|
|
|
|
|
|
|
if (!ltr)
|
|
|
|
|
tabWidth *= -1;
|
|
|
|
|
tabs.forEach(function(tab) {
|
|
|
|
|
if (tab == draggedTab || tab.pinned != draggedTab.pinned)
|
|
|
|
|
return;
|
|
|
|
|
else if (tab._tPos < draggedTab._tPos && tab._tPos >= newIndex)
|
|
|
|
|
tab.style.MozTransform = "translate(" + tabWidth + "px)";
|
|
|
|
|
else if (tab._tPos > draggedTab._tPos && tab._tPos < newIndex)
|
|
|
|
|
tab.style.MozTransform = "translate(" + -tabWidth + "px)";
|
|
|
|
|
else
|
|
|
|
|
tab.style.MozTransform = "";
|
|
|
|
|
});
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="_updateTabDetachState">
|
|
|
|
|
<parameter name="event"/>
|
|
|
|
|
<parameter name="draggedTab"/>
|
|
|
|
|
<body><![CDATA[
|
|
|
|
|
let data = draggedTab._dragData;
|
|
|
|
|
if (data._targetWindow.closed) {
|
|
|
|
|
data._targetWindow = window;
|
|
|
|
|
window.focus();
|
|
|
|
|
}
|
|
|
|
|
else if (data._dropTarget) {
|
|
|
|
|
data._dropTarget._tabDropIndicator.collapsed = true;
|
|
|
|
|
}
|
|
|
|
|
delete data._dropTarget;
|
|
|
|
|
|
|
|
|
|
function isEventOutsideWindow(event, win) {
|
|
|
|
|
return (event.screenX < win.screenX || event.screenX >= win.screenX + win.outerWidth ||
|
|
|
|
|
event.screenY < win.screenY || event.screenY >= win.screenY + win.outerHeight);
|
|
|
|
|
}
|
|
|
|
|
if (isEventOutsideWindow(event, data._targetWindow) ||
|
|
|
|
|
Services.ww.activeWindow != data._targetWindow) {
|
|
|
|
|
// Iterate through browser windows in hopefully front-to-back order.
|
|
|
|
|
let winEnum = Services.wm.getZOrderDOMWindowEnumerator("navigator:browser", true);
|
|
|
|
|
let wins = [];
|
|
|
|
|
while (winEnum.hasMoreElements())
|
|
|
|
|
wins.push(winEnum.getNext());
|
|
|
|
|
// Work around broken z-order enumerator on Linux. See bug 156333.
|
|
|
|
|
if (!wins.length) {
|
|
|
|
|
winEnum = Services.wm.getEnumerator("navigator:browser");
|
|
|
|
|
while (winEnum.hasMoreElements())
|
|
|
|
|
wins.unshift(winEnum.getNext());
|
|
|
|
|
}
|
|
|
|
|
wins.every(function(win) {
|
|
|
|
|
if (win.closed || win.windowState == STATE_MINIMIZED ||
|
|
|
|
|
isEventOutsideWindow(event, win))
|
|
|
|
|
return true;
|
|
|
|
|
data._targetWindow = win;
|
|
|
|
|
win.focus(); // Raise window when cursor moves over it.
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let detached = (this.getAttribute("drag") == "detach");
|
|
|
|
|
let loneTab = (this.childElementCount == 1);
|
|
|
|
|
let bo = loneTab ? draggedTab.boxObject : this.parentNode.boxObject;
|
|
|
|
|
// Detach tab if outside window, to the left or right of tab strip, or
|
|
|
|
|
// at least one tab height above or below it.
|
|
|
|
|
if (data._targetWindow != window ||
|
|
|
|
|
event.screenX < bo.screenX || event.screenX >= bo.screenX + bo.width ||
|
|
|
|
|
event.screenY < bo.screenY - (detached || loneTab ? 0 : 1) * bo.height ||
|
|
|
|
|
event.screenY >= bo.screenY + (detached || loneTab ? 1 : 2) * bo.height) {
|
|
|
|
|
if (data._targetWindow != window &&
|
|
|
|
|
data._targetWindow.windowState != STATE_MINIMIZED) {
|
|
|
|
|
let that = data._targetWindow.gBrowser.tabContainer;
|
|
|
|
|
let bo = that.parentNode.boxObject;
|
|
|
|
|
if (event.screenX >= bo.screenX && event.screenX < bo.screenX + bo.width &&
|
|
|
|
|
event.screenY >= bo.screenY && event.screenY < bo.screenY + bo.height) {
|
|
|
|
|
that._positionDropIndicator(event);
|
|
|
|
|
data._dropTarget = that;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let dragPanel = this._tabDragPanel;
|
|
|
|
|
if (data._dropTarget)
|
|
|
|
|
dragPanel.setAttribute("target", "true");
|
|
|
|
|
else
|
|
|
|
|
dragPanel.removeAttribute("target");
|
|
|
|
|
|
|
|
|
|
if (!detached) {
|
|
|
|
|
this.setAttribute("drag", "detach");
|
|
|
|
|
this._clearDragTransforms();
|
|
|
|
|
this._tabDropIndicator.collapsed = true;
|
|
|
|
|
if (draggedTab.style.maxWidth) {
|
|
|
|
|
data._maxWidth = draggedTab.style.maxWidth;
|
|
|
|
|
draggedTab.style.maxWidth = "";
|
|
|
|
|
}
|
2011-07-28 02:13:03 +04:00
|
|
|
|
delete data._dropIndex;
|
2011-07-27 09:26:14 +04:00
|
|
|
|
let label = dragPanel.firstChild;
|
|
|
|
|
let preview = dragPanel.lastChild;
|
|
|
|
|
label.value = draggedTab.label;
|
|
|
|
|
label.width = preview.width = Math.min(outerWidth / 2, screen.availWidth / 5);
|
|
|
|
|
let aspectRatio = this.tabbrowser.clientWidth / this.tabbrowser.clientHeight;
|
|
|
|
|
preview.height = Math.min(preview.width / aspectRatio, screen.availHeight / 5);
|
|
|
|
|
dragPanel.hidden = false;
|
|
|
|
|
dragPanel.openPopupAtScreen(event.screenX, event.screenY, false);
|
|
|
|
|
}
|
|
|
|
|
let width = dragPanel.clientWidth;
|
|
|
|
|
let [left, top] = this._getAdjustedCoords(event.screenX, event.screenY, width,
|
|
|
|
|
dragPanel.clientHeight, width / 2, 12, true);
|
|
|
|
|
dragPanel.moveTo(left, top);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if (detached) { // Otherwise, put tab back in the tab strip.
|
|
|
|
|
this.setAttribute("drag", "move");
|
|
|
|
|
if (data._maxWidth) {
|
|
|
|
|
draggedTab.style.setProperty("max-width", data._maxWidth, "important");
|
|
|
|
|
delete draggedTab._maxWidth;
|
|
|
|
|
}
|
|
|
|
|
this.mTabstrip._updateScrollButtonsDisabledState();
|
|
|
|
|
this._tabDragPanel.hidePopup();
|
|
|
|
|
}
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="_getAdjustedCoords">
|
|
|
|
|
<parameter name="aLeft"/>
|
|
|
|
|
<parameter name="aTop"/>
|
|
|
|
|
<parameter name="aWidth"/>
|
|
|
|
|
<parameter name="aHeight"/>
|
|
|
|
|
<parameter name="aOffsetX"/>
|
|
|
|
|
<parameter name="aOffsetY"/>
|
|
|
|
|
<parameter name="isPanel"/>
|
|
|
|
|
<body><![CDATA[
|
|
|
|
|
// screen.availTop et al. only check the source window's screen, but
|
|
|
|
|
// we want to look at the target window's screen.
|
|
|
|
|
let sX = {}, sY = {}, sWidth = {}, sHeight = {};
|
|
|
|
|
Cc["@mozilla.org/gfx/screenmanager;1"]
|
|
|
|
|
.getService(Ci.nsIScreenManager)
|
|
|
|
|
.screenForRect(aLeft, aTop, 1, 1)
|
|
|
|
|
.GetAvailRect(sX, sY, sWidth, sHeight);
|
|
|
|
|
// Window manager repositions panels that are too close to the right
|
|
|
|
|
// or bottom of a screen, so leave a gutter to avoid that.
|
|
|
|
|
if (isPanel) {
|
|
|
|
|
sWidth.value -= 3;
|
|
|
|
|
sHeight.value -= 3;
|
|
|
|
|
}
|
|
|
|
|
// Ensure rect will be entirely onscreen.
|
|
|
|
|
let width = Math.min(aWidth, sWidth.value);
|
|
|
|
|
let height = Math.min(aHeight, sHeight.value);
|
|
|
|
|
let left = Math.min(Math.max(aLeft - aOffsetX, sX.value),
|
|
|
|
|
sX.value + sWidth.value - width);
|
|
|
|
|
let top = Math.min(Math.max(aTop - aOffsetY, sY.value),
|
|
|
|
|
sY.value + sHeight.value - height);
|
|
|
|
|
return [left, top, width, height];
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="_handleTabDrop">
|
|
|
|
|
<parameter name="event"/>
|
|
|
|
|
<body><![CDATA[
|
|
|
|
|
let draggedTab = this.draggedTab;
|
|
|
|
|
if (this.getAttribute("drag") == "move") {
|
|
|
|
|
this._slideTab(event, draggedTab);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
let that = draggedTab._dragData._dropTarget;
|
|
|
|
|
let win = draggedTab._dragData._targetWindow;
|
|
|
|
|
if (!that || win.closed)
|
|
|
|
|
break;
|
|
|
|
|
that._tabDropIndicator.collapsed = true;
|
|
|
|
|
if (win.windowState == STATE_MINIMIZED)
|
|
|
|
|
break;
|
|
|
|
|
this._endTabDrag();
|
|
|
|
|
|
|
|
|
|
// User dropped the tab onto another window's tab strip, so swap the
|
|
|
|
|
// tab with a new one we create in that window, and then close it in
|
|
|
|
|
// this window (making it seem to have moved between windows).
|
|
|
|
|
let newIndex = that._getDropIndex(event);
|
|
|
|
|
let newTab = that.tabbrowser.addTab("about:blank");
|
|
|
|
|
let newBrowser = that.tabbrowser.getBrowserForTab(newTab);
|
|
|
|
|
newBrowser.stop(); // Stop the about:blank load.
|
|
|
|
|
newBrowser.docShell; // Make sure it has a docshell.
|
|
|
|
|
let numPinned = that.tabbrowser._numPinnedTabs;
|
|
|
|
|
if (newIndex < numPinned || draggedTab.pinned && newIndex == numPinned)
|
|
|
|
|
that.tabbrowser.pinTab(newTab);
|
|
|
|
|
that.tabbrowser.moveTabTo(newTab, newIndex);
|
|
|
|
|
that.tabbrowser.swapBrowsersAndCloseOther(newTab, draggedTab);
|
|
|
|
|
|
|
|
|
|
// We need to select the tab after we've done
|
|
|
|
|
// swapBrowsersAndCloseOther, so that the updateCurrentBrowser
|
|
|
|
|
// it triggers will correctly update our URL bar.
|
|
|
|
|
that.selectedItem = newTab;
|
|
|
|
|
return;
|
|
|
|
|
} while (false);
|
|
|
|
|
|
|
|
|
|
let [left, top, width, height] = this._getAdjustedCoords(
|
|
|
|
|
event.screenX, event.screenY, outerWidth, outerHeight,
|
|
|
|
|
this._tabDragPanel.clientWidth / 2, draggedTab._dragData._dragOffsetY);
|
|
|
|
|
this._endTabDrag();
|
|
|
|
|
|
|
|
|
|
if (this.childElementCount == 1) {
|
|
|
|
|
// Resize _before_ move to ensure the window fits the new screen. If
|
|
|
|
|
// the window is too large for its screen, the window manager may do
|
|
|
|
|
// automatic repositioning.
|
|
|
|
|
window.resizeTo(width, height);
|
|
|
|
|
window.moveTo(left, top);
|
|
|
|
|
window.focus();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
draggedTab.collapsed = true;
|
|
|
|
|
this.tabbrowser.replaceTabWithWindow(draggedTab, { screenX: left,
|
|
|
|
|
screenY: top,
|
|
|
|
|
#ifndef XP_WIN
|
|
|
|
|
outerWidth: width,
|
|
|
|
|
outerHeight: height
|
|
|
|
|
#endif
|
|
|
|
|
});
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="_slideTab">
|
|
|
|
|
<parameter name="event"/>
|
|
|
|
|
<parameter name="draggedTab"/>
|
|
|
|
|
<body><![CDATA[
|
|
|
|
|
let oldIndex = draggedTab._tPos;
|
|
|
|
|
let newIndex = draggedTab._dragData._dropIndex;
|
|
|
|
|
if (newIndex > oldIndex)
|
|
|
|
|
newIndex--;
|
|
|
|
|
this.removeAttribute("drag");
|
|
|
|
|
this._endTabDrag();
|
|
|
|
|
|
|
|
|
|
if (!draggedTab.pinned && newIndex < this.tabbrowser._numPinnedTabs)
|
|
|
|
|
this.tabbrowser.pinTab(draggedTab);
|
|
|
|
|
else if (draggedTab.pinned && newIndex >= this.tabbrowser._numPinnedTabs)
|
|
|
|
|
this.tabbrowser.unpinTab(draggedTab);
|
|
|
|
|
else if (Services.prefs.getBoolPref("browser.tabs.animate")) {
|
|
|
|
|
let difference = 0;
|
|
|
|
|
// Calculate number of visible tabs between start and destination.
|
|
|
|
|
if (newIndex != oldIndex) {
|
|
|
|
|
let tabs = this.tabbrowser.visibleTabs;
|
|
|
|
|
for (let i = 0; i < tabs.length; i++) {
|
|
|
|
|
let position = tabs[i]._tPos;
|
|
|
|
|
if (position <= newIndex && position > oldIndex)
|
|
|
|
|
difference++;
|
|
|
|
|
else if (position >= newIndex && position < oldIndex)
|
|
|
|
|
difference--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let displacement = difference * draggedTab.getBoundingClientRect().width;
|
|
|
|
|
if (window.getComputedStyle(this).direction == "rtl")
|
|
|
|
|
displacement *= -1;
|
|
|
|
|
let destination = "translate(" + displacement + "px)";
|
|
|
|
|
if (draggedTab.style.MozTransform != destination) {
|
|
|
|
|
this.setAttribute("drag", "finish");
|
|
|
|
|
draggedTab.style.MozTransform = destination;
|
|
|
|
|
draggedTab.addEventListener("transitionend", function finish(event) {
|
|
|
|
|
if (event.eventPhase != Event.AT_TARGET ||
|
|
|
|
|
event.propertyName != "-moz-transform")
|
|
|
|
|
return;
|
|
|
|
|
draggedTab.removeEventListener("transitionend", finish);
|
|
|
|
|
draggedTab.removeAttribute("dragged");
|
|
|
|
|
let that = draggedTab.parentNode;
|
|
|
|
|
that.removeAttribute("drag");
|
|
|
|
|
that._clearDragTransforms();
|
|
|
|
|
that.tabbrowser.moveTabTo(draggedTab, newIndex);
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
draggedTab.removeAttribute("dragged");
|
|
|
|
|
this._clearDragTransforms();
|
|
|
|
|
this.tabbrowser.moveTabTo(draggedTab, newIndex);
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="_endTabDrag">
|
|
|
|
|
<body><![CDATA[
|
|
|
|
|
let tab = this.draggedTab;
|
|
|
|
|
if (!tab)
|
|
|
|
|
return;
|
|
|
|
|
this.draggedTab = null;
|
|
|
|
|
delete tab._dragData;
|
|
|
|
|
|
|
|
|
|
document.removeEventListener("mousemove", this);
|
|
|
|
|
document.removeEventListener("mouseup", this);
|
|
|
|
|
this.removeEventListener("TabSelect", this);
|
|
|
|
|
this.mTabstrip.removeEventListener("scroll", this);
|
|
|
|
|
|
|
|
|
|
this._tabDragPanel.hidePopup();
|
|
|
|
|
this._tabDragPanel.hidden = true;
|
|
|
|
|
this._tabDropIndicator.collapsed = true;
|
|
|
|
|
|
|
|
|
|
if (this.hasAttribute("drag")) {
|
|
|
|
|
if (this.getAttribute("drag") == "detach")
|
|
|
|
|
this._unlockTabSizing();
|
|
|
|
|
tab.removeAttribute("dragged");
|
|
|
|
|
this.removeAttribute("drag");
|
|
|
|
|
this._clearDragTransforms();
|
|
|
|
|
}
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="_clearDragTransforms">
|
|
|
|
|
<body>
|
|
|
|
|
this.tabbrowser.visibleTabs.forEach(function(visibleTab) {
|
|
|
|
|
visibleTab.style.MozTransform = "";
|
|
|
|
|
});
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2010-03-17 09:36:13 +03:00
|
|
|
|
<field name="_dragOverDelay">350</field>
|
|
|
|
|
<field name="_dragTime">0</field>
|
|
|
|
|
|
|
|
|
|
<field name="_container" readonly="true"><![CDATA[
|
|
|
|
|
this.parentNode && this.parentNode.localName == "toolbar" ? this.parentNode : this;
|
|
|
|
|
]]></field>
|
|
|
|
|
|
|
|
|
|
<property name="visible"
|
|
|
|
|
onget="return !this._container.collapsed;">
|
|
|
|
|
<setter><![CDATA[
|
2011-01-07 23:28:02 +03:00
|
|
|
|
if (val == this.visible)
|
|
|
|
|
return val;
|
|
|
|
|
|
2010-03-17 09:36:13 +03:00
|
|
|
|
this._container.collapsed = !val;
|
|
|
|
|
|
|
|
|
|
document.getElementById("menu_closeWindow").hidden = !val;
|
|
|
|
|
document.getElementById("menu_close").setAttribute("label",
|
|
|
|
|
this.tabbrowser.mStringBundle.getString(val ? "tabs.closeTab" : "tabs.close"));
|
|
|
|
|
|
2011-01-07 23:28:02 +03:00
|
|
|
|
if (window.TabsInTitlebar)
|
|
|
|
|
TabsInTitlebar.allowedBy("tabs-visible", val);
|
|
|
|
|
|
2010-03-17 09:36:13 +03:00
|
|
|
|
return val;
|
|
|
|
|
]]></setter>
|
|
|
|
|
</property>
|
|
|
|
|
|
|
|
|
|
<method name="updateVisibility">
|
|
|
|
|
<body><![CDATA[
|
2011-03-31 12:12:10 +04:00
|
|
|
|
if (this.childNodes.length - this.tabbrowser._removingTabs.length == 1)
|
|
|
|
|
this.visible = window.toolbar.visible &&
|
|
|
|
|
!Services.prefs.getBoolPref("browser.tabs.autoHide");
|
2010-03-17 09:36:13 +03:00
|
|
|
|
else
|
|
|
|
|
this.visible = true;
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
2007-08-22 09:01:25 +04:00
|
|
|
|
|
|
|
|
|
<method name="adjustTabstrip">
|
2007-08-22 09:00:54 +04:00
|
|
|
|
<body><![CDATA[
|
2007-08-22 09:01:25 +04:00
|
|
|
|
// modes for tabstrip
|
2011-01-08 03:35:33 +03:00
|
|
|
|
// 0 - button on active tab only
|
|
|
|
|
// 1 - close buttons on all tabs
|
|
|
|
|
// 2 - no close buttons at all
|
|
|
|
|
// 3 - close button at the end of the tabstrip
|
2007-08-22 09:01:25 +04:00
|
|
|
|
switch (this.mCloseButtons) {
|
|
|
|
|
case 0:
|
2010-03-22 18:43:20 +03:00
|
|
|
|
if (this.childNodes.length == 1 && this._closeWindowWithLastTab)
|
2011-01-08 03:35:33 +03:00
|
|
|
|
this.setAttribute("closebuttons", "hidden");
|
2010-03-22 18:43:20 +03:00
|
|
|
|
else
|
|
|
|
|
this.setAttribute("closebuttons", "activetab");
|
2007-08-22 09:01:25 +04:00
|
|
|
|
break;
|
|
|
|
|
case 1:
|
2010-08-25 22:06:49 +04:00
|
|
|
|
if (this.childNodes.length == 1) {
|
|
|
|
|
if (this._closeWindowWithLastTab)
|
2011-01-08 03:35:33 +03:00
|
|
|
|
this.setAttribute("closebuttons", "hidden");
|
2010-08-25 22:06:49 +04:00
|
|
|
|
else
|
|
|
|
|
this.setAttribute("closebuttons", "alltabs");
|
|
|
|
|
} else {
|
2010-08-17 00:43:04 +04:00
|
|
|
|
let tab = this.tabbrowser.visibleTabs[this.tabbrowser._numPinnedTabs];
|
2010-06-24 18:29:02 +04:00
|
|
|
|
if (tab && tab.getBoundingClientRect().width > this.mTabClipWidth)
|
|
|
|
|
this.setAttribute("closebuttons", "alltabs");
|
|
|
|
|
else
|
|
|
|
|
this.setAttribute("closebuttons", "activetab");
|
|
|
|
|
}
|
2007-08-22 09:01:25 +04:00
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
case 3:
|
2011-01-08 03:35:33 +03:00
|
|
|
|
this.setAttribute("closebuttons", "never");
|
2007-08-22 09:01:25 +04:00
|
|
|
|
break;
|
|
|
|
|
}
|
2010-04-27 20:57:19 +04:00
|
|
|
|
var tabstripClosebutton = document.getElementById("tabs-closebutton");
|
|
|
|
|
if (tabstripClosebutton && tabstripClosebutton.parentNode == this._container)
|
|
|
|
|
tabstripClosebutton.collapsed = this.mCloseButtons != 3;
|
2007-08-22 09:01:25 +04:00
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
2009-01-15 15:30:43 +03:00
|
|
|
|
|
2007-08-22 09:01:25 +04:00
|
|
|
|
<method name="_handleTabSelect">
|
|
|
|
|
<body><![CDATA[
|
2007-08-22 09:02:44 +04:00
|
|
|
|
this.mTabstrip.ensureElementIsVisible(this.selectedItem);
|
2007-08-22 09:01:25 +04:00
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
2007-08-22 09:01:54 +04:00
|
|
|
|
|
2009-01-15 15:30:43 +03:00
|
|
|
|
<method name="_fillTrailingGap">
|
|
|
|
|
<body><![CDATA[
|
|
|
|
|
try {
|
|
|
|
|
// if we're at the right side (and not the logical end,
|
|
|
|
|
// which is why this works for both LTR and RTL)
|
|
|
|
|
// of the tabstrip, we need to ensure that we stay
|
|
|
|
|
// completely scrolled to the right side
|
|
|
|
|
var tabStrip = this.mTabstrip;
|
2010-05-27 13:00:48 +04:00
|
|
|
|
if (tabStrip.scrollPosition + tabStrip.scrollClientSize >
|
2009-07-10 13:13:10 +04:00
|
|
|
|
tabStrip.scrollSize)
|
2009-01-15 15:30:43 +03:00
|
|
|
|
tabStrip.scrollByPixels(-1);
|
|
|
|
|
} catch (e) {}
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2011-04-12 10:50:56 +04:00
|
|
|
|
<field name="_closingTabsSpacer">
|
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "closing-tabs-spacer");
|
|
|
|
|
</field>
|
|
|
|
|
|
|
|
|
|
<field name="_tabDefaultMaxWidth">NaN</field>
|
|
|
|
|
<field name="_lastTabClosedByMouse">false</field>
|
|
|
|
|
<field name="_hasTabTempMaxWidth">false</field>
|
|
|
|
|
<field name="_usingClosingTabsSpacer">false</field>
|
|
|
|
|
|
|
|
|
|
<!-- Try to keep the active tab's close button under the mouse cursor -->
|
|
|
|
|
<method name="_lockTabSizing">
|
|
|
|
|
<parameter name="aTab"/>
|
|
|
|
|
<body><![CDATA[
|
|
|
|
|
var tabs = this.tabbrowser.visibleTabs;
|
|
|
|
|
if (!tabs.length)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var isEndTab = (aTab._tPos > tabs[tabs.length-1]._tPos);
|
|
|
|
|
var tabWidth = aTab.getBoundingClientRect().width;
|
|
|
|
|
|
|
|
|
|
if (!this._tabDefaultMaxWidth)
|
|
|
|
|
this._tabDefaultMaxWidth =
|
|
|
|
|
parseFloat(window.getComputedStyle(aTab).maxWidth);
|
|
|
|
|
this._lastTabClosedByMouse = true;
|
|
|
|
|
|
|
|
|
|
if (this.getAttribute("overflow") == "true") {
|
|
|
|
|
// Don't need to do anything if we're in overflow mode and aren't scrolled
|
|
|
|
|
// all the way to the right, or if we're closing the last tab.
|
|
|
|
|
if (isEndTab || !this.mTabstrip._scrollButtonDown.disabled)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
// If the tab has an owner that will become the active tab, the owner will
|
|
|
|
|
// be to the left of it, so we actually want the left tab to slide over.
|
|
|
|
|
// This can't be done as easily in non-overflow mode, so we don't bother.
|
|
|
|
|
if (aTab.owner)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
this._expandSpacerBy(tabWidth);
|
|
|
|
|
} else { // non-overflow mode
|
|
|
|
|
// Locking is neither in effect nor needed, so let tabs expand normally.
|
|
|
|
|
if (isEndTab && !this._hasTabTempMaxWidth)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
let numPinned = this.tabbrowser._numPinnedTabs;
|
|
|
|
|
// Force tabs to stay the same width, unless we're closing the last tab,
|
|
|
|
|
// which case we need to let them expand just enough so that the overall
|
|
|
|
|
// tabbar width is the same.
|
|
|
|
|
if (isEndTab) {
|
|
|
|
|
let numNormalTabs = tabs.length - numPinned;
|
|
|
|
|
tabWidth = tabWidth * (numNormalTabs + 1) / numNormalTabs;
|
|
|
|
|
if (tabWidth > this._tabDefaultMaxWidth)
|
|
|
|
|
tabWidth = this._tabDefaultMaxWidth;
|
|
|
|
|
}
|
|
|
|
|
tabWidth += "px";
|
|
|
|
|
for (let i = numPinned; i < tabs.length; i++) {
|
|
|
|
|
let tab = tabs[i];
|
2011-05-22 19:25:44 +04:00
|
|
|
|
tab.style.setProperty("max-width", tabWidth, "important");
|
2011-04-12 10:50:56 +04:00
|
|
|
|
if (!isEndTab) { // keep tabs the same width
|
|
|
|
|
tab.style.MozTransition = "none";
|
|
|
|
|
tab.clientTop; // flush styles to skip animation; see bug 649247
|
|
|
|
|
tab.style.MozTransition = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this._hasTabTempMaxWidth = true;
|
2011-07-27 09:26:14 +04:00
|
|
|
|
window.addEventListener("mouseout", this);
|
2011-04-12 10:50:56 +04:00
|
|
|
|
}
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="_expandSpacerBy">
|
|
|
|
|
<parameter name="pixels"/>
|
|
|
|
|
<body><![CDATA[
|
|
|
|
|
let spacer = this._closingTabsSpacer;
|
|
|
|
|
spacer.style.width = parseFloat(spacer.style.width) + pixels + "px";
|
|
|
|
|
this._usingClosingTabsSpacer = true;
|
2011-07-27 09:26:14 +04:00
|
|
|
|
window.addEventListener("mouseout", this);
|
2011-04-12 10:50:56 +04:00
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="_unlockTabSizing">
|
|
|
|
|
<body><![CDATA[
|
2011-07-27 09:26:14 +04:00
|
|
|
|
window.removeEventListener("mouseout", this);
|
2011-04-12 10:50:56 +04:00
|
|
|
|
if (this._hasTabTempMaxWidth) {
|
|
|
|
|
this._hasTabTempMaxWidth = false;
|
|
|
|
|
let tabs = this.tabbrowser.visibleTabs;
|
|
|
|
|
for (let i = 0; i < tabs.length; i++)
|
|
|
|
|
tabs[i].style.maxWidth = "";
|
|
|
|
|
}
|
|
|
|
|
if (this._usingClosingTabsSpacer) {
|
|
|
|
|
this._usingClosingTabsSpacer = false;
|
|
|
|
|
this._closingTabsSpacer.style.width = 0;
|
|
|
|
|
}
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2010-06-24 18:29:02 +04:00
|
|
|
|
<method name="_positionPinnedTabs">
|
|
|
|
|
<body><![CDATA[
|
2011-01-07 23:27:17 +03:00
|
|
|
|
var numPinned = this.tabbrowser._numPinnedTabs;
|
2011-01-17 11:38:19 +03:00
|
|
|
|
var doPosition = this.getAttribute("overflow") == "true" &&
|
2011-05-25 04:57:31 +04:00
|
|
|
|
numPinned > 0;
|
2010-11-09 22:41:37 +03:00
|
|
|
|
|
2011-01-17 11:38:19 +03:00
|
|
|
|
if (doPosition) {
|
|
|
|
|
this.setAttribute("positionpinnedtabs", "true");
|
|
|
|
|
|
|
|
|
|
let scrollButtonWidth = this.mTabstrip._scrollButtonDown.scrollWidth;
|
|
|
|
|
let paddingStart = this.mTabstrip.scrollboxPaddingStart;
|
|
|
|
|
let width = 0;
|
|
|
|
|
|
|
|
|
|
for (let i = numPinned - 1; i >= 0; i--) {
|
|
|
|
|
let tab = this.childNodes[i];
|
|
|
|
|
width += tab.scrollWidth;
|
2010-11-24 12:50:20 +03:00
|
|
|
|
tab.style.MozMarginStart = - (width + scrollButtonWidth + paddingStart) + "px";
|
2011-01-17 11:38:19 +03:00
|
|
|
|
}
|
|
|
|
|
|
2010-11-24 12:50:20 +03:00
|
|
|
|
this.style.MozMarginStart = width + paddingStart + "px";
|
2011-01-17 11:38:19 +03:00
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
this.removeAttribute("positionpinnedtabs");
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < numPinned; i++) {
|
|
|
|
|
let tab = this.childNodes[i];
|
|
|
|
|
tab.style.MozMarginStart = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.style.MozMarginStart = "";
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-24 18:29:02 +04:00
|
|
|
|
this.mTabstrip.ensureElementIsVisible(this.selectedItem, false);
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2007-08-22 09:01:54 +04:00
|
|
|
|
<method name="handleEvent">
|
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
|
<body><![CDATA[
|
|
|
|
|
switch (aEvent.type) {
|
2007-08-22 09:02:44 +04:00
|
|
|
|
case "resize":
|
2010-11-16 12:19:00 +03:00
|
|
|
|
if (aEvent.target != window)
|
|
|
|
|
break;
|
2007-08-22 09:02:44 +04:00
|
|
|
|
var width = this.mTabstrip.boxObject.width;
|
|
|
|
|
if (width != this.mTabstripWidth) {
|
|
|
|
|
this.adjustTabstrip();
|
2009-01-15 15:30:43 +03:00
|
|
|
|
this._fillTrailingGap();
|
2007-08-22 09:02:44 +04:00
|
|
|
|
this._handleTabSelect();
|
|
|
|
|
this.mTabstripWidth = width;
|
|
|
|
|
}
|
2011-01-25 22:21:56 +03:00
|
|
|
|
this.tabbrowser.updateWindowResizers();
|
2007-08-22 09:02:44 +04:00
|
|
|
|
break;
|
2011-04-12 10:50:56 +04:00
|
|
|
|
case "mouseout":
|
2011-07-27 09:26:14 +04:00
|
|
|
|
if (this.draggedTab)
|
2011-04-12 10:50:56 +04:00
|
|
|
|
break;
|
2011-07-27 09:26:14 +04:00
|
|
|
|
let bo = this.mTabstrip.boxObject;
|
|
|
|
|
if (aEvent.screenX >= bo.screenX && aEvent.screenX < bo.screenX + bo.width &&
|
|
|
|
|
aEvent.screenY >= bo.screenY && aEvent.screenY < bo.screenY + bo.height)
|
|
|
|
|
break;
|
|
|
|
|
let tabContextMenu = document.getElementById("tabContextMenu");
|
|
|
|
|
if (tabContextMenu.state == "open")
|
|
|
|
|
tabContextMenu.addEventListener("popuphidden", this);
|
|
|
|
|
else
|
2011-04-12 10:50:56 +04:00
|
|
|
|
this._unlockTabSizing();
|
|
|
|
|
break;
|
2011-07-27 09:26:14 +04:00
|
|
|
|
case "popuphidden": // Tab context menu was closed.
|
|
|
|
|
if (aEvent.eventPhase != Event.AT_TARGET)
|
|
|
|
|
break;
|
|
|
|
|
aEvent.target.removeEventListener("popuphidden", this);
|
|
|
|
|
this._unlockTabSizing();
|
|
|
|
|
break;
|
|
|
|
|
case "mousemove":
|
|
|
|
|
this._handleTabDrag(aEvent);
|
|
|
|
|
break;
|
|
|
|
|
case "mouseup":
|
|
|
|
|
this._handleTabDrop(aEvent);
|
|
|
|
|
break;
|
|
|
|
|
case "TabSelect": // Focus was stolen from dragged tab!
|
|
|
|
|
this._endTabDrag(aEvent);
|
|
|
|
|
window.focus();
|
|
|
|
|
break;
|
|
|
|
|
case "scroll": // Tab strip was scrolled.
|
|
|
|
|
this._handleTabDrag();
|
|
|
|
|
break;
|
2007-08-22 09:01:54 +04:00
|
|
|
|
}
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2009-10-13 23:57:48 +04:00
|
|
|
|
<field name="_animateElement">
|
|
|
|
|
this.mTabstrip._scrollButtonDown;
|
2007-08-22 09:02:12 +04:00
|
|
|
|
</field>
|
2010-07-17 12:08:43 +04:00
|
|
|
|
|
2007-08-22 09:01:34 +04:00
|
|
|
|
<method name="_notifyBackgroundTab">
|
|
|
|
|
<parameter name="aTab"/>
|
|
|
|
|
<body><![CDATA[
|
2010-06-24 18:29:02 +04:00
|
|
|
|
if (aTab.pinned)
|
|
|
|
|
return;
|
|
|
|
|
|
2009-07-10 13:13:10 +04:00
|
|
|
|
var scrollRect = this.mTabstrip.scrollClientRect;
|
|
|
|
|
var tab = aTab.getBoundingClientRect();
|
2007-08-22 09:01:34 +04:00
|
|
|
|
|
2008-03-04 14:24:41 +03:00
|
|
|
|
// Is the new tab already completely visible?
|
2009-07-10 13:13:10 +04:00
|
|
|
|
if (scrollRect.left <= tab.left && tab.right <= scrollRect.right)
|
2008-03-04 14:24:41 +03:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (this.mTabstrip.smoothScroll) {
|
2010-08-20 00:22:33 +04:00
|
|
|
|
let selected = !this.selectedItem.pinned &&
|
|
|
|
|
this.selectedItem.getBoundingClientRect();
|
2008-03-04 14:24:41 +03:00
|
|
|
|
|
|
|
|
|
// Can we make both the new tab and the selected tab completely visible?
|
2010-08-20 00:22:33 +04:00
|
|
|
|
if (!selected ||
|
|
|
|
|
Math.max(tab.right - selected.left, selected.right - tab.left) <=
|
|
|
|
|
scrollRect.width) {
|
2008-03-04 14:24:41 +03:00
|
|
|
|
this.mTabstrip.ensureElementIsVisible(aTab);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2007-08-22 09:01:34 +04:00
|
|
|
|
|
2009-04-13 21:38:09 +04:00
|
|
|
|
this.mTabstrip._smoothScrollByPixels(this.mTabstrip._isRTLScrollbox ?
|
2009-07-10 13:13:10 +04:00
|
|
|
|
selected.right - scrollRect.right :
|
|
|
|
|
selected.left - scrollRect.left);
|
2007-08-22 09:01:34 +04:00
|
|
|
|
}
|
2008-03-04 14:24:41 +03:00
|
|
|
|
|
2009-11-05 11:02:12 +03:00
|
|
|
|
if (!this._animateElement.hasAttribute("notifybgtab")) {
|
|
|
|
|
this._animateElement.setAttribute("notifybgtab", "true");
|
|
|
|
|
setTimeout(function (ele) {
|
|
|
|
|
ele.removeAttribute("notifybgtab");
|
|
|
|
|
}, 150, this._animateElement);
|
|
|
|
|
}
|
2007-08-22 09:01:34 +04:00
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
2010-03-17 09:36:13 +03:00
|
|
|
|
|
|
|
|
|
<method name="_getDragTargetTab">
|
|
|
|
|
<parameter name="event"/>
|
|
|
|
|
<body><![CDATA[
|
2010-09-03 00:08:05 +04:00
|
|
|
|
let tab = event.target.localName == "tab" ? event.target : null;
|
|
|
|
|
if (tab &&
|
|
|
|
|
(event.type == "drop" || event.type == "dragover") &&
|
|
|
|
|
event.dataTransfer.dropEffect == "link") {
|
|
|
|
|
let boxObject = tab.boxObject;
|
|
|
|
|
if (event.screenX < boxObject.screenX + boxObject.width * .25 ||
|
|
|
|
|
event.screenX > boxObject.screenX + boxObject.width * .75)
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return tab;
|
2010-03-17 09:36:13 +03:00
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="_getDropIndex">
|
|
|
|
|
<parameter name="event"/>
|
2011-07-27 09:26:14 +04:00
|
|
|
|
<parameter name="draggedTab"/>
|
2010-03-17 09:36:13 +03:00
|
|
|
|
<body><![CDATA[
|
2011-07-27 09:26:14 +04:00
|
|
|
|
function compare(a, b, lessThan) lessThan ? a < b : a > b;
|
|
|
|
|
let ltr = (window.getComputedStyle(this).direction == "ltr");
|
|
|
|
|
let eX = event.screenX;
|
|
|
|
|
let tabs = this.tabbrowser.visibleTabs;
|
|
|
|
|
|
|
|
|
|
if (draggedTab) {
|
|
|
|
|
let dist = draggedTab._dragData._dragDistX;
|
|
|
|
|
let tabX = draggedTab.boxObject.screenX + dist;
|
|
|
|
|
let draggingRight = dist > 0;
|
|
|
|
|
if (draggingRight)
|
|
|
|
|
tabX += draggedTab.boxObject.width;
|
|
|
|
|
// iterate through app tabs first, since their z-index is higher
|
|
|
|
|
else if (!draggedTab.pinned)
|
|
|
|
|
for (let i = 0, numPinned = this.tabbrowser._numPinnedTabs; i < numPinned; i++)
|
|
|
|
|
if (compare(eX, tabs[i].boxObject.screenX + tabs[i].boxObject.width / 2, ltr))
|
|
|
|
|
return i;
|
|
|
|
|
|
|
|
|
|
let i = tabs.indexOf(draggedTab), tab = draggedTab, next;
|
|
|
|
|
while (next = ltr ^ draggingRight ? tabs[--i] : tabs[++i]) {
|
|
|
|
|
let x = next.pinned == draggedTab.pinned ? tabX : eX;
|
|
|
|
|
let middleOfNextTab = next.boxObject.screenX + next.boxObject.width / 2;
|
|
|
|
|
if (!compare(x, middleOfNextTab, !draggingRight))
|
|
|
|
|
break;
|
|
|
|
|
// ensure an app tab is actually inside the normal tab region
|
|
|
|
|
if (draggedTab.pinned && !next.pinned &&
|
|
|
|
|
x < this.mTabstrip._scrollButtonUp.boxObject.screenX)
|
|
|
|
|
break;
|
|
|
|
|
tab = next;
|
|
|
|
|
}
|
|
|
|
|
return tab._tPos + (ltr ^ draggingRight ? 0 : 1);
|
2010-03-17 09:36:13 +03:00
|
|
|
|
}
|
2011-07-27 09:26:14 +04:00
|
|
|
|
|
|
|
|
|
let tab = this._getDragTargetTab(event);
|
|
|
|
|
for (let i = tab ? tab._tPos : 0; i < tabs.length; i++)
|
|
|
|
|
if (compare(eX, tabs[i].boxObject.screenX + tabs[i].boxObject.width / 2, ltr))
|
|
|
|
|
return tabs[i]._tPos;
|
|
|
|
|
return this.childElementCount;
|
2010-03-17 09:36:13 +03:00
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="_setEffectAllowedForDataTransfer">
|
|
|
|
|
<parameter name="event"/>
|
|
|
|
|
<body><![CDATA[
|
|
|
|
|
var dt = event.dataTransfer;
|
|
|
|
|
// Disallow dropping multiple items
|
|
|
|
|
if (dt.mozItemCount > 1)
|
|
|
|
|
return dt.effectAllowed = "none";
|
|
|
|
|
|
2010-05-26 19:28:25 +04:00
|
|
|
|
if (browserDragAndDrop.canDropLink(event)) {
|
|
|
|
|
// Here we need to do this manually
|
|
|
|
|
return dt.effectAllowed = dt.dropEffect = "link";
|
2010-03-17 09:36:13 +03:00
|
|
|
|
}
|
|
|
|
|
return dt.effectAllowed = "none";
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2010-06-14 12:10:54 +04:00
|
|
|
|
<method name="_handleNewTab">
|
|
|
|
|
<parameter name="tab"/>
|
|
|
|
|
<body><![CDATA[
|
2011-05-10 10:42:39 +04:00
|
|
|
|
if (tab.parentNode != this)
|
2010-06-14 12:10:54 +04:00
|
|
|
|
return;
|
2011-09-08 13:02:05 +04:00
|
|
|
|
tab._fullyOpen = true;
|
2010-06-14 12:10:54 +04:00
|
|
|
|
|
2010-08-20 00:24:07 +04:00
|
|
|
|
this.adjustTabstrip();
|
|
|
|
|
|
2010-06-14 12:10:54 +04:00
|
|
|
|
if (tab.getAttribute("selected") == "true") {
|
|
|
|
|
this._fillTrailingGap();
|
|
|
|
|
this._handleTabSelect();
|
|
|
|
|
} else {
|
|
|
|
|
this._notifyBackgroundTab(tab);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// XXXmano: this is a temporary workaround for bug 345399
|
|
|
|
|
// We need to manually update the scroll buttons disabled state
|
|
|
|
|
// if a tab was inserted to the overflow area or removed from it
|
|
|
|
|
// without any scrolling and when the tabbar has already
|
|
|
|
|
// overflowed.
|
|
|
|
|
this.mTabstrip._updateScrollButtonsDisabledState();
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
2011-04-12 10:50:56 +04:00
|
|
|
|
|
2010-08-25 17:16:33 +04:00
|
|
|
|
<method name="_canAdvanceToTab">
|
|
|
|
|
<parameter name="aTab"/>
|
|
|
|
|
<body>
|
|
|
|
|
<![CDATA[
|
2011-05-25 10:50:44 +04:00
|
|
|
|
return !aTab.closing;
|
2010-08-25 17:16:33 +04:00
|
|
|
|
]]>
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
2010-06-14 12:10:54 +04:00
|
|
|
|
|
2010-04-27 20:57:19 +04:00
|
|
|
|
<!-- Deprecated stuff, implemented for backwards compatibility. -->
|
|
|
|
|
<property name="mTabstripClosebutton" readonly="true"
|
|
|
|
|
onget="return document.getElementById('tabs-closebutton');"/>
|
|
|
|
|
<property name="mAllTabsPopup" readonly="true"
|
|
|
|
|
onget="return document.getElementById('alltabs-popup');"/>
|
2007-08-22 09:01:34 +04:00
|
|
|
|
</implementation>
|
2010-03-17 09:36:13 +03:00
|
|
|
|
|
2007-08-22 09:00:54 +04:00
|
|
|
|
<handlers>
|
2007-08-22 09:01:28 +04:00
|
|
|
|
<handler event="TabSelect" action="this._handleTabSelect();"/>
|
2010-03-17 09:36:13 +03:00
|
|
|
|
|
2010-06-14 12:10:54 +04:00
|
|
|
|
<handler event="transitionend"><![CDATA[
|
2010-08-07 00:15:18 +04:00
|
|
|
|
if (event.propertyName != "max-width")
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var tab = event.target;
|
|
|
|
|
|
2011-09-08 13:02:05 +04:00
|
|
|
|
if (tab.getAttribute("fadein") == "true") {
|
|
|
|
|
if (tab._fullyOpen)
|
|
|
|
|
this.adjustTabstrip();
|
|
|
|
|
else
|
|
|
|
|
this._handleNewTab(tab);
|
|
|
|
|
} else if (tab.closing) {
|
2010-08-07 00:15:18 +04:00
|
|
|
|
this.tabbrowser._endRemoveTab(tab);
|
2011-09-08 13:02:05 +04:00
|
|
|
|
}
|
2010-06-14 12:10:54 +04:00
|
|
|
|
]]></handler>
|
|
|
|
|
|
2010-03-17 09:36:13 +03:00
|
|
|
|
<handler event="dblclick"><![CDATA[
|
2011-06-16 02:46:12 +04:00
|
|
|
|
#ifndef XP_MACOSX
|
|
|
|
|
// When the tabbar has an unified appearance with the titlebar
|
|
|
|
|
// and menubar, a double-click in it should have the same behavior
|
|
|
|
|
// as double-clicking the titlebar
|
|
|
|
|
if (TabsInTitlebar.enabled ||
|
|
|
|
|
(TabsOnTop.enabled && this.parentNode._dragBindingAlive))
|
2011-02-23 23:07:35 +03:00
|
|
|
|
return;
|
|
|
|
|
#endif
|
2011-06-16 02:46:12 +04:00
|
|
|
|
|
|
|
|
|
if (event.button != 0 ||
|
|
|
|
|
event.originalTarget.localName != "box")
|
|
|
|
|
return;
|
|
|
|
|
|
2011-02-23 23:07:35 +03:00
|
|
|
|
// See hack note in the tabbrowser-close-tab-button binding
|
2011-06-16 02:46:12 +04:00
|
|
|
|
if (!this._blockDblClick)
|
2010-03-17 09:36:13 +03:00
|
|
|
|
BrowserOpenTab();
|
2011-06-16 02:46:12 +04:00
|
|
|
|
|
|
|
|
|
event.preventDefault();
|
2010-03-17 09:36:13 +03:00
|
|
|
|
]]></handler>
|
|
|
|
|
|
|
|
|
|
<handler event="click"><![CDATA[
|
2010-06-22 10:28:15 +04:00
|
|
|
|
if (event.button != 1)
|
2010-03-17 09:36:13 +03:00
|
|
|
|
return;
|
|
|
|
|
|
2010-06-22 10:28:15 +04:00
|
|
|
|
if (event.target.localName == "tab") {
|
|
|
|
|
if (this.childNodes.length > 1 || !this._closeWindowWithLastTab)
|
2011-04-12 10:50:56 +04:00
|
|
|
|
this.tabbrowser.removeTab(event.target, {animate: true, byMouse: true});
|
2010-06-22 10:28:15 +04:00
|
|
|
|
} else if (event.originalTarget.localName == "box") {
|
|
|
|
|
BrowserOpenTab();
|
|
|
|
|
} else {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2010-03-17 09:36:13 +03:00
|
|
|
|
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
]]></handler>
|
|
|
|
|
|
2010-05-13 19:37:17 +04:00
|
|
|
|
<handler event="keypress"><![CDATA[
|
|
|
|
|
if (event.altKey || event.shiftKey ||
|
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
|
!event.metaKey)
|
|
|
|
|
#else
|
|
|
|
|
!event.ctrlKey || event.metaKey)
|
|
|
|
|
#endif
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
switch (event.keyCode) {
|
|
|
|
|
case KeyEvent.DOM_VK_UP:
|
|
|
|
|
this.tabbrowser.moveTabBackward();
|
|
|
|
|
break;
|
|
|
|
|
case KeyEvent.DOM_VK_DOWN:
|
|
|
|
|
this.tabbrowser.moveTabForward();
|
|
|
|
|
break;
|
|
|
|
|
case KeyEvent.DOM_VK_RIGHT:
|
|
|
|
|
case KeyEvent.DOM_VK_LEFT:
|
|
|
|
|
this.tabbrowser.moveTabOver(event);
|
|
|
|
|
break;
|
|
|
|
|
case KeyEvent.DOM_VK_HOME:
|
|
|
|
|
this.tabbrowser.moveTabToStart();
|
|
|
|
|
break;
|
|
|
|
|
case KeyEvent.DOM_VK_END:
|
|
|
|
|
this.tabbrowser.moveTabToEnd();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
// Stop the keypress event for the above keyboard
|
|
|
|
|
// shortcuts only.
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
]]></handler>
|
|
|
|
|
|
2010-03-17 09:36:13 +03:00
|
|
|
|
<handler event="dragstart"><![CDATA[
|
2011-07-27 09:26:14 +04:00
|
|
|
|
if (this.draggedTab)
|
|
|
|
|
return;
|
2010-03-17 09:36:13 +03:00
|
|
|
|
var tab = this._getDragTargetTab(event);
|
2011-07-27 09:26:14 +04:00
|
|
|
|
if (!tab || !tab._fullyOpen || tab.closing)
|
2010-03-17 09:36:13 +03:00
|
|
|
|
return;
|
|
|
|
|
|
2011-07-29 08:26:38 +04:00
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
|
if (event.altKey) {
|
|
|
|
|
#else
|
|
|
|
|
if (event.ctrlKey) {
|
|
|
|
|
#endif
|
|
|
|
|
let dt = event.dataTransfer;
|
2011-08-02 04:57:48 +04:00
|
|
|
|
let browser = tab.linkedBrowser;
|
|
|
|
|
dt.setData("text/x-moz-url", browser.currentURI.spec + "\n" + browser.contentTitle);
|
2011-07-29 08:26:38 +04:00
|
|
|
|
let favicon = document.getAnonymousElementByAttribute(tab, "class", "tab-icon-image");
|
|
|
|
|
dt.setDragImage(favicon, 16, 16);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-27 09:26:14 +04:00
|
|
|
|
this.setAttribute("drag", "move");
|
|
|
|
|
this.draggedTab = tab;
|
|
|
|
|
tab.setAttribute("dragged", "true");
|
|
|
|
|
let data = tab._dragData = {};
|
|
|
|
|
data._dragStartX = event.screenX;
|
|
|
|
|
if (!tab.pinned)
|
|
|
|
|
data._dragStartX += this.mTabstrip.scrollPosition;
|
|
|
|
|
data._dragDistX = 0;
|
|
|
|
|
data._dragOffsetY = event.screenY - window.screenY;
|
|
|
|
|
data._dropIndex = tab._tPos;
|
|
|
|
|
data._savedEvent = event;
|
|
|
|
|
data._targetWindow = window;
|
|
|
|
|
|
|
|
|
|
document.addEventListener("mousemove", this);
|
|
|
|
|
document.addEventListener("mouseup", this);
|
|
|
|
|
this.addEventListener("TabSelect", this);
|
|
|
|
|
this.mTabstrip.addEventListener("scroll", this);
|
2011-07-04 14:51:47 +04:00
|
|
|
|
|
2010-03-17 09:36:13 +03:00
|
|
|
|
event.stopPropagation();
|
|
|
|
|
]]></handler>
|
|
|
|
|
|
2011-07-27 09:26:14 +04:00
|
|
|
|
<handler event="dragover" action="this._positionDropIndicator(event);"/>
|
2010-03-17 09:36:13 +03:00
|
|
|
|
|
|
|
|
|
<handler event="drop"><![CDATA[
|
|
|
|
|
this._tabDropIndicator.collapsed = true;
|
|
|
|
|
|
2011-07-27 09:26:14 +04:00
|
|
|
|
let dt = event.dataTransfer;
|
|
|
|
|
if (dt.dropEffect != "link")
|
|
|
|
|
return;
|
2010-08-09 11:43:24 +04:00
|
|
|
|
|
2011-07-27 09:26:14 +04:00
|
|
|
|
let url = browserDragAndDrop.drop(event, { });
|
2010-08-09 11:43:24 +04:00
|
|
|
|
|
2011-07-27 09:26:14 +04:00
|
|
|
|
// Disallow dropping strings that contain spaces (not a valid url
|
|
|
|
|
// character). Also disallow dropping javascript: or data: urls.
|
|
|
|
|
if (!url || !url.length || url.indexOf(" ") != -1 ||
|
|
|
|
|
/^\s*(javascript|data):/.test(url))
|
|
|
|
|
return;
|
2010-03-17 09:36:13 +03:00
|
|
|
|
|
2011-07-27 09:26:14 +04:00
|
|
|
|
let bgLoad = Services.prefs.getBoolPref("browser.tabs.loadInBackground");
|
2010-03-17 09:36:13 +03:00
|
|
|
|
|
2011-07-27 09:26:14 +04:00
|
|
|
|
if (event.shiftKey)
|
|
|
|
|
bgLoad = !bgLoad;
|
2010-03-17 09:36:13 +03:00
|
|
|
|
|
2011-07-27 09:26:14 +04:00
|
|
|
|
let tab = this._getDragTargetTab(event);
|
|
|
|
|
if (!tab) {
|
|
|
|
|
// We're adding a new tab.
|
|
|
|
|
let newIndex = this._getDropIndex(event);
|
|
|
|
|
let newTab = this.tabbrowser.loadOneTab(getShortcutOrURI(url), {inBackground: bgLoad});
|
|
|
|
|
this.tabbrowser.moveTabTo(newTab, newIndex);
|
2010-03-17 09:36:13 +03:00
|
|
|
|
} else {
|
2011-07-27 09:26:14 +04:00
|
|
|
|
// Load in an existing tab.
|
|
|
|
|
try {
|
|
|
|
|
this.tabbrowser.getBrowserForTab(tab).loadURI(getShortcutOrURI(url));
|
|
|
|
|
if (!bgLoad)
|
|
|
|
|
this.selectedItem = tab;
|
|
|
|
|
ind.collapsed = true;
|
2010-03-17 09:36:13 +03:00
|
|
|
|
return;
|
2011-07-27 09:26:14 +04:00
|
|
|
|
} catch(ex) {
|
|
|
|
|
// Just ignore invalid urls.
|
2010-03-17 09:36:13 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
]]></handler>
|
|
|
|
|
|
2010-12-03 19:19:55 +03:00
|
|
|
|
<handler event="dragexit"><![CDATA[
|
2010-03-17 09:36:13 +03:00
|
|
|
|
this._dragTime = 0;
|
|
|
|
|
|
|
|
|
|
// This does not work at all (see bug 458613)
|
|
|
|
|
var target = event.relatedTarget;
|
|
|
|
|
while (target && target != this)
|
|
|
|
|
target = target.parentNode;
|
|
|
|
|
if (target)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
this._tabDropIndicator.collapsed = true;
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
]]></handler>
|
2007-08-22 09:01:34 +04:00
|
|
|
|
</handlers>
|
|
|
|
|
</binding>
|
|
|
|
|
|
2007-08-22 09:01:33 +04:00
|
|
|
|
<!-- close-tab-button binding
|
|
|
|
|
This binding relies on the structure of the tabbrowser binding.
|
2007-08-22 09:01:34 +04:00
|
|
|
|
Therefore it should only be used as a child of the tab or the tabs
|
2007-08-22 09:01:33 +04:00
|
|
|
|
element (in both cases, when they are anonymous nodes of <tabbrowser>).
|
|
|
|
|
-->
|
|
|
|
|
<binding id="tabbrowser-close-tab-button"
|
2007-08-22 09:02:01 +04:00
|
|
|
|
extends="chrome://global/content/bindings/toolbarbutton.xml#toolbarbutton-image">
|
2007-08-22 09:01:33 +04:00
|
|
|
|
<handlers>
|
2007-08-22 09:02:09 +04:00
|
|
|
|
<handler event="click" button="0"><![CDATA[
|
2007-08-22 09:01:33 +04:00
|
|
|
|
var bindingParent = document.getBindingParent(this);
|
2010-04-27 20:57:19 +04:00
|
|
|
|
var tabContainer = bindingParent.parentNode;
|
|
|
|
|
/* The only sequence in which a second click event (i.e. dblclik)
|
|
|
|
|
* can be dispatched on an in-tab close button is when it is shown
|
|
|
|
|
* after the first click (i.e. the first click event was dispatched
|
|
|
|
|
* on the tab). This happens when we show the close button only on
|
|
|
|
|
* the active tab. (bug 352021)
|
|
|
|
|
* The only sequence in which a third click event can be dispatched
|
|
|
|
|
* on an in-tab close button is when the tab was opened with a
|
|
|
|
|
* double click on the tabbar. (bug 378344)
|
|
|
|
|
* In both cases, it is most likely that the close button area has
|
|
|
|
|
* been accidentally clicked, therefore we do not close the tab.
|
|
|
|
|
*
|
|
|
|
|
* We don't want to ignore processing of more than one click event,
|
|
|
|
|
* though, since the user might actually be repeatedly clicking to
|
|
|
|
|
* close many tabs at once.
|
|
|
|
|
*/
|
|
|
|
|
if (event.detail > 1 && !this._ignoredClick) {
|
|
|
|
|
this._ignoredClick = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2008-03-09 03:31:39 +03:00
|
|
|
|
|
2010-04-27 20:57:19 +04:00
|
|
|
|
// Reset the "ignored click" flag
|
|
|
|
|
this._ignoredClick = false;
|
|
|
|
|
|
2011-04-12 10:50:56 +04:00
|
|
|
|
tabContainer.tabbrowser.removeTab(bindingParent, {animate: true, byMouse: true});
|
2010-06-14 12:09:55 +04:00
|
|
|
|
tabContainer._blockDblClick = true;
|
2010-04-27 20:57:19 +04:00
|
|
|
|
|
|
|
|
|
/* XXXmano hack (see bug 343628):
|
|
|
|
|
* Since we're removing the event target, if the user
|
|
|
|
|
* double-clicks this button, the dblclick event will be dispatched
|
|
|
|
|
* with the tabbar as its event target (and explicit/originalTarget),
|
|
|
|
|
* which treats that as a mouse gesture for opening a new tab.
|
|
|
|
|
* In this context, we're manually blocking the dblclick event
|
|
|
|
|
* (see dblclick handler).
|
|
|
|
|
*/
|
|
|
|
|
var clickedOnce = false;
|
|
|
|
|
function enableDblClick(event) {
|
|
|
|
|
if (event.detail == 1 && !clickedOnce) {
|
|
|
|
|
clickedOnce = true;
|
2010-03-17 09:36:13 +03:00
|
|
|
|
return;
|
|
|
|
|
}
|
2010-04-27 20:57:19 +04:00
|
|
|
|
setTimeout(function() {
|
2010-06-14 12:09:55 +04:00
|
|
|
|
tabContainer._blockDblClick = false;
|
2010-04-27 20:57:19 +04:00
|
|
|
|
}, 0);
|
|
|
|
|
tabContainer.removeEventListener("click", enableDblClick, false);
|
2007-08-22 09:01:33 +04:00
|
|
|
|
}
|
2010-04-27 20:57:19 +04:00
|
|
|
|
tabContainer.addEventListener("click", enableDblClick, false);
|
2007-08-22 09:01:33 +04:00
|
|
|
|
]]></handler>
|
2010-03-17 09:36:13 +03:00
|
|
|
|
|
2007-08-22 09:02:09 +04:00
|
|
|
|
<handler event="dblclick" button="0" phase="capturing">
|
2007-08-22 09:01:33 +04:00
|
|
|
|
// for the one-close-button case
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
</handler>
|
2010-03-17 09:36:13 +03:00
|
|
|
|
|
|
|
|
|
<handler event="dragstart">
|
|
|
|
|
event.stopPropagation();
|
|
|
|
|
</handler>
|
2007-08-22 09:01:33 +04:00
|
|
|
|
</handlers>
|
|
|
|
|
</binding>
|
|
|
|
|
|
2007-11-21 15:04:21 +03:00
|
|
|
|
<binding id="tabbrowser-tab" display="xul:hbox"
|
2007-08-22 09:00:54 +04:00
|
|
|
|
extends="chrome://global/content/bindings/tabbox.xml#tab">
|
2010-03-17 09:36:13 +03:00
|
|
|
|
<resources>
|
|
|
|
|
<stylesheet src="chrome://browser/content/tabbrowser.css"/>
|
|
|
|
|
</resources>
|
|
|
|
|
|
2010-07-17 12:08:43 +04:00
|
|
|
|
<content context="tabContextMenu" closetabtext="&closeTab.label;">
|
2010-09-15 11:28:37 +04:00
|
|
|
|
<xul:stack class="tab-stack" flex="1">
|
2010-11-29 17:18:40 +03:00
|
|
|
|
<xul:hbox xbl:inherits="pinned,selected,titlechanged"
|
|
|
|
|
class="tab-background">
|
|
|
|
|
<xul:hbox xbl:inherits="pinned,selected,titlechanged"
|
|
|
|
|
class="tab-background-start"/>
|
|
|
|
|
<xul:hbox xbl:inherits="pinned,selected,titlechanged"
|
|
|
|
|
class="tab-background-middle"/>
|
|
|
|
|
<xul:hbox xbl:inherits="pinned,selected,titlechanged"
|
|
|
|
|
class="tab-background-end"/>
|
|
|
|
|
</xul:hbox>
|
|
|
|
|
<xul:hbox xbl:inherits="pinned,selected,titlechanged"
|
|
|
|
|
class="tab-content" align="center">
|
2010-10-12 07:47:59 +04:00
|
|
|
|
<xul:image xbl:inherits="fadein,pinned,busy,progress,selected"
|
|
|
|
|
class="tab-throbber"
|
|
|
|
|
role="presentation"/>
|
|
|
|
|
<xul:image xbl:inherits="validate,src=image,fadein,pinned,selected"
|
2010-09-15 11:28:37 +04:00
|
|
|
|
class="tab-icon-image"
|
|
|
|
|
role="presentation"/>
|
|
|
|
|
<xul:label flex="1"
|
|
|
|
|
xbl:inherits="value=label,crop,accesskey,fadein,pinned,selected"
|
|
|
|
|
class="tab-text tab-label"
|
|
|
|
|
role="presentation"/>
|
|
|
|
|
<xul:toolbarbutton anonid="close-button"
|
|
|
|
|
xbl:inherits="fadein,pinned,selected"
|
|
|
|
|
clickthrough="never"
|
|
|
|
|
class="tab-close-button"/>
|
|
|
|
|
</xul:hbox>
|
|
|
|
|
</xul:stack>
|
2007-08-22 09:00:54 +04:00
|
|
|
|
</content>
|
2007-08-22 09:00:55 +04:00
|
|
|
|
|
2007-08-22 09:00:54 +04:00
|
|
|
|
<implementation>
|
2010-06-24 18:29:02 +04:00
|
|
|
|
<property name="pinned" readonly="true">
|
|
|
|
|
<getter>
|
|
|
|
|
return this.getAttribute("pinned") == "true";
|
|
|
|
|
</getter>
|
|
|
|
|
</property>
|
2010-10-11 21:27:05 +04:00
|
|
|
|
<property name="hidden" readonly="true">
|
|
|
|
|
<getter>
|
|
|
|
|
return this.getAttribute("hidden") == "true";
|
|
|
|
|
</getter>
|
|
|
|
|
</property>
|
2010-06-24 18:29:02 +04:00
|
|
|
|
|
2007-08-22 09:00:54 +04:00
|
|
|
|
<field name="mOverCloseButton">false</field>
|
2009-07-10 22:34:46 +04:00
|
|
|
|
<field name="mCorrespondingMenuitem">null</field>
|
2011-05-25 10:50:44 +04:00
|
|
|
|
<field name="closing">false</field>
|
2007-08-22 09:00:54 +04:00
|
|
|
|
</implementation>
|
|
|
|
|
|
|
|
|
|
<handlers>
|
|
|
|
|
<handler event="mouseover">
|
|
|
|
|
var anonid = event.originalTarget.getAttribute("anonid");
|
|
|
|
|
if (anonid == "close-button")
|
|
|
|
|
this.mOverCloseButton = true;
|
|
|
|
|
</handler>
|
|
|
|
|
<handler event="mouseout">
|
|
|
|
|
var anonid = event.originalTarget.getAttribute("anonid");
|
|
|
|
|
if (anonid == "close-button")
|
|
|
|
|
this.mOverCloseButton = false;
|
|
|
|
|
</handler>
|
2009-03-09 20:43:44 +03:00
|
|
|
|
<handler event="dragstart" phase="capturing">
|
|
|
|
|
this.style.MozUserFocus = '';
|
|
|
|
|
</handler>
|
2011-09-06 18:22:57 +04:00
|
|
|
|
<handler event="mousedown" phase="capturing">
|
2007-08-22 09:00:54 +04:00
|
|
|
|
<![CDATA[
|
2011-08-30 19:30:41 +04:00
|
|
|
|
if (this.selected) {
|
2009-03-09 20:43:44 +03:00
|
|
|
|
this.style.MozUserFocus = 'ignore';
|
|
|
|
|
this.clientTop; // just using this to flush style updates
|
2011-09-06 18:22:57 +04:00
|
|
|
|
} else if (this.mOverCloseButton) {
|
|
|
|
|
// Prevent tabbox.xml from selecting the tab.
|
|
|
|
|
event.stopPropagation();
|
2009-03-09 20:43:44 +03:00
|
|
|
|
}
|
2007-08-22 09:00:54 +04:00
|
|
|
|
]]>
|
2009-03-09 20:43:44 +03:00
|
|
|
|
</handler>
|
|
|
|
|
<handler event="mouseup">
|
|
|
|
|
this.style.MozUserFocus = '';
|
|
|
|
|
</handler>
|
2007-08-22 09:00:54 +04:00
|
|
|
|
</handlers>
|
|
|
|
|
</binding>
|
2007-08-22 08:58:49 +04:00
|
|
|
|
|
2009-07-10 22:34:46 +04:00
|
|
|
|
<binding id="tabbrowser-alltabs-popup"
|
|
|
|
|
extends="chrome://global/content/bindings/popup.xml#popup">
|
|
|
|
|
<implementation implements="nsIDOMEventListener">
|
|
|
|
|
<method name="_menuItemOnCommand">
|
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
|
<body><![CDATA[
|
2010-04-27 20:57:19 +04:00
|
|
|
|
gBrowser.selectedTab = aEvent.target.tab;
|
2009-07-10 22:34:46 +04:00
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="_tabOnAttrModified">
|
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
|
<body><![CDATA[
|
2009-12-12 22:31:21 +03:00
|
|
|
|
var tab = aEvent.target;
|
|
|
|
|
this._setMenuitemAttributes(tab.mCorrespondingMenuitem, tab);
|
2009-07-10 22:34:46 +04:00
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="_tabOnTabClose">
|
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
|
<body><![CDATA[
|
|
|
|
|
var menuItem = aEvent.target.mCorrespondingMenuitem;
|
|
|
|
|
if (menuItem)
|
|
|
|
|
this.removeChild(menuItem);
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="handleEvent">
|
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
|
<body><![CDATA[
|
|
|
|
|
if (!aEvent.isTrusted)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
switch (aEvent.type) {
|
|
|
|
|
case "command":
|
|
|
|
|
this._menuItemOnCommand(aEvent);
|
|
|
|
|
break;
|
2009-12-12 22:31:21 +03:00
|
|
|
|
case "TabAttrModified":
|
2009-07-10 22:34:46 +04:00
|
|
|
|
this._tabOnAttrModified(aEvent);
|
|
|
|
|
break;
|
|
|
|
|
case "TabClose":
|
|
|
|
|
this._tabOnTabClose(aEvent);
|
|
|
|
|
break;
|
|
|
|
|
case "TabOpen":
|
|
|
|
|
this._createTabMenuItem(aEvent.originalTarget);
|
|
|
|
|
break;
|
|
|
|
|
case "scroll":
|
|
|
|
|
this._updateTabsVisibilityStatus();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="_updateTabsVisibilityStatus">
|
|
|
|
|
<body><![CDATA[
|
2010-04-27 20:57:19 +04:00
|
|
|
|
var tabContainer = gBrowser.tabContainer;
|
2009-07-10 22:34:46 +04:00
|
|
|
|
// We don't want menu item decoration unless there is overflow.
|
|
|
|
|
if (tabContainer.getAttribute("overflow") != "true")
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var tabstripBO = tabContainer.mTabstrip.scrollBoxObject;
|
|
|
|
|
for (var i = 0; i < this.childNodes.length; i++) {
|
2011-04-29 09:21:13 +04:00
|
|
|
|
let curTab = this.childNodes[i].tab;
|
|
|
|
|
if (!curTab) // "Tab Groups" menuitem and its menuseparator
|
|
|
|
|
continue;
|
|
|
|
|
let curTabBO = curTab.boxObject;
|
|
|
|
|
if (!curTabBO) // "Tabs From Other Computers" menuitem
|
|
|
|
|
continue;
|
2009-07-10 22:34:46 +04:00
|
|
|
|
if (curTabBO.screenX >= tabstripBO.screenX &&
|
|
|
|
|
curTabBO.screenX + curTabBO.width <= tabstripBO.screenX + tabstripBO.width)
|
2011-05-25 10:50:44 +04:00
|
|
|
|
this.childNodes[i].setAttribute("tabIsVisible", "true");
|
2009-07-10 22:34:46 +04:00
|
|
|
|
else
|
|
|
|
|
this.childNodes[i].removeAttribute("tabIsVisible");
|
|
|
|
|
}
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
|
<method name="_createTabMenuItem">
|
|
|
|
|
<parameter name="aTab"/>
|
|
|
|
|
<body><![CDATA[
|
|
|
|
|
var menuItem = document.createElementNS(
|
2011-05-25 10:50:44 +04:00
|
|
|
|
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
|
2009-07-10 22:34:46 +04:00
|
|
|
|
"menuitem");
|
|
|
|
|
|
2010-04-27 20:57:19 +04:00
|
|
|
|
menuItem.setAttribute("class", "menuitem-iconic alltabs-item menuitem-with-favicon");
|
2009-07-10 22:34:46 +04:00
|
|
|
|
|
2009-12-12 22:31:21 +03:00
|
|
|
|
this._setMenuitemAttributes(menuItem, aTab);
|
2009-07-10 22:34:46 +04:00
|
|
|
|
|
|
|
|
|
// Keep some attributes of the menuitem in sync with its
|
|
|
|
|
// corresponding tab (e.g. the tab label)
|
|
|
|
|
aTab.mCorrespondingMenuitem = menuItem;
|
|
|
|
|
menuItem.tab = aTab;
|
|
|
|
|
menuItem.addEventListener("command", this, false);
|
|
|
|
|
|
|
|
|
|
this.appendChild(menuItem);
|
|
|
|
|
return menuItem;
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
2009-12-12 22:31:21 +03:00
|
|
|
|
|
|
|
|
|
<method name="_setMenuitemAttributes">
|
|
|
|
|
<parameter name="aMenuitem"/>
|
|
|
|
|
<parameter name="aTab"/>
|
|
|
|
|
<body><![CDATA[
|
|
|
|
|
aMenuitem.setAttribute("label", aTab.label);
|
|
|
|
|
aMenuitem.setAttribute("crop", aTab.getAttribute("crop"));
|
|
|
|
|
|
2011-09-16 21:42:32 +04:00
|
|
|
|
if (aTab.hasAttribute("busy")) {
|
2009-12-12 22:31:21 +03:00
|
|
|
|
aMenuitem.setAttribute("busy", aTab.getAttribute("busy"));
|
2011-09-16 21:42:32 +04:00
|
|
|
|
aMenuitem.removeAttribute("image");
|
|
|
|
|
} else {
|
|
|
|
|
aMenuitem.setAttribute("image", aTab.getAttribute("image"));
|
2009-12-12 22:31:21 +03:00
|
|
|
|
aMenuitem.removeAttribute("busy");
|
2011-09-16 21:42:32 +04:00
|
|
|
|
}
|
2009-12-12 22:31:21 +03:00
|
|
|
|
|
2011-09-27 12:39:22 +04:00
|
|
|
|
if (aTab.hasAttribute("pending"))
|
|
|
|
|
aMenuitem.setAttribute("pending", aTab.getAttribute("pending"));
|
|
|
|
|
else
|
|
|
|
|
aMenuitem.removeAttribute("pending");
|
|
|
|
|
|
2009-12-12 22:31:21 +03:00
|
|
|
|
if (aTab.selected)
|
|
|
|
|
aMenuitem.setAttribute("selected", "true");
|
|
|
|
|
else
|
|
|
|
|
aMenuitem.removeAttribute("selected");
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
2009-07-10 22:34:46 +04:00
|
|
|
|
</implementation>
|
|
|
|
|
|
|
|
|
|
<handlers>
|
|
|
|
|
<handler event="popupshowing">
|
|
|
|
|
<![CDATA[
|
|
|
|
|
// set up the menu popup
|
2010-04-27 20:57:19 +04:00
|
|
|
|
var tabcontainer = gBrowser.tabContainer;
|
2010-07-30 03:39:57 +04:00
|
|
|
|
let tabs = gBrowser.visibleTabs;
|
2009-07-10 22:34:46 +04:00
|
|
|
|
|
|
|
|
|
// Listen for changes in the tab bar.
|
2009-10-13 23:57:48 +04:00
|
|
|
|
tabcontainer.addEventListener("TabOpen", this, false);
|
2009-12-12 22:31:21 +03:00
|
|
|
|
tabcontainer.addEventListener("TabAttrModified", this, false);
|
|
|
|
|
tabcontainer.addEventListener("TabClose", this, false);
|
2009-07-10 22:34:46 +04:00
|
|
|
|
tabcontainer.mTabstrip.addEventListener("scroll", this, false);
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < tabs.length; i++) {
|
|
|
|
|
this._createTabMenuItem(tabs[i]);
|
|
|
|
|
}
|
|
|
|
|
this._updateTabsVisibilityStatus();
|
|
|
|
|
]]></handler>
|
|
|
|
|
|
2009-12-12 01:04:02 +03:00
|
|
|
|
<handler event="popuphidden">
|
2009-07-10 22:34:46 +04:00
|
|
|
|
<![CDATA[
|
|
|
|
|
// clear out the menu popup and remove the listeners
|
2011-02-19 13:35:02 +03:00
|
|
|
|
for (let i = this.childNodes.length - 1; i > 0; i--) {
|
|
|
|
|
let menuItem = this.childNodes[i];
|
2011-04-29 09:21:13 +04:00
|
|
|
|
if (menuItem.tab) {
|
2011-02-19 13:35:02 +03:00
|
|
|
|
menuItem.removeEventListener("command", this, false);
|
|
|
|
|
menuItem.tab.mCorrespondingMenuitem = null;
|
|
|
|
|
this.removeChild(menuItem);
|
|
|
|
|
}
|
2009-07-10 22:34:46 +04:00
|
|
|
|
}
|
2010-04-27 20:57:19 +04:00
|
|
|
|
var tabcontainer = gBrowser.tabContainer;
|
2009-07-10 22:34:46 +04:00
|
|
|
|
tabcontainer.mTabstrip.removeEventListener("scroll", this, false);
|
2009-10-13 23:57:48 +04:00
|
|
|
|
tabcontainer.removeEventListener("TabOpen", this, false);
|
2009-12-12 22:31:21 +03:00
|
|
|
|
tabcontainer.removeEventListener("TabAttrModified", this, false);
|
|
|
|
|
tabcontainer.removeEventListener("TabClose", this, false);
|
2009-07-10 22:34:46 +04:00
|
|
|
|
]]></handler>
|
|
|
|
|
|
|
|
|
|
<handler event="DOMMenuItemActive">
|
|
|
|
|
<![CDATA[
|
|
|
|
|
var tab = event.target.tab;
|
|
|
|
|
if (tab) {
|
2010-10-12 20:30:57 +04:00
|
|
|
|
let overLink = tab.linkedBrowser.currentURI.spec;
|
|
|
|
|
if (overLink == "about:blank")
|
|
|
|
|
overLink = "";
|
|
|
|
|
XULBrowserWindow.setOverLink(overLink, null);
|
2009-07-10 22:34:46 +04:00
|
|
|
|
}
|
|
|
|
|
]]></handler>
|
|
|
|
|
|
|
|
|
|
<handler event="DOMMenuItemInactive">
|
|
|
|
|
<![CDATA[
|
2009-07-21 08:25:59 +04:00
|
|
|
|
XULBrowserWindow.setOverLink("", null);
|
2009-07-10 22:34:46 +04:00
|
|
|
|
]]></handler>
|
|
|
|
|
|
|
|
|
|
</handlers>
|
|
|
|
|
</binding>
|
|
|
|
|
|
2011-01-28 16:35:49 +03:00
|
|
|
|
<binding id="statuspanel" display="xul:hbox">
|
|
|
|
|
<content>
|
|
|
|
|
<xul:hbox class="statuspanel-inner">
|
|
|
|
|
<xul:label class="statuspanel-label"
|
2011-01-28 09:48:28 +03:00
|
|
|
|
role="status"
|
2011-02-28 14:58:44 +03:00
|
|
|
|
xbl:inherits="value=label,crop,mirror"
|
2011-01-28 16:35:49 +03:00
|
|
|
|
flex="1"
|
|
|
|
|
crop="end"/>
|
|
|
|
|
</xul:hbox>
|
|
|
|
|
</content>
|
|
|
|
|
|
2011-03-03 03:48:58 +03:00
|
|
|
|
<implementation implements="nsIDOMEventListener">
|
|
|
|
|
<constructor><![CDATA[
|
|
|
|
|
window.addEventListener("findbaropen", this, false);
|
|
|
|
|
]]></constructor>
|
|
|
|
|
|
|
|
|
|
<destructor><![CDATA[
|
|
|
|
|
window.removeEventListener("findbaropen", this, false);
|
|
|
|
|
]]></destructor>
|
|
|
|
|
|
2011-01-28 16:35:49 +03:00
|
|
|
|
<property name="label">
|
2011-02-10 00:40:13 +03:00
|
|
|
|
<setter><![CDATA[
|
2011-03-03 03:48:58 +03:00
|
|
|
|
if (!this.label) {
|
|
|
|
|
if (window.gFindBarInitialized && !window.gFindBar.hidden)
|
|
|
|
|
this.setAttribute("mirror", "true");
|
|
|
|
|
else
|
|
|
|
|
this.removeAttribute("mirror");
|
|
|
|
|
}
|
2011-02-10 00:40:13 +03:00
|
|
|
|
|
|
|
|
|
this.style.minWidth = this.getAttribute("type") == "status" &&
|
|
|
|
|
this.getAttribute("previoustype") == "status"
|
|
|
|
|
? getComputedStyle(this).width : "";
|
|
|
|
|
|
2011-09-27 11:51:56 +04:00
|
|
|
|
if (val) {
|
|
|
|
|
this.setAttribute("label", val);
|
|
|
|
|
this.removeAttribute("inactive");
|
|
|
|
|
} else {
|
|
|
|
|
this.setAttribute("inactive", "true");
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-28 16:35:49 +03:00
|
|
|
|
return val;
|
2011-02-10 00:40:13 +03:00
|
|
|
|
]]></setter>
|
2011-01-28 16:35:49 +03:00
|
|
|
|
<getter>
|
2011-09-27 11:51:56 +04:00
|
|
|
|
return this.hasAttribute("inactive") ? "" : this.getAttribute("label");
|
2011-01-28 16:35:49 +03:00
|
|
|
|
</getter>
|
|
|
|
|
</property>
|
2011-02-04 11:07:45 +03:00
|
|
|
|
|
2011-03-03 03:48:58 +03:00
|
|
|
|
<method name="handleEvent">
|
|
|
|
|
<parameter name="event"/>
|
|
|
|
|
<body><![CDATA[
|
|
|
|
|
if (event.type == "findbaropen" &&
|
|
|
|
|
this.label)
|
|
|
|
|
this.setAttribute("mirror", "true");
|
|
|
|
|
]]></body>
|
|
|
|
|
</method>
|
|
|
|
|
|
2011-02-04 11:07:45 +03:00
|
|
|
|
<method name="_mirror">
|
|
|
|
|
<body>
|
|
|
|
|
if (this.hasAttribute("mirror"))
|
|
|
|
|
this.removeAttribute("mirror");
|
|
|
|
|
else
|
|
|
|
|
this.setAttribute("mirror", "true");
|
|
|
|
|
</body>
|
|
|
|
|
</method>
|
2011-01-28 16:35:49 +03:00
|
|
|
|
</implementation>
|
|
|
|
|
|
|
|
|
|
<handlers>
|
2011-02-04 11:07:45 +03:00
|
|
|
|
<handler event="mouseover" action="this._mirror();"/>
|
|
|
|
|
<handler event="dragover" action="this._mirror();"/>
|
2011-01-28 16:35:49 +03:00
|
|
|
|
</handlers>
|
|
|
|
|
</binding>
|
|
|
|
|
|
2007-08-22 08:58:49 +04:00
|
|
|
|
</bindings>
|