Bug 1892041 - Part 1: Update test262 features. r=spidermonkey-reviewers,dminor
[gecko.git] / dom / debugger / EventCallbackDebuggerNotification.cpp
blob049d57f86848289c2bb3646234c3ac37e7c99a1d
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"
14 #include "nsINode.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,
33 aGivenProto);
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) {
47 if (!mEventTarget) {
48 MOZ_ASSERT(false, "target should exist");
49 return;
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