diff --git a/content/treestyletab/windowHelper.js b/content/treestyletab/windowHelper.js index 6eeb52b7..5b2bb501 100644 --- a/content/treestyletab/windowHelper.js +++ b/content/treestyletab/windowHelper.js @@ -134,6 +134,7 @@ var TreeStyleTabWindowHelper = { ) aObserver = aObserver.tabContainer; + if (typeof aObserver._setEffectAllowedForDataTransfer === 'function') { // Firefox 43 and older TreeStyleTabUtils.doPatching(aObserver._setEffectAllowedForDataTransfer, aObserver+'._setEffectAllowedForDataTransfer', function(aName, aSource) { return eval('aObserver._setEffectAllowedForDataTransfer = '+aSource.replace( '{', @@ -153,6 +154,20 @@ var TreeStyleTabWindowHelper = { '$& TST.getTabFromEvent(event) == sourceNode &&' )); }, 'TST'); + } + else { // Firefox 44 and later + aObserver.__treestyletab__getDropEffectForTabDrag = aObserver._getDropEffectForTabDrag; + aObserver._getDropEffectForTabDrag = function(...aArgs) { + var effects = this.__treestyletab__getDropEffectForTabDrag.apply(this, aArgs); + if (effects === 'copy' || effects === 'move') { + let TSTTabBrowser = this instanceof Element ? (this.tabbrowser || this) : gBrowser ; + var TST = TSTTabBrowser.treeStyleTab + if (!TST.tabbarDNDObserver.canDropTab(aArgs[0])) + effects = 'none'; + } + return effects; + }; + } }, overrideGlobalFunctions : function TSTWH_overrideGlobalFunctions() diff --git a/modules/tabbarDNDObserver.js b/modules/tabbarDNDObserver.js index d75807e5..4db99d7c 100644 --- a/modules/tabbarDNDObserver.js +++ b/modules/tabbarDNDObserver.js @@ -968,7 +968,13 @@ try{ var info = this.getDropAction(aEvent, session); var observer = b; - if (b.tabContainer && b.tabContainer._setEffectAllowedForDataTransfer) + if ( + b.tabContainer && + ( + b.tabContainer._getDropEffectForTabDrag || // Firefox 44 and later + b.tabContainer._setEffectAllowedForDataTransfer // Firefox 43 and older + ) + ) observer = b.tabContainer; // auto-switch for staying on tabs @@ -980,7 +986,9 @@ try{ ) { let time = observer.mDragTime || observer._dragTime || 0; let delay = observer.mDragOverDelay || observer._dragOverDelay || 0; - let effects = observer._setEffectAllowedForDataTransfer(aEvent); + let effects = '_setEffectAllowedForDataTransfer' in observer ? + observer._setEffectAllowedForDataTransfer(aEvent) : + observer._getDropEffectForTabDrag(aEvent) ; if (effects == 'link') { let now = Date.now(); if (!time) { @@ -995,14 +1003,20 @@ try{ } } + { + let effects = '_setEffectAllowedForDataTransfer' in observer ? + observer._setEffectAllowedForDataTransfer(aEvent) : + observer._getDropEffectForTabDrag(aEvent) ; + if ( !info.canDrop || - observer._setEffectAllowedForDataTransfer(aEvent) == 'none' + effects == 'none' ) { aEvent.dataTransfer.effectAllowed = "none"; this.clearDropPosition(); return true; } + } let indicatorTab = info.target; if (sv.isCollapsed(info.target)) {