summaryrefslogtreecommitdiffstats
path: root/dom/events/InvokeEvent.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /dom/events/InvokeEvent.cpp
parentInitial commit. (diff)
downloadfirefox-upstream/124.0.1.tar.xz
firefox-upstream/124.0.1.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/events/InvokeEvent.cpp')
-rw-r--r--dom/events/InvokeEvent.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/dom/events/InvokeEvent.cpp b/dom/events/InvokeEvent.cpp
new file mode 100644
index 0000000000..4b7dc1e6da
--- /dev/null
+++ b/dom/events/InvokeEvent.cpp
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* 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/InvokeEvent.h"
+#include "mozilla/dom/EventTarget.h"
+#include "mozilla/dom/InvokeEventBinding.h"
+#include "nsContentUtils.h"
+
+namespace mozilla::dom {
+NS_IMPL_CYCLE_COLLECTION_INHERITED(InvokeEvent, Event, mInvoker)
+
+NS_IMPL_ADDREF_INHERITED(InvokeEvent, Event)
+NS_IMPL_RELEASE_INHERITED(InvokeEvent, Event)
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(InvokeEvent)
+NS_INTERFACE_MAP_END_INHERITING(Event)
+
+JSObject* InvokeEvent::WrapObjectInternal(JSContext* aCx,
+ JS::Handle<JSObject*> aGivenProto) {
+ return InvokeEvent_Binding::Wrap(aCx, this, aGivenProto);
+}
+
+already_AddRefed<InvokeEvent> InvokeEvent::Constructor(
+ mozilla::dom::EventTarget* aOwner, const nsAString& aType,
+ const InvokeEventInit& aEventInitDict) {
+ RefPtr<InvokeEvent> e = new InvokeEvent(aOwner);
+ bool trusted = e->Init(aOwner);
+ e->InitEvent(aType, aEventInitDict.mBubbles, aEventInitDict.mCancelable);
+ e->mInvoker = aEventInitDict.mInvoker;
+ e->mAction = aEventInitDict.mAction;
+ e->SetTrusted(trusted);
+ e->SetComposed(aEventInitDict.mComposed);
+ return e.forget();
+}
+
+already_AddRefed<InvokeEvent> InvokeEvent::Constructor(
+ const GlobalObject& aGlobal, const nsAString& aType,
+ const InvokeEventInit& aEventInitDict) {
+ nsCOMPtr<mozilla::dom::EventTarget> owner =
+ do_QueryInterface(aGlobal.GetAsSupports());
+ return Constructor(owner, aType, aEventInitDict);
+}
+
+Element* InvokeEvent::GetInvoker() {
+ EventTarget* currentTarget = GetCurrentTarget();
+ if (currentTarget) {
+ nsINode* retargeted = nsContentUtils::Retarget(
+ static_cast<nsINode*>(mInvoker), currentTarget->GetAsNode());
+ return retargeted->AsElement();
+ }
+ MOZ_ASSERT(!mEvent->mFlags.mIsBeingDispatched);
+ return mInvoker;
+}
+
+} // namespace mozilla::dom