summaryrefslogtreecommitdiffstats
path: root/src/libs/xpcom18a4/xpcom/tests/SizeTest06.cpp
blob: 2c28e7f32827be87be2b4efb7b8954d6f177ada9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
// Test06.cpp

#include "nsIDOMWindowInternal.h"
#include "nsIScriptGlobalObject.h"
#include "nsIWebShell.h"
#include "nsIDocShell.h"
#include "nsIWebShellWindow.h"
#include "nsCOMPtr.h"

NS_DEF_PTR(nsIScriptGlobalObject);
NS_DEF_PTR(nsIWebShell);
NS_DEF_PTR(nsIWebShellContainer);
NS_DEF_PTR(nsIWebShellWindow);

  /*
    Windows:
      nsCOMPtr_optimized           176
      nsCOMPtr_as_found            181
      nsCOMPtr_optimized*          182
      nsCOMPtr02*                  184
      nsCOMPtr02                   187
      nsCOMPtr02*                  188
      nsCOMPtr03                   189
      raw_optimized, nsCOMPtr00    191
      nsCOMPtr00*                  199
      nsCOMPtr_as_found*           201
      raw                          214

    Macintosh:
      nsCOMPtr_optimized           300    (1.0000)
      nsCOMPtr02                   320    (1.0667)  i.e., 6.67% bigger than nsCOMPtr_optimized
      nsCOMPtr00                   328    (1.0933)
      raw_optimized, nsCOMPtr03    332    (1.1067)
      nsCOMPtr_as_found            344    (1.1467)
      raw                          388    (1.2933)

  */


void // nsresult
Test06_raw(nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShellWindow)
    // m388, w214
{
//  if (!aDOMWindow)
//    return NS_ERROR_NULL_POINTER;
  nsIScriptGlobalObject* scriptGlobalObject = 0;
  nsresult status = aDOMWindow->QueryInterface(NS_GET_IID(nsIScriptGlobalObject), (void**)&scriptGlobalObject);
  nsIDocShell* docShell = 0;
  if (scriptGlobalObject)
    scriptGlobalObject->GetDocShell(&docShell);
  nsIWebShell* webShell = 0;
  if (docShell)
    status=docShell->QueryInterface(NS_GET_IID(nsIWebShell), (void**)&webShell);
  nsIWebShell* rootWebShell = 0;
  if (webShell)
    //status = webShell->GetRootWebShellEvenIfChrome(rootWebShell);
    {}
  nsIWebShellContainer* webShellContainer = 0;
  if (rootWebShell)
    status = rootWebShell->GetContainer(webShellContainer);
  if (webShellContainer)
    status = webShellContainer->QueryInterface(NS_GET_IID(nsIWebShellWindow), (void**)aWebShellWindow);
  else
    (*aWebShellWindow) = 0;
  NS_IF_RELEASE(webShellContainer);
  NS_IF_RELEASE(rootWebShell);
  NS_IF_RELEASE(webShell);
  NS_IF_RELEASE(docShell);
  NS_IF_RELEASE(scriptGlobalObject);
//    return status;
}

void // nsresult
Test06_raw_optimized(nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShellWindow)
    // m332, w191
{
//  if (!aDOMWindow)
//    return NS_ERROR_NULL_POINTER;
  (*aWebShellWindow) = 0;
  nsIScriptGlobalObject* scriptGlobalObject;
  nsresult status = aDOMWindow->QueryInterface(NS_GET_IID(nsIScriptGlobalObject), (void**)&scriptGlobalObject);
  if (NS_SUCCEEDED(status)) {
    nsIDocShell* docShell = 0;
    scriptGlobalObject->GetDocShell(&docShell);
    if (docShell) {
      nsIWebShell* webShell = 0;
      docShell->QueryInterface(NS_GET_IID(nsIWebShell), (void**)webShell);
      if (webShell) {
        nsIWebShell* rootWebShell;
        //    status = webShell->GetRootWebShellEvenIfChrome(rootWebShell);
        if (NS_SUCCEEDED(status)) {
          nsIWebShellContainer* webShellContainer;
          status = rootWebShell->GetContainer(webShellContainer);
          if (NS_SUCCEEDED(status)) {
            status = webShellContainer->QueryInterface(NS_GET_IID(nsIWebShellWindow), (void**)aWebShellWindow);
            NS_RELEASE(webShellContainer);
          }
          NS_RELEASE(rootWebShell);
        }
        NS_RELEASE(webShell);
      }
      NS_RELEASE(docShell);
    }
    NS_RELEASE(scriptGlobalObject);
  }
//  return status;
}

void
Test06_nsCOMPtr_as_found(nsIDOMWindowInternal* aDOMWindow, nsCOMPtr<nsIWebShellWindow>* aWebShellWindow)
    // m344, w181/201
{
//  if (!aDOMWindow)
//    return;
  nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject = do_QueryInterface(aDOMWindow);
  nsCOMPtr<nsIDocShell> docShell;
  if (scriptGlobalObject)
    scriptGlobalObject->GetDocShell(getter_AddRefs(docShell));  
  nsCOMPtr<nsIWebShell> webShell; 
  if (docShell)
    webShell = do_QueryInterface(docShell);
  nsCOMPtr<nsIWebShell> rootWebShell;
  if (webShell)
    //webShell->GetRootWebShellEvenIfChrome(*getter_AddRefs(rootWebShell));
    {}
  nsCOMPtr<nsIWebShellContainer> webShellContainer;
  if (rootWebShell)
    rootWebShell->GetContainer(*getter_AddRefs(webShellContainer));
  (*aWebShellWindow) = do_QueryInterface(webShellContainer);
}

void // nsresult
Test06_nsCOMPtr00(nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShellWindow)
    // m328, w191/199
{
//  if (!aDOMWindow)
//    return NS_ERROR_NULL_POINTER;
  nsresult status;
  nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject = do_QueryInterface(aDOMWindow, &status);
  nsIDocShell* temp0 = 0;
  if (scriptGlobalObject)
    scriptGlobalObject->GetDocShell(&temp0);
  nsCOMPtr<nsIDocShell> docShell = dont_AddRef(temp0);
  nsCOMPtr<nsIWebShell> webShell;
  if (docShell)
    webShell=do_QueryInterface(docShell, &status);
  nsIWebShellContainer* temp2 = 0;
  if (webShell)
    status = webShell->GetContainer(temp2);
  nsCOMPtr<nsIWebShellContainer> webShellContainer = dont_AddRef(temp2);
  if (webShellContainer)
    status = webShellContainer->QueryInterface(NS_GET_IID(nsIWebShellWindow), (void**)aWebShellWindow);
  else
    (*aWebShellWindow) = 0;
//    return status;
}

void // nsresult
Test06_nsCOMPtr_optimized(nsIDOMWindowInternal* aDOMWindow, nsCOMPtr<nsIWebShellWindow>* aWebShellWindow)
    // m300, w176/182
{
//    if (!aDOMWindow)
//      return NS_ERROR_NULL_POINTER;
  nsresult status;
  nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject = do_QueryInterface(aDOMWindow, &status);
  nsIDocShell* temp0 = 0;
  if (scriptGlobalObject)
    scriptGlobalObject->GetDocShell(&temp0);
  nsCOMPtr<nsIWebShell> webShell = do_QueryInterface(temp0, &status);
  nsIWebShell* temp2 = 0;
  if (webShell)
  //  status = webShell->GetRootWebShellEvenIfChrome(temp2);
    {}
  nsCOMPtr<nsIWebShell> rootWebShell = dont_AddRef(temp2);
  nsIWebShellContainer* temp3 = 0;
  if (rootWebShell)
    status = rootWebShell->GetContainer(temp3);
  nsCOMPtr<nsIWebShellContainer> webShellContainer = dont_AddRef(temp3);
  (*aWebShellWindow) = do_QueryInterface(webShellContainer, &status);
//    return status;
}

void // nsresult
Test06_nsCOMPtr02(nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShellWindow)
    // m320, w187/184
{
//    if (!aDOMWindow)
//      return NS_ERROR_NULL_POINTER;
  (*aWebShellWindow) = 0;
  nsresult status;
  nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject = do_QueryInterface(aDOMWindow, &status);
  if (scriptGlobalObject) {
    nsIDocShell* temp0;
    scriptGlobalObject->GetDocShell(&temp0);
    nsCOMPtr<nsIWebShell> webShell = do_QueryInterface(temp0);
    if (webShell) {
      nsIWebShellContainer* temp2;
      status = webShell->GetContainer(temp2);
      nsCOMPtr<nsIWebShellContainer> webShellContainer = dont_AddRef(temp2);
      if (webShellContainer)
        status = webShellContainer->QueryInterface(NS_GET_IID(nsIWebShellWindow), (void**)aWebShellWindow);
    }
  }
//    return status;
}

void // nsresult
Test06_nsCOMPtr03(nsIDOMWindowInternal* aDOMWindow, nsCOMPtr<nsIWebShellWindow>* aWebShellWindow)
    // m332, w189/188
{
//    if (!aDOMWindow)
//      return NS_ERROR_NULL_POINTER;
  (*aWebShellWindow) = 0;
  nsresult status;
  nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject = do_QueryInterface(aDOMWindow, &status);
  if (scriptGlobalObject) {
    nsIDocShell* temp0;
    scriptGlobalObject->GetDocShell(&temp0);
    nsCOMPtr<nsIDocShell> docShell = dont_AddRef(temp0);
    if (docShell) {
      nsCOMPtr<nsIWebShell> webShell = do_QueryInterface(docShell, &status);
      if (webShell) {
        nsIWebShellContainer* temp2;
        status = webShell->GetContainer(temp2);
        nsCOMPtr<nsIWebShellContainer> webShellContainer = dont_AddRef(temp2);
        (*aWebShellWindow) = do_QueryInterface(webShellContainer, &status);
      }
    }
  }
//    return status;
}