From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- dom/base/nsWindowRoot.h | 98 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 dom/base/nsWindowRoot.h (limited to 'dom/base/nsWindowRoot.h') diff --git a/dom/base/nsWindowRoot.h b/dom/base/nsWindowRoot.h new file mode 100644 index 0000000000..7fb56acd18 --- /dev/null +++ b/dom/base/nsWindowRoot.h @@ -0,0 +1,98 @@ +/* -*- 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 nsWindowRoot_h__ +#define nsWindowRoot_h__ + +class nsIGlobalObject; + +#include "mozilla/Attributes.h" +#include "mozilla/EventListenerManager.h" +#include "nsIWeakReferenceUtils.h" +#include "nsPIWindowRoot.h" +#include "nsCycleCollectionParticipant.h" +#include "nsTHashSet.h" +#include "nsHashKeys.h" + +class nsWindowRoot final : public nsPIWindowRoot { + public: + explicit nsWindowRoot(nsPIDOMWindowOuter* aWindow); + + NS_DECL_CYCLE_COLLECTING_ISUPPORTS + + mozilla::EventListenerManager* GetExistingListenerManager() const override; + mozilla::EventListenerManager* GetOrCreateListenerManager() override; + + bool ComputeDefaultWantsUntrusted(mozilla::ErrorResult& aRv) final; + + // TODO: Convert this to MOZ_CAN_RUN_SCRIPT (bug 1415230) + MOZ_CAN_RUN_SCRIPT_BOUNDARY bool DispatchEvent( + mozilla::dom::Event& aEvent, mozilla::dom::CallerType aCallerType, + mozilla::ErrorResult& aRv) override; + + void GetEventTargetParent(mozilla::EventChainPreVisitor& aVisitor) override; + + nsresult PostHandleEvent(mozilla::EventChainPostVisitor& aVisitor) override; + + // nsPIWindowRoot + + nsPIDOMWindowOuter* GetWindow() override; + + nsresult GetControllers(bool aForVisibleWindow, + nsIControllers** aResult) override; + nsresult GetControllerForCommand(const char* aCommand, bool aForVisibleWindow, + nsIController** _retval) override; + + void GetEnabledDisabledCommands( + nsTArray& aEnabledCommands, + nsTArray& aDisabledCommands) override; + + already_AddRefed GetPopupNode() override; + void SetPopupNode(nsINode* aNode) override; + + void SetParentTarget(mozilla::dom::EventTarget* aTarget) override { + mParent = aTarget; + } + mozilla::dom::EventTarget* GetParentTarget() override { return mParent; } + nsPIDOMWindowOuter* GetOwnerGlobalForBindingsInternal() override; + nsIGlobalObject* GetOwnerGlobal() const override; + + nsIGlobalObject* GetParentObject(); + + JSObject* WrapObject(JSContext*, JS::Handle aGivenProto) override; + + NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(nsWindowRoot) + + void AddBrowser(nsIRemoteTab* aBrowser) override; + void RemoveBrowser(nsIRemoteTab* aBrowser) override; + void EnumerateBrowsers(BrowserEnumerator aEnumFunc, void* aArg) override; + + protected: + virtual ~nsWindowRoot(); + + void GetEnabledDisabledCommandsForControllers( + nsIControllers* aControllers, nsTHashSet& aCommandsHandled, + nsTArray& aEnabledCommands, + nsTArray& aDisabledCommands); + + // Members + nsCOMPtr mWindow; + // We own the manager, which owns event listeners attached to us. + RefPtr mListenerManager; // [Strong] + nsWeakPtr mPopupNode; + + nsCOMPtr mParent; + + // The BrowserParents that are currently registered with this top-level + // window. + using WeakBrowserTable = nsTHashSet>; + WeakBrowserTable mWeakBrowsers; +}; + +extern already_AddRefed NS_NewWindowRoot( + nsPIDOMWindowOuter* aWindow); + +#endif -- cgit v1.2.3