|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
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 #ifndef nsDOMWindowList_h___ |
|
6 #define nsDOMWindowList_h___ |
|
7 |
|
8 #include "nsCOMPtr.h" |
|
9 #include "nsIDOMWindowCollection.h" |
|
10 #include <stdint.h> |
|
11 #include "nsIDocShell.h" |
|
12 |
|
13 class nsIDocShell; |
|
14 class nsIDOMWindow; |
|
15 |
|
16 class nsDOMWindowList : public nsIDOMWindowCollection |
|
17 { |
|
18 public: |
|
19 nsDOMWindowList(nsIDocShell *aDocShell); |
|
20 virtual ~nsDOMWindowList(); |
|
21 |
|
22 NS_DECL_ISUPPORTS |
|
23 NS_DECL_NSIDOMWINDOWCOLLECTION |
|
24 |
|
25 uint32_t GetLength(); |
|
26 already_AddRefed<nsIDOMWindow> IndexedGetter(uint32_t aIndex, bool& aFound); |
|
27 |
|
28 //local methods |
|
29 NS_IMETHOD SetDocShell(nsIDocShell* aDocShell); |
|
30 already_AddRefed<nsIDocShellTreeItem> GetDocShellTreeItemAt(uint32_t aIndex) |
|
31 { |
|
32 EnsureFresh(); |
|
33 nsCOMPtr<nsIDocShellTreeItem> item; |
|
34 if (mDocShellNode) { |
|
35 mDocShellNode->GetChildAt(aIndex, getter_AddRefs(item)); |
|
36 } |
|
37 return item.forget(); |
|
38 } |
|
39 |
|
40 protected: |
|
41 // Note: this function may flush and cause mDocShellNode to become null. |
|
42 void EnsureFresh(); |
|
43 |
|
44 nsIDocShell* mDocShellNode; //Weak Reference |
|
45 }; |
|
46 |
|
47 #endif // nsDOMWindowList_h___ |