Firefox 3.1のドラッグ&ドロップの仕様変更に追従したつもり
git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@3057 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
parent
07892afb28
commit
8a039ececf
@ -877,8 +877,11 @@ var TreeStyleTabService = {
|
|||||||
|
|
||||||
updateTabDNDObserver : function(aObserver)
|
updateTabDNDObserver : function(aObserver)
|
||||||
{
|
{
|
||||||
eval('aObserver.canDrop = '+
|
var canDropFunctionName = '_setEffectAllowedForDataTransfer' in aObserver ?
|
||||||
aObserver.canDrop.toSource().replace(
|
'_setEffectAllowedForDataTransfer' : // Firefox 3.1 or later
|
||||||
|
'canDrop' ; // Firefox 3.0.x
|
||||||
|
eval('aObserver.'+canDropFunctionName+' = '+
|
||||||
|
aObserver[canDropFunctionName].toSource().replace(
|
||||||
'{',
|
'{',
|
||||||
'{ var TSTTabBrowser = this;'
|
'{ var TSTTabBrowser = this;'
|
||||||
).replace(
|
).replace(
|
||||||
@ -910,21 +913,30 @@ catch(e) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
})(TSTTabBrowser))
|
})(TSTTabBrowser))
|
||||||
return false;
|
return TST_DRAGDROP_DISALLOW_RETRUN_VALUE;
|
||||||
$1
|
$1
|
||||||
]]></>
|
]]></>
|
||||||
|
).replace(
|
||||||
|
/TST_DRAGDROP_DISALLOW_RETRUN_VALUE/g,
|
||||||
|
(canDropFunctionName == 'canDrop' ?
|
||||||
|
'false' :
|
||||||
|
'dt.effectAllowed = "none"'
|
||||||
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
eval('aObserver.onDragOver = '+
|
var dragOverFunctionName = '_onDragOver' in aObserver ?
|
||||||
aObserver.onDragOver.toSource().replace(
|
'_onDragOver' : // Firefox 3.1 or later
|
||||||
|
'onDragOver' ; // Firefox 3.0.x
|
||||||
|
eval('aObserver.'+dragOverFunctionName+' = '+
|
||||||
|
aObserver[dragOverFunctionName].toSource().replace(
|
||||||
'{',
|
'{',
|
||||||
<><![CDATA[
|
<><![CDATA[
|
||||||
{
|
{
|
||||||
var TSTTabBrowser = this;
|
var TSTTabBrowser = this;
|
||||||
if ((function(aSelf) {
|
if ((function(aSelf) {
|
||||||
try{
|
try{
|
||||||
var info = TSTTabBrowser.treeStyleTab.getDropAction(aEvent, aDragSession);
|
var info = TSTTabBrowser.treeStyleTab.getDropAction(aEvent, TST_DRAGSESSION);
|
||||||
|
|
||||||
if (!info.target || info.target != TreeStyleTabService.evaluateXPath(
|
if (!info.target || info.target != TreeStyleTabService.evaluateXPath(
|
||||||
'child::xul:tab[@'+TreeStyleTabService.kDROP_POSITION+']',
|
'child::xul:tab[@'+TreeStyleTabService.kDROP_POSITION+']',
|
||||||
@ -933,7 +945,7 @@ try{
|
|||||||
).singleNodeValue)
|
).singleNodeValue)
|
||||||
TSTTabBrowser.treeStyleTab.clearDropPosition();
|
TSTTabBrowser.treeStyleTab.clearDropPosition();
|
||||||
|
|
||||||
if (!aSelf.canDrop(aEvent, aDragSession)) return true;
|
if (TST_DRAGDROP_DISALLOW_CHECK) return true;
|
||||||
|
|
||||||
info.target.setAttribute(
|
info.target.setAttribute(
|
||||||
TreeStyleTabService.kDROP_POSITION,
|
TreeStyleTabService.kDROP_POSITION,
|
||||||
@ -951,33 +963,51 @@ catch(e) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
]]></>
|
]]></>
|
||||||
|
).replace(
|
||||||
|
/TST_DRAGSESSION/g,
|
||||||
|
(canDropFunctionName == 'canDrop' ?
|
||||||
|
'aDragSession' :
|
||||||
|
'null'
|
||||||
|
)
|
||||||
|
).replace(
|
||||||
|
/TST_DRAGDROP_DISALLOW_CHECK/g,
|
||||||
|
(canDropFunctionName == 'canDrop' ?
|
||||||
|
'!aSelf.canDrop(aEvent, aDragSession)' :
|
||||||
|
'aSelf._setEffectAllowedForDataTransfer == "none"'
|
||||||
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
eval('aObserver.onDragExit = '+
|
var dragExitFunctionName = '_onDragLeave' in aObserver ?
|
||||||
aObserver.onDragExit.toSource().replace(
|
'_onDragLeave' : // Firefox 3.1 or later
|
||||||
|
'onDragExit' ; // Firefox 3.0.x
|
||||||
|
eval('aObserver.'+dragExitFunctionName+' = '+
|
||||||
|
aObserver[dragExitFunctionName].toSource().replace(
|
||||||
/(this.mTabDropIndicatorBar\.[^;]+;)/,
|
/(this.mTabDropIndicatorBar\.[^;]+;)/,
|
||||||
'$1; this.treeStyleTab.clearDropPosition();'
|
'$1; this.treeStyleTab.clearDropPosition();'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
eval('aObserver.onDrop = '+
|
var dropFunctionName = '_onDrop' in aObserver ?
|
||||||
aObserver.onDrop.toSource().replace(
|
'_onDrop' : // Firefox 3.1 or later
|
||||||
|
'onDrop' ; // Firefox 3.0.x
|
||||||
|
eval('aObserver.'+dropFunctionName+' = '+
|
||||||
|
aObserver[dropFunctionName].toSource().replace(
|
||||||
'{',
|
'{',
|
||||||
<><![CDATA[
|
<><![CDATA[
|
||||||
{
|
{
|
||||||
var TSTTabBrowser = this;
|
var TSTTabBrowser = this;
|
||||||
TSTTabBrowser.treeStyleTab.clearDropPosition();
|
TSTTabBrowser.treeStyleTab.clearDropPosition();
|
||||||
var dropActionInfo = TSTTabBrowser.treeStyleTab.getDropAction(aEvent, aDragSession);
|
var dropActionInfo = TSTTabBrowser.treeStyleTab.getDropAction(aEvent, TST_DRAGSESSION);
|
||||||
]]></>
|
]]></>
|
||||||
).replace( // Firefox 2
|
).replace( // Firefox 2
|
||||||
/(if \(aDragSession[^\)]+\) \{)/,
|
/(if \(aDragSession[^\)]+\) \{)/,
|
||||||
<><![CDATA[$1
|
<><![CDATA[$1
|
||||||
if (TSTTabBrowser.treeStyleTab.processDropAction(dropActionInfo, aDragSession.sourceNode))
|
if (TSTTabBrowser.treeStyleTab.processDropAction(dropActionInfo, TST_DRAGSESSION.sourceNode))
|
||||||
return;
|
return;
|
||||||
]]></>
|
]]></>
|
||||||
).replace( // Firefox 3
|
).replace( // Firefox 3.0.x, 3.1 or later
|
||||||
/(if \((accelKeyPressed|isCopy)\) {)/,
|
/(if \((accelKeyPressed|isCopy|dropEffect == "copy")\) {)/,
|
||||||
<><![CDATA[
|
<><![CDATA[
|
||||||
if (TSTTabBrowser.treeStyleTab.processDropAction(dropActionInfo, draggedTab))
|
if (TSTTabBrowser.treeStyleTab.processDropAction(dropActionInfo, draggedTab))
|
||||||
return;
|
return;
|
||||||
@ -1016,6 +1046,12 @@ catch(e) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
]]></>
|
]]></>
|
||||||
|
).replace(
|
||||||
|
/TST_DRAGSESSION/g,
|
||||||
|
(canDropFunctionName == 'canDrop' ?
|
||||||
|
'aDragSession' :
|
||||||
|
'TSTTabBrowser.treeStyleTab.getCurrentDragSession()'
|
||||||
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -1919,12 +1919,24 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
var flavourSet = new FlavourSet();
|
var flavourSet = new FlavourSet();
|
||||||
flavourSet.appendFlavour('text/x-moz-url');
|
flavourSet.appendFlavour('text/x-moz-url');
|
||||||
flavourSet.appendFlavour('text/unicode');
|
flavourSet.appendFlavour('text/unicode');
|
||||||
|
flavourSet.appendFlavour('text/plain');
|
||||||
flavourSet.appendFlavour('application/x-moz-file', 'nsIFile');
|
flavourSet.appendFlavour('application/x-moz-file', 'nsIFile');
|
||||||
return flavourSet;
|
return flavourSet;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getCurrentDragSession : function()
|
||||||
|
{
|
||||||
|
return Components
|
||||||
|
.classes['@mozilla.org/widget/dragservice;1']
|
||||||
|
.getService(Components.interfaces.nsIDragService)
|
||||||
|
.getCurrentSession();
|
||||||
|
},
|
||||||
|
|
||||||
getDropAction : function(aEvent, aDragSession)
|
getDropAction : function(aEvent, aDragSession)
|
||||||
{
|
{
|
||||||
|
if (!aDragSession)
|
||||||
|
aDragSession = this.getCurrentDragSession();
|
||||||
|
|
||||||
var info = this.getDropActionInternal(aEvent);
|
var info = this.getDropActionInternal(aEvent);
|
||||||
info.canDrop = true;
|
info.canDrop = true;
|
||||||
if (aDragSession &&
|
if (aDragSession &&
|
||||||
|
Loading…
Reference in New Issue
Block a user