Bug 1854550 - pt 10. Allow LOG() with zero extra arguments r=glandium
[gecko.git] / dom / base / nsPIWindowRoot.h
blobfe4a0df484c04ff7bd202cb896f3e104c68dcbd3
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 #ifndef nsPIWindowRoot_h__
8 #define nsPIWindowRoot_h__
10 #include "nsISupports.h"
11 #include "mozilla/dom/EventTarget.h"
13 class nsPIDOMWindowOuter;
14 class nsIControllers;
15 class nsIController;
16 class nsINode;
17 class nsIRemoteTab;
19 #define NS_IWINDOWROOT_IID \
20 { \
21 0xb8724c49, 0xc398, 0x4f9b, { \
22 0x82, 0x59, 0x87, 0x27, 0xa6, 0x47, 0xdd, 0x0f \
23 } \
26 class nsPIWindowRoot : public mozilla::dom::EventTarget {
27 public:
28 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IWINDOWROOT_IID)
30 bool IsRootWindow() const final { return true; }
32 NS_IMPL_FROMEVENTTARGET_HELPER(nsPIWindowRoot, IsRootWindow())
34 virtual nsPIDOMWindowOuter* GetWindow() = 0;
36 // get and set the node that is the context of a popup menu
37 virtual already_AddRefed<nsINode> GetPopupNode() = 0;
38 virtual void SetPopupNode(nsINode* aNode) = 0;
40 /**
41 * @param aForVisibleWindow true if caller needs controller which is
42 * associated with visible window.
44 virtual nsresult GetControllerForCommand(const char* aCommand,
45 bool aForVisibleWindow,
46 nsIController** aResult) = 0;
48 /**
49 * @param aForVisibleWindow true if caller needs controllers which are
50 * associated with visible window.
52 virtual nsresult GetControllers(bool aForVisibleWindow,
53 nsIControllers** aResult) = 0;
55 virtual void GetEnabledDisabledCommands(
56 nsTArray<nsCString>& aEnabledCommands,
57 nsTArray<nsCString>& aDisabledCommands) = 0;
59 virtual void SetParentTarget(mozilla::dom::EventTarget* aTarget) = 0;
60 virtual mozilla::dom::EventTarget* GetParentTarget() = 0;
62 // Stores a weak reference to the browser.
63 virtual void AddBrowser(nsIRemoteTab* aBrowser) = 0;
64 virtual void RemoveBrowser(nsIRemoteTab* aBrowser) = 0;
66 using BrowserEnumerator = void (*)(nsIRemoteTab* aTab, void* aArg);
68 // Enumerate all stored browsers that for which the weak reference is valid.
69 virtual void EnumerateBrowsers(BrowserEnumerator aEnumFunc, void* aArg) = 0;
72 namespace mozilla::dom {
74 inline nsPIWindowRoot* EventTarget::GetAsWindowRoot() {
75 return IsRootWindow() ? static_cast<nsPIWindowRoot*>(this) : nullptr;
78 inline const nsPIWindowRoot* EventTarget::GetAsWindowRoot() const {
79 return IsRootWindow() ? static_cast<const nsPIWindowRoot*>(this) : nullptr;
82 inline nsPIWindowRoot* EventTarget::AsWindowRoot() {
83 MOZ_DIAGNOSTIC_ASSERT(IsRootWindow());
84 return static_cast<nsPIWindowRoot*>(this);
87 inline const nsPIWindowRoot* EventTarget::AsWindowRoot() const {
88 MOZ_DIAGNOSTIC_ASSERT(IsRootWindow());
89 return static_cast<const nsPIWindowRoot*>(this);
92 } // namespace mozilla::dom
94 NS_DEFINE_STATIC_IID_ACCESSOR(nsPIWindowRoot, NS_IWINDOWROOT_IID)
96 #endif // nsPIWindowRoot_h__