APIを修正

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@1262 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2007-10-21 08:16:10 +00:00
parent 59f1cf2aff
commit 407647b081

View File

@ -84,8 +84,41 @@ var TreeStyleTabService = {
}, },
_ObserverService : null, _ObserverService : null,
/* API */
readyToOpenChildTab : function(aFrameOrTabBrowser, aMultiple)
{
var frame = this.getFrameFromTabBrowserElements(aFrameOrTabBrowser);
if (!frame) return;
var ownerBrowser = ('SplitBrowser' in window) ? this.getTabBrowserFromChildren(SplitBrowser.getSubBrowserAndBrowserFromFrame(frame.top).browser) : gBrowser ;
ownerBrowser.__treestyletab__readyToAttachNewTab = true;
ownerBrowser.__treestyletab__readyToAttachMultiple = aMultiple || false ;
ownerBrowser.__treestyletab__parentTab = this.getTabFromFrame(frame, ownerBrowser).getAttribute(this.kID);
},
stopToOpenChildTab : function(aFrameOrTabBrowser)
{
var frame = this.getFrameFromTabBrowserElements(aFrameOrTabBrowser);
if (!frame) return;
var ownerBrowser = ('SplitBrowser' in window) ? this.getTabBrowserFromChildren(SplitBrowser.getSubBrowserAndBrowserFromFrame(frame.top).browser) : gBrowser ;
ownerBrowser.__treestyletab__readyToAttachNewTab = false;
ownerBrowser.__treestyletab__readyToAttachMultiple = false;
ownerBrowser.__treestyletab__parentTab = null;
},
checkOpenChildTab : function(aFrameOrTabBrowser)
{
var frame = this.getFrameFromTabBrowserElements(aFrameOrTabBrowser);
if (!frame) return false;
var ownerBrowser = ('SplitBrowser' in window) ? this.getTabBrowserFromChildren(SplitBrowser.getSubBrowserAndBrowserFromFrame(frame.top).browser) : gBrowser ;
return ownerBrowser.__treestyletab__readyToAttachNewTab ? true : false ;
},
/* Utilities */ /* Utilities */
isEventFiredOnTabIcon : function(aEvent) isEventFiredOnTabIcon : function(aEvent)
{ {
var tab = this.getTabFromEvent(aEvent); var tab = this.getTabFromEvent(aEvent);
@ -197,6 +230,28 @@ var TreeStyleTabService = {
return (target.localName == 'tabbrowser') ? target : null ; return (target.localName == 'tabbrowser') ? target : null ;
}, },
getFrameFromTabBrowserElements : function(aFrameOrTabBrowser)
{
var frame = aFrameOrTabBrowser;
if (frame == '[object XULElement]') {
if (frame.localName == 'tab') {
frame = frame.linkedBrowser.contentWindow;
}
else if (frame.localName == 'browser') {
frame = frame.contentWindow;
}
else {
frame = this.getTabBrowserFromChildren(frame);
if (!frame) return null;
frame = frame.contentWindow;
}
}
if (!frame)
frame = this.browser.contentWindow;
return frame;
},
isTabVertical : function(aTabOrChild) isTabVertical : function(aTabOrChild)
{ {
var b = this.getTabBrowserFromChildren(aTabOrChild); var b = this.getTabBrowserFromChildren(aTabOrChild);
@ -820,7 +875,7 @@ catch(e) {
}, },
/* Event Handling */ /* Event Handling */
handleEvent : function(aEvent) handleEvent : function(aEvent)
{ {
switch (aEvent.type) switch (aEvent.type)
@ -1137,7 +1192,7 @@ catch(e) {
} }
return true; return true;
}, },
/* Tab Utilities */ /* Tab Utilities */
getTabValue : function(aTab, aKey) getTabValue : function(aTab, aKey)
@ -1490,7 +1545,7 @@ catch(e) {
}, },
/* Commands */ /* Commands */
initTabbar : function(aTabBrowser, aPosition) initTabbar : function(aTabBrowser, aPosition)
{ {
if (!aPosition) aPosition = this.getPref('extensions.treestyletab.tabbar.position'); if (!aPosition) aPosition = this.getPref('extensions.treestyletab.tabbar.position');
@ -1578,47 +1633,6 @@ catch(e) {
} }
}, },
readyToOpenChildTab : function(aFrameOrTabBrowser, aMultiple)
{
var frame = aFrameOrTabBrowser;
if (frame == '[object XULElement]') {
if (frame.localName == 'tab') {
frame = frame.linkedBrowser.contentWindow;
}
else if (frame.localName == 'browser') {
frame = frame.contentWindow;
}
else {
frame = this.getTabBrowserFromChildren(frame);
if (!frame) return;
frame = frame.contentWindow;
}
}
if (!frame)
frame = this.browser.contentWindow;
var ownerBrowser = ('SplitBrowser' in window) ? this.getTabBrowserFromChildren(SplitBrowser.getSubBrowserAndBrowserFromFrame(aFrame.top).browser) : gBrowser ;
ownerBrowser.__treestyletab__readyToAttachNewTab = true;
ownerBrowser.__treestyletab__readyToAttachMultiple = aMultiple || false ;
ownerBrowser.__treestyletab__parentTab = this.getTabFromFrame(frame, ownerBrowser).getAttribute(this.kID);
},
stopToOpenChildTab : function(aFrameOrTabBrowser)
{
var frame = aFrameOrTabBrowser;
if (frame == '[object XULElement]') {
frame = this.getTabBrowserFromChildren(frame);
if (!frame) return;
frame = frame.contentWindow;
}
if (!frame)
frame = this.browser.contentWindow;
var ownerBrowser = ('SplitBrowser' in window) ? this.getTabBrowserFromChildren(SplitBrowser.getSubBrowserAndBrowserFromFrame(frame.top).browser) : gBrowser ;
ownerBrowser.__treestyletab__readyToAttachNewTab = false;
ownerBrowser.__treestyletab__readyToAttachMultiple = false;
ownerBrowser.__treestyletab__parentTab = null;
},
/* attach/part */ /* attach/part */
attachTabTo : function(aChild, aParent, aInfo) attachTabTo : function(aChild, aParent, aInfo)
@ -2144,7 +2158,7 @@ catch(e) {
}, },
/* Pref Listener */ /* Pref Listener */
domain : 'extensions.treestyletab', domain : 'extensions.treestyletab',
observe : function(aSubject, aTopic, aPrefName) observe : function(aSubject, aTopic, aPrefName)
@ -2165,7 +2179,7 @@ catch(e) {
}, },
/* Save/Load Prefs */ /* Save/Load Prefs */
get Prefs() get Prefs()
{ {
if (!this._Prefs) { if (!this._Prefs) {