Bug 456106, use new drag and drop api in browser and toolkit, r=mano

This commit is contained in:
Neil Deakin 2009-06-20 20:04:07 -04:00
parent 444dc5a9aa
commit 2b862dc7a3
19 changed files with 462 additions and 548 deletions

View File

@ -2302,16 +2302,6 @@ function PageProxyClearIcon ()
gProxyFavIcon.removeAttribute("src"); gProxyFavIcon.removeAttribute("src");
} }
function PageProxyDragGesture(aEvent)
{
if (gProxyFavIcon.getAttribute("pageproxystate") == "valid") {
nsDragAndDrop.startDrag(aEvent, proxyIconDNDObserver);
return true;
}
return false;
}
function PageProxyClickHandler(aEvent) function PageProxyClickHandler(aEvent)
{ {
if (aEvent.button == 1 && gPrefService.getBoolPref("middlemouse.paste")) if (aEvent.button == 1 && gPrefService.getBoolPref("middlemouse.paste"))
@ -2668,56 +2658,88 @@ function FillInHTMLTooltip(tipElement)
return retVal; return retVal;
} }
var browserDragAndDrop = {
getDragURLFromDataTransfer : function (dt)
{
var types = dt.types;
for (var t = 0; t < types.length; t++) {
var type = types[t];
switch (type) {
case "text/uri-list":
var url = dt.getData("URL").replace(/^\s+|\s+$/g, "");
return [url, url];
case "text/plain":
case "text/x-moz-text-internal":
var url = dt.getData(type).replace(/^\s+|\s+$/g, "");
return [url, url];
case "text/x-moz-url":
var split = dt.getData(type).split("\n");
return [split[0], split[1]];
case "application/x-moz-file":
var file = dt.mozGetDataAt(type, 0);
var name = file instanceof Components.interfaces.nsIFile ? file.leafName : "";
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var fileHandler = ioService.getProtocolHandler("file")
.QueryInterface(Components.interfaces.nsIFileProtocolHandler);
return [fileHandler.getURLSpecFromFile(file), name];
}
}
return [ , ];
},
dragOver : function (aEvent, statusString)
{
var types = aEvent.dataTransfer.types;
if (types.contains("application/x-moz-file") ||
types.contains("text/x-moz-url") ||
types.contains("text/uri-list") ||
types.contains("text/plain")) {
aEvent.preventDefault();
if (statusString) {
var statusTextFld = document.getElementById("statusbar-display");
statusTextFld.label = gNavigatorBundle.getString(statusString);
}
}
}
}
var proxyIconDNDObserver = { var proxyIconDNDObserver = {
onDragStart: function (aEvent, aXferData, aDragAction) onDragStart: function (aEvent, aXferData, aDragAction)
{ {
if (gProxyFavIcon.getAttribute("pageproxystate") != "valid")
return;
var value = content.location.href; var value = content.location.href;
var urlString = value + "\n" + content.document.title; var urlString = value + "\n" + content.document.title;
var htmlString = "<a href=\"" + value + "\">" + value + "</a>"; var htmlString = "<a href=\"" + value + "\">" + value + "</a>";
aXferData.data = new TransferData(); var dt = aEvent.dataTransfer;
aXferData.data.addDataForFlavour("text/x-moz-url", urlString); dt.setData("text/x-moz-url", urlString);
aXferData.data.addDataForFlavour("text/unicode", value); dt.setData("text/uri-list", value);
aXferData.data.addDataForFlavour("text/html", htmlString); dt.setData("text/plain", value);
dt.setData("text/html", htmlString);
// we're copying the URL from the proxy icon, not moving
// we specify all of them though, because d&d sucks and OS's
// get confused if they don't get the one they want
aDragAction.action =
Components.interfaces.nsIDragService.DRAGDROP_ACTION_COPY |
Components.interfaces.nsIDragService.DRAGDROP_ACTION_MOVE |
Components.interfaces.nsIDragService.DRAGDROP_ACTION_LINK;
} }
} }
var homeButtonObserver = { var homeButtonObserver = {
onDrop: function (aEvent, aXferData, aDragSession) onDrop: function (aEvent)
{ {
var url = transferUtils.retrieveURLFromData(aXferData.data, aXferData.flavour.contentType); let url = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer)[0];
setTimeout(openHomeDialog, 0, url); setTimeout(openHomeDialog, 0, url);
}, },
onDragOver: function (aEvent, aFlavour, aDragSession) onDragOver: function (aEvent)
{ {
var statusTextFld = document.getElementById("statusbar-display"); browserDragAndDrop.dragOver(aEvent, "droponhomebutton");
statusTextFld.label = gNavigatorBundle.getString("droponhomebutton"); aEvent.dropEffect = "link";
aDragSession.dragAction = Components.interfaces.nsIDragService.DRAGDROP_ACTION_LINK;
}, },
onDragLeave: function (aEvent)
onDragExit: function (aEvent, aDragSession)
{ {
var statusTextFld = document.getElementById("statusbar-display"); var statusTextFld = document.getElementById("statusbar-display");
statusTextFld.label = ""; statusTextFld.label = "";
},
getSupportedFlavours: function ()
{
var flavourSet = new FlavourSet();
flavourSet.appendFlavour("application/x-moz-file", "nsIFile");
flavourSet.appendFlavour("text/x-moz-url");
flavourSet.appendFlavour("text/unicode");
flavourSet.appendFlavour("text/x-moz-text-internal"); // for tabs
return flavourSet;
} }
} }
@ -2746,137 +2768,101 @@ function openHomeDialog(aURL)
} }
var bookmarksButtonObserver = { var bookmarksButtonObserver = {
onDrop: function (aEvent, aXferData, aDragSession) onDrop: function (aEvent)
{ {
var split = aXferData.data.split("\n"); let [url, name] = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer);
var url = split[0]; try {
if (url != aXferData.data) // do nothing if it's not a valid URL PlacesUIUtils.showMinimalAddBookmarkUI(makeURI(url), name);
PlacesUIUtils.showMinimalAddBookmarkUI(makeURI(url), split[1]); } catch(ex) { }
}, },
onDragOver: function (aEvent, aFlavour, aDragSession) onDragOver: function (aEvent)
{ {
var statusTextFld = document.getElementById("statusbar-display"); browserDragAndDrop.dragOver(aEvent, "droponbookmarksbutton");
statusTextFld.label = gNavigatorBundle.getString("droponbookmarksbutton"); aEvent.dropEffect = "link";
aDragSession.dragAction = Components.interfaces.nsIDragService.DRAGDROP_ACTION_LINK;
}, },
onDragExit: function (aEvent, aDragSession) onDragLeave: function (aEvent)
{ {
var statusTextFld = document.getElementById("statusbar-display"); var statusTextFld = document.getElementById("statusbar-display");
statusTextFld.label = ""; statusTextFld.label = "";
},
getSupportedFlavours: function ()
{
var flavourSet = new FlavourSet();
flavourSet.appendFlavour("application/x-moz-file", "nsIFile");
flavourSet.appendFlavour("text/x-moz-url");
flavourSet.appendFlavour("text/unicode");
return flavourSet;
} }
} }
var newTabButtonObserver = { var newTabButtonObserver = {
onDragOver: function(aEvent, aFlavour, aDragSession) { onDragOver: function (aEvent)
var statusTextFld = document.getElementById("statusbar-display"); {
statusTextFld.label = gNavigatorBundle.getString("droponnewtabbutton"); browserDragAndDrop.dragOver(aEvent, "droponnewtabbutton");
return true;
}, },
onDragExit: function (aEvent, aDragSession) {
onDragLeave: function (aEvent)
{
var statusTextFld = document.getElementById("statusbar-display"); var statusTextFld = document.getElementById("statusbar-display");
statusTextFld.label = ""; statusTextFld.label = "";
}, },
onDrop: function (aEvent, aXferData, aDragSession) {
var xferData = aXferData.data.split("\n"); onDrop: function (aEvent)
var draggedText = xferData[0] || xferData[1]; {
let url = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer)[0];
var postData = {}; var postData = {};
var url = getShortcutOrURI(draggedText, postData); url = getShortcutOrURI(url, postData);
if (url) { if (url) {
nsDragAndDrop.dragDropSecurityCheck(aEvent, aDragSession, url); nsDragAndDrop.dragDropSecurityCheck(aEvent, null, url);
// allow third-party services to fixup this URL // allow third-party services to fixup this URL
openNewTabWith(url, null, postData.value, aEvent, true); openNewTabWith(url, null, postData.value, aEvent, true);
} }
},
getSupportedFlavours: function () {
var flavourSet = new FlavourSet();
flavourSet.appendFlavour("text/unicode");
flavourSet.appendFlavour("text/x-moz-url");
flavourSet.appendFlavour("application/x-moz-file", "nsIFile");
return flavourSet;
} }
} }
var newWindowButtonObserver = { var newWindowButtonObserver = {
onDragOver: function(aEvent, aFlavour, aDragSession) onDragOver: function (aEvent)
{ {
var statusTextFld = document.getElementById("statusbar-display"); browserDragAndDrop.dragOver(aEvent, "droponnewwindowbutton");
statusTextFld.label = gNavigatorBundle.getString("droponnewwindowbutton");
return true;
}, },
onDragExit: function (aEvent, aDragSession) onDragLeave: function (aEvent)
{ {
var statusTextFld = document.getElementById("statusbar-display"); var statusTextFld = document.getElementById("statusbar-display");
statusTextFld.label = ""; statusTextFld.label = "";
}, },
onDrop: function (aEvent, aXferData, aDragSession) onDrop: function (aEvent)
{ {
var xferData = aXferData.data.split("\n"); let url = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer)[0];
var draggedText = xferData[0] || xferData[1];
var postData = {}; var postData = {};
var url = getShortcutOrURI(draggedText, postData); url = getShortcutOrURI(url, postData);
if (url) { if (url) {
nsDragAndDrop.dragDropSecurityCheck(aEvent, aDragSession, url); nsDragAndDrop.dragDropSecurityCheck(aEvent, null, url);
// allow third-party services to fixup this URL // allow third-party services to fixup this URL
openNewWindowWith(url, null, postData.value, true); openNewWindowWith(url, null, postData.value, true);
} }
},
getSupportedFlavours: function ()
{
var flavourSet = new FlavourSet();
flavourSet.appendFlavour("text/unicode");
flavourSet.appendFlavour("text/x-moz-url");
flavourSet.appendFlavour("application/x-moz-file", "nsIFile");
flavourSet.appendFlavour("text/x-moz-text-internal"); // for tabs
return flavourSet;
} }
} }
var DownloadsButtonDNDObserver = { var DownloadsButtonDNDObserver = {
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// nsDragAndDrop // nsDragAndDrop
onDragOver: function (aEvent, aFlavour, aDragSession) onDragOver: function (aEvent)
{ {
var statusTextFld = document.getElementById("statusbar-display"); var statusTextFld = document.getElementById("statusbar-display");
statusTextFld.label = gNavigatorBundle.getString("dropondownloadsbutton"); statusTextFld.label = gNavigatorBundle.getString("dropondownloadsbutton");
aDragSession.canDrop = (aFlavour.contentType == "text/x-moz-url" || var types = aEvent.dataTransfer.types;
aFlavour.contentType == "text/unicode"); if (types.contains("text/x-moz-url") ||
types.contains("text/uri-list") ||
types.contains("text/plain"))
aEvent.preventDefault();
}, },
onDragExit: function (aEvent, aDragSession) onDragLeave: function (aEvent)
{ {
var statusTextFld = document.getElementById("statusbar-display"); var statusTextFld = document.getElementById("statusbar-display");
statusTextFld.label = ""; statusTextFld.label = "";
}, },
onDrop: function (aEvent, aXferData, aDragSession) onDrop: function (aEvent)
{ {
var split = aXferData.data.split("\n"); let [url, name] = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer);
var url = split[0]; nsDragAndDrop.dragDropSecurityCheck(aEvent, null, url);
if (url != aXferData.data) { //do nothing, not a valid URL
nsDragAndDrop.dragDropSecurityCheck(aEvent, aDragSession, url);
var name = split[1];
saveURL(url, name, null, true, true); saveURL(url, name, null, true, true);
} }
},
getSupportedFlavours: function ()
{
var flavourSet = new FlavourSet();
flavourSet.appendFlavour("text/x-moz-url");
flavourSet.appendFlavour("text/unicode");
return flavourSet;
}
} }
const DOMLinkHandler = { const DOMLinkHandler = {
@ -5021,15 +5007,21 @@ function middleMousePaste(event)
*/ */
var contentAreaDNDObserver = { var contentAreaDNDObserver = {
onDrop: function (aEvent, aXferData, aDragSession) onDragOver: function (aEvent)
{
var types = aEvent.dataTransfer.types;
if (types.contains("application/x-moz-file") ||
types.contains("text/x-moz-url") ||
types.contains("text/uri-list") ||
types.contains("text/plain"))
aEvent.preventDefault();
},
onDrop: function (aEvent)
{ {
if (aEvent.getPreventDefault()) if (aEvent.getPreventDefault())
return; return;
var dragType = aXferData.flavour.contentType; let [url, name] = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer);
var dragData = aXferData.data;
var url = transferUtils.retrieveURLFromData(dragData, dragType);
// valid urls don't contain spaces ' '; if we have a space it // valid urls don't contain spaces ' '; if we have a space it
// isn't a valid url, or if it's a javascript: or data: url, // isn't a valid url, or if it's a javascript: or data: url,
@ -5038,7 +5030,7 @@ var contentAreaDNDObserver = {
/^\s*(javascript|data):/.test(url)) /^\s*(javascript|data):/.test(url))
return; return;
nsDragAndDrop.dragDropSecurityCheck(aEvent, aDragSession, url); nsDragAndDrop.dragDropSecurityCheck(aEvent, null, url);
switch (document.documentElement.getAttribute('windowtype')) { switch (document.documentElement.getAttribute('windowtype')) {
case "navigator:browser": case "navigator:browser":
@ -5054,18 +5046,7 @@ var contentAreaDNDObserver = {
// keep the event from being handled by the dragDrop listeners // keep the event from being handled by the dragDrop listeners
// built-in to gecko if they happen to be above us. // built-in to gecko if they happen to be above us.
aEvent.preventDefault(); aEvent.preventDefault();
},
getSupportedFlavours: function ()
{
var flavourSet = new FlavourSet();
flavourSet.appendFlavour(TAB_DROP_TYPE);
flavourSet.appendFlavour("text/x-moz-url");
flavourSet.appendFlavour("text/plain");
flavourSet.appendFlavour("application/x-moz-file", "nsIFile");
return flavourSet;
} }
}; };
function MultiplexHandler(event) function MultiplexHandler(event)

View File

@ -344,9 +344,10 @@
<toolbarbutton id="home-button" class="toolbarbutton-1 chromeclass-toolbar-additional" <toolbarbutton id="home-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
persist="class" persist="class"
label="&homeButton.label;" label="&homeButton.label;"
ondragover="nsDragAndDrop.dragOver(event, homeButtonObserver);" ondragover="homeButtonObserver.onDragOver(event)"
ondragdrop="nsDragAndDrop.drop(event, homeButtonObserver);" ondragenter="homeButtonObserver.onDragOver(event)"
ondragexit="nsDragAndDrop.dragExit(event, homeButtonObserver);" ondrop="homeButtonObserver.onDrop(event)"
ondragleave="homeButtonObserver.onDragLeave(event)"
onclick="BrowserGoHome(event);"/> onclick="BrowserGoHome(event);"/>
<toolbaritem id="urlbar-container" align="center" flex="400" persist="width" <toolbaritem id="urlbar-container" align="center" flex="400" persist="width"
@ -389,7 +390,7 @@
<image id="urlbar-throbber" busy="false"/> <image id="urlbar-throbber" busy="false"/>
<image id="page-proxy-favicon" validate="never" <image id="page-proxy-favicon" validate="never"
pageproxystate="invalid" pageproxystate="invalid"
ondraggesture="PageProxyDragGesture(event);" ondragstart="proxyIconDNDObserver.onDragStart(event);"
onerror="this.removeAttribute('src');"/> onerror="this.removeAttribute('src');"/>
</stack> </stack>
<label id="identity-icon-label" crop="center" flex="1"/> <label id="identity-icon-label" crop="center" flex="1"/>
@ -449,10 +450,10 @@
<toolbarbutton id="downloads-button" class="toolbarbutton-1 chromeclass-toolbar-additional" <toolbarbutton id="downloads-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
observes="Tools:Downloads" observes="Tools:Downloads"
ondragdrop="nsDragAndDrop.drop(event, DownloadsButtonDNDObserver); event.stopPropagation()" ondrop="DownloadsButtonDNDObserver.onDrop(event)"
ondragover="nsDragAndDrop.dragOver(event, DownloadsButtonDNDObserver); event.stopPropagation()" ondragover="DownloadsButtonDNDObserver.onDragOver(event)"
ondragenter="nsDragAndDrop.dragEnter(event, DownloadsButtonDNDObserver); event.stopPropagation()" ondragenter="DownloadsButtonDNDObserver.onDragOver(event)"
ondragexit="nsDragAndDrop.dragExit(event, DownloadsButtonDNDObserver); event.stopPropagation()" ondragleave="DownloadsButtonDNDObserver.onDragLeave(event)"
label="&downloads.label;" label="&downloads.label;"
tooltiptext="&downloads.tooltip;"/> tooltiptext="&downloads.tooltip;"/>
@ -463,25 +464,28 @@
<toolbarbutton id="bookmarks-button" class="toolbarbutton-1 chromeclass-toolbar-additional" <toolbarbutton id="bookmarks-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
observes="viewBookmarksSidebar" observes="viewBookmarksSidebar"
tooltiptext="&bookmarksButton.tooltip;" tooltiptext="&bookmarksButton.tooltip;"
ondragover="nsDragAndDrop.dragOver(event, bookmarksButtonObserver);" ondrop="bookmarksButtonObserver.onDrop(event)"
ondragdrop="nsDragAndDrop.drop(event, bookmarksButtonObserver);" ondragover="bookmarksButtonObserver.onDragOver(event)"
ondragexit="nsDragAndDrop.dragExit(event, bookmarksButtonObserver);"/> ondragenter="bookmarksButtonObserver.onDragOver(event)"
ondragleave="bookmarksButtonObserver.onDragLeave(event)"/>
<toolbarbutton id="new-tab-button" class="toolbarbutton-1 chromeclass-toolbar-additional" <toolbarbutton id="new-tab-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
label="&tabCmd.label;" label="&tabCmd.label;"
command="cmd_newNavigatorTab" command="cmd_newNavigatorTab"
tooltiptext="&newTabButton.tooltip;" tooltiptext="&newTabButton.tooltip;"
ondragover="nsDragAndDrop.dragOver(event, newTabButtonObserver);" ondrop="newTabButtonObserver.onDrop(event)"
ondragdrop="nsDragAndDrop.drop(event, newTabButtonObserver);" ondragover="newTabButtonObserver.onDragOver(event)"
ondragexit="nsDragAndDrop.dragExit(event, newTabButtonObserver);"/> ondragenter="newTabButtonObserver.onDragOver(event)"
ondragleave="newTabButtonObserver.onDragLeave(event)"/>
<toolbarbutton id="new-window-button" class="toolbarbutton-1 chromeclass-toolbar-additional" <toolbarbutton id="new-window-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
label="&newNavigatorCmd.label;" label="&newNavigatorCmd.label;"
command="key_newNavigator" command="key_newNavigator"
tooltiptext="&newWindowButton.tooltip;" tooltiptext="&newWindowButton.tooltip;"
ondragover="nsDragAndDrop.dragOver(event, newWindowButtonObserver);" ondrop="newWindowButtonObserver.onDrop(event)"
ondragdrop="nsDragAndDrop.drop(event, newWindowButtonObserver);" ondragover="newWindowButtonObserver.onDragOver(event)"
ondragexit="nsDragAndDrop.dragExit(event, newWindowButtonObserver);"/> ondragenter="newWindowButtonObserver.onDragOver(event)"
ondragleave="newWindowButtonObserver.onDragLeave(event)"/>
<toolbarbutton id="cut-button" class="toolbarbutton-1 chromeclass-toolbar-additional" <toolbarbutton id="cut-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
label="&cutCmd.label;" label="&cutCmd.label;"
@ -557,7 +561,7 @@
contentcontextmenu="contentAreaContextMenu" contentcontextmenu="contentAreaContextMenu"
onnewtab="BrowserOpenTab();" onnewtab="BrowserOpenTab();"
autocompletepopup="PopupAutoComplete" autocompletepopup="PopupAutoComplete"
ondrop="nsDragAndDrop.drop(event, contentAreaDNDObserver);" ondrop="contentAreaDNDObserver.onDrop(event)"
onclick="return contentAreaClick(event, false);"/> onclick="return contentAreaClick(event, false);"/>
</vbox> </vbox>
</hbox> </hbox>
@ -571,7 +575,7 @@
<findbar browserid="content" id="FindToolbar"/> <findbar browserid="content" id="FindToolbar"/>
<statusbar class="chromeclass-status" id="status-bar" <statusbar class="chromeclass-status" id="status-bar"
ondrop="nsDragAndDrop.drop(event, contentAreaDNDObserver);"> ondrop="contentAreaDNDObserver.onDrop(event)">
<statusbarpanel id="statusbar-display" label="" flex="1"/> <statusbarpanel id="statusbar-display" label="" flex="1"/>
<statusbarpanel class="statusbarpanel-progress" collapsed="true" id="statusbar-progresspanel"> <statusbarpanel class="statusbarpanel-progress" collapsed="true" id="statusbar-progresspanel">
<progressmeter class="progressmeter-statusbar" id="statusbar-icon" mode="normal" value="0"/> <progressmeter class="progressmeter-statusbar" id="statusbar-icon" mode="normal" value="0"/>

View File

@ -216,7 +216,7 @@
<!-- Media information --> <!-- Media information -->
<vbox id="mediaPanel"> <vbox id="mediaPanel">
<tree id="imagetree" onselect="onImageSelect();" contextmenu="picontext" <tree id="imagetree" onselect="onImageSelect();" contextmenu="picontext"
ondraggesture="onBeginLinkDrag(event,'image-address','image-alt')"> ondragstart="onBeginLinkDrag(event,'image-address','image-alt')">
<treecols> <treecols>
<treecol sortSeparators="true" persist="hidden width" flex="10" <treecol sortSeparators="true" persist="hidden width" flex="10"
width="10" id="image-address" label="&mediaAddress;"/> width="10" id="image-address" label="&mediaAddress;"/>

View File

@ -122,6 +122,7 @@ _BROWSER_FILES = browser_sanitize-timespans.js \
browser_tabs_owner.js \ browser_tabs_owner.js \
browser_bug491431.js \ browser_bug491431.js \
browser_bug304198.js \ browser_bug304198.js \
browser_drag.js \
$(NULL) $(NULL)
ifeq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) ifeq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))

View File

@ -0,0 +1,23 @@
function test()
{
// ---- Test dragging the proxy icon ---
var value = content.location.href;
var urlString = value + "\n" + content.document.title;
var htmlString = "<a href=\"" + value + "\">" + value + "</a>";
var expected = [ [
"text/x-moz-url: " + urlString,
"text/uri-list: " + value,
"text/plain: " + value,
"text/html: " + htmlString
] ];
// set the valid attribute so dropping is allowed
var proxyicon = document.getElementById("page-proxy-favicon")
var oldstate = proxyicon.getAttribute("pageproxystate");
proxyicon.setAttribute("pageproxystate", "valid");
var dt = EventUtils.synthesizeDragStart(proxyicon, expected);
is(dt, null, "drag on proxy icon");
proxyicon.setAttribute("pageproxystate", oldstate);
}

View File

@ -238,22 +238,27 @@
</method> </method>
<method name="onDragOver"> <method name="onDragOver">
<parameter name="aEvent"/>
<body> <body>
return true; var types = aEvent.dataTransfer.types;
if (types.contains("application/x-moz-file") ||
types.contains("text/x-moz-url") ||
types.contains("text/uri-list") ||
types.contains("text/unicode"))
aEvent.preventDefault();
</body> </body>
</method> </method>
<method name="onDrop"> <method name="onDrop">
<parameter name="aEvent"/> <parameter name="aEvent"/>
<parameter name="aXferData"/>
<parameter name="aDragSession"/>
<body><![CDATA[ <body><![CDATA[
var url = transferUtils.retrieveURLFromData(aXferData.data, aXferData.flavour.contentType); aEvent.stopPropagation();
var url = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer)[0];
// The URL bar automatically handles inputs with newline characters, // The URL bar automatically handles inputs with newline characters,
// so we can get away with treating text/x-moz-url flavours as text/unicode. // so we can get away with treating text/x-moz-url flavours as text/plain.
if (url) { if (url) {
nsDragAndDrop.dragDropSecurityCheck(aEvent, aDragSession, url); nsDragAndDrop.dragDropSecurityCheck(aEvent, null, url);
this.value = url; this.value = url;
SetPageProxyState("invalid"); SetPageProxyState("invalid");
@ -269,21 +274,6 @@
]]></body> ]]></body>
</method> </method>
<method name="getSupportedFlavours">
<body><![CDATA[
var flavourSet = new FlavourSet();
// Favor text/x-moz-url since text/unicode coming from Win32 1.8 branch
// drops contains URL\ntext. The previous comment here said that
// plain text drops often come with text/x-moz-url flavor, but I
// haven't seen that, so hopefully that behavior has changed.
flavourSet.appendFlavour("text/x-moz-url");
flavourSet.appendFlavour("text/unicode");
flavourSet.appendFlavour("application/x-moz-file", "nsIFile");
return flavourSet;
]]></body>
</method>
<method name="_getSelectedValueForClipboard"> <method name="_getSelectedValueForClipboard">
<body><![CDATA[ <body><![CDATA[
var val = this.value.substring(this.selectionStart, this.selectionEnd); var val = this.value.substring(this.selectionStart, this.selectionEnd);
@ -449,8 +439,8 @@
event.stopPropagation(); event.stopPropagation();
]]></handler> ]]></handler>
<handler event="focus" phase="capturing" action="this._hideURLTooltip();"/> <handler event="focus" phase="capturing" action="this._hideURLTooltip();"/>
<handler event="dragover" phase="capturing" action="nsDragAndDrop.dragOver(event, this);"/> <handler event="dragover" phase="capturing" action="this.onDragOver(event, this);"/>
<handler event="drop" phase="capturing" action="nsDragAndDrop.drop(event, this);"/> <handler event="drop" phase="capturing" action="this.onDrop(event, this);"/>
<handler event="select"><![CDATA[ <handler event="select"><![CDATA[
if (!Cc["@mozilla.org/widget/clipboard;1"] if (!Cc["@mozilla.org/widget/clipboard;1"]
.getService(Ci.nsIClipboard) .getService(Ci.nsIClipboard)

View File

@ -224,22 +224,13 @@ var gEngineManagerDialog = {
} }
}; };
var gDragObserver = { function onDragEngineStart(event) {
onDragStart: function (aEvent, aXferData, aDragAction) {
var selectedIndex = gEngineView.selectedIndex; var selectedIndex = gEngineView.selectedIndex;
if (selectedIndex == -1) if (selectedIndex > 0) {
return; event.dataTransfer.setData(ENGINE_FLAVOR, selectedIndex.toString());
event.dataTransfer.effectAllowed = "move";
aXferData.data = new TransferData(); }
aXferData.data.addDataForFlavour(ENGINE_FLAVOR, selectedIndex.toString()); }
aDragAction.action = Ci.nsIDragService.DRAGDROP_ACTION_MOVE;
},
onDrop: function (aEvent, aXferData, aDragSession) { },
onDragExit: function (aEvent, aDragSession) { },
onDragOver: function (aEvent, aFlavour, aDragSession) { },
getSupportedFlavours: function() { return null; }
};
// "Operation" objects // "Operation" objects
function EngineMoveOp(aEngineClone, aNewIndex) { function EngineMoveOp(aEngineClone, aNewIndex) {

View File

@ -58,8 +58,6 @@
<script type="application/x-javascript" <script type="application/x-javascript"
src="chrome://browser/content/search/engineManager.js"/> src="chrome://browser/content/search/engineManager.js"/>
<script type="application/x-javascript"
src="chrome://global/content/nsDragAndDrop.js"/>
<commandset id="engineManagerCommandSet"> <commandset id="engineManagerCommandSet">
<command id="cmd_remove" <command id="cmd_remove"
@ -90,7 +88,7 @@
<tree id="engineList" flex="1" rows="10" hidecolumnpicker="true" <tree id="engineList" flex="1" rows="10" hidecolumnpicker="true"
seltype="single" onselect="gEngineManagerDialog.onSelect();"> seltype="single" onselect="gEngineManagerDialog.onSelect();">
<treechildren id="engineChildren" flex="1" <treechildren id="engineChildren" flex="1"
ondraggesture="nsDragAndDrop.startDrag(event, gDragObserver);"/> ondragstart="onDragEngineStart(event)"/>
<treecols> <treecols>
<treecol id="engineName" flex="4" label="&columnLabel.name;"/> <treecol id="engineName" flex="4" label="&columnLabel.name;"/>
<treecol id="engineKeyword" flex="1" label="&columnLabel.keyword;"/> <treecol id="engineKeyword" flex="1" label="&columnLabel.keyword;"/>

View File

@ -67,7 +67,6 @@
onunload="window.XULBrowserWindow.destroy();"> onunload="window.XULBrowserWindow.destroy();">
<script type="application/javascript" src="chrome://help/content/help.js"/> <script type="application/javascript" src="chrome://help/content/help.js"/>
<script type="application/javascript" src="chrome://global/content/nsDragAndDrop.js"/>
<script type="application/javascript" src="chrome://global/content/viewZoomOverlay.js"/> <script type="application/javascript" src="chrome://global/content/viewZoomOverlay.js"/>
<script type="application/javascript" src="chrome://global/content/globalOverlay.js"/> <script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>

View File

@ -68,7 +68,6 @@
persist="screenX screenY width height sizemode"> persist="screenX screenY width height sizemode">
<script type="application/javascript" src="chrome://global/content/globalOverlay.js"/> <script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="application/javascript" src="chrome://global/content/nsDragAndDrop.js"/>
<script type="application/javascript" src="chrome://global/content/printUtils.js"/> <script type="application/javascript" src="chrome://global/content/printUtils.js"/>
<script type="application/javascript" src="chrome://global/content/viewSource.js"/> <script type="application/javascript" src="chrome://global/content/viewSource.js"/>
<script type="application/javascript" src="chrome://global/content/viewPartialSource.js"/> <script type="application/javascript" src="chrome://global/content/viewPartialSource.js"/>
@ -185,9 +184,7 @@
</menubar> </menubar>
</toolbox> </toolbox>
<vbox id="appcontent" flex="1" <vbox id="appcontent" flex="1" ondrop="contentAreaDNDObserver.drop(event);">
ondragdrop="nsDragAndDrop.drop(event, contentAreaDNDObserver);">
<browser id="content" type="content-primary" name="content" src="about:blank" flex="1" <browser id="content" type="content-primary" name="content" src="about:blank" flex="1"
disablehistory="true" context="viewSourceContextMenu"/> disablehistory="true" context="viewSourceContextMenu"/>
<findbar id="FindToolbar" browserid="content"/> <findbar id="FindToolbar" browserid="content"/>

View File

@ -74,7 +74,6 @@
<script type="application/javascript" src="chrome://global/content/viewSource.js"/> <script type="application/javascript" src="chrome://global/content/viewSource.js"/>
<script type="application/javascript" src="chrome://global/content/viewZoomOverlay.js"/> <script type="application/javascript" src="chrome://global/content/viewZoomOverlay.js"/>
<script type="application/javascript" src="chrome://global/content/contentAreaUtils.js"/> <script type="application/javascript" src="chrome://global/content/contentAreaUtils.js"/>
<script type="application/javascript" src="chrome://global/content/nsDragAndDrop.js"/>
<stringbundle id="viewSourceBundle" src="chrome://global/locale/viewSource.properties"/> <stringbundle id="viewSourceBundle" src="chrome://global/locale/viewSource.properties"/>
@ -235,8 +234,7 @@
</menubar> </menubar>
</toolbox> </toolbox>
<vbox id="appcontent" flex="1" <vbox id="appcontent" flex="1" ondrop="contentAreaDNDObserver.drop(event);">
ondragdrop="nsDragAndDrop.drop(event, contentAreaDNDObserver);">
<browser id="content" type="content-primary" name="content" src="about:blank" flex="1" <browser id="content" type="content-primary" name="content" src="about:blank" flex="1"
context="viewSourceContextMenu" showcaret="true"/> context="viewSourceContextMenu" showcaret="true"/>

View File

@ -732,30 +732,14 @@ function isToolbarItem(aElt)
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
//// Drag and Drop observers //// Drag and Drop observers
function onToolbarDragStart(aEvent)
{
nsDragAndDrop.startDrag(aEvent, dragStartObserver);
}
function onToolbarDragOver(aEvent)
{
nsDragAndDrop.dragOver(aEvent, toolbarDNDObserver);
}
function onToolbarDrop(aEvent)
{
nsDragAndDrop.drop(aEvent, toolbarDNDObserver);
}
function onToolbarDragLeave(aEvent) function onToolbarDragLeave(aEvent)
{ {
if (gCurrentDragOverItem) if (gCurrentDragOverItem)
setDragActive(gCurrentDragOverItem, false); setDragActive(gCurrentDragOverItem, false);
} }
var dragStartObserver = function onToolbarDragStart(aEvent)
{ {
onDragStart: function (aEvent, aXferData, aDragAction) {
var documentId = gToolboxDocument.documentElement.id; var documentId = gToolboxDocument.documentElement.id;
var item = aEvent.target; var item = aEvent.target;
@ -764,18 +748,17 @@ var dragStartObserver =
item.setAttribute("dragactive", "true"); item.setAttribute("dragactive", "true");
aXferData.data = new TransferDataSet(); var dt = aEvent.dataTransfer;
var data = new TransferData(); dt.setData("text/toolbarwrapper-id/" + documentId, item.firstChild.id);
data.addDataForFlavour("text/toolbarwrapper-id/"+documentId, item.firstChild.id); dt.effectAllowed = "move";
aXferData.data.push(data);
aDragAction.action = Components.interfaces.nsIDragService.DRAGDROP_ACTION_MOVE;
}
} }
var toolbarDNDObserver = function onToolbarDragOver(aEvent)
{
onDragOver: function (aEvent, aFlavour, aDragSession)
{ {
var documentId = gToolboxDocument.documentElement.id;
if (!aEvent.dataTransfer.types.contains("text/toolbarwrapper-id/" + documentId))
return;
var toolbar = aEvent.target; var toolbar = aEvent.target;
var dropTarget = aEvent.target; var dropTarget = aEvent.target;
while (toolbar && toolbar.localName != "toolbar") { while (toolbar && toolbar.localName != "toolbar") {
@ -818,17 +801,18 @@ var toolbarDNDObserver =
setDragActive(gCurrentDragOverItem, true); setDragActive(gCurrentDragOverItem, true);
aDragSession.canDrop = true; aEvent.preventDefault();
}, }
onDrop: function (aEvent, aXferData, aDragSession) function onToolbarDrop(aEvent)
{ {
if (!gCurrentDragOverItem) if (!gCurrentDragOverItem)
return; return;
setDragActive(gCurrentDragOverItem, false); setDragActive(gCurrentDragOverItem, false);
var draggedItemId = aXferData.data; var documentId = gToolboxDocument.documentElement.id;
var draggedItemId = aEvent.dataTransfer.getData("text/toolbarwrapper-id/" + documentId);
if (gCurrentDragOverItem.id == draggedItemId) if (gCurrentDragOverItem.id == draggedItemId)
return; return;
@ -839,7 +823,6 @@ var toolbarDNDObserver =
var draggedPaletteWrapper = document.getElementById("wrapper-"+draggedItemId); var draggedPaletteWrapper = document.getElementById("wrapper-"+draggedItemId);
if (!draggedPaletteWrapper) { if (!draggedPaletteWrapper) {
// The wrapper has been dragged from the toolbar. // The wrapper has been dragged from the toolbar.
// Get the wrapper from the toolbar document and make sure that // Get the wrapper from the toolbar document and make sure that
// it isn't being dropped on itself. // it isn't being dropped on itself.
var wrapper = gToolboxDocument.getElementById("wrapper-"+draggedItemId); var wrapper = gToolboxDocument.getElementById("wrapper-"+draggedItemId);
@ -929,31 +912,19 @@ var toolbarDNDObserver =
gCurrentDragOverItem = null; gCurrentDragOverItem = null;
toolboxChanged(); toolboxChanged();
}, };
_flavourSet: null, function onPaletteDragOver(aEvent)
getSupportedFlavours: function ()
{ {
if (!this._flavourSet) {
this._flavourSet = new FlavourSet();
var documentId = gToolboxDocument.documentElement.id; var documentId = gToolboxDocument.documentElement.id;
this._flavourSet.appendFlavour("text/toolbarwrapper-id/"+documentId); if (aEvent.dataTransfer.types.contains("text/toolbarwrapper-id/" + documentId))
} aEvent.preventDefault();
return this._flavourSet;
}
} }
var paletteDNDObserver = function onPaletteDrop(aEvent)
{ {
onDragOver: function (aEvent, aFlavour, aDragSession) var documentId = gToolboxDocument.documentElement.id;
{ var itemId = aEvent.dataTransfer.getData("text/toolbarwrapper-id/" + documentId);
aDragSession.canDrop = true;
},
onDrop: function(aEvent, aXferData, aDragSession)
{
var itemId = aXferData.data;
var wrapper = gToolboxDocument.getElementById("wrapper-"+itemId); var wrapper = gToolboxDocument.getElementById("wrapper-"+itemId);
if (wrapper) { if (wrapper) {
@ -976,18 +947,4 @@ var paletteDNDObserver =
} }
toolboxChanged(); toolboxChanged();
},
_flavourSet: null,
getSupportedFlavours: function ()
{
if (!this._flavourSet) {
this._flavourSet = new FlavourSet();
var documentId = gToolboxDocument.documentElement.id;
this._flavourSet.appendFlavour("text/toolbarwrapper-id/"+documentId);
} }
return this._flavourSet;
}
}

View File

@ -57,7 +57,6 @@
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://global/content/customizeToolbar.js"/> <script type="application/javascript" src="chrome://global/content/customizeToolbar.js"/>
<script type="application/javascript" src="chrome://global/content/nsDragAndDrop.js"/>
<stringbundle id="stringBundle" src="chrome://global/locale/customizeToolbar.properties"/> <stringbundle id="stringBundle" src="chrome://global/locale/customizeToolbar.properties"/>
@ -73,9 +72,9 @@
</description> </description>
<vbox flex="1" id="palette-box" <vbox flex="1" id="palette-box"
ondraggesture="nsDragAndDrop.startDrag(event, dragStartObserver);" ondragstart="onToolbarDragStart(event)"
ondragover="nsDragAndDrop.dragOver(event, paletteDNDObserver);" ondragover="onPaletteDragOver(event)"
ondragdrop="nsDragAndDrop.drop(event, paletteDNDObserver);"/> ondrop="onPaletteDrop(event)"/>
<box align="center"> <box align="center">
<label value="&show.label;"/> <label value="&show.label;"/>

View File

@ -37,6 +37,17 @@
# #
# ***** END LICENSE BLOCK ***** # ***** END LICENSE BLOCK *****
////////////////////////////////////////////////////////////////////////
//
// USE OF THIS API FOR DRAG AND DROP IS DEPRECATED!
// Do not use this file for new code.
//
// For documentation about what to use instead, see:
// http://developer.mozilla.org/En/DragDrop/Drag_and_Drop
//
////////////////////////////////////////////////////////////////////////
/** /**
* nsTransferable - a wrapper for nsITransferable that simplifies * nsTransferable - a wrapper for nsITransferable that simplifies
* javascript clipboard and drag&drop. for use in * javascript clipboard and drag&drop. for use in
@ -574,6 +585,9 @@ var nsDragAndDrop = {
**/ **/
dragDropSecurityCheck: function (aEvent, aDragSession, aDraggedText) dragDropSecurityCheck: function (aEvent, aDragSession, aDraggedText)
{ {
if (!aDragSession)
aDragSession = this.mDragService.getCurrentSession();
var sourceDoc = aDragSession.sourceDocument; var sourceDoc = aDragSession.sourceDocument;
if (!sourceDoc) if (!sourceDoc)
return; return;

View File

@ -68,24 +68,6 @@
</getter> </getter>
</property> </property>
<method name="getSupportedFlavours">
<body><![CDATA[
var flavourSet = new FlavourSet();
flavourSet.appendFlavour("text/unicode");
return flavourSet;
]]></body>
</method>
<method name="onDrop">
<parameter name="aEvent"/>
<parameter name="aXferData"/>
<parameter name="aDragSession"/>
<body><![CDATA[
this.value = aXferData.data;
this.findbar._find(aXferData.data);
]]></body>
</method>
<method name="_handleEnter"> <method name="_handleEnter">
<parameter name="aEvent"/> <parameter name="aEvent"/>
<body><![CDATA[ <body><![CDATA[
@ -206,7 +188,10 @@
]]></handler> ]]></handler>
<handler event="drop" phase="capturing"><![CDATA[ <handler event="drop" phase="capturing"><![CDATA[
nsDragAndDrop.drop(event, this); var value = event.dataTransfer.getData("text/plain");
this.value = value;
this.findbar._find(value);
event.stopPropagation();
]]></handler> ]]></handler>
</handlers> </handlers>
</binding> </binding>

View File

@ -674,29 +674,26 @@ function buildContextMenu(aEvent)
var gDownloadDNDObserver = var gDownloadDNDObserver =
{ {
onDragOver: function (aEvent, aFlavour, aDragSession) onDragOver: function (aEvent)
{ {
aDragSession.canDrop = true; var types = aEvent.dataTransfer.types;
if (types.contains("text/uri-list") ||
types.contains("text/x-moz-url") ||
types.contains("text/plain"))
aEvent.preventDefault();
}, },
onDrop: function(aEvent, aXferData, aDragSession) onDrop: function(aEvent)
{ {
var split = aXferData.data.split("\n"); var dt = aEvent.dataTransfer;
var url = split[0]; var url = dt.getData("URL");
if (url != aXferData.data) { //do nothing, not a valid URL var name;
var name = split[1]; if (!url) {
saveURL(url, name, null, true, true); url = dt.getData("text/x-moz-url") || dt.getData("text/plain");
[url, name] = url.split("\n");
} }
}, if (url)
_flavourSet: null, saveURL(url, name ? name : url, null, true, true);
getSupportedFlavours: function ()
{
if (!this._flavourSet) {
this._flavourSet = new FlavourSet();
this._flavourSet.appendFlavour("text/x-moz-url");
this._flavourSet.appendFlavour("text/unicode");
}
return this._flavourSet;
} }
} }

View File

@ -70,7 +70,6 @@
<script type="application/javascript" src="chrome://mozapps/content/downloads/downloads.js"/> <script type="application/javascript" src="chrome://mozapps/content/downloads/downloads.js"/>
<script type="application/javascript" src="chrome://mozapps/content/downloads/DownloadProgressListener.js"/> <script type="application/javascript" src="chrome://mozapps/content/downloads/DownloadProgressListener.js"/>
<script type="application/javascript" src="chrome://global/content/contentAreaUtils.js"/> <script type="application/javascript" src="chrome://global/content/contentAreaUtils.js"/>
<script type="application/javascript" src="chrome://global/content/nsDragAndDrop.js"/>
<script type="application/javascript" src="chrome://global/content/globalOverlay.js"/> <script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
<stringbundleset id="downloadSet"> <stringbundleset id="downloadSet">
@ -179,8 +178,8 @@
<richlistbox id="downloadView" seltype="multiple" flex="1" <richlistbox id="downloadView" seltype="multiple" flex="1"
context="downloadContextMenu" context="downloadContextMenu"
ondblclick="onDownloadDblClick(event);" ondblclick="onDownloadDblClick(event);"
ondragover="nsDragAndDrop.dragOver(event, gDownloadDNDObserver);" ondragover="gDownloadDNDObserver.onDragOver(event)"
ondragdrop="nsDragAndDrop.drop(event, gDownloadDNDObserver);"> ondrop="gDownloadDNDObserver.onDrop(event)">
</richlistbox> </richlistbox>
<windowdragbox id="search" align="center"> <windowdragbox id="search" align="center">

View File

@ -1888,7 +1888,6 @@ function buildContextMenu(aEvent)
var gExtensionsDNDObserver = var gExtensionsDNDObserver =
{ {
_ioServ: null, _ioServ: null,
_canDrop: false,
_ensureServices: function () _ensureServices: function ()
{ {
@ -1898,31 +1897,38 @@ var gExtensionsDNDObserver =
}, },
// returns a JS object whose properties are used by xpinstall // returns a JS object whose properties are used by xpinstall
_getDataFromDragSession: function (aDragSession, aPosition) _getDragData: function (dataTransfer, aIndex)
{ {
var fileData = { }; var fileData = { };
// if this fails we do not have valid data to drop // if this fails we do not have valid data to drop
try { try {
var xfer = Components.classes["@mozilla.org/widget/transferable;1"] var url = dataTransfer.mozGetDataAt("text/uri-list", aIndex);
.createInstance(Components.interfaces.nsITransferable); if (!url) {
xfer.addDataFlavor("text/x-moz-url"); url = dataTransfer.mozGetDataAt("text/x-moz-url", aIndex);
xfer.addDataFlavor("application/x-moz-file", "nsIFile"); url = url ? url.split("\n")[0] : null;
aDragSession.getData(xfer, aPosition); if (!url) {
var file = dataTransfer.mozGetDataAt("application/x-moz-file", aIndex);
var flavour = { }, data = { }, length = { }; var ioService = Components.classes["@mozilla.org/network/io-service;1"]
xfer.getAnyTransferData(flavour, data, length); .getService(Components.interfaces.nsIIOService);
var selectedFlavour = this.getSupportedFlavours().flavourTable[flavour.value]; var fileHandler = this._ioServ.getProtocolHandler("file")
var xferData = new FlavourData(data.value, length.value, selectedFlavour); .QueryInterface(Components.interfaces.nsIFileProtocolHandler);
url = fileHandler.getURLSpecFromFile(file);
}
}
var fileURL = transferUtils.retrieveURLFromData(xferData.data, if (!url) {
xferData.flavour.contentType); url = dataTransfer.mozGetDataAt("text/plain", aIndex)
fileData.fileURL = fileURL; if (!url)
return null;
}
var uri = this._ioServ.newURI(fileURL, null, null); fileData.fileURL = url;
var url = uri.QueryInterface(nsIURL);
fileData.fileName = url.fileName;
switch (url.fileExtension) { var uri = this._ioServ.newURI(url, null, null).QueryInterface(nsIURL);
fileData.fileName = uri.fileName;
switch (uri.fileExtension) {
case "xpi": case "xpi":
fileData.type = nsIUpdateItem.TYPE_EXTENSION; fileData.type = nsIUpdateItem.TYPE_EXTENSION;
break; break;
@ -1940,31 +1946,16 @@ var gExtensionsDNDObserver =
return fileData; return fileData;
}, },
canDrop: function (aEvent, aDragSession) { return this._canDrop; }, onDragOver: function (aEvent)
onDragEnter: function (aEvent, aDragSession)
{ {
// XXXrstrong - bug 269568, GTK2 drag and drop is returning invalid data for var types = aEvent.dataTransfer.types;
// dragenter and dragover. To workaround this we always set canDrop to true if (types.contains("text/uri-list") ||
// and just use the xfer data returned in ondrop which is valid. types.contains("text/x-moz-url") ||
#ifndef MOZ_WIDGET_GTK2 types.contains("application/x-moz-file"))
this._ensureServices(); aEvent.preventDefault();
var count = aDragSession.numDropItems;
for (var i = 0; i < count; ++i) {
var fileData = this._getDataFromDragSession(aDragSession, i);
if (!fileData) {
this._canDrop = false;
return;
}
}
#endif
this._canDrop = true;
}, },
onDragOver: function (aEvent, aFlavor, aDragSession) { }, onDrop: function(aEvent)
onDrop: function(aEvent, aXferData, aDragSession)
{ {
if (!isXPInstallEnabled()) if (!isXPInstallEnabled())
return; return;
@ -1976,9 +1967,10 @@ var gExtensionsDNDObserver =
var xpiCount = 0; var xpiCount = 0;
var themeCount = 0; var themeCount = 0;
var count = aDragSession.numDropItems; var dataTransfer = aEvent.dataTransfer;
var count = dataTransfer.mozItemCount;
for (var i = 0; i < count; ++i) { for (var i = 0; i < count; ++i) {
var fileData = this._getDataFromDragSession(aDragSession, i); var fileData = this._getDragData(dataTransfer, i);
if (!fileData) if (!fileData)
continue; continue;
@ -1995,16 +1987,6 @@ var gExtensionsDNDObserver =
if (xpiCount > 0) if (xpiCount > 0)
InstallTrigger.install(xpinstallObj); InstallTrigger.install(xpinstallObj);
},
_flavourSet: null,
getSupportedFlavours: function ()
{
if (!this._flavourSet) {
this._flavourSet = new FlavourSet();
this._flavourSet.appendFlavour("text/x-moz-url");
this._flavourSet.appendFlavour("application/x-moz-file", "nsIFile");
}
return this._flavourSet;
} }
}; };

View File

@ -65,7 +65,6 @@
<script type="application/javascript" src="chrome://global/content/globalOverlay.js"/> <script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="application/javascript" src="chrome://global/content/contentAreaUtils.js"/> <script type="application/javascript" src="chrome://global/content/contentAreaUtils.js"/>
<script type="application/javascript" src="chrome://mozapps/content/extensions/extensions.js"/> <script type="application/javascript" src="chrome://mozapps/content/extensions/extensions.js"/>
<script type="application/javascript" src="chrome://global/content/nsDragAndDrop.js"/>
<stringbundleset id="extensionsSet"> <stringbundleset id="extensionsSet">
<stringbundle id="brandStrings" src="chrome://branding/locale/brand.properties"/> <stringbundle id="brandStrings" src="chrome://branding/locale/brand.properties"/>
@ -200,9 +199,9 @@
<hbox flex="1"> <hbox flex="1">
<richlistbox id="extensionsView" flex="1" <richlistbox id="extensionsView" flex="1"
datasources="rdf:null" context="addonContextMenu" datasources="rdf:null" context="addonContextMenu"
ondragenter="nsDragAndDrop.dragEnter(event, gExtensionsDNDObserver);" ondragenter="gExtensionsDNDObserver.onDragOver(event)"
ondragover="nsDragAndDrop.dragOver(event, gExtensionsDNDObserver);" ondragover="gExtensionsDNDObserver.onDragOver(event)"
ondragdrop="nsDragAndDrop.drop(event, gExtensionsDNDObserver);" ondrop="gExtensionsDNDObserver.onDrop(event)"
ondblclick="onViewDoubleClick(event);"/> ondblclick="onViewDoubleClick(event);"/>
<splitter id="themeSplitter" hidden="true" collapse="none" persist="state"/> <splitter id="themeSplitter" hidden="true" collapse="none" persist="state"/>