|
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 /* |
|
7 |
|
8 The XUL "controllers" object. |
|
9 |
|
10 */ |
|
11 |
|
12 #ifndef nsXULControllers_h__ |
|
13 #define nsXULControllers_h__ |
|
14 |
|
15 #include "nsCOMPtr.h" |
|
16 #include "nsTArray.h" |
|
17 #include "nsWeakPtr.h" |
|
18 #include "nsIControllers.h" |
|
19 #include "nsCycleCollectionParticipant.h" |
|
20 |
|
21 /* non-XPCOM class for holding controllers and their IDs */ |
|
22 class nsXULControllerData |
|
23 { |
|
24 public: |
|
25 nsXULControllerData(uint32_t inControllerID, nsIController* inController) |
|
26 : mControllerID(inControllerID) |
|
27 , mController(inController) |
|
28 { |
|
29 } |
|
30 |
|
31 ~nsXULControllerData() {} |
|
32 |
|
33 uint32_t GetControllerID() { return mControllerID; } |
|
34 |
|
35 nsresult GetController(nsIController **outController) |
|
36 { |
|
37 NS_IF_ADDREF(*outController = mController); |
|
38 return NS_OK; |
|
39 } |
|
40 |
|
41 uint32_t mControllerID; |
|
42 nsCOMPtr<nsIController> mController; |
|
43 }; |
|
44 |
|
45 |
|
46 nsresult NS_NewXULControllers(nsISupports* aOuter, REFNSIID aIID, void** aResult); |
|
47 |
|
48 class nsXULControllers : public nsIControllers |
|
49 { |
|
50 public: |
|
51 friend nsresult |
|
52 NS_NewXULControllers(nsISupports* aOuter, REFNSIID aIID, void** aResult); |
|
53 |
|
54 NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
|
55 NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsXULControllers, nsIControllers) |
|
56 NS_DECL_NSICONTROLLERS |
|
57 |
|
58 protected: |
|
59 nsXULControllers(); |
|
60 virtual ~nsXULControllers(void); |
|
61 |
|
62 void DeleteControllers(); |
|
63 |
|
64 nsTArray<nsXULControllerData*> mControllers; |
|
65 uint32_t mCurControllerID; |
|
66 }; |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 #endif // nsXULControllers_h__ |