Home > XUL Apps > Tabbrowser Extensions > Information for Developers

Tabbrowser Extensions: Information for Developers

Documents

Introduction of Tabbrowser Extensions (Japanese)
This is an archive of the document introducing this extension, for the XUL contest in the Mozilla.Party.jp 4.0. There are some technical information of the implementation.

Extra Methods and Properties (2004-08-10)

Here is a list of some extra methods and properties provided by Tabbrowser Extensions for tab and tabbrowser widget. You can use these properties by your original XUL applications and they will power your apps. Or, if you use customizable extensions about mouse gesures, buttons, etc., you can call TBE features with following methods.

Name Type Description
tab widget
tabId String (readonly) is the identifier string for the tab. If you use direct reference for the element node of the tab, memory leak sometimes appears. I recommend you to use this ID to identify tabs from events or other cases. (You can identify the tab from this ID by the method getTabByTabId() of the tabbrowser widget.)
childTabs Array of Element Nodes (readonly) This are child tabs related to the tab directly. The length of this array will be "0", if the TabGroup Mode is disabled or the tab has no child. You can edit this by methods of tabbrowser widget, attachTabTo() and detachTab().
hasChildTabs() method returns a boolean value which indicates the tab has child tabs or not. This is quicker than accessing the childTabs property.
allChildTabs Array of Element Nodes (readonly) is a simple array that includes all of children related to the tab directly or indirectly. The length of this array will be "0", if the TabGroup Mode is disabled or the tab has no child.
parentTab Element Node is the parent tab related to the tab directly. It will be null, if the TabGroup Mode is disabled or the tab has no parent. You can edit this by methods of tabbrowser widget, attachTabTo() and detachTab().
rootTab Element Node (readonly) is the top-level parent of the tab. It will be null, if the TabGroup Mode is disabled or the tab has no parent.
ownerGroup Array of Element Nodes (readonly) is a simple array that has all of tabs of the group which contains the tab. The length of this array will be "0", if the TabGroup Mode is disabled or the tab is not grouped.
previousTab Element Node (readonly) is the previous tab of the tab. This always refers the previously displayed even if users rearrangeed tabs.
nextTab Element Node (readonly) is the next tab of the tab. This always refers the next displayed even if users rearrangeed tabs.
locked Boolean is a property which indicates the tab is locked or unlocked.
referrerBlocked Boolean is a property which indicates the tab is blocked or unblocked sending HTTP_REFERER.
autoReloadInterval Number is the inverval of auto-reloading (msec). A 0 stops reloading of the tab.
allowPlugins Boolean allows/forbids to use plug-ins in the tab.
allowJavascript Boolean allows/forbids to use JavaScript in the tab.
allowMetaRedirects Boolean allows/forbids to use redirecting or reloading by webpages in the tab.
allowSubframes Boolean allows/forbids to show frames in the tab.
allowImages Boolean allows/forbids to load imagesin the tab.
fixedLabel String sets the fixed label of the tab. To cancel fixed labels, you should set null.
tabbrowser widget
getTabByTabId(aID) method finds and returns a tab from tabId. If there is no tab which has the ID, this returns null. Tabs' ID will be used instead of direct references to element nodes of tabs.
tabGroupsAvailable Boolean (readonly) indicates the TabGroup Mode is enabled or disabled.
attachTabTo(aTab, aParent) method relates the tab aTab to the parent tab aParent as a child. The expression attachTabTo(aTab, aParent) is equals to aTab.parentTab = aParent.
detachTab(aTab, aKeepChildTabs) method releases aTab from the parent. For example, when there is a group of three tabs, A(root), B(child of A) and C(child of B), detachTab(B, true) releases the small group B and C, detachTab(B, false) releases only B. And, the expression detachTab(aTab, true) is equals to aTab.parentTab = null.
removeAllTabs() method closes any tab. This returns no value.
removeLeftTabsFrom(aTab), removeRightTabsFrom(aTab) method closes all of tabs located in left/right of the tab. This returns the handed tab.
undoRemoveTab() method reopens the tab last closed, and returns it.
moveTabTo(aTab, aIndex) method moves the tab to the absolute position. For example, when you hand "0", the tab will be moved to the left edge. If the position is out of range, the tab will be moved to left or right edge. This returns the moved tab.
moveTabBy(aTab, aOrder) method moves the tab by the relative order. For example, when you hand "-2", the tab will be moved to the left twice. If the position is out of range, the tab will be moved to left or right edge. This returns the moved tab.
moveTabLeft(aTab), moveTabRight(aTab) method moves the tab to the left or right. If you move the tab of the left edge to the left it will be moved to the right edge.
removeTabGroup(aTab) method closes the tab and child tabs (but the parent and brothers are not). When the TabGroup Mode is disabled, this works like removeTab(). This returns no value.
editBookmarkFromTab(aTab) method opens a bookmark property dialog for the bookmarked page. This will do no action if the page is not bookmarked. This returns the handed tab.
duplicateTab(aTab) method copies the tab, in the same window. This returns the new (duplicated) tab.
duplicateTabInWindow(aTab) method opens a new window for the copied tab. This returns the original tab.
sortTabsByGroup() method sorts all of tabs by groups. This will do no action when the TabGroup Mode is disabled.
setTabColorFor(aTab, aColorSet) method sets background and font color of the tab. This will change child tabs of the tab too, if the TabGroup Mode is available. You should hand a string aColorSet like following:
#RRGGBB:#RRGGBB
sets colors directly. The first half is the background color, second is forward. If you omit the second half, forward color will be calculated automatically.
auto
sets colors at random.
default
backs to the default colors.
getTabInfo(aTab) method gets an information object ([object XULTabbrowserTabInfo]) of the tab. It contains label, session histories, and so on.
addTabWithTabInfo(aTabInfo) method opens a tab which has same label, histories, etc. This method needs a tab information created by the method getTabInfo(). This returns the new tab.

You can use different implementation for with-tabextensions or without, like following:


// ex. A feature to download set of tabs
//    with tabextensions    : Download current tab-group
//    without tabextensions : Download all tabs

var tabs = ('TabbrowserService' in window) ? gBrowser.selectedTab.ownerGroup : [] ;
if (!tabs.length) tabs = gBrowser.mTabContainer.childNodes;

for (var i = 0; i < tabs.length; i++) {
	saveDocument(gBrowser.getBrowserForTab(tabs[i]).contentDocument);
}
		

And, you can call those methods from mouse gestures provided by other extensions, like:

gBrowser.undoRemoveTab();

Extra Events (2004-08-28)

"tabbrowser" elements dispatch following special events if TBE is installed. You can use them to use your custom features about the tabbed browsing.

Name When the event is dispatched? Extra properties
XULTabbrowserTabAdded When a new tab is opened.
tabId
The ID of the new tab. (String)
tabURI
The URI loaded into the tab. (String)
referrerURI
HTTP_REFERER (nsIURI)
XULTabbrowserAddTabCanceled When new tab isn't opened because there are too many tabs.
loadingURI
The URI which should be loaded into the tab. (String)
referrerURI
HTTP_REFERER (nsIURI)
tabInfo
Status flag of the new tab. (Object)
XULTabbrowserTabRemoved When a tab is closed.
tabId
The ID of the closed tab. (String)
tabIndex
The position of the closed tab. (Number)
XULTabbrowserTabLoading While a tab is loading.
tabId
The ID of the tab loading progressively. (String)
tabURI
The URI which is currently loading. (String)
loadingView
The frame object which is currently loading. (Window)
XULTabbrowserTabLoad When a tab is completely loaded.
tabId
The ID of the tab which is completely loaded. (String)
tabURI
The URI of the page loaded into the tab. (String)
loadedView
The frame objecf which is completely loaded. (Window)
XULTabbrowserTabLocationChange When the location of the page currently shown in the tab is changed.
tabId
The ID of the tab loading progressively. (String)
oldLocation
The URI of the page pveriously shown (String)
newLocation
The URI of the page newly shown. (String)
XULTabbrowserUndoCacheAdded When a closed tab is cached.
cachedTabInfo
The information of the cached tab which is recently closed. (XULTabbrowserTabInfo)
XULTabbrowserUndoCacheOverFlowed When the cache is filled up and the oldest entry is automatically removed.
overFlowedCachedTabInfo
The information of the cache which is removed. (XULTabbrowserTabInfo)
XULTabbrowserUndoCacheRemoved When an entry is removed from the cache.
removedCachedTabInfo
The information of the cache which is removed. (XULTabbrowserTabInfo)
XULTabbrowserTabStatusChange When status of tabs (locked, forbid to load images, or others) is changed.
tabId
The ID of the page status is changed. (String)
targetStatus
The name of the status which is changed. (String)
targetURI
The URI of the target page for the status changing. If the change is independent on special pages, it is "ANY". (String)
XULTabbrowserTabMoved When a tab is moved (rearranged).
tabId
The ID of the tab which is moved. (String)
oldTabIndex
The index of the original position. (Number)
newTabIndex
The index of the new position. (Number)
XULTabbrowserURIDrop When an URI string is dropped on the tab bar.
droppedURI
The URI which is dropped. (String)
XULTabbrowserTabDrop When a tab is dropped on the tab bar.
tabURI
The URI of the page shown in the dropped tab. (String)
droppedTabId
The ID of the dropped tab. (String)
targetTabId
The ID of the tab catching the dropped tab. (String)
droppedPosition
The dropped position. If the tab is dropped before a tab, it is "tabbrowser.DROP_BEFORE". When dropped after a tab, it is "tabbrowser.DROP_AFTER". It is "tabbrowser.DROP_ON" if a tab is dropped on. (Number)
dragdropShiftKey
The value of "shiftKey" prperty of dragdrop event. (Boolean)
dragdropAltKey
The value of "altKey" prperty of dragdrop event. (Boolean)
dragdropMetaKey
The value of "metaKey" prperty of dragdrop event. (Boolean)
dragdropCtrlKey
The value of "ctrlKey" prperty of dragdrop event. (Boolean)
dragdropTarget
The value of "target" prperty of dragdrop event. (Node)
dragdropOriginalTarget
The value of "originalTarget" prperty of dragdrop event. (Node)
TabbrowserTabGroupModified When a group of tabs is modified.
tabId
The ID of the tab which is newly attached to or detached from a group. (String)

You can use those events for your implementation like:


// ex. A feature to close new tabs automatically if I open them for movies.

function onTabLoad(aEvent) {
   if (aEvent.tabURI.match(/\.(rm|ram|avi|mov|wmv|asf)$/i)) {
      var tabbrowser = aEvent.target;
      var tab        = tabbrowser.getTabByTabId(aEvent.tabId);
      tabbrowser.removeTab(tab);
   }
}

window.addEventListener('XULTabbrowserTabLoad', onTabLoad, true);
Last modified:2013/03/27 04:34:46