|
1 /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
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/. */ |
|
6 |
|
7 #ifndef nsWindowRoot_h__ |
|
8 #define nsWindowRoot_h__ |
|
9 |
|
10 class nsPIDOMWindow; |
|
11 class nsIDOMEventListener; |
|
12 class nsIDOMEvent; |
|
13 |
|
14 namespace mozilla { |
|
15 class EventChainPostVisitor; |
|
16 class EventChainPreVisitor; |
|
17 } // namespace mozilla |
|
18 |
|
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" |
|
25 |
|
26 class nsWindowRoot : public nsPIWindowRoot |
|
27 { |
|
28 public: |
|
29 nsWindowRoot(nsPIDOMWindow* aWindow); |
|
30 virtual ~nsWindowRoot(); |
|
31 |
|
32 NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
|
33 NS_DECL_NSIDOMEVENTTARGET |
|
34 |
|
35 virtual mozilla::EventListenerManager* |
|
36 GetExistingListenerManager() const MOZ_OVERRIDE; |
|
37 virtual mozilla::EventListenerManager* |
|
38 GetOrCreateListenerManager() MOZ_OVERRIDE; |
|
39 |
|
40 using mozilla::dom::EventTarget::RemoveEventListener; |
|
41 virtual void AddEventListener(const nsAString& aType, |
|
42 mozilla::dom::EventListener* aListener, |
|
43 bool aUseCapture, |
|
44 const mozilla::dom::Nullable<bool>& aWantsUntrusted, |
|
45 mozilla::ErrorResult& aRv) MOZ_OVERRIDE; |
|
46 |
|
47 // nsPIWindowRoot |
|
48 |
|
49 virtual nsPIDOMWindow* GetWindow() MOZ_OVERRIDE; |
|
50 |
|
51 virtual nsresult GetControllers(nsIControllers** aResult) MOZ_OVERRIDE; |
|
52 virtual nsresult GetControllerForCommand(const char * aCommand, |
|
53 nsIController** _retval) MOZ_OVERRIDE; |
|
54 |
|
55 virtual nsIDOMNode* GetPopupNode() MOZ_OVERRIDE; |
|
56 virtual void SetPopupNode(nsIDOMNode* aNode) MOZ_OVERRIDE; |
|
57 |
|
58 virtual void SetParentTarget(mozilla::dom::EventTarget* aTarget) MOZ_OVERRIDE |
|
59 { |
|
60 mParent = aTarget; |
|
61 } |
|
62 virtual mozilla::dom::EventTarget* GetParentTarget() MOZ_OVERRIDE { return mParent; } |
|
63 virtual nsIDOMWindow* GetOwnerGlobal() MOZ_OVERRIDE; |
|
64 |
|
65 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsWindowRoot, |
|
66 nsIDOMEventTarget) |
|
67 |
|
68 protected: |
|
69 // Members |
|
70 nsCOMPtr<nsPIDOMWindow> mWindow; |
|
71 // We own the manager, which owns event listeners attached to us. |
|
72 nsRefPtr<mozilla::EventListenerManager> mListenerManager; // [Strong] |
|
73 nsCOMPtr<nsIDOMNode> mPopupNode; // [OWNER] |
|
74 |
|
75 nsCOMPtr<mozilla::dom::EventTarget> mParent; |
|
76 }; |
|
77 |
|
78 extern already_AddRefed<mozilla::dom::EventTarget> |
|
79 NS_NewWindowRoot(nsPIDOMWindow* aWindow); |
|
80 |
|
81 #endif |