1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "EventCallbackDebuggerNotification.h"
9 #include "DebuggerNotificationManager.h"
10 #include "mozilla/dom/EventTarget.h"
11 #include "mozilla/dom/Worker.h"
12 #include "mozilla/dom/XMLHttpRequestEventTarget.h"
13 #include "nsIGlobalObject.h"
15 #include "nsQueryObject.h"
17 namespace mozilla::dom
{
19 NS_IMPL_CYCLE_COLLECTION_INHERITED(EventCallbackDebuggerNotification
,
20 CallbackDebuggerNotification
, mEvent
)
22 NS_IMPL_ADDREF_INHERITED(EventCallbackDebuggerNotification
,
23 CallbackDebuggerNotification
)
24 NS_IMPL_RELEASE_INHERITED(EventCallbackDebuggerNotification
,
25 CallbackDebuggerNotification
)
27 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(EventCallbackDebuggerNotification
)
28 NS_INTERFACE_MAP_END_INHERITING(CallbackDebuggerNotification
)
30 JSObject
* EventCallbackDebuggerNotification::WrapObject(
31 JSContext
* aCx
, JS::Handle
<JSObject
*> aGivenProto
) {
32 return EventCallbackDebuggerNotification_Binding::Wrap(aCx
, this,
36 already_AddRefed
<DebuggerNotification
>
37 EventCallbackDebuggerNotification::CloneInto(nsIGlobalObject
* aNewOwner
) const {
38 RefPtr
<EventCallbackDebuggerNotification
> notification(
39 new EventCallbackDebuggerNotification(mDebuggeeGlobal
, mType
, mEvent
,
40 mTargetType
, mPhase
, aNewOwner
));
41 return notification
.forget();
44 void EventCallbackDebuggerNotificationGuard::DispatchToManager(
45 const RefPtr
<DebuggerNotificationManager
>& aManager
,
46 CallbackDebuggerNotificationPhase aPhase
) {
48 MOZ_ASSERT(false, "target should exist");
52 Maybe
<EventCallbackDebuggerNotificationType
> notificationType(
53 mEventTarget
->GetDebuggerNotificationType());
55 if (notificationType
) {
56 aManager
->Dispatch
<EventCallbackDebuggerNotification
>(
57 DebuggerNotificationType::DomEvent
,
58 // The DOM event will always be live during event dispatch.
59 MOZ_KnownLive(mEvent
), *notificationType
, aPhase
);
63 } // namespace mozilla::dom