タブのフォーカス移動でツリーの自動開閉を行う設定の時、Ctrl-Tabでのフォーカス移動に際しては、Ctrlキーを放したタイミングで初めてツリーの開閉を制御するようにした
git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@4942 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
parent
3f664f1754
commit
8c06bbf824
@ -1385,6 +1385,7 @@ var TreeStyleTabService = {
|
||||
this.onPrefChange('extensions.treestyletab.animation.indent.duration');
|
||||
this.onPrefChange('extensions.treestyletab.animation.collapse.duration');
|
||||
this.onPrefChange('extensions.treestyletab.twisty.expandSensitiveArea');
|
||||
this.onPrefChange('extensions.treestyletab.autoCollapseExpandSubTreeOnSelect.whileFocusMovingByShortcut');
|
||||
},
|
||||
initialized : false,
|
||||
|
||||
@ -1898,7 +1899,8 @@ catch(e) {
|
||||
window['piro.sakura.ne.jp'].animationManager.stop();
|
||||
this.destroyTabBrowser(gBrowser);
|
||||
|
||||
this.endListenKeyEvents();
|
||||
this.endListenKeyEventsFor(this.LISTEN_FOR_AUTOHIDE);
|
||||
this.endListenKeyEventsFor(this.LISTEN_FOR_AUTOEXPAND_BY_FOCUSCHANGE);
|
||||
|
||||
document.getElementById('contentAreaContextMenu').removeEventListener('popupshowing', this, false);
|
||||
document.removeEventListener('popupshowing', this, false);
|
||||
@ -1990,6 +1992,36 @@ catch(e) {
|
||||
}
|
||||
},
|
||||
|
||||
keyEventListening : false,
|
||||
keyEventListeningFlags : 0,
|
||||
|
||||
LISTEN_FOR_AUTOHIDE : 1,
|
||||
LISTEN_FOR_AUTOEXPAND_BY_FOCUSCHANGE : 2,
|
||||
|
||||
startListenKeyEventsFor : function(aReason)
|
||||
{
|
||||
if (this.keyEventListeningFlags & aReason) return;
|
||||
if (!this.keyEventListening) {
|
||||
window.addEventListener('keydown', this, true);
|
||||
window.addEventListener('keyup', this, true);
|
||||
window.addEventListener('keypress', this, true);
|
||||
this.keyEventListening = true;
|
||||
}
|
||||
this.keyEventListeningFlags |= aReason;
|
||||
},
|
||||
|
||||
endListenKeyEventsFor : function(aReason)
|
||||
{
|
||||
if (!(this.keyEventListeningFlags & aReason)) return;
|
||||
this.keyEventListeningFlags ^= aReason;
|
||||
if (!this.keyEventListeningFlags && this.keyEventListening) {
|
||||
window.removeEventListener('keydown', this, true);
|
||||
window.removeEventListener('keyup', this, true);
|
||||
window.removeEventListener('keypress', this, true);
|
||||
this.keyEventListening = false;
|
||||
}
|
||||
},
|
||||
|
||||
onKeyDown : function(aEvent)
|
||||
{
|
||||
var b = this.browser;
|
||||
@ -2005,7 +2037,8 @@ catch(e) {
|
||||
!aEvent.altKey &&
|
||||
this.accelKeyPressed
|
||||
) {
|
||||
if (this.getTreePref('tabbar.autoShow.accelKeyDown') &&
|
||||
if (sv.autoHideEnabled &&
|
||||
this.getTreePref('tabbar.autoShow.accelKeyDown') &&
|
||||
!sv.autoHideShown &&
|
||||
!sv.delayedAutoShowTimer &&
|
||||
!this.delayedAutoShowForShortcutTimer) {
|
||||
@ -2023,6 +2056,7 @@ catch(e) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (sv.autoHideEnabled)
|
||||
sv.hideTabbar();
|
||||
}
|
||||
},
|
||||
@ -2073,25 +2107,43 @@ catch(e) {
|
||||
aEvent.charCode == 0 && aEvent.keyCode == 16
|
||||
)
|
||||
) {
|
||||
if (this.getTreePref('tabbar.autoShow.tabSwitch'))
|
||||
if (sv.autoHideEnabled &&
|
||||
this.getTreePref('tabbar.autoShow.tabSwitch'))
|
||||
sv.showTabbar(sv.kSHOWN_BY_SHORTCUT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (sv.showHideTabbarReason == sv.kSHOWN_BY_SHORTCUT)
|
||||
// when you just release accel key...
|
||||
|
||||
if (sv.autoHideEnabled &&
|
||||
sv.showHideTabbarReason == sv.kSHOWN_BY_SHORTCUT) {
|
||||
sv.hideTabbar();
|
||||
}
|
||||
|
||||
if (this._tabShouldBeExpandedAfterKeyReleased) {
|
||||
let tab = this._tabShouldBeExpandedAfterKeyReleased;
|
||||
if (this.hasChildTabs(tab) &&
|
||||
(tab.getAttribute(this.kSUBTREE_COLLAPSED) == 'true')) {
|
||||
this.getTabBrowserFromChild(tab)
|
||||
.treeStyleTab
|
||||
.collapseExpandTreesIntelligentlyFor(tab);
|
||||
}
|
||||
}
|
||||
this._tabShouldBeExpandedAfterKeyReleased = null;
|
||||
},
|
||||
|
||||
// autohide
|
||||
|
||||
updateAutoHideKeyListeners : function()
|
||||
{
|
||||
if (
|
||||
this.getTreePref('tabbar.autoHide.mode') &&
|
||||
this.shouldListenKeyEvents
|
||||
this.shouldListenKeyEventsForAutoHide
|
||||
) {
|
||||
this.startListenKeyEvents();
|
||||
this.startListenKeyEventsFor(this.LISTEN_FOR_AUTOHIDE);
|
||||
}
|
||||
else {
|
||||
this.endListenKeyEvents();
|
||||
this.endListenKeyEventsFor(this.LISTEN_FOR_AUTOHIDE);
|
||||
}
|
||||
window.setTimeout(function() {
|
||||
if (window.windowState != Components.interfaces.nsIDOMChromeWindow.STATE_NORMAL) return;
|
||||
@ -2100,27 +2152,7 @@ catch(e) {
|
||||
}, 0);
|
||||
},
|
||||
|
||||
startListenKeyEvents : function()
|
||||
{
|
||||
if (this.keyEventListening) return;
|
||||
window.addEventListener('keydown', this, true);
|
||||
window.addEventListener('keyup', this, true);
|
||||
window.addEventListener('keypress', this, true);
|
||||
this.keyEventListening = true;
|
||||
},
|
||||
|
||||
endListenKeyEvents : function()
|
||||
{
|
||||
if (!this.keyEventListening) return;
|
||||
window.removeEventListener('keydown', this, true);
|
||||
window.removeEventListener('keyup', this, true);
|
||||
window.removeEventListener('keypress', this, true);
|
||||
this.keyEventListening = false;
|
||||
},
|
||||
|
||||
keyEventListening : false,
|
||||
|
||||
get shouldListenKeyEvents()
|
||||
get shouldListenKeyEventsForAutoHide()
|
||||
{
|
||||
return this.getTreePref('tabbar.autoShow.accelKeyDown') ||
|
||||
this.getTreePref('tabbar.autoShow.tabSwitch') ||
|
||||
@ -2526,6 +2558,13 @@ catch(e) {
|
||||
);
|
||||
},
|
||||
|
||||
expandTreeAfterKeyReleased : function(aTab)
|
||||
{
|
||||
if (this.getTreePref('autoCollapseExpandSubTreeOnSelect.whileFocusMovingByShortcut')) return;
|
||||
this._tabShouldBeExpandedAfterKeyReleased = aTab || null;
|
||||
},
|
||||
_tabShouldBeExpandedAfterKeyReleased : null,
|
||||
|
||||
registerTabFocusAllowance : function(aProcess) /* PUBLIC API */
|
||||
{
|
||||
this._tabFocusAllowance.push(aProcess);
|
||||
@ -2658,6 +2697,17 @@ catch(e) {
|
||||
this.expandTwistyArea = value;
|
||||
break;
|
||||
|
||||
case 'extensions.treestyletab.autoCollapseExpandSubTreeOnSelect.whileFocusMovingByShortcut':
|
||||
case 'extensions.treestyletab.autoCollapseExpandSubTreeOnSelect':
|
||||
if (!this.getTreePref('autoCollapseExpandSubTreeOnSelect.whileFocusMovingByShortcut') &&
|
||||
this.getTreePref('autoCollapseExpandSubTreeOnSelect')) {
|
||||
this.startListenKeyEventsFor(this.LISTEN_FOR_AUTOEXPAND_BY_FOCUSCHANGE);
|
||||
}
|
||||
else {
|
||||
this.endListenKeyEventsFor(this.LISTEN_FOR_AUTOEXPAND_BY_FOCUSCHANGE);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -199,9 +199,10 @@ TreeStyleTabBrowser.prototype = {
|
||||
b.mTabContainer.advanceSelectedTab.toSource().replace(
|
||||
'{',
|
||||
<![CDATA[$&
|
||||
if (TreeStyleTabService.getTreePref('focusMode') == TreeStyleTabService.kFOCUS_VISIBLE) {
|
||||
var treeStyleTab = TreeStyleTabService.getTabBrowserFromChild(this).treeStyleTab;
|
||||
treeStyleTab._focusChangedByShortcut = TreeStyleTabService.accelKeyPressed;
|
||||
if (treeStyleTab.getTreePref('focusMode') == treeStyleTab.kFOCUS_VISIBLE) {
|
||||
(function(aDir, aWrap, aSelf) {
|
||||
var treeStyleTab = TreeStyleTabService.getTabBrowserFromChild(aSelf).treeStyleTab;
|
||||
var nextTab = (aDir < 0) ? treeStyleTab.getPreviousVisibleTab(aSelf.selectedItem) : treeStyleTab.getNextVisibleTab(aSelf.selectedItem) ;
|
||||
if (!nextTab && aWrap) {
|
||||
nextTab = TreeStyleTabService.evaluateXPath(
|
||||
@ -1883,15 +1884,30 @@ TreeStyleTabBrowser.prototype = {
|
||||
b.selectedTab = this.getRootTab(tab);
|
||||
}
|
||||
}
|
||||
else if (this.hasChildTabs(tab) &&
|
||||
(tab.getAttribute(this.kSUBTREE_COLLAPSED) == 'true') &&
|
||||
this.getTreePref('autoCollapseExpandSubTreeOnSelect')) {
|
||||
if (!this._focusChangedByCurrentTabRemove ||
|
||||
this.getTreePref('autoCollapseExpandSubTreeOnSelect.onCurrentTabRemove'))
|
||||
else if (
|
||||
this.getTreePref('autoCollapseExpandSubTreeOnSelect') &&
|
||||
(
|
||||
!this._focusChangedByCurrentTabRemove ||
|
||||
this.getTreePref('autoCollapseExpandSubTreeOnSelect.onCurrentTabRemove')
|
||||
)
|
||||
) {
|
||||
if (!this.hasChildTabs(tab) || (tab.getAttribute(this.kSUBTREE_COLLAPSED) != 'true'))
|
||||
tab = null;
|
||||
|
||||
if (
|
||||
this._focusChangedByShortcut &&
|
||||
this.accelKeyPressed &&
|
||||
!this.getTreePref('autoCollapseExpandSubTreeOnSelect.whileFocusMovingByShortcut')
|
||||
) {
|
||||
TreeStyleTabService.expandTreeAfterKeyReleased(tab);
|
||||
}
|
||||
else {
|
||||
this.collapseExpandTreesIntelligentlyWithDelayFor(tab);
|
||||
}
|
||||
}
|
||||
|
||||
this._focusChangedByCurrentTabRemove = false;
|
||||
this._focusChangedByShortcut = false;
|
||||
|
||||
if (this.autoHideEnabled && this.autoHideShown)
|
||||
this.redrawContentArea();
|
||||
@ -3435,9 +3451,9 @@ TreeStyleTabBrowser.prototype = {
|
||||
|
||||
collapseExpandTreesIntelligentlyFor : function(aTab, aJustNow)
|
||||
{
|
||||
var b = this.mTabBrowser;
|
||||
if (this.doingCollapseExpand) return;
|
||||
if (!aTab || this.doingCollapseExpand) return;
|
||||
|
||||
var b = this.mTabBrowser;
|
||||
var sameParentTab = this.getParentTab(aTab);
|
||||
var expandedParentTabs = [
|
||||
aTab.getAttribute(this.kID)
|
||||
@ -4074,8 +4090,8 @@ TreeStyleTabBrowser.prototype = {
|
||||
this.mTabBrowser.mPanelContainer.addEventListener('scroll', this, true);
|
||||
if (this.shouldListenMouseMove)
|
||||
this.startListenMouseMove();
|
||||
if (this.mTabBrowser == gBrowser && this.shouldListenKeyEvents)
|
||||
TreeStyleTabService.startListenKeyEvents();
|
||||
if (this.mTabBrowser == gBrowser && this.shouldListenKeyEventsForAutoHide)
|
||||
TreeStyleTabService.startListenKeyEventsFor(this.LISTEN_FOR_AUTOHIDE);
|
||||
|
||||
this.clearTabbarCanvas();
|
||||
this.updateTabbarTransparency();
|
||||
@ -4100,7 +4116,7 @@ TreeStyleTabBrowser.prototype = {
|
||||
this.mTabBrowser.mPanelContainer.removeEventListener('scroll', this, true);
|
||||
this.endListenMouseMove();
|
||||
if (this.mTabBrowser == gBrowser)
|
||||
TreeStyleTabService.endListenKeyEvents();
|
||||
TreeStyleTabService.endListenKeyEventsFor(this.LISTEN_FOR_AUTOHIDE);
|
||||
|
||||
this.clearTabbarCanvas();
|
||||
this.updateTabbarTransparency();
|
||||
|
@ -92,6 +92,7 @@ pref("extensions.treestyletab.useEffectiveTLD", true);
|
||||
|
||||
pref("extensions.treestyletab.autoCollapseExpandSubTreeOnSelect", true);
|
||||
pref("extensions.treestyletab.autoCollapseExpandSubTreeOnSelect.onCurrentTabRemove", true);
|
||||
pref("extensions.treestyletab.autoCollapseExpandSubTreeOnSelect.whileFocusMovingByShortcut", false);
|
||||
pref("extensions.treestyletab.collapseExpandSubTree.dblclick", false);
|
||||
pref("extensions.treestyletab.autoExpandSubTreeOnCollapsedChildFocused", true);
|
||||
pref("extensions.treestyletab.autoExpandSubTreeOnAppendChild", true);
|
||||
|
Loading…
Reference in New Issue
Block a user