diff options
author | Moonchild <moonchild@palemoon.org> | 2021-07-12 03:06:58 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2021-07-12 03:06:58 +0000 |
commit | d8d6160dc63b34fe159e8968a828202f0c22489b (patch) | |
tree | 65b3207ee4a5670700e5a4164d7c4fbb8b320861 | |
parent | 309dbc1f983593c3bbed63fc28833fee030f98ee (diff) | |
download | uxp-d8d6160dc63b34fe159e8968a828202f0c22489b.tar.gz |
Issue mcp-graveyard/UXP#1792 - Part 4: Implement constructors for the EventTarget interface.
-rw-r--r-- | dom/bindings/Bindings.conf | 1 | ||||
-rw-r--r-- | dom/events/EventTarget.cpp | 15 | ||||
-rw-r--r-- | dom/events/EventTarget.h | 2 | ||||
-rw-r--r-- | dom/webidl/EventTarget.webidl | 3 |
4 files changed, 19 insertions, 2 deletions
diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index af3c7f70f0..c408765430 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -293,7 +293,6 @@ DOMInterfaces = { # We can also get rid of the UnwrapArg bits in # the dom QueryInterface (in BindingUtils.cpp) at that point. 'hasXPConnectImpls': True, - 'concrete': False, 'jsImplParent': 'mozilla::DOMEventTargetHelper', 'implicitJSContext': [ 'dispatchEvent' ] }, diff --git a/dom/events/EventTarget.cpp b/dom/events/EventTarget.cpp index cf69dcb859..5f9228c21c 100644 --- a/dom/events/EventTarget.cpp +++ b/dom/events/EventTarget.cpp @@ -7,11 +7,26 @@ #include "mozilla/dom/Event.h" #include "mozilla/dom/EventTarget.h" #include "mozilla/dom/EventTargetBinding.h" +#include "mozilla/dom/ConstructibleEventTarget.h" +#include "nsIGlobalObject.h" #include "nsThreadUtils.h" namespace mozilla { namespace dom { +/* static */ +already_AddRefed<EventTarget> +EventTarget::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv) +{ + nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports()); + if (!global) { + aRv.Throw(NS_ERROR_UNEXPECTED); + return nullptr; + } + RefPtr<EventTarget> target = new ConstructibleEventTarget(global); + return target.forget(); +} + void EventTarget::RemoveEventListener(const nsAString& aType, EventListener* aListener, diff --git a/dom/events/EventTarget.h b/dom/events/EventTarget.h index 9e5d1e7653..251600dfb9 100644 --- a/dom/events/EventTarget.h +++ b/dom/events/EventTarget.h @@ -42,6 +42,8 @@ public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_EVENTTARGET_IID) // WebIDL API + static already_AddRefed<EventTarget> Constructor(const GlobalObject& aGlobal, + ErrorResult& aRv); using nsIDOMEventTarget::AddEventListener; using nsIDOMEventTarget::RemoveEventListener; using nsIDOMEventTarget::DispatchEvent; diff --git a/dom/webidl/EventTarget.webidl b/dom/webidl/EventTarget.webidl index 9e8a267ff4..123fac4785 100644 --- a/dom/webidl/EventTarget.webidl +++ b/dom/webidl/EventTarget.webidl @@ -23,7 +23,8 @@ dictionary AddEventListenerOptions : EventListenerOptions { boolean once = false; }; -[Exposed=(Window,Worker,WorkerDebugger,System)] +[Constructor, + Exposed=(Window,Worker,WorkerDebugger,System)] interface EventTarget { /* Passing null for wantsUntrusted means "default behavior", which differs in content and chrome. In content that default boolean |