1 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
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 nsWindowRoot_h__
8 #define nsWindowRoot_h__
11 class nsIDOMEventListener
;
15 class EventChainPostVisitor
;
16 class EventChainPreVisitor
;
17 } // namespace mozilla
19 #include "mozilla/Attributes.h"
20 #include "mozilla/EventListenerManager.h"
21 #include "nsIDOMEventTarget.h"
22 #include "nsPIWindowRoot.h"
23 #include "nsCycleCollectionParticipant.h"
24 #include "nsAutoPtr.h"
26 class nsWindowRoot
: public nsPIWindowRoot
29 explicit nsWindowRoot(nsPIDOMWindow
* aWindow
);
31 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
32 NS_DECL_NSIDOMEVENTTARGET
34 virtual mozilla::EventListenerManager
*
35 GetExistingListenerManager() const MOZ_OVERRIDE
;
36 virtual mozilla::EventListenerManager
*
37 GetOrCreateListenerManager() MOZ_OVERRIDE
;
39 using mozilla::dom::EventTarget::RemoveEventListener
;
40 virtual void AddEventListener(const nsAString
& aType
,
41 mozilla::dom::EventListener
* aListener
,
43 const mozilla::dom::Nullable
<bool>& aWantsUntrusted
,
44 mozilla::ErrorResult
& aRv
) MOZ_OVERRIDE
;
48 virtual nsPIDOMWindow
* GetWindow() MOZ_OVERRIDE
;
50 virtual nsresult
GetControllers(nsIControllers
** aResult
) MOZ_OVERRIDE
;
51 virtual nsresult
GetControllerForCommand(const char * aCommand
,
52 nsIController
** _retval
) MOZ_OVERRIDE
;
54 virtual nsIDOMNode
* GetPopupNode() MOZ_OVERRIDE
;
55 virtual void SetPopupNode(nsIDOMNode
* aNode
) MOZ_OVERRIDE
;
57 virtual void SetParentTarget(mozilla::dom::EventTarget
* aTarget
) MOZ_OVERRIDE
61 virtual mozilla::dom::EventTarget
* GetParentTarget() MOZ_OVERRIDE
{ return mParent
; }
62 virtual nsIDOMWindow
* GetOwnerGlobal() MOZ_OVERRIDE
;
64 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsWindowRoot
,
68 virtual ~nsWindowRoot();
71 nsCOMPtr
<nsPIDOMWindow
> mWindow
;
72 // We own the manager, which owns event listeners attached to us.
73 nsRefPtr
<mozilla::EventListenerManager
> mListenerManager
; // [Strong]
74 nsCOMPtr
<nsIDOMNode
> mPopupNode
; // [OWNER]
76 nsCOMPtr
<mozilla::dom::EventTarget
> mParent
;
79 extern already_AddRefed
<mozilla::dom::EventTarget
>
80 NS_NewWindowRoot(nsPIDOMWindow
* aWindow
);