Follow to changes introduced by the bug 1207594.

The method "_setEffectAllowedForDataTransfer" was renamed to "_getDropEffectForTabDrag".
This commit is contained in:
YUKI Hiroshi 2015-11-04 11:43:54 +09:00
parent f75443ce6f
commit 1029b40e09
2 changed files with 32 additions and 3 deletions

View File

@ -134,6 +134,7 @@ var TreeStyleTabWindowHelper = {
) )
aObserver = aObserver.tabContainer; aObserver = aObserver.tabContainer;
if (typeof aObserver._setEffectAllowedForDataTransfer === 'function') { // Firefox 43 and older
TreeStyleTabUtils.doPatching(aObserver._setEffectAllowedForDataTransfer, aObserver+'._setEffectAllowedForDataTransfer', function(aName, aSource) { TreeStyleTabUtils.doPatching(aObserver._setEffectAllowedForDataTransfer, aObserver+'._setEffectAllowedForDataTransfer', function(aName, aSource) {
return eval('aObserver._setEffectAllowedForDataTransfer = '+aSource.replace( return eval('aObserver._setEffectAllowedForDataTransfer = '+aSource.replace(
'{', '{',
@ -153,6 +154,20 @@ var TreeStyleTabWindowHelper = {
'$& TST.getTabFromEvent(event) == sourceNode &&' '$& TST.getTabFromEvent(event) == sourceNode &&'
)); ));
}, 'TST'); }, '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() overrideGlobalFunctions : function TSTWH_overrideGlobalFunctions()

View File

@ -968,7 +968,13 @@ try{
var info = this.getDropAction(aEvent, session); var info = this.getDropAction(aEvent, session);
var observer = b; 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; observer = b.tabContainer;
// auto-switch for staying on tabs // auto-switch for staying on tabs
@ -980,7 +986,9 @@ try{
) { ) {
let time = observer.mDragTime || observer._dragTime || 0; let time = observer.mDragTime || observer._dragTime || 0;
let delay = observer.mDragOverDelay || observer._dragOverDelay || 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') { if (effects == 'link') {
let now = Date.now(); let now = Date.now();
if (!time) { if (!time) {
@ -995,14 +1003,20 @@ try{
} }
} }
{
let effects = '_setEffectAllowedForDataTransfer' in observer ?
observer._setEffectAllowedForDataTransfer(aEvent) :
observer._getDropEffectForTabDrag(aEvent) ;
if ( if (
!info.canDrop || !info.canDrop ||
observer._setEffectAllowedForDataTransfer(aEvent) == 'none' effects == 'none'
) { ) {
aEvent.dataTransfer.effectAllowed = "none"; aEvent.dataTransfer.effectAllowed = "none";
this.clearDropPosition(); this.clearDropPosition();
return true; return true;
} }
}
let indicatorTab = info.target; let indicatorTab = info.target;
if (sv.isCollapsed(info.target)) { if (sv.isCollapsed(info.target)) {