Bug 923054 part 1 - Convert DataTransfer to WebIDL bindings, move files and rename class. r=smaug
authorPeter Van der Beken <peterv@propagandism.org>
Mon, 12 Aug 2013 16:45:33 +0200
changeset 171236 6dacf81bb5255357276102eb305f57b2f3bfdd02
parent 171235 26bfe4ef1bc2208a4f8d0cc102b44dc4901b50f0
child 171237 a40bcf02bb6025f64ee57cf702c7926edc2f3782
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewerssmaug
bugs923054
milestone30.0a1
Bug 923054 part 1 - Convert DataTransfer to WebIDL bindings, move files and rename class. r=smaug
content/base/src/nsContentAreaDragDrop.cpp
content/base/src/nsContentAreaDragDrop.h
content/base/src/nsContentUtils.cpp
content/base/src/nsCopySupport.cpp
dom/events/ClipboardEvent.cpp
dom/events/DataTransfer.cpp
dom/events/DataTransfer.h
dom/events/moz.build
dom/events/nsDOMDataTransfer.cpp
dom/events/nsDOMDataTransfer.h
dom/events/nsDOMDragEvent.cpp
dom/events/nsEventStateManager.cpp
dom/events/nsEventStateManager.h
--- a/content/base/src/nsContentAreaDragDrop.cpp
+++ b/content/base/src/nsContentAreaDragDrop.cpp
@@ -44,43 +44,43 @@
 #include "nsIPrincipal.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIWebBrowserPersist.h"
 #include "nsEscape.h"
 #include "nsContentUtils.h"
 #include "nsIMIMEService.h"
 #include "imgIContainer.h"
 #include "imgIRequest.h"
-#include "nsDOMDataTransfer.h"
+#include "mozilla/dom/DataTransfer.h"
 #include "nsIMIMEInfo.h"
 #include "nsRange.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/HTMLAreaElement.h"
 
-using mozilla::dom::HTMLAreaElement;
+using namespace mozilla::dom;
 
 class MOZ_STACK_CLASS DragDataProducer
 {
 public:
   DragDataProducer(nsPIDOMWindow* aWindow,
                    nsIContent* aTarget,
                    nsIContent* aSelectionTargetNode,
                    bool aIsAltKeyPressed);
-  nsresult Produce(nsDOMDataTransfer* aDataTransfer,
+  nsresult Produce(DataTransfer* aDataTransfer,
                    bool* aCanDrag,
                    nsISelection** aSelection,
                    nsIContent** aDragNode);
 
 private:
-  void AddString(nsDOMDataTransfer* aDataTransfer,
+  void AddString(DataTransfer* aDataTransfer,
                  const nsAString& aFlavor,
                  const nsAString& aData,
                  nsIPrincipal* aPrincipal);
   nsresult AddStringsToDataTransfer(nsIContent* aDragNode,
-                                    nsDOMDataTransfer* aDataTransfer);
+                                    DataTransfer* aDataTransfer);
   static nsresult GetDraggableSelectionData(nsISelection* inSelection,
                                             nsIContent* inRealTargetNode,
                                             nsIContent **outImageOrLinkNode,
                                             bool* outDragSelectedText);
   static already_AddRefed<nsIContent> FindParentLinkNode(nsIContent* inNode);
   static void GetAnchorURL(nsIContent* inNode, nsAString& outURL);
   static void GetNodeString(nsIContent* inNode, nsAString & outNodeString);
   static void CreateLinkText(const nsAString& inURL, const nsAString & inText,
@@ -107,17 +107,17 @@ private:
 };
 
 
 nsresult
 nsContentAreaDragDrop::GetDragData(nsPIDOMWindow* aWindow,
                                    nsIContent* aTarget,
                                    nsIContent* aSelectionTargetNode,
                                    bool aIsAltKeyPressed,
-                                   nsDOMDataTransfer* aDataTransfer,
+                                   DataTransfer* aDataTransfer,
                                    bool* aCanDrag,
                                    nsISelection** aSelection,
                                    nsIContent** aDragNode)
 {
   NS_ENSURE_TRUE(aSelectionTargetNode, NS_ERROR_INVALID_ARG);
 
   *aCanDrag = true;
 
@@ -349,17 +349,17 @@ DragDataProducer::GetNodeString(nsIConte
   nsRefPtr<nsRange> range = doc->CreateRange(rv);
   if (range) {
     range->SelectNode(*node, rv);
     range->ToString(outNodeString);
   }
 }
 
 nsresult
-DragDataProducer::Produce(nsDOMDataTransfer* aDataTransfer,
+DragDataProducer::Produce(DataTransfer* aDataTransfer,
                           bool* aCanDrag,
                           nsISelection** aSelection,
                           nsIContent** aDragNode)
 {
   NS_PRECONDITION(aCanDrag && aSelection && aDataTransfer && aDragNode,
                   "null pointer passed to Produce");
   NS_ASSERTION(mWindow, "window not set");
   NS_ASSERTION(mSelectionTargetNode, "selection target node should have been set");
@@ -698,31 +698,31 @@ DragDataProducer::Produce(nsDOMDataTrans
          dragNode ? dragNode : mSelectionTargetNode.get(), aDataTransfer);
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_IF_ADDREF(*aDragNode = dragNode);
   return NS_OK;
 }
 
 void
-DragDataProducer::AddString(nsDOMDataTransfer* aDataTransfer,
+DragDataProducer::AddString(DataTransfer* aDataTransfer,
                             const nsAString& aFlavor,
                             const nsAString& aData,
                             nsIPrincipal* aPrincipal)
 {
   nsCOMPtr<nsIWritableVariant> variant = do_CreateInstance(NS_VARIANT_CONTRACTID);
   if (variant) {
     variant->SetAsAString(aData);
     aDataTransfer->SetDataWithPrincipal(aFlavor, variant, 0, aPrincipal);
   }
 }
 
 nsresult
 DragDataProducer::AddStringsToDataTransfer(nsIContent* aDragNode,
-                                           nsDOMDataTransfer* aDataTransfer)
+                                           DataTransfer* aDataTransfer)
 {
   NS_ASSERTION(aDragNode, "adding strings for null node");
 
   // set all of the data to have the principal of the node where the data came from
   nsIPrincipal* principal = aDragNode->NodePrincipal();
 
   // add a special flavor if we're an anchor to indicate that we have
   // a URL in the drag data
--- a/content/base/src/nsContentAreaDragDrop.h
+++ b/content/base/src/nsContentAreaDragDrop.h
@@ -16,17 +16,22 @@ class nsIDOMNode;
 class nsPIDOMWindow;
 class nsIDOMDragEvent;
 class nsISelection;
 class nsITransferable;
 class nsIContent;
 class nsIURI;
 class nsIFile;
 class nsISimpleEnumerator;
-class nsDOMDataTransfer;
+
+namespace mozilla {
+namespace dom {
+class DataTransfer;
+}
+}
 
 //
 // class nsContentAreaDragDrop, used to generate the dragdata
 //
 class nsContentAreaDragDrop
 {
 public:
 
@@ -47,17 +52,17 @@ public:
    *                    selection is being dragged.
    * aDragNode - [out] the link, image or area being dragged, or null if the
    *             drag occurred on another element.
    */
   static nsresult GetDragData(nsPIDOMWindow* aWindow,
                               nsIContent* aTarget,
                               nsIContent* aSelectionTargetNode,
                               bool aIsAltKeyPressed,
-                              nsDOMDataTransfer* aDataTransfer,
+                              mozilla::dom::DataTransfer* aDataTransfer,
                               bool* aCanDrag,
                               nsISelection** aSelection,
                               nsIContent** aDragNode);
 };
 
 // this is used to save images to disk lazily when the image data is asked for
 // during the drop instead of when it is added to the drag data transfer. This
 // ensures that the image data is only created when an image drop is allowed.
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -62,17 +62,17 @@
 #include "nsCPrefetchService.h"
 #include "nsCRT.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsCycleCollector.h"
 #include "nsDataHashtable.h"
 #include "nsDocShellCID.h"
 #include "nsDocument.h"
 #include "nsDOMCID.h"
-#include "nsDOMDataTransfer.h"
+#include "mozilla/dom/DataTransfer.h"
 #include "nsDOMJSUtils.h"
 #include "nsDOMMutationObserver.h"
 #include "nsDOMTouchEvent.h"
 #include "nsError.h"
 #include "nsEventDispatcher.h"
 #include "nsEventListenerManager.h"
 #include "nsEventStateManager.h"
 #include "nsFocusManager.h"
@@ -4976,17 +4976,17 @@ nsContentUtils::SetDataTransferInEvent(W
 
   nsCOMPtr<nsIDOMDataTransfer> initialDataTransfer;
   dragSession->GetDataTransfer(getter_AddRefs(initialDataTransfer));
   if (!initialDataTransfer) {
     // A dataTransfer won't exist when a drag was started by some other
     // means, for instance calling the drag service directly, or a drag
     // from another application. In either case, a new dataTransfer should
     // be created that reflects the data.
-    initialDataTransfer = new nsDOMDataTransfer(aDragEvent->message, true, -1);
+    initialDataTransfer = new DataTransfer(aDragEvent->message, true, -1);
 
     NS_ENSURE_TRUE(initialDataTransfer, NS_ERROR_OUT_OF_MEMORY);
 
     // now set it in the drag session so we don't need to create it again
     dragSession->SetDataTransfer(initialDataTransfer);
   }
 
   bool isCrossDomainSubFrameDrop = false;
--- a/content/base/src/nsCopySupport.cpp
+++ b/content/base/src/nsCopySupport.cpp
@@ -15,17 +15,17 @@
 #include "nsXPCOM.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIDOMRange.h"
 #include "nsRange.h"
 #include "imgIContainer.h"
 #include "nsIPresShell.h"
 #include "nsFocusManager.h"
 #include "nsEventDispatcher.h"
-#include "nsDOMDataTransfer.h"
+#include "mozilla/dom/DataTransfer.h"
 
 #include "nsIDocShell.h"
 #include "nsIContentViewerEdit.h"
 #include "nsIClipboardDragDropHooks.h"
 #include "nsIClipboardDragDropHookList.h"
 #include "nsIClipboardHelper.h"
 #include "nsISelectionController.h"
 
@@ -48,16 +48,17 @@
 
 #include "mozilla/ContentEvents.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/Selection.h"
 
 #include "mozilla/Preferences.h"
 
 using namespace mozilla;
+using namespace mozilla::dom;
 
 nsresult NS_NewDomSelection(nsISelection **aDomSelection);
 
 static NS_DEFINE_CID(kCClipboardCID,           NS_CLIPBOARD_CID);
 static NS_DEFINE_CID(kCTransferableCID,        NS_TRANSFERABLE_CID);
 static NS_DEFINE_CID(kHTMLConverterCID,        NS_HTMLFORMATCONVERTER_CID);
 
 // copy string data onto the transferable
@@ -638,19 +639,19 @@ nsCopySupport::FireClipboardEvent(int32_
     return false;
 
   nsCOMPtr<nsIDocShell> docShell = do_GetInterface(piWindow);
   const bool chromeShell =
     docShell && docShell->ItemType() == nsIDocShellTreeItem::typeChrome;
 
   // next, fire the cut, copy or paste event
   bool doDefault = true;
-  nsRefPtr<nsDOMDataTransfer> clipboardData;
+  nsRefPtr<DataTransfer> clipboardData;
   if (chromeShell || Preferences::GetBool("dom.event.clipboardevents.enabled", true)) {
-    clipboardData = new nsDOMDataTransfer(aType, aType == NS_PASTE, aClipboardType);
+    clipboardData = new DataTransfer(aType, aType == NS_PASTE, aClipboardType);
 
     nsEventStatus status = nsEventStatus_eIgnore;
     InternalClipboardEvent evt(true, aType);
     evt.clipboardData = clipboardData;
     nsEventDispatcher::Dispatch(content, presShell->GetPresContext(), &evt, nullptr,
                                 &status);
     // If the event was cancelled, don't do the clipboard operation
     doDefault = (status != nsEventStatus_eConsumeNoDefault);
--- a/dom/events/ClipboardEvent.cpp
+++ b/dom/events/ClipboardEvent.cpp
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/ClipboardEvent.h"
 #include "mozilla/ContentEvents.h"
-#include "nsDOMDataTransfer.h"
+#include "mozilla/dom/DataTransfer.h"
 #include "nsIClipboard.h"
 
 namespace mozilla {
 namespace dom {
 
 ClipboardEvent::ClipboardEvent(EventTarget* aOwner,
                                nsPresContext* aPresContext,
                                InternalClipboardEvent* aEvent)
@@ -51,24 +51,24 @@ ClipboardEvent::Constructor(const Global
                             const nsAString& aType,
                             const ClipboardEventInit& aParam,
                             ErrorResult& aRv)
 {
   nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
   nsRefPtr<ClipboardEvent> e = new ClipboardEvent(t, nullptr, nullptr);
   bool trusted = e->Init(t);
 
-  nsRefPtr<nsDOMDataTransfer> clipboardData;
+  nsRefPtr<DataTransfer> clipboardData;
   if (e->mEventIsInternal) {
     InternalClipboardEvent* event = e->mEvent->AsClipboardEvent();
     if (event) {
       // Always create a clipboardData for the copy event. If this is changed to
       // support other types of events, make sure that read/write privileges are
-      // checked properly within nsDOMDataTransfer.
-      clipboardData = new nsDOMDataTransfer(NS_COPY, false, -1);
+      // checked properly within DataTransfer.
+      clipboardData = new DataTransfer(NS_COPY, false, -1);
       clipboardData->SetData(aParam.mDataType, aParam.mData);
     }
   }
 
   aRv = e->InitClipboardEvent(aType, aParam.mBubbles, aParam.mCancelable,
                               clipboardData);
   e->SetTrusted(trusted);
   return e.forget();
@@ -83,20 +83,20 @@ ClipboardEvent::GetClipboardData(nsIDOMD
 
 nsIDOMDataTransfer*
 ClipboardEvent::GetClipboardData()
 {
   InternalClipboardEvent* event = mEvent->AsClipboardEvent();
 
   if (!event->clipboardData) {
     if (mEventIsInternal) {
-      event->clipboardData = new nsDOMDataTransfer(NS_COPY, false, -1);
+      event->clipboardData = new DataTransfer(NS_COPY, false, -1);
     } else {
       event->clipboardData =
-        new nsDOMDataTransfer(event->message, event->message == NS_PASTE, nsIClipboard::kGlobalClipboard);
+        new DataTransfer(event->message, event->message == NS_PASTE, nsIClipboard::kGlobalClipboard);
     }
   }
 
   return event->clipboardData;
 }
 
 } // namespace dom
 } // namespace mozilla
rename from dom/events/nsDOMDataTransfer.cpp
rename to dom/events/DataTransfer.cpp
--- a/dom/events/nsDOMDataTransfer.cpp
+++ b/dom/events/DataTransfer.cpp
@@ -2,17 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/BasicEvents.h"
 
-#include "nsDOMDataTransfer.h"
+#include "DataTransfer.h"
 
 #include "nsIDOMDocument.h"
 #include "nsIVariant.h"
 #include "nsISupportsPrimitives.h"
 #include "nsDOMClassInfoID.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsDOMLists.h"
 #include "nsError.h"
@@ -21,52 +21,52 @@
 #include "nsContentUtils.h"
 #include "nsIContent.h"
 #include "nsCRT.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIScriptContext.h"
 #include "nsIDocument.h"
 #include "nsIScriptGlobalObject.h"
 
-using namespace mozilla;
-using namespace mozilla::dom;
+DOMCI_DATA(DataTransfer, mozilla::dom::DataTransfer)
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMDataTransfer)
+namespace mozilla {
+namespace dom {
 
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDOMDataTransfer)
+NS_IMPL_CYCLE_COLLECTION_CLASS(DataTransfer)
+
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(DataTransfer)
   if (tmp->mFiles) {
     tmp->mFiles->Disconnect();
     NS_IMPL_CYCLE_COLLECTION_UNLINK(mFiles)
   }
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mDragTarget)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mDragImage)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMDataTransfer)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(DataTransfer)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFiles)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDragTarget)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDragImage)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
-NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMDataTransfer)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMDataTransfer)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(DataTransfer)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(DataTransfer)
 
-DOMCI_DATA(DataTransfer, nsDOMDataTransfer)
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMDataTransfer)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DataTransfer)
   NS_INTERFACE_MAP_ENTRY(nsIDOMDataTransfer)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMDataTransfer)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DataTransfer)
 NS_INTERFACE_MAP_END
 
 // the size of the array
-const char nsDOMDataTransfer::sEffects[8][9] = {
+const char DataTransfer::sEffects[8][9] = {
   "none", "copy", "move", "copyMove", "link", "copyLink", "linkMove", "all"
 };
 
-nsDOMDataTransfer::nsDOMDataTransfer(uint32_t aEventType, bool aIsExternal, int32_t aClipboardType)
+DataTransfer::DataTransfer(uint32_t aEventType, bool aIsExternal, int32_t aClipboardType)
   : mEventType(aEventType),
     mDropEffect(nsIDragService::DRAGDROP_ACTION_NONE),
     mEffectAllowed(nsIDragService::DRAGDROP_ACTION_UNINITIALIZED),
     mCursorState(false),
     mReadOnly(true),
     mIsExternal(aIsExternal),
     mUserCancelled(false),
     mIsCrossDomainSubFrameDrop(false),
@@ -86,27 +86,27 @@ nsDOMDataTransfer::nsDOMDataTransfer(uin
     if (aEventType == NS_PASTE) {
       CacheExternalClipboardFormats();
     } else if (aEventType >= NS_DRAGDROP_EVENT_START && aEventType <= NS_DRAGDROP_LEAVE_SYNTH) {
       CacheExternalDragFormats();
     }
   }
 }
 
-nsDOMDataTransfer::nsDOMDataTransfer(uint32_t aEventType,
-                                     const uint32_t aEffectAllowed,
-                                     bool aCursorState,
-                                     bool aIsExternal,
-                                     bool aUserCancelled,
-                                     bool aIsCrossDomainSubFrameDrop,
-                                     int32_t aClipboardType,
-                                     nsTArray<nsTArray<TransferItem> >& aItems,
-                                     nsIDOMElement* aDragImage,
-                                     uint32_t aDragImageX,
-                                     uint32_t aDragImageY)
+DataTransfer::DataTransfer(uint32_t aEventType,
+                           const uint32_t aEffectAllowed,
+                           bool aCursorState,
+                           bool aIsExternal,
+                           bool aUserCancelled,
+                           bool aIsCrossDomainSubFrameDrop,
+                           int32_t aClipboardType,
+                           nsTArray<nsTArray<TransferItem> >& aItems,
+                           nsIDOMElement* aDragImage,
+                           uint32_t aDragImageX,
+                           uint32_t aDragImageY)
   : mEventType(aEventType),
     mDropEffect(nsIDragService::DRAGDROP_ACTION_NONE),
     mEffectAllowed(aEffectAllowed),
     mCursorState(aCursorState),
     mReadOnly(true),
     mIsExternal(aIsExternal),
     mUserCancelled(aUserCancelled),
     mIsCrossDomainSubFrameDrop(aIsCrossDomainSubFrameDrop),
@@ -118,55 +118,55 @@ nsDOMDataTransfer::nsDOMDataTransfer(uin
 {
   // The items are copied from aItems into mItems. There is no need to copy
   // the actual data in the items as the data transfer will be read only. The
   // draggesture and dragstart events are the only times when items are
   // modifiable, but those events should have been using the first constructor
   // above.
   NS_ASSERTION(aEventType != NS_DRAGDROP_GESTURE &&
                aEventType != NS_DRAGDROP_START,
-               "invalid event type for nsDOMDataTransfer constructor");
+               "invalid event type for DataTransfer constructor");
 }
 
 NS_IMETHODIMP
-nsDOMDataTransfer::GetDropEffect(nsAString& aDropEffect)
+DataTransfer::GetDropEffect(nsAString& aDropEffect)
 {
   aDropEffect.AssignASCII(sEffects[mDropEffect]);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMDataTransfer::SetDropEffect(const nsAString& aDropEffect)
+DataTransfer::SetDropEffect(const nsAString& aDropEffect)
 {
   // the drop effect can only be 'none', 'copy', 'move' or 'link'.
   for (uint32_t e = 0; e <= nsIDragService::DRAGDROP_ACTION_LINK; e++) {
     if (aDropEffect.EqualsASCII(sEffects[e])) {
       // don't allow copyMove
       if (e != (nsIDragService::DRAGDROP_ACTION_COPY |
                 nsIDragService::DRAGDROP_ACTION_MOVE))
         mDropEffect = e;
       break;
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMDataTransfer::GetEffectAllowed(nsAString& aEffectAllowed)
+DataTransfer::GetEffectAllowed(nsAString& aEffectAllowed)
 {
   if (mEffectAllowed == nsIDragService::DRAGDROP_ACTION_UNINITIALIZED)
     aEffectAllowed.AssignLiteral("uninitialized");
   else
     aEffectAllowed.AssignASCII(sEffects[mEffectAllowed]);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMDataTransfer::SetEffectAllowed(const nsAString& aEffectAllowed)
+DataTransfer::SetEffectAllowed(const nsAString& aEffectAllowed)
 {
   if (aEffectAllowed.EqualsLiteral("uninitialized")) {
     mEffectAllowed = nsIDragService::DRAGDROP_ACTION_UNINITIALIZED;
     return NS_OK;
   }
 
   static_assert(nsIDragService::DRAGDROP_ACTION_NONE == 0,
                 "DRAGDROP_ACTION_NONE constant is wrong");
@@ -183,52 +183,52 @@ nsDOMDataTransfer::SetEffectAllowed(cons
       break;
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMDataTransfer::GetDropEffectInt(uint32_t* aDropEffect)
+DataTransfer::GetDropEffectInt(uint32_t* aDropEffect)
 {
   *aDropEffect = mDropEffect;
   return  NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMDataTransfer::SetDropEffectInt(uint32_t aDropEffect)
+DataTransfer::SetDropEffectInt(uint32_t aDropEffect)
 {
   mDropEffect = aDropEffect;
   return  NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMDataTransfer::GetEffectAllowedInt(uint32_t* aEffectAllowed)
+DataTransfer::GetEffectAllowedInt(uint32_t* aEffectAllowed)
 {
   *aEffectAllowed = mEffectAllowed;
   return  NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMDataTransfer::SetEffectAllowedInt(uint32_t aEffectAllowed)
+DataTransfer::SetEffectAllowedInt(uint32_t aEffectAllowed)
 {
   mEffectAllowed = aEffectAllowed;
   return  NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMDataTransfer::GetMozUserCancelled(bool* aUserCancelled)
+DataTransfer::GetMozUserCancelled(bool* aUserCancelled)
 {
   *aUserCancelled = mUserCancelled;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMDataTransfer::GetFiles(nsIDOMFileList** aFileList)
+DataTransfer::GetFiles(nsIDOMFileList** aFileList)
 {
   *aFileList = nullptr;
 
   if (mEventType != NS_DRAGDROP_DROP && mEventType != NS_DRAGDROP_DRAGDROP &&
       mEventType != NS_PASTE) {
     return NS_OK;
   }
 
@@ -264,17 +264,17 @@ nsDOMDataTransfer::GetFiles(nsIDOMFileLi
   }
 
   *aFileList = mFiles;
   NS_ADDREF(*aFileList);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMDataTransfer::GetTypes(nsIDOMDOMStringList** aTypes)
+DataTransfer::GetTypes(nsIDOMDOMStringList** aTypes)
 {
   *aTypes = nullptr;
 
   nsRefPtr<nsDOMStringList> types = new nsDOMStringList();
 
   if (mItems.Length()) {
     const nsTArray<TransferItem>& item = mItems[0];
     for (uint32_t i = 0; i < item.Length(); i++)
@@ -289,17 +289,17 @@ nsDOMDataTransfer::GetTypes(nsIDOMDOMStr
 
   *aTypes = types;
   NS_ADDREF(*aTypes);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMDataTransfer::GetData(const nsAString& aFormat, nsAString& aData)
+DataTransfer::GetData(const nsAString& aFormat, nsAString& aData)
 {
   // return an empty string if data for the format was not found
   aData.Truncate();
 
   nsCOMPtr<nsIVariant> data;
   nsresult rv = MozGetDataAt(aFormat, 0, getter_AddRefs(data));
   if (rv == NS_ERROR_DOM_INDEX_SIZE_ERR) {
     return NS_OK;
@@ -344,62 +344,62 @@ nsDOMDataTransfer::GetData(const nsAStri
       aData = stringdata;
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMDataTransfer::SetData(const nsAString& aFormat, const nsAString& aData)
+DataTransfer::SetData(const nsAString& aFormat, const nsAString& aData)
 {
   nsCOMPtr<nsIWritableVariant> variant = do_CreateInstance(NS_VARIANT_CONTRACTID);
   NS_ENSURE_TRUE(variant, NS_ERROR_OUT_OF_MEMORY);
 
   variant->SetAsAString(aData);
 
   return MozSetDataAt(aFormat, variant, 0);
 }
 
 NS_IMETHODIMP
-nsDOMDataTransfer::ClearData(const nsAString& aFormat)
+DataTransfer::ClearData(const nsAString& aFormat)
 {
   nsresult rv = MozClearDataAt(aFormat, 0);
   return (rv == NS_ERROR_DOM_INDEX_SIZE_ERR) ? NS_OK : rv;
 }
 
 NS_IMETHODIMP
-nsDOMDataTransfer::GetMozItemCount(uint32_t* aCount)
+DataTransfer::GetMozItemCount(uint32_t* aCount)
 {
   *aCount = mItems.Length();
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMDataTransfer::GetMozCursor(nsAString& aCursorState)
+DataTransfer::GetMozCursor(nsAString& aCursorState)
 {
   if (mCursorState) {
     aCursorState.AssignLiteral("default");
   } else {
     aCursorState.AssignLiteral("auto");
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMDataTransfer::SetMozCursor(const nsAString& aCursorState)
+DataTransfer::SetMozCursor(const nsAString& aCursorState)
 {
   // Lock the cursor to an arrow during the drag.
   mCursorState = aCursorState.EqualsLiteral("default");
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMDataTransfer::GetMozSourceNode(nsIDOMNode** aSourceNode)
+DataTransfer::GetMozSourceNode(nsIDOMNode** aSourceNode)
 {
   *aSourceNode = nullptr;
 
   nsCOMPtr<nsIDragSession> dragSession = nsContentUtils::GetDragSession();
   if (!dragSession)
     return NS_OK;
 
   nsCOMPtr<nsIDOMNode> sourceNode;
@@ -407,17 +407,17 @@ nsDOMDataTransfer::GetMozSourceNode(nsID
   if (sourceNode && !nsContentUtils::CanCallerAccess(sourceNode))
     return NS_OK;
 
   sourceNode.swap(*aSourceNode);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMDataTransfer::MozTypesAt(uint32_t aIndex, nsIDOMDOMStringList** aTypes)
+DataTransfer::MozTypesAt(uint32_t aIndex, nsIDOMDOMStringList** aTypes)
 {
   *aTypes = nullptr;
 
   // Only the first item is valid for clipboard events
   if (aIndex > 0 &&
       (mEventType == NS_CUT || mEventType == NS_COPY || mEventType == NS_PASTE)) {
     return NS_ERROR_DOM_INDEX_SIZE_ERR;
   }
@@ -433,19 +433,18 @@ nsDOMDataTransfer::MozTypesAt(uint32_t a
 
   *aTypes = types;
   NS_ADDREF(*aTypes);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMDataTransfer::MozGetDataAt(const nsAString& aFormat,
-                                uint32_t aIndex,
-                                nsIVariant** aData)
+DataTransfer::MozGetDataAt(const nsAString& aFormat, uint32_t aIndex,
+                           nsIVariant** aData)
 {
   *aData = nullptr;
 
   if (aFormat.IsEmpty())
     return NS_OK;
 
   if (aIndex >= mItems.Length()) {
     return NS_ERROR_DOM_INDEX_SIZE_ERR;
@@ -518,19 +517,18 @@ nsDOMDataTransfer::MozGetDataAt(const ns
       return NS_OK;
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMDataTransfer::MozSetDataAt(const nsAString& aFormat,
-                                nsIVariant* aData,
-                                uint32_t aIndex)
+DataTransfer::MozSetDataAt(const nsAString& aFormat, nsIVariant* aData,
+                           uint32_t aIndex)
 {
   NS_ENSURE_TRUE(aData, NS_ERROR_NULL_POINTER);
 
   if (aFormat.IsEmpty())
     return NS_OK;
 
   if (mReadOnly)
     return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
@@ -557,17 +555,17 @@ nsDOMDataTransfer::MozSetDataAt(const ns
 
   nsresult rv = NS_OK;
   nsIPrincipal* principal = GetCurrentPrincipal(&rv);
   NS_ENSURE_SUCCESS(rv, rv);
   return SetDataWithPrincipal(aFormat, aData, aIndex, principal);
 }
 
 NS_IMETHODIMP
-nsDOMDataTransfer::MozClearDataAt(const nsAString& aFormat, uint32_t aIndex)
+DataTransfer::MozClearDataAt(const nsAString& aFormat, uint32_t aIndex)
 {
   if (mReadOnly)
     return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
 
   if (aIndex >= mItems.Length()) {
     return NS_ERROR_DOM_INDEX_SIZE_ERR;
   }
 
@@ -611,33 +609,33 @@ nsDOMDataTransfer::MozClearDataAt(const 
   // if the last format for an item is removed, remove the entire item
   if (!item.Length())
      mItems.RemoveElementAt(aIndex);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMDataTransfer::SetDragImage(nsIDOMElement* aImage, int32_t aX, int32_t aY)
+DataTransfer::SetDragImage(nsIDOMElement* aImage, int32_t aX, int32_t aY)
 {
   if (mReadOnly)
     return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
 
   if (aImage) {
     nsCOMPtr<nsIContent> content = do_QueryInterface(aImage);
     NS_ENSURE_TRUE(content, NS_ERROR_INVALID_ARG);
   }
   mDragImage = aImage;
   mDragImageX = aX;
   mDragImageY = aY;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMDataTransfer::AddElement(nsIDOMElement* aElement)
+DataTransfer::AddElement(nsIDOMElement* aElement)
 {
   NS_ENSURE_TRUE(aElement, NS_ERROR_NULL_POINTER);
 
   if (aElement) {
     nsCOMPtr<nsIContent> content = do_QueryInterface(aElement);
     NS_ENSURE_TRUE(content, NS_ERROR_INVALID_ARG);
   }
 
@@ -645,32 +643,32 @@ nsDOMDataTransfer::AddElement(nsIDOMElem
     return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
 
   mDragTarget = do_QueryInterface(aElement);
 
   return NS_OK;
 }
 
 nsresult
-nsDOMDataTransfer::Clone(uint32_t aEventType, bool aUserCancelled,
-                         bool aIsCrossDomainSubFrameDrop,
-                         nsIDOMDataTransfer** aNewDataTransfer)
+DataTransfer::Clone(uint32_t aEventType, bool aUserCancelled,
+                    bool aIsCrossDomainSubFrameDrop,
+                    nsIDOMDataTransfer** aNewDataTransfer)
 {
-  nsDOMDataTransfer* newDataTransfer =
-    new nsDOMDataTransfer(aEventType, mEffectAllowed, mCursorState,
-                          mIsExternal, aUserCancelled, aIsCrossDomainSubFrameDrop,
-                          mClipboardType, mItems, mDragImage, mDragImageX, mDragImageY);
+  DataTransfer* newDataTransfer =
+    new DataTransfer(aEventType, mEffectAllowed, mCursorState, mIsExternal,
+                     aUserCancelled, aIsCrossDomainSubFrameDrop, mClipboardType,
+                     mItems, mDragImage, mDragImageX, mDragImageY);
 
   *aNewDataTransfer = newDataTransfer;
   NS_ADDREF(*aNewDataTransfer);
   return NS_OK;
 }
 
 already_AddRefed<nsISupportsArray>
-nsDOMDataTransfer::GetTransferables(nsIDOMNode* aDragTarget)
+DataTransfer::GetTransferables(nsIDOMNode* aDragTarget)
 {
   MOZ_ASSERT(aDragTarget);
 
   nsCOMPtr<nsISupportsArray> transArray =
     do_CreateInstance("@mozilla.org/supports-array;1");
   if (!transArray) {
     return nullptr;
   }
@@ -695,17 +693,17 @@ nsDOMDataTransfer::GetTransferables(nsID
       transArray->AppendElement(transferable);
     }
   }
 
   return transArray.forget();
 }
 
 already_AddRefed<nsITransferable>
-nsDOMDataTransfer::GetTransferable(uint32_t aIndex, nsILoadContext* aLoadContext)
+DataTransfer::GetTransferable(uint32_t aIndex, nsILoadContext* aLoadContext)
 {
   if (aIndex >= mItems.Length()) {
     return nullptr;
   }
 
   nsTArray<TransferItem>& item = mItems[aIndex];
   uint32_t count = item.Length();
   if (!count) {
@@ -762,19 +760,19 @@ nsDOMDataTransfer::GetTransferable(uint3
   if (added) {
     return transferable.forget();
   }
 
   return nullptr;
 }
 
 bool
-nsDOMDataTransfer::ConvertFromVariant(nsIVariant* aVariant,
-                                      nsISupports** aSupports,
-                                      uint32_t* aLength)
+DataTransfer::ConvertFromVariant(nsIVariant* aVariant,
+                                 nsISupports** aSupports,
+                                 uint32_t* aLength)
 {
   *aSupports = nullptr;
   *aLength = 0;
 
   uint16_t type;
   aVariant->GetDataType(&type);
   if (type == nsIDataType::VTYPE_INTERFACE ||
       type == nsIDataType::VTYPE_INTERFACE_IS) {
@@ -826,26 +824,26 @@ nsDOMDataTransfer::ConvertFromVariant(ns
 
   // each character is two bytes
   *aLength = str.Length() << 1;
 
   return true;
 }
 
 void
-nsDOMDataTransfer::ClearAll()
+DataTransfer::ClearAll()
 {
   mItems.Clear();
 }
 
 nsresult
-nsDOMDataTransfer::SetDataWithPrincipal(const nsAString& aFormat,
-                                        nsIVariant* aData,
-                                        uint32_t aIndex,
-                                        nsIPrincipal* aPrincipal)
+DataTransfer::SetDataWithPrincipal(const nsAString& aFormat,
+                                   nsIVariant* aData,
+                                   uint32_t aIndex,
+                                   nsIPrincipal* aPrincipal)
 {
   nsAutoString format;
   GetRealFormat(aFormat, format);
 
   // check if the item for the format already exists. In that case,
   // just replace it.
   TransferItem* formatitem;
   if (aIndex < mItems.Length()) {
@@ -884,59 +882,59 @@ nsDOMDataTransfer::SetDataWithPrincipal(
   formatitem->mFormat = format;
   formatitem->mPrincipal = aPrincipal;
   formatitem->mData = aData;
 
   return NS_OK;
 }
 
 nsIPrincipal*
-nsDOMDataTransfer::GetCurrentPrincipal(nsresult* rv)
+DataTransfer::GetCurrentPrincipal(nsresult* rv)
 {
   nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
 
   nsCOMPtr<nsIPrincipal> currentPrincipal;
   *rv = ssm->GetSubjectPrincipal(getter_AddRefs(currentPrincipal));
   NS_ENSURE_SUCCESS(*rv, nullptr);
 
   if (!currentPrincipal)
     ssm->GetSystemPrincipal(getter_AddRefs(currentPrincipal));
 
   return currentPrincipal.get();
 }
 
 void
-nsDOMDataTransfer::GetRealFormat(const nsAString& aInFormat, nsAString& aOutFormat)
+DataTransfer::GetRealFormat(const nsAString& aInFormat, nsAString& aOutFormat)
 {
   // treat text/unicode as equivalent to text/plain
   nsAutoString lowercaseFormat;
   nsContentUtils::ASCIIToLower(aInFormat, lowercaseFormat);
   if (lowercaseFormat.EqualsLiteral("text") || lowercaseFormat.EqualsLiteral("text/unicode"))
     aOutFormat.AssignLiteral("text/plain");
   else if (lowercaseFormat.EqualsLiteral("url"))
     aOutFormat.AssignLiteral("text/uri-list");
   else
     aOutFormat.Assign(lowercaseFormat);
 }
 
 void
-nsDOMDataTransfer::CacheExternalData(const char* aFormat, uint32_t aIndex, nsIPrincipal* aPrincipal)
+DataTransfer::CacheExternalData(const char* aFormat, uint32_t aIndex, nsIPrincipal* aPrincipal)
 {
   if (strcmp(aFormat, kUnicodeMime) == 0) {
     SetDataWithPrincipal(NS_LITERAL_STRING("text/plain"), nullptr, aIndex, aPrincipal);
   } else {
     if (strcmp(aFormat, kURLDataMime) == 0) {
       SetDataWithPrincipal(NS_LITERAL_STRING("text/uri-list"), nullptr, aIndex, aPrincipal);
     }
     SetDataWithPrincipal(NS_ConvertUTF8toUTF16(aFormat), nullptr, aIndex, aPrincipal);
   }
 }
 
 void
-nsDOMDataTransfer::CacheExternalDragFormats()
+DataTransfer::CacheExternalDragFormats()
 {
   // Called during the constructor to cache the formats available from an
   // external drag. The data associated with each format will be set to null.
   // This data will instead only be retrieved in FillInExternalDragData when
   // asked for, as it may be time consuming for the source application to
   // generate it.
 
   nsCOMPtr<nsIDragSession> dragSession = nsContentUtils::GetDragSession();
@@ -968,17 +966,17 @@ nsDOMDataTransfer::CacheExternalDragForm
       if (supported) {
         CacheExternalData(formats[f], c, sysPrincipal);
       }
     }
   }
 }
 
 void
-nsDOMDataTransfer::CacheExternalClipboardFormats()
+DataTransfer::CacheExternalClipboardFormats()
 {
   NS_ASSERTION(mEventType == NS_PASTE, "caching clipboard data for invalid event");
 
   // Called during the constructor for paste events to cache the formats
   // available on the clipboard. As with CacheExternalDragFormats, the
   // data will only be retrieved when needed.
 
   nsCOMPtr<nsIClipboard> clipboard = do_GetService("@mozilla.org/widget/clipboard;1");
@@ -1002,17 +1000,17 @@ nsDOMDataTransfer::CacheExternalClipboar
     // the data. When retrieved, GetRealData will read the data.
     if (supported) {
       CacheExternalData(formats[f], 0, sysPrincipal);
     }
   }
 }
 
 void
-nsDOMDataTransfer::FillInExternalData(TransferItem& aItem, uint32_t aIndex)
+DataTransfer::FillInExternalData(TransferItem& aItem, uint32_t aIndex)
 {
   NS_PRECONDITION(mIsExternal, "Not an external data transfer");
 
   if (aItem.mData) {
     return;
   }
 
   // only drag and paste events should be calling FillInExternalData
@@ -1076,8 +1074,11 @@ nsDOMDataTransfer::FillInExternalData(Tr
       variant->SetAsAString(str);
     }
     else {
       variant->SetAsISupports(data);
     }
 
     aItem.mData = variant;
   }
+
+} // namespace dom
+} // namespace mozilla
rename from dom/events/nsDOMDataTransfer.h
rename to dom/events/DataTransfer.h
--- a/dom/events/nsDOMDataTransfer.h
+++ b/dom/events/DataTransfer.h
@@ -1,97 +1,101 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef nsDOMDataTransfer_h__
-#define nsDOMDataTransfer_h__
+#ifndef mozilla_dom_DataTransfer_h
+#define mozilla_dom_DataTransfer_h
 
 #include "nsString.h"
 #include "nsTArray.h"
 #include "nsIVariant.h"
 #include "nsIPrincipal.h"
 #include "nsIDOMDataTransfer.h"
 #include "nsIDOMElement.h"
 #include "nsCycleCollectionParticipant.h"
 
 #include "nsAutoPtr.h"
 #include "nsDOMFile.h"
 #include "mozilla/Attributes.h"
 
+class nsEventStateManager;
 class nsITransferable;
 class nsISupportsArray;
 class nsILoadContext;
 
+namespace mozilla {
+namespace dom {
+
 /**
  * TransferItem is used to hold data for a particular format. Each piece of
  * data has a principal set from the caller which added it. This allows a
  * caller that wishes to retrieve the data to only be able to access the data
  * it is allowed to, yet still allow a chrome caller to retrieve any of the
  * data.
  */
 struct TransferItem {
   nsString mFormat;
   nsCOMPtr<nsIPrincipal> mPrincipal;
   nsCOMPtr<nsIVariant> mData;
 };
 
-class nsDOMDataTransfer MOZ_FINAL : public nsIDOMDataTransfer
+class DataTransfer MOZ_FINAL : public nsIDOMDataTransfer
 {
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_NSIDOMDATATRANSFER
 
-  NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsDOMDataTransfer, nsIDOMDataTransfer)
+  NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(DataTransfer, nsIDOMDataTransfer)
 
-  friend class nsEventStateManager;
+  friend class ::nsEventStateManager;
 
 protected:
 
   // hide the default constructor
-  nsDOMDataTransfer();
+  DataTransfer();
 
   // this constructor is used only by the Clone method to copy the fields as
   // needed to a new data transfer.
-  nsDOMDataTransfer(uint32_t aEventType,
-                    const uint32_t aEffectAllowed,
-                    bool aCursorState,
-                    bool aIsExternal,
-                    bool aUserCancelled,
-                    bool aIsCrossDomainSubFrameDrop,
-                    int32_t aClipboardType,
-                    nsTArray<nsTArray<TransferItem> >& aItems,
-                    nsIDOMElement* aDragImage,
-                    uint32_t aDragImageX,
-                    uint32_t aDragImageY);
+  DataTransfer(uint32_t aEventType,
+               const uint32_t aEffectAllowed,
+               bool aCursorState,
+               bool aIsExternal,
+               bool aUserCancelled,
+               bool aIsCrossDomainSubFrameDrop,
+               int32_t aClipboardType,
+               nsTArray<nsTArray<TransferItem> >& aItems,
+               nsIDOMElement* aDragImage,
+               uint32_t aDragImageX,
+               uint32_t aDragImageY);
 
-  ~nsDOMDataTransfer()
+  ~DataTransfer()
   {
     if (mFiles) {
       mFiles->Disconnect();
     }
   }
 
   static const char sEffects[8][9];
 
 public:
 
-  // Constructor for nsDOMDataTransfer.
+  // Constructor for DataTransfer.
   //
   // aEventType is an event constant (such as NS_DRAGDROP_START)
   //
   // aIsExternal must only be true when used to create a dataTransfer for a
   // paste or a drag that was started without using a data transfer. The
   // latter will occur when an external drag occurs, that is, a drag where the
   // source is another application, or a drag is started by calling the drag
   // service directly. For clipboard operations, aClipboardType indicates
   // which clipboard to use, from nsIClipboard, or -1 for non-clipboard operations,
   // or if access to the system clipboard should not be allowed.
-  nsDOMDataTransfer(uint32_t aEventType, bool aIsExternal, int32_t aClipboardType);
+  DataTransfer(uint32_t aEventType, bool aIsExternal, int32_t aClipboardType);
 
   void GetDragTarget(nsIDOMElement** aDragTarget)
   {
     *aDragTarget = mDragTarget;
     NS_IF_ADDREF(*aDragTarget);
   }
 
   // a readonly dataTransfer cannot have new data added or existing data removed.
@@ -196,10 +200,13 @@ protected:
 
   // the custom drag image and coordinates within the image. If mDragImage is
   // null, the default image is created from the drag target.
   nsCOMPtr<nsIDOMElement> mDragImage;
   uint32_t mDragImageX;
   uint32_t mDragImageY;
 };
 
-#endif // nsDOMDataTransfer_h__
+} // namespace dom
+} // namespace mozilla
 
+#endif /* mozilla_dom_DataTransfer_h */
+
--- a/dom/events/moz.build
+++ b/dom/events/moz.build
@@ -37,36 +37,37 @@ EXPORTS.mozilla += [
 
 EXPORTS.mozilla.dom += [
     'AnimationEvent.h',
     'BeforeUnloadEvent.h',
     'ClipboardEvent.h',
     'CommandEvent.h',
     'CompositionEvent.h',
     'DataContainerEvent.h',
+    'DataTransfer.h',
     'EventTarget.h',
     'PointerEvent.h',
     'Touch.h',
     'WheelEvent.h',
 ]
 
 if CONFIG['MOZ_WEBSPEECH']:
     EXPORTS.mozilla.dom += ['SpeechRecognitionError.h']
 
 UNIFIED_SOURCES += [
     'AnimationEvent.cpp',
     'BeforeUnloadEvent.cpp',
     'ClipboardEvent.cpp',
     'CommandEvent.cpp',
     'CompositionEvent.cpp',
     'DataContainerEvent.cpp',
+    'DataTransfer.cpp',
     'EventTarget.cpp',
     'nsAsyncDOMEvent.cpp',
     'nsContentEventHandler.cpp',
-    'nsDOMDataTransfer.cpp',
     'nsDOMDeviceMotionEvent.cpp',
     'nsDOMDragEvent.cpp',
     'nsDOMEventTargetHelper.cpp',
     'nsDOMFocusEvent.cpp',
     'nsDOMKeyboardEvent.cpp',
     'nsDOMMessageEvent.cpp',
     'nsDOMMouseEvent.cpp',
     'nsDOMMouseScrollEvent.cpp',
--- a/dom/events/nsDOMDragEvent.cpp
+++ b/dom/events/nsDOMDragEvent.cpp
@@ -1,16 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsDOMDragEvent.h"
 #include "nsContentUtils.h"
-#include "nsIDOMDataTransfer.h"
 #include "prtime.h"
 #include "mozilla/MouseEvents.h"
 
 using namespace mozilla;
 
 nsDOMDragEvent::nsDOMDragEvent(mozilla::dom::EventTarget* aOwner,
                                nsPresContext* aPresContext,
                                WidgetDragEvent* aEvent)
--- a/dom/events/nsEventStateManager.cpp
+++ b/dom/events/nsEventStateManager.cpp
@@ -65,17 +65,17 @@
 #include "nsEventDispatcher.h"
 
 #include "nsServiceManagerUtils.h"
 #include "nsITimer.h"
 #include "nsFontMetrics.h"
 #include "nsIDOMXULDocument.h"
 #include "nsIDragService.h"
 #include "nsIDragSession.h"
-#include "nsDOMDataTransfer.h"
+#include "mozilla/dom/DataTransfer.h"
 #include "nsContentAreaDragDrop.h"
 #ifdef MOZ_XUL
 #include "nsTreeBodyFrame.h"
 #endif
 #include "nsIController.h"
 #include "nsICommandParams.h"
 #include "mozilla/Services.h"
 #include "mozilla/dom/HTMLLabelElement.h"
@@ -2106,18 +2106,18 @@ nsEventStateManager::GenerateDragGesture
     if (DeprecatedAbs(pt.x - mGestureDownPoint.x) > pixelThresholdX ||
         DeprecatedAbs(pt.y - mGestureDownPoint.y) > pixelThresholdY) {
       if (Prefs::ClickHoldContextMenu()) {
         // stop the click-hold before we fire off the drag gesture, in case
         // it takes a long time
         KillClickHoldTimer();
       }
 
-      nsRefPtr<nsDOMDataTransfer> dataTransfer =
-        new nsDOMDataTransfer(NS_DRAGDROP_START, false, -1);
+      nsRefPtr<DataTransfer> dataTransfer =
+        new DataTransfer(NS_DRAGDROP_START, false, -1);
       if (!dataTransfer)
         return;
 
       nsCOMPtr<nsISelection> selection;
       nsCOMPtr<nsIContent> eventContent, targetContent;
       mCurrentTarget->GetContentForEvent(aEvent, getter_AddRefs(eventContent));
       if (eventContent)
         DetermineDragTarget(aPresContext, eventContent, dataTransfer,
@@ -2210,17 +2210,17 @@ nsEventStateManager::GenerateDragGesture
     // while dragging.
     FlushPendingEvents(aPresContext);
   }
 } // GenerateDragGesture
 
 void
 nsEventStateManager::DetermineDragTarget(nsPresContext* aPresContext,
                                          nsIContent* aSelectionTarget,
-                                         nsDOMDataTransfer* aDataTransfer,
+                                         DataTransfer* aDataTransfer,
                                          nsISelection** aSelection,
                                          nsIContent** aTargetNode)
 {
   *aTargetNode = nullptr;
 
   nsCOMPtr<nsISupports> container = aPresContext->GetContainerWeak();
   nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(container);
   if (!window)
@@ -2297,17 +2297,17 @@ nsEventStateManager::DetermineDragTarget
     *aTargetNode = dragContent;
     NS_ADDREF(*aTargetNode);
   }
 }
 
 bool
 nsEventStateManager::DoDefaultDragStart(nsPresContext* aPresContext,
                                         WidgetDragEvent* aDragEvent,
-                                        nsDOMDataTransfer* aDataTransfer,
+                                        DataTransfer* aDataTransfer,
                                         nsIContent* aDragTarget,
                                         nsISelection* aSelection)
 {
   nsCOMPtr<nsIDragService> dragService =
     do_GetService("@mozilla.org/widget/dragservice;1");
   if (!dragService)
     return false;
 
--- a/dom/events/nsEventStateManager.h
+++ b/dom/events/nsEventStateManager.h
@@ -19,24 +19,24 @@
 #include "Units.h"
 
 class nsFrameLoader;
 class nsIContent;
 class nsIDocument;
 class nsIDocShell;
 class nsIDocShellTreeItem;
 class imgIContainer;
-class nsDOMDataTransfer;
 class EnterLeaveDispatcher;
 class nsIMarkupDocumentViewer;
 class nsIScrollableFrame;
 class nsITimer;
 
 namespace mozilla {
 namespace dom {
+class DataTransfer;
 class TabParent;
 }
 }
 
 class OverOutElementsWrapper MOZ_FINAL : public nsISupports
 {
 public:
   OverOutElementsWrapper() : mLastOverFrame(nullptr) {}
@@ -734,33 +734,33 @@ protected:
    *
    * aSelectionTarget - target to check for selection
    * aDataTransfer - data transfer object that will contain the data to drag
    * aSelection - [out] set to the selection to be dragged
    * aTargetNode - [out] the draggable node, or null if there isn't one
    */
   void DetermineDragTarget(nsPresContext* aPresContext,
                            nsIContent* aSelectionTarget,
-                           nsDOMDataTransfer* aDataTransfer,
+                           mozilla::dom::DataTransfer* aDataTransfer,
                            nsISelection** aSelection,
                            nsIContent** aTargetNode);
 
   /*
    * Perform the default handling for the dragstart/draggesture event and set up a
    * drag for aDataTransfer if it contains any data. Returns true if a drag has
    * started.
    *
    * aDragEvent - the dragstart/draggesture event
    * aDataTransfer - the data transfer that holds the data to be dragged
    * aDragTarget - the target of the drag
    * aSelection - the selection to be dragged
    */
   bool DoDefaultDragStart(nsPresContext* aPresContext,
                           mozilla::WidgetDragEvent* aDragEvent,
-                          nsDOMDataTransfer* aDataTransfer,
+                          mozilla::dom::DataTransfer* aDataTransfer,
                           nsIContent* aDragTarget,
                           nsISelection* aSelection);
 
   bool IsTrackingDragGesture ( ) const { return mGestureDownContent != nullptr; }
   /**
    * Set the fields of aEvent to reflect the mouse position and modifier keys
    * that were set when the user first pressed the mouse button (stored by
    * BeginTrackingDragGesture). aEvent->widget must be