1 | // Test06.cpp
|
---|
2 |
|
---|
3 | #include "nsIDOMWindowInternal.h"
|
---|
4 | #include "nsIScriptGlobalObject.h"
|
---|
5 | #include "nsIWebShell.h"
|
---|
6 | #include "nsIDocShell.h"
|
---|
7 | #include "nsIWebShellWindow.h"
|
---|
8 | #include "nsCOMPtr.h"
|
---|
9 |
|
---|
10 | NS_DEF_PTR(nsIScriptGlobalObject);
|
---|
11 | NS_DEF_PTR(nsIWebShell);
|
---|
12 | NS_DEF_PTR(nsIWebShellContainer);
|
---|
13 | NS_DEF_PTR(nsIWebShellWindow);
|
---|
14 |
|
---|
15 | /*
|
---|
16 | Windows:
|
---|
17 | nsCOMPtr_optimized 176
|
---|
18 | nsCOMPtr_as_found 181
|
---|
19 | nsCOMPtr_optimized* 182
|
---|
20 | nsCOMPtr02* 184
|
---|
21 | nsCOMPtr02 187
|
---|
22 | nsCOMPtr02* 188
|
---|
23 | nsCOMPtr03 189
|
---|
24 | raw_optimized, nsCOMPtr00 191
|
---|
25 | nsCOMPtr00* 199
|
---|
26 | nsCOMPtr_as_found* 201
|
---|
27 | raw 214
|
---|
28 |
|
---|
29 | Macintosh:
|
---|
30 | nsCOMPtr_optimized 300 (1.0000)
|
---|
31 | nsCOMPtr02 320 (1.0667) i.e., 6.67% bigger than nsCOMPtr_optimized
|
---|
32 | nsCOMPtr00 328 (1.0933)
|
---|
33 | raw_optimized, nsCOMPtr03 332 (1.1067)
|
---|
34 | nsCOMPtr_as_found 344 (1.1467)
|
---|
35 | raw 388 (1.2933)
|
---|
36 |
|
---|
37 | */
|
---|
38 |
|
---|
39 |
|
---|
40 | void // nsresult
|
---|
41 | Test06_raw(nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShellWindow)
|
---|
42 | // m388, w214
|
---|
43 | {
|
---|
44 | // if (!aDOMWindow)
|
---|
45 | // return NS_ERROR_NULL_POINTER;
|
---|
46 | nsIScriptGlobalObject* scriptGlobalObject = 0;
|
---|
47 | nsresult status = aDOMWindow->QueryInterface(NS_GET_IID(nsIScriptGlobalObject), (void**)&scriptGlobalObject);
|
---|
48 | nsIDocShell* docShell = 0;
|
---|
49 | if (scriptGlobalObject)
|
---|
50 | scriptGlobalObject->GetDocShell(&docShell);
|
---|
51 | nsIWebShell* webShell = 0;
|
---|
52 | if (docShell)
|
---|
53 | status=docShell->QueryInterface(NS_GET_IID(nsIWebShell), (void**)&webShell);
|
---|
54 | nsIWebShell* rootWebShell = 0;
|
---|
55 | if (webShell)
|
---|
56 | //status = webShell->GetRootWebShellEvenIfChrome(rootWebShell);
|
---|
57 | {}
|
---|
58 | nsIWebShellContainer* webShellContainer = 0;
|
---|
59 | if (rootWebShell)
|
---|
60 | status = rootWebShell->GetContainer(webShellContainer);
|
---|
61 | if (webShellContainer)
|
---|
62 | status = webShellContainer->QueryInterface(NS_GET_IID(nsIWebShellWindow), (void**)aWebShellWindow);
|
---|
63 | else
|
---|
64 | (*aWebShellWindow) = 0;
|
---|
65 | NS_IF_RELEASE(webShellContainer);
|
---|
66 | NS_IF_RELEASE(rootWebShell);
|
---|
67 | NS_IF_RELEASE(webShell);
|
---|
68 | NS_IF_RELEASE(docShell);
|
---|
69 | NS_IF_RELEASE(scriptGlobalObject);
|
---|
70 | // return status;
|
---|
71 | }
|
---|
72 |
|
---|
73 | void // nsresult
|
---|
74 | Test06_raw_optimized(nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShellWindow)
|
---|
75 | // m332, w191
|
---|
76 | {
|
---|
77 | // if (!aDOMWindow)
|
---|
78 | // return NS_ERROR_NULL_POINTER;
|
---|
79 | (*aWebShellWindow) = 0;
|
---|
80 | nsIScriptGlobalObject* scriptGlobalObject;
|
---|
81 | nsresult status = aDOMWindow->QueryInterface(NS_GET_IID(nsIScriptGlobalObject), (void**)&scriptGlobalObject);
|
---|
82 | if (NS_SUCCEEDED(status)) {
|
---|
83 | nsIDocShell* docShell = 0;
|
---|
84 | scriptGlobalObject->GetDocShell(&docShell);
|
---|
85 | if (docShell) {
|
---|
86 | nsIWebShell* webShell = 0;
|
---|
87 | docShell->QueryInterface(NS_GET_IID(nsIWebShell), (void**)webShell);
|
---|
88 | if (webShell) {
|
---|
89 | nsIWebShell* rootWebShell;
|
---|
90 | // status = webShell->GetRootWebShellEvenIfChrome(rootWebShell);
|
---|
91 | if (NS_SUCCEEDED(status)) {
|
---|
92 | nsIWebShellContainer* webShellContainer;
|
---|
93 | status = rootWebShell->GetContainer(webShellContainer);
|
---|
94 | if (NS_SUCCEEDED(status)) {
|
---|
95 | status = webShellContainer->QueryInterface(NS_GET_IID(nsIWebShellWindow), (void**)aWebShellWindow);
|
---|
96 | NS_RELEASE(webShellContainer);
|
---|
97 | }
|
---|
98 | NS_RELEASE(rootWebShell);
|
---|
99 | }
|
---|
100 | NS_RELEASE(webShell);
|
---|
101 | }
|
---|
102 | NS_RELEASE(docShell);
|
---|
103 | }
|
---|
104 | NS_RELEASE(scriptGlobalObject);
|
---|
105 | }
|
---|
106 | // return status;
|
---|
107 | }
|
---|
108 |
|
---|
109 | void
|
---|
110 | Test06_nsCOMPtr_as_found(nsIDOMWindowInternal* aDOMWindow, nsCOMPtr<nsIWebShellWindow>* aWebShellWindow)
|
---|
111 | // m344, w181/201
|
---|
112 | {
|
---|
113 | // if (!aDOMWindow)
|
---|
114 | // return;
|
---|
115 | nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject = do_QueryInterface(aDOMWindow);
|
---|
116 | nsCOMPtr<nsIDocShell> docShell;
|
---|
117 | if (scriptGlobalObject)
|
---|
118 | scriptGlobalObject->GetDocShell(getter_AddRefs(docShell));
|
---|
119 | nsCOMPtr<nsIWebShell> webShell;
|
---|
120 | if (docShell)
|
---|
121 | webShell = do_QueryInterface(docShell);
|
---|
122 | nsCOMPtr<nsIWebShell> rootWebShell;
|
---|
123 | if (webShell)
|
---|
124 | //webShell->GetRootWebShellEvenIfChrome(*getter_AddRefs(rootWebShell));
|
---|
125 | {}
|
---|
126 | nsCOMPtr<nsIWebShellContainer> webShellContainer;
|
---|
127 | if (rootWebShell)
|
---|
128 | rootWebShell->GetContainer(*getter_AddRefs(webShellContainer));
|
---|
129 | (*aWebShellWindow) = do_QueryInterface(webShellContainer);
|
---|
130 | }
|
---|
131 |
|
---|
132 | void // nsresult
|
---|
133 | Test06_nsCOMPtr00(nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShellWindow)
|
---|
134 | // m328, w191/199
|
---|
135 | {
|
---|
136 | // if (!aDOMWindow)
|
---|
137 | // return NS_ERROR_NULL_POINTER;
|
---|
138 | nsresult status;
|
---|
139 | nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject = do_QueryInterface(aDOMWindow, &status);
|
---|
140 | nsIDocShell* temp0 = 0;
|
---|
141 | if (scriptGlobalObject)
|
---|
142 | scriptGlobalObject->GetDocShell(&temp0);
|
---|
143 | nsCOMPtr<nsIDocShell> docShell = dont_AddRef(temp0);
|
---|
144 | nsCOMPtr<nsIWebShell> webShell;
|
---|
145 | if (docShell)
|
---|
146 | webShell=do_QueryInterface(docShell, &status);
|
---|
147 | nsIWebShellContainer* temp2 = 0;
|
---|
148 | if (webShell)
|
---|
149 | status = webShell->GetContainer(temp2);
|
---|
150 | nsCOMPtr<nsIWebShellContainer> webShellContainer = dont_AddRef(temp2);
|
---|
151 | if (webShellContainer)
|
---|
152 | status = webShellContainer->QueryInterface(NS_GET_IID(nsIWebShellWindow), (void**)aWebShellWindow);
|
---|
153 | else
|
---|
154 | (*aWebShellWindow) = 0;
|
---|
155 | // return status;
|
---|
156 | }
|
---|
157 |
|
---|
158 | void // nsresult
|
---|
159 | Test06_nsCOMPtr_optimized(nsIDOMWindowInternal* aDOMWindow, nsCOMPtr<nsIWebShellWindow>* aWebShellWindow)
|
---|
160 | // m300, w176/182
|
---|
161 | {
|
---|
162 | // if (!aDOMWindow)
|
---|
163 | // return NS_ERROR_NULL_POINTER;
|
---|
164 | nsresult status;
|
---|
165 | nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject = do_QueryInterface(aDOMWindow, &status);
|
---|
166 | nsIDocShell* temp0 = 0;
|
---|
167 | if (scriptGlobalObject)
|
---|
168 | scriptGlobalObject->GetDocShell(&temp0);
|
---|
169 | nsCOMPtr<nsIWebShell> webShell = do_QueryInterface(temp0, &status);
|
---|
170 | nsIWebShell* temp2 = 0;
|
---|
171 | if (webShell)
|
---|
172 | // status = webShell->GetRootWebShellEvenIfChrome(temp2);
|
---|
173 | {}
|
---|
174 | nsCOMPtr<nsIWebShell> rootWebShell = dont_AddRef(temp2);
|
---|
175 | nsIWebShellContainer* temp3 = 0;
|
---|
176 | if (rootWebShell)
|
---|
177 | status = rootWebShell->GetContainer(temp3);
|
---|
178 | nsCOMPtr<nsIWebShellContainer> webShellContainer = dont_AddRef(temp3);
|
---|
179 | (*aWebShellWindow) = do_QueryInterface(webShellContainer, &status);
|
---|
180 | // return status;
|
---|
181 | }
|
---|
182 |
|
---|
183 | void // nsresult
|
---|
184 | Test06_nsCOMPtr02(nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShellWindow)
|
---|
185 | // m320, w187/184
|
---|
186 | {
|
---|
187 | // if (!aDOMWindow)
|
---|
188 | // return NS_ERROR_NULL_POINTER;
|
---|
189 | (*aWebShellWindow) = 0;
|
---|
190 | nsresult status;
|
---|
191 | nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject = do_QueryInterface(aDOMWindow, &status);
|
---|
192 | if (scriptGlobalObject) {
|
---|
193 | nsIDocShell* temp0;
|
---|
194 | scriptGlobalObject->GetDocShell(&temp0);
|
---|
195 | nsCOMPtr<nsIWebShell> webShell = do_QueryInterface(temp0);
|
---|
196 | if (webShell) {
|
---|
197 | nsIWebShellContainer* temp2;
|
---|
198 | status = webShell->GetContainer(temp2);
|
---|
199 | nsCOMPtr<nsIWebShellContainer> webShellContainer = dont_AddRef(temp2);
|
---|
200 | if (webShellContainer)
|
---|
201 | status = webShellContainer->QueryInterface(NS_GET_IID(nsIWebShellWindow), (void**)aWebShellWindow);
|
---|
202 | }
|
---|
203 | }
|
---|
204 | // return status;
|
---|
205 | }
|
---|
206 |
|
---|
207 | void // nsresult
|
---|
208 | Test06_nsCOMPtr03(nsIDOMWindowInternal* aDOMWindow, nsCOMPtr<nsIWebShellWindow>* aWebShellWindow)
|
---|
209 | // m332, w189/188
|
---|
210 | {
|
---|
211 | // if (!aDOMWindow)
|
---|
212 | // return NS_ERROR_NULL_POINTER;
|
---|
213 | (*aWebShellWindow) = 0;
|
---|
214 | nsresult status;
|
---|
215 | nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject = do_QueryInterface(aDOMWindow, &status);
|
---|
216 | if (scriptGlobalObject) {
|
---|
217 | nsIDocShell* temp0;
|
---|
218 | scriptGlobalObject->GetDocShell(&temp0);
|
---|
219 | nsCOMPtr<nsIDocShell> docShell = dont_AddRef(temp0);
|
---|
220 | if (docShell) {
|
---|
221 | nsCOMPtr<nsIWebShell> webShell = do_QueryInterface(docShell, &status);
|
---|
222 | if (webShell) {
|
---|
223 | nsIWebShellContainer* temp2;
|
---|
224 | status = webShell->GetContainer(temp2);
|
---|
225 | nsCOMPtr<nsIWebShellContainer> webShellContainer = dont_AddRef(temp2);
|
---|
226 | (*aWebShellWindow) = do_QueryInterface(webShellContainer, &status);
|
---|
227 | }
|
---|
228 | }
|
---|
229 | }
|
---|
230 | // return status;
|
---|
231 | }
|
---|