From a3ea17eac1cdfce0c10dd6bbd2de0849e1cb3883 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 20 Apr 2018 12:55:31 -0400 Subject: [PATCH] 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 | 9 ++++----- dom/events/Event.cpp | 1 + dom/events/Event.h | 9 +++++++++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/dom/events/DataTransferItem.cpp b/dom/events/DataTransferItem.cpp index 0cf53e83a36f..aea429a6810e 100644 --- a/dom/events/DataTransferItem.cpp +++ b/dom/events/DataTransferItem.cpp @@ -326,10 +326,9 @@ DataTransferItem::GetAsEntry(nsIPrincipal& aSubjectPrincipal, if (target) { global = target->GetOwnerGlobal(); } else { - nsCOMPtr event = - do_QueryInterface(mDataTransfer->GetParentObject()); + RefPtr event = do_QueryObject(mDataTransfer->GetParentObject()); if (event) { - global = event->InternalDOMEvent()->GetParentObject(); + global = event->GetParentObject(); } } @@ -469,8 +468,8 @@ DataTransferItem::GetAsString(FunctionStringCallback* aCallback, if (parent && !global) { if (nsCOMPtr target = do_QueryInterface(parent)) { global = target->GetOwnerGlobal(); - } else if (nsCOMPtr event = do_QueryInterface(parent)) { - global = event->InternalDOMEvent()->GetParentObject(); + } else if (RefPtr event = do_QueryObject(parent)) { + global = event->GetParentObject(); } } if (global) { diff --git a/dom/events/Event.cpp b/dom/events/Event.cpp index fa33dcc3ab43..96ef83e85511 100644 --- a/dom/events/Event.cpp +++ b/dom/events/Event.cpp @@ -137,6 +137,7 @@ Event::~Event() 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 diff --git a/dom/events/Event.h b/dom/events/Event.h index 1a267e409cd1..cfcf8a639387 100755 --- a/dom/events/Event.h +++ b/dom/events/Event.h @@ -46,10 +46,17 @@ class XULCommandEvent; #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); @@ -393,6 +400,8 @@ private: bool mOriginalWantsPopupControlCheck; }; +NS_DEFINE_STATIC_IID_ACCESSOR(Event, NS_EVENT_IID) + } // namespace dom } // namespace mozilla