Bug 1455052 part 9. Stop using nsIDOMEvent in DataTransferItem. r=masayuki
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 20 Apr 2018 12:55:31 -0400
changeset 414724 43abd16157caaffe8f9166be815c09aef8f4b42e
parent 414723 b35aad989a131db1435b0254724f31db025a0e7a
child 414725 7d824df868b789d6c8bfe8376ba34b45af6d2110
push id102409
push userbzbarsky@mozilla.com
push dateFri, 20 Apr 2018 16:56:05 +0000
treeherdermozilla-inbound@27df0b6428b6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1455052
milestone61.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 1455052 part 9. Stop using nsIDOMEvent in DataTransferItem. r=masayuki I couldn't figure out a way to do this without giving Event an IID.... MozReview-Commit-ID: LdXmsQSHeIc
dom/events/DataTransferItem.cpp
dom/events/Event.cpp
dom/events/Event.h
--- a/dom/events/DataTransferItem.cpp
+++ b/dom/events/DataTransferItem.cpp
@@ -321,20 +321,19 @@ DataTransferItem::GetAsEntry(nsIPrincipa
 
   nsCOMPtr<nsIGlobalObject> global;
   // This is annoying, but DataTransfer may have various things as parent.
   nsCOMPtr<EventTarget> target =
     do_QueryInterface(mDataTransfer->GetParentObject());
   if (target) {
     global = target->GetOwnerGlobal();
   } else {
-    nsCOMPtr<nsIDOMEvent> event =
-      do_QueryInterface(mDataTransfer->GetParentObject());
+    RefPtr<Event> event = do_QueryObject(mDataTransfer->GetParentObject());
     if (event) {
-      global = event->InternalDOMEvent()->GetParentObject();
+      global = event->GetParentObject();
     }
   }
 
   if (!global) {
     return nullptr;
   }
 
   RefPtr<FileSystem> fs = FileSystem::Create(global);
@@ -464,18 +463,18 @@ DataTransferItem::GetAsString(FunctionSt
 
   // DataTransfer.mParent might be EventTarget, nsIGlobalObject, ClipboardEvent
   // nsPIDOMWindowOuter, null
   nsISupports* parent = mDataTransfer->GetParentObject();
   nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(parent);
   if (parent && !global) {
     if (nsCOMPtr<dom::EventTarget> target = do_QueryInterface(parent)) {
       global = target->GetOwnerGlobal();
-    } else if (nsCOMPtr<nsIDOMEvent> event = do_QueryInterface(parent)) {
-      global = event->InternalDOMEvent()->GetParentObject();
+    } else if (RefPtr<Event> event = do_QueryObject(parent)) {
+      global = event->GetParentObject();
     }
   }
   if (global) {
     rv = global->Dispatch(TaskCategory::Other, runnable.forget());
   } else {
     rv = NS_DispatchToMainThread(runnable);
   }
   if (NS_FAILED(rv)) {
--- a/dom/events/Event.cpp
+++ b/dom/events/Event.cpp
@@ -132,16 +132,17 @@ Event::~Event()
   if (mEventIsInternal && mEvent) {
     delete mEvent;
   }
 }
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Event)
   NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_INTERFACE_MAP_ENTRY(nsISupports)
+  NS_INTERFACE_MAP_ENTRY(Event)
   NS_INTERFACE_MAP_ENTRY(nsIDOMEvent)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(Event)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(Event)
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(Event)
 
--- a/dom/events/Event.h
+++ b/dom/events/Event.h
@@ -41,20 +41,27 @@ class MouseEvent;
 class TimeEvent;
 class UIEvent;
 class WantsPopupControlCheck;
 class XULCommandEvent;
 #define GENERATED_EVENT(EventClass_) class EventClass_;
 #include "mozilla/dom/GeneratedEventList.h"
 #undef GENERATED_EVENT
 
+// IID for Event
+#define NS_EVENT_IID                                            \
+  { 0x71139716, 0x4d91, 0x4dee,                                 \
+      { 0xba, 0xf9, 0xe3, 0x3b, 0x80, 0xc1, 0x61, 0x61 } }
+
 class Event : public nsIDOMEvent,
               public nsWrapperCache
 {
 public:
+  NS_DECLARE_STATIC_IID_ACCESSOR(NS_EVENT_IID)
+
   Event(EventTarget* aOwner,
         nsPresContext* aPresContext,
         WidgetEvent* aEvent);
   explicit Event(nsPIDOMWindowInner* aWindow);
 
 protected:
   virtual ~Event();
 
@@ -388,16 +395,18 @@ public:
     mEvent->SetWantsPopupControlCheck(mOriginalWantsPopupControlCheck);
   }
 
 private:
   Event* mEvent;
   bool mOriginalWantsPopupControlCheck;
 };
 
+NS_DEFINE_STATIC_IID_ACCESSOR(Event, NS_EVENT_IID)
+
 } // namespace dom
 } // namespace mozilla
 
 already_AddRefed<mozilla::dom::Event>
 NS_NewDOMEvent(mozilla::dom::EventTarget* aOwner,
                nsPresContext* aPresContext,
                mozilla::WidgetEvent* aEvent);