diff options
author | Moonchild <moonchild@palemoon.org> | 2021-07-12 03:04:29 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2021-07-12 03:04:29 +0000 |
commit | 1b86eb76fc620fb3e4d2683401b55780f26d1d3d (patch) | |
tree | a0a2053fcba47cbc19f4593c43b802e2eda4784a | |
parent | ea0e4de698ec2f983cfb0a6f758a41a15bccba5a (diff) | |
download | uxp-1b86eb76fc620fb3e4d2683401b55780f26d1d3d.tar.gz |
Issue #1792 - Part 3: Add ConstructibleEventTarget helper class.
Of course it couldn't be trivial :P
wrapObject is a pure virtual function which prevents an abstract constructor
from being used.
So, we need to extend DOMEventTargetHelper (applicable acronym: DETH :D) with
a wrapObject implementation - in a derivative class is the clearest way to do
this, as opposed to making DETH more complex.
-rw-r--r-- | dom/events/ConstructibleEventTarget.cpp | 20 | ||||
-rw-r--r-- | dom/events/ConstructibleEventTarget.h | 34 | ||||
-rw-r--r-- | dom/events/moz.build | 2 |
3 files changed, 56 insertions, 0 deletions
diff --git a/dom/events/ConstructibleEventTarget.cpp b/dom/events/ConstructibleEventTarget.cpp new file mode 100644 index 0000000000..8e768f7a61 --- /dev/null +++ b/dom/events/ConstructibleEventTarget.cpp @@ -0,0 +1,20 @@ +/* -*- Mode: C++; tab-width: 8; 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/ConstructibleEventTarget.h" +#include "mozilla/dom/EventTargetBinding.h" + +namespace mozilla { +namespace dom { + +JSObject* +ConstructibleEventTarget::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto) +{ + return EventTargetBinding::Wrap(cx, this, aGivenProto); +} + +} // namespace dom +} // namespace mozilla + diff --git a/dom/events/ConstructibleEventTarget.h b/dom/events/ConstructibleEventTarget.h new file mode 100644 index 0000000000..18f60d556c --- /dev/null +++ b/dom/events/ConstructibleEventTarget.h @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 8; 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 mozilla_dom_ConstructibleEventTarget_h_ +#define mozilla_dom_ConstructibleEventTarget_h_ + +#include "mozilla/DOMEventTargetHelper.h" +#include "js/RootingAPI.h" + +namespace mozilla { +namespace dom { + +class ConstructibleEventTarget : public DOMEventTargetHelper +{ +public: + // We're not worrying about ISupports and Cycle Collection here just for a wrapper function. + // This does mean that ConstructibleEventTarget will show up in CC and refcount logs as a + // DOMEventTargetHelper, but that's OK. + + explicit ConstructibleEventTarget(nsIGlobalObject* aGlobalObject) + : DOMEventTargetHelper(aGlobalObject) + { + } + + virtual JSObject* WrapObject(JSContext* cx, + JS::Handle<JSObject*> aGivenProto) override; +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_ConstructibleEventTarget_h_ diff --git a/dom/events/moz.build b/dom/events/moz.build index c5fd750146..d651167bd9 100644 --- a/dom/events/moz.build +++ b/dom/events/moz.build @@ -40,6 +40,7 @@ EXPORTS.mozilla.dom += [ 'ClipboardEvent.h', 'CommandEvent.h', 'CompositionEvent.h', + 'ConstructibleEventTarget.h', 'CustomEvent.h', 'DataContainerEvent.h', 'DataTransfer.h', @@ -80,6 +81,7 @@ SOURCES += [ 'ClipboardEvent.cpp', 'CommandEvent.cpp', 'CompositionEvent.cpp', + 'ConstructibleEventTarget.cpp', 'ContentEventHandler.cpp', 'CustomEvent.cpp', 'DataContainerEvent.cpp', |