diff --git a/mozilla/browser/base/content/customizeToolbarSheet.xul b/mozilla/browser/base/content/customizeToolbarSheet.xul
index 1ca8cf96bc8..12e3c78c14e 100644
--- a/mozilla/browser/base/content/customizeToolbarSheet.xul
+++ b/mozilla/browser/base/content/customizeToolbarSheet.xul
@@ -61,8 +61,6 @@
src="chrome://global/content/customizeToolbar.js"/>
-
diff --git a/mozilla/browser/base/content/web-panels.xul b/mozilla/browser/base/content/web-panels.xul
index 16db8f24b8e..4163a0f1837 100644
--- a/mozilla/browser/base/content/web-panels.xul
+++ b/mozilla/browser/base/content/web-panels.xul
@@ -46,7 +46,6 @@
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="load()" onunload="unload()">
-
diff --git a/mozilla/browser/components/bookmarks/content/bookmarksManager.xul b/mozilla/browser/components/bookmarks/content/bookmarksManager.xul
index a30d2554488..76fc00c803d 100644
--- a/mozilla/browser/components/bookmarks/content/bookmarksManager.xul
+++ b/mozilla/browser/components/bookmarks/content/bookmarksManager.xul
@@ -59,7 +59,6 @@
-
diff --git a/mozilla/browser/components/bookmarks/content/bookmarksPanel.xul b/mozilla/browser/components/bookmarks/content/bookmarksPanel.xul
index dc3b23ab444..74154e81255 100644
--- a/mozilla/browser/components/bookmarks/content/bookmarksPanel.xul
+++ b/mozilla/browser/components/bookmarks/content/bookmarksPanel.xul
@@ -49,7 +49,6 @@
-
diff --git a/mozilla/browser/components/history/content/history-panel.xul b/mozilla/browser/components/history/content/history-panel.xul
index 5e010c480aa..811c00c077f 100644
--- a/mozilla/browser/components/history/content/history-panel.xul
+++ b/mozilla/browser/components/history/content/history-panel.xul
@@ -47,7 +47,6 @@
elementtofocus="historyTree">
-
diff --git a/mozilla/editor/ui/composer/content/TextEditorAppShell.xul b/mozilla/editor/ui/composer/content/TextEditorAppShell.xul
index ca2e0aa421c..19bc722ba66 100644
--- a/mozilla/editor/ui/composer/content/TextEditorAppShell.xul
+++ b/mozilla/editor/ui/composer/content/TextEditorAppShell.xul
@@ -72,7 +72,6 @@
-
-
diff --git a/mozilla/mail/components/addrbook/content/addressbook.xul b/mozilla/mail/components/addrbook/content/addressbook.xul
index 6f07304c7cc..8de63a1b6bb 100644
--- a/mozilla/mail/components/addrbook/content/addressbook.xul
+++ b/mozilla/mail/components/addrbook/content/addressbook.xul
@@ -78,7 +78,6 @@
-
diff --git a/mozilla/mail/components/compose/content/messengercompose.xul b/mozilla/mail/components/compose/content/messengercompose.xul
index ba4b140abc7..7eb5bbcb95c 100644
--- a/mozilla/mail/components/compose/content/messengercompose.xul
+++ b/mozilla/mail/components/compose/content/messengercompose.xul
@@ -81,7 +81,6 @@
-
diff --git a/mozilla/mail/extensions/newsblog/content/feed-subscriptions.xul b/mozilla/mail/extensions/newsblog/content/feed-subscriptions.xul
index 1038752910f..6ec627d328d 100644
--- a/mozilla/mail/extensions/newsblog/content/feed-subscriptions.xul
+++ b/mozilla/mail/extensions/newsblog/content/feed-subscriptions.xul
@@ -64,7 +64,6 @@
-
diff --git a/mozilla/mailnews/addrbook/resources/content/abDirTreeOverlay.xul b/mozilla/mailnews/addrbook/resources/content/abDirTreeOverlay.xul
index 54c2266ad36..0aaf12b5287 100644
--- a/mozilla/mailnews/addrbook/resources/content/abDirTreeOverlay.xul
+++ b/mozilla/mailnews/addrbook/resources/content/abDirTreeOverlay.xul
@@ -44,7 +44,6 @@
-
diff --git a/mozilla/mailnews/addrbook/resources/content/abResultsPaneOverlay.xul b/mozilla/mailnews/addrbook/resources/content/abResultsPaneOverlay.xul
index eee97922010..f4ffbf2e1d8 100644
--- a/mozilla/mailnews/addrbook/resources/content/abResultsPaneOverlay.xul
+++ b/mozilla/mailnews/addrbook/resources/content/abResultsPaneOverlay.xul
@@ -45,7 +45,6 @@
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-
diff --git a/mozilla/mailnews/base/resources/content/mail3PaneWindowVertLayout.xul b/mozilla/mailnews/base/resources/content/mail3PaneWindowVertLayout.xul
index db48316acc6..9fb848e0f50 100644
--- a/mozilla/mailnews/base/resources/content/mail3PaneWindowVertLayout.xul
+++ b/mozilla/mailnews/base/resources/content/mail3PaneWindowVertLayout.xul
@@ -84,7 +84,6 @@
-
diff --git a/mozilla/mailnews/base/resources/content/messageWindow.xul b/mozilla/mailnews/base/resources/content/messageWindow.xul
index eeb9a882bbe..d80a37dd6a0 100644
--- a/mozilla/mailnews/base/resources/content/messageWindow.xul
+++ b/mozilla/mailnews/base/resources/content/messageWindow.xul
@@ -77,7 +77,6 @@
-
diff --git a/mozilla/mailnews/base/resources/content/messenger.xul b/mozilla/mailnews/base/resources/content/messenger.xul
index 9094276b27a..bd49430e813 100644
--- a/mozilla/mailnews/base/resources/content/messenger.xul
+++ b/mozilla/mailnews/base/resources/content/messenger.xul
@@ -84,7 +84,6 @@
-
diff --git a/mozilla/mailnews/base/resources/content/msgHdrViewOverlay.xul b/mozilla/mailnews/base/resources/content/msgHdrViewOverlay.xul
index b0bbacacea9..6cfe3b27a4a 100644
--- a/mozilla/mailnews/base/resources/content/msgHdrViewOverlay.xul
+++ b/mozilla/mailnews/base/resources/content/msgHdrViewOverlay.xul
@@ -54,7 +54,6 @@
-
diff --git a/mozilla/mailnews/compose/resources/content/messengercompose.xul b/mozilla/mailnews/compose/resources/content/messengercompose.xul
index 32175095ae7..374f22a9527 100644
--- a/mozilla/mailnews/compose/resources/content/messengercompose.xul
+++ b/mozilla/mailnews/compose/resources/content/messengercompose.xul
@@ -99,7 +99,6 @@
-
-
diff --git a/mozilla/suite/browser/viewSourceOverlay.xul b/mozilla/suite/browser/viewSourceOverlay.xul
index 2db8979eca9..c463e392b4e 100644
--- a/mozilla/suite/browser/viewSourceOverlay.xul
+++ b/mozilla/suite/browser/viewSourceOverlay.xul
@@ -54,7 +54,6 @@
-
diff --git a/mozilla/suite/common/history/historyTreeOverlay.xul b/mozilla/suite/common/history/historyTreeOverlay.xul
index 3f7f0f2057a..b3de6567422 100644
--- a/mozilla/suite/common/history/historyTreeOverlay.xul
+++ b/mozilla/suite/common/history/historyTreeOverlay.xul
@@ -56,7 +56,6 @@
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
-
diff --git a/mozilla/suite/common/search/search-panel.xul b/mozilla/suite/common/search/search-panel.xul
index 636d7d74f4b..0477658ca53 100644
--- a/mozilla/suite/common/search/search-panel.xul
+++ b/mozilla/suite/common/search/search-panel.xul
@@ -50,7 +50,6 @@
-
diff --git a/mozilla/toolkit/components/help/content/customizeToolbar.xul b/mozilla/toolkit/components/help/content/customizeToolbar.xul
index f60e0cb51c7..0546fe892bc 100644
--- a/mozilla/toolkit/components/help/content/customizeToolbar.xul
+++ b/mozilla/toolkit/components/help/content/customizeToolbar.xul
@@ -56,7 +56,6 @@
-
diff --git a/mozilla/toolkit/content/customizeToolbar.xul b/mozilla/toolkit/content/customizeToolbar.xul
index 306641a4797..6a0f860415e 100644
--- a/mozilla/toolkit/content/customizeToolbar.xul
+++ b/mozilla/toolkit/content/customizeToolbar.xul
@@ -60,7 +60,6 @@
-
diff --git a/mozilla/toolkit/content/jar.mn b/mozilla/toolkit/content/jar.mn
index 3e284d0b977..3f60b6bf6b4 100644
--- a/mozilla/toolkit/content/jar.mn
+++ b/mozilla/toolkit/content/jar.mn
@@ -2,6 +2,9 @@ toolkit.jar:
% content global %content/global/ xpcnativewrappers=yes
% content global-platform %content/global-platform/ platform xpcnativewrappers=yes
% content global-region %content/global-region/ xpcnativewrappers=yes
+# provide the nsTransferable in nsDragAndDrop.js to extensions that have to
+# work with Geckos from before 1.9, when there was a separate file
+% override chrome://global/content/nsTransferable.js chrome://global/content/nsDragAndDrop.js
+ content/global/license.html (license.html)
content/global/XPCNativeWrapper.js (XPCNativeWrapper.js)
* content/global/xul.css (xul.css)
@@ -29,7 +32,6 @@ toolkit.jar:
*+ content/global/inlineSpellCheckUI.js (inlineSpellCheckUI.js)
+ content/global/mozilla.xhtml (mozilla.xhtml)
*+ content/global/nsDragAndDrop.js (nsDragAndDrop.js)
-+ content/global/nsTransferable.js (nsTransferable.js)
*+ content/global/nsWidgetStateManager.js (nsWidgetStateManager.js)
+ content/global/selectDialog.js (selectDialog.js)
+ content/global/selectDialog.xul (selectDialog.xul)
diff --git a/mozilla/toolkit/content/nsDragAndDrop.js b/mozilla/toolkit/content/nsDragAndDrop.js
index 1cf7f7abfbb..03eefd231bb 100644
--- a/mozilla/toolkit/content/nsDragAndDrop.js
+++ b/mozilla/toolkit/content/nsDragAndDrop.js
@@ -73,7 +73,9 @@ var nsTransferable = {
}
else
{
- // non-string data. TBD!
+ // non-string data.
+ supports = currData.supports;
+ length = 0; // kFlavorHasDataProvider
}
trans.setTransferData(currFlavour, supports, length * 2);
}
diff --git a/mozilla/toolkit/content/nsTransferable.js b/mozilla/toolkit/content/nsTransferable.js
deleted file mode 100644
index 2f147c7a7e4..00000000000
--- a/mozilla/toolkit/content/nsTransferable.js
+++ /dev/null
@@ -1,326 +0,0 @@
-/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Ben Goodger (Original Author)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-////////////////////////////////////////////////////////////////////////////
-// XXX - WARNING - DRAG AND DROP API CHANGE ALERT - XXX
-// This file has been extensively modified in a checkin planned for Mozilla
-// 0.8, and the API has been modified. DO NOT MODIFY THIS FILE without
-// approval from ben@netscape.com, otherwise your changes will be lost.
-
-/**
- * nsTransferable - a wrapper for nsITransferable that simplifies
- * javascript clipboard and drag&drop. for use in
- * these situations you should use the nsClipboard
- * and nsDragAndDrop wrappers for more convenience
- **/
-
-var nsTransferable = {
- /**
- * nsITransferable set (TransferData aTransferData) ;
- *
- * Creates a transferable with data for a list of supported types ("flavours")
- *
- * @param TransferData aTransferData
- * a javascript object in the format described above
- **/
- set: function (aTransferDataSet)
- {
- var trans = this.createTransferable();
- for (var i = 0; i < aTransferDataSet.dataList.length; ++i)
- {
- var currData = aTransferDataSet.dataList[i];
- var currFlavour = currData.flavour.contentType;
- trans.addDataFlavor(currFlavour);
- var supports = null; // nsISupports data
- var length = 0;
- if (currData.flavour.dataIIDKey == "nsISupportsString")
- {
- supports = Components.classes["@mozilla.org/supports-string;1"]
- .createInstance(Components.interfaces.nsISupportsString);
-
- supports.data = currData.supports;
- length = supports.data.length;
- }
- else
- {
- // non-string data.
- supports = currData.supports;
- length = 0; // kFlavorHasDataProvider
- }
- trans.setTransferData(currFlavour, supports, length * 2);
- }
- return trans;
- },
-
- /**
- * TransferData/TransferDataSet get (FlavourSet aFlavourSet,
- * Function aRetrievalFunc, Boolean aAnyFlag) ;
- *
- * Retrieves data from the transferable provided in aRetrievalFunc, formatted
- * for more convenient access.
- *
- * @param FlavourSet aFlavourSet
- * a FlavourSet object that contains a list of supported flavours.
- * @param Function aRetrievalFunc
- * a reference to a function that returns a nsISupportsArray of nsITransferables
- * for each item from the specified source (clipboard/drag&drop etc)
- * @param Boolean aAnyFlag
- * a flag specifying whether or not a specific flavour is requested. If false,
- * data of the type of the first flavour in the flavourlist parameter is returned,
- * otherwise the best flavour supported will be returned.
- **/
- get: function (aFlavourSet, aRetrievalFunc, aAnyFlag)
- {
- if (!aRetrievalFunc)
- throw "No data retrieval handler provided!";
-
- var supportsArray = aRetrievalFunc(aFlavourSet);
- var dataArray = [];
- var count = supportsArray.Count();
-
- // Iterate over the number of items returned from aRetrievalFunc. For
- // clipboard operations, this is 1, for drag and drop (where multiple
- // items may have been dragged) this could be >1.
- for (var i = 0; i < count; i++)
- {
- var trans = supportsArray.GetElementAt(i);
- if (!trans) continue;
- trans = trans.QueryInterface(Components.interfaces.nsITransferable);
-
- var data = { };
- var length = { };
-
- var currData = null;
- if (aAnyFlag)
- {
- var flavour = { };
- trans.getAnyTransferData(flavour, data, length);
- if (data && flavour)
- {
- var selectedFlavour = aFlavourSet.flavourTable[flavour.value];
- if (selectedFlavour)
- dataArray[i] = FlavourToXfer(data.value, length.value, selectedFlavour);
- }
- }
- else
- {
- var firstFlavour = aFlavourSet.flavours[0];
- trans.getTransferData(firstFlavour, data, length);
- if (data && firstFlavour)
- dataArray[i] = FlavourToXfer(data.value, length.value, firstFlavour);
- }
- }
- return new TransferDataSet(dataArray);
- },
-
- /**
- * nsITransferable createTransferable (void) ;
- *
- * Creates and returns a transferable object.
- **/
- createTransferable: function ()
- {
- const kXferableContractID = "@mozilla.org/widget/transferable;1";
- const kXferableIID = Components.interfaces.nsITransferable;
- return Components.classes[kXferableContractID].createInstance(kXferableIID);
- }
-};
-
-/**
- * A FlavourSet is a simple type that represents a collection of Flavour objects.
- * FlavourSet is constructed from an array of Flavours, and stores this list as
- * an array and a hashtable. The rationale for the dual storage is as follows:
- *
- * Array: Ordering is important when adding data flavours to a transferable.
- * Flavours added first are deemed to be 'preferred' by the client.
- * Hash: Convenient lookup of flavour data using the content type (MIME type)
- * of data as a key.
- */
-function FlavourSet(aFlavourList)
-{
- this.flavours = aFlavourList || [];
- this.flavourTable = { };
-
- this._XferID = "FlavourSet";
-
- for (var i = 0; i < this.flavours.length; ++i)
- this.flavourTable[this.flavours[i].contentType] = this.flavours[i];
-}
-
-FlavourSet.prototype = {
- appendFlavour: function (aFlavour, aFlavourIIDKey)
- {
- var flavour = new Flavour (aFlavour, aFlavourIIDKey);
- this.flavours.push(flavour);
- this.flavourTable[flavour.contentType] = flavour;
- }
-};
-
-/**
- * A Flavour is a simple type that represents a data type that can be handled.
- * It takes a content type (MIME type) which is used when storing data on the
- * system clipboard/drag and drop, and an IIDKey (string interface name
- * which is used to QI data to an appropriate form. The default interface is
- * assumed to be wide-string.
- */
-function Flavour(aContentType, aDataIIDKey)
-{
- this.contentType = aContentType;
- this.dataIIDKey = aDataIIDKey || "nsISupportsString";
-
- this._XferID = "Flavour";
-}
-
-function TransferDataBase() {}
-TransferDataBase.prototype = {
- push: function (aItems)
- {
- this.dataList.push(aItems);
- },
-
- get first ()
- {
- return "dataList" in this && this.dataList.length ? this.dataList[0] : null;
- }
-};
-
-/**
- * TransferDataSet is a list (array) of TransferData objects, which represents
- * data dragged from one or more elements.
- */
-function TransferDataSet(aTransferDataList)
-{
- this.dataList = aTransferDataList || [];
-
- this._XferID = "TransferDataSet";
-}
-TransferDataSet.prototype = TransferDataBase.prototype;
-
-/**
- * TransferData is a list (array) of FlavourData for all the applicable content
- * types associated with a drag from a single item.
- */
-function TransferData(aFlavourDataList)
-{
- this.dataList = aFlavourDataList || [];
-
- this._XferID = "TransferData";
-}
-TransferData.prototype = {
- __proto__: TransferDataBase.prototype,
-
- addDataForFlavour: function (aFlavourString, aData, aLength, aDataIIDKey)
- {
- this.dataList.push(new FlavourData(aData, aLength,
- new Flavour(aFlavourString, aDataIIDKey)));
- }
-};
-
-/**
- * FlavourData is a type that represents data retrieved from the system
- * clipboard or drag and drop. It is constructed internally by the Transferable
- * using the raw (nsISupports) data from the clipboard, the length of the data,
- * and an object of type Flavour representing the type. Clients implementing
- * IDragDropObserver receive an object of this type in their implementation of
- * onDrop. They access the 'data' property to retrieve data, which is either data
- * QI'ed to a usable form, or unicode string.
- */
-function FlavourData(aData, aLength, aFlavour)
-{
- this.supports = aData;
- this.contentLength = aLength;
- this.flavour = aFlavour || null;
-
- this._XferID = "FlavourData";
-}
-
-FlavourData.prototype = {
- get data ()
- {
- if (this.flavour &&
- this.flavour.dataIIDKey != "nsISupportsString" )
- return this.supports.QueryInterface(Components.interfaces[this.flavour.dataIIDKey]);
- else {
- var unicode = this.supports.QueryInterface(Components.interfaces.nsISupportsString);
- if (unicode)
- return unicode.data.substring(0, this.contentLength/2);
-
- return this.supports;
- }
- return "";
- }
-}
-
-/**
- * Create a TransferData object with a single FlavourData entry. Used when
- * unwrapping data of a specific flavour from the drag service.
- */
-function FlavourToXfer(aData, aLength, aFlavour)
-{
- return new TransferData([new FlavourData(aData, aLength, aFlavour)]);
-}
-
-var transferUtils = {
-
- retrieveURLFromData: function (aData, flavour)
- {
- switch (flavour) {
- case "text/unicode":
- return aData;
- case "text/x-moz-url":
- return aData.toString().split("\n")[0];
- case "application/x-moz-file":
- 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(aData);
- }
- return null;
- }
-
-}
-
-/*
-function DUMP_obj (aObj)
-{
- for (var i in aObj)
- dump("*** aObj[" + i + "] = " + aObj[i] + "\n");
-}
-*/
-
diff --git a/mozilla/toolkit/mozapps/downloads/content/downloads.xul b/mozilla/toolkit/mozapps/downloads/content/downloads.xul
index 9832a09b887..ce96704ee85 100644
--- a/mozilla/toolkit/mozapps/downloads/content/downloads.xul
+++ b/mozilla/toolkit/mozapps/downloads/content/downloads.xul
@@ -67,7 +67,6 @@
-
diff --git a/mozilla/toolkit/mozapps/extensions/content/extensions.xul b/mozilla/toolkit/mozapps/extensions/content/extensions.xul
index 5c175c7726a..2ec1aa002c4 100644
--- a/mozilla/toolkit/mozapps/extensions/content/extensions.xul
+++ b/mozilla/toolkit/mozapps/extensions/content/extensions.xul
@@ -65,7 +65,6 @@
-
diff --git a/mozilla/xpfe/components/bookmarks/resources/bm-panel.xul b/mozilla/xpfe/components/bookmarks/resources/bm-panel.xul
index 301125c40e3..94cb97934b9 100644
--- a/mozilla/xpfe/components/bookmarks/resources/bm-panel.xul
+++ b/mozilla/xpfe/components/bookmarks/resources/bm-panel.xul
@@ -66,7 +66,6 @@
-
diff --git a/mozilla/xpfe/components/bookmarks/resources/bookmarksManager.xul b/mozilla/xpfe/components/bookmarks/resources/bookmarksManager.xul
index 2523f7f19ca..f87495842f1 100644
--- a/mozilla/xpfe/components/bookmarks/resources/bookmarksManager.xul
+++ b/mozilla/xpfe/components/bookmarks/resources/bookmarksManager.xul
@@ -82,7 +82,6 @@
-
diff --git a/mozilla/xpfe/global/jar.mn b/mozilla/xpfe/global/jar.mn
index 50d8402bcfd..5fda4385a43 100644
--- a/mozilla/xpfe/global/jar.mn
+++ b/mozilla/xpfe/global/jar.mn
@@ -22,7 +22,7 @@ toolkit.jar:
content/global/nsTreeSorting.js (resources/content/nsTreeSorting.js)
content/global/nsClipboard.js (resources/content/nsClipboard.js)
content/global/nsDragAndDrop.js (resources/content/nsDragAndDrop.js)
- content/global/nsTransferable.js (resources/content/nsTransferable.js)
+ content/global/nsTransferable.js (resources/content/nsDragAndDrop.js)
content/global/nsUserSettings.js (resources/content/nsUserSettings.js)
content/global/xul.css (resources/content/xul.css)
* content/global/inlineSpellCheckUI.js (/toolkit/content/inlineSpellCheckUI.js)
diff --git a/mozilla/xpfe/global/resources/content/nsDragAndDrop.js b/mozilla/xpfe/global/resources/content/nsDragAndDrop.js
index 09ac60f0692..3b924fbc393 100644
--- a/mozilla/xpfe/global/resources/content/nsDragAndDrop.js
+++ b/mozilla/xpfe/global/resources/content/nsDragAndDrop.js
@@ -37,19 +37,279 @@
*
* ***** END LICENSE BLOCK ***** */
-////////////////////////////////////////////////////////////////////////////
-// XXX - WARNING - DRAG AND DROP API CHANGE ALERT - XXX
-// This file has been extensively modified in a checkin planned for Mozilla
-// 0.8, and the API has been modified. DO NOT MODIFY THIS FILE without
-// approval from ben@netscape.com, otherwise your changes will be lost.
+/**
+ * nsTransferable - a wrapper for nsITransferable that simplifies
+ * javascript clipboard and drag&drop. for use in
+ * these situations you should use the nsClipboard
+ * and nsDragAndDrop wrappers for more convenience
+ **/
+
+var nsTransferable = {
+ /**
+ * nsITransferable set (TransferData aTransferData) ;
+ *
+ * Creates a transferable with data for a list of supported types ("flavours")
+ *
+ * @param TransferData aTransferData
+ * a javascript object in the format described above
+ **/
+ set: function (aTransferDataSet)
+ {
+ var trans = this.createTransferable();
+ for (var i = 0; i < aTransferDataSet.dataList.length; ++i)
+ {
+ var currData = aTransferDataSet.dataList[i];
+ var currFlavour = currData.flavour.contentType;
+ trans.addDataFlavor(currFlavour);
+ var supports = null; // nsISupports data
+ var length = 0;
+ if (currData.flavour.dataIIDKey == "nsISupportsString")
+ {
+ supports = Components.classes["@mozilla.org/supports-string;1"]
+ .createInstance(Components.interfaces.nsISupportsString);
-/**
- * XXX - until load is supported in chrome, you also need to include
- * these files:
- * chrome://global/content/nsTransferable.js
- **/
+ supports.data = currData.supports;
+ length = supports.data.length;
+ }
+ else
+ {
+ // non-string data.
+ supports = currData.supports;
+ length = 0; // kFlavorHasDataProvider
+ }
+ trans.setTransferData(currFlavour, supports, length * 2);
+ }
+ return trans;
+ },
+
+ /**
+ * TransferData/TransferDataSet get (FlavourSet aFlavourSet,
+ * Function aRetrievalFunc, Boolean aAnyFlag) ;
+ *
+ * Retrieves data from the transferable provided in aRetrievalFunc, formatted
+ * for more convenient access.
+ *
+ * @param FlavourSet aFlavourSet
+ * a FlavourSet object that contains a list of supported flavours.
+ * @param Function aRetrievalFunc
+ * a reference to a function that returns a nsISupportsArray of nsITransferables
+ * for each item from the specified source (clipboard/drag&drop etc)
+ * @param Boolean aAnyFlag
+ * a flag specifying whether or not a specific flavour is requested. If false,
+ * data of the type of the first flavour in the flavourlist parameter is returned,
+ * otherwise the best flavour supported will be returned.
+ **/
+ get: function (aFlavourSet, aRetrievalFunc, aAnyFlag)
+ {
+ if (!aRetrievalFunc)
+ throw "No data retrieval handler provided!";
+
+ var supportsArray = aRetrievalFunc(aFlavourSet);
+ var dataArray = [];
+ var count = supportsArray.Count();
+
+ // Iterate over the number of items returned from aRetrievalFunc. For
+ // clipboard operations, this is 1, for drag and drop (where multiple
+ // items may have been dragged) this could be >1.
+ for (var i = 0; i < count; i++)
+ {
+ var trans = supportsArray.GetElementAt(i);
+ if (!trans) continue;
+ trans = trans.QueryInterface(Components.interfaces.nsITransferable);
+
+ var data = { };
+ var length = { };
+
+ var currData = null;
+ if (aAnyFlag)
+ {
+ var flavour = { };
+ trans.getAnyTransferData(flavour, data, length);
+ if (data && flavour)
+ {
+ var selectedFlavour = aFlavourSet.flavourTable[flavour.value];
+ if (selectedFlavour)
+ dataArray[i] = FlavourToXfer(data.value, length.value, selectedFlavour);
+ }
+ }
+ else
+ {
+ var firstFlavour = aFlavourSet.flavours[0];
+ trans.getTransferData(firstFlavour, data, length);
+ if (data && firstFlavour)
+ dataArray[i] = FlavourToXfer(data.value, length.value, firstFlavour);
+ }
+ }
+ return new TransferDataSet(dataArray);
+ },
+ /**
+ * nsITransferable createTransferable (void) ;
+ *
+ * Creates and returns a transferable object.
+ **/
+ createTransferable: function ()
+ {
+ const kXferableContractID = "@mozilla.org/widget/transferable;1";
+ const kXferableIID = Components.interfaces.nsITransferable;
+ return Components.classes[kXferableContractID].createInstance(kXferableIID);
+ }
+};
+/**
+ * A FlavourSet is a simple type that represents a collection of Flavour objects.
+ * FlavourSet is constructed from an array of Flavours, and stores this list as
+ * an array and a hashtable. The rationale for the dual storage is as follows:
+ *
+ * Array: Ordering is important when adding data flavours to a transferable.
+ * Flavours added first are deemed to be 'preferred' by the client.
+ * Hash: Convenient lookup of flavour data using the content type (MIME type)
+ * of data as a key.
+ */
+function FlavourSet(aFlavourList)
+{
+ this.flavours = aFlavourList || [];
+ this.flavourTable = { };
+
+ this._XferID = "FlavourSet";
+
+ for (var i = 0; i < this.flavours.length; ++i)
+ this.flavourTable[this.flavours[i].contentType] = this.flavours[i];
+}
+
+FlavourSet.prototype = {
+ appendFlavour: function (aFlavour, aFlavourIIDKey)
+ {
+ var flavour = new Flavour (aFlavour, aFlavourIIDKey);
+ this.flavours.push(flavour);
+ this.flavourTable[flavour.contentType] = flavour;
+ }
+};
+
+/**
+ * A Flavour is a simple type that represents a data type that can be handled.
+ * It takes a content type (MIME type) which is used when storing data on the
+ * system clipboard/drag and drop, and an IIDKey (string interface name
+ * which is used to QI data to an appropriate form. The default interface is
+ * assumed to be wide-string.
+ */
+function Flavour(aContentType, aDataIIDKey)
+{
+ this.contentType = aContentType;
+ this.dataIIDKey = aDataIIDKey || "nsISupportsString";
+
+ this._XferID = "Flavour";
+}
+
+function TransferDataBase() {}
+TransferDataBase.prototype = {
+ push: function (aItems)
+ {
+ this.dataList.push(aItems);
+ },
+
+ get first ()
+ {
+ return "dataList" in this && this.dataList.length ? this.dataList[0] : null;
+ }
+};
+
+/**
+ * TransferDataSet is a list (array) of TransferData objects, which represents
+ * data dragged from one or more elements.
+ */
+function TransferDataSet(aTransferDataList)
+{
+ this.dataList = aTransferDataList || [];
+
+ this._XferID = "TransferDataSet";
+}
+TransferDataSet.prototype = TransferDataBase.prototype;
+
+/**
+ * TransferData is a list (array) of FlavourData for all the applicable content
+ * types associated with a drag from a single item.
+ */
+function TransferData(aFlavourDataList)
+{
+ this.dataList = aFlavourDataList || [];
+
+ this._XferID = "TransferData";
+}
+TransferData.prototype = {
+ __proto__: TransferDataBase.prototype,
+
+ addDataForFlavour: function (aFlavourString, aData, aLength, aDataIIDKey)
+ {
+ this.dataList.push(new FlavourData(aData, aLength,
+ new Flavour(aFlavourString, aDataIIDKey)));
+ }
+};
+
+/**
+ * FlavourData is a type that represents data retrieved from the system
+ * clipboard or drag and drop. It is constructed internally by the Transferable
+ * using the raw (nsISupports) data from the clipboard, the length of the data,
+ * and an object of type Flavour representing the type. Clients implementing
+ * IDragDropObserver receive an object of this type in their implementation of
+ * onDrop. They access the 'data' property to retrieve data, which is either data
+ * QI'ed to a usable form, or unicode string.
+ */
+function FlavourData(aData, aLength, aFlavour)
+{
+ this.supports = aData;
+ this.contentLength = aLength;
+ this.flavour = aFlavour || null;
+
+ this._XferID = "FlavourData";
+}
+
+FlavourData.prototype = {
+ get data ()
+ {
+ if (this.flavour &&
+ this.flavour.dataIIDKey != "nsISupportsString" )
+ return this.supports.QueryInterface(Components.interfaces[this.flavour.dataIIDKey]);
+ else {
+ var unicode = this.supports.QueryInterface(Components.interfaces.nsISupportsString);
+ if (unicode)
+ return unicode.data.substring(0, this.contentLength/2);
+
+ return this.supports;
+ }
+ return "";
+ }
+}
+
+/**
+ * Create a TransferData object with a single FlavourData entry. Used when
+ * unwrapping data of a specific flavour from the drag service.
+ */
+function FlavourToXfer(aData, aLength, aFlavour)
+{
+ return new TransferData([new FlavourData(aData, aLength, aFlavour)]);
+}
+
+var transferUtils = {
+
+ retrieveURLFromData: function (aData, flavour)
+ {
+ switch (flavour) {
+ case "text/unicode":
+ return aData;
+ case "text/x-moz-url":
+ return aData.toString().split("\n")[0];
+ case "application/x-moz-file":
+ 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(aData);
+ }
+ return null;
+ }
+
+}
/**
* nsDragAndDrop - a convenience wrapper for nsTransferable, nsITransferable
diff --git a/mozilla/xpfe/global/resources/content/nsTransferable.js b/mozilla/xpfe/global/resources/content/nsTransferable.js
deleted file mode 100644
index 41ae1294f75..00000000000
--- a/mozilla/xpfe/global/resources/content/nsTransferable.js
+++ /dev/null
@@ -1,326 +0,0 @@
-/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Ben Goodger (Original Author)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-////////////////////////////////////////////////////////////////////////////
-// XXX - WARNING - DRAG AND DROP API CHANGE ALERT - XXX
-// This file has been extensively modified in a checkin planned for Mozilla
-// 0.8, and the API has been modified. DO NOT MODIFY THIS FILE without
-// approval from ben@netscape.com, otherwise your changes will be lost.
-
-/**
- * nsTransferable - a wrapper for nsITransferable that simplifies
- * javascript clipboard and drag&drop. for use in
- * these situations you should use the nsClipboard
- * and nsDragAndDrop wrappers for more convenience
- **/
-
-var nsTransferable = {
- /**
- * nsITransferable set (TransferData aTransferData) ;
- *
- * Creates a transferable with data for a list of supported types ("flavours")
- *
- * @param TransferData aTransferData
- * a javascript object in the format described above
- **/
- set: function (aTransferDataSet)
- {
- var trans = this.createTransferable();
- for (var i = 0; i < aTransferDataSet.dataList.length; ++i)
- {
- var currData = aTransferDataSet.dataList[i];
- var currFlavour = currData.flavour.contentType;
- trans.addDataFlavor(currFlavour);
- var supports = null; // nsISupports data
- var length = 0;
- if (currData.flavour.dataIIDKey == "nsISupportsString")
- {
- supports = Components.classes["@mozilla.org/supports-string;1"]
- .createInstance(Components.interfaces.nsISupportsString);
-
- supports.data = currData.supports;
- length = supports.data.length;
- }
- else
- {
- // non-string data.
- supports = currData.supports;
- length = 0; // kFlavorHasDataProvider
- }
- trans.setTransferData(currFlavour, supports, length * 2);
- }
- return trans;
- },
-
- /**
- * TransferData/TransferDataSet get (FlavourSet aFlavourSet,
- * Function aRetrievalFunc, Boolean aAnyFlag) ;
- *
- * Retrieves data from the transferable provided in aRetrievalFunc, formatted
- * for more convenient access.
- *
- * @param FlavourSet aFlavourSet
- * a FlavourSet object that contains a list of supported flavours.
- * @param Function aRetrievalFunc
- * a reference to a function that returns a nsISupportsArray of nsITransferables
- * for each item from the specified source (clipboard/drag&drop etc)
- * @param Boolean aAnyFlag
- * a flag specifying whether or not a specific flavour is requested. If false,
- * data of the type of the first flavour in the flavourlist parameter is returned,
- * otherwise the best flavour supported will be returned.
- **/
- get: function (aFlavourSet, aRetrievalFunc, aAnyFlag)
- {
- if (!aRetrievalFunc)
- throw "No data retrieval handler provided!";
-
- var supportsArray = aRetrievalFunc(aFlavourSet);
- var dataArray = [];
- var count = supportsArray.Count();
-
- // Iterate over the number of items returned from aRetrievalFunc. For
- // clipboard operations, this is 1, for drag and drop (where multiple
- // items may have been dragged) this could be >1.
- for (var i = 0; i < count; i++)
- {
- var trans = supportsArray.GetElementAt(i);
- if (!trans) continue;
- trans = trans.QueryInterface(Components.interfaces.nsITransferable);
-
- var data = { };
- var length = { };
-
- var currData = null;
- if (aAnyFlag)
- {
- var flavour = { };
- trans.getAnyTransferData(flavour, data, length);
- if (data && flavour)
- {
- var selectedFlavour = aFlavourSet.flavourTable[flavour.value];
- if (selectedFlavour)
- dataArray[i] = FlavourToXfer(data.value, length.value, selectedFlavour);
- }
- }
- else
- {
- var firstFlavour = aFlavourSet.flavours[0];
- trans.getTransferData(firstFlavour, data, length);
- if (data && firstFlavour)
- dataArray[i] = FlavourToXfer(data.value, length.value, firstFlavour);
- }
- }
- return new TransferDataSet(dataArray);
- },
-
- /**
- * nsITransferable createTransferable (void) ;
- *
- * Creates and returns a transferable object.
- **/
- createTransferable: function ()
- {
- const kXferableContractID = "@mozilla.org/widget/transferable;1";
- const kXferableIID = Components.interfaces.nsITransferable;
- return Components.classes[kXferableContractID].createInstance(kXferableIID);
- }
-};
-
-/**
- * A FlavourSet is a simple type that represents a collection of Flavour objects.
- * FlavourSet is constructed from an array of Flavours, and stores this list as
- * an array and a hashtable. The rationale for the dual storage is as follows:
- *
- * Array: Ordering is important when adding data flavours to a transferable.
- * Flavours added first are deemed to be 'preferred' by the client.
- * Hash: Convenient lookup of flavour data using the content type (MIME type)
- * of data as a key.
- */
-function FlavourSet(aFlavourList)
-{
- this.flavours = aFlavourList || [];
- this.flavourTable = { };
-
- this._XferID = "FlavourSet";
-
- for (var i = 0; i < this.flavours.length; ++i)
- this.flavourTable[this.flavours[i].contentType] = this.flavours[i];
-}
-
-FlavourSet.prototype = {
- appendFlavour: function (aFlavour, aFlavourIIDKey)
- {
- var flavour = new Flavour (aFlavour, aFlavourIIDKey);
- this.flavours.push(flavour);
- this.flavourTable[flavour.contentType] = flavour;
- }
-};
-
-/**
- * A Flavour is a simple type that represents a data type that can be handled.
- * It takes a content type (MIME type) which is used when storing data on the
- * system clipboard/drag and drop, and an IIDKey (string interface name
- * which is used to QI data to an appropriate form. The default interface is
- * assumed to be wide-string.
- */
-function Flavour(aContentType, aDataIIDKey)
-{
- this.contentType = aContentType;
- this.dataIIDKey = aDataIIDKey || "nsISupportsString";
-
- this._XferID = "Flavour";
-}
-
-function TransferDataBase() {}
-TransferDataBase.prototype = {
- push: function (aItems)
- {
- this.dataList.push(aItems);
- },
-
- get first ()
- {
- return "dataList" in this && this.dataList.length ? this.dataList[0] : null;
- }
-};
-
-/**
- * TransferDataSet is a list (array) of TransferData objects, which represents
- * data dragged from one or more elements.
- */
-function TransferDataSet(aTransferDataList)
-{
- this.dataList = aTransferDataList || [];
-
- this._XferID = "TransferDataSet";
-}
-TransferDataSet.prototype = TransferDataBase.prototype;
-
-/**
- * TransferData is a list (array) of FlavourData for all the applicable content
- * types associated with a drag from a single item.
- */
-function TransferData(aFlavourDataList)
-{
- this.dataList = aFlavourDataList || [];
-
- this._XferID = "TransferData";
-}
-TransferData.prototype = {
- __proto__: TransferDataBase.prototype,
-
- addDataForFlavour: function (aFlavourString, aData, aLength, aDataIIDKey)
- {
- this.dataList.push(new FlavourData(aData, aLength,
- new Flavour(aFlavourString, aDataIIDKey)));
- }
-};
-
-/**
- * FlavourData is a type that represents data retrieved from the system
- * clipboard or drag and drop. It is constructed internally by the Transferable
- * using the raw (nsISupports) data from the clipboard, the length of the data,
- * and an object of type Flavour representing the type. Clients implementing
- * IDragDropObserver receive an object of this type in their implementation of
- * onDrop. They access the 'data' property to retrieve data, which is either data
- * QI'ed to a usable form, or unicode string.
- */
-function FlavourData(aData, aLength, aFlavour)
-{
- this.supports = aData;
- this.contentLength = aLength;
- this.flavour = aFlavour || null;
-
- this._XferID = "FlavourData";
-}
-
-FlavourData.prototype = {
- get data ()
- {
- if (this.flavour &&
- this.flavour.dataIIDKey != "nsISupportsString" )
- return this.supports.QueryInterface(Components.interfaces[this.flavour.dataIIDKey]);
- else {
- var unicode = this.supports.QueryInterface(Components.interfaces.nsISupportsString);
- if (unicode)
- return unicode.data.substring(0, this.contentLength/2);
-
- return this.supports;
- }
- return "";
- }
-}
-
-/**
- * Create a TransferData object with a single FlavourData entry. Used when
- * unwrapping data of a specific flavour from the drag service.
- */
-function FlavourToXfer(aData, aLength, aFlavour)
-{
- return new TransferData([new FlavourData(aData, aLength, aFlavour)]);
-}
-
-var transferUtils = {
-
- retrieveURLFromData: function (aData, flavour)
- {
- switch (flavour) {
- case "text/unicode":
- return aData;
- case "text/x-moz-url":
- return aData.toString().split("\n")[0];
- case "application/x-moz-file":
- 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(aData);
- }
- return null;
- }
-
-}
-
-/*
-function DUMP_obj (aObj)
-{
- for (var i in aObj)
- dump("*** aObj[" + i + "] = " + aObj[i] + "\n");
-}
-*/
-