Bug 1351193 - Part 1: Added new DataTransfer constructor, r=Nika
☠☠ backed out by 561dd8c84f85 ☠ ☠
authorAnny Gakhokidze <agakhokidze@mozilla.com>
Wed, 23 May 2018 11:57:08 -0400
changeset 421009 94ffa7844ae7ab8053c22028d9b2cb9f7fc571e5
parent 421008 4231bd54fb2feca2d479876db705acc3262bea58
child 421010 b05e943f8d2ca718a02895997fd30fcf9a9470d9
push id34088
push userdluca@mozilla.com
push dateMon, 04 Jun 2018 17:56:32 +0000
treeherdermozilla-central@5b15326286d4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNika
bugs1351193
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1351193 - Part 1: Added new DataTransfer constructor, r=Nika Deleted the old Chrome DataTransfer constructor because it was only used for some tests which can be easily changed. Added a new constructor that is not Chrome Only. MozReview-Commit-ID: HjcgafSiWfM
dom/events/DataTransfer.cpp
dom/events/DataTransfer.h
dom/webidl/DataTransfer.webidl
testing/web-platform/meta/html/editing/dnd/datastore/datatransfer-constructor-001.html.ini
--- a/dom/events/DataTransfer.cpp
+++ b/dom/events/DataTransfer.cpp
@@ -192,32 +192,22 @@ DataTransfer::DataTransfer(nsISupports* 
                "invalid event type for DataTransfer constructor");
 }
 
 DataTransfer::~DataTransfer()
 {}
 
 // static
 already_AddRefed<DataTransfer>
-DataTransfer::Constructor(const GlobalObject& aGlobal,
-                          const nsAString& aEventType, bool aIsExternal,
-                          ErrorResult& aRv)
+DataTransfer::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv)
 {
-  nsAutoCString onEventType("on");
-  AppendUTF16toUTF8(aEventType, onEventType);
-  RefPtr<nsAtom> eventTypeAtom = NS_Atomize(onEventType);
-  if (!eventTypeAtom) {
-    aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
-    return nullptr;
-  }
 
-  EventMessage eventMessage = nsContentUtils::GetEventMessage(eventTypeAtom);
   RefPtr<DataTransfer> transfer = new DataTransfer(aGlobal.GetAsSupports(),
-                                                     eventMessage, aIsExternal,
-                                                     -1);
+                                                   eCopy, /* is external */ false, /* clipboard type */ -1);
+  transfer->mEffectAllowed = nsIDragService::DRAGDROP_ACTION_NONE;
   return transfer.forget();
 }
 
 JSObject*
 DataTransfer::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return DataTransferBinding::Wrap(aCx, this, aGivenProto);
 }
--- a/dom/events/DataTransfer.h
+++ b/dom/events/DataTransfer.h
@@ -114,18 +114,17 @@ public:
     MOZ_ASSERT(aNewParent);
     // Setting the parent after we've been wrapped is pointless, so
     // make sure we aren't wrapped yet.
     MOZ_ASSERT(!GetWrapperPreserveColor());
     mParent = aNewParent;
   }
 
   static already_AddRefed<DataTransfer>
-  Constructor(const GlobalObject& aGlobal, const nsAString& aEventType,
-              bool aIsExternal, ErrorResult& aRv);
+  Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
 
   /**
    * The actual effect that will be used, and should always be one of the
    * possible values of effectAllowed.
    *
    * For dragstart, drag and dragleave events, the dropEffect is initialized
    * to none. Any value assigned to the dropEffect will be set, but the value
    * isn't used for anything.
--- a/dom/webidl/DataTransfer.webidl
+++ b/dom/webidl/DataTransfer.webidl
@@ -2,17 +2,17 @@
 /* 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/.
  *
  * The origin of this IDL file is:
  * http://www.whatwg.org/specs/web-apps/current-work/#the-datatransfer-interface
  */
 
-[ChromeConstructor(DOMString eventType, boolean isExternal)]
+[Constructor]
 interface DataTransfer {
            attribute DOMString dropEffect;
            attribute DOMString effectAllowed;
 
   readonly attribute DataTransferItemList items;
 
   void setDragImage(Element image, long x, long y);
 
deleted file mode 100644
--- a/testing/web-platform/meta/html/editing/dnd/datastore/datatransfer-constructor-001.html.ini
+++ /dev/null
@@ -1,4 +0,0 @@
-[datatransfer-constructor-001.html]
-  [Verify DataTransfer constructor]
-    expected: FAIL
-