diff --git a/dom/base/Attr.h b/dom/base/Attr.h index 95248a6e0b16..2acc5e9fefec 100644 --- a/dom/base/Attr.h +++ b/dom/base/Attr.h @@ -12,7 +12,6 @@ #define mozilla_dom_Attr_h #include "mozilla/Attributes.h" -#include "nsDOMAttributeMap.h" #include "nsINode.h" #include "nsString.h" #include "nsCOMPtr.h" diff --git a/dom/base/DirectionalityUtils.cpp b/dom/base/DirectionalityUtils.cpp index 00c11a593dba..39a156ee004a 100644 --- a/dom/base/DirectionalityUtils.cpp +++ b/dom/base/DirectionalityUtils.cpp @@ -224,7 +224,6 @@ namespace mozilla { using mozilla::dom::Element; -using mozilla::dom::HTMLSlotElement; using mozilla::dom::ShadowRoot; static nsIContent* GetParentOrHostOrSlot( diff --git a/dom/base/NodeUbiReporting.h b/dom/base/NodeUbiReporting.h index 27bfdfa6fc9b..86eb802a7baf 100644 --- a/dom/base/NodeUbiReporting.h +++ b/dom/base/NodeUbiReporting.h @@ -7,8 +7,6 @@ #ifndef dom_NodeUbiReporting_h #define dom_NodeUbiReporting_h -#include "Attr.h" -#include "Document.h" #include "nsIContent.h" #include "nsIContentInlines.h" #include "nsINode.h" diff --git a/dom/base/ThirdPartyUtil.cpp b/dom/base/ThirdPartyUtil.cpp index 0185c032a64f..1748c4d21f62 100644 --- a/dom/base/ThirdPartyUtil.cpp +++ b/dom/base/ThirdPartyUtil.cpp @@ -18,11 +18,9 @@ #include "nsReadableUtils.h" #include "nsThreadUtils.h" #include "mozilla/ClearOnShutdown.h" -#include "mozilla/dom/Document.h" #include "mozilla/Logging.h" #include "mozilla/StaticPtr.h" #include "mozilla/Unused.h" -#include "nsGlobalWindowOuter.h" #include "nsPIDOMWindow.h" NS_IMPL_ISUPPORTS(ThirdPartyUtil, mozIThirdPartyUtil) @@ -94,16 +92,6 @@ nsresult ThirdPartyUtil::IsThirdPartyInternal(const nsCString& aFirstDomain, return NS_OK; } -nsCString ThirdPartyUtil::GetBaseDomainFromWindow(nsPIDOMWindowOuter* aWindow) { - mozilla::dom::Document* doc = aWindow ? aWindow->GetExtantDoc() : nullptr; - - if (!doc) { - return EmptyCString(); - } - - return doc->GetBaseDomain(); -} - NS_IMETHODIMP ThirdPartyUtil::GetPrincipalFromWindow(mozIDOMWindowProxy* aWin, nsIPrincipal** result) { diff --git a/dom/base/ThirdPartyUtil.h b/dom/base/ThirdPartyUtil.h index 9710891a3cdb..525e6ccf5a1f 100644 --- a/dom/base/ThirdPartyUtil.h +++ b/dom/base/ThirdPartyUtil.h @@ -14,7 +14,6 @@ #include "mozilla/Attributes.h" class nsIURI; -class nsPIDOMWindowOuter; class ThirdPartyUtil final : public mozIThirdPartyUtil { public: @@ -37,7 +36,15 @@ class ThirdPartyUtil final : public mozIThirdPartyUtil { nsresult IsThirdPartyInternal(const nsCString& aFirstDomain, nsIURI* aSecondURI, bool* aResult); - nsCString GetBaseDomainFromWindow(nsPIDOMWindowOuter* aWindow); + nsCString GetBaseDomainFromWindow(nsPIDOMWindowOuter* aWindow) { + mozilla::dom::Document* doc = aWindow ? aWindow->GetExtantDoc() : nullptr; + + if (!doc) { + return EmptyCString(); + } + + return doc->GetBaseDomain(); + } RefPtr mTLDService; }; diff --git a/dom/base/nsDOMAttributeMap.h b/dom/base/nsDOMAttributeMap.h index e852d5cabd9f..8cb73617d12b 100644 --- a/dom/base/nsDOMAttributeMap.h +++ b/dom/base/nsDOMAttributeMap.h @@ -12,6 +12,7 @@ #define nsDOMAttributeMap_h #include "mozilla/MemoryReporting.h" +#include "mozilla/dom/Attr.h" #include "mozilla/ErrorResult.h" #include "nsCycleCollectionParticipant.h" #include "nsRefPtrHashtable.h" @@ -19,15 +20,10 @@ #include "nsWrapperCache.h" class nsAtom; -class nsINode; namespace mozilla { namespace dom { -class Attr; class DocGroup; -class Document; -class Element; -class NodeInfo; } // namespace dom } // namespace mozilla diff --git a/dom/base/nsDataDocumentContentPolicy.cpp b/dom/base/nsDataDocumentContentPolicy.cpp index e9f3739cf3fd..22522649e0bb 100644 --- a/dom/base/nsDataDocumentContentPolicy.cpp +++ b/dom/base/nsDataDocumentContentPolicy.cpp @@ -11,7 +11,6 @@ */ #include "nsContentUtils.h" -#include "nsContentPolicyUtils.h" #include "nsDataDocumentContentPolicy.h" #include "nsNetUtil.h" #include "nsIProtocolHandler.h" @@ -41,7 +40,7 @@ nsDataDocumentContentPolicy::ShouldLoad(nsIURI* aContentLocation, nsILoadInfo* aLoadInfo, const nsACString& aMimeGuess, int16_t* aDecision) { - auto setBlockingReason = mozilla::MakeScopeExit([&]() { + auto setBlockingReason = MakeScopeExit([&]() { if (NS_CP_REJECTED(*aDecision)) { NS_SetRequestBlockingReason( aLoadInfo, nsILoadInfo::BLOCKING_REASON_CONTENT_POLICY_DATA_DOCUMENT); diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index d50eccbede40..e5c6f0e3ac55 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -17,9 +17,7 @@ #include "nsHistory.h" #include "nsDOMNavigationTiming.h" #include "nsIDOMStorageManager.h" -#include "mozilla/dom/CallbackDebuggerNotification.h" #include "mozilla/dom/ContentFrameMessageManager.h" -#include "mozilla/dom/DebuggerNotification.h" #include "mozilla/dom/DocumentInlines.h" #include "mozilla/dom/DOMJSProxyHandler.h" #include "mozilla/dom/EventTarget.h" @@ -1375,8 +1373,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGlobalWindowInner) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCacheStorage) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mVRDisplays) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDebuggerNotificationManager) - // Traverse stuff from nsPIDOMWindow NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mChromeEventHandler) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mParentTarget) @@ -1475,8 +1471,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindowInner) NS_IMPL_CYCLE_COLLECTION_UNLINK(mCacheStorage) NS_IMPL_CYCLE_COLLECTION_UNLINK(mVRDisplays) - NS_IMPL_CYCLE_COLLECTION_UNLINK(mDebuggerNotificationManager) - // Unlink stuff from nsPIDOMWindow NS_IMPL_CYCLE_COLLECTION_UNLINK(mChromeEventHandler) NS_IMPL_CYCLE_COLLECTION_UNLINK(mParentTarget) @@ -3298,9 +3292,6 @@ int32_t nsGlobalWindowInner::RequestAnimationFrame( js::NotifyAnimationActivity(GetWrapperPreserveColor()); } - DebuggerNotificationDispatch(this, - DebuggerNotificationType::RequestAnimationFrame); - int32_t handle; aError = mDoc->ScheduleFrameRequestCallback(aCallback, &handle); return handle; @@ -3312,9 +3303,6 @@ void nsGlobalWindowInner::CancelAnimationFrame(int32_t aHandle, return; } - DebuggerNotificationDispatch(this, - DebuggerNotificationType::CancelAnimationFrame); - mDoc->CancelFrameRequestCallback(aHandle); } @@ -3745,16 +3733,12 @@ void nsGlobalWindowInner::MozScrollSnap() { } void nsGlobalWindowInner::ClearTimeout(int32_t aHandle) { - DebuggerNotificationDispatch(this, DebuggerNotificationType::ClearTimeout); - if (aHandle > 0) { mTimeoutManager->ClearTimeout(aHandle, Timeout::Reason::eTimeoutOrInterval); } } void nsGlobalWindowInner::ClearInterval(int32_t aHandle) { - DebuggerNotificationDispatch(this, DebuggerNotificationType::ClearInterval); - if (aHandle > 0) { mTimeoutManager->ClearTimeout(aHandle, Timeout::Reason::eTimeoutOrInterval); } @@ -4022,20 +4006,6 @@ EventListenerManager* nsGlobalWindowInner::GetExistingListenerManager() const { return mListenerManager; } -mozilla::dom::DebuggerNotificationManager* -nsGlobalWindowInner::GetOrCreateDebuggerNotificationManager() { - if (!mDebuggerNotificationManager) { - mDebuggerNotificationManager = new DebuggerNotificationManager(this); - } - - return mDebuggerNotificationManager; -} - -mozilla::dom::DebuggerNotificationManager* -nsGlobalWindowInner::GetExistingDebuggerNotificationManager() { - return mDebuggerNotificationManager; -} - //***************************************************************************** // nsGlobalWindowInner::nsPIDOMWindow //***************************************************************************** @@ -5731,15 +5701,10 @@ int32_t nsGlobalWindowInner::SetTimeoutOrInterval( } if (inner != this) { - RefPtr innerRef(inner); - return innerRef->SetTimeoutOrInterval(aCx, aFunction, aTimeout, aArguments, - aIsInterval, aError); + return inner->SetTimeoutOrInterval(aCx, aFunction, aTimeout, aArguments, + aIsInterval, aError); } - DebuggerNotificationDispatch( - this, aIsInterval ? DebuggerNotificationType::SetInterval - : DebuggerNotificationType::SetTimeout); - nsCOMPtr handler = NS_CreateJSTimeoutHandler(aCx, this, aFunction, aArguments, aError); if (!handler) { @@ -5764,15 +5729,10 @@ int32_t nsGlobalWindowInner::SetTimeoutOrInterval(JSContext* aCx, } if (inner != this) { - RefPtr innerRef(inner); - return innerRef->SetTimeoutOrInterval(aCx, aHandler, aTimeout, aIsInterval, - aError); + return inner->SetTimeoutOrInterval(aCx, aHandler, aTimeout, aIsInterval, + aError); } - DebuggerNotificationDispatch( - this, aIsInterval ? DebuggerNotificationType::SetInterval - : DebuggerNotificationType::SetTimeout); - nsCOMPtr handler = NS_CreateJSTimeoutHandler(aCx, this, aHandler, aError); if (!handler) { @@ -5820,10 +5780,6 @@ bool nsGlobalWindowInner::RunTimeoutHandler(Timeout* aTimeout, reason = "setTimeout handler"; } - auto timerNotificationType = - timeout->mIsInterval ? DebuggerNotificationType::SetIntervalCallback - : DebuggerNotificationType::SetTimeoutCallback; - bool abortIntervalHandler = false; nsCOMPtr handler( do_QueryInterface(timeout->mScriptHandler)); @@ -5857,8 +5813,6 @@ bool nsGlobalWindowInner::RunTimeoutHandler(Timeout* aTimeout, initiatingScript->AssociateWithScript(script); } - CallbackDebuggerNotificationGuard guard(this, timerNotificationType); - rv = exec.ExecScript(); } } @@ -5871,13 +5825,7 @@ bool nsGlobalWindowInner::RunTimeoutHandler(Timeout* aTimeout, nsCOMPtr me(static_cast(this)); ErrorResult rv; JS::Rooted ignoredVal(RootingCx()); - - { - CallbackDebuggerNotificationGuard guard(this, timerNotificationType); - - callback->Call(me, handler->GetArgs(), &ignoredVal, rv, reason); - } - + callback->Call(me, handler->GetArgs(), &ignoredVal, rv, reason); if (rv.IsUncatchableException()) { abortIntervalHandler = true; } @@ -5888,9 +5836,6 @@ bool nsGlobalWindowInner::RunTimeoutHandler(Timeout* aTimeout, nsCOMPtr basicHandler(timeout->mScriptHandler); nsCOMPtr kungFuDeathGrip(static_cast(this)); mozilla::Unused << kungFuDeathGrip; - - CallbackDebuggerNotificationGuard guard(this, timerNotificationType); - basicHandler->Call(); } diff --git a/dom/base/nsGlobalWindowInner.h b/dom/base/nsGlobalWindowInner.h index 7359b2f22fa5..79a582cc66f3 100644 --- a/dom/base/nsGlobalWindowInner.h +++ b/dom/base/nsGlobalWindowInner.h @@ -36,7 +36,6 @@ #include "prclist.h" #include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/ChromeMessageBroadcaster.h" -#include "mozilla/dom/DebuggerNotificationManager.h" #include "mozilla/dom/NavigatorBinding.h" #include "mozilla/dom/StorageEvent.h" #include "mozilla/dom/StorageEventBinding.h" @@ -285,12 +284,6 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget, virtual mozilla::EventListenerManager* GetOrCreateListenerManager() override; - mozilla::Maybe - GetDebuggerNotificationType() const override { - return mozilla::Some( - mozilla::dom::EventCallbackDebuggerNotificationType::Global); - } - bool ComputeDefaultWantsUntrusted(mozilla::ErrorResult& aRv) final; virtual nsPIDOMWindowOuter* GetOwnerGlobalForBindingsInternal() override; @@ -324,12 +317,6 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget, virtual bool IsFrozen() const override; void SyncStateFromParentWindow(); - mozilla::dom::DebuggerNotificationManager* - GetOrCreateDebuggerNotificationManager() override; - - mozilla::dom::DebuggerNotificationManager* - GetExistingDebuggerNotificationManager() override; - mozilla::Maybe GetClientInfo() const override; mozilla::Maybe GetClientState() const; mozilla::Maybe GetController() @@ -694,35 +681,23 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget, const mozilla::dom::WindowPostMessageOptions& aOptions, nsIPrincipal& aSubjectPrincipal, mozilla::ErrorResult& aError); - - MOZ_CAN_RUN_SCRIPT int32_t SetTimeout(JSContext* aCx, mozilla::dom::Function& aFunction, int32_t aTimeout, const mozilla::dom::Sequence& aArguments, mozilla::ErrorResult& aError); - - MOZ_CAN_RUN_SCRIPT int32_t SetTimeout(JSContext* aCx, const nsAString& aHandler, int32_t aTimeout, const mozilla::dom::Sequence& /* unused */, mozilla::ErrorResult& aError); - - MOZ_CAN_RUN_SCRIPT void ClearTimeout(int32_t aHandle); - - MOZ_CAN_RUN_SCRIPT int32_t SetInterval(JSContext* aCx, mozilla::dom::Function& aFunction, const int32_t aTimeout, const mozilla::dom::Sequence& aArguments, mozilla::ErrorResult& aError); - - MOZ_CAN_RUN_SCRIPT int32_t SetInterval(JSContext* aCx, const nsAString& aHandler, const int32_t aTimeout, const mozilla::dom::Sequence& /* unused */, mozilla::ErrorResult& aError); - - MOZ_CAN_RUN_SCRIPT void ClearInterval(int32_t aHandle); void GetOrigin(nsAString& aOrigin); void Atob(const nsAString& aAsciiBase64String, nsAString& aBinaryData, @@ -819,12 +794,8 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget, void SetOuterHeight(JSContext* aCx, JS::Handle aValue, mozilla::dom::CallerType aCallerType, mozilla::ErrorResult& aError); - - MOZ_CAN_RUN_SCRIPT int32_t RequestAnimationFrame(mozilla::dom::FrameRequestCallback& aCallback, mozilla::ErrorResult& aError); - - MOZ_CAN_RUN_SCRIPT void CancelAnimationFrame(int32_t aHandle, mozilla::ErrorResult& aError); uint32_t RequestIdleCallback(JSContext* aCx, @@ -1088,13 +1059,10 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget, public: // Timeout Functions // |interval| is in milliseconds. - MOZ_CAN_RUN_SCRIPT int32_t SetTimeoutOrInterval( JSContext* aCx, mozilla::dom::Function& aFunction, int32_t aTimeout, const mozilla::dom::Sequence& aArguments, bool aIsInterval, mozilla::ErrorResult& aError); - - MOZ_CAN_RUN_SCRIPT int32_t SetTimeoutOrInterval(JSContext* aCx, const nsAString& aHandler, int32_t aTimeout, bool aIsInterval, mozilla::ErrorResult& aError); @@ -1349,9 +1317,6 @@ class nsGlobalWindowInner final : public mozilla::dom::EventTarget, nsCOMPtr mDocumentStoragePrincipal; nsCOMPtr mDocumentCsp; - RefPtr - mDebuggerNotificationManager; - // mBrowserChild is only ever populated in the content process. nsCOMPtr mBrowserChild; diff --git a/dom/base/nsIGlobalObject.h b/dom/base/nsIGlobalObject.h index ccaf46003d2c..aca2c3297f9b 100644 --- a/dom/base/nsIGlobalObject.h +++ b/dom/base/nsIGlobalObject.h @@ -35,7 +35,6 @@ namespace mozilla { class DOMEventTargetHelper; namespace dom { class VoidFunction; -class DebuggerNotificationManager; class ServiceWorker; class ServiceWorkerRegistration; class ServiceWorkerRegistrationDescriptor; @@ -132,16 +131,6 @@ class nsIGlobalObject : public nsISupports, virtual bool IsInSyncOperation() { return false; } - virtual mozilla::dom::DebuggerNotificationManager* - GetOrCreateDebuggerNotificationManager() { - return nullptr; - } - - virtual mozilla::dom::DebuggerNotificationManager* - GetExistingDebuggerNotificationManager() { - return nullptr; - } - virtual mozilla::Maybe GetClientInfo() const; virtual mozilla::Maybe GetController() diff --git a/dom/base/nsINode.h b/dom/base/nsINode.h index 26d9ca2af9eb..b4ff63f51509 100644 --- a/dom/base/nsINode.h +++ b/dom/base/nsINode.h @@ -940,12 +940,6 @@ class nsINode : public mozilla::dom::EventTarget { const override; virtual mozilla::EventListenerManager* GetOrCreateListenerManager() override; - mozilla::Maybe - GetDebuggerNotificationType() const override { - return mozilla::Some( - mozilla::dom::EventCallbackDebuggerNotificationType::Node); - } - bool ComputeDefaultWantsUntrusted(mozilla::ErrorResult& aRv) final; virtual bool IsApzAware() const override; diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index e5bdd80974fb..4e46bbe4824d 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -201,13 +201,6 @@ DOMInterfaces = { 'implicitJSContext': ['define'], }, -'DebuggerNotification': { - 'concrete': True, -}, -'CallbackDebuggerNotification': { - 'concrete': True, -}, - 'DedicatedWorkerGlobalScope': { 'headerFile': 'mozilla/dom/WorkerScope.h', }, diff --git a/dom/chrome-webidl/DebuggerNotification.webidl b/dom/chrome-webidl/DebuggerNotification.webidl deleted file mode 100644 index 7487e4688df6..000000000000 --- a/dom/chrome-webidl/DebuggerNotification.webidl +++ /dev/null @@ -1,57 +0,0 @@ -/* 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/. */ - -enum DebuggerNotificationType { - // DebuggerNotification - "setTimeout", - "clearTimeout", - "setInterval", - "clearInterval", - "requestAnimationFrame", - "cancelAnimationFrame", - - // CallbackDebuggerNotification - "setTimeoutCallback", - "setIntervalCallback", - "requestAnimationFrameCallback", - - // EventCallbackDebuggerNotification - "domEvent", -}; - -[ChromeOnly] -interface DebuggerNotification { - readonly attribute DebuggerNotificationType type; - - // The global object that has triggered the notification. - readonly attribute object global; -}; - -// For DOM events, we send notifications just before, and just after the -// event handler has been dispatched so that listeners -enum CallbackDebuggerNotificationPhase { - "pre", - "post", -}; - -// A base notification type for notifications that are dispatched as pairs with -// a before and after notification. -[ChromeOnly] -interface CallbackDebuggerNotification : DebuggerNotification { - readonly attribute CallbackDebuggerNotificationPhase phase; -}; - -enum EventCallbackDebuggerNotificationType { - "global", - "node", - "xhr", - "worker", -}; - -// A notification that about the engine calling a DOM event handler. -[ChromeOnly] -interface EventCallbackDebuggerNotification : CallbackDebuggerNotification { - readonly attribute Event event; - readonly attribute EventCallbackDebuggerNotificationType targetType; -}; diff --git a/dom/chrome-webidl/DebuggerNotificationObserver.webidl b/dom/chrome-webidl/DebuggerNotificationObserver.webidl deleted file mode 100644 index 5494d95bfd5b..000000000000 --- a/dom/chrome-webidl/DebuggerNotificationObserver.webidl +++ /dev/null @@ -1,28 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; 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/. - */ - -callback DebuggerNotificationCallback = void (DebuggerNotification n); - -[ChromeOnly, Constructor, Exposed=(Window, Worker)] -interface DebuggerNotificationObserver { - // Throws if the object is not a browser global or does not support - // debugger notifications. - // Returns false if already connected to this global. - [Throws] - boolean connect(object global); - - // Throws if the object is not a browser global or does not support - // debugger notifications. - // Returns false if not connected to this global. - [Throws] - boolean disconnect(object global); - - // Returns false if listener already added. - boolean addListener(DebuggerNotificationCallback handler); - - // Returns false if listener was not found. - boolean removeListener(DebuggerNotificationCallback handler); -}; diff --git a/dom/chrome-webidl/moz.build b/dom/chrome-webidl/moz.build index 2200a1a7e9db..de0e1a302d0a 100644 --- a/dom/chrome-webidl/moz.build +++ b/dom/chrome-webidl/moz.build @@ -35,8 +35,6 @@ PREPROCESSED_WEBIDL_FILES = [ WEBIDL_FILES = [ 'BrowsingContext.webidl', 'ChannelWrapper.webidl', - 'DebuggerNotification.webidl', - 'DebuggerNotificationObserver.webidl', 'DocumentL10n.webidl', 'DominatorTree.webidl', 'DOMLocalization.webidl', diff --git a/dom/debugger/CallbackDebuggerNotification.cpp b/dom/debugger/CallbackDebuggerNotification.cpp deleted file mode 100644 index 71c6ea0f6038..000000000000 --- a/dom/debugger/CallbackDebuggerNotification.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- 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 "CallbackDebuggerNotification.h" - -namespace mozilla { -namespace dom { - -NS_IMPL_CYCLE_COLLECTION_INHERITED(CallbackDebuggerNotification, - DebuggerNotification) - -NS_IMPL_ADDREF_INHERITED(CallbackDebuggerNotification, DebuggerNotification) -NS_IMPL_RELEASE_INHERITED(CallbackDebuggerNotification, DebuggerNotification) - -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(CallbackDebuggerNotification) -NS_INTERFACE_MAP_END_INHERITING(DebuggerNotification) - -JSObject* CallbackDebuggerNotification::WrapObject( - JSContext* aCx, JS::Handle aGivenProto) { - return CallbackDebuggerNotification_Binding::Wrap(aCx, this, aGivenProto); -} - -already_AddRefed CallbackDebuggerNotification::CloneInto( - nsIGlobalObject* aNewOwner) const { - RefPtr notification( - new CallbackDebuggerNotification(mDebuggeeGlobal, mType, mPhase, - aNewOwner)); - return notification.forget(); -} - -} // namespace dom -} // namespace mozilla diff --git a/dom/debugger/CallbackDebuggerNotification.h b/dom/debugger/CallbackDebuggerNotification.h deleted file mode 100644 index deab8142d537..000000000000 --- a/dom/debugger/CallbackDebuggerNotification.h +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- 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/. */ - -#ifndef mozilla_dom_CallbackDebuggerNotification_h -#define mozilla_dom_CallbackDebuggerNotification_h - -#include "DebuggerNotification.h" -#include "DebuggerNotificationManager.h" - -namespace mozilla { -namespace dom { - -class CallbackDebuggerNotification : public DebuggerNotification { - public: - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CallbackDebuggerNotification, - DebuggerNotification) - - CallbackDebuggerNotification(nsIGlobalObject* aDebuggeeGlobal, - DebuggerNotificationType aType, - CallbackDebuggerNotificationPhase aPhase, - nsIGlobalObject* aOwnerGlobal = nullptr) - : DebuggerNotification(aDebuggeeGlobal, aType, aOwnerGlobal), - mPhase(aPhase) {} - - // nsWrapperCache - virtual JSObject* WrapObject(JSContext* aCx, - JS::Handle aGivenProto) override; - - already_AddRefed CloneInto( - nsIGlobalObject* aNewOwner) const override; - - CallbackDebuggerNotificationPhase Phase() const { return mPhase; } - - protected: - ~CallbackDebuggerNotification() = default; - - CallbackDebuggerNotificationPhase mPhase; -}; - -class MOZ_RAII CallbackDebuggerNotificationGuard final { - public: - MOZ_CAN_RUN_SCRIPT CallbackDebuggerNotificationGuard( - nsIGlobalObject* aDebuggeeGlobal, DebuggerNotificationType aType) - : mDebuggeeGlobal(aDebuggeeGlobal), mType(aType) { - Dispatch(CallbackDebuggerNotificationPhase::Pre); - } - CallbackDebuggerNotificationGuard(const CallbackDebuggerNotificationGuard&) = - delete; - CallbackDebuggerNotificationGuard(CallbackDebuggerNotificationGuard&&) = - delete; - CallbackDebuggerNotificationGuard& operator=( - const CallbackDebuggerNotificationGuard&) = delete; - CallbackDebuggerNotificationGuard& operator=( - CallbackDebuggerNotificationGuard&&) = delete; - - MOZ_CAN_RUN_SCRIPT ~CallbackDebuggerNotificationGuard() { - Dispatch(CallbackDebuggerNotificationPhase::Post); - } - - private: - MOZ_CAN_RUN_SCRIPT void Dispatch(CallbackDebuggerNotificationPhase aPhase) { - auto manager = DebuggerNotificationManager::ForDispatch(mDebuggeeGlobal); - if (MOZ_UNLIKELY(manager)) { - manager->Dispatch(mType, aPhase); - } - } - - nsIGlobalObject* mDebuggeeGlobal; - DebuggerNotificationType mType; -}; - -} // namespace dom -} // namespace mozilla - -#endif // mozilla_dom_CallbackDebuggerNotification_h diff --git a/dom/debugger/DebuggerNotification.cpp b/dom/debugger/DebuggerNotification.cpp deleted file mode 100644 index f1de648cf220..000000000000 --- a/dom/debugger/DebuggerNotification.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- 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 "DebuggerNotification.h" - -#include "DebuggerNotificationManager.h" - -namespace mozilla { -namespace dom { - -NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DebuggerNotification, mDebuggeeGlobal, - mOwnerGlobal) - -NS_IMPL_CYCLE_COLLECTING_ADDREF(DebuggerNotification) -NS_IMPL_CYCLE_COLLECTING_RELEASE(DebuggerNotification) - -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DebuggerNotification) - NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY - NS_INTERFACE_MAP_ENTRY(nsISupports) -NS_INTERFACE_MAP_END - -JSObject* DebuggerNotification::WrapObject(JSContext* aCx, - JS::Handle aGivenProto) { - return DebuggerNotification_Binding::Wrap(aCx, this, aGivenProto); -} - -already_AddRefed DebuggerNotification::CloneInto( - nsIGlobalObject* aNewOwner) const { - RefPtr notification( - new DebuggerNotification(mDebuggeeGlobal, mType, aNewOwner)); - return notification.forget(); -} - -} // namespace dom -} // namespace mozilla diff --git a/dom/debugger/DebuggerNotification.h b/dom/debugger/DebuggerNotification.h deleted file mode 100644 index c4f34b460bcd..000000000000 --- a/dom/debugger/DebuggerNotification.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- 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/. */ - -#ifndef mozilla_dom_DebuggerNotification_h -#define mozilla_dom_DebuggerNotification_h - -#include "DebuggerNotificationManager.h" -#include "mozilla/dom/DebuggerNotificationBinding.h" -#include "nsIGlobalObject.h" -#include "nsISupports.h" -#include "nsWrapperCache.h" - -namespace mozilla { -namespace dom { - -class DebuggerNotification : public nsISupports, public nsWrapperCache { - public: - NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DebuggerNotification) - - DebuggerNotification(nsIGlobalObject* aDebuggeeGlobal, - DebuggerNotificationType aType, - nsIGlobalObject* aOwnerGlobal = nullptr) - : mType(aType), - mDebuggeeGlobal(aDebuggeeGlobal), - mOwnerGlobal(aOwnerGlobal){}; - - nsIGlobalObject* GetParentObject() const { - MOZ_ASSERT(mOwnerGlobal, - "Notification must be cloned into an observer global before " - "being wrapped"); - return mOwnerGlobal; - } - - DebuggerNotificationType Type() const { return mType; } - - void GetGlobal(JSContext* aCx, JS::MutableHandle aResult) { - aResult.set(mDebuggeeGlobal->GetGlobalJSObject()); - } - - virtual already_AddRefed CloneInto( - nsIGlobalObject* aNewOwner) const; - - // nsWrapperCache - virtual JSObject* WrapObject(JSContext* aCx, - JS::Handle aGivenProto) override; - - protected: - virtual ~DebuggerNotification() = default; - - DebuggerNotificationType mType; - nsCOMPtr mDebuggeeGlobal; - - private: - nsCOMPtr mOwnerGlobal; -}; - -MOZ_CAN_RUN_SCRIPT inline void DebuggerNotificationDispatch( - nsIGlobalObject* aDebuggeeGlobal, DebuggerNotificationType aType) { - auto manager = DebuggerNotificationManager::ForDispatch(aDebuggeeGlobal); - if (MOZ_UNLIKELY(manager)) { - manager->Dispatch(aType); - } -} - -} // namespace dom -} // namespace mozilla - -#endif // mozilla_dom_DebuggerNotification_h diff --git a/dom/debugger/DebuggerNotificationManager.cpp b/dom/debugger/DebuggerNotificationManager.cpp deleted file mode 100644 index 4e13838f1450..000000000000 --- a/dom/debugger/DebuggerNotificationManager.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- 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 "DebuggerNotificationManager.h" - -#include "mozilla/ScopeExit.h" -#include "nsIGlobalObject.h" - -namespace mozilla { -namespace dom { - -NS_IMPL_CYCLE_COLLECTION(DebuggerNotificationManager, mDebuggeeGlobal, - mNotificationObservers) - -NS_IMPL_CYCLE_COLLECTING_ADDREF(DebuggerNotificationManager) -NS_IMPL_CYCLE_COLLECTING_RELEASE(DebuggerNotificationManager) - -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DebuggerNotificationManager) - NS_INTERFACE_MAP_ENTRY(nsISupports) -NS_INTERFACE_MAP_END - -NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(DebuggerNotificationManager) -NS_IMPL_CYCLE_COLLECTION_TRACE_END - -bool DebuggerNotificationManager::Attach( - DebuggerNotificationObserver* aObserver) { - RefPtr ptr(aObserver); - - if (mNotificationObservers.Contains(ptr)) { - return false; - } - - mNotificationObservers.AppendElement(ptr); - return true; -} -bool DebuggerNotificationManager::Detach( - DebuggerNotificationObserver* aObserver) { - RefPtr ptr(aObserver); - - return mNotificationObservers.RemoveElement(ptr); -} - -bool DebuggerNotificationManager::HasListeners() { - nsTObserverArray>::ForwardIterator iter( - mNotificationObservers); - - while (iter.HasMore()) { - RefPtr observer(iter.GetNext()); - if (observer->HasListeners()) { - return true; - } - } - - return false; -} - -void DebuggerNotificationManager::NotifyListeners( - DebuggerNotification* aNotification) { - nsTObserverArray>::ForwardIterator iter( - mNotificationObservers); - - while (iter.HasMore()) { - RefPtr observer(iter.GetNext()); - observer->NotifyListeners(aNotification); - } -} - -} // namespace dom -} // namespace mozilla diff --git a/dom/debugger/DebuggerNotificationManager.h b/dom/debugger/DebuggerNotificationManager.h deleted file mode 100644 index bed9dce85106..000000000000 --- a/dom/debugger/DebuggerNotificationManager.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- 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/. */ - -#ifndef mozilla_dom_DebuggerNotificationManager_h -#define mozilla_dom_DebuggerNotificationManager_h - -#include "DebuggerNotificationObserver.h" -#include "nsCycleCollectionParticipant.h" -#include "nsIGlobalObject.h" -#include "nsISupports.h" -#include "nsTObserverArray.h" - -namespace mozilla { -namespace dom { - -class DebuggerNotificationManager final : public nsISupports { - public: - NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DebuggerNotificationManager) - - static RefPtr ForDispatch( - nsIGlobalObject* aDebuggeeGlobal) { - if (MOZ_UNLIKELY(!aDebuggeeGlobal)) { - return nullptr; - } - auto managerPtr = aDebuggeeGlobal->GetExistingDebuggerNotificationManager(); - if (MOZ_LIKELY(!managerPtr) || !managerPtr->HasListeners()) { - return nullptr; - } - - return managerPtr; - } - - explicit DebuggerNotificationManager(nsIGlobalObject* aDebuggeeGlobal) - : mDebuggeeGlobal(aDebuggeeGlobal), mNotificationObservers() {} - - bool Attach(DebuggerNotificationObserver* aObserver); - bool Detach(DebuggerNotificationObserver* aObserver); - - bool HasListeners(); - - template - MOZ_CAN_RUN_SCRIPT void Dispatch(Args... aArgs) { - RefPtr notification(new T(mDebuggeeGlobal, aArgs...)); - NotifyListeners(notification); - } - - private: - ~DebuggerNotificationManager() = default; - - MOZ_CAN_RUN_SCRIPT void NotifyListeners(DebuggerNotification* aNotification); - - nsCOMPtr mDebuggeeGlobal; - nsTObserverArray> mNotificationObservers; -}; - -} // namespace dom -} // namespace mozilla - -#endif // mozilla_dom_DebuggerNotificationManager_h diff --git a/dom/debugger/DebuggerNotificationObserver.cpp b/dom/debugger/DebuggerNotificationObserver.cpp deleted file mode 100644 index 75bd4a91cf2f..000000000000 --- a/dom/debugger/DebuggerNotificationObserver.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/* -*- 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 "DebuggerNotificationObserver.h" - -#include "DebuggerNotification.h" -#include "nsIGlobalObject.h" -#include "WrapperFactory.h" - -namespace mozilla { -namespace dom { - -NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DebuggerNotificationObserver, - mOwnerGlobal, mEventListenerCallbacks) - -NS_IMPL_CYCLE_COLLECTING_ADDREF(DebuggerNotificationObserver) -NS_IMPL_CYCLE_COLLECTING_RELEASE(DebuggerNotificationObserver) - -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DebuggerNotificationObserver) - NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY -NS_INTERFACE_MAP_END - -/* static */ already_AddRefed -DebuggerNotificationObserver::Constructor(GlobalObject& aGlobal, - ErrorResult& aRv) { - nsCOMPtr globalInterface( - do_QueryInterface(aGlobal.GetAsSupports())); - if (NS_WARN_IF(!globalInterface)) { - aRv.Throw(NS_ERROR_FAILURE); - return nullptr; - } - - RefPtr observer( - new DebuggerNotificationObserver(globalInterface)); - return observer.forget(); -} - -DebuggerNotificationObserver::DebuggerNotificationObserver( - nsIGlobalObject* aOwnerGlobal) - : mEventListenerCallbacks(), mOwnerGlobal(aOwnerGlobal) {} - -JSObject* DebuggerNotificationObserver::WrapObject( - JSContext* aCx, JS::Handle aGivenProto) { - return DebuggerNotificationObserver_Binding::Wrap(aCx, this, aGivenProto); -} - -static already_AddRefed GetManager( - JSContext* aCx, JS::Handle aDebuggeeGlobal) { - // The debuggee global here is likely a debugger-compartment cross-compartment - // wrapper for the debuggee global object, so we need to unwrap it to get - // the real debuggee-compartment global object. - JS::Rooted debuggeeGlobalRooted( - aCx, js::UncheckedUnwrap(aDebuggeeGlobal, false)); - - if (!debuggeeGlobalRooted) { - return nullptr; - } - - nsCOMPtr debuggeeGlobalObject( - xpc::NativeGlobal(debuggeeGlobalRooted)); - if (!debuggeeGlobalObject) { - return nullptr; - } - - RefPtr manager( - debuggeeGlobalObject->GetOrCreateDebuggerNotificationManager()); - return manager.forget(); -} - -bool DebuggerNotificationObserver::Connect( - JSContext* aCx, JS::Handle aDebuggeeGlobal, ErrorResult& aRv) { - RefPtr manager(GetManager(aCx, aDebuggeeGlobal)); - - if (!manager) { - aRv.Throw(NS_ERROR_FAILURE); - return false; - } - - return manager->Attach(this); -} - -bool DebuggerNotificationObserver::Disconnect( - JSContext* aCx, JS::Handle aDebuggeeGlobal, ErrorResult& aRv) { - RefPtr manager(GetManager(aCx, aDebuggeeGlobal)); - - if (!manager) { - aRv.Throw(NS_ERROR_FAILURE); - return false; - } - - return manager->Detach(this); -} - -bool DebuggerNotificationObserver::AddListener( - DebuggerNotificationCallback& aHandlerFn) { - nsTObserverArray>::ForwardIterator iter( - mEventListenerCallbacks); - while (iter.HasMore()) { - if (*iter.GetNext().get() == aHandlerFn) { - return false; - } - } - - RefPtr handlerFn(&aHandlerFn); - mEventListenerCallbacks.AppendElement(handlerFn); - return true; -} - -bool DebuggerNotificationObserver::RemoveListener( - DebuggerNotificationCallback& aHandlerFn) { - nsTObserverArray>::ForwardIterator iter( - mEventListenerCallbacks); - for (uint32_t i = 0; iter.HasMore(); i++) { - if (*iter.GetNext().get() == aHandlerFn) { - mEventListenerCallbacks.RemoveElementAt(i); - return true; - } - } - - return false; -} - -bool DebuggerNotificationObserver::HasListeners() { - return !mEventListenerCallbacks.IsEmpty(); -} - -void DebuggerNotificationObserver::NotifyListeners( - DebuggerNotification* aNotification) { - if (!HasListeners()) { - return; - } - - // Since we want the notification objects to live in the same compartment - // as the observer, we create a new instance of the notification before - // an observer dispatches the event listeners. - RefPtr debuggerNotification( - aNotification->CloneInto(mOwnerGlobal)); - - nsTObserverArray>::ForwardIterator iter( - mEventListenerCallbacks); - - while (iter.HasMore()) { - RefPtr cb(iter.GetNext()); - cb->Call(*debuggerNotification); - } -} - -} // namespace dom -} // namespace mozilla diff --git a/dom/debugger/DebuggerNotificationObserver.h b/dom/debugger/DebuggerNotificationObserver.h deleted file mode 100644 index 80ffcb084c7f..000000000000 --- a/dom/debugger/DebuggerNotificationObserver.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- 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/. */ - -#ifndef mozilla_dom_DebuggerNotificationObserver_h -#define mozilla_dom_DebuggerNotificationObserver_h - -#include "DebuggerNotificationManager.h" -#include "mozilla/dom/DebuggerNotificationObserverBinding.h" -#include "mozilla/RefPtr.h" -#include "nsTObserverArray.h" -#include "nsWrapperCache.h" - -class nsIGlobalObject; - -namespace mozilla { -namespace dom { - -class DebuggerNotification; - -class DebuggerNotificationObserver final : public nsISupports, - public nsWrapperCache { - public: - NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DebuggerNotificationObserver) - - static already_AddRefed Constructor( - GlobalObject& aGlobal, ErrorResult& aRv); - - nsIGlobalObject* GetParentObject() const { return mOwnerGlobal; } - - // nsWrapperCache - virtual JSObject* WrapObject(JSContext* aCx, - JS::Handle aGivenProto) override; - - bool Connect(JSContext* aCx, JS::Handle aDebuggeeGlobal, - ErrorResult& aRv); - bool Disconnect(JSContext* aCx, JS::Handle aDebuggeeGlobal, - ErrorResult& aRv); - - bool AddListener(DebuggerNotificationCallback& aHandlerFn); - bool RemoveListener(DebuggerNotificationCallback& aHandlerFn); - - bool HasListeners(); - - MOZ_CAN_RUN_SCRIPT void NotifyListeners(DebuggerNotification* aNotification); - - private: - explicit DebuggerNotificationObserver(nsIGlobalObject* aOwnerGlobal); - ~DebuggerNotificationObserver() = default; - - nsTObserverArray> - mEventListenerCallbacks; - nsCOMPtr mOwnerGlobal; -}; - -} // namespace dom -} // namespace mozilla - -#endif // mozilla_dom_DebuggerNotificationObserver_h diff --git a/dom/debugger/EventCallbackDebuggerNotification.cpp b/dom/debugger/EventCallbackDebuggerNotification.cpp deleted file mode 100644 index 14d3879f8c02..000000000000 --- a/dom/debugger/EventCallbackDebuggerNotification.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- 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 "EventCallbackDebuggerNotification.h" - -#include "DebuggerNotificationManager.h" -#include "mozilla/dom/EventTarget.h" -#include "mozilla/dom/Worker.h" -#include "mozilla/dom/XMLHttpRequestEventTarget.h" -#include "nsIGlobalObject.h" -#include "nsINode.h" -#include "nsQueryObject.h" - -namespace mozilla { -namespace dom { - -NS_IMPL_CYCLE_COLLECTION_INHERITED(EventCallbackDebuggerNotification, - CallbackDebuggerNotification, mEvent) - -NS_IMPL_ADDREF_INHERITED(EventCallbackDebuggerNotification, - CallbackDebuggerNotification) -NS_IMPL_RELEASE_INHERITED(EventCallbackDebuggerNotification, - CallbackDebuggerNotification) - -NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(EventCallbackDebuggerNotification) -NS_INTERFACE_MAP_END_INHERITING(CallbackDebuggerNotification) - -JSObject* EventCallbackDebuggerNotification::WrapObject( - JSContext* aCx, JS::Handle aGivenProto) { - return EventCallbackDebuggerNotification_Binding::Wrap(aCx, this, - aGivenProto); -} - -already_AddRefed -EventCallbackDebuggerNotification::CloneInto(nsIGlobalObject* aNewOwner) const { - RefPtr notification( - new EventCallbackDebuggerNotification(mDebuggeeGlobal, mType, mEvent, - mTargetType, mPhase, aNewOwner)); - return notification.forget(); -} - -void EventCallbackDebuggerNotificationGuard::DispatchToManager( - const RefPtr& aManager, - CallbackDebuggerNotificationPhase aPhase) { - if (!mEventTarget) { - MOZ_ASSERT(false, "target should exist"); - return; - } - - Maybe notificationType( - mEventTarget->GetDebuggerNotificationType()); - - if (notificationType) { - aManager->Dispatch( - DebuggerNotificationType::DomEvent, - // The DOM event will always be live during event dispatch. - MOZ_KnownLive(mEvent), *notificationType, aPhase); - } -} - -} // namespace dom -} // namespace mozilla diff --git a/dom/debugger/EventCallbackDebuggerNotification.h b/dom/debugger/EventCallbackDebuggerNotification.h deleted file mode 100644 index 34b0fa955417..000000000000 --- a/dom/debugger/EventCallbackDebuggerNotification.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- 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/. */ - -#ifndef mozilla_dom_EventCallbackDebuggerNotification_h -#define mozilla_dom_EventCallbackDebuggerNotification_h - -#include "CallbackDebuggerNotification.h" -#include "DebuggerNotificationManager.h" -#include "mozilla/dom/Event.h" -#include "mozilla/RefPtr.h" - -namespace mozilla { -namespace dom { - -class EventCallbackDebuggerNotification : public CallbackDebuggerNotification { - public: - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(EventCallbackDebuggerNotification, - CallbackDebuggerNotification) - - EventCallbackDebuggerNotification( - nsIGlobalObject* debuggeeGlobal, DebuggerNotificationType t, Event* event, - EventCallbackDebuggerNotificationType targetType, - CallbackDebuggerNotificationPhase phase, - nsIGlobalObject* ownerGlobal = nullptr) - : CallbackDebuggerNotification(debuggeeGlobal, t, phase, ownerGlobal), - mEvent(event), - mTargetType(targetType) {} - - // nsWrapperCache - virtual JSObject* WrapObject(JSContext* aCx, - JS::Handle aGivenProto) override; - - already_AddRefed CloneInto( - nsIGlobalObject* newOwner) const override; - - mozilla::dom::Event* Event() const { return mEvent; } - EventCallbackDebuggerNotificationType TargetType() const { - return mTargetType; - } - - private: - ~EventCallbackDebuggerNotification() = default; - - RefPtr mEvent; - EventCallbackDebuggerNotificationType mTargetType; -}; - -class MOZ_RAII EventCallbackDebuggerNotificationGuard final { - public: - MOZ_CAN_RUN_SCRIPT explicit EventCallbackDebuggerNotificationGuard( - mozilla::dom::EventTarget* aEventTarget, mozilla::dom::Event* aEvent) - : mDebuggeeGlobal(aEventTarget ? aEventTarget->GetOwnerGlobal() - : nullptr), - mEventTarget(aEventTarget), - mEvent(aEvent) { - Dispatch(CallbackDebuggerNotificationPhase::Pre); - } - EventCallbackDebuggerNotificationGuard( - const EventCallbackDebuggerNotificationGuard&) = delete; - EventCallbackDebuggerNotificationGuard( - EventCallbackDebuggerNotificationGuard&&) = delete; - EventCallbackDebuggerNotificationGuard& operator=( - const EventCallbackDebuggerNotificationGuard&) = delete; - EventCallbackDebuggerNotificationGuard& operator=( - EventCallbackDebuggerNotificationGuard&&) = delete; - - MOZ_CAN_RUN_SCRIPT ~EventCallbackDebuggerNotificationGuard() { - Dispatch(CallbackDebuggerNotificationPhase::Post); - } - - private: - MOZ_CAN_RUN_SCRIPT void Dispatch(CallbackDebuggerNotificationPhase aPhase) { - auto manager = DebuggerNotificationManager::ForDispatch(mDebuggeeGlobal); - if (MOZ_UNLIKELY(manager)) { - DispatchToManager(manager, aPhase); - } - } - - MOZ_CAN_RUN_SCRIPT void DispatchToManager( - const RefPtr& aManager, - CallbackDebuggerNotificationPhase aPhase); - - nsIGlobalObject* mDebuggeeGlobal; - mozilla::dom::EventTarget* mEventTarget; - mozilla::dom::Event* mEvent; -}; - -} // namespace dom -} // namespace mozilla - -#endif // mozilla_dom_EventCallbackDebuggerNotification_h diff --git a/dom/debugger/moz.build b/dom/debugger/moz.build deleted file mode 100644 index 0ebcd3c33deb..000000000000 --- a/dom/debugger/moz.build +++ /dev/null @@ -1,26 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# 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/. - -with Files("**"): - BUG_COMPONENT = ("DevTools", "Debugger") - -EXPORTS.mozilla.dom += [ - 'CallbackDebuggerNotification.h', - 'DebuggerNotification.h', - 'DebuggerNotificationManager.h', - 'DebuggerNotificationObserver.h', - 'EventCallbackDebuggerNotification.h', -] - -UNIFIED_SOURCES += [ - 'CallbackDebuggerNotification.cpp', - 'DebuggerNotification.cpp', - 'DebuggerNotificationManager.cpp', - 'DebuggerNotificationObserver.cpp', - 'EventCallbackDebuggerNotification.cpp', -] - -FINAL_LIBRARY = 'xul' \ No newline at end of file diff --git a/dom/events/EventListenerManager.cpp b/dom/events/EventListenerManager.cpp index 440a0c4969a9..de5063ab8df8 100644 --- a/dom/events/EventListenerManager.cpp +++ b/dom/events/EventListenerManager.cpp @@ -20,7 +20,6 @@ #include "mozilla/Preferences.h" #include "mozilla/PresShell.h" #include "mozilla/dom/BindingUtils.h" -#include "mozilla/dom/EventCallbackDebuggerNotification.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/Event.h" #include "mozilla/dom/EventTargetBinding.h" @@ -1015,7 +1014,6 @@ nsresult EventListenerManager::HandleEventSubType(Listener* aListener, } if (NS_SUCCEEDED(result)) { - EventCallbackDebuggerNotificationGuard dbgGuard(aCurrentTarget, aDOMEvent); nsAutoMicroTask mt; // Event::currentTarget is set in EventDispatcher. diff --git a/dom/events/EventTarget.h b/dom/events/EventTarget.h index e03ceb18ccab..7e122369cd6b 100644 --- a/dom/events/EventTarget.h +++ b/dom/events/EventTarget.h @@ -8,7 +8,6 @@ #define mozilla_dom_EventTarget_h_ #include "mozilla/dom/BindingDeclarations.h" -#include "mozilla/dom/DebuggerNotificationBinding.h" #include "mozilla/dom/Nullable.h" #include "nsISupports.h" #include "nsWrapperCache.h" @@ -196,11 +195,6 @@ class EventTarget : public nsISupports, public nsWrapperCache { */ virtual EventListenerManager* GetExistingListenerManager() const = 0; - virtual Maybe - GetDebuggerNotificationType() const { - return Nothing(); - } - // Called from AsyncEventDispatcher to notify it is running. virtual void AsyncEventRunning(AsyncEventDispatcher* aEvent) {} diff --git a/dom/moz.build b/dom/moz.build index 34b3e86d7417..ffd9742f73a7 100644 --- a/dom/moz.build +++ b/dom/moz.build @@ -44,7 +44,6 @@ DIRS += [ 'commandhandler', 'credentialmanagement', 'crypto', - 'debugger', 'encoding', 'events', 'fetch', diff --git a/dom/workers/RegisterBindings.cpp b/dom/workers/RegisterBindings.cpp index 3cdce4ba1157..f0e0f0a7fb97 100644 --- a/dom/workers/RegisterBindings.cpp +++ b/dom/workers/RegisterBindings.cpp @@ -9,7 +9,6 @@ #include "RuntimeService.h" #include "jsapi.h" -#include "mozilla/dom/DebuggerNotificationObserverBinding.h" #include "mozilla/dom/RegisterWorkerBindings.h" #include "mozilla/dom/RegisterWorkerDebuggerBindings.h" #include "mozilla/OSFileConstants.h" @@ -53,10 +52,6 @@ bool WorkerPrivate::RegisterDebuggerBindings(JSContext* aCx, return false; } - if (!DebuggerNotificationObserver_Binding::GetConstructorObject(aCx)) { - return false; - } - if (!JS_DefineDebuggerObject(aCx, aGlobal)) { return false; } diff --git a/dom/workers/Worker.h b/dom/workers/Worker.h index 5bd804efb7fe..ed0b9ed6e235 100644 --- a/dom/workers/Worker.h +++ b/dom/workers/Worker.h @@ -8,7 +8,6 @@ #define mozilla_dom_Worker_h #include "mozilla/Attributes.h" -#include "mozilla/dom/DebuggerNotificationBinding.h" #include "mozilla/DOMEventTargetHelper.h" #include "mozilla/RefPtr.h" #include "mozilla/WeakPtr.h" @@ -39,11 +38,6 @@ class Worker : public DOMEventTargetHelper, public SupportsWeakPtr { JSObject* WrapObject(JSContext* aCx, JS::Handle aGivenProto) override; - Maybe GetDebuggerNotificationType() - const override { - return Some(EventCallbackDebuggerNotificationType::Worker); - } - void PostMessage(JSContext* aCx, JS::Handle aMessage, const Sequence& aTransferable, ErrorResult& aRv); diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index 219c7e21a911..bc07c3e98dd3 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -17,7 +17,6 @@ #include "mozilla/ScopeExit.h" #include "mozilla/StaticPrefs.h" #include "mozilla/dom/BlobURLProtocolHandler.h" -#include "mozilla/dom/CallbackDebuggerNotification.h" #include "mozilla/dom/ClientManager.h" #include "mozilla/dom/ClientSource.h" #include "mozilla/dom/ClientState.h" @@ -4310,11 +4309,6 @@ bool WorkerPrivate::RunExpiredTimeouts(JSContext* aCx) { reason = "setTimeout handler"; } - auto timerNotificationType = - info->mIsInterval ? DebuggerNotificationType::SetIntervalCallback - : DebuggerNotificationType::SetTimeoutCallback; - - RefPtr scope = GlobalScope(); RefPtr callback = info->mHandler->GetCallback(); if (!callback) { nsAutoMicroTask mt; @@ -4334,9 +4328,6 @@ bool WorkerPrivate::RunExpiredTimeouts(JSContext* aCx) { JS::Rooted unused(aes.cx()); JS::SourceText srcBuf; - - CallbackDebuggerNotificationGuard guard(scope, timerNotificationType); - if (!srcBuf.init(aes.cx(), script.BeginReading(), script.Length(), JS::SourceOwnership::Borrowed) || !JS::Evaluate(aes.cx(), options, srcBuf, &unused)) { @@ -4348,13 +4339,8 @@ bool WorkerPrivate::RunExpiredTimeouts(JSContext* aCx) { } else { ErrorResult rv; JS::Rooted ignoredVal(aCx); - - { - CallbackDebuggerNotificationGuard guard(scope, timerNotificationType); - - callback->Call(scope, info->mHandler->GetArgs(), &ignoredVal, rv, - reason); - } + RefPtr scope = GlobalScope(); + callback->Call(scope, info->mHandler->GetArgs(), &ignoredVal, rv, reason); if (rv.IsUncatchableException()) { rv.SuppressException(); retval = false; diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp index 5e805c1e4838..26b016df697a 100644 --- a/dom/workers/WorkerScope.cpp +++ b/dom/workers/WorkerScope.cpp @@ -13,7 +13,6 @@ #include "mozilla/dom/Clients.h" #include "mozilla/dom/ClientState.h" #include "mozilla/dom/Console.h" -#include "mozilla/dom/DebuggerNotification.h" #include "mozilla/dom/DedicatedWorkerGlobalScopeBinding.h" #include "mozilla/dom/Fetch.h" #include "mozilla/dom/FunctionBinding.h" @@ -104,7 +103,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(WorkerGlobalScope, NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mNavigator) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mIndexedDB) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCacheStorage) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDebuggerNotificationManager) tmp->TraverseHostObjectURIs(cb); tmp->mWorkerPrivate->TraverseTimeouts(cb); NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END @@ -119,7 +117,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(WorkerGlobalScope, NS_IMPL_CYCLE_COLLECTION_UNLINK(mNavigator) NS_IMPL_CYCLE_COLLECTION_UNLINK(mIndexedDB) NS_IMPL_CYCLE_COLLECTION_UNLINK(mCacheStorage) - NS_IMPL_CYCLE_COLLECTION_UNLINK(mDebuggerNotificationManager) tmp->UnlinkHostObjectURIs(); tmp->mWorkerPrivate->UnlinkTimeouts(); NS_IMPL_CYCLE_COLLECTION_UNLINK_END @@ -259,8 +256,6 @@ int32_t WorkerGlobalScope::SetTimeout(JSContext* aCx, Function& aHandler, ErrorResult& aRv) { mWorkerPrivate->AssertIsOnWorkerThread(); - DebuggerNotificationDispatch(this, DebuggerNotificationType::SetTimeout); - nsCOMPtr handler = NS_CreateJSTimeoutHandler(aCx, mWorkerPrivate, aHandler, aArguments, aRv); if (!handler) { @@ -276,8 +271,6 @@ int32_t WorkerGlobalScope::SetTimeout(JSContext* aCx, const nsAString& aHandler, ErrorResult& aRv) { mWorkerPrivate->AssertIsOnWorkerThread(); - DebuggerNotificationDispatch(this, DebuggerNotificationType::SetTimeout); - nsCOMPtr handler = NS_CreateJSTimeoutHandler(aCx, mWorkerPrivate, aHandler, aRv); if (!handler) { @@ -289,9 +282,6 @@ int32_t WorkerGlobalScope::SetTimeout(JSContext* aCx, const nsAString& aHandler, void WorkerGlobalScope::ClearTimeout(int32_t aHandle) { mWorkerPrivate->AssertIsOnWorkerThread(); - - DebuggerNotificationDispatch(this, DebuggerNotificationType::ClearTimeout); - mWorkerPrivate->ClearTimeout(aHandle); } @@ -301,8 +291,6 @@ int32_t WorkerGlobalScope::SetInterval(JSContext* aCx, Function& aHandler, ErrorResult& aRv) { mWorkerPrivate->AssertIsOnWorkerThread(); - DebuggerNotificationDispatch(this, DebuggerNotificationType::SetInterval); - nsCOMPtr handler = NS_CreateJSTimeoutHandler(aCx, mWorkerPrivate, aHandler, aArguments, aRv); if (NS_WARN_IF(aRv.Failed())) { @@ -319,8 +307,6 @@ int32_t WorkerGlobalScope::SetInterval(JSContext* aCx, ErrorResult& aRv) { mWorkerPrivate->AssertIsOnWorkerThread(); - DebuggerNotificationDispatch(this, DebuggerNotificationType::SetInterval); - Sequence dummy; nsCOMPtr handler = @@ -334,9 +320,6 @@ int32_t WorkerGlobalScope::SetInterval(JSContext* aCx, void WorkerGlobalScope::ClearInterval(int32_t aHandle) { mWorkerPrivate->AssertIsOnWorkerThread(); - - DebuggerNotificationDispatch(this, DebuggerNotificationType::ClearInterval); - mWorkerPrivate->ClearTimeout(aHandle); } @@ -477,20 +460,6 @@ AbstractThread* WorkerGlobalScope::AbstractMainThreadFor( MOZ_CRASH("AbstractMainThreadFor not supported for workers."); } -mozilla::dom::DebuggerNotificationManager* -WorkerGlobalScope::GetOrCreateDebuggerNotificationManager() { - if (!mDebuggerNotificationManager) { - mDebuggerNotificationManager = new DebuggerNotificationManager(this); - } - - return mDebuggerNotificationManager; -} - -mozilla::dom::DebuggerNotificationManager* -WorkerGlobalScope::GetExistingDebuggerNotificationManager() { - return mDebuggerNotificationManager; -} - Maybe WorkerGlobalScope::GetClientInfo() const { return mWorkerPrivate->GetClientInfo(); } diff --git a/dom/workers/WorkerScope.h b/dom/workers/WorkerScope.h index 6c244344cb5d..0a178ede4fbf 100644 --- a/dom/workers/WorkerScope.h +++ b/dom/workers/WorkerScope.h @@ -10,7 +10,6 @@ #include "mozilla/Attributes.h" #include "mozilla/dom/WorkerCommon.h" #include "mozilla/DOMEventTargetHelper.h" -#include "mozilla/dom/DebuggerNotificationManager.h" #include "mozilla/dom/Headers.h" #include "mozilla/dom/RequestBinding.h" #include "nsWeakReference.h" @@ -61,8 +60,6 @@ class WorkerGlobalScope : public DOMEventTargetHelper, RefPtr mIndexedDB; RefPtr mCacheStorage; nsCOMPtr mSerialEventTarget; - RefPtr - mDebuggerNotificationManager; uint32_t mWindowInteractionsAllowed; @@ -110,25 +107,19 @@ class WorkerGlobalScope : public DOMEventTargetHelper, void ImportScripts(JSContext* aCx, const Sequence& aScriptURLs, ErrorResult& aRv); - MOZ_CAN_RUN_SCRIPT int32_t SetTimeout(JSContext* aCx, Function& aHandler, const int32_t aTimeout, const Sequence& aArguments, ErrorResult& aRv); - MOZ_CAN_RUN_SCRIPT int32_t SetTimeout(JSContext* aCx, const nsAString& aHandler, const int32_t aTimeout, const Sequence& /* unused */, ErrorResult& aRv); - MOZ_CAN_RUN_SCRIPT void ClearTimeout(int32_t aHandle); - MOZ_CAN_RUN_SCRIPT int32_t SetInterval(JSContext* aCx, Function& aHandler, const int32_t aTimeout, const Sequence& aArguments, ErrorResult& aRv); - MOZ_CAN_RUN_SCRIPT int32_t SetInterval(JSContext* aCx, const nsAString& aHandler, const int32_t aTimeout, const Sequence& /* unused */, ErrorResult& aRv); - MOZ_CAN_RUN_SCRIPT void ClearInterval(int32_t aHandle); void GetOrigin(nsAString& aOrigin) const; @@ -192,18 +183,6 @@ class WorkerGlobalScope : public DOMEventTargetHelper, AbstractThread* AbstractMainThreadFor(TaskCategory aCategory) override; - mozilla::dom::DebuggerNotificationManager* - GetOrCreateDebuggerNotificationManager() override; - - mozilla::dom::DebuggerNotificationManager* - GetExistingDebuggerNotificationManager() override; - - mozilla::Maybe - GetDebuggerNotificationType() const override { - return mozilla::Some( - mozilla::dom::EventCallbackDebuggerNotificationType::Global); - } - Maybe GetClientInfo() const override; Maybe GetClientState() const; diff --git a/dom/xhr/XMLHttpRequestEventTarget.h b/dom/xhr/XMLHttpRequestEventTarget.h index fd4289610a7e..1e81c7fcd723 100644 --- a/dom/xhr/XMLHttpRequestEventTarget.h +++ b/dom/xhr/XMLHttpRequestEventTarget.h @@ -26,11 +26,6 @@ class XMLHttpRequestEventTarget : public DOMEventTargetHelper { NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XMLHttpRequestEventTarget, DOMEventTargetHelper) - mozilla::Maybe - GetDebuggerNotificationType() const override { - return mozilla::Some(EventCallbackDebuggerNotificationType::Xhr); - } - IMPL_EVENT_HANDLER(loadstart) IMPL_EVENT_HANDLER(progress) IMPL_EVENT_HANDLER(abort) diff --git a/layout/base/nsRefreshDriver.cpp b/layout/base/nsRefreshDriver.cpp index 8b45963555ce..7eed0b35aebc 100644 --- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -52,7 +52,6 @@ #include "nsViewManager.h" #include "GeckoProfiler.h" #include "nsNPAPIPluginInstance.h" -#include "mozilla/dom/CallbackDebuggerNotification.h" #include "mozilla/dom/Event.h" #include "mozilla/dom/Performance.h" #include "mozilla/dom/Selection.h" @@ -1696,12 +1695,6 @@ void nsRefreshDriver::RunFrameRequestCallbacks(TimeStamp aNowTime) { callback.mHandle)) { continue; } - - nsCOMPtr global(innerWindow ? innerWindow->AsGlobal() - : nullptr); - CallbackDebuggerNotificationGuard guard( - global, DebuggerNotificationType::RequestAnimationFrameCallback); - // MOZ_KnownLive is OK, because the stack array frameRequestCallbacks // keeps callback alive and the mCallback strong reference can't be // mutated by the call.