diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index 02f6f02a..0c0472d6 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -961,14 +961,34 @@ var TreeStyleTabService = { /* PUBLIC API */ var b = this.browser; var event = b.ownerDocument.createEvent('Events'); - event.initEvent(this.kEVENT_TYPE_TAB_FOCUS_SWITCHING_KEY_DOWN, true, false); - event.sourceEvent = aEvent; + + var event = b.ownerDocument.createEvent('XULCommandEvents'); + event.initCommandEvent(this.kEVENT_TYPE_TAB_FOCUS_SWITCHING_KEY_DOWN, + true, + false, + b.ownerDocument.defaultView, + 0, + aEvent.ctrlKey, + aEvent.altKey, + aEvent.shiftKey, + aEvent.metaKey, + aEvent + ); b.dispatchEvent(event); // for backward compatibility - event = b.ownerDocument.createEvent('Events'); - event.initEvent(this.kEVENT_TYPE_TAB_FOCUS_SWITCHING_KEY_DOWN.replace(/^nsDOM/, ''), true, false); - event.sourceEvent = aEvent; + event = b.ownerDocument.createEvent('XULCommandEvents'); + event.initCommandEvent(this.kEVENT_TYPE_TAB_FOCUS_SWITCHING_KEY_DOWN.replace(/^nsDOM/, ''), + true, + false, + b.ownerDocument.defaultView, + 0, + aEvent.ctrlKey, + aEvent.altKey, + aEvent.shiftKey, + aEvent.metaKey, + aEvent + ); b.dispatchEvent(event); }, accelKeyPressed : false, @@ -1001,6 +1021,12 @@ var TreeStyleTabService = { var onlyShiftKey = (!aEvent.shiftKey && aEvent.keyCode == 16 && (aEvent.type == 'keyup' || aEvent.charCode == 0)); + var detailFlags = 0; + if (scrollDown) detailFlags |= this.kTAB_FOCUS_SWITCHING_SCROLL_DOWN; + if (scrollUp) detailFlags |= this.kTAB_FOCUS_SWITCHING_SCROLL_UP; + if (standBy) detailFlags |= this.kTAB_FOCUS_SWITCHING_STAND_BY; + if (onlyShiftKey) detailFlags |= this.kTAB_FOCUS_SWITCHING_ONLY_SHIFT_KEY; + if ( scrollDown || scrollUp || @@ -1009,23 +1035,42 @@ var TreeStyleTabService = { ) ) { /* PUBLIC API */ - let event = b.ownerDocument.createEvent('Events'); - event.initEvent(this.kEVENT_TYPE_TAB_FOCUS_SWITCHING_START, true, false); + let event = b.ownerDocument.createEvent('XULCommandEvents'); + event.initCommandEvent(this.kEVENT_TYPE_TAB_FOCUS_SWITCHING_START, + true, + false, + b.ownerDocument.defaultView, + detailFlags, + aEvent.ctrlKey, + aEvent.altKey, + aEvent.shiftKey, + aEvent.metaKey, + aEvent + ); + /* for backward compatibility */ event.scrollDown = scrollDown; event.scrollUp = scrollUp; event.standBy = standBy; event.onlyShiftKey = onlyShiftKey; - event.sourceEvent = aEvent; b.dispatchEvent(event); // for backward compatibility - event = b.ownerDocument.createEvent('Events'); - event.initEvent(this.kEVENT_TYPE_TAB_FOCUS_SWITCHING_START.replace(/^nsDOM/, ''), true, false); + event = b.ownerDocument.createEvent('XULCommandEvents'); + event.initCommandEvent(this.kEVENT_TYPE_TAB_FOCUS_SWITCHING_START.replace(/^nsDOM/, ''), + true, + false, + b.ownerDocument.defaultView, + detailFlags, + aEvent.ctrlKey, + aEvent.altKey, + aEvent.shiftKey, + aEvent.metaKey, + aEvent + ); event.scrollDown = scrollDown; event.scrollUp = scrollUp; event.standBy = standBy; event.onlyShiftKey = onlyShiftKey; - event.sourceEvent = aEvent; b.dispatchEvent(event); return; @@ -1035,23 +1080,42 @@ var TreeStyleTabService = { /* PUBLIC API */ let (event) { - event = document.createEvent('Events'); - event.initEvent(this.kEVENT_TYPE_TAB_FOCUS_SWITCHING_END, true, false); + event = b.ownerDocument.createEvent('XULCommandEvents'); + event.initCommandEvent(this.kEVENT_TYPE_TAB_FOCUS_SWITCHING_END, + true, + false, + b.ownerDocument.defaultView, + detailFlags, + aEvent.ctrlKey, + aEvent.altKey, + aEvent.shiftKey, + aEvent.metaKey, + aEvent + ); + /* for backward compatibility */ event.scrollDown = scrollDown; event.scrollUp = scrollUp; event.standBy = standBy; event.onlyShiftKey = onlyShiftKey; - event.sourceEvent = aEvent; b.dispatchEvent(event); // for backward compatibility - event = document.createEvent('Events'); - event.initEvent(this.kEVENT_TYPE_TAB_FOCUS_SWITCHING_END.replace(/^nsDOM/, ''), true, false); + event = b.ownerDocument.createEvent('XULCommandEvents'); + event.initCommandEvent(this.kEVENT_TYPE_TAB_FOCUS_SWITCHING_END.replace(/^nsDOM/, ''), + true, + false, + b.ownerDocument.defaultView, + detailFlags, + aEvent.ctrlKey, + aEvent.altKey, + aEvent.shiftKey, + aEvent.metaKey, + aEvent + ); event.scrollDown = scrollDown; event.scrollUp = scrollUp; event.standBy = standBy; event.onlyShiftKey = onlyShiftKey; - event.sourceEvent = aEvent; b.dispatchEvent(event); } diff --git a/modules/autoHide.js b/modules/autoHide.js index 458997ea..f235f7b1 100644 --- a/modules/autoHide.js +++ b/modules/autoHide.js @@ -1126,12 +1126,12 @@ AutoHideBrowser.prototype = { if (this.enabled && this.treeStyleTab.getTreePref('tabbar.autoShow.tabSwitch') && ( - aEvent.scrollDown || - aEvent.scrollUp || + aEvent.detail & this.treeStyleTab.kTAB_FOCUS_SWITCHING_SCROLL_DOWN || + aEvent.detail & this.treeStyleTab.kTAB_FOCUS_SWITCHING_SCROLL_UP || ( // when you release "shift" key this.expanded && - aEvent.standBy && - aEvent.onlyShiftKey + aEvent.detail & this.treeStyleTab.kTAB_FOCUS_SWITCHING_STAND_BY && + aEvent.detail & this.treeStyleTab.kTAB_FOCUS_SWITCHING_ONLY_SHIFT_KEY ) )) this.show(this.kSHOWN_BY_SHORTCUT); diff --git a/modules/utils.js b/modules/utils.js index 8ece049c..33eeb6ed 100644 --- a/modules/utils.js +++ b/modules/utils.js @@ -122,6 +122,10 @@ var TreeStyleTabUtils = { kEVENT_TYPE_TAB_FOCUS_SWITCHING_KEY_DOWN : 'nsDOMTreeStyleTabFocusSwitchingKeyDown', kEVENT_TYPE_TAB_FOCUS_SWITCHING_START : 'nsDOMTreeStyleTabFocusSwitchingStart', kEVENT_TYPE_TAB_FOCUS_SWITCHING_END : 'nsDOMTreeStyleTabFocusSwitchingEnd', + kTAB_FOCUS_SWITCHING_SCROLL_DOWN : (1 << 0), + kTAB_FOCUS_SWITCHING_SCROLL_UP : (1 << 1), + kTAB_FOCUS_SWITCHING_STAND_BY : (1 << 2), + kTAB_FOCUS_SWITCHING_ONLY_SHIFT_KEY : (1 << 3), kEVENT_TYPE_SUBTREE_CLOSING : 'nsDOMTreeStyleTabSubtreeClosing', kEVENT_TYPE_SUBTREE_CLOSED : 'nsDOMTreeStyleTabSubtreeClosed', kEVENT_TYPE_TAB_COLLAPSED_STATE_CHANGED : 'nsDOMTreeStyleTabCollapsedStateChange',