home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0"?>
-
- <!DOCTYPE bindings [
- <!ENTITY % tabBrowserDTD SYSTEM "chrome://global/locale/tabbrowser.dtd" >
- %tabBrowserDTD;
- ]>
-
- <bindings id="tabBindings"
- xmlns="http://www.mozilla.org/xbl"
- xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
- xmlns:xbl="http://www.mozilla.org/xbl">
-
- <binding id="tab-base">
- <resources>
- <stylesheet src="chrome://global/skin/tabbox.css"/>
- </resources>
- </binding>
-
- <binding id="tabbox" display="xul:box"
- extends="chrome://global/content/bindings/tabbox.xml#tab-base">
- <implementation implements="nsIAccessibleProvider">
- <property name="accessible">
- <getter>
- <![CDATA[
- var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
- return accService.createXULTabBoxAccessible(this);
- ]]>
- </getter>
- </property>
-
- <property name="handleCtrlTab">
- <setter>
- <![CDATA[
- this.setAttribute("handleCtrlTab", val);
- return val;
- ]]>
- </setter>
- <getter>
- <![CDATA[
- return (this.getAttribute("handleCtrlTab") != "false");
- ]]>
- </getter>
- </property>
-
- <property name="handleCtrlPageUpDown">
- <setter>
- <![CDATA[
- this.setAttribute("handleCtrlPageUpDown", val);
- return val;
- ]]>
- </setter>
- <getter>
- <![CDATA[
- return (this.getAttribute("handleCtrlPageUpDown") != "false");
- ]]>
- </getter>
- </property>
-
- <property name="_tabs">
- <getter>
- <![CDATA[
- var tabs = this.getElementsByTagNameNS(
- "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
- "tabs");
- return tabs.length ? tabs[0] : null;
- ]]>
- </getter>
- </property>
-
- <property name="_tabpanels">
- <getter>
- <![CDATA[
- var tabpanels = this.getElementsByTagNameNS(
- "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
- "tabpanels");
- return tabpanels.length ? tabpanels[0] : null;
- ]]>
- </getter>
- </property>
-
- <property name="selectedIndex"
- onget="return this._tabs ? this._tabs.selectedIndex : null;">
- <setter>
- <![CDATA[
- if (this._tabs)
- this._tabs.selectedIndex = val;
- return val;
- ]]>
- </setter>
- </property>
-
- <property name="selectedTab"
- onget="return this._tabs ? this._tabs.selectedItem : null;">
- <setter>
- <![CDATA[
- if (!val)
- throw Components.results.NS_ERROR_NULL_POINTER;
- if (this._tabs)
- this._tabs.selectedItem = val;
- return val;
- ]]>
- </setter>
- </property>
-
- <property name="selectedPanel"
- onget="return this._tabpanels ? this._tabpanels.selectedPanel : null;">
- <setter>
- <![CDATA[
- if (!val)
- throw Components.results.NS_ERROR_NULL_POINTER;
- if (this._tabpanels)
- this._tabpanels.selectedPanel = val;
- return val;
- ]]>
- </setter>
- </property>
-
- <!-- store the last time CTRL-TAB was pressed -->
- <field name="_lastCtrlTabTime">
- null
- </field>
-
- <field name="_keyEventHandler" readonly="true">
- <![CDATA[({
- tabbox: this,
- handleEvent: function handleEvent(event) {
- if (!event.isTrusted) {
- // Don't let untrusted events mess with tabs.
- return;
- }
-
- switch (event.keyCode) {
- case event.DOM_VK_TAB:
- if (event.ctrlKey && !event.altKey && !event.metaKey) {
- // MERC (rpaul) hide the statusbar current engine menu popup and current tabs popup
- document.getElementById('currentEngineStatusbarPopup').hidePopup();
- document.getAnonymousElementByAttribute(this.tabbox._tabs, 'class', 'tabs-dropdown').firstChild.hidePopup();
-
- // MERC (DP): hide the site control popup (if it's open) before switching tabs
- document.getElementById('SiteControlsPopup').hidePopup();
-
- // MERC (DP): if last CTRL_TAB was more than threshold time (2 secs)
- // then go to last selected tab. otherwise cycle thru tabs.
- var now = new Date();
- if (this.tabbox._tabs && this.tabbox.handleCtrlTab) {
- if(!this.tabbox._tabs.lastSelectedTab) {
- this.tabbox._tabs.advanceSelectedTab(event.shiftKey ? -1 : 1);
- } else {
- if(!this._lastCtrlTabTime) {
- this.tabbox._tabs.selectedItem = this.tabbox._tabs.lastSelectedTab;
- } else {
- // threshold time is 2 seconds
- if(now - this._lastCtrlTabTime <= 2000) {
- this.tabbox._tabs.advanceSelectedTab(event.shiftKey ? -1 : 1);
- } else {
- this.tabbox._tabs.selectedItem = this.tabbox._tabs.lastSelectedTab;
- }
- }
- }
-
- // store the time ctrl-tab pressed
- this._lastCtrlTabTime = now.getTime();
-
- event.stopPropagation();
- event.preventDefault();
- }
- }
- break;
- case event.DOM_VK_PAGE_UP:
- if (event.ctrlKey && !event.shiftKey && !event.altKey && !event.metaKey)
- if (this.tabbox._tabs && this.tabbox.handleCtrlPageUpDown) {
- // MERC (rpaul) hide the statusbar current engine menu popup and current tabs popup
- document.getElementById('currentEngineStatusbarPopup').hidePopup();
- document.getAnonymousElementByAttribute(this.tabbox._tabs, 'class', 'tabs-dropdown').firstChild.hidePopup();
- // MERC (DP): hide the site control popup (if it's open) before switching tabs
- document.getElementById('SiteControlsPopup').hidePopup();
- this.tabbox._tabs.advanceSelectedTab(-1);
- event.stopPropagation();
- event.preventDefault();
- }
- break;
- case event.DOM_VK_PAGE_DOWN:
- if (event.ctrlKey && !event.shiftKey && !event.altKey && !event.metaKey)
- if (this.tabbox._tabs && this.tabbox.handleCtrlPageUpDown) {
- // MERC (rpaul) hide the statusbar current engine menu popup and current tabs popup
- document.getElementById('currentEngineStatusbarPopup').hidePopup();
- document.getAnonymousElementByAttribute(this.tabbox._tabs, 'class', 'tabs-dropdown').firstChild.hidePopup();
- // MERC (DP): hide the site control popup (if it's open) before switching tabs
- document.getElementById('SiteControlsPopup').hidePopup();
-
- // MERC (DP): hide the site control popup (if it's open) before switching tabs
- document.getElementById('SiteControlsPopup').hidePopup();
-
- this.tabbox._tabs.advanceSelectedTab(1);
- event.stopPropagation();
- event.preventDefault();
- }
- break;
- }
- }
- })]]>
- </field>
-
- <field name="_eventNode">this</field>
-
- <property name="eventNode" onget="return this._eventNode;">
- <setter>
- <![CDATA[
- if (val != this._eventNode) {
- val.addEventListener("keypress", this._keyEventHandler, true);
- this._eventNode.removeEventListener("keypress", this._keyEventHandler, true);
- this._eventNode = val;
- }
- return val;
- ]]>
- </setter>
- </property>
-
- <constructor>
- switch (this.getAttribute("eventnode")) {
- case "parent": this._eventNode = this.parentNode; break;
- case "window": this._eventNode = window; break;
- case "document": this._eventNode = document; break;
- }
- this._eventNode.addEventListener("keypress", this._keyEventHandler, true);
- </constructor>
-
- <destructor>
- this._eventNode.removeEventListener("keypress", this._keyEventHandler, true);
- </destructor>
- </implementation>
- </binding>
-
- <binding id="tabs" display="xul:box"
- extends="chrome://global/content/bindings/tabbox.xml#tab-base">
- <content>
- <xul:spacer class="tabs-left"/>
- <children/>
- <xul:spacer class="tabs-right" flex="1"/>
- </content>
-
- <implementation implements="nsIDOMXULSelectControlElement, nsIAccessibleProvider">
- <constructor>
- <![CDATA[
- var prefs = Components.classes["@mozilla.org/preferences-service;1"]
- .getService(Components.interfaces.nsIPrefService);
- prefs = prefs.getBranch(null);
-
- // this attribute detemines whether or not the close button appears on the tab
- if(prefs.getBoolPref("browser.tabs.showCloseButtonOnTab"))
- this.setAttribute("showCloseButton", "true");
-
- // this attribute detemines whether or not the site control button appears on the tab
- if(prefs.getBoolPref("browser.tabs.showSiteControlButtonOnTab"))
- this.setAttribute("showSiteControlButton", "true");
-
- // first and last tabs need to be able to have unique styles
- // and also need to select first tab on startup.
- if (this.firstChild)
- this.firstChild.setAttribute("first-tab", "true");
- if (this.lastChild)
- this.lastChild.setAttribute("last-tab", "true");
- this.selectedIndex = 0;
- var o = this.getAttribute("orient");
- if (!o)
- this.setAttribute("orient", "horizontal");
- ]]>
- </constructor>
-
- <property name="accessible">
- <getter>
- <![CDATA[
- var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
- return accService.createXULTabsAccessible(this);
- ]]>
- </getter>
- </property>
-
- <field name="lastSelectedTab">null</field>
-
- <property name="selectedIndex">
- <getter>
- <![CDATA[
- const tabs = this.childNodes;
- for (var i = 0; i < tabs.length; i++) {
- if (tabs[i].selected)
- return i;
- }
- // throw an exception when no tab is selected (we shouldn't get here)
- throw Components.results.NS_ERROR_FAILURE;
- ]]>
- </getter>
-
- <setter>
- <![CDATA[
- const tabs = this.childNodes;
- for (var i = 0; i < tabs.length; i++) {
- if (tabs[i].selected)
- this.lastSelectedTab = tabs[i];
- }
-
- if (0 <= val && val < tabs.length && !tabs[val].selected) {
-
- for (var i = 0; i < tabs.length; i++)
- if (i != val && tabs[i].selected)
- tabs[i].selected = false;
-
- tabs[val].selected = true;
-
- for (var parent = this.parentNode; parent; parent = parent.parentNode) {
- if (parent.localName == 'tabbox') {
- var tabpanels = parent._tabpanels;
- // This will cause an onselect event to fire for the tabpanel element.
- if (tabpanels) {
- // find an id
- var linkedPanelId = tabs[val].linkedPanel;
- var linkedPanel = linkedPanelId ? document.getElementById(linkedPanelId) : null;
- if (linkedPanel) {
- tabpanels.selectedPanel = linkedPanel;
- } else
- tabpanels.selectedIndex = val;
- }
- break;
- }
- }
-
- // Fire an onselect event for the tabs element.
- var event = document.createEvent('Events');
- event.initEvent('select', false, true);
- this.dispatchEvent(event);
- }
- return val;
- ]]>
- </setter>
- </property>
-
- <property name="selectedItem">
- <getter>
- <![CDATA[
- const tabs = this.childNodes;
- for (var i = 0; i < tabs.length; i++) {
- if (tabs[i].selected)
- return tabs[i];
- }
- // throw an exception when no tab is selected (we shouldn't get here)
- throw Components.results.NS_ERROR_FAILURE;
- ]]>
- </getter>
-
- <setter>
- <![CDATA[
- if (!val)
- throw Components.results.NS_ERROR_NULL_POINTER;
- if (!val.selected) {
- const tabs = this.childNodes;
- for (var i = 0; i < tabs.length; i++)
- if (tabs[i] == val)
- this.selectedIndex = i;
- }
- return val;
- ]]>
- </setter>
- </property>
-
- <method name="advanceSelectedTab">
- <parameter name="aDir"/>
- <body>
- <![CDATA[
- var startTab = this.selectedItem;
- var next = startTab[aDir == -1 ? "previousSibling" : "nextSibling"];
-
- while (next != startTab && (!next || next.getAttribute("hidden"))) {
- if (next && next.getAttribute("hidden"))
- next = next[aDir == -1 ? "previousSibling" : "nextSibling"];
- if (!next)
- next = aDir == 1 ? this.childNodes[0] : this.childNodes[this.childNodes.length - 1];
- }
-
- if (next && next != startTab) {
- this.selectedItem = next;
- if (this.getAttribute("setfocus") != "false") {
- next.focus();
- document.commandDispatcher.advanceFocusIntoSubtree(next);
- }
- }
- ]]>
- </body>
- </method>
-
- <method name="selectTabByIndex">
- <parameter name="aIndex"/>
- <body>
- <![CDATA[
- this.selectedItem = this.childNodes[aIndex];
- ]]>
- </body>
- </method>
-
- <method name="appendItem">
- <parameter name="label"/>
- <parameter name="value"/>
- <body>
- <![CDATA[
- var XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
- var tab = document.createElementNS(XULNS, "tab");
- tab.setAttribute("label", label);
- tab.setAttribute("value", value);
- this.appendChild(tab);
- return tab;
- ]]>
- </body>
- </method>
-
- <method name="insertItemAt">
- <parameter name="index"/>
- <parameter name="label"/>
- <parameter name="value"/>
- <body>
- <![CDATA[
- var XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
- var tab = document.createElementNS(XULNS, "tab");
- tab.setAttribute("label", label);
- tab.setAttribute("value", value);
- var before = this.childNodes[index];
- if (before)
- this.insertBefore(tab, before);
- else
- this.appendChild(tab);
- return tab;
- ]]>
- </body>
- </method>
-
- <method name="removeItemAt">
- <parameter name="index"/>
- <body>
- <![CDATA[
- var remove = this.childNodes[index];
- if (remove)
- this.removeChild(remove);
- return remove;
- ]]>
- </body>
- </method>
- </implementation>
- </binding>
-
- <binding id="tabs-closebutton"
- extends="chrome://global/content/bindings/tabbox.xml#tabs">
- <implementation>
- <property name="inHandleResize"/>
- <property name="lastWidth"/>
- <method name="handleResize">
- <body>
- <![CDATA[
- // If the toolbar has not actually changed width, bail out.
- // This helps avoid too-frequent calls.
-
- // MERC (DP) redraw was not happening if you delete a tab
- //if (this.boxObject.width == this.lastWidth) return;
-
- this.lastWidth = this.boxObject.width;
-
- // Function is not re-entrant
- if (this.inHandleResize) return;
- this.inHandleResize = true;
-
- // Iterate through the tabs
- var tabContainer = document.getAnonymousElementByAttribute(this,'anonid','tabcontainer');
- var containerRightExtent = tabContainer.boxObject.x + tabContainer.boxObject.width;
- var tab = this.firstChild;
- while (tab) {
- var tabRightExtent = tab.boxObject.x + tab.boxObject.width;
- if (tabRightExtent > containerRightExtent) {
- tab.setAttribute('taboverflow','true');
- } else {
- tab.removeAttribute('taboverflow');
- }
- tab = tab.nextSibling;
- }
-
- this.inHandleResize = false;
- ]]>
- </body>
- </method>
- </implementation>
- <content>
- <xul:toolbarbutton class="sidebar-button" anonid="sidebar-button" command="toggleSidebar"/>
- <!--MERC (rpaul) moving new tab button and drop to left of tab strip -->
- <xul:stack class="tabs-newbutton-stack" id="new-tab-button-container">
- <xul:toolbarbutton id="tabNewButton" class="tabs-newbutton" top="0" left="0"
- onmouseover="if (event.target.parentNode.parentNode.parentNode.
- firstChild.localName == 'tooltip') { event.target.parentNode.
- parentNode.parentNode.firstChild.setAttribute('label', 'Open a new tab');};"
- label="&tabs-newbutton.label;"
- xbl:inherits="oncommand=onnewpreftab"/>
- <xul:toolbarbutton id="tabs-newdropdown"
- class="tabs-newdropdown"
- onmouseover="if (event.target.parentNode.parentNode.parentNode.
- firstChild.localName == 'tooltip') { event.target.parentNode.
- parentNode.parentNode.firstChild.setAttribute('label', 'Select a new tab from list');};"
- left="24" top="14"/>
- </xul:stack>
-
- <xul:hbox anonid="tabcontainer" flex="1" style="min-width: 1px; overflow: hidden !important;">
- <children/>
- </xul:hbox>
-
- <xul:spacer class="tabs-right" flex="0"/>
-
- <!-- MERC (DP): this menu contains the list of all tabs open. the menuitems will
- be populated inside updateTabListMenu().
- -->
- <xul:toolbarbutton anonid="tabs-dropdown" type="menu" class="tabs-dropdown"
- onmouseover="if (event.target.parentNode.parentNode.firstChild.localName == 'tooltip')
- { event.target.parentNode.parentNode.
- firstChild.setAttribute('label', 'List open tabs');};"
- orient="horizontal" align="end">
- <xul:menupopup position="at_pointer" anonid="tabsDropDownMenu"
- onpopupshowing="tabbrowser = this.parentNode;
- while (tabbrowser.localName != 'tabbrowser')
- tabbrowser = tabbrowser.parentNode;
- tabbrowser.updateTabListMenu(this);">
- </xul:menupopup>
- </xul:toolbarbutton>
- </content>
- <handlers>
- <handler event="overflow">this.handleResize();</handler>
- <handler event="underflow">this.handleResize();</handler>
- </handlers>
- </binding>
-
- <binding id="tabpanels"
- extends="chrome://global/content/bindings/tabbox.xml#tab-base">
- <implementation implements="nsIAccessibleProvider">
- <property name="accessible">
- <getter>
- <![CDATA[
- var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
- return accService.createXULTabPanelsAccessible(this);
- ]]>
- </getter>
- </property>
-
- <field name="_selectedPanel">null</field>
-
- <property name="selectedIndex">
- <getter>
- <![CDATA[
- var indexStr = this.getAttribute("selectedIndex");
- return indexStr ? parseInt(indexStr) : -1;
- ]]>
- </getter>
-
- <setter>
- <![CDATA[
-
- var panel = this._selectedPanel;
- this._selectedPanel = this.childNodes[val];
- this.setAttribute("selectedIndex", val);
- if (this._selectedPanel != panel) {
- var event = document.createEvent("Events");
- event.initEvent("select", false, true);
- this.dispatchEvent(event);
- //MERC - JA this attribute is called always when tab selection is changed from UI
- //if(this._selectedPanel.localName == 'browser')//JA changed after ff5->vulp
- var browser = this._selectedPanel.firstChild.nextSibling;//from getBrowserAtIndex
- if(browser && browser.localName == 'browser')
- {
-
- BrowserStoreTabCharset();//Sliu, save current document character set for openPopupInTab
- window.onTabAction(2,val,null);//notify about new selected tab
- try{
- var hpDoc = browser.contentDocument.QueryInterface(Components.interfaces.nsIHTMLPluginDocument);
- if(hpDoc)
- hpDoc.setPluginFocus();
- }
- catch (e) {}
- }
- ///JA
- }
- return val;
- ]]>
- </setter>
- </property>
-
-
- <property name="selectedPanel">
- <getter>
- <![CDATA[
- return this._selectedPanel;
- ]]>
- </getter>
-
- <setter>
- <![CDATA[
- var selectedIndex = -1;
- for (var panel = val; panel != null; panel = panel.previousSibling)
- ++selectedIndex;
- this.selectedIndex = selectedIndex;
- return val;
- ]]>
- </setter>
- </property>
- </implementation>
- </binding>
-
- <binding id="tab" display="xul:button"
- extends="chrome://global/content/bindings/tabbox.xml#tab-base">
- <content>
- <xul:box class="tab-left"/>
- <xul:stack class="tab-content" flex="1"
- xbl:inherits="validate,image,label,accesskey,crop,disabled">
- <xul:hbox class="tab-content-bg" align="stretch">
- <xul:image class="tab-content-bgimage" flex="1"/>
- </xul:hbox>
- <xul:hbox class="tab-content-fg" align="end"
- xbl:inherits="validate,image,label,accesskey,crop,disabled">
- <xul:image class="tab-icon" xbl:inherits="validate,src=image"/>
- <xul:label class="tab-text" xbl:inherits="value=label,accesskey,crop,disabled" flex="1"/>
- <xul:toolbarbutton type="menu" class="tab-popupmenu-button" anonid="menubutton">
-
- </xul:toolbarbutton>
-
- <xul:hbox class="tab-closebutton-container">
- <xul:stack class="tab-closebutton-stack">
- <xul:hbox class="tab-closebutton-box" align="right" pack="end" anonid="closebutton-box">
- <xul:toolbarbutton anonid="closebutton"
- class="tab-closebutton close-button"
- ondblclick="event.preventBubble();"
- xbl:inherits="disabled=disableclose,oncommand=onclosetab"/>
- </xul:hbox>
- </xul:stack>
-
- </xul:hbox>
- </xul:hbox>
- </xul:stack>
- <xul:box class="tab-right"/>
- </content>
-
- <implementation implements="nsIDOMXULSelectControlItemElement, nsIAccessibleProvider">
- <method name="toggleDisplayEngineSiteControl">
- <body>
- <![CDATA[
- //dump('tabbox.xml: toggleDisplayEngineSiteControl()\n');
-
- var tabbrowser = this;
- while (tabbrowser.localName != 'tabbrowser') tabbrowser = tabbrowser.parentNode;
- var url = tabbrowser.currentURI.spec;
- var sc = sitecontrols.SCSVC;
-
- // To allow engine toggling, the URI must either be for a controllable site
- // (including local files) or else 'about:blank'. Otherwise, bail out...
- if ((url != 'about:blank') && (!sc.isControllableURI(url))) {
- dump('*** bailing out of toggleEngine\n');
- return;
- }
- // So now we know the site is either a controllable URI or 'about:blank'
-
- // Grab the RDF resource for this site
- var site;
- if (url == 'about:blank') {
- // We will treat this as if it's a DEFAULT site
- // This should be SiteControls:Default resource
- site = sc.getResourceForURI('');
- } else {
- site = sc.getResourceForURI(url);
- }
-
- // If the site being toggled is not handled by an *explicit* site
- // control, then we will want to add a new site control for it.
- if ((site.Value != sitecontrols.SC_LOCAL) && (url != 'about:blank'))
- {
- var host = sitecontrols.getStrippedHostFromURL(url);
- var pattern = sitecontrols.SCSVC.getControlledSite(host);
- if ((pattern != null) || (host && (host != "") && (host != pattern)))
- {
- sitecontrols.SCSVC.addControlledSite(host);
- site = sitecontrols.SCSVC.getResourceForURI(host);
-
- // we need to set the engine of the newly added SC for the redirect case
- //var currentEngine = tabbrowser.mCurrentBrowser.webNavigation.browserEngine;
- //sitecontrols.SCSVC.updateSiteControlResource(site, 'displayEngine', currentEngine);
- }
- }
-
- // Toggle the engine
- var currentEngine = tabbrowser.getBrowserForTab(tabbrowser.mCurrentTab).docShell.browserEngine;
- if (currentEngine == "Gecko") {
- // Changing from Gecko to Trident
- currentEngine = "Trident";
- } else {
- // Changing from Trident to Gecko
- currentEngine = "Gecko";
- }
- sc.updateSiteControlResource(site, 'displayEngine', currentEngine);
- sc.updateSiteControlResource(site, 'securityLevel', 'Custom');
-
- gBrowser = document.getElementById('content');
- gBrowser.mCurrentTab.removeAttribute("engine");
- UpdateStatusBarEngineIcon();
- BrowserReload();
-
- // Debug output
- var siteStr = site.Value;
- if (host) siteStr = host;
- ]]>
- </body>
- </method>
-
- <!-- MERC - JCH : init special pop-up tab property and popup counter property -->
- <constructor>
- this.setAttribute('isNonUserInitPopupTab', false);
- this.setAttribute('isClosing', false);//JA
- </constructor>
-
- <method name="changeSiteControl">
- <parameter name="menuitemId"/>
- <parameter name="aPopupMenu"/>
- <body>
- <![CDATA[
- //dump('tabbox.xml: changeSiteControl()\n');
-
- //var menuitem = document.getAnonymousElementByAttribute(this, 'anonid', menuitemId);
- var tabbrowser = this;
- while (tabbrowser.localName != 'tabbrowser')
- tabbrowser = tabbrowser.parentNode;
-
- var menuitem;
- if(tabbrowser.mPrefs.getBoolPref("browser.tabs.showSiteControlButtonOnTab")) {
- menuitem = document.getAnonymousElementByAttribute(this, 'anonid', menuitemId);
- } else {
- menuitem = aPopupMenu.getElementsByAttribute("anonid", menuitemId);
- menuitem = menuitem[0];
- }
-
-
- var url = tabbrowser.currentURI.spec;
-
- // Bail if it's not a controllable URI
- if (!sitecontrols.SCSVC.isControllableURI(url)) return;
-
- // Get SC resource
- var site = sitecontrols.SCSVC.getResourceForURI(url);
-
- var host = sitecontrols.getStrippedHostFromURL(url);
- var pattern = sitecontrols.SCSVC.getControlledSite(host);
-
- if ((pattern!=null || host!=pattern) && (site.Value != sitecontrols.SC_LOCAL)) {
- sitecontrols.SCSVC.addControlledSite(host);
- site = sitecontrols.SCSVC.getResourceForURI(host);
-
- // we need to set the engine of the newly added SC for the redirect case
- var currentEngine = tabbrowser.mCurrentBrowser.webNavigation.browserEngine;
- sitecontrols.SCSVC.updateSiteControlResource(site, 'displayEngine', currentEngine);
- }
-
- var anonid = menuitem.getAttribute('anonid');
- var type = menuitem.getAttribute('type');
-
- if (type == 'checkbox') {
- var checked = menuitem.getAttribute('checked');
- if (!checked) checked = 'false';
- sitecontrols.SCSVC.updateSiteControlResource(site, anonid, checked);
- }
-
- //sitecontrols.SCSVC.writeSiteControls();
-
- // if we changed allow JS, Java, ActiveX, reload the browser
- // so changes take affect immediately
- if( (anonid == 'enableJavaScript') ||
- (anonid == 'enableJava') ||
- (anonid == 'enableActiveX') )
- {
- updateSCSecurityLevel();
- //getWebNavigation().reload(nsIWebNavigation.LOAD_FLAGS_NONE);
- BrowserReload();
- }
- ]]>
- </body>
- </method>
-
- <method name="updateSiteControlSecurityLevel">
- <parameter name="level"/>
- <body>
- <![CDATA[
- //dump('tabbox.xml: updateSiteControlSecurityLevel()\n');
-
- var tabbrowser = this;
- while (tabbrowser.localName != 'tabbrowser')
- tabbrowser = tabbrowser.parentNode;
- var url = tabbrowser.currentURI.spec;
-
- // Bail if it's not a controllable URI
- if (!sitecontrols.SCSVC.isControllableURI(url)) return;
-
- // Get SC resource
- var site = sitecontrols.SCSVC.getResourceForURI(url);
-
- var host = sitecontrols.getStrippedHostFromURL(url);
- var pattern = sitecontrols.SCSVC.getControlledSite(host);
- if ((pattern!=null || host!=pattern) && (site.Value != sitecontrols.SC_LOCAL)) {
- sitecontrols.SCSVC.addControlledSite(host);
- site = sitecontrols.SCSVC.getResourceForURI(host);
-
- // we need to set the engine of the newly added SC for the redirect case
- var currentEngine = tabbrowser.mCurrentBrowser.webNavigation.browserEngine;
- sitecontrols.SCSVC.updateSiteControlResource(site, 'displayEngine', currentEngine);
- }
- sitecontrols.setSecurityLevel(site, level);
- ]]>
- </body>
- </method>
-
- <property name="accessible">
- <getter>
- <![CDATA[
- var accService = Components.classes["@mozilla.org/accessibilityService;1"].getService(Components.interfaces.nsIAccessibilityService);
- return accService.createXULTabAccessible(this);
- ]]>
- </getter>
- </property>
-
- <property name="label">
- <getter>
- return this.getAttribute("label");
- </getter>
- <setter>
- this.setAttribute("label", val);
- return val;
- </setter>
- </property>
-
- <property name="tabs"
- onget="return this.getAttribute('tabs');"
- onset="this.setAttribute('tabs', val); return val;"/>
-
- <!-- MERC - JCH : boolean to indicate whether the tab holds non-user-initiated pop-ups -->
- <property name="isNonUserInitPopupTab">
- <getter>
- var v = this.getAttribute("isClosing")!="true";
- if(this.getAttribute("isNonUserInitPopupTab")=="true")
- {
- if(v)
- return true;
- }
- return false;
- </getter>
- <setter>
- this.setAttribute("isNonUserInitPopupTab", val); return val;
- </setter>
- </property>
-
- <!-- JA -->
- <property name="isClosing">
- <getter>
- return this.getAttribute('isClosing') == 'true'?true:false;
- </getter>
- <setter>
- this.setAttribute('isClosing', val); return val;
- </setter>
- </property>
-
- <!-- XXX -->
- <property name="selected">
- <getter>
- return this.getAttribute("selected") == "true" ? true : false;
- </getter>
- <setter>
- this.setAttribute("selected", val);
- if (this.previousSibling) {
- if (val)
- this.previousSibling.setAttribute("beforeselected", val);
- else
- this.previousSibling.removeAttribute("beforeselected");
- }
- if (this.nextSibling) {
- if (val)
- this.nextSibling.setAttribute("afterselected", val);
- else
- this.nextSibling.removeAttribute("afterselected");
- }
- return val;
- </setter>
- </property>
-
- <property name="linkedPanel" onget="return this.getAttribute('linkedpanel')"
- onset="this.setAttribute('linkedpanel', val); return val;"/>
-
- <!-- MERC - JCH: Needed to avoid sitecontrols dialog from opening on dbl clicks -->
- <field name="_lastClickTime">0</field>
-
- </implementation>
-
- <handlers>
- <!-- MERC (DP): close tab on double click -->
- <handler event="click" clickcount="2" button="0">
- <![CDATA[
- // we need this if statement since tabbox.xml is used in places other than the browser
- // tabs area e.g. Page Info. so do the following code only if we are in the browser tabs
- if(this.parentNode.hasAttribute('browsertabs')) {
- var tabbrowser = this.parentNode;
- while(tabbrowser.localName != 'tabbrowser')
- tabbrowser = tabbrowser.parentNode;
-
- var doubleClickToCloseTab = tabbrowser.mPrefs.getBoolPref("browser.tabs.doubleClickToClose");
- if(doubleClickToCloseTab)
- tabbrowser.removeCurrentTab();
- }
- ]]>
- </handler>
-
- <handler event="click" button="0">
- <![CDATA[
- var updateSelected = true;
- var tabParent = this.parentNode;
-
- // we need this if statement since tabbox.xml is used in places other than the browser
- // tabs area e.g. Page Info. so do the following code only if we are in the browser tabs
- if (tabParent.hasAttribute('browsertabs')) {
-
- //JA add notification about selected tab
- var menubutton = document.getAnonymousElementByAttribute(this, 'anonid', 'menubutton');
- var closebutton = document.getAnonymousElementByAttribute(this, 'anonid', 'closebutton');
- var popup;
- if ((menubutton.boxObject.screenX <= event.screenX)
- && (event.screenX - menubutton.boxObject.screenX <= menubutton.boxObject.width)
- && (menubutton.boxObject.screenY <= event.screenY)
- && (event.screenY - menubutton.boxObject.screenY <= menubutton.boxObject.height))
- {
-
- // MERC - JCH: Addressing BLT #158887. Prevent opening SC popup
- // when double clicking on SC icon. If click is less than or
- // equal to a second apart from previous, don't open the popup.
- var currentTime = new Date();
-
- var elapsedTime = currentTime.getTime() - _lastClickTime;
- _lastClickTime = currentTime.getTime();
-
- if (elapsedTime > 1000) {
- showSiteControlsPopup(0,0);
- }
- }
- else if ((closebutton.boxObject.screenX <= event.screenX)
- && (event.screenX - closebutton.boxObject.screenX <= closebutton.boxObject.width)
- && (closebutton.boxObject.screenY <= event.screenY)
- && (event.screenY - closebutton.boxObject.screenY <= closebutton.boxObject.height))
- {
- // get handle to tabbrowser object
- var tabbrowser = this.parentNode;
- while (tabbrowser.localName != 'tabbrowser')
- tabbrowser = tabbrowser.parentNode;
-
- tabbrowser.removeTab(this);
- updateSelected = false;
- }
- }
-
- if (updateSelected) {
- tabParent.selectedItem = this;
- }
- ]]>
- </handler>
- <handler event="mousemove">
- <![CDATA[
- // MERC (rpaul) event handler to get the tooltips of the close button, site controls
- // and the tab title
-
- var tabParent = this.parentNode;
- var gBrowser = document.getElementById('content');
-
- // we need this if statement since tabbox.xml is used in places other than the browser
- // tabs area e.g. Page Info. so do the following code only if we are in the browser tabs
- if (tabParent.hasAttribute('browsertabs')) {
- var tooltipNode = event.target.parentNode.parentNode.firstChild;
- if (!tooltipNode) return;
- tooltipNode.hidePopup();
- //JA add notification about selected tab
- var menubutton = document.getAnonymousElementByAttribute(this, 'anonid', 'menubutton');
- var closebutton = document.getAnonymousElementByAttribute(this, 'anonid', 'closebutton');
- if ((menubutton.boxObject.screenX <= event.screenX)
- && (event.screenX - menubutton.boxObject.screenX <= menubutton.boxObject.width)
- && (menubutton.boxObject.screenY <= event.screenY)
- && (event.screenY - menubutton.boxObject.screenY <= menubutton.boxObject.height))
- {
- tooltipNode.setAttribute('label', 'Open Site Controls');
- return;
- }
- else if ((closebutton.boxObject.screenX <= event.screenX)
- && (event.screenX - closebutton.boxObject.screenX <= closebutton.boxObject.width)
- && (closebutton.boxObject.screenY <= event.screenY)
- && (event.screenY - closebutton.boxObject.screenY <= closebutton.boxObject.height))
- {
- // only set tooltip for site controls if the tab is active
- if (event.target.getAttribute("selected") == "true") {
- tooltipNode.setAttribute('label', 'Close this tab');
- return;
- }
- }
- else if (event.target.localName == "tab"){
- if (event.target.hasAttribute('label')) {
- var tabToolTip = event.target.getAttribute('label');
- tooltipNode.setAttribute('label', tabToolTip);
- return;
- }
- }
- else {
- tooltipNode.removeAttribute('label');
- }
- }
-
- ]]>
- </handler>
- <!-- /MERC -->
-
- <handler event="keypress" keycode="vk_left">
- <![CDATA[
- this.parentNode.advanceSelectedTab(-1);
- ]]>
- </handler>
-
- <handler event="keypress" keycode="vk_right">
- <![CDATA[
- this.parentNode.advanceSelectedTab(1);
- ]]>
- </handler>
-
- <handler event="keypress" keycode="vk_up">
- <![CDATA[
- this.parentNode.advanceSelectedTab(-1);
- ]]>
- </handler>
-
- <handler event="keypress" keycode="vk_down">
- <![CDATA[
- this.parentNode.advanceSelectedTab(1);
- ]]>
- </handler>
- </handlers>
- </binding>
-
- </bindings>