· 8 years ago · Aug 11, 2018, 08:54 PM
1# HG changeset patch
2# User Ehsan Akhgari <ehsan@mozilla.com>
3# Date 1316324162 14400
4# Node ID 71948f5a6c805b670beba1128905ab209571ae46
5# Parent 5319b0100025f1a5bc7c30cabde3b9a3bcbf998d
6[mq]: qi.patch
7
8diff --git a/accessible/src/atk/nsAccessibleWrap.cpp b/accessible/src/atk/nsAccessibleWrap.cpp
9--- a/accessible/src/atk/nsAccessibleWrap.cpp
10+++ b/accessible/src/atk/nsAccessibleWrap.cpp
11@@ -410,69 +410,69 @@ nsAccessibleWrap::CreateMaiInterfaces(vo
12 // the Component interface are supported by all nsIAccessible
13 interfacesBits |= 1 << MAI_INTERFACE_COMPONENT;
14
15 // Add Action interface if the action count is more than zero.
16 if (ActionCount() > 0)
17 interfacesBits |= 1 << MAI_INTERFACE_ACTION;
18
19 //nsIAccessibleText
20- nsCOMPtr<nsIAccessibleText> accessInterfaceText;
21- QueryInterface(NS_GET_IID(nsIAccessibleText),
22- getter_AddRefs(accessInterfaceText));
23+ nsCOMPtr<nsIAccessibleText> accessInterfaceText =
24+ dont_AddRef(static_cast<nsIAccessibleText*>
25+ (QueryInterfaceFast(NS_GET_IID(nsIAccessibleText))));
26 if (accessInterfaceText) {
27 interfacesBits |= 1 << MAI_INTERFACE_TEXT;
28 }
29
30 //nsIAccessibleEditableText
31- nsCOMPtr<nsIAccessibleEditableText> accessInterfaceEditableText;
32- QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
33- getter_AddRefs(accessInterfaceEditableText));
34+ nsCOMPtr<nsIAccessibleEditableText> accessInterfaceEditableText =
35+ dont_AddRef(static_cast<nsIAccessibleEditableText*>
36+ (QueryInterfaceFast(NS_GET_IID(nsIAccessibleEditableText))));
37 if (accessInterfaceEditableText) {
38 interfacesBits |= 1 << MAI_INTERFACE_EDITABLE_TEXT;
39 }
40
41 //nsIAccessibleValue
42- nsCOMPtr<nsIAccessibleValue> accessInterfaceValue;
43- QueryInterface(NS_GET_IID(nsIAccessibleValue),
44- getter_AddRefs(accessInterfaceValue));
45+ nsCOMPtr<nsIAccessibleValue> accessInterfaceValue =
46+ dont_AddRef(static_cast<nsIAccessibleValue*>
47+ (QueryInterfaceFast(NS_GET_IID(nsIAccessibleValue))));
48 if (accessInterfaceValue) {
49 interfacesBits |= 1 << MAI_INTERFACE_VALUE;
50 }
51
52 //nsIAccessibleDocument
53- nsCOMPtr<nsIAccessibleDocument> accessInterfaceDocument;
54- QueryInterface(NS_GET_IID(nsIAccessibleDocument),
55- getter_AddRefs(accessInterfaceDocument));
56+ nsCOMPtr<nsIAccessibleDocument> accessInterfaceDocument =
57+ dont_AddRef(static_cast<nsIAccessibleDocument*>
58+ (QueryInterfaceFast(NS_GET_IID(nsIAccessibleDocument))));
59 if (accessInterfaceDocument) {
60 interfacesBits |= 1 << MAI_INTERFACE_DOCUMENT;
61 }
62
63 //nsIAccessibleImage
64- nsCOMPtr<nsIAccessibleImage> accessInterfaceImage;
65- QueryInterface(NS_GET_IID(nsIAccessibleImage),
66- getter_AddRefs(accessInterfaceImage));
67+ nsCOMPtr<nsIAccessibleImage> accessInterfaceImage =
68+ dont_AddRef(static_cast<nsIAccessibleImage*>
69+ (QueryInterfaceFast(NS_GET_IID(nsIAccessibleImage))));
70 if (accessInterfaceImage) {
71 interfacesBits |= 1 << MAI_INTERFACE_IMAGE;
72 }
73
74 // HyperLinkAccessible
75 if (IsLink())
76 interfacesBits |= 1 << MAI_INTERFACE_HYPERLINK_IMPL;
77
78 if (!nsAccUtils::MustPrune(this)) { // These interfaces require children
79 //nsIAccessibleHypertext
80 if (IsHyperText()) {
81 interfacesBits |= 1 << MAI_INTERFACE_HYPERTEXT;
82 }
83
84 //nsIAccessibleTable
85- nsCOMPtr<nsIAccessibleTable> accessInterfaceTable;
86- QueryInterface(NS_GET_IID(nsIAccessibleTable),
87- getter_AddRefs(accessInterfaceTable));
88+ nsCOMPtr<nsIAccessibleTable> accessInterfaceTable =
89+ dont_AddRef(static_cast<nsIAccessibleTable*>
90+ (QueryInterfaceFast(NS_GET_IID(nsIAccessibleTable))));
91 if (accessInterfaceTable) {
92 interfacesBits |= 1 << MAI_INTERFACE_TABLE;
93 }
94
95 //nsIAccessibleSelection
96 if (IsSelect()) {
97 interfacesBits |= 1 << MAI_INTERFACE_SELECTION;
98 }
99diff --git a/accessible/src/atk/nsMaiInterfaceDocument.cpp b/accessible/src/atk/nsMaiInterfaceDocument.cpp
100--- a/accessible/src/atk/nsMaiInterfaceDocument.cpp
101+++ b/accessible/src/atk/nsMaiInterfaceDocument.cpp
102@@ -63,19 +63,19 @@ documentInterfaceInitCB(AtkDocumentIface
103
104 const gchar *
105 getDocumentLocaleCB(AtkDocument *aDocument)
106 {
107 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
108 if (!accWrap)
109 return nsnull;
110
111- nsCOMPtr<nsIAccessNode> docAccessNode;
112- accWrap->QueryInterface(NS_GET_IID(nsIAccessNode),
113- getter_AddRefs(docAccessNode));
114+ nsCOMPtr<nsIAccessNode> docAccessNode =
115+ dont_AddRef(static_cast<nsIAccessNode*>
116+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessNode))));
117 NS_ENSURE_TRUE(docAccessNode, nsnull);
118
119 nsAutoString locale;
120 docAccessNode->GetLanguage(locale);
121 if (locale.IsEmpty()) {
122 return nsnull;
123 }
124 return nsAccessibleWrap::ReturnString(locale);
125@@ -83,19 +83,19 @@ getDocumentLocaleCB(AtkDocument *aDocume
126
127 const gchar *
128 getDocumentTypeCB(AtkDocument *aDocument)
129 {
130 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
131 if (!accWrap)
132 return nsnull;
133
134- nsCOMPtr<nsIAccessibleDocument> accDocument;
135- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleDocument),
136- getter_AddRefs(accDocument));
137+ nsCOMPtr<nsIAccessibleDocument> accDocument =
138+ dont_AddRef(static_cast<nsIAccessibleDocument*>
139+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleDocument))));
140 NS_ENSURE_TRUE(accDocument, nsnull);
141
142 nsAutoString mimeType;
143 nsresult rv = accDocument->GetMimeType(mimeType);
144 NS_ENSURE_SUCCESS(rv, nsnull);
145 return nsAccessibleWrap::ReturnString(mimeType);
146 }
147
148@@ -111,19 +111,19 @@ prependToList(GSList *aList, const char
149
150 AtkAttributeSet *
151 getDocumentAttributesCB(AtkDocument *aDocument)
152 {
153 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
154 if (!accWrap)
155 return nsnull;
156
157- nsCOMPtr<nsIAccessibleDocument> accDocument;
158- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleDocument),
159- getter_AddRefs(accDocument));
160+ nsCOMPtr<nsIAccessibleDocument> accDocument =
161+ dont_AddRef(static_cast<nsIAccessibleDocument*>
162+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleDocument))));
163 NS_ENSURE_TRUE(accDocument, nsnull);
164
165 // according to atkobject.h, AtkAttributeSet is a GSList
166 GSList *attributes = nsnull;
167
168 nsAutoString aURL;
169 nsresult rv = accDocument->GetURL(aURL);
170 if (NS_SUCCEEDED(rv)) {
171@@ -146,19 +146,19 @@ getDocumentAttributesCB(AtkDocument *aDo
172 const gchar *
173 getDocumentAttributeValueCB(AtkDocument *aDocument,
174 const gchar *aAttrName)
175 {
176 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument));
177 if (!accWrap)
178 return nsnull;
179
180- nsCOMPtr<nsIAccessibleDocument> accDocument;
181- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleDocument),
182- getter_AddRefs(accDocument));
183+ nsCOMPtr<nsIAccessibleDocument> accDocument =
184+ dont_AddRef(static_cast<nsIAccessibleDocument*>
185+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleDocument))));
186 NS_ENSURE_TRUE(accDocument, nsnull);
187
188 nsresult rv;
189 nsAutoString attrValue;
190 if (!g_ascii_strcasecmp(aAttrName, kDocTypeName)) {
191 rv = accDocument->GetDocType(attrValue);
192 NS_ENSURE_SUCCESS(rv, nsnull);
193 }
194diff --git a/accessible/src/atk/nsMaiInterfaceEditableText.cpp b/accessible/src/atk/nsMaiInterfaceEditableText.cpp
195--- a/accessible/src/atk/nsMaiInterfaceEditableText.cpp
196+++ b/accessible/src/atk/nsMaiInterfaceEditableText.cpp
197@@ -62,19 +62,19 @@ gboolean
198 setRunAttributesCB(AtkEditableText *aText, AtkAttributeSet *aAttribSet,
199 gint aStartOffset, gint aEndOffset)
200
201 {
202 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
203 if (!accWrap)
204 return FALSE;
205
206- nsCOMPtr<nsIAccessibleEditableText> accText;
207- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
208- getter_AddRefs(accText));
209+ nsCOMPtr<nsIAccessibleEditableText> accText =
210+ dont_AddRef(static_cast<nsIAccessibleEditableText*>
211+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleEditableText))));
212 NS_ENSURE_TRUE(accText, FALSE);
213
214 nsCOMPtr<nsISupports> attrSet;
215 /* how to insert attributes into nsISupports ??? */
216
217 nsresult rv = accText->SetAttributes(aStartOffset, aEndOffset,
218 attrSet);
219 return NS_FAILED(rv) ? FALSE : TRUE;
220@@ -82,19 +82,19 @@ setRunAttributesCB(AtkEditableText *aTex
221
222 void
223 setTextContentsCB(AtkEditableText *aText, const gchar *aString)
224 {
225 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
226 if (!accWrap)
227 return;
228
229- nsCOMPtr<nsIAccessibleEditableText> accText;
230- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
231- getter_AddRefs(accText));
232+ nsCOMPtr<nsIAccessibleEditableText> accText =
233+ dont_AddRef(static_cast<nsIAccessibleEditableText*>
234+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleEditableText))));
235 if (!accText)
236 return;
237
238 MAI_LOG_DEBUG(("EditableText: setTextContentsCB, aString=%s", aString));
239
240 NS_ConvertUTF8toUTF16 strContent(aString);
241 accText->SetTextContents(strContent);
242 }
243@@ -102,19 +102,19 @@ setTextContentsCB(AtkEditableText *aText
244 void
245 insertTextCB(AtkEditableText *aText,
246 const gchar *aString, gint aLength, gint *aPosition)
247 {
248 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
249 if (!accWrap)
250 return;
251
252- nsCOMPtr<nsIAccessibleEditableText> accText;
253- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
254- getter_AddRefs(accText));
255+ nsCOMPtr<nsIAccessibleEditableText> accText =
256+ dont_AddRef(static_cast<nsIAccessibleEditableText*>
257+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleEditableText))));
258 if (!accText)
259 return;
260
261 NS_ConvertUTF8toUTF16 strContent(aString);
262
263 // interface changed in nsIAccessibleEditableText.idl ???
264 //
265 // PRInt32 pos = *aPosition;
266@@ -129,70 +129,70 @@ insertTextCB(AtkEditableText *aText,
267
268 void
269 copyTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos)
270 {
271 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
272 if (!accWrap)
273 return;
274
275- nsCOMPtr<nsIAccessibleEditableText> accText;
276- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
277- getter_AddRefs(accText));
278+ nsCOMPtr<nsIAccessibleEditableText> accText =
279+ dont_AddRef(static_cast<nsIAccessibleEditableText*>
280+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleEditableText))));
281 if (!accText)
282 return;
283
284 MAI_LOG_DEBUG(("EditableText: copyTextCB, aStartPos=%d, aEndPos=%d",
285 aStartPos, aEndPos));
286 accText->CopyText(aStartPos, aEndPos);
287 }
288
289 void
290 cutTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos)
291 {
292 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
293 if (!accWrap)
294 return;
295
296- nsCOMPtr<nsIAccessibleEditableText> accText;
297- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
298- getter_AddRefs(accText));
299+ nsCOMPtr<nsIAccessibleEditableText> accText =
300+ dont_AddRef(static_cast<nsIAccessibleEditableText*>
301+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleEditableText))));
302 if (!accText)
303 return;
304 MAI_LOG_DEBUG(("EditableText: cutTextCB, aStartPos=%d, aEndPos=%d",
305 aStartPos, aEndPos));
306 accText->CutText(aStartPos, aEndPos);
307 }
308
309 void
310 deleteTextCB(AtkEditableText *aText, gint aStartPos, gint aEndPos)
311 {
312 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
313 if (!accWrap)
314 return;
315
316- nsCOMPtr<nsIAccessibleEditableText> accText;
317- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
318- getter_AddRefs(accText));
319+ nsCOMPtr<nsIAccessibleEditableText> accText =
320+ dont_AddRef(static_cast<nsIAccessibleEditableText*>
321+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleEditableText))));
322 if (!accText)
323 return;
324
325 MAI_LOG_DEBUG(("EditableText: deleteTextCB, aStartPos=%d, aEndPos=%d",
326 aStartPos, aEndPos));
327 accText->DeleteText(aStartPos, aEndPos);
328 }
329
330 void
331 pasteTextCB(AtkEditableText *aText, gint aPosition)
332 {
333 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
334 if (!accWrap)
335 return;
336
337- nsCOMPtr<nsIAccessibleEditableText> accText;
338- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleEditableText),
339- getter_AddRefs(accText));
340+ nsCOMPtr<nsIAccessibleEditableText> accText =
341+ dont_AddRef(static_cast<nsIAccessibleEditableText*>
342+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleEditableText))));
343 if (!accText)
344 return;
345
346 MAI_LOG_DEBUG(("EditableText: pasteTextCB, aPosition=%d", aPosition));
347 accText->PasteText(aPosition);
348 }
349diff --git a/accessible/src/atk/nsMaiInterfaceImage.cpp b/accessible/src/atk/nsMaiInterfaceImage.cpp
350--- a/accessible/src/atk/nsMaiInterfaceImage.cpp
351+++ b/accessible/src/atk/nsMaiInterfaceImage.cpp
352@@ -56,19 +56,19 @@ imageInterfaceInitCB(AtkImageIface *aIfa
353 void
354 getImagePositionCB(AtkImage *aImage, gint *aAccX, gint *aAccY,
355 AtkCoordType aCoordType)
356 {
357 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
358 if (!accWrap)
359 return;
360
361- nsCOMPtr<nsIAccessibleImage> image;
362- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleImage),
363- getter_AddRefs(image));
364+ nsCOMPtr<nsIAccessibleImage> image =
365+ dont_AddRef(static_cast<nsIAccessibleImage*>
366+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleImage))));
367 if (!image)
368 return;
369
370 PRUint32 geckoCoordType = (aCoordType == ATK_XY_WINDOW) ?
371 nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE :
372 nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE;
373
374 // Returned in screen coordinates
375@@ -83,16 +83,16 @@ getImageDescriptionCB(AtkImage *aImage)
376
377 void
378 getImageSizeCB(AtkImage *aImage, gint *aAccWidth, gint *aAccHeight)
379 {
380 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aImage));
381 if (!accWrap)
382 return;
383
384- nsCOMPtr<nsIAccessibleImage> image;
385- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleImage),
386- getter_AddRefs(image));
387+ nsCOMPtr<nsIAccessibleImage> image =
388+ dont_AddRef(static_cast<nsIAccessibleImage*>
389+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleImage))));
390 if (!image)
391 return;
392
393 image->GetImageSize(aAccWidth, aAccHeight);
394 }
395diff --git a/accessible/src/atk/nsMaiInterfaceTable.cpp b/accessible/src/atk/nsMaiInterfaceTable.cpp
396--- a/accessible/src/atk/nsMaiInterfaceTable.cpp
397+++ b/accessible/src/atk/nsMaiInterfaceTable.cpp
398@@ -73,19 +73,19 @@ tableInterfaceInitCB(AtkTableIface *aIfa
399 /* static */
400 AtkObject*
401 refAtCB(AtkTable *aTable, gint aRow, gint aColumn)
402 {
403 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
404 if (!accWrap)
405 return nsnull;
406
407- nsCOMPtr<nsIAccessibleTable> accTable;
408- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
409- getter_AddRefs(accTable));
410+ nsCOMPtr<nsIAccessibleTable> accTable =
411+ dont_AddRef(static_cast<nsIAccessibleTable*>
412+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleTable))));
413 NS_ENSURE_TRUE(accTable, nsnull);
414
415 nsCOMPtr<nsIAccessible> cell;
416 nsresult rv = accTable->GetCellAt(aRow, aColumn,getter_AddRefs(cell));
417 if (NS_FAILED(rv) || !cell)
418 return nsnull;
419
420 AtkObject *cellAtkObj = nsAccessibleWrap::GetAtkObject(cell);
421@@ -97,95 +97,95 @@ refAtCB(AtkTable *aTable, gint aRow, gin
422
423 gint
424 getIndexAtCB(AtkTable *aTable, gint aRow, gint aColumn)
425 {
426 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
427 if (!accWrap)
428 return -1;
429
430- nsCOMPtr<nsIAccessibleTable> accTable;
431- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
432- getter_AddRefs(accTable));
433+ nsCOMPtr<nsIAccessibleTable> accTable =
434+ dont_AddRef(static_cast<nsIAccessibleTable*>
435+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleTable))));
436 NS_ENSURE_TRUE(accTable, -1);
437
438 PRInt32 index;
439 nsresult rv = accTable->GetCellIndexAt(aRow, aColumn, &index);
440 NS_ENSURE_SUCCESS(rv, -1);
441
442 return static_cast<gint>(index);
443 }
444
445 gint
446 getColumnAtIndexCB(AtkTable *aTable, gint aIndex)
447 {
448 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
449 if (!accWrap)
450 return -1;
451
452- nsCOMPtr<nsIAccessibleTable> accTable;
453- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
454- getter_AddRefs(accTable));
455+ nsCOMPtr<nsIAccessibleTable> accTable =
456+ dont_AddRef(static_cast<nsIAccessibleTable*>
457+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleTable))));
458 NS_ENSURE_TRUE(accTable, -1);
459
460 PRInt32 col;
461 nsresult rv = accTable->GetColumnIndexAt(aIndex, &col);
462 NS_ENSURE_SUCCESS(rv, -1);
463
464 return static_cast<gint>(col);
465 }
466
467 gint
468 getRowAtIndexCB(AtkTable *aTable, gint aIndex)
469 {
470 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
471 if (!accWrap)
472 return -1;
473
474- nsCOMPtr<nsIAccessibleTable> accTable;
475- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
476- getter_AddRefs(accTable));
477+ nsCOMPtr<nsIAccessibleTable> accTable =
478+ dont_AddRef(static_cast<nsIAccessibleTable*>
479+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleTable))));
480 NS_ENSURE_TRUE(accTable, -1);
481
482 PRInt32 row;
483 nsresult rv = accTable->GetRowIndexAt(aIndex, &row);
484 NS_ENSURE_SUCCESS(rv, -1);
485
486 return static_cast<gint>(row);
487 }
488
489 gint
490 getColumnCountCB(AtkTable *aTable)
491 {
492 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
493 if (!accWrap)
494 return -1;
495
496- nsCOMPtr<nsIAccessibleTable> accTable;
497- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
498- getter_AddRefs(accTable));
499+ nsCOMPtr<nsIAccessibleTable> accTable =
500+ dont_AddRef(static_cast<nsIAccessibleTable*>
501+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleTable))));
502 NS_ENSURE_TRUE(accTable, -1);
503
504 PRInt32 count;
505 nsresult rv = accTable->GetColumnCount(&count);
506 NS_ENSURE_SUCCESS(rv, -1);
507
508 return static_cast<gint>(count);
509 }
510
511 gint
512 getRowCountCB(AtkTable *aTable)
513 {
514 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
515 if (!accWrap)
516 return -1;
517
518- nsCOMPtr<nsIAccessibleTable> accTable;
519- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
520- getter_AddRefs(accTable));
521+ nsCOMPtr<nsIAccessibleTable> accTable =
522+ dont_AddRef(static_cast<nsIAccessibleTable*>
523+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleTable))));
524 NS_ENSURE_TRUE(accTable, -1);
525
526 PRInt32 count;
527 nsresult rv = accTable->GetRowCount(&count);
528 NS_ENSURE_SUCCESS(rv, -1);
529
530 return static_cast<gint>(count);
531 }
532@@ -193,19 +193,19 @@ getRowCountCB(AtkTable *aTable)
533 gint
534 getColumnExtentAtCB(AtkTable *aTable,
535 gint aRow, gint aColumn)
536 {
537 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
538 if (!accWrap)
539 return -1;
540
541- nsCOMPtr<nsIAccessibleTable> accTable;
542- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
543- getter_AddRefs(accTable));
544+ nsCOMPtr<nsIAccessibleTable> accTable =
545+ dont_AddRef(static_cast<nsIAccessibleTable*>
546+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleTable))));
547 NS_ENSURE_TRUE(accTable, -1);
548
549 PRInt32 extent;
550 nsresult rv = accTable->GetColumnExtentAt(aRow, aColumn, &extent);
551 NS_ENSURE_SUCCESS(rv, -1);
552
553 return static_cast<gint>(extent);
554 }
555@@ -213,38 +213,38 @@ getColumnExtentAtCB(AtkTable *aTable,
556 gint
557 getRowExtentAtCB(AtkTable *aTable,
558 gint aRow, gint aColumn)
559 {
560 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
561 if (!accWrap)
562 return -1;
563
564- nsCOMPtr<nsIAccessibleTable> accTable;
565- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
566- getter_AddRefs(accTable));
567+ nsCOMPtr<nsIAccessibleTable> accTable =
568+ dont_AddRef(static_cast<nsIAccessibleTable*>
569+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleTable))));
570 NS_ENSURE_TRUE(accTable, -1);
571
572 PRInt32 extent;
573 nsresult rv = accTable->GetRowExtentAt(aRow, aColumn, &extent);
574 NS_ENSURE_SUCCESS(rv, -1);
575
576 return static_cast<gint>(extent);
577 }
578
579 AtkObject*
580 getCaptionCB(AtkTable *aTable)
581 {
582 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
583 if (!accWrap)
584 return nsnull;
585
586- nsCOMPtr<nsIAccessibleTable> accTable;
587- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
588- getter_AddRefs(accTable));
589+ nsCOMPtr<nsIAccessibleTable> accTable =
590+ dont_AddRef(static_cast<nsIAccessibleTable*>
591+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleTable))));
592 NS_ENSURE_TRUE(accTable, nsnull);
593
594 nsCOMPtr<nsIAccessible> caption;
595 nsresult rv = accTable->GetCaption(getter_AddRefs(caption));
596 if (NS_FAILED(rv) || !caption)
597 return nsnull;
598
599 return nsAccessibleWrap::GetAtkObject(caption);
600@@ -252,38 +252,38 @@ getCaptionCB(AtkTable *aTable)
601
602 const gchar*
603 getColumnDescriptionCB(AtkTable *aTable, gint aColumn)
604 {
605 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
606 if (!accWrap)
607 return nsnull;
608
609- nsCOMPtr<nsIAccessibleTable> accTable;
610- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
611- getter_AddRefs(accTable));
612+ nsCOMPtr<nsIAccessibleTable> accTable =
613+ dont_AddRef(static_cast<nsIAccessibleTable*>
614+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleTable))));
615 NS_ENSURE_TRUE(accTable, nsnull);
616
617 nsAutoString autoStr;
618 nsresult rv = accTable->GetColumnDescription(aColumn, autoStr);
619 NS_ENSURE_SUCCESS(rv, nsnull);
620
621 return nsAccessibleWrap::ReturnString(autoStr);
622 }
623
624 AtkObject*
625 getColumnHeaderCB(AtkTable *aTable, gint aColumn)
626 {
627 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
628 if (!accWrap)
629 return nsnull;
630
631- nsCOMPtr<nsIAccessibleTable> accTable;
632- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
633- getter_AddRefs(accTable));
634+ nsCOMPtr<nsIAccessibleTable> accTable =
635+ dont_AddRef(static_cast<nsIAccessibleTable*>
636+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleTable))));
637 NS_ENSURE_TRUE(accTable, nsnull);
638
639 nsCOMPtr<nsIAccessible> accCell;
640 accTable->GetCellAt(0, aColumn, getter_AddRefs(accCell));
641 if (!accCell)
642 return nsnull;
643
644 // If the cell at the first row is column header then assume it is column
645@@ -313,38 +313,38 @@ getColumnHeaderCB(AtkTable *aTable, gint
646
647 const gchar*
648 getRowDescriptionCB(AtkTable *aTable, gint aRow)
649 {
650 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
651 if (!accWrap)
652 return nsnull;
653
654- nsCOMPtr<nsIAccessibleTable> accTable;
655- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
656- getter_AddRefs(accTable));
657+ nsCOMPtr<nsIAccessibleTable> accTable =
658+ dont_AddRef(static_cast<nsIAccessibleTable*>
659+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleTable))));
660 NS_ENSURE_TRUE(accTable, nsnull);
661
662 nsAutoString autoStr;
663 nsresult rv = accTable->GetRowDescription(aRow, autoStr);
664 NS_ENSURE_SUCCESS(rv, nsnull);
665
666 return nsAccessibleWrap::ReturnString(autoStr);
667 }
668
669 AtkObject*
670 getRowHeaderCB(AtkTable *aTable, gint aRow)
671 {
672 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
673 if (!accWrap)
674 return nsnull;
675
676- nsCOMPtr<nsIAccessibleTable> accTable;
677- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
678- getter_AddRefs(accTable));
679+ nsCOMPtr<nsIAccessibleTable> accTable =
680+ dont_AddRef(static_cast<nsIAccessibleTable*>
681+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleTable))));
682 NS_ENSURE_TRUE(accTable, nsnull);
683
684 nsCOMPtr<nsIAccessible> accCell;
685 accTable->GetCellAt(aRow, 0, getter_AddRefs(accCell));
686 if (!accCell)
687 return nsnull;
688
689 // If the cell at the first column is row header then assume it is row
690@@ -384,19 +384,19 @@ getSummaryCB(AtkTable *aTable)
691
692 gint
693 getSelectedColumnsCB(AtkTable *aTable, gint **aSelected)
694 {
695 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
696 if (!accWrap)
697 return 0;
698
699- nsCOMPtr<nsIAccessibleTable> accTable;
700- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
701- getter_AddRefs(accTable));
702+ nsCOMPtr<nsIAccessibleTable> accTable =
703+ dont_AddRef(static_cast<nsIAccessibleTable*>
704+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleTable))));
705 NS_ENSURE_TRUE(accTable, 0);
706
707 PRUint32 size = 0;
708 PRInt32 *columns = NULL;
709 nsresult rv = accTable->GetSelectedColumnIndices(&size, &columns);
710 if (NS_FAILED(rv) || (size == 0) || !columns) {
711 *aSelected = nsnull;
712 return 0;
713@@ -419,19 +419,19 @@ getSelectedColumnsCB(AtkTable *aTable, g
714
715 gint
716 getSelectedRowsCB(AtkTable *aTable, gint **aSelected)
717 {
718 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
719 if (!accWrap)
720 return 0;
721
722- nsCOMPtr<nsIAccessibleTable> accTable;
723- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
724- getter_AddRefs(accTable));
725+ nsCOMPtr<nsIAccessibleTable> accTable =
726+ dont_AddRef(static_cast<nsIAccessibleTable*>
727+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleTable))));
728 NS_ENSURE_TRUE(accTable, 0);
729
730 PRUint32 size = 0;
731 PRInt32 *rows = NULL;
732 nsresult rv = accTable->GetSelectedRowIndices(&size, &rows);
733 if (NS_FAILED(rv) || (size == 0) || !rows) {
734 *aSelected = nsnull;
735 return 0;
736@@ -454,51 +454,51 @@ getSelectedRowsCB(AtkTable *aTable, gint
737
738 gboolean
739 isColumnSelectedCB(AtkTable *aTable, gint aColumn)
740 {
741 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
742 if (!accWrap)
743 return FALSE;
744
745- nsCOMPtr<nsIAccessibleTable> accTable;
746- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
747- getter_AddRefs(accTable));
748+ nsCOMPtr<nsIAccessibleTable> accTable =
749+ dont_AddRef(static_cast<nsIAccessibleTable*>
750+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleTable))));
751 NS_ENSURE_TRUE(accTable, FALSE);
752
753 PRBool outValue;
754 nsresult rv = accTable->IsColumnSelected(aColumn, &outValue);
755 return NS_FAILED(rv) ? FALSE : static_cast<gboolean>(outValue);
756 }
757
758 gboolean
759 isRowSelectedCB(AtkTable *aTable, gint aRow)
760 {
761 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
762 if (!accWrap)
763 return FALSE;
764
765- nsCOMPtr<nsIAccessibleTable> accTable;
766- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
767- getter_AddRefs(accTable));
768+ nsCOMPtr<nsIAccessibleTable> accTable =
769+ dont_AddRef(static_cast<nsIAccessibleTable*>
770+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleTable))));
771 NS_ENSURE_TRUE(accTable, FALSE);
772
773 PRBool outValue;
774 nsresult rv = accTable->IsRowSelected(aRow, &outValue);
775 return NS_FAILED(rv) ? FALSE : static_cast<gboolean>(outValue);
776 }
777
778 gboolean
779 isCellSelectedCB(AtkTable *aTable, gint aRow, gint aColumn)
780 {
781 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aTable));
782 if (!accWrap)
783 return FALSE;
784
785- nsCOMPtr<nsIAccessibleTable> accTable;
786- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleTable),
787- getter_AddRefs(accTable));
788+ nsCOMPtr<nsIAccessibleTable> accTable =
789+ dont_AddRef(static_cast<nsIAccessibleTable*>
790+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleTable))));
791 NS_ENSURE_TRUE(accTable, FALSE);
792
793 PRBool outValue;
794 nsresult rv = accTable->IsCellSelected(aRow, aColumn, &outValue);
795 return NS_FAILED(rv) ? FALSE : static_cast<gboolean>(outValue);
796 }
797diff --git a/accessible/src/atk/nsMaiInterfaceText.cpp b/accessible/src/atk/nsMaiInterfaceText.cpp
798--- a/accessible/src/atk/nsMaiInterfaceText.cpp
799+++ b/accessible/src/atk/nsMaiInterfaceText.cpp
800@@ -87,19 +87,19 @@ void ConvertTexttoAsterisks(nsAccessible
801
802 gchar *
803 getTextCB(AtkText *aText, gint aStartOffset, gint aEndOffset)
804 {
805 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
806 if (!accWrap)
807 return nsnull;
808
809- nsCOMPtr<nsIAccessibleText> accText;
810- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
811- getter_AddRefs(accText));
812+ nsCOMPtr<nsIAccessibleText> accText =
813+ dont_AddRef(static_cast<nsIAccessibleText*>
814+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleText))));
815 NS_ENSURE_TRUE(accText, nsnull);
816
817 nsAutoString autoStr;
818 nsresult rv = accText->GetText(aStartOffset, aEndOffset, autoStr);
819 NS_ENSURE_SUCCESS(rv, nsnull);
820
821 ConvertTexttoAsterisks(accWrap, autoStr);
822 NS_ConvertUTF16toUTF8 cautoStr(autoStr);
823@@ -112,19 +112,19 @@ gchar *
824 getTextAfterOffsetCB(AtkText *aText, gint aOffset,
825 AtkTextBoundary aBoundaryType,
826 gint *aStartOffset, gint *aEndOffset)
827 {
828 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
829 if (!accWrap)
830 return nsnull;
831
832- nsCOMPtr<nsIAccessibleText> accText;
833- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
834- getter_AddRefs(accText));
835+ nsCOMPtr<nsIAccessibleText> accText =
836+ dont_AddRef(static_cast<nsIAccessibleText*>
837+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleText))));
838 NS_ENSURE_TRUE(accText, nsnull);
839
840 nsAutoString autoStr;
841 PRInt32 startOffset = 0, endOffset = 0;
842 nsresult rv =
843 accText->GetTextAfterOffset(aOffset, aBoundaryType,
844 &startOffset, &endOffset, autoStr);
845 *aStartOffset = startOffset;
846@@ -141,19 +141,19 @@ gchar *
847 getTextAtOffsetCB(AtkText *aText, gint aOffset,
848 AtkTextBoundary aBoundaryType,
849 gint *aStartOffset, gint *aEndOffset)
850 {
851 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
852 if (!accWrap)
853 return nsnull;
854
855- nsCOMPtr<nsIAccessibleText> accText;
856- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
857- getter_AddRefs(accText));
858+ nsCOMPtr<nsIAccessibleText> accText =
859+ dont_AddRef(static_cast<nsIAccessibleText*>
860+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleText))));
861 NS_ENSURE_TRUE(accText, nsnull);
862
863 nsAutoString autoStr;
864 PRInt32 startOffset = 0, endOffset = 0;
865 nsresult rv =
866 accText->GetTextAtOffset(aOffset, aBoundaryType,
867 &startOffset, &endOffset, autoStr);
868 *aStartOffset = startOffset;
869@@ -168,19 +168,19 @@ getTextAtOffsetCB(AtkText *aText, gint a
870
871 gunichar
872 getCharacterAtOffsetCB(AtkText *aText, gint aOffset)
873 {
874 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
875 if (!accWrap)
876 return 0;
877
878- nsCOMPtr<nsIAccessibleText> accText;
879- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
880- getter_AddRefs(accText));
881+ nsCOMPtr<nsIAccessibleText> accText =
882+ dont_AddRef(static_cast<nsIAccessibleText*>
883+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleText))));
884 NS_ENSURE_TRUE(accText, 0);
885
886 /* PRUnichar is unsigned short in Mozilla */
887 /* gnuichar is guint32 in glib */
888 PRUnichar uniChar;
889 nsresult rv =
890 accText->GetCharacterAtOffset(aOffset, &uniChar);
891
892@@ -196,19 +196,19 @@ gchar *
893 getTextBeforeOffsetCB(AtkText *aText, gint aOffset,
894 AtkTextBoundary aBoundaryType,
895 gint *aStartOffset, gint *aEndOffset)
896 {
897 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
898 if (!accWrap)
899 return nsnull;
900
901- nsCOMPtr<nsIAccessibleText> accText;
902- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
903- getter_AddRefs(accText));
904+ nsCOMPtr<nsIAccessibleText> accText =
905+ dont_AddRef(static_cast<nsIAccessibleText*>
906+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleText))));
907 NS_ENSURE_TRUE(accText, nsnull);
908
909 nsAutoString autoStr;
910 PRInt32 startOffset = 0, endOffset = 0;
911 nsresult rv =
912 accText->GetTextBeforeOffset(aOffset, aBoundaryType,
913 &startOffset, &endOffset, autoStr);
914 *aStartOffset = startOffset;
915@@ -223,19 +223,19 @@ getTextBeforeOffsetCB(AtkText *aText, gi
916
917 gint
918 getCaretOffsetCB(AtkText *aText)
919 {
920 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
921 if (!accWrap)
922 return 0;
923
924- nsCOMPtr<nsIAccessibleText> accText;
925- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
926- getter_AddRefs(accText));
927+ nsCOMPtr<nsIAccessibleText> accText =
928+ dont_AddRef(static_cast<nsIAccessibleText*>
929+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleText))));
930 NS_ENSURE_TRUE(accText, 0);
931
932 PRInt32 offset;
933 nsresult rv = accText->GetCaretOffset(&offset);
934 return (NS_FAILED(rv)) ? 0 : static_cast<gint>(offset);
935 }
936
937 AtkAttributeSet *
938@@ -245,19 +245,19 @@ getRunAttributesCB(AtkText *aText, gint
939 {
940 *aStartOffset = -1;
941 *aEndOffset = -1;
942
943 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
944 if (!accWrap)
945 return nsnull;
946
947- nsCOMPtr<nsIAccessibleText> accText;
948- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
949- getter_AddRefs(accText));
950+ nsCOMPtr<nsIAccessibleText> accText =
951+ dont_AddRef(static_cast<nsIAccessibleText*>
952+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleText))));
953 NS_ENSURE_TRUE(accText, nsnull);
954
955 nsCOMPtr<nsIPersistentProperties> attributes;
956 PRInt32 startOffset = 0, endOffset = 0;
957 nsresult rv = accText->GetTextAttributes(PR_FALSE, aOffset,
958 &startOffset, &endOffset,
959 getter_AddRefs(attributes));
960 NS_ENSURE_SUCCESS(rv, nsnull);
961@@ -270,19 +270,19 @@ getRunAttributesCB(AtkText *aText, gint
962
963 AtkAttributeSet *
964 getDefaultAttributesCB(AtkText *aText)
965 {
966 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
967 if (!accWrap)
968 return nsnull;
969
970- nsCOMPtr<nsIAccessibleText> accText;
971- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
972- getter_AddRefs(accText));
973+ nsCOMPtr<nsIAccessibleText> accText =
974+ dont_AddRef(static_cast<nsIAccessibleText*>
975+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleText))));
976 NS_ENSURE_TRUE(accText, nsnull);
977
978 nsCOMPtr<nsIPersistentProperties> attributes;
979 nsresult rv = accText->GetDefaultTextAttributes(getter_AddRefs(attributes));
980 if (NS_FAILED(rv))
981 return nsnull;
982
983 return ConvertToAtkAttributeSet(attributes);
984@@ -293,19 +293,19 @@ getCharacterExtentsCB(AtkText *aText, gi
985 gint *aX, gint *aY,
986 gint *aWidth, gint *aHeight,
987 AtkCoordType aCoords)
988 {
989 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
990 if(!accWrap || !aX || !aY || !aWidth || !aHeight)
991 return;
992
993- nsCOMPtr<nsIAccessibleText> accText;
994- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
995- getter_AddRefs(accText));
996+ nsCOMPtr<nsIAccessibleText> accText =
997+ dont_AddRef(static_cast<nsIAccessibleText*>
998+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleText))));
999 if (!accText)
1000 return;
1001
1002 PRInt32 extY = 0, extX = 0;
1003 PRInt32 extWidth = 0, extHeight = 0;
1004
1005 PRUint32 geckoCoordType;
1006 if (aCoords == ATK_XY_SCREEN)
1007@@ -330,19 +330,19 @@ getCharacterExtentsCB(AtkText *aText, gi
1008 void
1009 getRangeExtentsCB(AtkText *aText, gint aStartOffset, gint aEndOffset,
1010 AtkCoordType aCoords, AtkTextRectangle *aRect)
1011 {
1012 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
1013 if(!accWrap || !aRect)
1014 return;
1015
1016- nsCOMPtr<nsIAccessibleText> accText;
1017- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
1018- getter_AddRefs(accText));
1019+ nsCOMPtr<nsIAccessibleText> accText =
1020+ dont_AddRef(static_cast<nsIAccessibleText*>
1021+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleText))));
1022 if (!accText)
1023 return;
1024
1025 PRInt32 extY = 0, extX = 0;
1026 PRInt32 extWidth = 0, extHeight = 0;
1027
1028 PRUint32 geckoCoordType;
1029 if (aCoords == ATK_XY_SCREEN)
1030@@ -381,19 +381,19 @@ gint
1031 getOffsetAtPointCB(AtkText *aText,
1032 gint aX, gint aY,
1033 AtkCoordType aCoords)
1034 {
1035 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
1036 if (!accWrap)
1037 return -1;
1038
1039- nsCOMPtr<nsIAccessibleText> accText;
1040- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
1041- getter_AddRefs(accText));
1042+ nsCOMPtr<nsIAccessibleText> accText =
1043+ dont_AddRef(static_cast<nsIAccessibleText*>
1044+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleText))));
1045 NS_ENSURE_TRUE(accText, -1);
1046
1047 PRInt32 offset = 0;
1048 PRUint32 geckoCoordType;
1049 if (aCoords == ATK_XY_SCREEN)
1050 geckoCoordType = nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE;
1051 else
1052 geckoCoordType = nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE;
1053@@ -404,38 +404,38 @@ getOffsetAtPointCB(AtkText *aText,
1054
1055 gint
1056 getTextSelectionCountCB(AtkText *aText)
1057 {
1058 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
1059 if (!accWrap)
1060 return nsnull;
1061
1062- nsCOMPtr<nsIAccessibleText> accText;
1063- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
1064- getter_AddRefs(accText));
1065+ nsCOMPtr<nsIAccessibleText> accText =
1066+ dont_AddRef(static_cast<nsIAccessibleText*>
1067+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleText))));
1068 NS_ENSURE_TRUE(accText, nsnull);
1069
1070 PRInt32 selectionCount;
1071 nsresult rv = accText->GetSelectionCount(&selectionCount);
1072
1073 return NS_FAILED(rv) ? 0 : selectionCount;
1074 }
1075
1076 gchar *
1077 getTextSelectionCB(AtkText *aText, gint aSelectionNum,
1078 gint *aStartOffset, gint *aEndOffset)
1079 {
1080 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
1081 if (!accWrap)
1082 return nsnull;
1083
1084- nsCOMPtr<nsIAccessibleText> accText;
1085- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
1086- getter_AddRefs(accText));
1087+ nsCOMPtr<nsIAccessibleText> accText =
1088+ dont_AddRef(static_cast<nsIAccessibleText*>
1089+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleText))));
1090 NS_ENSURE_TRUE(accText, nsnull);
1091
1092 PRInt32 startOffset = 0, endOffset = 0;
1093 nsresult rv = accText->GetSelectionBounds(aSelectionNum,
1094 &startOffset, &endOffset);
1095
1096 *aStartOffset = startOffset;
1097 *aEndOffset = endOffset;
1098@@ -450,69 +450,69 @@ gboolean
1099 addTextSelectionCB(AtkText *aText,
1100 gint aStartOffset,
1101 gint aEndOffset)
1102 {
1103 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
1104 if (!accWrap)
1105 return FALSE;
1106
1107- nsCOMPtr<nsIAccessibleText> accText;
1108- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
1109- getter_AddRefs(accText));
1110+ nsCOMPtr<nsIAccessibleText> accText =
1111+ dont_AddRef(static_cast<nsIAccessibleText*>
1112+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleText))));
1113 NS_ENSURE_TRUE(accText, FALSE);
1114
1115 nsresult rv = accText->AddSelection(aStartOffset, aEndOffset);
1116
1117 return NS_SUCCEEDED(rv) ? TRUE : FALSE;
1118 }
1119
1120 gboolean
1121 removeTextSelectionCB(AtkText *aText,
1122 gint aSelectionNum)
1123 {
1124 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
1125 if (!accWrap)
1126 return FALSE;
1127
1128- nsCOMPtr<nsIAccessibleText> accText;
1129- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
1130- getter_AddRefs(accText));
1131+ nsCOMPtr<nsIAccessibleText> accText =
1132+ dont_AddRef(static_cast<nsIAccessibleText*>
1133+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleText))));
1134 NS_ENSURE_TRUE(accText, FALSE);
1135
1136 nsresult rv = accText->RemoveSelection(aSelectionNum);
1137
1138 return NS_SUCCEEDED(rv) ? TRUE : FALSE;
1139 }
1140
1141 gboolean
1142 setTextSelectionCB(AtkText *aText, gint aSelectionNum,
1143 gint aStartOffset, gint aEndOffset)
1144 {
1145 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
1146 if (!accWrap)
1147 return FALSE;
1148
1149- nsCOMPtr<nsIAccessibleText> accText;
1150- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
1151- getter_AddRefs(accText));
1152+ nsCOMPtr<nsIAccessibleText> accText =
1153+ dont_AddRef(static_cast<nsIAccessibleText*>
1154+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleText))));
1155 NS_ENSURE_TRUE(accText, FALSE);
1156
1157 nsresult rv = accText->SetSelectionBounds(aSelectionNum,
1158 aStartOffset, aEndOffset);
1159 return NS_SUCCEEDED(rv) ? TRUE : FALSE;
1160 }
1161
1162 gboolean
1163 setCaretOffsetCB(AtkText *aText, gint aOffset)
1164 {
1165 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aText));
1166 if (!accWrap)
1167 return FALSE;
1168
1169- nsCOMPtr<nsIAccessibleText> accText;
1170- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleText),
1171- getter_AddRefs(accText));
1172+ nsCOMPtr<nsIAccessibleText> accText =
1173+ dont_AddRef(static_cast<nsIAccessibleText*>
1174+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleText))));
1175 NS_ENSURE_TRUE(accText, FALSE);
1176
1177 nsresult rv = accText->SetCaretOffset(aOffset);
1178 return NS_SUCCEEDED(rv) ? TRUE : FALSE;
1179 }
1180diff --git a/accessible/src/atk/nsMaiInterfaceValue.cpp b/accessible/src/atk/nsMaiInterfaceValue.cpp
1181--- a/accessible/src/atk/nsMaiInterfaceValue.cpp
1182+++ b/accessible/src/atk/nsMaiInterfaceValue.cpp
1183@@ -55,19 +55,19 @@ valueInterfaceInitCB(AtkValueIface *aIfa
1184
1185 void
1186 getCurrentValueCB(AtkValue *obj, GValue *value)
1187 {
1188 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
1189 if (!accWrap)
1190 return;
1191
1192- nsCOMPtr<nsIAccessibleValue> accValue;
1193- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
1194- getter_AddRefs(accValue));
1195+ nsCOMPtr<nsIAccessibleValue> accValue =
1196+ dont_AddRef(static_cast<nsIAccessibleValue*>
1197+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleValue))));
1198 if (!accValue)
1199 return;
1200
1201 memset (value, 0, sizeof (GValue));
1202 double accDouble;
1203 if (NS_FAILED(accValue->GetCurrentValue(&accDouble)))
1204 return;
1205 g_value_init (value, G_TYPE_DOUBLE);
1206@@ -76,19 +76,19 @@ getCurrentValueCB(AtkValue *obj, GValue
1207
1208 void
1209 getMaximumValueCB(AtkValue *obj, GValue *value)
1210 {
1211 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
1212 if (!accWrap)
1213 return;
1214
1215- nsCOMPtr<nsIAccessibleValue> accValue;
1216- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
1217- getter_AddRefs(accValue));
1218+ nsCOMPtr<nsIAccessibleValue> accValue =
1219+ dont_AddRef(static_cast<nsIAccessibleValue*>
1220+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleValue))));
1221 if (!accValue)
1222 return;
1223
1224 memset (value, 0, sizeof (GValue));
1225 double accDouble;
1226 if (NS_FAILED(accValue->GetMaximumValue(&accDouble)))
1227 return;
1228 g_value_init (value, G_TYPE_DOUBLE);
1229@@ -97,19 +97,19 @@ getMaximumValueCB(AtkValue *obj, GValue
1230
1231 void
1232 getMinimumValueCB(AtkValue *obj, GValue *value)
1233 {
1234 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
1235 if (!accWrap)
1236 return;
1237
1238- nsCOMPtr<nsIAccessibleValue> accValue;
1239- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
1240- getter_AddRefs(accValue));
1241+ nsCOMPtr<nsIAccessibleValue> accValue =
1242+ dont_AddRef(static_cast<nsIAccessibleValue*>
1243+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleValue))));
1244 if (!accValue)
1245 return;
1246
1247 memset (value, 0, sizeof (GValue));
1248 double accDouble;
1249 if (NS_FAILED(accValue->GetMinimumValue(&accDouble)))
1250 return;
1251 g_value_init (value, G_TYPE_DOUBLE);
1252@@ -118,19 +118,19 @@ getMinimumValueCB(AtkValue *obj, GValue
1253
1254 void
1255 getMinimumIncrementCB(AtkValue *obj, GValue *minimumIncrement)
1256 {
1257 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
1258 if (!accWrap)
1259 return;
1260
1261- nsCOMPtr<nsIAccessibleValue> accValue;
1262- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
1263- getter_AddRefs(accValue));
1264+ nsCOMPtr<nsIAccessibleValue> accValue =
1265+ dont_AddRef(static_cast<nsIAccessibleValue*>
1266+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleValue))));
1267 if (!accValue)
1268 return;
1269
1270 memset (minimumIncrement, 0, sizeof (GValue));
1271 double accDouble;
1272 if (NS_FAILED(accValue->GetMinimumIncrement(&accDouble)))
1273 return;
1274 g_value_init (minimumIncrement, G_TYPE_DOUBLE);
1275@@ -139,16 +139,16 @@ getMinimumIncrementCB(AtkValue *obj, GVa
1276
1277 gboolean
1278 setCurrentValueCB(AtkValue *obj, const GValue *value)
1279 {
1280 nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(obj));
1281 if (!accWrap)
1282 return FALSE;
1283
1284- nsCOMPtr<nsIAccessibleValue> accValue;
1285- accWrap->QueryInterface(NS_GET_IID(nsIAccessibleValue),
1286- getter_AddRefs(accValue));
1287+ nsCOMPtr<nsIAccessibleValue> accValue =
1288+ dont_AddRef(static_cast<nsIAccessibleValue*>
1289+ (accWrap->QueryInterfaceFast(NS_GET_IID(nsIAccessibleValue))));
1290 NS_ENSURE_TRUE(accValue, FALSE);
1291
1292 double accDouble =g_value_get_double (value);
1293 return !NS_FAILED(accValue->SetCurrentValue(accDouble));
1294 }
1295diff --git a/accessible/src/base/a11yGeneric.h b/accessible/src/base/a11yGeneric.h
1296--- a/accessible/src/base/a11yGeneric.h
1297+++ b/accessible/src/base/a11yGeneric.h
1298@@ -44,18 +44,17 @@
1299 // What we want is: NS_INTERFACE_MAP_ENTRY(self) for static IID accessors,
1300 // but some of our classes have an ambiguous base class of nsISupports which
1301 // prevents this from working (the default macro converts it to nsISupports,
1302 // then addrefs it, then returns it). Therefore, we expand the macro here and
1303 // change it so that it works. Yuck.
1304 #define NS_INTERFACE_MAP_STATIC_AMBIGUOUS(_class) \
1305 if (aIID.Equals(NS_GET_IID(_class))) { \
1306 NS_ADDREF(this); \
1307- *aInstancePtr = this; \
1308- return NS_OK; \
1309+ return this; \
1310 } else
1311
1312 #define NS_OK_DEFUNCT_OBJECT \
1313 NS_ERROR_GENERATE_SUCCESS(NS_ERROR_MODULE_GENERAL, 0x22)
1314
1315 #define NS_ENSURE_A11Y_SUCCESS(res, ret) \
1316 PR_BEGIN_MACRO \
1317 nsresult __rv = res; /* Don't evaluate |res| more than once */ \
1318diff --git a/accessible/src/base/nsAccessible.cpp b/accessible/src/base/nsAccessible.cpp
1319--- a/accessible/src/base/nsAccessible.cpp
1320+++ b/accessible/src/base/nsAccessible.cpp
1321@@ -132,66 +132,59 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
1322 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsAccessible, nsAccessNode)
1323 NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mParent)
1324 NS_IMPL_CYCLE_COLLECTION_UNLINK_NSTARRAY(mChildren)
1325 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
1326
1327 NS_IMPL_ADDREF_INHERITED(nsAccessible, nsAccessNode)
1328 NS_IMPL_RELEASE_INHERITED(nsAccessible, nsAccessNode)
1329
1330-nsresult nsAccessible::QueryInterface(REFNSIID aIID, void** aInstancePtr)
1331+NS_IMETHODIMP_(void*) nsAccessible::QueryInterfaceFast(REFNSIID aIID)
1332 {
1333 // Custom-built QueryInterface() knows when we support nsIAccessibleSelectable
1334 // based on role attribute and aria-multiselectable
1335- *aInstancePtr = nsnull;
1336
1337 if (aIID.Equals(NS_GET_IID(nsXPCOMCycleCollectionParticipant))) {
1338- *aInstancePtr = &NS_CYCLE_COLLECTION_NAME(nsAccessible);
1339- return NS_OK;
1340+ return &NS_CYCLE_COLLECTION_NAME(nsAccessible);
1341 }
1342
1343 if (aIID.Equals(NS_GET_IID(nsIAccessible))) {
1344- *aInstancePtr = static_cast<nsIAccessible*>(this);
1345 NS_ADDREF_THIS();
1346- return NS_OK;
1347+ return static_cast<nsIAccessible*>(this);
1348 }
1349
1350 if (aIID.Equals(NS_GET_IID(nsAccessible))) {
1351- *aInstancePtr = static_cast<nsAccessible*>(this);
1352 NS_ADDREF_THIS();
1353- return NS_OK;
1354+ return static_cast<nsAccessible*>(this);
1355 }
1356
1357 if (aIID.Equals(NS_GET_IID(nsIAccessibleSelectable))) {
1358 if (IsSelect()) {
1359- *aInstancePtr = static_cast<nsIAccessibleSelectable*>(this);
1360 NS_ADDREF_THIS();
1361- return NS_OK;
1362+ return static_cast<nsIAccessibleSelectable*>(this);
1363 }
1364- return NS_ERROR_NO_INTERFACE;
1365+ return nsnull;
1366 }
1367
1368 if (aIID.Equals(NS_GET_IID(nsIAccessibleValue))) {
1369 if (mRoleMapEntry && mRoleMapEntry->valueRule != eNoValue) {
1370- *aInstancePtr = static_cast<nsIAccessibleValue*>(this);
1371 NS_ADDREF_THIS();
1372- return NS_OK;
1373+ return static_cast<nsIAccessibleValue*>(this);
1374 }
1375- }
1376+ }
1377
1378 if (aIID.Equals(NS_GET_IID(nsIAccessibleHyperLink))) {
1379 if (IsLink()) {
1380- *aInstancePtr = static_cast<nsIAccessibleHyperLink*>(this);
1381 NS_ADDREF_THIS();
1382- return NS_OK;
1383+ return static_cast<nsIAccessibleHyperLink*>(this);
1384 }
1385- return NS_ERROR_NO_INTERFACE;
1386+ return nsnull;
1387 }
1388
1389- return nsAccessNodeWrap::QueryInterface(aIID, aInstancePtr);
1390+ return nsAccessNodeWrap::QueryInterfaceFast(aIID);
1391 }
1392
1393 nsAccessible::nsAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
1394 nsAccessNodeWrap(aContent, aShell),
1395 mParent(nsnull), mIndexInParent(-1), mFlags(eChildrenUninitialized),
1396 mIndexOfEmbeddedChild(-1), mRoleMapEntry(nsnull)
1397 {
1398 #ifdef NS_DEBUG_X
1399diff --git a/accessible/src/base/nsDocAccessible.cpp b/accessible/src/base/nsDocAccessible.cpp
1400--- a/accessible/src/base/nsDocAccessible.cpp
1401+++ b/accessible/src/base/nsDocAccessible.cpp
1402@@ -164,34 +164,29 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_
1403 NS_INTERFACE_MAP_ENTRY(nsIAccessibleDocument)
1404 NS_INTERFACE_MAP_ENTRY(nsIDocumentObserver)
1405 NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
1406 NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
1407 NS_INTERFACE_MAP_ENTRY(nsIObserver)
1408 NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIAccessibleDocument)
1409 foundInterface = 0;
1410
1411- nsresult status;
1412 if (!foundInterface) {
1413 // HTML document accessible must inherit from nsHyperTextAccessible to get
1414 // support text interfaces. XUL document accessible doesn't need this.
1415 // However at some point we may push <body> to implement the interfaces and
1416 // return nsDocAccessible to inherit from nsAccessibleWrap.
1417
1418- status = IsHyperText() ?
1419- nsHyperTextAccessible::QueryInterface(aIID,
1420- (void**)&foundInterface) :
1421- nsAccessible::QueryInterface(aIID, (void**)&foundInterface);
1422- } else {
1423- NS_ADDREF(foundInterface);
1424- status = NS_OK;
1425+ return IsHyperText() ?
1426+ nsHyperTextAccessible::QueryInterfaceFast(aIID) :
1427+ nsAccessible::QueryInterfaceFast(aIID);
1428 }
1429
1430- *aInstancePtr = foundInterface;
1431- return status;
1432+ NS_ADDREF(foundInterface);
1433+ return foundInterface;
1434 }
1435
1436 NS_IMPL_ADDREF_INHERITED(nsDocAccessible, nsHyperTextAccessible)
1437 NS_IMPL_RELEASE_INHERITED(nsDocAccessible, nsHyperTextAccessible)
1438
1439
1440 ////////////////////////////////////////////////////////////////////////////////
1441 // nsIAccessible
1442diff --git a/accessible/src/html/nsHyperTextAccessible.cpp b/accessible/src/html/nsHyperTextAccessible.cpp
1443--- a/accessible/src/html/nsHyperTextAccessible.cpp
1444+++ b/accessible/src/html/nsHyperTextAccessible.cpp
1445@@ -77,55 +77,49 @@ nsHyperTextAccessible::
1446 nsAccessibleWrap(aNode, aShell)
1447 {
1448 mFlags |= eHyperTextAccessible;
1449 }
1450
1451 NS_IMPL_ADDREF_INHERITED(nsHyperTextAccessible, nsAccessibleWrap)
1452 NS_IMPL_RELEASE_INHERITED(nsHyperTextAccessible, nsAccessibleWrap)
1453
1454-nsresult nsHyperTextAccessible::QueryInterface(REFNSIID aIID, void** aInstancePtr)
1455+NS_IMETHODIMP_(void*) nsHyperTextAccessible::QueryInterfaceFast(REFNSIID aIID)
1456 {
1457- *aInstancePtr = nsnull;
1458-
1459 if (aIID.Equals(NS_GET_IID(nsHyperTextAccessible))) {
1460- *aInstancePtr = static_cast<nsHyperTextAccessible*>(this);
1461 NS_ADDREF_THIS();
1462- return NS_OK;
1463+ return static_cast<nsHyperTextAccessible*>(this);
1464 }
1465
1466 if (mRoleMapEntry &&
1467 (mRoleMapEntry->role == nsIAccessibleRole::ROLE_GRAPHIC ||
1468 mRoleMapEntry->role == nsIAccessibleRole::ROLE_IMAGE_MAP ||
1469 mRoleMapEntry->role == nsIAccessibleRole::ROLE_SLIDER ||
1470 mRoleMapEntry->role == nsIAccessibleRole::ROLE_PROGRESSBAR ||
1471 mRoleMapEntry->role == nsIAccessibleRole::ROLE_SEPARATOR)) {
1472 // ARIA roles that these interfaces are not appropriate for
1473- return nsAccessible::QueryInterface(aIID, aInstancePtr);
1474+ return nsAccessible::QueryInterfaceFast(aIID);
1475 }
1476
1477 if (aIID.Equals(NS_GET_IID(nsIAccessibleText))) {
1478- *aInstancePtr = static_cast<nsIAccessibleText*>(this);
1479 NS_ADDREF_THIS();
1480- return NS_OK;
1481+ return static_cast<nsIAccessibleText*>(this);
1482 }
1483
1484 if (aIID.Equals(NS_GET_IID(nsIAccessibleHyperText))) {
1485- *aInstancePtr = static_cast<nsIAccessibleHyperText*>(this);
1486 NS_ADDREF_THIS();
1487- return NS_OK;
1488+ return static_cast<nsIAccessibleHyperText*>(this);
1489 }
1490
1491 if (aIID.Equals(NS_GET_IID(nsIAccessibleEditableText))) {
1492- *aInstancePtr = static_cast<nsIAccessibleEditableText*>(this);
1493 NS_ADDREF_THIS();
1494- return NS_OK;
1495+ return static_cast<nsIAccessibleEditableText*>(this);
1496 }
1497
1498- return nsAccessible::QueryInterface(aIID, aInstancePtr);
1499+ return nsAccessible::QueryInterfaceFast(aIID);
1500 }
1501
1502 PRUint32
1503 nsHyperTextAccessible::NativeRole()
1504 {
1505 nsIAtom *tag = mContent->Tag();
1506
1507 if (tag == nsGkAtoms::form)
1508diff --git a/accessible/src/msaa/CAccessibleAction.h b/accessible/src/msaa/CAccessibleAction.h
1509--- a/accessible/src/msaa/CAccessibleAction.h
1510+++ b/accessible/src/msaa/CAccessibleAction.h
1511@@ -73,17 +73,17 @@ public:
1512 /* [in] */ long actionIndex,
1513 /* [retval][out] */ BSTR *name);
1514
1515 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_localizedName(
1516 /* [in] */ long actionIndex,
1517 /* [retval][out] */ BSTR *localizedName);
1518
1519 // nsISupports
1520- NS_IMETHOD QueryInterface(const nsIID& uuid, void** result) = 0;
1521+ NS_IMETHOD_(void*) QueryInterfaceFast(const nsIID& uuid) = 0;
1522
1523 };
1524
1525
1526 #define FORWARD_IACCESSIBLEACTION(Class) \
1527 virtual HRESULT STDMETHODCALLTYPE nActions(long *nActions) \
1528 { \
1529 return Class::nActions(nActions); \
1530diff --git a/accessible/src/msaa/CAccessibleComponent.h b/accessible/src/msaa/CAccessibleComponent.h
1531--- a/accessible/src/msaa/CAccessibleComponent.h
1532+++ b/accessible/src/msaa/CAccessibleComponent.h
1533@@ -59,17 +59,17 @@ public:
1534
1535 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_foreground(
1536 /* [retval][out] */ IA2Color *foreground);
1537
1538 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_background(
1539 /* [retval][out] */ IA2Color *background);
1540
1541 // nsISupports
1542- NS_IMETHOD QueryInterface(const nsIID& uuid, void** result) = 0;
1543+ NS_IMETHOD_(void*) QueryInterfaceFast(const nsIID& uuid) = 0;
1544
1545 protected:
1546
1547 /**
1548 * Return ARGB value for CSS property like 'color' or 'background-color'.
1549 */
1550 HRESULT GetARGBValueFromCSSProperty(const nsAString& aPropName,
1551 IA2Color *aColorValue);
1552diff --git a/accessible/src/msaa/CAccessibleEditableText.h b/accessible/src/msaa/CAccessibleEditableText.h
1553--- a/accessible/src/msaa/CAccessibleEditableText.h
1554+++ b/accessible/src/msaa/CAccessibleEditableText.h
1555@@ -79,13 +79,13 @@ public:
1556 /* [in] */ BSTR *text);
1557
1558 virtual HRESULT STDMETHODCALLTYPE setAttributes(
1559 /* [in] */ long startOffset,
1560 /* [in] */ long endOffset,
1561 /* [in] */ BSTR *attributes);
1562
1563 // nsISupports
1564- NS_IMETHOD QueryInterface(const nsIID& uuid, void** result) = 0;
1565+ NS_IMETHOD_(void*) QueryInterfaceFast(const nsIID& uuid) = 0;
1566 };
1567
1568 #endif
1569
1570diff --git a/accessible/src/msaa/CAccessibleHyperlink.h b/accessible/src/msaa/CAccessibleHyperlink.h
1571--- a/accessible/src/msaa/CAccessibleHyperlink.h
1572+++ b/accessible/src/msaa/CAccessibleHyperlink.h
1573@@ -70,14 +70,14 @@ public:
1574
1575 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_endIndex(
1576 /* [retval][out] */ long *index);
1577
1578 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_valid(
1579 /* [retval][out] */ boolean *valid);
1580
1581 // nsISupports
1582- NS_IMETHOD QueryInterface(const nsIID& uuid, void** result) = 0;
1583+ NS_IMETHOD_(void*) QueryInterfaceFast(const nsIID& uuid) = 0;
1584
1585 };
1586
1587 #endif
1588
1589diff --git a/accessible/src/msaa/CAccessibleHypertext.h b/accessible/src/msaa/CAccessibleHypertext.h
1590--- a/accessible/src/msaa/CAccessibleHypertext.h
1591+++ b/accessible/src/msaa/CAccessibleHypertext.h
1592@@ -65,13 +65,13 @@ public:
1593 /* [in] */ long index,
1594 /* [retval][out] */ IAccessibleHyperlink **hyperlink);
1595
1596 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_hyperlinkIndex(
1597 /* [in] */ long charIndex,
1598 /* [retval][out] */ long *hyperlinkIndex);
1599
1600 // nsISupports
1601- NS_IMETHOD QueryInterface(const nsIID& uuid, void** result) = 0;
1602+ NS_IMETHOD_(void*) QueryInterfaceFast(const nsIID& uuid) = 0;
1603 };
1604
1605 #endif
1606
1607diff --git a/accessible/src/msaa/CAccessibleImage.h b/accessible/src/msaa/CAccessibleImage.h
1608--- a/accessible/src/msaa/CAccessibleImage.h
1609+++ b/accessible/src/msaa/CAccessibleImage.h
1610@@ -61,14 +61,14 @@ public:
1611 /* [out] */ long *x,
1612 /* [retval][out] */ long *y);
1613
1614 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_imageSize(
1615 /* [out] */ long *height,
1616 /* [retval][out] */ long *width);
1617
1618 // nsISupports
1619- NS_IMETHOD QueryInterface(const nsIID& uuid, void** result) = 0;
1620+ NS_IMETHOD_(void*) QueryInterfaceFast(const nsIID& uuid) = 0;
1621
1622 };
1623
1624 #endif
1625
1626diff --git a/accessible/src/msaa/CAccessibleTable.h b/accessible/src/msaa/CAccessibleTable.h
1627--- a/accessible/src/msaa/CAccessibleTable.h
1628+++ b/accessible/src/msaa/CAccessibleTable.h
1629@@ -190,17 +190,17 @@ public:
1630 /* [out, size_is(,*nColumns)] */ long **selectedColumns,
1631 /* [out, retval] */ long *nColumns);
1632
1633 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_selectedRows(
1634 /* [out, size_is(,*nRows)] */ long **selectedRows,
1635 /* [out, retval] */ long *nRows);
1636
1637 // nsISupports
1638- NS_IMETHOD QueryInterface(const nsIID& uuid, void** result) = 0;
1639+ NS_IMETHOD_(void*) QueryInterfaceFast(const nsIID& uuid) = 0;
1640
1641 private:
1642 enum eItemsType {
1643 ITEMSTYPE_CELLS,
1644 ITEMSTYPE_COLUMNS,
1645 ITEMSTYPE_ROWS
1646 };
1647
1648diff --git a/accessible/src/msaa/CAccessibleTableCell.h b/accessible/src/msaa/CAccessibleTableCell.h
1649--- a/accessible/src/msaa/CAccessibleTableCell.h
1650+++ b/accessible/src/msaa/CAccessibleTableCell.h
1651@@ -83,12 +83,12 @@ public:
1652 /* [out] */ long *rowExtents,
1653 /* [out] */ long *columnExtents,
1654 /* [out, retval] */ boolean *isSelected);
1655
1656 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_isSelected(
1657 /* [out, retval] */ boolean *isSelected);
1658
1659 // nsISupports
1660- NS_IMETHOD QueryInterface(const nsIID& uuid, void** result) = 0;
1661+ NS_IMETHOD_(void*) QueryInterfaceFast(const nsIID& uuid) = 0;
1662 };
1663
1664 #endif
1665diff --git a/accessible/src/msaa/CAccessibleText.h b/accessible/src/msaa/CAccessibleText.h
1666--- a/accessible/src/msaa/CAccessibleText.h
1667+++ b/accessible/src/msaa/CAccessibleText.h
1668@@ -143,17 +143,17 @@ public:
1669
1670 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_newText(
1671 /* [retval][out] */ IA2TextSegment *newText);
1672
1673 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_oldText(
1674 /* [retval][out] */ IA2TextSegment *oldText);
1675
1676 // nsISupports
1677- NS_IMETHOD QueryInterface(const nsIID& uuid, void** result) = 0;
1678+ NS_IMETHOD_(void*) QueryInterfaceFast(const nsIID& uuid) = 0;
1679
1680 protected:
1681 virtual nsresult GetModifiedText(PRBool aGetInsertedText, nsAString& aText,
1682 PRUint32 *aStartOffset,
1683 PRUint32 *aEndOffset) = 0;
1684
1685 private:
1686 HRESULT GetModifiedText(PRBool aGetInsertedText, IA2TextSegment *aNewText);
1687diff --git a/accessible/src/msaa/CAccessibleValue.h b/accessible/src/msaa/CAccessibleValue.h
1688--- a/accessible/src/msaa/CAccessibleValue.h
1689+++ b/accessible/src/msaa/CAccessibleValue.h
1690@@ -61,14 +61,14 @@ public:
1691
1692 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_maximumValue(
1693 /* [retval][out] */ VARIANT *maximumValue);
1694
1695 virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_minimumValue(
1696 /* [retval][out] */ VARIANT *minimumValue);
1697
1698 // nsISupports
1699- NS_IMETHOD QueryInterface(const nsIID& uuid, void** result) = 0;
1700+ NS_IMETHOD_(void*) QueryInterfaceFast(const nsIID& uuid) = 0;
1701
1702 };
1703
1704 #endif
1705
1706diff --git a/accessible/src/msaa/ia2AccessibleRelation.cpp b/accessible/src/msaa/ia2AccessibleRelation.cpp
1707--- a/accessible/src/msaa/ia2AccessibleRelation.cpp
1708+++ b/accessible/src/msaa/ia2AccessibleRelation.cpp
1709@@ -186,17 +186,18 @@ __try {
1710
1711 STDMETHODIMP
1712 ia2AccessibleRelation::get_target(long aTargetIndex, IUnknown **aTarget)
1713 {
1714 __try {
1715 if (aTargetIndex < 0 || aTargetIndex >= mTargets.Length() || !aTarget)
1716 return E_INVALIDARG;
1717
1718- mTargets[aTargetIndex]->QueryInterface((const nsID&) IID_IUnknown, (void**) aTarget);
1719+ *aTarget = static_cast<IUnknown*>
1720+ (mTargets[aTargetIndex]->QueryInterfaceFast((const nsID&) IID_IUnknown));
1721 return S_OK;
1722
1723 } __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
1724 return E_FAIL;
1725 }
1726
1727 STDMETHODIMP
1728 ia2AccessibleRelation::get_targets(long aMaxTargets, IUnknown **aTargets,
1729diff --git a/accessible/src/xul/nsXULListboxAccessible.cpp b/accessible/src/xul/nsXULListboxAccessible.cpp
1730--- a/accessible/src/xul/nsXULListboxAccessible.cpp
1731+++ b/accessible/src/xul/nsXULListboxAccessible.cpp
1732@@ -131,30 +131,29 @@ nsXULListboxAccessible::
1733 nsXULListboxAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
1734 nsXULSelectableAccessible(aContent, aShell)
1735 {
1736 }
1737
1738 NS_IMPL_ADDREF_INHERITED(nsXULListboxAccessible, nsXULSelectableAccessible)
1739 NS_IMPL_RELEASE_INHERITED(nsXULListboxAccessible, nsXULSelectableAccessible)
1740
1741-nsresult
1742-nsXULListboxAccessible::QueryInterface(REFNSIID aIID, void** aInstancePtr)
1743+NS_IMETHODIMP_(void*)
1744+nsXULListboxAccessible::QueryInterfaceFast(REFNSIID aIID)
1745 {
1746- nsresult rv = nsXULSelectableAccessible::QueryInterface(aIID, aInstancePtr);
1747- if (*aInstancePtr)
1748- return rv;
1749+ void* result = nsXULSelectableAccessible::QueryInterfaceFast(aIID);
1750+ if (result)
1751+ return result;
1752
1753 if (aIID.Equals(NS_GET_IID(nsIAccessibleTable)) && IsMulticolumn()) {
1754- *aInstancePtr = static_cast<nsIAccessibleTable*>(this);
1755 NS_ADDREF_THIS();
1756- return NS_OK;
1757+ return static_cast<nsIAccessibleTable*>(this);
1758 }
1759
1760- return NS_ERROR_NO_INTERFACE;
1761+ return nsnull;
1762 }
1763
1764 PRBool
1765 nsXULListboxAccessible::IsMulticolumn()
1766 {
1767 PRInt32 numColumns = 0;
1768 nsresult rv = GetColumnCount(&numColumns);
1769 if (NS_FAILED(rv))
1770diff --git a/content/base/public/nsContentUtils.h b/content/base/public/nsContentUtils.h
1771--- a/content/base/public/nsContentUtils.h
1772+++ b/content/base/public/nsContentUtils.h
1773@@ -1977,18 +1977,17 @@ public:
1774 #endif
1775 }
1776 };
1777
1778 #define NS_INTERFACE_MAP_ENTRY_TEAROFF(_interface, _allocator) \
1779 if (aIID.Equals(NS_GET_IID(_interface))) { \
1780 foundInterface = static_cast<_interface *>(_allocator); \
1781 if (!foundInterface) { \
1782- *aInstancePtr = nsnull; \
1783- return NS_ERROR_OUT_OF_MEMORY; \
1784+ return nsnull; \
1785 } \
1786 } else
1787
1788 /**
1789 * Macros to workaround math-bugs bugs in various platforms
1790 */
1791
1792 /**
1793diff --git a/content/base/public/nsINode.h b/content/base/public/nsINode.h
1794--- a/content/base/public/nsINode.h
1795+++ b/content/base/public/nsINode.h
1796@@ -1396,23 +1396,21 @@ extern const nsIID kThisPtrOffsetsSID;
1797 NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsISupports, _implClass)
1798
1799 #define NS_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class) \
1800 NS_OFFSET_AND_INTERFACE_TABLE_BEGIN_AMBIGUOUS(_class, _class)
1801
1802 #define NS_OFFSET_AND_INTERFACE_TABLE_END \
1803 { nsnull, 0 } }; \
1804 if (aIID.Equals(kThisPtrOffsetsSID)) { \
1805- *aInstancePtr = \
1806- const_cast<void*>(static_cast<const void*>(&offsetAndQITable)); \
1807- return NS_OK; \
1808+ return const_cast<void*>(static_cast<const void*>(&offsetAndQITable)); \
1809 }
1810
1811 #define NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE \
1812- rv = NS_TableDrivenQI(this, offsetAndQITable, aIID, aInstancePtr); \
1813+ result = NS_TableDrivenQI(this, offsetAndQITable, aIID); \
1814 NS_INTERFACE_TABLE_TO_MAP_SEGUE
1815
1816 // nsNodeSH::PreCreate() depends on the identity pointer being the same as
1817 // nsINode, so if you change the nsISupports line below, make sure
1818 // nsNodeSH::PreCreate() still does the right thing!
1819 #define NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class) \
1820 NS_OFFSET_AND_INTERFACE_TABLE_BEGIN_AMBIGUOUS(_class, nsINode) \
1821 NS_INTERFACE_TABLE_ENTRY(_class, nsINode)
1822diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp
1823--- a/content/base/src/nsContentUtils.cpp
1824+++ b/content/base/src/nsContentUtils.cpp
1825@@ -4914,17 +4914,18 @@ nsSameOriginChecker::AsyncOnChannelRedir
1826 }
1827
1828 return rv;
1829 }
1830
1831 NS_IMETHODIMP
1832 nsSameOriginChecker::GetInterface(const nsIID & aIID, void **aResult)
1833 {
1834- return QueryInterface(aIID, aResult);
1835+ *aResult = QueryInterfaceFast(aIID);
1836+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
1837 }
1838
1839 /* static */
1840 nsresult
1841 nsContentUtils::GetASCIIOrigin(nsIPrincipal* aPrincipal, nsCString& aOrigin)
1842 {
1843 NS_PRECONDITION(aPrincipal, "missing principal");
1844
1845diff --git a/content/base/src/nsCrossSiteListenerProxy.cpp b/content/base/src/nsCrossSiteListenerProxy.cpp
1846--- a/content/base/src/nsCrossSiteListenerProxy.cpp
1847+++ b/content/base/src/nsCrossSiteListenerProxy.cpp
1848@@ -1024,17 +1024,18 @@ nsCORSPreflightListener::AsyncOnChannelR
1849
1850 callback->OnRedirectVerifyCallback(NS_OK);
1851 return NS_OK;
1852 }
1853
1854 NS_IMETHODIMP
1855 nsCORSPreflightListener::GetInterface(const nsIID & aIID, void **aResult)
1856 {
1857- return QueryInterface(aIID, aResult);
1858+ *aResult = QueryInterfaceFast(aIID);
1859+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
1860 }
1861
1862
1863 nsresult
1864 NS_StartCORSPreflight(nsIChannel* aRequestChannel,
1865 nsIStreamListener* aListener,
1866 nsIPrincipal* aPrincipal,
1867 PRBool aWithCredentials,
1868diff --git a/content/base/src/nsDOMFileReader.cpp b/content/base/src/nsDOMFileReader.cpp
1869--- a/content/base/src/nsDOMFileReader.cpp
1870+++ b/content/base/src/nsDOMFileReader.cpp
1871@@ -244,17 +244,18 @@ nsDOMFileReader::Initialize(nsISupports*
1872 return NS_OK;
1873 }
1874
1875 // nsIInterfaceRequestor
1876
1877 NS_IMETHODIMP
1878 nsDOMFileReader::GetInterface(const nsIID & aIID, void **aResult)
1879 {
1880- return QueryInterface(aIID, aResult);
1881+ *aResult = QueryInterfaceFast(aIID);
1882+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
1883 }
1884
1885 // nsIDOMFileReader
1886
1887 NS_IMETHODIMP
1888 nsDOMFileReader::GetReadyState(PRUint16 *aReadyState)
1889 {
1890 *aReadyState = mReadyState;
1891diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp
1892--- a/content/base/src/nsDocument.cpp
1893+++ b/content/base/src/nsDocument.cpp
1894@@ -1698,20 +1698,20 @@ NS_INTERFACE_TABLE_HEAD(nsDocument)
1895 new nsNodeSelectorTearoff(this))
1896 if (aIID.Equals(NS_GET_IID(nsIDOMXPathEvaluator)) ||
1897 aIID.Equals(NS_GET_IID(nsIXPathEvaluatorInternal))) {
1898 if (!mXPathEvaluatorTearoff) {
1899 nsresult rv;
1900 mXPathEvaluatorTearoff =
1901 do_CreateInstance(NS_XPATH_EVALUATOR_CONTRACTID,
1902 static_cast<nsIDocument *>(this), &rv);
1903- NS_ENSURE_SUCCESS(rv, rv);
1904- }
1905-
1906- return mXPathEvaluatorTearoff->QueryInterface(aIID, aInstancePtr);
1907+ NS_ENSURE_SUCCESS(rv, nsnull);
1908+ }
1909+
1910+ return mXPathEvaluatorTearoff->QueryInterfaceFast(aIID);
1911 }
1912 else
1913 NS_INTERFACE_MAP_END
1914
1915
1916 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDocument)
1917 NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_DESTROY(nsDocument,
1918 nsNodeUtils::LastRelease(this))
1919diff --git a/content/base/src/nsEventSource.cpp b/content/base/src/nsEventSource.cpp
1920--- a/content/base/src/nsEventSource.cpp
1921+++ b/content/base/src/nsEventSource.cpp
1922@@ -767,17 +767,18 @@ nsEventSource::GetInterface(const nsIID
1923 nsCOMPtr<nsIDOMWindow> window;
1924 if (mOwner) {
1925 window = mOwner->GetOuterWindow();
1926 }
1927
1928 return wwatch->GetPrompt(window, aIID, aResult);
1929 }
1930
1931- return QueryInterface(aIID, aResult);
1932+ *aResult = QueryInterfaceFast(aIID);
1933+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
1934 }
1935
1936 // static
1937 PRBool
1938 nsEventSource::PrefEnabled()
1939 {
1940 return Preferences::GetBool("dom.server-events.enabled", PR_FALSE);
1941 }
1942diff --git a/content/base/src/nsFileDataProtocolHandler.cpp b/content/base/src/nsFileDataProtocolHandler.cpp
1943--- a/content/base/src/nsFileDataProtocolHandler.cpp
1944+++ b/content/base/src/nsFileDataProtocolHandler.cpp
1945@@ -170,18 +170,17 @@ NS_IMPL_RELEASE_INHERITED(nsFileDataURI,
1946 NS_INTERFACE_MAP_BEGIN(nsFileDataURI)
1947 NS_INTERFACE_MAP_ENTRY(nsIURIWithPrincipal)
1948 if (aIID.Equals(kFILEDATAURICID))
1949 foundInterface = static_cast<nsIURI*>(this);
1950 else if (aIID.Equals(kThisSimpleURIImplementationCID)) {
1951 // Need to return explicitly here, because if we just set foundInterface
1952 // to null the NS_INTERFACE_MAP_END_INHERITING will end up calling into
1953 // nsSimplURI::QueryInterface and finding something for this CID.
1954- *aInstancePtr = nsnull;
1955- return NS_NOINTERFACE;
1956+ return nsnull;
1957 }
1958 else
1959 NS_INTERFACE_MAP_END_INHERITING(nsSimpleURI)
1960
1961 // nsIURIWithPrincipal methods:
1962
1963 NS_IMETHODIMP
1964 nsFileDataURI::GetPrincipal(nsIPrincipal** aPrincipal)
1965diff --git a/content/base/src/nsGenericElement.h b/content/base/src/nsGenericElement.h
1966--- a/content/base/src/nsGenericElement.h
1967+++ b/content/base/src/nsGenericElement.h
1968@@ -1100,27 +1100,26 @@ public:
1969 {
1970 }
1971
1972 private:
1973 nsRefPtr<nsGenericElement> mElement;
1974 };
1975
1976 #define NS_ELEMENT_INTERFACE_TABLE_TO_MAP_SEGUE \
1977- rv = nsGenericElement::QueryInterface(aIID, aInstancePtr); \
1978- if (NS_SUCCEEDED(rv)) \
1979- return rv; \
1980+ result = nsGenericElement::QueryInterfaceFast(aIID); \
1981+ if (result) \
1982+ return result; \
1983 \
1984 NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
1985
1986 #define NS_ELEMENT_INTERFACE_MAP_END \
1987 { \
1988- return PostQueryInterface(aIID, aInstancePtr); \
1989+ PostQueryInterface(aIID, reinterpret_cast<void**> (&foundInterface)); \
1990+ return foundInterface; \
1991 } \
1992 \
1993 NS_ADDREF(foundInterface); \
1994 \
1995- *aInstancePtr = foundInterface; \
1996- \
1997- return NS_OK; \
1998+ return foundInterface; \
1999 }
2000
2001 #endif /* nsGenericElement_h___ */
2002diff --git a/content/base/src/nsStyleLinkElement.cpp b/content/base/src/nsStyleLinkElement.cpp
2003--- a/content/base/src/nsStyleLinkElement.cpp
2004+++ b/content/base/src/nsStyleLinkElement.cpp
2005@@ -225,18 +225,18 @@ nsStyleLinkElement::DoUpdateStyleSheet(n
2006 aOldDocument->EndUpdate(UPDATE_STYLE);
2007 nsStyleLinkElement::SetStyleSheet(nsnull);
2008 }
2009
2010 if (mDontLoadStyle || !mUpdatesEnabled) {
2011 return NS_OK;
2012 }
2013
2014- nsCOMPtr<nsIContent> thisContent;
2015- QueryInterface(NS_GET_IID(nsIContent), getter_AddRefs(thisContent));
2016+ nsCOMPtr<nsIContent> thisContent = dont_AddRef(static_cast<nsIContent*>
2017+ (QueryInterfaceFast(NS_GET_IID(nsIContent))));
2018
2019 NS_ENSURE_TRUE(thisContent, NS_ERROR_FAILURE);
2020
2021 nsCOMPtr<nsIDocument> doc = thisContent->GetDocument();
2022
2023 if (!doc || !doc->CSSLoader()->GetEnabled()) {
2024 return NS_OK;
2025 }
2026diff --git a/content/base/src/nsStyleLinkElement.h b/content/base/src/nsStyleLinkElement.h
2027--- a/content/base/src/nsStyleLinkElement.h
2028+++ b/content/base/src/nsStyleLinkElement.h
2029@@ -57,17 +57,17 @@ class nsIDocument;
2030
2031 class nsStyleLinkElement : public nsIDOMLinkStyle,
2032 public nsIStyleSheetLinkingElement
2033 {
2034 public:
2035 nsStyleLinkElement();
2036 virtual ~nsStyleLinkElement();
2037
2038- NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) = 0;
2039+ NS_IMETHOD_(void*) QueryInterfaceFast(REFNSIID aIID) = 0;
2040
2041 // nsIDOMLinkStyle
2042 NS_DECL_NSIDOMLINKSTYLE
2043
2044 // nsIStyleSheetLinkingElement
2045 NS_IMETHOD SetStyleSheet(nsIStyleSheet* aStyleSheet);
2046 NS_IMETHOD GetStyleSheet(nsIStyleSheet*& aStyleSheet);
2047 NS_IMETHOD InitStyleLinkElement(PRBool aDontLoadStyle);
2048diff --git a/content/base/src/nsSyncLoadService.cpp b/content/base/src/nsSyncLoadService.cpp
2049--- a/content/base/src/nsSyncLoadService.cpp
2050+++ b/content/base/src/nsSyncLoadService.cpp
2051@@ -323,17 +323,18 @@ nsSyncLoader::AsyncOnChannelRedirect(nsI
2052 callback->OnRedirectVerifyCallback(NS_OK);
2053 return NS_OK;
2054 }
2055
2056 NS_IMETHODIMP
2057 nsSyncLoader::GetInterface(const nsIID & aIID,
2058 void **aResult)
2059 {
2060- return QueryInterface(aIID, aResult);
2061+ *aResult = QueryInterfaceFast(aIID);
2062+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
2063 }
2064
2065 /* static */
2066 nsresult
2067 nsSyncLoadService::LoadDocument(nsIURI *aURI, nsIPrincipal *aLoaderPrincipal,
2068 nsILoadGroup *aLoadGroup, PRBool aForceToXML,
2069 nsIDOMDocument** aResult)
2070 {
2071diff --git a/content/base/src/nsXMLHttpRequest.cpp b/content/base/src/nsXMLHttpRequest.cpp
2072--- a/content/base/src/nsXMLHttpRequest.cpp
2073+++ b/content/base/src/nsXMLHttpRequest.cpp
2074@@ -3061,17 +3061,18 @@ nsXMLHttpRequest::GetInterface(const nsI
2075 window = mOwner->GetOuterWindow();
2076 }
2077
2078 return wwatch->GetPrompt(window, aIID,
2079 reinterpret_cast<void**>(aResult));
2080
2081 }
2082
2083- return QueryInterface(aIID, aResult);
2084+ *aResult = QueryInterfaceFast(aIID);
2085+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
2086 }
2087
2088 NS_IMETHODIMP
2089 nsXMLHttpRequest::GetUpload(nsIXMLHttpRequestUpload** aUpload)
2090 {
2091 *aUpload = nsnull;
2092
2093 nsresult rv;
2094diff --git a/content/html/content/src/nsGenericHTMLElement.cpp b/content/html/content/src/nsGenericHTMLElement.cpp
2095--- a/content/html/content/src/nsGenericHTMLElement.cpp
2096+++ b/content/html/content/src/nsGenericHTMLElement.cpp
2097@@ -279,23 +279,21 @@ NS_INTERFACE_TABLE_HEAD(nsGenericHTMLEle
2098 nsIDOMElementCSSInlineStyle)
2099 NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(nsGenericHTMLElementTearoff)
2100 NS_INTERFACE_MAP_END_AGGREGATED(mElement)
2101
2102
2103 NS_IMPL_INT_ATTR_DEFAULT_VALUE(nsGenericHTMLElement, TabIndex, tabindex, -1)
2104 NS_IMPL_BOOL_ATTR(nsGenericHTMLElement, Hidden, hidden)
2105
2106-nsresult
2107+void*
2108 nsGenericHTMLElement::DOMQueryInterface(nsIDOMHTMLElement *aElement,
2109- REFNSIID aIID, void **aInstancePtr)
2110+ REFNSIID aIID)
2111 {
2112- NS_PRECONDITION(aInstancePtr, "null out param");
2113-
2114- nsresult rv = NS_ERROR_FAILURE;
2115+ void* result = nsnull;
2116
2117 NS_INTERFACE_TABLE_BEGIN
2118 NS_INTERFACE_TABLE_ENTRY(nsIDOMHTMLElement, nsIDOMNode)
2119 NS_INTERFACE_TABLE_ENTRY(nsIDOMHTMLElement, nsIDOMElement)
2120 NS_INTERFACE_TABLE_ENTRY(nsIDOMHTMLElement, nsIDOMHTMLElement)
2121 NS_INTERFACE_TABLE_END_WITH_PTR(aElement)
2122
2123 NS_INTERFACE_TABLE_TO_MAP_SEGUE
2124diff --git a/content/html/content/src/nsGenericHTMLElement.h b/content/html/content/src/nsGenericHTMLElement.h
2125--- a/content/html/content/src/nsGenericHTMLElement.h
2126+++ b/content/html/content/src/nsGenericHTMLElement.h
2127@@ -97,18 +97,17 @@ public:
2128 /**
2129 * Handle QI for the standard DOM interfaces (DOMNode, DOMElement,
2130 * DOMHTMLElement) and handles tearoffs for other standard interfaces.
2131 * @param aElement the element as nsIDOMHTMLElement*
2132 * @param aIID the IID to QI to
2133 * @param aInstancePtr the QI'd method [OUT]
2134 * @see nsGenericHTMLElementTearoff
2135 */
2136- nsresult DOMQueryInterface(nsIDOMHTMLElement *aElement, REFNSIID aIID,
2137- void **aInstancePtr);
2138+ void* DOMQueryInterface(nsIDOMHTMLElement *aElement, REFNSIID aIID);
2139
2140 // From nsGenericElement
2141 nsresult CopyInnerTo(nsGenericElement* aDest) const;
2142
2143 // Implementation for nsIDOMElement
2144 NS_METHOD SetAttribute(const nsAString& aName,
2145 const nsAString& aValue);
2146
2147@@ -845,17 +844,17 @@ class nsGenericHTMLFormElement : public
2148 {
2149 public:
2150 nsGenericHTMLFormElement(already_AddRefed<nsINodeInfo> aNodeInfo);
2151 virtual ~nsGenericHTMLFormElement();
2152
2153 NS_DECL_AND_IMPL_DOM_MEMORY_REPORTER_SIZEOF(nsGenericHTMLFormElement,
2154 nsGenericHTMLElement)
2155
2156- NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
2157+ NS_IMETHOD_(void*) QueryInterfaceFast(REFNSIID aIID);
2158
2159 virtual PRBool IsNodeOfType(PRUint32 aFlags) const;
2160 virtual void SaveSubtreeState();
2161
2162 // nsIFormControl
2163 virtual mozilla::dom::Element* GetFormElement();
2164 virtual void SetForm(nsIDOMHTMLFormElement* aForm);
2165 virtual void ClearForm(PRBool aRemoveFromForm);
2166@@ -1027,17 +1026,17 @@ public:
2167 {
2168 mNetworkCreated = aFromParser == mozilla::dom::FROM_PARSER_NETWORK;
2169 }
2170 virtual ~nsGenericHTMLFrameElement();
2171
2172 NS_DECL_DOM_MEMORY_REPORTER_SIZEOF
2173
2174 // nsISupports
2175- NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
2176+ NS_IMETHOD_(void*) QueryInterfaceFast(REFNSIID aIID);
2177
2178 // nsIDOMNSHTMLFrameElement
2179 NS_DECL_NSIDOMNSHTMLFRAMEELEMENT
2180
2181 // nsIFrameLoaderOwner
2182 NS_DECL_NSIFRAMELOADEROWNER
2183
2184 // nsIContent
2185@@ -1348,23 +1347,23 @@ protected:
2186 NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMElement, _base) \
2187 NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMHTMLElement, _base)
2188
2189 #define NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class) \
2190 NS_HTML_CONTENT_INTERFACE_TABLE_AMBIGUOUS_BEGIN(_class, nsIDOMHTMLElement)
2191
2192 #define NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE_AMBIGUOUS(_class, _base, \
2193 _base_if) \
2194- rv = _base::QueryInterface(aIID, aInstancePtr); \
2195- if (NS_SUCCEEDED(rv)) \
2196- return rv; \
2197+ result = _base::QueryInterfaceFast(aIID); \
2198+ if (result) \
2199+ return result; \
2200 \
2201- rv = DOMQueryInterface(static_cast<_base_if *>(this), aIID, aInstancePtr); \
2202- if (NS_SUCCEEDED(rv)) \
2203- return rv; \
2204+ result = DOMQueryInterface(static_cast<_base_if *>(this), aIID); \
2205+ if (result) \
2206+ return result; \
2207 \
2208 NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
2209
2210 #define NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE(_class, _base) \
2211 NS_HTML_CONTENT_INTERFACE_TABLE_TO_MAP_SEGUE_AMBIGUOUS(_class, _base, \
2212 nsIDOMHTMLElement)
2213
2214 #define NS_HTML_CONTENT_INTERFACE_MAP_END \
2215@@ -1379,18 +1378,17 @@ protected:
2216 mNodeInfo->Equals(nsGkAtoms::_tag))
2217
2218
2219 #define NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO_GETTER(_getter) \
2220 if (aIID.Equals(NS_GET_IID(nsIClassInfo)) || \
2221 aIID.Equals(NS_GET_IID(nsXPCClassInfo))) { \
2222 foundInterface = _getter (); \
2223 if (!foundInterface) { \
2224- *aInstancePtr = nsnull; \
2225- return NS_ERROR_OUT_OF_MEMORY; \
2226+ return nsnull; \
2227 } \
2228 } else
2229
2230 #define NS_HTML_CONTENT_INTERFACE_TABLE0(_class) \
2231 NS_HTML_CONTENT_INTERFACE_TABLE_BEGIN(_class) \
2232 NS_OFFSET_AND_INTERFACE_TABLE_END
2233
2234 #define NS_HTML_CONTENT_INTERFACE_TABLE1(_class, _i1) \
2235diff --git a/content/html/content/src/nsHTMLMediaElement.cpp b/content/html/content/src/nsHTMLMediaElement.cpp
2236--- a/content/html/content/src/nsHTMLMediaElement.cpp
2237+++ b/content/html/content/src/nsHTMLMediaElement.cpp
2238@@ -362,17 +362,18 @@ NS_IMETHODIMP nsHTMLMediaElement::MediaL
2239 return sink->AsyncOnChannelRedirect(aOldChannel, aNewChannel, aFlags, cb);
2240
2241 cb->OnRedirectVerifyCallback(NS_OK);
2242 return NS_OK;
2243 }
2244
2245 NS_IMETHODIMP nsHTMLMediaElement::MediaLoadListener::GetInterface(const nsIID & aIID, void **aResult)
2246 {
2247- return QueryInterface(aIID, aResult);
2248+ *aResult = QueryInterfaceFast(aIID);
2249+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
2250 }
2251
2252 NS_IMPL_ADDREF_INHERITED(nsHTMLMediaElement, nsGenericHTMLElement)
2253 NS_IMPL_RELEASE_INHERITED(nsHTMLMediaElement, nsGenericHTMLElement)
2254
2255 NS_IMPL_CYCLE_COLLECTION_CLASS(nsHTMLMediaElement)
2256
2257 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsHTMLMediaElement, nsGenericHTMLElement)
2258diff --git a/content/html/document/src/nsHTMLDocument.h b/content/html/document/src/nsHTMLDocument.h
2259--- a/content/html/document/src/nsHTMLDocument.h
2260+++ b/content/html/document/src/nsHTMLDocument.h
2261@@ -71,20 +71,17 @@ class nsHTMLDocument : public nsDocument
2262 public nsIDOMHTMLDocument
2263 {
2264 public:
2265 using nsDocument::SetDocumentURI;
2266
2267 nsHTMLDocument();
2268 virtual nsresult Init();
2269
2270- NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
2271-
2272- NS_IMETHOD_(nsrefcnt) AddRef(void);
2273- NS_IMETHOD_(nsrefcnt) Release(void);
2274+ NS_DECL_ISUPPORTS
2275
2276 virtual void Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup);
2277 virtual void ResetToURI(nsIURI* aURI, nsILoadGroup* aLoadGroup,
2278 nsIPrincipal* aPrincipal);
2279
2280 virtual nsresult CreateShell(nsPresContext* aContext,
2281 nsIViewManager* aViewManager,
2282 nsStyleSet* aStyleSet,
2283diff --git a/content/media/nsMediaStream.cpp b/content/media/nsMediaStream.cpp
2284--- a/content/media/nsMediaStream.cpp
2285+++ b/content/media/nsMediaStream.cpp
2286@@ -143,17 +143,18 @@ nsMediaChannelStream::Listener::AsyncOnC
2287
2288 cb->OnRedirectVerifyCallback(NS_OK);
2289 return NS_OK;
2290 }
2291
2292 nsresult
2293 nsMediaChannelStream::Listener::GetInterface(const nsIID & aIID, void **aResult)
2294 {
2295- return QueryInterface(aIID, aResult);
2296+ *aResult = QueryInterfaceFast(aIID);
2297+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
2298 }
2299
2300 nsresult
2301 nsMediaChannelStream::OnStartRequest(nsIRequest* aRequest)
2302 {
2303 NS_ASSERTION(mChannel.get() == aRequest, "Wrong channel!");
2304
2305 nsHTMLMediaElement* element = mDecoder->GetMediaElement();
2306diff --git a/content/xtf/src/nsXTFElementWrapper.cpp b/content/xtf/src/nsXTFElementWrapper.cpp
2307--- a/content/xtf/src/nsXTFElementWrapper.cpp
2308+++ b/content/xtf/src/nsXTFElementWrapper.cpp
2309@@ -113,57 +113,52 @@ NS_IMPL_RELEASE_INHERITED(nsXTFElementWr
2310
2311 NS_IMPL_CYCLE_COLLECTION_CLASS(nsXTFElementWrapper)
2312 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXTFElementWrapper,
2313 nsXTFElementWrapperBase)
2314 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mXTFElement)
2315 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mAttributeHandler)
2316 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
2317
2318-NS_IMETHODIMP
2319-nsXTFElementWrapper::QueryInterface(REFNSIID aIID, void** aInstancePtr)
2320+NS_IMETHODIMP_(void*)
2321+nsXTFElementWrapper::QueryInterfaceFast(REFNSIID aIID)
2322 {
2323- NS_PRECONDITION(aInstancePtr, "null out param");
2324-
2325 NS_IMPL_QUERY_CYCLE_COLLECTION(nsXTFElementWrapper)
2326 if (aIID.Equals(NS_GET_IID(nsIClassInfo)) ||
2327 aIID.Equals(NS_GET_IID(nsXPCClassInfo))) {
2328- *aInstancePtr = static_cast<nsIClassInfo*>(this);
2329 NS_ADDREF_THIS();
2330- return NS_OK;
2331+ return static_cast<nsIClassInfo*>(this);
2332 }
2333 if (aIID.Equals(NS_GET_IID(nsIXPCScriptable))) {
2334- *aInstancePtr = static_cast<nsIXPCScriptable*>(this);
2335 NS_ADDREF_THIS();
2336- return NS_OK;
2337+ return static_cast<nsIXPCScriptable*>(this);
2338 }
2339 if (aIID.Equals(NS_GET_IID(nsIXTFElementWrapper))) {
2340- *aInstancePtr = static_cast<nsIXTFElementWrapper*>(this);
2341 NS_ADDREF_THIS();
2342- return NS_OK;
2343+ return static_cast<nsIXTFElementWrapper*>(this);
2344 }
2345
2346- nsresult rv = nsXTFElementWrapperBase::QueryInterface(aIID, aInstancePtr);
2347- if (NS_SUCCEEDED(rv)) {
2348- return rv;
2349+ void* result = nsXTFElementWrapperBase::QueryInterfaceFast(aIID);
2350+ if (result) {
2351+ return result;
2352 }
2353
2354 // try to get get the interface from our wrapped element:
2355 nsCOMPtr<nsISupports> inner;
2356 QueryInterfaceInner(aIID, getter_AddRefs(inner));
2357
2358 if (inner) {
2359- rv = NS_NewXTFInterfaceAggregator(aIID, inner,
2360- static_cast<nsIContent*>(this),
2361- aInstancePtr);
2362+ NS_NewXTFInterfaceAggregator(aIID, inner,
2363+ static_cast<nsIContent*>(this),
2364+ &result);
2365
2366- return rv;
2367+ return result;
2368 }
2369
2370- return NS_ERROR_NO_INTERFACE;
2371+ return nsnull;
2372 }
2373
2374 //----------------------------------------------------------------------
2375 // nsIContent methods:
2376
2377 nsresult
2378 nsXTFElementWrapper::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
2379 nsIContent* aBindingParent,
2380diff --git a/content/xtf/src/nsXTFInterfaceAggregator.cpp b/content/xtf/src/nsXTFInterfaceAggregator.cpp
2381--- a/content/xtf/src/nsXTFInterfaceAggregator.cpp
2382+++ b/content/xtf/src/nsXTFInterfaceAggregator.cpp
2383@@ -128,28 +128,25 @@ NS_NewXTFInterfaceAggregator(const nsIID
2384 }
2385
2386 //----------------------------------------------------------------------
2387 // nsISupports implementation
2388
2389 NS_IMPL_ADDREF(nsXTFInterfaceAggregator)
2390 NS_IMPL_RELEASE(nsXTFInterfaceAggregator)
2391
2392-NS_IMETHODIMP
2393-nsXTFInterfaceAggregator::QueryInterface(REFNSIID aIID, void** aInstancePtr)
2394+NS_IMETHODIMP_(void*)
2395+nsXTFInterfaceAggregator::QueryInterfaceFast(REFNSIID aIID)
2396 {
2397- NS_PRECONDITION(aInstancePtr, "null out param");
2398-
2399 if (aIID.Equals(mIID)) {
2400- *aInstancePtr = mXPTCStub;
2401 NS_ADDREF_THIS();
2402- return NS_OK;
2403+ return mXPTCStub;
2404 }
2405
2406- return mOuter->QueryInterface(aIID, aInstancePtr);
2407+ return mOuter->QueryInterfaceFast(aIID);
2408 }
2409
2410 //----------------------------------------------------------------------
2411 // nsXPTCStubBase implementation
2412
2413 NS_IMETHODIMP
2414 nsXTFInterfaceAggregator::CallMethod(PRUint16 methodIndex,
2415 const XPTMethodDescriptor *info,
2416diff --git a/content/xtf/src/nsXTFWeakTearoff.cpp b/content/xtf/src/nsXTFWeakTearoff.cpp
2417--- a/content/xtf/src/nsXTFWeakTearoff.cpp
2418+++ b/content/xtf/src/nsXTFWeakTearoff.cpp
2419@@ -102,40 +102,37 @@ NS_NewXTFWeakTearoff(const nsIID& iid,
2420 nsRefPtr<nsXTFWeakTearoff> result =
2421 new nsXTFWeakTearoff(iid, obj, &rv);
2422 if (!result)
2423 return NS_ERROR_OUT_OF_MEMORY;
2424
2425 if (NS_FAILED(rv))
2426 return rv;
2427
2428- return result->QueryInterface(iid, (void**) aResult);
2429+ *aResult = static_cast<nsISupports*> (result->QueryInterfaceFast(iid));
2430+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
2431 }
2432
2433 //----------------------------------------------------------------------
2434 // nsISupports implementation
2435
2436 NS_IMPL_ADDREF(nsXTFWeakTearoff)
2437 NS_IMPL_RELEASE(nsXTFWeakTearoff)
2438
2439-NS_IMETHODIMP
2440-nsXTFWeakTearoff::QueryInterface(REFNSIID aIID, void** aInstancePtr)
2441+NS_IMETHODIMP_(void*)
2442+nsXTFWeakTearoff::QueryInterfaceFast(REFNSIID aIID)
2443 {
2444- NS_PRECONDITION(aInstancePtr, "null out param");
2445-
2446 if (aIID.Equals(mIID) || aIID.Equals(NS_GET_IID(nsISupports))) {
2447- *aInstancePtr = mXPTCStub;
2448 NS_ADDREF_THIS();
2449- return NS_OK;
2450+ return mXPTCStub;
2451 }
2452 // we can't map QI onto the obj, because the xpcom wrapper otherwise
2453 // QI-accumulates all interfaces defined on mObj
2454 // else return mObj->QueryInterface(aIID, aInstancePtr);
2455- *aInstancePtr = nsnull;
2456- return NS_ERROR_NO_INTERFACE;
2457+ return nsnull;
2458 }
2459
2460 NS_IMETHODIMP
2461 nsXTFWeakTearoff::CallMethod(PRUint16 methodIndex,
2462 const XPTMethodDescriptor* info,
2463 nsXPTCMiniVariant* params)
2464 {
2465 NS_ASSERTION(methodIndex >= 3,
2466diff --git a/content/xul/document/src/nsXULControllers.cpp b/content/xul/document/src/nsXULControllers.cpp
2467--- a/content/xul/document/src/nsXULControllers.cpp
2468+++ b/content/xul/document/src/nsXULControllers.cpp
2469@@ -83,22 +83,21 @@ NS_NewXULControllers(nsISupports* aOuter
2470 {
2471 NS_PRECONDITION(aOuter == nsnull, "no aggregation");
2472 if (aOuter)
2473 return NS_ERROR_NO_AGGREGATION;
2474
2475 nsXULControllers* controllers = new nsXULControllers();
2476 if (! controllers)
2477 return NS_ERROR_OUT_OF_MEMORY;
2478-
2479- nsresult rv;
2480+
2481 NS_ADDREF(controllers);
2482- rv = controllers->QueryInterface(aIID, aResult);
2483+ *aResult = controllers->QueryInterfaceFast(aIID);
2484 NS_RELEASE(controllers);
2485- return rv;
2486+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
2487 }
2488
2489 NS_IMPL_CYCLE_COLLECTION_CLASS(nsXULControllers)
2490 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsXULControllers)
2491 tmp->DeleteControllers();
2492 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
2493 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXULControllers)
2494 {
2495diff --git a/content/xul/templates/src/nsXULContentBuilder.cpp b/content/xul/templates/src/nsXULContentBuilder.cpp
2496--- a/content/xul/templates/src/nsXULContentBuilder.cpp
2497+++ b/content/xul/templates/src/nsXULContentBuilder.cpp
2498@@ -383,18 +383,20 @@ NS_NewXULContentBuilder(nsISupports* aOu
2499 nsXULContentBuilder* result = new nsXULContentBuilder();
2500 if (!result)
2501 return NS_ERROR_OUT_OF_MEMORY;
2502
2503 NS_ADDREF(result); // stabilize
2504
2505 rv = result->InitGlobals();
2506
2507- if (NS_SUCCEEDED(rv))
2508- rv = result->QueryInterface(aIID, aResult);
2509+ if (NS_SUCCEEDED(rv)) {
2510+ *aResult = result->QueryInterfaceFast(aIID);
2511+ rv = (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
2512+ }
2513
2514 NS_RELEASE(result);
2515 return rv;
2516 }
2517
2518 nsXULContentBuilder::nsXULContentBuilder()
2519 {
2520 mSortState.initialized = PR_FALSE;
2521diff --git a/content/xul/templates/src/nsXULTreeBuilder.cpp b/content/xul/templates/src/nsXULTreeBuilder.cpp
2522--- a/content/xul/templates/src/nsXULTreeBuilder.cpp
2523+++ b/content/xul/templates/src/nsXULTreeBuilder.cpp
2524@@ -293,18 +293,20 @@ NS_NewXULTreeBuilder(nsISupports* aOuter
2525 nsXULTreeBuilder* result = new nsXULTreeBuilder();
2526 if (! result)
2527 return NS_ERROR_OUT_OF_MEMORY;
2528
2529 NS_ADDREF(result); // stabilize
2530
2531 rv = result->InitGlobals();
2532
2533- if (NS_SUCCEEDED(rv))
2534- rv = result->QueryInterface(aIID, aResult);
2535+ if (NS_SUCCEEDED(rv)) {
2536+ *aResult = result->QueryInterfaceFast(aIID);
2537+ rv = (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
2538+ }
2539
2540 NS_RELEASE(result);
2541 return rv;
2542 }
2543
2544 NS_IMPL_CYCLE_COLLECTION_CLASS(nsXULTreeBuilder)
2545
2546 NS_IMPL_ADDREF_INHERITED(nsXULTreeBuilder, nsXULTemplateBuilder)
2547diff --git a/docshell/base/nsDefaultURIFixup.cpp b/docshell/base/nsDefaultURIFixup.cpp
2548--- a/docshell/base/nsDefaultURIFixup.cpp
2549+++ b/docshell/base/nsDefaultURIFixup.cpp
2550@@ -852,11 +852,13 @@ nsresult nsDefaultURIFixup::KeywordURIFi
2551
2552 nsresult NS_NewURIFixup(nsIURIFixup **aURIFixup)
2553 {
2554 nsDefaultURIFixup *fixup = new nsDefaultURIFixup;
2555 if (fixup == nsnull)
2556 {
2557 return NS_ERROR_OUT_OF_MEMORY;
2558 }
2559- return fixup->QueryInterface(NS_GET_IID(nsIURIFixup), (void **) aURIFixup);
2560+ *aURIFixup = static_cast<nsIURIFixup*>
2561+ (fixup->QueryInterfaceFast(NS_GET_IID(nsIURIFixup)));
2562+ return (*aURIFixup) ? NS_OK : NS_ERROR_NO_INTERFACE;
2563 }
2564
2565diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp
2566--- a/docshell/base/nsDocShell.cpp
2567+++ b/docshell/base/nsDocShell.cpp
2568@@ -2065,19 +2065,20 @@ nsDocShell::GetDocShellEnumerator(PRInt3
2569 if (NS_FAILED(rv)) return rv;
2570
2571 rv = docShellEnum->SetEnumerationRootItem((nsIDocShellTreeItem *)this);
2572 if (NS_FAILED(rv)) return rv;
2573
2574 rv = docShellEnum->First();
2575 if (NS_FAILED(rv)) return rv;
2576
2577- rv = docShellEnum->QueryInterface(NS_GET_IID(nsISimpleEnumerator), (void **)outEnum);
2578-
2579- return rv;
2580+ *outEnum = static_cast<nsISimpleEnumerator*>
2581+ (docShellEnum->QueryInterfaceFast(NS_GET_IID(nsISimpleEnumerator)));
2582+
2583+ return (*outEnum) ? NS_OK : NS_ERROR_NO_INTERFACE;
2584 }
2585
2586 NS_IMETHODIMP
2587 nsDocShell::GetAppType(PRUint32 * aAppType)
2588 {
2589 *aAppType = mAppType;
2590 return NS_OK;
2591 }
2592diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp
2593--- a/dom/base/nsDOMClassInfo.cpp
2594+++ b/dom/base/nsDOMClassInfo.cpp
2595@@ -5623,18 +5623,17 @@ NS_INTERFACE_MAP_BEGIN(nsDOMConstructor)
2596 "Can't change constructability dynamically!");
2597 }
2598 #endif
2599 foundInterface =
2600 NS_GetDOMClassInfoInstance(mConstructable ?
2601 eDOMClassInfo_DOMConstructor_id :
2602 eDOMClassInfo_DOMPrototype_id);
2603 if (!foundInterface) {
2604- *aInstancePtr = nsnull;
2605- return NS_ERROR_OUT_OF_MEMORY;
2606+ return nsnull;
2607 }
2608 } else
2609 NS_INTERFACE_MAP_END
2610
2611 nsresult
2612 nsDOMConstructor::PreCreate(JSContext *cx, JSObject *globalObj, JSObject **parentObj)
2613 {
2614 nsCOMPtr<nsPIDOMWindow> owner(do_QueryReferent(mWeakOwner));
2615diff --git a/dom/base/nsDOMClassInfoID.h b/dom/base/nsDOMClassInfoID.h
2616--- a/dom/base/nsDOMClassInfoID.h
2617+++ b/dom/base/nsDOMClassInfoID.h
2618@@ -157,29 +157,27 @@ class nsXPCClassInfo;
2619 extern nsIClassInfo*
2620 NS_GetDOMClassInfoInstance(nsDOMClassInfoID aID);
2621
2622 #define NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(_class) \
2623 if (aIID.Equals(NS_GET_IID(nsIClassInfo)) || \
2624 aIID.Equals(NS_GET_IID(nsXPCClassInfo))) { \
2625 foundInterface = NS_GetDOMClassInfoInstance(eDOMClassInfo_##_class##_id); \
2626 if (!foundInterface) { \
2627- *aInstancePtr = nsnull; \
2628- return NS_ERROR_OUT_OF_MEMORY; \
2629+ return nsnull; \
2630 } \
2631 } else
2632
2633 #define NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO_CONDITIONAL(_class, condition) \
2634 if ((condition) && \
2635 (aIID.Equals(NS_GET_IID(nsIClassInfo)) || \
2636 aIID.Equals(NS_GET_IID(nsXPCClassInfo)))) { \
2637 foundInterface = NS_GetDOMClassInfoInstance(eDOMClassInfo_##_class##_id); \
2638 if (!foundInterface) { \
2639- *aInstancePtr = nsnull; \
2640- return NS_ERROR_OUT_OF_MEMORY; \
2641+ return nsnull; \
2642 } \
2643 } else
2644
2645 #else
2646
2647 // See nsIDOMClassInfo.h
2648
2649 #endif // _IMPL_NS_LAYOUT
2650diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp
2651--- a/dom/base/nsGlobalWindow.cpp
2652+++ b/dom/base/nsGlobalWindow.cpp
2653@@ -1079,19 +1079,18 @@ nsGlobalWindow::ShutDown()
2654 // static
2655 void
2656 nsGlobalWindow::CleanupCachedXBLHandlers(nsGlobalWindow* aWindow)
2657 {
2658 if (aWindow->mCachedXBLPrototypeHandlers.IsInitialized() &&
2659 aWindow->mCachedXBLPrototypeHandlers.Count() > 0) {
2660 aWindow->mCachedXBLPrototypeHandlers.Clear();
2661
2662- nsISupports* supports;
2663- aWindow->QueryInterface(NS_GET_IID(nsCycleCollectionISupports),
2664- reinterpret_cast<void**>(&supports));
2665+ nsISupports* supports = static_cast<nsISupports*>
2666+ (aWindow->QueryInterfaceFast(NS_GET_IID(nsCycleCollectionISupports)));
2667 NS_ASSERTION(supports, "Failed to QI to nsCycleCollectionISupports?!");
2668
2669 nsContentUtils::DropJSObjects(supports);
2670 }
2671 }
2672
2673 void
2674 nsGlobalWindow::MaybeForgiveSpamCount()
2675@@ -6910,19 +6909,18 @@ nsGlobalWindow::CacheXBLPrototypeHandler
2676 if (!mCachedXBLPrototypeHandlers.Count()) {
2677 // Can't use macros to get the participant because nsGlobalChromeWindow also
2678 // runs through this code. Use QueryInterface to get the correct objects.
2679 nsXPCOMCycleCollectionParticipant* participant;
2680 CallQueryInterface(this, &participant);
2681 NS_ASSERTION(participant,
2682 "Failed to QI to nsXPCOMCycleCollectionParticipant!");
2683
2684- nsISupports* thisSupports;
2685- QueryInterface(NS_GET_IID(nsCycleCollectionISupports),
2686- reinterpret_cast<void**>(&thisSupports));
2687+ nsISupports* thisSupports = static_cast<nsISupports*>
2688+ (QueryInterfaceFast(NS_GET_IID(nsCycleCollectionISupports)));
2689 NS_ASSERTION(thisSupports, "Failed to QI to nsCycleCollectionISupports!");
2690
2691 nsresult rv = nsContentUtils::HoldJSObjects(thisSupports, participant);
2692 if (NS_FAILED(rv)) {
2693 NS_ERROR("nsContentUtils::HoldJSObjects failed!");
2694 return;
2695 }
2696 }
2697@@ -8328,17 +8326,17 @@ nsGlobalWindow::GetInterface(const nsIID
2698 if (utilsIfc) {
2699 mWindowUtils = do_GetWeakReference(utilsIfc);
2700 *aSink = utilsIfc;
2701 NS_ADDREF(((nsISupports *) *aSink));
2702 }
2703 }
2704 }
2705 else {
2706- return QueryInterface(aIID, aSink);
2707+ *aSink = QueryInterfaceFast(aIID);
2708 }
2709
2710 return *aSink ? NS_OK : NS_ERROR_NO_INTERFACE;
2711 }
2712
2713 void
2714 nsGlobalWindow::FireOfflineStatusEvent()
2715 {
2716diff --git a/dom/base/nsIDOMClassInfo.h b/dom/base/nsIDOMClassInfo.h
2717--- a/dom/base/nsIDOMClassInfo.h
2718+++ b/dom/base/nsIDOMClassInfo.h
2719@@ -77,18 +77,17 @@
2720 if (aIID.Equals(NS_GET_IID(nsIClassInfo)) || \
2721 aIID.Equals(NS_GET_IID(nsXPCClassInfo))) { \
2722 static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID); \
2723 \
2724 nsresult rv; \
2725 nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID, \
2726 &rv)); \
2727 if (NS_FAILED(rv)) { \
2728- *aInstancePtr = nsnull; \
2729- return rv; \
2730+ return nsnull; \
2731 } \
2732 \
2733 foundInterface = \
2734 sof->GetClassInfoInstance(eDOMClassInfo_##_class##_id); \
2735 } else
2736
2737 #endif /* _IMPL_NS_LAYOUT */
2738
2739@@ -103,18 +102,17 @@
2740 foundInterface = NS_CLASSINFO_NAME(_class); \
2741 } else { \
2742 static NS_DEFINE_CID(kDOMSOF_CID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID); \
2743 \
2744 nsresult rv; \
2745 nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID, \
2746 &rv)); \
2747 if (NS_FAILED(rv)) { \
2748- *aInstancePtr = nsnull; \
2749- return rv; \
2750+ return nsnull; \
2751 } \
2752 \
2753 foundInterface = \
2754 sof->GetExternalClassInfoInstance(NS_LITERAL_STRING(#_class)); \
2755 \
2756 if (foundInterface) { \
2757 NS_CLASSINFO_NAME(_class) = foundInterface; \
2758 NS_CLASSINFO_NAME(_class)->AddRef(); \
2759diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp
2760--- a/dom/base/nsJSEnvironment.cpp
2761+++ b/dom/base/nsJSEnvironment.cpp
2762@@ -3986,10 +3986,12 @@ nsresult NS_CreateJSArgv(JSContext *aCon
2763 nsJSArgArray *ret = new nsJSArgArray(aContext, argc,
2764 static_cast<jsval *>(argv), &rv);
2765 if (ret == nsnull)
2766 return NS_ERROR_OUT_OF_MEMORY;
2767 if (NS_FAILED(rv)) {
2768 delete ret;
2769 return rv;
2770 }
2771- return ret->QueryInterface(NS_GET_IID(nsIArray), (void **)aArray);
2772+ *aArray = static_cast<nsIArray*>
2773+ (ret->QueryInterfaceFast(NS_GET_IID(nsIArray)));
2774+ return (*aArray) ? NS_OK : NS_ERROR_NO_INTERFACE;
2775 }
2776diff --git a/dom/base/nsWrapperCache.h b/dom/base/nsWrapperCache.h
2777--- a/dom/base/nsWrapperCache.h
2778+++ b/dom/base/nsWrapperCache.h
2779@@ -142,13 +142,12 @@ private:
2780
2781 PtrBits mWrapperPtrBits;
2782 };
2783
2784 NS_DEFINE_STATIC_IID_ACCESSOR(nsWrapperCache, NS_WRAPPERCACHE_IID)
2785
2786 #define NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY \
2787 if ( aIID.Equals(NS_GET_IID(nsWrapperCache)) ) { \
2788- *aInstancePtr = static_cast<nsWrapperCache*>(this); \
2789- return NS_OK; \
2790+ return static_cast<nsWrapperCache*>(this); \
2791 }
2792
2793 #endif /* nsWrapperCache_h___ */
2794diff --git a/dom/indexedDB/CheckPermissionsHelper.cpp b/dom/indexedDB/CheckPermissionsHelper.cpp
2795--- a/dom/indexedDB/CheckPermissionsHelper.cpp
2796+++ b/dom/indexedDB/CheckPermissionsHelper.cpp
2797@@ -172,17 +172,18 @@ CheckPermissionsHelper::Run()
2798 }
2799
2800 NS_IMETHODIMP
2801 CheckPermissionsHelper::GetInterface(const nsIID& aIID,
2802 void** aResult)
2803 {
2804 NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
2805 if (aIID.Equals(NS_GET_IID(nsIObserver))) {
2806- return QueryInterface(aIID, aResult);
2807+ *aResult = QueryInterfaceFast(aIID);
2808+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
2809 }
2810
2811 if (aIID.Equals(NS_GET_IID(nsIDOMWindow))) {
2812 return mWindow->QueryInterface(aIID, aResult);
2813 }
2814
2815 *aResult = nsnull;
2816 return NS_ERROR_NOT_AVAILABLE;
2817diff --git a/dom/indexedDB/CheckQuotaHelper.cpp b/dom/indexedDB/CheckQuotaHelper.cpp
2818--- a/dom/indexedDB/CheckQuotaHelper.cpp
2819+++ b/dom/indexedDB/CheckQuotaHelper.cpp
2820@@ -237,17 +237,18 @@ CheckQuotaHelper::Run()
2821
2822 NS_IMETHODIMP
2823 CheckQuotaHelper::GetInterface(const nsIID& aIID,
2824 void** aResult)
2825 {
2826 NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
2827
2828 if (aIID.Equals(NS_GET_IID(nsIObserver))) {
2829- return QueryInterface(aIID, aResult);
2830+ *aResult = QueryInterfaceFast(aIID);
2831+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
2832 }
2833
2834 if (aIID.Equals(NS_GET_IID(nsIDOMWindow))) {
2835 return mWindow->QueryInterface(aIID, aResult);
2836 }
2837
2838 *aResult = nsnull;
2839 return NS_ERROR_NOT_AVAILABLE;
2840diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp
2841--- a/dom/ipc/TabChild.cpp
2842+++ b/dom/ipc/TabChild.cpp
2843@@ -344,17 +344,18 @@ TabChild::FocusPrevElement()
2844 return NS_OK;
2845 }
2846
2847 NS_IMETHODIMP
2848 TabChild::GetInterface(const nsIID & aIID, void **aSink)
2849 {
2850 // XXXbz should we restrict the set of interfaces we hand out here?
2851 // See bug 537429
2852- return QueryInterface(aIID, aSink);
2853+ *aSink = QueryInterfaceFast(aIID);
2854+ return (*aSink) ? NS_OK : NS_ERROR_NO_INTERFACE;
2855 }
2856
2857 NS_IMETHODIMP
2858 TabChild::ProvideWindow(nsIDOMWindow* aParent, PRUint32 aChromeFlags,
2859 PRBool aCalledFromJS,
2860 PRBool aPositionSpecified, PRBool aSizeSpecified,
2861 nsIURI* aURI, const nsAString& aName,
2862 const nsACString& aFeatures, PRBool* aWindowIsNew,
2863diff --git a/dom/plugins/base/nsNPAPIPluginInstance.cpp b/dom/plugins/base/nsNPAPIPluginInstance.cpp
2864--- a/dom/plugins/base/nsNPAPIPluginInstance.cpp
2865+++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp
2866@@ -506,17 +506,19 @@ nsresult
2867 nsNPAPIPluginInstance::NewStreamListener(const char* aURL, void* notifyData,
2868 nsIPluginStreamListener** listener)
2869 {
2870 nsNPAPIPluginStreamListener* stream = new nsNPAPIPluginStreamListener(this, notifyData, aURL);
2871 NS_ENSURE_TRUE(stream, NS_ERROR_OUT_OF_MEMORY);
2872
2873 mStreamListeners.AppendElement(stream);
2874
2875- return stream->QueryInterface(kIPluginStreamListenerIID, (void**)listener);
2876+ *listener = static_cast<nsIPluginStreamListener*>
2877+ (stream->QueryInterfaceFast(kIPluginStreamListenerIID));
2878+ return (*listener) ? NS_OK : NS_ERROR_NO_INTERFACE;
2879 }
2880
2881 nsresult nsNPAPIPluginInstance::Print(NPPrint* platformPrint)
2882 {
2883 NS_ENSURE_TRUE(platformPrint, NS_ERROR_NULL_POINTER);
2884
2885 PluginDestructionGuard guard(this);
2886
2887diff --git a/dom/plugins/base/nsPluginStreamListenerPeer.cpp b/dom/plugins/base/nsPluginStreamListenerPeer.cpp
2888--- a/dom/plugins/base/nsPluginStreamListenerPeer.cpp
2889+++ b/dom/plugins/base/nsPluginStreamListenerPeer.cpp
2890@@ -1325,17 +1325,18 @@ nsPluginStreamListenerPeer::GetInterface
2891 }
2892
2893 NS_IMETHODIMP
2894 nsPluginStreamListenerPeer::GetInterface(const nsIID& aIID, void** result)
2895 {
2896 // Provide nsIChannelEventSink ourselves, otherwise let our document's
2897 // script global object owner provide the interface.
2898 if (aIID.Equals(NS_GET_IID(nsIChannelEventSink))) {
2899- return QueryInterface(aIID, result);
2900+ *result = QueryInterfaceFast(aIID);
2901+ return (*result) ? NS_OK : NS_ERROR_NO_INTERFACE;
2902 }
2903
2904 return GetInterfaceGlobal(aIID, result);
2905 }
2906
2907 /**
2908 * Proxy class which forwards async redirect notifications back to the necko
2909 * callback, keeping nsPluginStreamListenerPeer::mRequests in sync with
2910diff --git a/dom/src/jsurl/nsJSProtocolHandler.cpp b/dom/src/jsurl/nsJSProtocolHandler.cpp
2911--- a/dom/src/jsurl/nsJSProtocolHandler.cpp
2912+++ b/dom/src/jsurl/nsJSProtocolHandler.cpp
2913@@ -1303,18 +1303,17 @@ NS_IMPL_RELEASE_INHERITED(nsJSURI, nsSim
2914
2915 NS_INTERFACE_MAP_BEGIN(nsJSURI)
2916 if (aIID.Equals(kJSURICID))
2917 foundInterface = static_cast<nsIURI*>(this);
2918 else if (aIID.Equals(kThisSimpleURIImplementationCID)) {
2919 // Need to return explicitly here, because if we just set foundInterface
2920 // to null the NS_INTERFACE_MAP_END_INHERITING will end up calling into
2921 // nsSimplURI::QueryInterface and finding something for this CID.
2922- *aInstancePtr = nsnull;
2923- return NS_NOINTERFACE;
2924+ return nsnull;
2925 }
2926 else
2927 NS_INTERFACE_MAP_END_INHERITING(nsSimpleURI)
2928
2929 // nsISerializable methods:
2930
2931 NS_IMETHODIMP
2932 nsJSURI::Read(nsIObjectInputStream* aStream)
2933diff --git a/dom/src/jsurl/nsJSProtocolHandler.h b/dom/src/jsurl/nsJSProtocolHandler.h
2934--- a/dom/src/jsurl/nsJSProtocolHandler.h
2935+++ b/dom/src/jsurl/nsJSProtocolHandler.h
2936@@ -113,17 +113,16 @@ public:
2937
2938 // nsISerializable overrides
2939 NS_IMETHOD Read(nsIObjectInputStream* aStream);
2940 NS_IMETHOD Write(nsIObjectOutputStream* aStream);
2941
2942 // Override the nsIClassInfo method GetClassIDNoAlloc to make sure our
2943 // nsISerializable impl works right.
2944 NS_IMETHOD GetClassIDNoAlloc(nsCID *aClassIDNoAlloc);
2945- //NS_IMETHOD QueryInterface( const nsIID& aIID, void** aInstancePtr );
2946
2947 protected:
2948 virtual nsresult EqualsInternal(nsIURI* other,
2949 RefHandlingEnum refHandlingMode,
2950 PRBool* result);
2951 private:
2952 nsCOMPtr<nsIURI> mBaseURI;
2953 };
2954diff --git a/dom/src/storage/nsDOMStorage.cpp b/dom/src/storage/nsDOMStorage.cpp
2955--- a/dom/src/storage/nsDOMStorage.cpp
2956+++ b/dom/src/storage/nsDOMStorage.cpp
2957@@ -583,27 +583,29 @@ NS_INTERFACE_MAP_END
2958
2959 nsresult
2960 NS_NewDOMStorage(nsISupports* aOuter, REFNSIID aIID, void** aResult)
2961 {
2962 nsDOMStorage* storage = new nsDOMStorage();
2963 if (!storage)
2964 return NS_ERROR_OUT_OF_MEMORY;
2965
2966- return storage->QueryInterface(aIID, aResult);
2967+ *aResult = storage->QueryInterfaceFast(aIID);
2968+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
2969 }
2970
2971 nsresult
2972 NS_NewDOMStorage2(nsISupports* aOuter, REFNSIID aIID, void** aResult)
2973 {
2974 nsDOMStorage2* storage = new nsDOMStorage2();
2975 if (!storage)
2976 return NS_ERROR_OUT_OF_MEMORY;
2977
2978- return storage->QueryInterface(aIID, aResult);
2979+ *aResult = storage->QueryInterfaceFast(aIID);
2980+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
2981 }
2982
2983 DOMStorageBase::DOMStorageBase()
2984 : mStorageType(nsPIDOMStorage::Unknown)
2985 , mUseDB(PR_FALSE)
2986 , mSessionOnly(PR_TRUE)
2987 , mCanUseChromePersist(false)
2988 {
2989diff --git a/dom/src/threads/nsDOMWorkerMacros.h b/dom/src/threads/nsDOMWorkerMacros.h
2990--- a/dom/src/threads/nsDOMWorkerMacros.h
2991+++ b/dom/src/threads/nsDOMWorkerMacros.h
2992@@ -118,18 +118,18 @@ NS_IMPL_THREADSAFE_DOM_CI_ALL_THE_REST(_
2993 NS_IMETHOD GetClassIDNoAlloc(nsCID* aClassIDNoAlloc) \
2994 { return _to GetClassIDNoAlloc(aClassIDNoAlloc); }
2995
2996 #define NS_DECL_NSICLASSINFO_GETINTERFACES \
2997 NS_IMETHOD GetInterfaces(PRUint32* aCount, nsIID*** aArray);
2998
2999 // Don't know why nsISupports.idl defines this out...
3000 #define NS_FORWARD_NSISUPPORTS(_to) \
3001- NS_IMETHOD QueryInterface(const nsIID& uuid, void** result) { \
3002- return _to QueryInterface(uuid, result); \
3003+ NS_IMETHOD_(void*) QueryInterfaceFast(const nsIID& uuid) { \
3004+ return _to QueryInterfaceFast(uuid); \
3005 } \
3006 NS_IMETHOD_(nsrefcnt) AddRef(void) { return _to AddRef(); } \
3007 NS_IMETHOD_(nsrefcnt) Release(void) { return _to Release(); }
3008
3009 #define JSON_PRIMITIVE_PROPNAME \
3010 "primitive"
3011
3012 #endif /* __NSDOMWORKERMACROS_H__ */
3013diff --git a/editor/composer/src/nsComposerCommandsUpdater.cpp b/editor/composer/src/nsComposerCommandsUpdater.cpp
3014--- a/editor/composer/src/nsComposerCommandsUpdater.cpp
3015+++ b/editor/composer/src/nsComposerCommandsUpdater.cpp
3016@@ -414,11 +414,12 @@ nsComposerCommandsUpdater::Notify(nsITim
3017
3018
3019 nsresult
3020 NS_NewComposerCommandsUpdater(nsISelectionListener** aInstancePtrResult)
3021 {
3022 nsComposerCommandsUpdater* newThang = new nsComposerCommandsUpdater;
3023 NS_ENSURE_TRUE(newThang, NS_ERROR_OUT_OF_MEMORY);
3024
3025- return newThang->QueryInterface(NS_GET_IID(nsISelectionListener),
3026- (void **)aInstancePtrResult);
3027+ *aInstancePtrResult = static_cast<nsISelectionListener*>
3028+ (newThang->QueryInterfaceFast(NS_GET_IID(nsISelectionListener)));
3029+ return (*aInstancePtrResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
3030 }
3031diff --git a/editor/libeditor/base/ChangeCSSInlineStyleTxn.h b/editor/libeditor/base/ChangeCSSInlineStyleTxn.h
3032--- a/editor/libeditor/base/ChangeCSSInlineStyleTxn.h
3033+++ b/editor/libeditor/base/ChangeCSSInlineStyleTxn.h
3034@@ -100,17 +100,17 @@ private:
3035 * set the property in the transaction to that value; if the value
3036 * is empty, remove the property from element's styles. If the boolean
3037 * is false, just remove the style attribute.
3038 */
3039 nsresult SetStyle(PRBool aAttributeWasSet, nsAString & aValue);
3040
3041 public:
3042 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ChangeCSSInlineStyleTxn, EditTxn)
3043- NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
3044+ NS_IMETHOD_(void*) QueryInterfaceFast(REFNSIID aIID);
3045
3046 NS_DECL_EDITTXN
3047
3048 NS_IMETHOD RedoTransaction();
3049
3050 protected:
3051
3052 /** the editor that created this transaction */
3053diff --git a/editor/libeditor/base/DeleteRangeTxn.h b/editor/libeditor/base/DeleteRangeTxn.h
3054--- a/editor/libeditor/base/DeleteRangeTxn.h
3055+++ b/editor/libeditor/base/DeleteRangeTxn.h
3056@@ -60,17 +60,17 @@ public:
3057 */
3058 NS_IMETHOD Init(nsIEditor *aEditor,
3059 nsIDOMRange *aRange,
3060 nsRangeUpdater *aRangeUpdater);
3061
3062 DeleteRangeTxn();
3063
3064 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DeleteRangeTxn, EditAggregateTxn)
3065- NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
3066+ NS_IMETHOD_(void*) QueryInterfaceFast(REFNSIID aIID);
3067
3068 NS_DECL_EDITTXN
3069
3070 NS_IMETHOD RedoTransaction();
3071
3072 protected:
3073
3074 NS_IMETHOD CreateTxnsToDeleteBetween(nsIDOMNode *aStartParent,
3075diff --git a/editor/libeditor/base/DeleteTextTxn.h b/editor/libeditor/base/DeleteTextTxn.h
3076--- a/editor/libeditor/base/DeleteTextTxn.h
3077+++ b/editor/libeditor/base/DeleteTextTxn.h
3078@@ -61,17 +61,17 @@ public:
3079 nsIDOMCharacterData *aElement,
3080 PRUint32 aOffset,
3081 PRUint32 aNumCharsToDelete,
3082 nsRangeUpdater *aRangeUpdater);
3083
3084 DeleteTextTxn();
3085
3086 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DeleteTextTxn, EditTxn)
3087- NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
3088+ NS_IMETHOD_(void*) QueryInterfaceFast(REFNSIID aIID);
3089
3090 NS_DECL_EDITTXN
3091
3092 PRUint32 GetOffset() { return mOffset; }
3093
3094 PRUint32 GetNumCharsToDelete() { return mNumCharsToDelete; }
3095
3096 protected:
3097diff --git a/editor/libeditor/base/IMETextTxn.cpp b/editor/libeditor/base/IMETextTxn.cpp
3098--- a/editor/libeditor/base/IMETextTxn.cpp
3099+++ b/editor/libeditor/base/IMETextTxn.cpp
3100@@ -62,19 +62,18 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
3101
3102 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IMETextTxn, EditTxn)
3103 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mElement)
3104 // mRangeList can't lead to cycles
3105 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
3106
3107 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IMETextTxn)
3108 if (aIID.Equals(IMETextTxn::GetCID())) {
3109- *aInstancePtr = (void*)(IMETextTxn*)this;
3110 NS_ADDREF_THIS();
3111- return NS_OK;
3112+ return (void*)(IMETextTxn*)this;
3113 } else
3114 NS_INTERFACE_MAP_END_INHERITING(EditTxn)
3115
3116 NS_IMETHODIMP IMETextTxn::Init(nsIDOMCharacterData *aElement,
3117 PRUint32 aOffset,
3118 PRUint32 aReplaceLength,
3119 nsIPrivateTextRangeList *aTextRangeList,
3120 const nsAString &aStringToInsert,
3121diff --git a/editor/libeditor/base/IMETextTxn.h b/editor/libeditor/base/IMETextTxn.h
3122--- a/editor/libeditor/base/IMETextTxn.h
3123+++ b/editor/libeditor/base/IMETextTxn.h
3124@@ -84,17 +84,17 @@ public:
3125
3126 NS_IMETHOD Merge(nsITransaction *aTransaction, PRBool *aDidMerge);
3127
3128 NS_IMETHOD MarkFixed(void);
3129
3130 // nsISupports declarations
3131
3132 // override QueryInterface to handle IMETextTxn request
3133- NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
3134+ NS_IMETHOD_(void*) QueryInterfaceFast(REFNSIID aIID);
3135
3136 /** return the string data associated with this transaction */
3137 NS_IMETHOD GetData(nsString& aResult, nsIPrivateTextRangeList** aTextRangeList);
3138
3139 protected:
3140
3141 NS_IMETHOD CollapseTextSelection(void);
3142
3143diff --git a/editor/libeditor/base/InsertTextTxn.cpp b/editor/libeditor/base/InsertTextTxn.cpp
3144--- a/editor/libeditor/base/InsertTextTxn.cpp
3145+++ b/editor/libeditor/base/InsertTextTxn.cpp
3146@@ -58,19 +58,18 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
3147 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(InsertTextTxn, EditTxn)
3148 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mElement)
3149 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
3150
3151 NS_IMPL_ADDREF_INHERITED(InsertTextTxn, EditTxn)
3152 NS_IMPL_RELEASE_INHERITED(InsertTextTxn, EditTxn)
3153 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(InsertTextTxn)
3154 if (aIID.Equals(InsertTextTxn::GetCID())) {
3155- *aInstancePtr = (void*)(InsertTextTxn*)this;
3156 NS_ADDREF_THIS();
3157- return NS_OK;
3158+ return (void*)(InsertTextTxn*)this;
3159 } else
3160 NS_INTERFACE_MAP_END_INHERITING(EditTxn)
3161
3162 NS_IMETHODIMP InsertTextTxn::Init(nsIDOMCharacterData *aElement,
3163 PRUint32 aOffset,
3164 const nsAString &aStringToInsert,
3165 nsIEditor *aEditor)
3166 {
3167diff --git a/editor/libeditor/base/JoinElementTxn.h b/editor/libeditor/base/JoinElementTxn.h
3168--- a/editor/libeditor/base/JoinElementTxn.h
3169+++ b/editor/libeditor/base/JoinElementTxn.h
3170@@ -62,17 +62,17 @@ public:
3171 */
3172 NS_IMETHOD Init(nsEditor *aEditor,
3173 nsIDOMNode *aLeftNode,
3174 nsIDOMNode *aRightNode);
3175
3176 JoinElementTxn();
3177
3178 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(JoinElementTxn, EditTxn)
3179- NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
3180+ NS_IMETHOD_(void*) QueryInterfaceFast(REFNSIID aIID);
3181
3182 NS_DECL_EDITTXN
3183
3184 protected:
3185
3186 /** the elements to operate upon.
3187 * After the merge, mRightNode remains and mLeftNode is removed from the content tree.
3188 */
3189diff --git a/editor/libeditor/base/PlaceholderTxn.cpp b/editor/libeditor/base/PlaceholderTxn.cpp
3190--- a/editor/libeditor/base/PlaceholderTxn.cpp
3191+++ b/editor/libeditor/base/PlaceholderTxn.cpp
3192@@ -142,17 +142,18 @@ NS_IMETHODIMP PlaceholderTxn::Merge(nsIT
3193 nsCOMPtr<nsPIEditorTransaction> pTxn = do_QueryInterface(aTransaction);
3194 NS_ENSURE_TRUE(pTxn, NS_OK); // it's foreign so just bail!
3195
3196 EditTxn *editTxn = (EditTxn*)aTransaction; //XXX: hack, not safe! need nsIEditTransaction!
3197 // determine if this incoming txn is a placeholder txn
3198 nsCOMPtr<nsIAbsorbingTransaction> plcTxn;// = do_QueryInterface(editTxn);
3199 // can't do_QueryInterface() above due to our broken transaction interfaces.
3200 // instead have to brute it below. ugh.
3201- editTxn->QueryInterface(NS_GET_IID(nsIAbsorbingTransaction), getter_AddRefs(plcTxn));
3202+ plcTxn = dont_AddRef(static_cast<nsIAbsorbingTransaction*>
3203+ (editTxn->QueryInterfaceFast(NS_GET_IID(nsIAbsorbingTransaction))));
3204
3205 // we are absorbing all txn's if mAbsorb is lit.
3206 if (mAbsorb)
3207 {
3208 nsRefPtr<IMETextTxn> otherTxn;
3209 if (NS_SUCCEEDED(aTransaction->QueryInterface(IMETextTxn::GetCID(), getter_AddRefs(otherTxn))) && otherTxn)
3210 {
3211 // special handling for IMETextTxn's: they need to merge with any previous
3212@@ -192,17 +193,18 @@ NS_IMETHODIMP PlaceholderTxn::Merge(nsIT
3213 if (((mName.get() == nsGkAtoms::TypingTxnName) ||
3214 (mName.get() == nsGkAtoms::IMETxnName) ||
3215 (mName.get() == nsGkAtoms::DeleteTxnName))
3216 && !mCommitted )
3217 {
3218 nsCOMPtr<nsIAbsorbingTransaction> plcTxn;// = do_QueryInterface(editTxn);
3219 // can't do_QueryInterface() above due to our broken transaction interfaces.
3220 // instead have to brute it below. ugh.
3221- editTxn->QueryInterface(NS_GET_IID(nsIAbsorbingTransaction), getter_AddRefs(plcTxn));
3222+ plcTxn = dont_AddRef(static_cast<nsIAbsorbingTransaction*>
3223+ (editTxn->QueryInterfaceFast(NS_GET_IID(nsIAbsorbingTransaction))));
3224 if (plcTxn)
3225 {
3226 nsCOMPtr<nsIAtom> atom;
3227 plcTxn->GetTxnName(getter_AddRefs(atom));
3228 if (atom && (atom == mName))
3229 {
3230 // check if start selection of next placeholder matches
3231 // end selection of this placeholder
3232diff --git a/editor/libeditor/base/nsEditor.cpp b/editor/libeditor/base/nsEditor.cpp
3233--- a/editor/libeditor/base/nsEditor.cpp
3234+++ b/editor/libeditor/base/nsEditor.cpp
3235@@ -626,18 +626,18 @@ nsEditor::DoTransaction(nsITransaction *
3236 // it's pretty darn amazing how many different types of pointers
3237 // this transaction goes through here. I bet this is a record.
3238
3239 // We start off with an EditTxn since that's what the factory returns.
3240 nsRefPtr<EditTxn> editTxn = new PlaceholderTxn();
3241 if (!editTxn) { return NS_ERROR_OUT_OF_MEMORY; }
3242
3243 // Then we QI to an nsIAbsorbingTransaction to get at placeholder functionality
3244- nsCOMPtr<nsIAbsorbingTransaction> plcTxn;
3245- editTxn->QueryInterface(NS_GET_IID(nsIAbsorbingTransaction), getter_AddRefs(plcTxn));
3246+ nsCOMPtr<nsIAbsorbingTransaction> plcTxn = dont_AddRef(static_cast<nsIAbsorbingTransaction*>
3247+ (editTxn->QueryInterfaceFast(NS_GET_IID(nsIAbsorbingTransaction))));
3248 // have to use line above instead of "plcTxn = do_QueryInterface(editTxn);"
3249 // due to our broken interface model for transactions.
3250
3251 // save off weak reference to placeholder txn
3252 mPlaceHolderTxn = do_GetWeakReference(plcTxn);
3253 plcTxn->Init(mPlaceHolderName, mSelState, this);
3254 mSelState = nsnull; // placeholder txn took ownership of this pointer
3255
3256diff --git a/editor/libeditor/base/nsStyleSheetTxns.h b/editor/libeditor/base/nsStyleSheetTxns.h
3257--- a/editor/libeditor/base/nsStyleSheetTxns.h
3258+++ b/editor/libeditor/base/nsStyleSheetTxns.h
3259@@ -50,17 +50,17 @@ public:
3260 * @param aSheet the stylesheet to add
3261 */
3262 NS_IMETHOD Init(nsIEditor *aEditor,
3263 nsCSSStyleSheet *aSheet);
3264
3265 AddStyleSheetTxn();
3266
3267 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(AddStyleSheetTxn, EditTxn)
3268- NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
3269+ NS_IMETHOD_(void*) QueryInterfaceFast(REFNSIID aIID);
3270
3271 NS_DECL_EDITTXN
3272
3273 protected:
3274
3275 nsIEditor* mEditor; // the editor that created this transaction
3276 nsRefPtr<nsCSSStyleSheet> mSheet; // the style sheet to add
3277
3278@@ -75,17 +75,17 @@ public:
3279 * @param aSheet the stylesheet to remove
3280 */
3281 NS_IMETHOD Init(nsIEditor *aEditor,
3282 nsCSSStyleSheet *aSheet);
3283
3284 RemoveStyleSheetTxn();
3285
3286 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(RemoveStyleSheetTxn, EditTxn)
3287- NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
3288+ NS_IMETHOD_(void*) QueryInterfaceFast(REFNSIID aIID);
3289
3290 NS_DECL_EDITTXN
3291
3292 protected:
3293
3294 nsIEditor* mEditor; // the editor that created this transaction
3295 nsRefPtr<nsCSSStyleSheet> mSheet; // the style sheet to remove
3296
3297diff --git a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
3298--- a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
3299+++ b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
3300@@ -175,17 +175,18 @@ NS_INTERFACE_MAP_END
3301 // nsDocShellTreeOwner::nsIInterfaceRequestor
3302 //*****************************************************************************
3303
3304 NS_IMETHODIMP
3305 nsDocShellTreeOwner::GetInterface(const nsIID& aIID, void** aSink)
3306 {
3307 NS_ENSURE_ARG_POINTER(aSink);
3308
3309- if(NS_SUCCEEDED(QueryInterface(aIID, aSink)))
3310+ *aSink = QueryInterfaceFast(aIID);
3311+ if (*aSink)
3312 return NS_OK;
3313
3314 if (aIID.Equals(NS_GET_IID(nsIWebBrowserChromeFocus))) {
3315 if (mWebBrowserChromeWeak != nsnull)
3316 return mWebBrowserChromeWeak->QueryReferent(aIID, aSink);
3317 return mOwnerWin->QueryInterface(aIID, aSink);
3318 }
3319
3320diff --git a/embedding/browser/webBrowser/nsWebBrowser.cpp b/embedding/browser/webBrowser/nsWebBrowser.cpp
3321--- a/embedding/browser/webBrowser/nsWebBrowser.cpp
3322+++ b/embedding/browser/webBrowser/nsWebBrowser.cpp
3323@@ -188,17 +188,18 @@ NS_INTERFACE_MAP_END
3324 ///*****************************************************************************
3325 // nsWebBrowser::nsIInterfaceRequestor
3326 //*****************************************************************************
3327
3328 NS_IMETHODIMP nsWebBrowser::GetInterface(const nsIID& aIID, void** aSink)
3329 {
3330 NS_ENSURE_ARG_POINTER(aSink);
3331
3332- if(NS_SUCCEEDED(QueryInterface(aIID, aSink)))
3333+ *aSink = QueryInterfaceFast(aIID);
3334+ if (*aSink)
3335 return NS_OK;
3336
3337 if (mDocShell) {
3338 #ifdef NS_PRINTING
3339 if (aIID.Equals(NS_GET_IID(nsIWebBrowserPrint))) {
3340 nsCOMPtr<nsIContentViewer> viewer;
3341 mDocShell->GetContentViewer(getter_AddRefs(viewer));
3342 if (!viewer)
3343@@ -1190,19 +1191,18 @@ NS_IMETHODIMP nsWebBrowser::Create()
3344 mListenerArray = nsnull;
3345 }
3346
3347 // HACK ALERT - this registration registers the nsDocShellTreeOwner as a
3348 // nsIWebBrowserListener so it can setup its MouseListener in one of the
3349 // progress callbacks. If we can register the MouseListener another way, this
3350 // registration can go away, and nsDocShellTreeOwner can stop implementing
3351 // nsIWebProgressListener.
3352- nsCOMPtr<nsISupports> supports = nsnull;
3353- (void)mDocShellTreeOwner->QueryInterface(NS_GET_IID(nsIWebProgressListener),
3354- static_cast<void**>(getter_AddRefs(supports)));
3355+ nsCOMPtr<nsISupports> supports = dont_AddRef(static_cast<nsISupports*>
3356+ (mDocShellTreeOwner->QueryInterfaceFast(NS_GET_IID(nsIWebProgressListener))));
3357 (void)BindListener(supports, NS_GET_IID(nsIWebProgressListener));
3358
3359 NS_ENSURE_SUCCESS(mDocShellAsWin->InitWindow(nsnull,
3360 docShellParentWidget, mInitInfo->x, mInitInfo->y, mInitInfo->cx,
3361 mInitInfo->cy), NS_ERROR_FAILURE);
3362
3363 mDocShellAsItem->SetName(mInitInfo->name.get());
3364 if (mContentType == typeChromeWrapper)
3365diff --git a/embedding/components/commandhandler/src/nsBaseCommandController.cpp b/embedding/components/commandhandler/src/nsBaseCommandController.cpp
3366--- a/embedding/components/commandhandler/src/nsBaseCommandController.cpp
3367+++ b/embedding/components/commandhandler/src/nsBaseCommandController.cpp
3368@@ -97,17 +97,18 @@ nsBaseCommandController::SetCommandConte
3369 return NS_OK;
3370 }
3371
3372 NS_IMETHODIMP
3373 nsBaseCommandController::GetInterface(const nsIID & aIID, void * *result)
3374 {
3375 NS_ENSURE_ARG_POINTER(result);
3376
3377- if (NS_SUCCEEDED(QueryInterface(aIID, result)))
3378+ *result = QueryInterfaceFast(aIID);
3379+ if (*result)
3380 return NS_OK;
3381
3382 if (aIID.Equals(NS_GET_IID(nsIControllerCommandTable)))
3383 {
3384 if (mCommandTable)
3385 return mCommandTable->QueryInterface(aIID, result);
3386 return NS_ERROR_NOT_INITIALIZED;
3387 }
3388diff --git a/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp b/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp
3389--- a/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp
3390+++ b/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp
3391@@ -265,24 +265,22 @@ NS_INTERFACE_MAP_END
3392 //*****************************************************************************
3393 // nsWebBrowserPersist::nsIInterfaceRequestor
3394 //*****************************************************************************
3395
3396 NS_IMETHODIMP nsWebBrowserPersist::GetInterface(const nsIID & aIID, void **aIFace)
3397 {
3398 NS_ENSURE_ARG_POINTER(aIFace);
3399
3400- *aIFace = nsnull;
3401-
3402- nsresult rv = QueryInterface(aIID, aIFace);
3403- if (NS_SUCCEEDED(rv))
3404+ *aIFace = QueryInterfaceFast(aIID);
3405+ if (*aIFace)
3406 {
3407- return rv;
3408+ return NS_OK;
3409 }
3410-
3411+
3412 if (mProgressListener && (aIID.Equals(NS_GET_IID(nsIAuthPrompt))
3413 || aIID.Equals(NS_GET_IID(nsIPrompt))))
3414 {
3415 mProgressListener->QueryInterface(aIID, aIFace);
3416 if (*aIFace)
3417 return NS_OK;
3418 }
3419
3420diff --git a/intl/uconv/util/nsUCConstructors.cpp b/intl/uconv/util/nsUCConstructors.cpp
3421--- a/intl/uconv/util/nsUCConstructors.cpp
3422+++ b/intl/uconv/util/nsUCConstructors.cpp
3423@@ -41,19 +41,19 @@
3424 #include "nsUCConstructors.h"
3425
3426 template<class T>
3427 inline NS_METHOD StabilizedQueryInterface(T* aNewObject,
3428 REFNSIID aIID,
3429 void **aResult)
3430 {
3431 NS_ADDREF(aNewObject);
3432- nsresult rv = aNewObject->QueryInterface(aIID, aResult);
3433+ *aResult = aNewObject->QueryInterfaceFast(aIID);
3434 NS_RELEASE(aNewObject);
3435- return rv;
3436+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
3437 }
3438
3439 NS_METHOD
3440 CreateMultiTableDecoder(PRInt32 aTableCount, const uRange * aRangeArray,
3441 uScanClassID * aScanClassArray,
3442 uMappingTable ** aMappingTable,
3443 PRUint32 aMaxLengthFactor,
3444 nsISupports* aOuter,
3445diff --git a/js/src/xpconnect/src/xpcconvert.cpp b/js/src/xpconnect/src/xpcconvert.cpp
3446--- a/js/src/xpconnect/src/xpcconvert.cpp
3447+++ b/js/src/xpconnect/src/xpcconvert.cpp
3448@@ -1517,18 +1517,22 @@ XPCConvert::JSObject2NativeInterface(XPC
3449 if(pErr)
3450 *pErr = rv;
3451 if(NS_SUCCEEDED(rv) && wrapper)
3452 {
3453 // We need to go through the QueryInterface logic to make this return
3454 // the right thing for the various 'special' interfaces; e.g.
3455 // nsIPropertyBag. We must use AggregatedQueryInterface in cases where
3456 // there is an outer to avoid nasty recursion.
3457- rv = aOuter ? wrapper->AggregatedQueryInterface(*iid, dest) :
3458- wrapper->QueryInterface(*iid, dest);
3459+ if (aOuter) {
3460+ rv = wrapper->AggregatedQueryInterface(*iid, dest);
3461+ } else {
3462+ *dest = wrapper->QueryInterfaceFast(*iid);
3463+ rv = (*dest) ? NS_OK : NS_ERROR_NO_INTERFACE;
3464+ }
3465 if(pErr)
3466 *pErr = rv;
3467 NS_RELEASE(wrapper);
3468 return NS_SUCCEEDED(rv);
3469 }
3470
3471 // else...
3472 return JS_FALSE;
3473diff --git a/js/src/xpconnect/src/xpcquickstubs.cpp b/js/src/xpconnect/src/xpcquickstubs.cpp
3474--- a/js/src/xpconnect/src/xpcquickstubs.cpp
3475+++ b/js/src/xpconnect/src/xpcquickstubs.cpp
3476@@ -1002,23 +1002,24 @@ xpc_qsUnwrapArgImpl(JSContext *cx,
3477 *ppArgRef = nsnull;
3478 return rv;
3479 }
3480
3481 // We need to go through the QueryInterface logic to make this return
3482 // the right thing for the various 'special' interfaces; e.g.
3483 // nsIPropertyBag. We must use AggregatedQueryInterface in cases where
3484 // there is an outer to avoid nasty recursion.
3485- rv = wrappedJS->QueryInterface(iid, ppArg);
3486- if(NS_SUCCEEDED(rv))
3487+ *ppArg = wrappedJS->QueryInterfaceFast(iid);
3488+ if(*ppArg)
3489 {
3490 *ppArgRef = static_cast<nsISupports*>(*ppArg);
3491 *vp = OBJECT_TO_JSVAL(wrappedJS->GetJSObject());
3492+ return NS_OK;
3493 }
3494- return rv;
3495+ return NS_ERROR_NO_INTERFACE;
3496 }
3497
3498 JSBool
3499 xpc_qsJsvalToCharStr(JSContext *cx, jsval v, JSAutoByteString *bytes)
3500 {
3501 JSString *str;
3502
3503 JS_ASSERT(!bytes->ptr());
3504diff --git a/js/src/xpconnect/src/xpcwrappedjs.cpp b/js/src/xpconnect/src/xpcwrappedjs.cpp
3505--- a/js/src/xpconnect/src/xpcwrappedjs.cpp
3506+++ b/js/src/xpconnect/src/xpcwrappedjs.cpp
3507@@ -114,56 +114,48 @@ nsXPCWrappedJS::AggregatedQueryInterface
3508 NS_ADDREF(this);
3509 *aInstancePtr = (void*) static_cast<nsIXPConnectWrappedJS*>(this);
3510 return NS_OK;
3511 }
3512
3513 return mClass->DelegatedQueryInterface(this, aIID, aInstancePtr);
3514 }
3515
3516-NS_IMETHODIMP
3517-nsXPCWrappedJS::QueryInterface(REFNSIID aIID, void** aInstancePtr)
3518+NS_IMETHODIMP_(void*)
3519+nsXPCWrappedJS::QueryInterfaceFast(REFNSIID aIID)
3520 {
3521- if(nsnull == aInstancePtr)
3522- {
3523- NS_PRECONDITION(0, "null pointer");
3524- return NS_ERROR_NULL_POINTER;
3525- }
3526-
3527 if ( aIID.Equals(NS_GET_IID(nsXPCOMCycleCollectionParticipant)) ) {
3528- *aInstancePtr = & NS_CYCLE_COLLECTION_NAME(nsXPCWrappedJS);
3529- return NS_OK;
3530+ return & NS_CYCLE_COLLECTION_NAME(nsXPCWrappedJS);
3531 }
3532
3533 if(aIID.Equals(NS_GET_IID(nsCycleCollectionISupports)))
3534 {
3535- *aInstancePtr =
3536- NS_CYCLE_COLLECTION_CLASSNAME(nsXPCWrappedJS)::Upcast(this);
3537- return NS_OK;
3538+ return NS_CYCLE_COLLECTION_CLASSNAME(nsXPCWrappedJS)::Upcast(this);
3539 }
3540
3541 if(!IsValid())
3542- return NS_ERROR_UNEXPECTED;
3543+ return nsnull;
3544
3545 // Always check for this first so that our 'outer' can get this interface
3546 // from us without recurring into a call to the outer's QI!
3547 if(aIID.Equals(NS_GET_IID(nsIXPConnectWrappedJS)))
3548 {
3549 NS_ADDREF(this);
3550- *aInstancePtr = (void*) static_cast<nsIXPConnectWrappedJS*>(this);
3551- return NS_OK;
3552+ return (void*) static_cast<nsIXPConnectWrappedJS*>(this);
3553 }
3554
3555 nsISupports* outer = GetAggregatedNativeObject();
3556 if(outer)
3557- return outer->QueryInterface(aIID, aInstancePtr);
3558+ return outer->QueryInterfaceFast(aIID);
3559
3560 // else...
3561
3562- return mClass->DelegatedQueryInterface(this, aIID, aInstancePtr);
3563+ void* instancePtr = nsnull;
3564+ mClass->DelegatedQueryInterface(this, aIID, &instancePtr);
3565+ return instancePtr;
3566 }
3567
3568
3569 // Refcounting is now similar to that used in the chained (pre-flattening)
3570 // wrappednative system.
3571 //
3572 // We are now holding an extra refcount for nsISupportsWeakReference support.
3573 //
3574diff --git a/js/src/xpconnect/src/xpcwrappedjsclass.cpp b/js/src/xpconnect/src/xpcwrappedjsclass.cpp
3575--- a/js/src/xpconnect/src/xpcwrappedjsclass.cpp
3576+++ b/js/src/xpconnect/src/xpcwrappedjsclass.cpp
3577@@ -809,19 +809,19 @@ nsXPCWrappedJSClass::DelegatedQueryInter
3578 nsXPCWrappedJS* wrapper;
3579 nsresult rv = nsXPCWrappedJS::GetNewOrUsed(ccx, jsobj, aIID, nsnull,
3580 &wrapper);
3581 if(NS_SUCCEEDED(rv) && wrapper)
3582 {
3583 // We need to go through the QueryInterface logic to make
3584 // this return the right thing for the various 'special'
3585 // interfaces; e.g. nsIPropertyBag.
3586- rv = wrapper->QueryInterface(aIID, aInstancePtr);
3587+ *aInstancePtr = wrapper->QueryInterfaceFast(aIID);
3588 NS_RELEASE(wrapper);
3589- return rv;
3590+ return (*aInstancePtr) ? NS_OK : NS_ERROR_NO_INTERFACE;
3591 }
3592 }
3593
3594 // else...
3595 // no can do
3596 *aInstancePtr = nsnull;
3597 return NS_NOINTERFACE;
3598 }
3599diff --git a/js/src/xpconnect/tests/components/xpctest_child.cpp b/js/src/xpconnect/tests/components/xpctest_child.cpp
3600--- a/js/src/xpconnect/tests/components/xpctest_child.cpp
3601+++ b/js/src/xpconnect/tests/components/xpctest_child.cpp
3602@@ -149,32 +149,27 @@ public:
3603 NS_DECL_NSIXPCTESTCHILD
3604
3605 xpctestChild();
3606 };
3607
3608 NS_IMPL_ADDREF(xpctestChild)
3609 NS_IMPL_RELEASE(xpctestChild)
3610
3611-NS_IMETHODIMP
3612-xpctestChild::QueryInterface(REFNSIID iid, void** result)
3613+NS_IMETHODIMP_(void*)
3614+xpctestChild::QueryInterfaceFast(REFNSIID iid)
3615 {
3616- if (! result)
3617- return NS_ERROR_NULL_POINTER;
3618-
3619 if (iid.Equals(NS_GET_IID(nsIXPCTestChild)) ||
3620 iid.Equals(NS_GET_IID(nsIXPCTestParent)) ||
3621 iid.Equals(NS_GET_IID(nsISupports))) {
3622- *result = static_cast<nsIXPCTestChild*>(this);
3623 NS_ADDREF(this);
3624- return NS_OK;
3625+ return static_cast<nsIXPCTestChild*>(this);
3626 }
3627 else {
3628- *result = nsnull;
3629- return NS_NOINTERFACE;
3630+ return nsnull;
3631 }
3632 }
3633
3634 xpctestChild::xpctestChild()
3635 {
3636 NS_ADDREF_THIS();
3637 }
3638
3639diff --git a/js/src/xpconnect/tests/components/xpctest_noisy.cpp b/js/src/xpconnect/tests/components/xpctest_noisy.cpp
3640--- a/js/src/xpconnect/tests/components/xpctest_noisy.cpp
3641+++ b/js/src/xpconnect/tests/components/xpctest_noisy.cpp
3642@@ -78,33 +78,28 @@ NS_IMETHODIMP_(nsrefcnt) xpctestNoisy::R
3643 NS_LOG_RELEASE(this, mRefCnt, "xpctestNoisy");
3644 if (mRefCnt == 0) {
3645 delete this;
3646 return 0;
3647 }
3648 return mRefCnt;
3649 }
3650
3651-NS_IMETHODIMP
3652-xpctestNoisy::QueryInterface(REFNSIID iid, void** result)
3653+NS_IMETHODIMP_(void*)
3654+xpctestNoisy::QueryInterfaceFast(REFNSIID iid)
3655 {
3656- if (! result)
3657- return NS_ERROR_NULL_POINTER;
3658-
3659 if (iid.Equals(NS_GET_IID(nsIXPCTestNoisy)) ||
3660 iid.Equals(NS_GET_IID(nsISupports))) {
3661- *result = static_cast<nsIXPCTestNoisy*>(this);
3662 printf("Noisy %d - QueryInterface called and succeeding\n", mID);
3663 NS_ADDREF(this);
3664- return NS_OK;
3665+ return static_cast<nsIXPCTestNoisy*>(this);
3666 }
3667 else {
3668- *result = nsnull;
3669 printf("Noisy %d - QueryInterface for interface I don't do\n", mID);
3670- return NS_NOINTERFACE;
3671+ return nsnull;
3672 }
3673 }
3674
3675 xpctestNoisy::xpctestNoisy()
3676 : mID(++sID)
3677 {
3678 sCount++;
3679 printf("Noisy %d - Created, %d total\n", mID, sCount);
3680diff --git a/layout/build/nsLayoutModule.cpp b/layout/build/nsLayoutModule.cpp
3681--- a/layout/build/nsLayoutModule.cpp
3682+++ b/layout/build/nsLayoutModule.cpp
3683@@ -707,17 +707,18 @@ Construct_nsIScriptSecurityManager(nsISu
3684 if (!aResult)
3685 return NS_ERROR_NULL_POINTER;
3686 *aResult = nsnull;
3687 if (aOuter)
3688 return NS_ERROR_NO_AGGREGATION;
3689 nsScriptSecurityManager *obj = nsScriptSecurityManager::GetScriptSecurityManager();
3690 if (!obj)
3691 return NS_ERROR_OUT_OF_MEMORY;
3692- if (NS_FAILED(obj->QueryInterface(aIID, aResult)))
3693+ *aResult = obj->QueryInterfaceFast(aIID);
3694+ if (!*aResult)
3695 return NS_ERROR_FAILURE;
3696 return NS_OK;
3697 }
3698
3699 #ifdef DEBUG
3700 NS_DEFINE_NAMED_CID(NS_FRAME_UTIL_CID);
3701 NS_DEFINE_NAMED_CID(NS_LAYOUT_DEBUGGER_CID);
3702 #endif
3703diff --git a/layout/style/StyleRule.cpp b/layout/style/StyleRule.cpp
3704--- a/layout/style/StyleRule.cpp
3705+++ b/layout/style/StyleRule.cpp
3706@@ -1264,19 +1264,18 @@ StyleRule::~StyleRule()
3707 mDOMRule->DOMDeclaration()->DropReference();
3708 NS_RELEASE(mDOMRule);
3709 }
3710 }
3711
3712 // QueryInterface implementation for StyleRule
3713 NS_INTERFACE_MAP_BEGIN(StyleRule)
3714 if (aIID.Equals(NS_GET_IID(mozilla::css::StyleRule))) {
3715- *aInstancePtr = this;
3716 NS_ADDREF_THIS();
3717- return NS_OK;
3718+ return this;
3719 }
3720 else
3721 NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
3722 NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule)
3723 NS_INTERFACE_MAP_END
3724
3725 NS_IMPL_ADDREF_INHERITED(StyleRule, Rule)
3726 NS_IMPL_RELEASE_INHERITED(StyleRule, Rule)
3727diff --git a/layout/style/nsCSSRules.cpp b/layout/style/nsCSSRules.cpp
3728--- a/layout/style/nsCSSRules.cpp
3729+++ b/layout/style/nsCSSRules.cpp
3730@@ -1105,19 +1105,18 @@ NameSpaceRule::~NameSpaceRule()
3731 }
3732
3733 NS_IMPL_ADDREF_INHERITED(NameSpaceRule, Rule)
3734 NS_IMPL_RELEASE_INHERITED(NameSpaceRule, Rule)
3735
3736 // QueryInterface implementation for NameSpaceRule
3737 NS_INTERFACE_MAP_BEGIN(NameSpaceRule)
3738 if (aIID.Equals(NS_GET_IID(css::NameSpaceRule))) {
3739- *aInstancePtr = this;
3740 NS_ADDREF_THIS();
3741- return NS_OK;
3742+ return this;
3743 }
3744 else
3745 NS_INTERFACE_MAP_ENTRY(nsIStyleRule)
3746 NS_INTERFACE_MAP_ENTRY(nsIDOMCSSRule)
3747 NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStyleRule)
3748 NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CSSNameSpaceRule)
3749 NS_INTERFACE_MAP_END
3750
3751diff --git a/layout/style/nsDOMCSSDeclaration.h b/layout/style/nsDOMCSSDeclaration.h
3752--- a/layout/style/nsDOMCSSDeclaration.h
3753+++ b/layout/style/nsDOMCSSDeclaration.h
3754@@ -56,19 +56,19 @@ class Loader;
3755 class Rule;
3756 }
3757 }
3758
3759 class nsDOMCSSDeclaration : public nsICSSDeclaration,
3760 public nsIDOMCSS2Properties
3761 {
3762 public:
3763- // Only implement QueryInterface; subclasses have the responsibility
3764+ // Only implement QueryInterfaceFast; subclasses have the responsibility
3765 // of implementing AddRef/Release.
3766- NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
3767+ NS_IMETHOD_(void*) QueryInterfaceFast(REFNSIID aIID);
3768
3769 NS_DECL_NSICSSDECLARATION
3770
3771 NS_IMETHOD GetMozPerspective(nsAString_internal&);
3772 NS_IMETHOD SetMozPerspective(const nsAString_internal&);
3773 NS_IMETHOD GetMozPerspectiveOrigin(nsAString_internal&);
3774 NS_IMETHOD SetMozPerspectiveOrigin(const nsAString_internal&);
3775 NS_IMETHOD GetMozBackfaceVisibility(nsAString_internal&);
3776diff --git a/layout/svg/base/src/nsSVGOuterSVGFrame.cpp b/layout/svg/base/src/nsSVGOuterSVGFrame.cpp
3777--- a/layout/svg/base/src/nsSVGOuterSVGFrame.cpp
3778+++ b/layout/svg/base/src/nsSVGOuterSVGFrame.cpp
3779@@ -59,17 +59,17 @@ namespace dom = mozilla::dom;
3780
3781 class nsSVGMutationObserver : public nsStubMutationObserver
3782 {
3783 public:
3784 // nsIMutationObserver interface
3785 NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
3786
3787 // nsISupports interface:
3788- NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
3789+ NS_IMETHOD_(void*) QueryInterfaceFast(const nsIID& aIID);
3790 private:
3791 NS_IMETHOD_(nsrefcnt) AddRef() { return 1; }
3792 NS_IMETHOD_(nsrefcnt) Release() { return 1; }
3793
3794 static void UpdateTextFragmentTrees(nsIFrame *aFrame);
3795 };
3796
3797 //----------------------------------------------------------------------
3798diff --git a/layout/xul/base/src/tree/src/nsTreeColumns.cpp b/layout/xul/base/src/tree/src/nsTreeColumns.cpp
3799--- a/layout/xul/base/src/tree/src/nsTreeColumns.cpp
3800+++ b/layout/xul/base/src/tree/src/nsTreeColumns.cpp
3801@@ -92,18 +92,17 @@ DOMCI_DATA(TreeColumn, nsTreeColumn)
3802
3803 // QueryInterface implementation for nsTreeColumn
3804 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsTreeColumn)
3805 NS_INTERFACE_MAP_ENTRY(nsITreeColumn)
3806 NS_INTERFACE_MAP_ENTRY(nsISupports)
3807 NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(TreeColumn)
3808 if (aIID.Equals(NS_GET_IID(nsTreeColumn))) {
3809 AddRef();
3810- *aInstancePtr = this;
3811- return NS_OK;
3812+ return this;
3813 }
3814 else
3815 NS_INTERFACE_MAP_END
3816
3817 nsIFrame*
3818 nsTreeColumn::GetFrame()
3819 {
3820 NS_ENSURE_TRUE(mContent, nsnull);
3821diff --git a/modules/libpr0n/src/imgLoader.cpp b/modules/libpr0n/src/imgLoader.cpp
3822--- a/modules/libpr0n/src/imgLoader.cpp
3823+++ b/modules/libpr0n/src/imgLoader.cpp
3824@@ -2268,18 +2268,20 @@ NS_IMETHODIMP imgCacheValidator::OnDataA
3825
3826 return mDestListener->OnDataAvailable(aRequest, ctxt, inStr, sourceOffset, count);
3827 }
3828
3829 /** nsIInterfaceRequestor methods **/
3830
3831 NS_IMETHODIMP imgCacheValidator::GetInterface(const nsIID & aIID, void **aResult)
3832 {
3833- if (aIID.Equals(NS_GET_IID(nsIChannelEventSink)))
3834- return QueryInterface(aIID, aResult);
3835+ if (aIID.Equals(NS_GET_IID(nsIChannelEventSink))) {
3836+ *aResult = QueryInterfaceFast(aIID);
3837+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
3838+ }
3839
3840 return mProgressProxy->GetInterface(aIID, aResult);
3841 }
3842
3843 // These functions are materially the same as the same functions in imgRequest.
3844 // We duplicate them because we're verifying whether cache loads are necessary,
3845 // not unconditionally loading.
3846
3847diff --git a/modules/libpr0n/src/imgRequest.cpp b/modules/libpr0n/src/imgRequest.cpp
3848--- a/modules/libpr0n/src/imgRequest.cpp
3849+++ b/modules/libpr0n/src/imgRequest.cpp
3850@@ -1217,18 +1217,20 @@ imgRequest::SniffMimeType(const char *bu
3851 }
3852
3853
3854 /** nsIInterfaceRequestor methods **/
3855
3856 NS_IMETHODIMP
3857 imgRequest::GetInterface(const nsIID & aIID, void **aResult)
3858 {
3859- if (!mPrevChannelSink || aIID.Equals(NS_GET_IID(nsIChannelEventSink)))
3860- return QueryInterface(aIID, aResult);
3861+ if (!mPrevChannelSink || aIID.Equals(NS_GET_IID(nsIChannelEventSink))) {
3862+ *aResult = QueryInterfaceFast(aIID);
3863+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
3864+ }
3865
3866 NS_ASSERTION(mPrevChannelSink != this,
3867 "Infinite recursion - don't keep track of channel sinks that are us!");
3868 return mPrevChannelSink->GetInterface(aIID, aResult);
3869 }
3870
3871 /** nsIChannelEventSink methods **/
3872 NS_IMETHODIMP
3873diff --git a/netwerk/base/src/nsBufferedStreams.cpp b/netwerk/base/src/nsBufferedStreams.cpp
3874--- a/netwerk/base/src/nsBufferedStreams.cpp
3875+++ b/netwerk/base/src/nsBufferedStreams.cpp
3876@@ -277,19 +277,19 @@ nsresult
3877 nsBufferedInputStream::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
3878 {
3879 NS_ENSURE_NO_AGGREGATION(aOuter);
3880
3881 nsBufferedInputStream* stream = new nsBufferedInputStream();
3882 if (stream == nsnull)
3883 return NS_ERROR_OUT_OF_MEMORY;
3884 NS_ADDREF(stream);
3885- nsresult rv = stream->QueryInterface(aIID, aResult);
3886+ *aResult = stream->QueryInterfaceFast(aIID);
3887 NS_RELEASE(stream);
3888- return rv;
3889+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
3890 }
3891
3892 NS_IMETHODIMP
3893 nsBufferedInputStream::Init(nsIInputStream* stream, PRUint32 bufferSize)
3894 {
3895 return nsBufferedStream::Init(stream, bufferSize);
3896 }
3897
3898@@ -535,19 +535,19 @@ nsresult
3899 nsBufferedOutputStream::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
3900 {
3901 NS_ENSURE_NO_AGGREGATION(aOuter);
3902
3903 nsBufferedOutputStream* stream = new nsBufferedOutputStream();
3904 if (stream == nsnull)
3905 return NS_ERROR_OUT_OF_MEMORY;
3906 NS_ADDREF(stream);
3907- nsresult rv = stream->QueryInterface(aIID, aResult);
3908+ *aResult = stream->QueryInterfaceFast(aIID);
3909 NS_RELEASE(stream);
3910- return rv;
3911+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
3912 }
3913
3914 NS_IMETHODIMP
3915 nsBufferedOutputStream::Init(nsIOutputStream* stream, PRUint32 bufferSize)
3916 {
3917 // QI stream to an nsISafeOutputStream, to see if we should support it
3918 mSafeStream = do_QueryInterface(stream);
3919
3920diff --git a/netwerk/base/src/nsFileStreams.cpp b/netwerk/base/src/nsFileStreams.cpp
3921--- a/netwerk/base/src/nsFileStreams.cpp
3922+++ b/netwerk/base/src/nsFileStreams.cpp
3923@@ -248,19 +248,19 @@ nsresult
3924 nsFileInputStream::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
3925 {
3926 NS_ENSURE_NO_AGGREGATION(aOuter);
3927
3928 nsFileInputStream* stream = new nsFileInputStream();
3929 if (stream == nsnull)
3930 return NS_ERROR_OUT_OF_MEMORY;
3931 NS_ADDREF(stream);
3932- nsresult rv = stream->QueryInterface(aIID, aResult);
3933+ *aResult = stream->QueryInterfaceFast(aIID);
3934 NS_RELEASE(stream);
3935- return rv;
3936+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
3937 }
3938
3939 nsresult
3940 nsFileInputStream::Open(nsIFile* aFile, PRInt32 aIOFlags, PRInt32 aPerm)
3941 {
3942 nsresult rv = NS_OK;
3943
3944 // If the previous file is open, close it
3945@@ -492,19 +492,19 @@ nsresult
3946 nsPartialFileInputStream::Create(nsISupports *aOuter, REFNSIID aIID,
3947 void **aResult)
3948 {
3949 NS_ENSURE_NO_AGGREGATION(aOuter);
3950
3951 nsPartialFileInputStream* stream = new nsPartialFileInputStream();
3952
3953 NS_ADDREF(stream);
3954- nsresult rv = stream->QueryInterface(aIID, aResult);
3955+ *aResult = stream->QueryInterfaceFast(aIID);
3956 NS_RELEASE(stream);
3957- return rv;
3958+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
3959 }
3960
3961 NS_IMETHODIMP
3962 nsPartialFileInputStream::Init(nsIFile* aFile, PRUint64 aStart,
3963 PRUint64 aLength, PRInt32 aIOFlags,
3964 PRInt32 aPerm, PRInt32 aBehaviorFlags)
3965 {
3966 mStart = aStart;
3967@@ -598,19 +598,19 @@ nsresult
3968 nsFileOutputStream::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
3969 {
3970 NS_ENSURE_NO_AGGREGATION(aOuter);
3971
3972 nsFileOutputStream* stream = new nsFileOutputStream();
3973 if (stream == nsnull)
3974 return NS_ERROR_OUT_OF_MEMORY;
3975 NS_ADDREF(stream);
3976- nsresult rv = stream->QueryInterface(aIID, aResult);
3977+ *aResult = stream->QueryInterfaceFast(aIID);
3978 NS_RELEASE(stream);
3979- return rv;
3980+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
3981 }
3982
3983 NS_IMETHODIMP
3984 nsFileOutputStream::Init(nsIFile* file, PRInt32 ioFlags, PRInt32 perm,
3985 PRInt32 behaviorFlags)
3986 {
3987 NS_ENSURE_TRUE(mFD == nsnull, NS_ERROR_ALREADY_INITIALIZED);
3988 NS_ENSURE_TRUE(!mDeferredOpen, NS_ERROR_ALREADY_INITIALIZED);
3989diff --git a/netwerk/base/src/nsIncrementalDownload.cpp b/netwerk/base/src/nsIncrementalDownload.cpp
3990--- a/netwerk/base/src/nsIncrementalDownload.cpp
3991+++ b/netwerk/base/src/nsIncrementalDownload.cpp
3992@@ -840,12 +840,12 @@ net_NewIncrementalDownload(nsISupports *
3993 if (outer)
3994 return NS_ERROR_NO_AGGREGATION;
3995
3996 nsIncrementalDownload *d = new nsIncrementalDownload();
3997 if (!d)
3998 return NS_ERROR_OUT_OF_MEMORY;
3999
4000 NS_ADDREF(d);
4001- nsresult rv = d->QueryInterface(iid, result);
4002+ *result = d->QueryInterfaceFast(iid);
4003 NS_RELEASE(d);
4004- return rv;
4005+ return (*result) ? NS_OK : NS_ERROR_FAILURE;
4006 }
4007diff --git a/netwerk/base/src/nsMIMEInputStream.cpp b/netwerk/base/src/nsMIMEInputStream.cpp
4008--- a/netwerk/base/src/nsMIMEInputStream.cpp
4009+++ b/netwerk/base/src/nsMIMEInputStream.cpp
4010@@ -315,20 +315,20 @@ nsMIMEInputStreamConstructor(nsISupports
4011 NS_ADDREF(inst);
4012
4013 nsresult rv = inst->Init();
4014 if (NS_FAILED(rv)) {
4015 NS_RELEASE(inst);
4016 return rv;
4017 }
4018
4019- rv = inst->QueryInterface(iid, result);
4020+ *result = inst->QueryInterfaceFast(iid);
4021 NS_RELEASE(inst);
4022
4023- return rv;
4024+ return (*result) ? NS_OK : NS_ERROR_NO_INTERFACE;
4025 }
4026
4027 PRBool
4028 nsMIMEInputStream::Read(const IPC::Message *aMsg, void **aIter)
4029 {
4030 using IPC::ReadParam;
4031
4032 if (!ReadParam(aMsg, aIter, &mHeaders) ||
4033diff --git a/netwerk/base/src/nsURIChecker.cpp b/netwerk/base/src/nsURIChecker.cpp
4034--- a/netwerk/base/src/nsURIChecker.cpp
4035+++ b/netwerk/base/src/nsURIChecker.cpp
4036@@ -355,17 +355,18 @@ nsURIChecker::OnDataAvailable(nsIRequest
4037 NS_IMETHODIMP
4038 nsURIChecker::GetInterface(const nsIID & aIID, void **aResult)
4039 {
4040 if (mObserver && aIID.Equals(NS_GET_IID(nsIAuthPrompt))) {
4041 nsCOMPtr<nsIInterfaceRequestor> req = do_QueryInterface(mObserver);
4042 if (req)
4043 return req->GetInterface(aIID, aResult);
4044 }
4045- return QueryInterface(aIID, aResult);
4046+ *aResult = QueryInterfaceFast(aIID);
4047+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
4048 }
4049
4050 //-----------------------------------------------------------------------------
4051 // nsIChannelEventSink methods:
4052 //-----------------------------------------------------------------------------
4053
4054 NS_IMETHODIMP
4055 nsURIChecker::AsyncOnChannelRedirect(nsIChannel *aOldChannel,
4056diff --git a/netwerk/build/nsNetModule.cpp b/netwerk/build/nsNetModule.cpp
4057--- a/netwerk/build/nsNetModule.cpp
4058+++ b/netwerk/build/nsNetModule.cpp
4059@@ -310,19 +310,19 @@ type##Constructor(nsISupports *aOuter, R
4060 \
4061 *aResult = NULL; \
4062 if (NULL != aOuter) { \
4063 rv = NS_ERROR_NO_AGGREGATION; \
4064 return rv; \
4065 } \
4066 inst = WebSocketChannelConstructor(secure); \
4067 NS_ADDREF(inst); \
4068- rv = inst->QueryInterface(aIID, aResult); \
4069+ *aResult = inst->QueryInterfaceFast(aIID); \
4070 NS_RELEASE(inst); \
4071- return rv; \
4072+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE; \
4073 }
4074
4075 WEB_SOCKET_HANDLER_CONSTRUCTOR(WebSocketChannel, false)
4076 WEB_SOCKET_HANDLER_CONSTRUCTOR(WebSocketSSLChannel, true)
4077 #undef WEB_SOCKET_HANDLER_CONSTRUCTOR
4078 } // namespace mozilla::net
4079 } // namespace mozilla
4080 #endif
4081@@ -553,38 +553,36 @@ CreateNewHTTPCompressConvFactory (nsISup
4082 }
4083 NS_RELEASE(inst); /* get rid of extra refcnt */
4084 return rv;
4085 }
4086
4087 static nsresult
4088 CreateNewUnknownDecoderFactory(nsISupports *aOuter, REFNSIID aIID, void **aResult)
4089 {
4090- nsresult rv;
4091-
4092 if (!aResult) {
4093 return NS_ERROR_NULL_POINTER;
4094 }
4095 *aResult = nsnull;
4096
4097 if (aOuter) {
4098 return NS_ERROR_NO_AGGREGATION;
4099 }
4100
4101 nsUnknownDecoder *inst;
4102
4103 inst = new nsUnknownDecoder();
4104 if (!inst) {
4105 return NS_ERROR_OUT_OF_MEMORY;
4106 }
4107 NS_ADDREF(inst);
4108- rv = inst->QueryInterface(aIID, aResult);
4109+ *aResult = inst->QueryInterfaceFast(aIID);
4110 NS_RELEASE(inst);
4111
4112- return rv;
4113+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
4114 }
4115
4116 static nsresult
4117 CreateNewBinaryDetectorFactory(nsISupports *aOuter, REFNSIID aIID, void **aResult)
4118 {
4119 nsresult rv;
4120
4121 if (!aResult) {
4122@@ -596,20 +594,20 @@ CreateNewBinaryDetectorFactory(nsISuppor
4123 return NS_ERROR_NO_AGGREGATION;
4124 }
4125
4126 nsBinaryDetector* inst = new nsBinaryDetector();
4127 if (!inst) {
4128 return NS_ERROR_OUT_OF_MEMORY;
4129 }
4130 NS_ADDREF(inst);
4131- rv = inst->QueryInterface(aIID, aResult);
4132+ *aResult = inst->QueryInterfaceFast(aIID);
4133 NS_RELEASE(inst);
4134
4135- return rv;
4136+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
4137 }
4138
4139 static nsresult
4140 CreateNewNSTXTToHTMLConvFactory(nsISupports *aOuter, REFNSIID aIID, void **aResult)
4141 {
4142 nsresult rv;
4143
4144 if (!aResult) {
4145diff --git a/netwerk/protocol/about/nsAboutCache.cpp b/netwerk/protocol/about/nsAboutCache.cpp
4146--- a/netwerk/protocol/about/nsAboutCache.cpp
4147+++ b/netwerk/protocol/about/nsAboutCache.cpp
4148@@ -382,16 +382,16 @@ nsAboutCache::ParseURI(nsIURI * uri, nsC
4149
4150 nsresult
4151 nsAboutCache::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
4152 {
4153 nsAboutCache* about = new nsAboutCache();
4154 if (about == nsnull)
4155 return NS_ERROR_OUT_OF_MEMORY;
4156 NS_ADDREF(about);
4157- nsresult rv = about->QueryInterface(aIID, aResult);
4158+ *aResult = about->QueryInterfaceFast(aIID);
4159 NS_RELEASE(about);
4160- return rv;
4161+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
4162 }
4163
4164
4165
4166 ////////////////////////////////////////////////////////////////////////////////
4167diff --git a/netwerk/protocol/about/nsAboutProtocolHandler.h b/netwerk/protocol/about/nsAboutProtocolHandler.h
4168--- a/netwerk/protocol/about/nsAboutProtocolHandler.h
4169+++ b/netwerk/protocol/about/nsAboutProtocolHandler.h
4170@@ -84,17 +84,17 @@ public:
4171 {}
4172
4173 // For use only from deserialization
4174 nsNestedAboutURI() : nsSimpleNestedURI() {}
4175
4176 virtual ~nsNestedAboutURI() {}
4177
4178 // Override QI so we can QI to our CID as needed
4179- NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
4180+ NS_IMETHOD_(void*) QueryInterfaceFast(REFNSIID aIID);
4181
4182 // Override StartClone(), the nsISerializable methods, and
4183 // GetClassIDNoAlloc; this last is needed to make our nsISerializable impl
4184 // work right.
4185 virtual nsSimpleURI* StartClone(RefHandlingEnum aRefHandlingMode);
4186 NS_IMETHOD Read(nsIObjectInputStream* aStream);
4187 NS_IMETHOD Write(nsIObjectOutputStream* aStream);
4188 NS_IMETHOD GetClassIDNoAlloc(nsCID *aClassIDNoAlloc);
4189diff --git a/netwerk/protocol/ftp/FTPChannelParent.cpp b/netwerk/protocol/ftp/FTPChannelParent.cpp
4190--- a/netwerk/protocol/ftp/FTPChannelParent.cpp
4191+++ b/netwerk/protocol/ftp/FTPChannelParent.cpp
4192@@ -252,14 +252,15 @@ FTPChannelParent::Delete()
4193
4194 //-----------------------------------------------------------------------------
4195 // FTPChannelParent::nsIInterfaceRequestor
4196 //-----------------------------------------------------------------------------
4197
4198 NS_IMETHODIMP
4199 FTPChannelParent::GetInterface(const nsIID& uuid, void** result)
4200 {
4201- return QueryInterface(uuid, result);
4202+ *result = QueryInterfaceFast(uuid);
4203+ return (*result) ? NS_OK : NS_ERROR_NO_INTERFACE;
4204 }
4205
4206 } // namespace net
4207 } // namespace mozilla
4208
4209diff --git a/netwerk/protocol/http/HttpChannelParent.cpp b/netwerk/protocol/http/HttpChannelParent.cpp
4210--- a/netwerk/protocol/http/HttpChannelParent.cpp
4211+++ b/netwerk/protocol/http/HttpChannelParent.cpp
4212@@ -113,17 +113,18 @@ HttpChannelParent::GetInterface(const ns
4213 if (aIID.Equals(NS_GET_IID(nsIAuthPromptProvider)) ||
4214 aIID.Equals(NS_GET_IID(nsISecureBrowserUI))) {
4215 if (!mTabParent)
4216 return NS_NOINTERFACE;
4217
4218 return mTabParent->QueryInterface(aIID, result);
4219 }
4220
4221- return QueryInterface(aIID, result);
4222+ *result = QueryInterfaceFast(aIID);
4223+ return (*result) ? NS_OK : NS_ERROR_NO_INTERFACE;
4224 }
4225
4226 //-----------------------------------------------------------------------------
4227 // HttpChannelParent::PHttpChannelParent
4228 //-----------------------------------------------------------------------------
4229
4230 bool
4231 HttpChannelParent::RecvAsyncOpen(const IPC::URI& aURI,
4232diff --git a/netwerk/protocol/http/HttpChannelParentListener.cpp b/netwerk/protocol/http/HttpChannelParentListener.cpp
4233--- a/netwerk/protocol/http/HttpChannelParentListener.cpp
4234+++ b/netwerk/protocol/http/HttpChannelParentListener.cpp
4235@@ -140,17 +140,18 @@ HttpChannelParentListener::OnDataAvailab
4236
4237 NS_IMETHODIMP
4238 HttpChannelParentListener::GetInterface(const nsIID& aIID, void **result)
4239 {
4240 if (aIID.Equals(NS_GET_IID(nsIChannelEventSink)) ||
4241 aIID.Equals(NS_GET_IID(nsIHttpEventSink)) ||
4242 aIID.Equals(NS_GET_IID(nsIRedirectResultListener)))
4243 {
4244- return QueryInterface(aIID, result);
4245+ *result = QueryInterfaceFast(aIID);
4246+ return (*result) ? NS_OK : NS_ERROR_NO_INTERFACE;
4247 }
4248
4249 nsCOMPtr<nsIInterfaceRequestor> ir;
4250 if (mActiveChannel &&
4251 NS_SUCCEEDED(CallQueryInterface(mActiveChannel.get(),
4252 getter_AddRefs(ir))))
4253 {
4254 return ir->GetInterface(aIID, result);
4255diff --git a/netwerk/protocol/websocket/BaseWebSocketChannel.h b/netwerk/protocol/websocket/BaseWebSocketChannel.h
4256--- a/netwerk/protocol/websocket/BaseWebSocketChannel.h
4257+++ b/netwerk/protocol/websocket/BaseWebSocketChannel.h
4258@@ -55,17 +55,17 @@ const static PRInt32 kDefaultWSSPort
4259 class BaseWebSocketChannel : public nsIWebSocketChannel,
4260 public nsIProtocolHandler
4261 {
4262 public:
4263 BaseWebSocketChannel();
4264
4265 NS_DECL_NSIPROTOCOLHANDLER
4266
4267- NS_IMETHOD QueryInterface(const nsIID & uuid, void **result NS_OUTPARAM) = 0;
4268+ NS_IMETHOD_(void*) QueryInterfaceFast(const nsIID & uuid) = 0;
4269 NS_IMETHOD_(nsrefcnt ) AddRef(void) = 0;
4270 NS_IMETHOD_(nsrefcnt ) Release(void) = 0;
4271
4272 // Partial implementation of nsIWebSocketChannel
4273 //
4274 NS_IMETHOD GetOriginalURI(nsIURI **aOriginalURI);
4275 NS_IMETHOD GetURI(nsIURI **aURI);
4276 NS_IMETHOD GetNotificationCallbacks(nsIInterfaceRequestor **aNotificationCallbacks);
4277diff --git a/netwerk/protocol/websocket/WebSocketChannel.cpp b/netwerk/protocol/websocket/WebSocketChannel.cpp
4278--- a/netwerk/protocol/websocket/WebSocketChannel.cpp
4279+++ b/netwerk/protocol/websocket/WebSocketChannel.cpp
4280@@ -1771,18 +1771,20 @@ WebSocketChannel::OnLookupComplete(nsICa
4281
4282 // nsIInterfaceRequestor
4283
4284 NS_IMETHODIMP
4285 WebSocketChannel::GetInterface(const nsIID & iid, void **result NS_OUTPARAM)
4286 {
4287 LOG(("WebSocketChannel::GetInterface() %p\n", this));
4288
4289- if (iid.Equals(NS_GET_IID(nsIChannelEventSink)))
4290- return QueryInterface(iid, result);
4291+ if (iid.Equals(NS_GET_IID(nsIChannelEventSink))) {
4292+ *result = QueryInterfaceFast(iid);
4293+ return (*result) ? NS_OK : NS_ERROR_NO_INTERFACE;
4294+ }
4295
4296 if (mCallbacks)
4297 return mCallbacks->GetInterface(iid, result);
4298
4299 return NS_ERROR_FAILURE;
4300 }
4301
4302 // nsIChannelEventSink
4303diff --git a/netwerk/streamconv/converters/nsIndexedToHTML.cpp b/netwerk/streamconv/converters/nsIndexedToHTML.cpp
4304--- a/netwerk/streamconv/converters/nsIndexedToHTML.cpp
4305+++ b/netwerk/streamconv/converters/nsIndexedToHTML.cpp
4306@@ -86,19 +86,19 @@ nsresult
4307 nsIndexedToHTML::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult) {
4308 nsresult rv;
4309 if (aOuter)
4310 return NS_ERROR_NO_AGGREGATION;
4311
4312 nsIndexedToHTML* _s = new nsIndexedToHTML();
4313 if (_s == nsnull)
4314 return NS_ERROR_OUT_OF_MEMORY;
4315-
4316- rv = _s->QueryInterface(aIID, aResult);
4317- return rv;
4318+
4319+ *aResult = _s->QueryInterfaceFast(aIID);
4320+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
4321 }
4322
4323 nsresult
4324 nsIndexedToHTML::Init(nsIStreamListener* aListener) {
4325
4326 nsXPIDLString ellipsis;
4327 nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
4328 if (prefs) {
4329diff --git a/netwerk/test/TestPageLoad.cpp b/netwerk/test/TestPageLoad.cpp
4330--- a/netwerk/test/TestPageLoad.cpp
4331+++ b/netwerk/test/TestPageLoad.cpp
4332@@ -237,17 +237,18 @@ public:
4333
4334 NS_IMPL_THREADSAFE_ISUPPORTS2(MyNotifications,
4335 nsIInterfaceRequestor,
4336 nsIProgressEventSink)
4337
4338 NS_IMETHODIMP
4339 MyNotifications::GetInterface(const nsIID &iid, void **result)
4340 {
4341- return QueryInterface(iid, result);
4342+ *result = QueryInterfaceFast(iid);
4343+ return (*result) ? NS_OK : NS_ERROR_NO_INTERFACE;
4344 }
4345
4346 NS_IMETHODIMP
4347 MyNotifications::OnStatus(nsIRequest *req, nsISupports *ctx,
4348 nsresult status, const PRUnichar *statusText)
4349 {
4350 //printf("status: %x\n", status);
4351 return NS_OK;
4352diff --git a/parser/html/nsHtml5Atom.cpp b/parser/html/nsHtml5Atom.cpp
4353--- a/parser/html/nsHtml5Atom.cpp
4354+++ b/parser/html/nsHtml5Atom.cpp
4355@@ -72,21 +72,21 @@ nsHtml5Atom::AddRef()
4356
4357 NS_IMETHODIMP_(nsrefcnt)
4358 nsHtml5Atom::Release()
4359 {
4360 NS_NOTREACHED("Attempt to Release an nsHtml5Atom.");
4361 return 1;
4362 }
4363
4364-NS_IMETHODIMP
4365-nsHtml5Atom::QueryInterface(REFNSIID aIID, void** aInstancePtr)
4366+NS_IMETHODIMP_(void*)
4367+nsHtml5Atom::QueryInterfaceFast(REFNSIID aIID)
4368 {
4369 NS_NOTREACHED("Attempt to call QueryInterface an nsHtml5Atom.");
4370- return NS_ERROR_UNEXPECTED;
4371+ return nsnull;
4372 }
4373
4374 NS_IMETHODIMP
4375 nsHtml5Atom::ScriptableToString(nsAString& aBuf)
4376 {
4377 NS_NOTREACHED("Should not call ScriptableToString.");
4378 return NS_ERROR_NOT_IMPLEMENTED;
4379 }
4380diff --git a/rdf/base/src/nsInMemoryDataSource.cpp b/rdf/base/src/nsInMemoryDataSource.cpp
4381--- a/rdf/base/src/nsInMemoryDataSource.cpp
4382+++ b/rdf/base/src/nsInMemoryDataSource.cpp
4383@@ -868,18 +868,19 @@ NS_NewRDFInMemoryDataSource(nsISupports*
4384 InMemoryDataSource* datasource = new InMemoryDataSource(aOuter);
4385 if (! datasource)
4386 return NS_ERROR_OUT_OF_MEMORY;
4387 NS_ADDREF(datasource);
4388
4389 nsresult rv = datasource->Init();
4390 if (NS_SUCCEEDED(rv)) {
4391 datasource->fAggregated.AddRef();
4392- rv = datasource->AggregatedQueryInterface(aIID, aResult); // This'll AddRef()
4393+ *aResult = datasource->AggregatedQueryInterface(aIID); // This'll AddRef()
4394 datasource->fAggregated.Release();
4395+ rv = (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
4396 }
4397
4398 NS_RELEASE(datasource);
4399 return rv;
4400 }
4401
4402
4403 InMemoryDataSource::InMemoryDataSource(nsISupports* aOuter)
4404diff --git a/rdf/base/src/nsRDFContentSink.cpp b/rdf/base/src/nsRDFContentSink.cpp
4405--- a/rdf/base/src/nsRDFContentSink.cpp
4406+++ b/rdf/base/src/nsRDFContentSink.cpp
4407@@ -401,38 +401,31 @@ RDFContentSinkImpl::~RDFContentSinkImpl(
4408 }
4409
4410 ////////////////////////////////////////////////////////////////////////
4411 // nsISupports interface
4412
4413 NS_IMPL_ADDREF(RDFContentSinkImpl)
4414 NS_IMPL_RELEASE(RDFContentSinkImpl)
4415
4416-NS_IMETHODIMP
4417-RDFContentSinkImpl::QueryInterface(REFNSIID iid, void** result)
4418+NS_IMETHODIMP_(void*)
4419+RDFContentSinkImpl::QueryInterfaceFast(REFNSIID iid)
4420 {
4421- NS_PRECONDITION(result, "null ptr");
4422- if (! result)
4423- return NS_ERROR_NULL_POINTER;
4424-
4425- *result = nsnull;
4426 if (iid.Equals(kIRDFContentSinkIID) ||
4427 iid.Equals(kIXMLContentSinkIID) ||
4428 iid.Equals(kIContentSinkIID) ||
4429 iid.Equals(kISupportsIID)) {
4430- *result = static_cast<nsIXMLContentSink*>(this);
4431 AddRef();
4432- return NS_OK;
4433+ return static_cast<nsIXMLContentSink*>(this);
4434 }
4435 else if (iid.Equals(kIExpatSinkIID)) {
4436- *result = static_cast<nsIExpatSink*>(this);
4437 AddRef();
4438- return NS_OK;
4439+ return static_cast<nsIExpatSink*>(this);
4440 }
4441- return NS_NOINTERFACE;
4442+ return nsnull;
4443 }
4444
4445 NS_IMETHODIMP
4446 RDFContentSinkImpl::HandleStartElement(const PRUnichar *aName,
4447 const PRUnichar **aAtts,
4448 PRUint32 aAttsCount,
4449 PRInt32 aIndex,
4450 PRUint32 aLineNumber)
4451diff --git a/rdf/base/src/nsRDFService.cpp b/rdf/base/src/nsRDFService.cpp
4452--- a/rdf/base/src/nsRDFService.cpp
4453+++ b/rdf/base/src/nsRDFService.cpp
4454@@ -492,31 +492,26 @@ LiteralImpl::~LiteralImpl()
4455 // what a vanilla NS_RELEASE() would do).
4456 nsrefcnt refcnt;
4457 NS_RELEASE2(RDFServiceImpl::gRDFService, refcnt);
4458 }
4459
4460 NS_IMPL_THREADSAFE_ADDREF(LiteralImpl)
4461 NS_IMPL_THREADSAFE_RELEASE(LiteralImpl)
4462
4463-nsresult
4464-LiteralImpl::QueryInterface(REFNSIID iid, void** result)
4465+NS_IMETHODIMP_(void*)
4466+LiteralImpl::QueryInterfaceFast(REFNSIID iid)
4467 {
4468- if (! result)
4469- return NS_ERROR_NULL_POINTER;
4470-
4471- *result = nsnull;
4472 if (iid.Equals(kIRDFLiteralIID) ||
4473 iid.Equals(kIRDFNodeIID) ||
4474 iid.Equals(kISupportsIID)) {
4475- *result = static_cast<nsIRDFLiteral*>(this);
4476 AddRef();
4477- return NS_OK;
4478+ return static_cast<nsIRDFLiteral*>(this);
4479 }
4480- return NS_NOINTERFACE;
4481+ return nsnull;
4482 }
4483
4484 NS_IMETHODIMP
4485 LiteralImpl::EqualsNode(nsIRDFNode* aNode, PRBool* aResult)
4486 {
4487 nsresult rv;
4488 nsIRDFLiteral* literal;
4489 rv = aNode->QueryInterface(kIRDFLiteralIID, (void**) &literal);
4490@@ -594,31 +589,26 @@ DateImpl::~DateImpl()
4491 // what a vanilla NS_RELEASE() would do).
4492 nsrefcnt refcnt;
4493 NS_RELEASE2(RDFServiceImpl::gRDFService, refcnt);
4494 }
4495
4496 NS_IMPL_ADDREF(DateImpl)
4497 NS_IMPL_RELEASE(DateImpl)
4498
4499-nsresult
4500-DateImpl::QueryInterface(REFNSIID iid, void** result)
4501+NS_IMETHODIMP_(void*)
4502+DateImpl::QueryInterfaceFast(REFNSIID iid)
4503 {
4504- if (! result)
4505- return NS_ERROR_NULL_POINTER;
4506-
4507- *result = nsnull;
4508 if (iid.Equals(kIRDFDateIID) ||
4509 iid.Equals(kIRDFNodeIID) ||
4510 iid.Equals(kISupportsIID)) {
4511- *result = static_cast<nsIRDFDate*>(this);
4512 AddRef();
4513- return NS_OK;
4514+ return static_cast<nsIRDFDate*>(this);
4515 }
4516- return NS_NOINTERFACE;
4517+ return nsnull;
4518 }
4519
4520 NS_IMETHODIMP
4521 DateImpl::EqualsNode(nsIRDFNode* node, PRBool* result)
4522 {
4523 nsresult rv;
4524 nsIRDFDate* date;
4525 if (NS_SUCCEEDED(node->QueryInterface(kIRDFDateIID, (void**) &date))) {
4526@@ -700,31 +690,27 @@ IntImpl::~IntImpl()
4527 // what a vanilla NS_RELEASE() would do).
4528 nsrefcnt refcnt;
4529 NS_RELEASE2(RDFServiceImpl::gRDFService, refcnt);
4530 }
4531
4532 NS_IMPL_ADDREF(IntImpl)
4533 NS_IMPL_RELEASE(IntImpl)
4534
4535-nsresult
4536-IntImpl::QueryInterface(REFNSIID iid, void** result)
4537+
4538+NS_IMETHODIMP_(void*)
4539+IntImpl::QueryInterfaceFast(REFNSIID iid)
4540 {
4541- if (! result)
4542- return NS_ERROR_NULL_POINTER;
4543-
4544- *result = nsnull;
4545 if (iid.Equals(kIRDFIntIID) ||
4546 iid.Equals(kIRDFNodeIID) ||
4547 iid.Equals(kISupportsIID)) {
4548- *result = static_cast<nsIRDFInt*>(this);
4549 AddRef();
4550- return NS_OK;
4551+ return static_cast<nsIRDFInt*>(this);
4552 }
4553- return NS_NOINTERFACE;
4554+ return nsnull;
4555 }
4556
4557 NS_IMETHODIMP
4558 IntImpl::EqualsNode(nsIRDFNode* node, PRBool* result)
4559 {
4560 nsresult rv;
4561 nsIRDFInt* intValue;
4562 if (NS_SUCCEEDED(node->QueryInterface(kIRDFIntIID, (void**) &intValue))) {
4563@@ -859,28 +845,30 @@ RDFServiceImpl::~RDFServiceImpl()
4564 nsresult
4565 RDFServiceImpl::CreateSingleton(nsISupports* aOuter,
4566 const nsIID& aIID, void **aResult)
4567 {
4568 NS_ENSURE_NO_AGGREGATION(aOuter);
4569
4570 if (gRDFService) {
4571 NS_ERROR("Trying to create RDF serviec twice.");
4572- return gRDFService->QueryInterface(aIID, aResult);
4573+ *aResult = gRDFService->QueryInterfaceFast(aIID);
4574+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
4575 }
4576
4577 nsRefPtr<RDFServiceImpl> serv = new RDFServiceImpl();
4578 if (!serv)
4579 return NS_ERROR_OUT_OF_MEMORY;
4580
4581 nsresult rv = serv->Init();
4582 if (NS_FAILED(rv))
4583 return rv;
4584
4585- return serv->QueryInterface(aIID, aResult);
4586+ *aResult = serv->QueryInterfaceFast(aIID);
4587+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
4588 }
4589
4590 NS_IMPL_THREADSAFE_ISUPPORTS2(RDFServiceImpl, nsIRDFService, nsISupportsWeakReference)
4591
4592 // Per RFC2396.
4593 static const PRUint8
4594 kLegalSchemeChars[] = {
4595 // ASCII Bits Ordered Hex
4596diff --git a/rdf/base/src/nsRDFXMLDataSource.cpp b/rdf/base/src/nsRDFXMLDataSource.cpp
4597--- a/rdf/base/src/nsRDFXMLDataSource.cpp
4598+++ b/rdf/base/src/nsRDFXMLDataSource.cpp
4599@@ -495,17 +495,18 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
4600 NS_INTERFACE_MAP_ENTRY(nsIChannelEventSink)
4601 NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIRDFDataSource)
4602 NS_INTERFACE_MAP_END
4603
4604 // nsIInterfaceRequestor
4605 NS_IMETHODIMP
4606 RDFXMLDataSourceImpl::GetInterface(const nsIID& aIID, void** aSink)
4607 {
4608- return QueryInterface(aIID, aSink);
4609+ *aSink = QueryInterfaceFast(aIID);
4610+ return (*aSink) ? NS_OK : NS_ERROR_NO_INTERFACE;
4611 }
4612
4613 nsresult
4614 RDFXMLDataSourceImpl::BlockingParse(nsIURI* aURL, nsIStreamListener* aConsumer)
4615 {
4616 nsresult rv;
4617
4618 // XXX I really hate the way that we're spoon-feeding this stuff
4619diff --git a/rdf/datasource/src/nsLocalStore.cpp b/rdf/datasource/src/nsLocalStore.cpp
4620--- a/rdf/datasource/src/nsLocalStore.cpp
4621+++ b/rdf/datasource/src/nsLocalStore.cpp
4622@@ -254,17 +254,18 @@ NS_NewLocalStore(nsISupports* aOuter, RE
4623 return NS_ERROR_OUT_OF_MEMORY;
4624
4625 NS_ADDREF(impl);
4626
4627 nsresult rv;
4628 rv = impl->Init();
4629 if (NS_SUCCEEDED(rv)) {
4630 // Set up the result pointer
4631- rv = impl->QueryInterface(aIID, aResult);
4632+ *aResult = impl->QueryInterfaceFast(aIID);
4633+ rv = (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
4634 }
4635
4636 NS_RELEASE(impl);
4637 return rv;
4638 }
4639
4640 NS_IMPL_CYCLE_COLLECTION_1(LocalStoreImpl, mInner)
4641 NS_IMPL_CYCLE_COLLECTING_ADDREF(LocalStoreImpl)
4642diff --git a/security/manager/ssl/src/nsCertPicker.cpp b/security/manager/ssl/src/nsCertPicker.cpp
4643--- a/security/manager/ssl/src/nsCertPicker.cpp
4644+++ b/security/manager/ssl/src/nsCertPicker.cpp
4645@@ -202,19 +202,20 @@ NS_IMETHODIMP nsCertPicker::PickByUsage(
4646
4647 if (i == selectedIndex) {
4648 nsNSSCertificate *cert = nsNSSCertificate::Create(node->cert);
4649 if (!cert) {
4650 rv = NS_ERROR_OUT_OF_MEMORY;
4651 break;
4652 }
4653
4654- nsIX509Cert *x509 = 0;
4655- nsresult rv = cert->QueryInterface(NS_GET_IID(nsIX509Cert), (void**)&x509);
4656- if (NS_FAILED(rv)) {
4657+ nsIX509Cert *x509 = static_cast<nsIX509Cert*>
4658+ (cert->QueryInterfaceFast(NS_GET_IID(nsIX509Cert)));
4659+ if (!x509) {
4660+ rv = NS_ERROR_NO_INTERFACE;
4661 break;
4662 }
4663
4664 NS_ADDREF(x509);
4665 *_retval = x509;
4666 NS_RELEASE(cert);
4667 break;
4668 }
4669diff --git a/security/manager/ssl/src/nsNSSIOLayer.cpp b/security/manager/ssl/src/nsNSSIOLayer.cpp
4670--- a/security/manager/ssl/src/nsNSSIOLayer.cpp
4671+++ b/security/manager/ssl/src/nsNSSIOLayer.cpp
4672@@ -3798,17 +3798,18 @@ nsSSLIOLayerAddToSocket(PRInt32 family,
4673
4674 if (NS_FAILED(rv)) {
4675 goto loser;
4676 }
4677
4678 nsNSSShutDownList::trackSSLSocketCreate();
4679
4680 PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("[%p] Socket set up\n", (void*)sslSock));
4681- infoObject->QueryInterface(NS_GET_IID(nsISupports), (void**) (info));
4682+ *info = static_cast<nsISupports*>
4683+ (infoObject->QueryInterfaceFast(NS_GET_IID(nsISupports)));
4684
4685 // We are going use a clear connection first //
4686 if (forSTARTTLS || proxyHost) {
4687 infoObject->SetHandshakePending(PR_FALSE);
4688 }
4689
4690 return NS_OK;
4691 loser:
4692diff --git a/security/manager/ssl/src/nsNSSModule.cpp b/security/manager/ssl/src/nsNSSModule.cpp
4693--- a/security/manager/ssl/src/nsNSSModule.cpp
4694+++ b/security/manager/ssl/src/nsNSSModule.cpp
4695@@ -89,34 +89,36 @@
4696 inst = new _InstanceClass(); \
4697 if (NULL == inst) { \
4698 if (ensureOperator == nssLoadingComponent) \
4699 EnsureNSSInitialized(nssInitFailed); \
4700 rv = NS_ERROR_OUT_OF_MEMORY; \
4701 return rv; \
4702 } \
4703 NS_ADDREF(inst); \
4704- rv = inst->QueryInterface(aIID, aResult); \
4705+ *aResult = inst->QueryInterfaceFast(aIID); \
4706+ rv = (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE; \
4707 NS_RELEASE(inst); \
4708 PR_END_MACRO
4709
4710 #define NS_NSS_INSTANTIATE_INIT(ensureOperator, _InstanceClass, _InitMethod) \
4711 PR_BEGIN_MACRO \
4712 _InstanceClass * inst; \
4713 inst = new _InstanceClass(); \
4714 if (NULL == inst) { \
4715 if (ensureOperator == nssLoadingComponent) \
4716 EnsureNSSInitialized(nssInitFailed); \
4717 rv = NS_ERROR_OUT_OF_MEMORY; \
4718 return rv; \
4719 } \
4720 NS_ADDREF(inst); \
4721 rv = inst->_InitMethod(); \
4722 if(NS_SUCCEEDED(rv)) { \
4723- rv = inst->QueryInterface(aIID, aResult); \
4724+ *aResult = inst->QueryInterfaceFast(aIID); \
4725+ rv = (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE; \
4726 } \
4727 NS_RELEASE(inst); \
4728 PR_END_MACRO
4729
4730
4731 #define NS_NSS_GENERIC_FACTORY_CONSTRUCTOR(ensureOperator, \
4732 _InstanceClass) \
4733 NS_NSS_GENERIC_FACTORY_CONSTRUCTOR_BYPROCESS(ensureOperator, \
4734diff --git a/toolkit/components/build/nsToolkitCompsModule.cpp b/toolkit/components/build/nsToolkitCompsModule.cpp
4735--- a/toolkit/components/build/nsToolkitCompsModule.cpp
4736+++ b/toolkit/components/build/nsToolkitCompsModule.cpp
4737@@ -107,20 +107,20 @@ nsUrlClassifierDBServiceConstructor(nsIS
4738 NS_ENSURE_ARG_POINTER(aResult);
4739 NS_ENSURE_NO_AGGREGATION(aOuter);
4740
4741 nsUrlClassifierDBService *inst = nsUrlClassifierDBService::GetInstance(&rv);
4742 if (NULL == inst) {
4743 return rv;
4744 }
4745 /* NS_ADDREF(inst); */
4746- rv = inst->QueryInterface(aIID, aResult);
4747+ *aResult = inst->QueryInterfaceFast(aIID);
4748 NS_RELEASE(inst);
4749
4750- return rv;
4751+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
4752 }
4753 #endif
4754
4755 #ifdef MOZ_FEEDS
4756 NS_GENERIC_FACTORY_CONSTRUCTOR(nsScriptableUnescapeHTML)
4757 #endif
4758
4759 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBrowserStatusFilter)
4760diff --git a/toolkit/components/intl/nsCharsetMenu.cpp b/toolkit/components/intl/nsCharsetMenu.cpp
4761--- a/toolkit/components/intl/nsCharsetMenu.cpp
4762+++ b/toolkit/components/intl/nsCharsetMenu.cpp
4763@@ -326,22 +326,21 @@ NS_NewCharsetMenu(nsISupports * aOuter,
4764 *aResult = nsnull;
4765 return NS_ERROR_NO_AGGREGATION;
4766 }
4767 nsCharsetMenu* inst = new nsCharsetMenu();
4768 if (!inst) {
4769 *aResult = nsnull;
4770 return NS_ERROR_OUT_OF_MEMORY;
4771 }
4772- nsresult res = inst->QueryInterface(aIID, aResult);
4773- if (NS_FAILED(res)) {
4774- *aResult = nsnull;
4775+ *aResult = inst->QueryInterfaceFast(aIID);
4776+ if (!*aResult) {
4777 delete inst;
4778 }
4779- return res;
4780+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
4781 }
4782
4783 struct charsetMenuSortRecord {
4784 nsMenuEntry* item;
4785 PRUint8* key;
4786 PRUint32 len;
4787
4788 };
4789diff --git a/toolkit/components/places/AsyncFaviconHelpers.cpp b/toolkit/components/places/AsyncFaviconHelpers.cpp
4790--- a/toolkit/components/places/AsyncFaviconHelpers.cpp
4791+++ b/toolkit/components/places/AsyncFaviconHelpers.cpp
4792@@ -636,17 +636,18 @@ AsyncFetchAndSetIconFromNetwork::OnDataA
4793 return NS_OK;
4794 }
4795
4796
4797 NS_IMETHODIMP
4798 AsyncFetchAndSetIconFromNetwork::GetInterface(const nsIID& uuid,
4799 void** aResult)
4800 {
4801- return QueryInterface(uuid, aResult);
4802+ *aResult = QueryInterfaceFast(uuid);
4803+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
4804 }
4805
4806
4807 NS_IMETHODIMP
4808 AsyncFetchAndSetIconFromNetwork::AsyncOnChannelRedirect(
4809 nsIChannel* oldChannel
4810 , nsIChannel* newChannel
4811 , PRUint32 flags
4812diff --git a/toolkit/components/places/nsNavHistoryResult.cpp b/toolkit/components/places/nsNavHistoryResult.cpp
4813--- a/toolkit/components/places/nsNavHistoryResult.cpp
4814+++ b/toolkit/components/places/nsNavHistoryResult.cpp
4815@@ -83,18 +83,17 @@
4816 // What we want is: NS_INTERFACE_MAP_ENTRY(self) for static IID accessors,
4817 // but some of our classes (like nsNavHistoryResult) have an ambiguous base
4818 // class of nsISupports which prevents this from working (the default macro
4819 // converts it to nsISupports, then addrefs it, then returns it). Therefore, we
4820 // expand the macro here and change it so that it works. Yuck.
4821 #define NS_INTERFACE_MAP_STATIC_AMBIGUOUS(_class) \
4822 if (aIID.Equals(NS_GET_IID(_class))) { \
4823 NS_ADDREF(this); \
4824- *aInstancePtr = this; \
4825- return NS_OK; \
4826+ return this; \
4827 } else
4828
4829 // Number of changes to handle separately in a batch. If more changes are
4830 // requested the node will switch to full refresh mode.
4831 #define MAX_BATCH_CHANGES_BEFORE_REFRESH 5
4832
4833 // Emulate string comparison (used for sorting) for PRTime and int.
4834 inline PRInt32 ComparePRTime(PRTime a, PRTime b)
4835@@ -4841,18 +4840,19 @@ nsNavHistoryResult::SetSuppressNotificat
4836 NS_IMETHODIMP
4837 nsNavHistoryResult::GetRoot(nsINavHistoryContainerResultNode** aRoot)
4838 {
4839 if (!mRootNode) {
4840 NS_NOTREACHED("Root is null");
4841 *aRoot = nsnull;
4842 return NS_ERROR_FAILURE;
4843 }
4844- return mRootNode->QueryInterface(NS_GET_IID(nsINavHistoryContainerResultNode),
4845- reinterpret_cast<void**>(aRoot));
4846+ *aRoot = static_cast<nsINavHistoryContainerResultNode*>
4847+ (mRootNode->QueryInterfaceFast(NS_GET_IID(nsINavHistoryContainerResultNode)));
4848+ return (*aRoot) ? NS_OK : NS_ERROR_NO_INTERFACE;
4849 }
4850
4851
4852 void
4853 nsNavHistoryResult::requestRefresh(nsNavHistoryContainerResultNode* aContainer)
4854 {
4855 // Don't add twice the same container.
4856 if (mRefreshParticipants.IndexOf(aContainer) == mRefreshParticipants.NoIndex)
4857diff --git a/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp b/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp
4858--- a/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp
4859+++ b/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp
4860@@ -574,17 +574,18 @@ nsUrlClassifierStreamUpdater::NotifySSLE
4861 }
4862
4863 ///////////////////////////////////////////////////////////////////////////////
4864 // nsIInterfaceRequestor implementation
4865
4866 NS_IMETHODIMP
4867 nsUrlClassifierStreamUpdater::GetInterface(const nsIID & eventSinkIID, void* *_retval)
4868 {
4869- return QueryInterface(eventSinkIID, _retval);
4870+ *_retval = QueryInterfaceFast(eventSinkIID);
4871+ return (*_retval) ? NS_OK : NS_ERROR_NO_INTERFACE;
4872 }
4873
4874
4875 ///////////////////////////////////////////////////////////////////////////////
4876 // nsITimerCallback implementation
4877 NS_IMETHODIMP
4878 nsUrlClassifierStreamUpdater::Notify(nsITimer *timer)
4879 {
4880diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp
4881--- a/toolkit/xre/nsAppRunner.cpp
4882+++ b/toolkit/xre/nsAppRunner.cpp
4883@@ -1011,18 +1011,19 @@ nsXULAppInfo::SetSubmitReports(PRBool aE
4884 #endif
4885
4886 static const nsXULAppInfo kAppInfo;
4887 static nsresult AppInfoConstructor(nsISupports* aOuter,
4888 REFNSIID aIID, void **aResult)
4889 {
4890 NS_ENSURE_NO_AGGREGATION(aOuter);
4891
4892- return const_cast<nsXULAppInfo*>(&kAppInfo)->
4893- QueryInterface(aIID, aResult);
4894+ *aResult = const_cast<nsXULAppInfo*>(&kAppInfo)->
4895+ QueryInterfaceFast(aIID);
4896+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
4897 }
4898
4899 PRBool gLogConsoleErrors
4900 #ifdef DEBUG
4901 = PR_TRUE;
4902 #else
4903 = PR_FALSE;
4904 #endif
4905diff --git a/toolkit/xre/nsXREDirProvider.h b/toolkit/xre/nsXREDirProvider.h
4906--- a/toolkit/xre/nsXREDirProvider.h
4907+++ b/toolkit/xre/nsXREDirProvider.h
4908@@ -46,19 +46,17 @@
4909 #include "nsCOMPtr.h"
4910 #include "nsCOMArray.h"
4911
4912 class nsXREDirProvider : public nsIDirectoryServiceProvider2,
4913 public nsIProfileStartup
4914 {
4915 public:
4916 // we use a custom isupports implementation (no refcount)
4917- NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
4918- NS_IMETHOD_(nsrefcnt) AddRef(void);
4919- NS_IMETHOD_(nsrefcnt) Release(void);
4920+ NS_DECL_ISUPPORTS
4921
4922 NS_DECL_NSIDIRECTORYSERVICEPROVIDER
4923 NS_DECL_NSIDIRECTORYSERVICEPROVIDER2
4924 NS_DECL_NSIPROFILESTARTUP
4925
4926 nsXREDirProvider();
4927
4928 // if aXULAppDir is null, use gArgv[0]
4929diff --git a/uriloader/base/nsDocLoader.cpp b/uriloader/base/nsDocLoader.cpp
4930--- a/uriloader/base/nsDocLoader.cpp
4931+++ b/uriloader/base/nsDocLoader.cpp
4932@@ -297,17 +297,18 @@ NS_IMETHODIMP nsDocLoader::GetInterface(
4933
4934 NS_ENSURE_ARG_POINTER(aSink);
4935
4936 if(aIID.Equals(NS_GET_IID(nsILoadGroup))) {
4937 *aSink = mLoadGroup;
4938 NS_IF_ADDREF((nsISupports*)*aSink);
4939 rv = NS_OK;
4940 } else {
4941- rv = QueryInterface(aIID, aSink);
4942+ *aSink = QueryInterfaceFast(aIID);
4943+ rv = (*aSink) ? NS_OK : NS_ERROR_NO_INTERFACE;
4944 }
4945
4946 return rv;
4947 }
4948
4949 /* static */
4950 already_AddRefed<nsDocLoader>
4951 nsDocLoader::GetAsDocLoader(nsISupports* aSupports)
4952diff --git a/view/src/nsView.cpp b/view/src/nsView.cpp
4953--- a/view/src/nsView.cpp
4954+++ b/view/src/nsView.cpp
4955@@ -75,42 +75,35 @@ class ViewWrapper : public nsIInterfaceR
4956 NS_DEFINE_STATIC_IID_ACCESSOR(ViewWrapper, VIEW_WRAPPER_IID)
4957
4958 NS_IMPL_ADDREF(ViewWrapper)
4959 NS_IMPL_RELEASE(ViewWrapper)
4960 #ifndef DEBUG
4961 NS_IMPL_QUERY_INTERFACE2(ViewWrapper, ViewWrapper, nsIInterfaceRequestor)
4962
4963 #else
4964-NS_IMETHODIMP ViewWrapper::QueryInterface(REFNSIID aIID, void** aInstancePtr)
4965+NS_IMETHODIMP_(void*) ViewWrapper::QueryInterfaceFast(REFNSIID aIID)
4966 {
4967- NS_ENSURE_ARG_POINTER(aInstancePtr);
4968-
4969 NS_ASSERTION(!aIID.Equals(NS_GET_IID(nsIView)),
4970 "Someone expects a viewwrapper to be a view!");
4971-
4972- *aInstancePtr = nsnull;
4973-
4974+
4975 if (aIID.Equals(NS_GET_IID(nsISupports))) {
4976- *aInstancePtr = static_cast<nsISupports*>(this);
4977+ AddRef();
4978+ return static_cast<nsISupports*>(this);
4979 }
4980 else if (aIID.Equals(NS_GET_IID(ViewWrapper))) {
4981- *aInstancePtr = this;
4982+ AddRef();
4983+ return this;
4984 }
4985 else if (aIID.Equals(NS_GET_IID(nsIInterfaceRequestor))) {
4986- *aInstancePtr = this;
4987+ AddRef();
4988+ return this;
4989 }
4990
4991-
4992- if (*aInstancePtr) {
4993- AddRef();
4994- return NS_OK;
4995- }
4996-
4997- return NS_NOINTERFACE;
4998+ return nsnull;
4999 }
5000 #endif
5001
5002 NS_IMETHODIMP ViewWrapper::GetInterface(REFNSIID aIID, void** aInstancePtr)
5003 {
5004 if (aIID.Equals(NS_GET_IID(nsIView))) {
5005 *aInstancePtr = mView;
5006 return NS_OK;
5007@@ -298,33 +291,26 @@ void nsView::DestroyWidget()
5008 mWindow->SetClientData(nsnull);
5009 mWindow->Destroy();
5010 }
5011
5012 NS_RELEASE(mWindow);
5013 }
5014 }
5015
5016-nsresult nsView::QueryInterface(const nsIID& aIID, void** aInstancePtr)
5017+NS_IMETHODIMP_(void*) nsView::QueryInterfaceFast(const nsIID& aIID)
5018 {
5019- if (nsnull == aInstancePtr) {
5020- return NS_ERROR_NULL_POINTER;
5021+ NS_ASSERTION(!aIID.Equals(NS_GET_IID(nsISupports)),
5022+ "Someone expects views to be ISupports-derived!");
5023+
5024+ if (aIID.Equals(NS_GET_IID(nsIView))) {
5025+ return (void*)(nsIView*)this;
5026 }
5027
5028- NS_ASSERTION(!aIID.Equals(NS_GET_IID(nsISupports)),
5029- "Someone expects views to be ISupports-derived!");
5030-
5031- *aInstancePtr = nsnull;
5032-
5033- if (aIID.Equals(NS_GET_IID(nsIView))) {
5034- *aInstancePtr = (void*)(nsIView*)this;
5035- return NS_OK;
5036- }
5037-
5038- return NS_NOINTERFACE;
5039+ return nsnull;
5040 }
5041
5042 nsIView* nsIView::GetViewFor(nsIWidget* aWidget)
5043 {
5044 NS_PRECONDITION(nsnull != aWidget, "null widget ptr");
5045
5046 ViewWrapper* wrapper = GetWrapperFor(aWidget);
5047
5048diff --git a/view/src/nsView.h b/view/src/nsView.h
5049--- a/view/src/nsView.h
5050+++ b/view/src/nsView.h
5051@@ -54,17 +54,17 @@ class nsViewManager;
5052 class nsView : public nsIView
5053 {
5054 public:
5055 nsView(nsViewManager* aViewManager = nsnull,
5056 nsViewVisibility aVisibility = nsViewVisibility_kShow);
5057
5058 NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
5059
5060- NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr);
5061+ NS_IMETHOD_(void*) QueryInterfaceFast(REFNSIID aIID);
5062
5063 /**
5064 * Called to indicate that the position of the view has been changed.
5065 * The specified coordinates are in the parent view's coordinate space.
5066 * @param x new x position
5067 * @param y new y position
5068 */
5069 virtual void SetPosition(nscoord aX, nscoord aY);
5070diff --git a/widget/src/gtk2/nsWidgetFactory.cpp b/widget/src/gtk2/nsWidgetFactory.cpp
5071--- a/widget/src/gtk2/nsWidgetFactory.cpp
5072+++ b/widget/src/gtk2/nsWidgetFactory.cpp
5073@@ -126,20 +126,20 @@ nsNativeThemeGTKConstructor(nsISupports
5074 }
5075
5076 inst = new nsNativeThemeGTK();
5077 if (NULL == inst) {
5078 rv = NS_ERROR_OUT_OF_MEMORY;
5079 return rv;
5080 }
5081 NS_ADDREF(inst);
5082- rv = inst->QueryInterface(aIID, aResult);
5083+ *aResult = inst->QueryInterfaceFast(aIID);
5084 NS_RELEASE(inst);
5085
5086- return rv;
5087+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
5088 }
5089 #endif
5090
5091 #if defined(MOZ_X11)
5092 NS_GENERIC_FACTORY_CONSTRUCTOR(nsIdleServiceGTK)
5093 namespace mozilla {
5094 namespace widget {
5095 // This constructor should really be shared with all platforms.
5096@@ -199,20 +199,20 @@ nsNativeKeyBindingsConstructor(nsISuppor
5097
5098 inst = new nsNativeKeyBindings();
5099 if (NULL == inst) {
5100 rv = NS_ERROR_OUT_OF_MEMORY;
5101 return rv;
5102 }
5103 NS_ADDREF(inst);
5104 inst->Init(aKeyBindingsType);
5105- rv = inst->QueryInterface(aIID, aResult);
5106+ *aResult = inst->QueryInterfaceFast(aIID);
5107 NS_RELEASE(inst);
5108
5109- return rv;
5110+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
5111 }
5112
5113 static nsresult
5114 nsNativeKeyBindingsInputConstructor(nsISupports *aOuter, REFNSIID aIID,
5115 void **aResult)
5116 {
5117 return nsNativeKeyBindingsConstructor(aOuter, aIID, aResult,
5118 eKeyBindings_Input);
5119diff --git a/widget/src/windows/nsNativeThemeWin.cpp b/widget/src/windows/nsNativeThemeWin.cpp
5120--- a/widget/src/windows/nsNativeThemeWin.cpp
5121+++ b/widget/src/windows/nsNativeThemeWin.cpp
5122@@ -3736,10 +3736,11 @@ nsresult NS_NewNativeTheme(nsISupports *
5123 return NS_ERROR_NO_INTERFACE;
5124
5125 if (aOuter)
5126 return NS_ERROR_NO_AGGREGATION;
5127
5128 nsNativeThemeWin* theme = new nsNativeThemeWin();
5129 if (!theme)
5130 return NS_ERROR_OUT_OF_MEMORY;
5131- return theme->QueryInterface(aIID, aResult);
5132+ *aResult = theme->QueryInterfaceFast(aIID);
5133+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
5134 }
5135diff --git a/widget/src/windows/nsPrintSettingsWin.cpp b/widget/src/windows/nsPrintSettingsWin.cpp
5136--- a/widget/src/windows/nsPrintSettingsWin.cpp
5137+++ b/widget/src/windows/nsPrintSettingsWin.cpp
5138@@ -146,17 +146,19 @@ NS_IMETHODIMP nsPrintSettingsWin::SetDev
5139 return NS_OK;
5140 }
5141
5142 //-------------------------------------------
5143 nsresult
5144 nsPrintSettingsWin::_Clone(nsIPrintSettings **_retval)
5145 {
5146 nsPrintSettingsWin* printSettings = new nsPrintSettingsWin(*this);
5147- return printSettings->QueryInterface(NS_GET_IID(nsIPrintSettings), (void**)_retval); // ref counts
5148+ *_retval = static_cast<nsIPrintSettings*>
5149+ (printSettings->QueryInterfaceFast(NS_GET_IID(nsIPrintSettings)));
5150+ return (*_retval) ? NS_OK : NS_ERROR_NO_INTERFACE;
5151 }
5152
5153 //-------------------------------------------
5154 nsPrintSettingsWin& nsPrintSettingsWin::operator=(const nsPrintSettingsWin& rhs)
5155 {
5156 if (this == &rhs) {
5157 return *this;
5158 }
5159diff --git a/widget/src/xpwidgets/nsAppShellSingleton.h b/widget/src/xpwidgets/nsAppShellSingleton.h
5160--- a/widget/src/xpwidgets/nsAppShellSingleton.h
5161+++ b/widget/src/xpwidgets/nsAppShellSingleton.h
5162@@ -87,12 +87,13 @@ nsAppShellShutdown()
5163 }
5164
5165 static nsresult
5166 nsAppShellConstructor(nsISupports *outer, const nsIID &iid, void **result)
5167 {
5168 NS_ENSURE_TRUE(!outer, NS_ERROR_NO_AGGREGATION);
5169 NS_ENSURE_TRUE(sAppShell, NS_ERROR_NOT_INITIALIZED);
5170
5171- return sAppShell->QueryInterface(iid, result);
5172+ *result = sAppShell->QueryInterfaceFast(iid);
5173+ return (*result) ? NS_OK : NS_ERROR_NO_INTERFACE;
5174 }
5175
5176 #endif // nsAppShellSingleton_h__
5177diff --git a/xpcom/base/nsAgg.h b/xpcom/base/nsAgg.h
5178--- a/xpcom/base/nsAgg.h
5179+++ b/xpcom/base/nsAgg.h
5180@@ -72,25 +72,25 @@ public:
5181 * Returns PR_TRUE if this object is part of an aggregated object. \
5182 */ \
5183 PRBool IsPartOfAggregated(void) { return fOuter != InnerObject(); } \
5184 \
5185 private: \
5186 \
5187 /* You must implement this operation instead of the nsISupports */ \
5188 /* methods. */ \
5189- nsresult \
5190- AggregatedQueryInterface(const nsIID& aIID, void** aInstancePtr); \
5191+ void* \
5192+ AggregatedQueryInterface(const nsIID& aIID); \
5193 \
5194 class Internal : public nsISupports { \
5195 public: \
5196 \
5197 Internal() {} \
5198 \
5199- NS_IMETHOD QueryInterface(const nsIID& aIID, void** aInstancePtr); \
5200+ NS_IMETHOD_(void*) QueryInterfaceFast(const nsIID& aIID); \
5201 NS_IMETHOD_(nsrefcnt) AddRef(void); \
5202 NS_IMETHOD_(nsrefcnt) Release(void); \
5203 \
5204 NS_DECL_OWNINGTHREAD \
5205 }; \
5206 \
5207 friend class Internal; \
5208 \
5209@@ -190,39 +190,39 @@ _class::Internal::Release(void)
5210 agg->mRefCnt.stabilizeForDeletion(this); \
5211 delete agg; \
5212 return 0; \
5213 } \
5214 return count; \
5215 }
5216
5217 #define NS_IMPL_AGGREGATED_HELPER(_class) \
5218-NS_IMETHODIMP \
5219-_class::QueryInterface(const nsIID& aIID, void** aInstancePtr) \
5220+NS_IMETHODIMP_(void*) \
5221+_class::QueryInterfaceFast(const nsIID& aIID) \
5222 { \
5223- return fOuter->QueryInterface(aIID, aInstancePtr); \
5224+ return fOuter->QueryInterfaceFast(aIID); \
5225 } \
5226 \
5227 NS_IMETHODIMP_(nsrefcnt) \
5228 _class::AddRef(void) \
5229 { \
5230 return fOuter->AddRef(); \
5231 } \
5232 \
5233 NS_IMETHODIMP_(nsrefcnt) \
5234 _class::Release(void) \
5235 { \
5236 return fOuter->Release(); \
5237 } \
5238 \
5239-NS_IMETHODIMP \
5240-_class::Internal::QueryInterface(const nsIID& aIID, void** aInstancePtr) \
5241+NS_IMETHODIMP_(void*) \
5242+_class::Internal::QueryInterfaceFast(const nsIID& aIID) \
5243 { \
5244 _class* agg = (_class*)((char*)(this) - offsetof(_class, fAggregated)); \
5245- return agg->AggregatedQueryInterface(aIID, aInstancePtr); \
5246+ return agg->AggregatedQueryInterface(aIID); \
5247 } \
5248
5249 /**
5250 * To make aggregated objects participate in cycle collection we need to enable
5251 * the outer object (aggregator) to traverse/unlink the objects held by the
5252 * inner object (the aggregatee). We can't just make the inner object QI'able to
5253 * NS_CYCLECOLLECTIONPARTICIPANT_IID, we don't want to return the inner object's
5254 * nsCycleCollectionParticipant for the outer object (which will happen if the
5255@@ -274,23 +274,19 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsAggregat
5256 #define NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION_AGGREGATED(_class) \
5257 NS_IMPL_QUERY_CYCLE_COLLECTION(_class)
5258
5259 #define NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION_AGGREGATED(_class) \
5260 NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION_AGGREGATED(_class) \
5261 NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION_ISUPPORTS(_class)
5262
5263 #define NS_IMPL_AGGREGATED_QUERY_HEAD(_class) \
5264-nsresult \
5265-_class::AggregatedQueryInterface(REFNSIID aIID, void** aInstancePtr) \
5266+void* \
5267+_class::AggregatedQueryInterface(REFNSIID aIID) \
5268 { \
5269- NS_ASSERTION(aInstancePtr, \
5270- "AggregatedQueryInterface requires a non-NULL result ptr!"); \
5271- if ( !aInstancePtr ) \
5272- return NS_ERROR_NULL_POINTER; \
5273 nsISupports* foundInterface; \
5274 if ( aIID.Equals(NS_GET_IID(nsISupports)) ) \
5275 foundInterface = InnerObject(); \
5276 else
5277
5278 #define NS_IMPL_AGGREGATED_QUERY_CYCLE_COLLECTION(_class) \
5279 if (aIID.Equals(IsPartOfAggregated() ? \
5280 NS_GET_IID(nsCycleCollectionParticipant) : \
5281diff --git a/xpcom/base/nsAutoPtr.h b/xpcom/base/nsAutoPtr.h
5282--- a/xpcom/base/nsAutoPtr.h
5283+++ b/xpcom/base/nsAutoPtr.h
5284@@ -935,19 +935,17 @@ class nsRefPtr
5285 nsRefPtr( const already_AddRefed<I>& aSmartPtr )
5286 : mRawPtr(aSmartPtr.mRawPtr)
5287 // construct from |dont_AddRef(expr)|
5288 {
5289 }
5290
5291 nsRefPtr( const nsCOMPtr_helper& helper )
5292 {
5293- void* newRawPtr;
5294- if (NS_FAILED(helper(NS_GET_TEMPLATE_IID(T), &newRawPtr)))
5295- newRawPtr = 0;
5296+ void* newRawPtr = helper(NS_GET_TEMPLATE_IID(T));
5297 mRawPtr = static_cast<T*>(newRawPtr);
5298 }
5299
5300 // Assignment operators
5301
5302 nsRefPtr<T>&
5303 operator=( const nsRefPtr<T>& rhs )
5304 // copy assignment operator
5305@@ -971,19 +969,17 @@ class nsRefPtr
5306 {
5307 assign_assuming_AddRef(rhs.mRawPtr);
5308 return *this;
5309 }
5310
5311 nsRefPtr<T>&
5312 operator=( const nsCOMPtr_helper& helper )
5313 {
5314- void* newRawPtr;
5315- if (NS_FAILED(helper(NS_GET_TEMPLATE_IID(T), &newRawPtr)))
5316- newRawPtr = 0;
5317+ void* newRawPtr = helper(NS_GET_TEMPLATE_IID(T));
5318 assign_assuming_AddRef(static_cast<T*>(newRawPtr));
5319 return *this;
5320 }
5321
5322 // Other pointer operators
5323
5324 void
5325 swap( nsRefPtr<T>& rhs )
5326@@ -1356,38 +1352,35 @@ CallQueryInterface( nsRefPtr<SourceType>
5327
5328 template<class T>
5329 class nsQueryObject : public nsCOMPtr_helper
5330 {
5331 public:
5332 nsQueryObject(T* aRawPtr)
5333 : mRawPtr(aRawPtr) {}
5334
5335- virtual nsresult NS_FASTCALL operator()( const nsIID& aIID, void** aResult ) const {
5336- nsresult status = mRawPtr ? mRawPtr->QueryInterface(aIID, aResult)
5337- : NS_ERROR_NULL_POINTER;
5338- return status;
5339+ virtual void* NS_FASTCALL operator()( const nsIID& aIID ) const {
5340+ return mRawPtr ? mRawPtr->QueryInterfaceFast(aIID) : nsnull;
5341 }
5342 private:
5343 T* mRawPtr;
5344 };
5345
5346 template<class T>
5347 class nsQueryObjectWithError : public nsCOMPtr_helper
5348 {
5349 public:
5350 nsQueryObjectWithError(T* aRawPtr, nsresult* aErrorPtr)
5351 : mRawPtr(aRawPtr), mErrorPtr(aErrorPtr) {}
5352
5353- virtual nsresult NS_FASTCALL operator()( const nsIID& aIID, void** aResult ) const {
5354- nsresult status = mRawPtr ? mRawPtr->QueryInterface(aIID, aResult)
5355- : NS_ERROR_NULL_POINTER;
5356+ virtual void* NS_FASTCALL operator()( const nsIID& aIID ) const {
5357+ void* result = mRawPtr ? mRawPtr->QueryInterfaceFast(aIID) : nsnull;
5358 if (mErrorPtr)
5359- *mErrorPtr = status;
5360- return status;
5361+ *mErrorPtr = result ? NS_OK : NS_ERROR_NO_INTERFACE;
5362+ return result;
5363 }
5364 private:
5365 T* mRawPtr;
5366 nsresult* mErrorPtr;
5367 };
5368
5369 template<class T>
5370 inline
5371diff --git a/xpcom/base/nsISupports.idl b/xpcom/base/nsISupports.idl
5372--- a/xpcom/base/nsISupports.idl
5373+++ b/xpcom/base/nsISupports.idl
5374@@ -49,17 +49,17 @@
5375
5376 %{C++
5377 /*
5378 * Start commenting out the C++ versions of the below in the output header
5379 */
5380 #if 0
5381 %}
5382
5383-[scriptable, uuid(00000000-0000-0000-c000-000000000046)]
5384+[scriptable, uuid(e8b6284a-5d69-48d7-a975-38cf7ba6d81b)]
5385 interface nsISupports {
5386 void QueryInterface(in nsIIDRef uuid,
5387 [iid_is(uuid),retval] out nsQIResult result);
5388 [noscript, notxpcom] nsrefcnt AddRef();
5389 [noscript, notxpcom] nsrefcnt Release();
5390 };
5391
5392 %{C++
5393diff --git a/xpcom/base/nsISupportsBase.h b/xpcom/base/nsISupportsBase.h
5394--- a/xpcom/base/nsISupportsBase.h
5395+++ b/xpcom/base/nsISupportsBase.h
5396@@ -39,56 +39,55 @@
5397 #ifndef nscore_h___
5398 #include "nscore.h"
5399 #endif
5400
5401 #ifndef nsID_h__
5402 #include "nsID.h"
5403 #endif
5404
5405+#ifndef nsDebug_h___
5406+#include "nsDebug.h"
5407+#endif
5408+
5409
5410 /*@{*/
5411 /**
5412 * IID for the nsISupports interface
5413- * {00000000-0000-0000-c000-000000000046}
5414+ * {e8b6284a-5d69-48d7-a975-38cf7ba6d81b}
5415 *
5416- * To maintain binary compatibility with COM's IUnknown, we define the IID
5417- * of nsISupports to be the same as that of COM's IUnknown.
5418+ * Note that nsISupports used to be binary compatible with COM's nsIUnknown,
5419+ * but that is not the case any more.
5420 */
5421 #define NS_ISUPPORTS_IID \
5422- { 0x00000000, 0x0000, 0x0000, \
5423- {0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46} }
5424+ { 0xe8b6284a, 0x5d69, 0x48d7, \
5425+ {0xa9, 0x75, 0x38, 0xcf, 0x7b, 0xa6, 0xd8, 0x1b} }
5426
5427 /**
5428 * Basic component object model interface. Objects which implement
5429 * this interface support runtime interface discovery (QueryInterface)
5430- * and a reference counted memory model (AddRef/Release). This is
5431- * modelled after the win32 IUnknown API.
5432+ * and a reference counted memory model (AddRef/Release).
5433 */
5434 class NS_NO_VTABLE nsISupports {
5435 public:
5436
5437 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISUPPORTS_IID)
5438
5439 /**
5440 * @name Methods
5441 */
5442
5443 //@{
5444 /**
5445 * A run time mechanism for interface discovery.
5446 * @param aIID [in] A requested interface IID
5447- * @param aInstancePtr [out] A pointer to an interface pointer to
5448- * receive the result.
5449- * @return <b>NS_OK</b> if the interface is supported by the associated
5450- * instance, <b>NS_NOINTERFACE</b> if it is not.
5451- *
5452- * aInstancePtr must not be null.
5453+ * @return an interface pointer if the interface is supported by the
5454+ * associated instance, <b>null</b> if it is not.
5455 */
5456- NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) = 0;
5457+ NS_IMETHOD_(void*) QueryInterfaceFast(REFNSIID aIID) = 0;
5458 /**
5459 * Increases the reference count for this interface.
5460 * The associated instance will not be deleted unless
5461 * the reference count is returned to zero.
5462 *
5463 * @return The resulting reference count.
5464 */
5465 NS_IMETHOD_(nsrefcnt) AddRef(void) = 0;
5466@@ -97,16 +96,39 @@ public:
5467 * Decreases the reference count for this interface.
5468 * Generally, if the reference count returns to zero,
5469 * the associated instance is deleted.
5470 *
5471 * @return The resulting reference count.
5472 */
5473 NS_IMETHOD_(nsrefcnt) Release(void) = 0;
5474
5475+ /**
5476+ * A wrapper around QueryInterfaceFast, which simply calls it internally.
5477+ *
5478+ * This exists in order to provide backwards compatibility with the old
5479+ * QueryInterface method, and it will be removed in the future.
5480+ *
5481+ * @param aIID [in] A requested interface IID
5482+ * @param aInstancePtr [out] A pointer to an interface pointer to
5483+ * receive the result.
5484+ * @return <b>NS_OK</b> if the interface is supported by the associated
5485+ * instance, <b>NS_NOINTERFACE</b> if it is not.
5486+ *
5487+ * aInstancePtr must not be null.
5488+ */
5489+ nsresult QueryInterface(REFNSIID aIID, void** aInstancePtr)
5490+ {
5491+ NS_ASSERTION(aInstancePtr, "QueryInterface requires a non-NULL destination!");
5492+
5493+ *aInstancePtr = QueryInterfaceFast(aIID);
5494+
5495+ return (*aInstancePtr) ? NS_OK : NS_ERROR_NO_INTERFACE;
5496+ }
5497+
5498 //@}
5499 };
5500
5501 NS_DEFINE_STATIC_IID_ACCESSOR(nsISupports, NS_ISUPPORTS_IID)
5502
5503 /*@}*/
5504
5505 #endif
5506diff --git a/xpcom/base/nsMemoryImpl.h b/xpcom/base/nsMemoryImpl.h
5507--- a/xpcom/base/nsMemoryImpl.h
5508+++ b/xpcom/base/nsMemoryImpl.h
5509@@ -45,17 +45,17 @@
5510 // nsMemoryImpl is a static object. We can do this because it doesn't have
5511 // a constructor/destructor or any instance members. Please don't add
5512 // instance member variables, only static member variables.
5513
5514 class nsMemoryImpl : public nsIMemory
5515 {
5516 public:
5517 // We don't use the generic macros because we are a special static object
5518- NS_IMETHOD QueryInterface(REFNSIID aIID, void** aResult);
5519+ NS_IMETHOD_(void*) QueryInterfaceFast(REFNSIID aIID);
5520 NS_IMETHOD_(nsrefcnt) AddRef(void) { return 1; }
5521 NS_IMETHOD_(nsrefcnt) Release(void) { return 1; }
5522
5523 NS_DECL_NSIMEMORY
5524
5525 static nsresult Create(nsISupports* outer,
5526 const nsIID& aIID, void **aResult);
5527
5528diff --git a/xpcom/components/ModuleUtils.h b/xpcom/components/ModuleUtils.h
5529--- a/xpcom/components/ModuleUtils.h
5530+++ b/xpcom/components/ModuleUtils.h
5531@@ -57,20 +57,20 @@ _InstanceClass##Constructor(nsISupports
5532 } \
5533 \
5534 inst = new _InstanceClass(); \
5535 if (NULL == inst) { \
5536 rv = NS_ERROR_OUT_OF_MEMORY; \
5537 return rv; \
5538 } \
5539 NS_ADDREF(inst); \
5540- rv = inst->QueryInterface(aIID, aResult); \
5541+ *aResult = inst->QueryInterfaceFast(aIID); \
5542 NS_RELEASE(inst); \
5543 \
5544- return rv; \
5545+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE; \
5546 }
5547
5548 #define NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(_InstanceClass, _InitMethod) \
5549 static nsresult \
5550 _InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID, \
5551 void **aResult) \
5552 { \
5553 nsresult rv; \
5554@@ -86,21 +86,21 @@ _InstanceClass##Constructor(nsISupports
5555 inst = new _InstanceClass(); \
5556 if (NULL == inst) { \
5557 rv = NS_ERROR_OUT_OF_MEMORY; \
5558 return rv; \
5559 } \
5560 NS_ADDREF(inst); \
5561 rv = inst->_InitMethod(); \
5562 if(NS_SUCCEEDED(rv)) { \
5563- rv = inst->QueryInterface(aIID, aResult); \
5564+ *aResult = inst->QueryInterfaceFast(aIID); \
5565 } \
5566 NS_RELEASE(inst); \
5567 \
5568- return rv; \
5569+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE; \
5570 }
5571
5572 // 'Constructor' that uses an existing getter function that gets a singleton.
5573 // NOTE: assumes that getter does an AddRef - so additional AddRef is not done.
5574 #define NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(_InstanceClass, _GetterProc) \
5575 static nsresult \
5576 _InstanceClass##Constructor(nsISupports *aOuter, REFNSIID aIID, \
5577 void **aResult) \
5578@@ -116,20 +116,20 @@ _InstanceClass##Constructor(nsISupports
5579 } \
5580 \
5581 inst = already_AddRefed<_InstanceClass>(_GetterProc()).get(); \
5582 if (NULL == inst) { \
5583 rv = NS_ERROR_OUT_OF_MEMORY; \
5584 return rv; \
5585 } \
5586 /* NS_ADDREF(inst); */ \
5587- rv = inst->QueryInterface(aIID, aResult); \
5588+ *aResult = inst->QueryInterfaceFast(aIID); \
5589 NS_RELEASE(inst); \
5590 \
5591- return rv; \
5592+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE; \
5593 }
5594
5595 #ifndef MOZILLA_INTERNAL_API
5596
5597 #include "nsIModule.h"
5598 #include "nsISupportsUtils.h"
5599
5600 namespace mozilla {
5601diff --git a/xpcom/components/nsComponentManager.cpp b/xpcom/components/nsComponentManager.cpp
5602--- a/xpcom/components/nsComponentManager.cpp
5603+++ b/xpcom/components/nsComponentManager.cpp
5604@@ -172,22 +172,23 @@ NS_DEFINE_CID(kCategoryManagerCID, NS_CA
5605 #define COMPMGR_TIME_FUNCTION_CONTRACTID(cid) \
5606 NS_TIME_FUNCTION_MIN_FMT(5, "%s (line %d) (contractid: %s)", MOZ_FUNCTION_NAME, \
5607 __LINE__, (cid))
5608 #else
5609 #define COMPMGR_TIME_FUNCTION_CID(cid) do {} while (0)
5610 #define COMPMGR_TIME_FUNCTION_CONTRACTID(cid) do {} while (0)
5611 #endif
5612
5613-nsresult
5614-nsGetServiceFromCategory::operator()(const nsIID& aIID, void** aInstancePtr) const
5615+void*
5616+nsGetServiceFromCategory::operator()(const nsIID& aIID) const
5617 {
5618 nsresult rv;
5619 nsXPIDLCString value;
5620 nsCOMPtr<nsICategoryManager> catman;
5621+ void* instancePtr;
5622 nsComponentManagerImpl *compMgr = nsComponentManagerImpl::gComponentManager;
5623 if (!compMgr) {
5624 rv = NS_ERROR_NOT_INITIALIZED;
5625 goto error;
5626 }
5627
5628 if (!mCategory || !mEntry) {
5629 // when categories have defaults, use that for null mEntry
5630@@ -206,24 +207,24 @@ nsGetServiceFromCategory::operator()(con
5631 if (NS_FAILED(rv)) goto error;
5632 if (!value) {
5633 rv = NS_ERROR_SERVICE_NOT_AVAILABLE;
5634 goto error;
5635 }
5636
5637 rv = compMgr->
5638 nsComponentManagerImpl::GetServiceByContractID(value,
5639- aIID, aInstancePtr);
5640+ aIID, &instancePtr);
5641 if (NS_FAILED(rv)) {
5642 error:
5643- *aInstancePtr = 0;
5644+ instancePtr = 0;
5645 }
5646 if (mErrorPtr)
5647 *mErrorPtr = rv;
5648- return rv;
5649+ return instancePtr;
5650 }
5651
5652 ////////////////////////////////////////////////////////////////////////////////
5653 // Arena helper functions
5654 ////////////////////////////////////////////////////////////////////////////////
5655 char *
5656 ArenaStrndup(const char *s, PRUint32 len, PLArenaPool *arena)
5657 {
5658@@ -284,17 +285,18 @@ nsresult
5659 nsComponentManagerImpl::Create(nsISupports* aOuter, REFNSIID aIID, void** aResult)
5660 {
5661 if (aOuter)
5662 return NS_ERROR_NO_AGGREGATION;
5663
5664 if (!gComponentManager)
5665 return NS_ERROR_FAILURE;
5666
5667- return gComponentManager->QueryInterface(aIID, aResult);
5668+ *aResult = gComponentManager->QueryInterfaceFast(aIID);
5669+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
5670 }
5671
5672 nsComponentManagerImpl::nsComponentManagerImpl()
5673 : mMon("nsComponentManagerImpl.mMon")
5674 , mStatus(NOT_INITIALIZED)
5675 {
5676 }
5677
5678@@ -1041,17 +1043,18 @@ NS_IMPL_THREADSAFE_ISUPPORTS5(nsComponen
5679
5680
5681 nsresult
5682 nsComponentManagerImpl::GetInterface(const nsIID & uuid, void **result)
5683 {
5684 NS_WARNING("This isn't supported");
5685 // fall through to QI as anything QIable is a superset of what can be
5686 // got via the GetInterface()
5687- return QueryInterface(uuid, result);
5688+ *result = QueryInterfaceFast(uuid);
5689+ return (*result) ? NS_OK : NS_ERROR_NO_INTERFACE;
5690 }
5691
5692 nsFactoryEntry *
5693 nsComponentManagerImpl::GetFactoryEntry(const char *aContractID,
5694 PRUint32 aContractIDLen)
5695 {
5696 ReentrantMonitorAutoEnter mon(mMon);
5697 return mContractIDs.Get(nsDependentCString(aContractID, aContractIDLen));
5698diff --git a/xpcom/ds/nsICollection.idl b/xpcom/ds/nsICollection.idl
5699--- a/xpcom/ds/nsICollection.idl
5700+++ b/xpcom/ds/nsICollection.idl
5701@@ -69,17 +69,17 @@ class nsQueryElementAt : public nsCOMPtr
5702 nsQueryElementAt( nsICollection* aCollection, PRUint32 aIndex, nsresult* aErrorPtr )
5703 : mCollection(aCollection),
5704 mIndex(aIndex),
5705 mErrorPtr(aErrorPtr)
5706 {
5707 // nothing else to do here
5708 }
5709
5710- virtual nsresult NS_FASTCALL operator()( const nsIID& aIID, void** ) const;
5711+ virtual void* NS_FASTCALL operator()( const nsIID& aIID ) const;
5712
5713 private:
5714 nsICollection* mCollection;
5715 PRUint32 mIndex;
5716 nsresult* mErrorPtr;
5717 };
5718
5719 inline
5720diff --git a/xpcom/ds/nsINIParserImpl.cpp b/xpcom/ds/nsINIParserImpl.cpp
5721--- a/xpcom/ds/nsINIParserImpl.cpp
5722+++ b/xpcom/ds/nsINIParserImpl.cpp
5723@@ -83,17 +83,18 @@ nsINIParserFactory::CreateINIParser(nsIL
5724 NS_IMETHODIMP
5725 nsINIParserFactory::CreateInstance(nsISupports* aOuter,
5726 REFNSIID aIID,
5727 void **aResult)
5728 {
5729 NS_ENSURE_NO_AGGREGATION(aOuter);
5730
5731 // We are our own singleton.
5732- return QueryInterface(aIID, aResult);
5733+ *aResult = QueryInterfaceFast(aIID);
5734+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
5735 }
5736
5737 NS_IMETHODIMP
5738 nsINIParserFactory::LockFactory(PRBool aLock)
5739 {
5740 return NS_OK;
5741 }
5742
5743diff --git a/xpcom/ds/nsSupportsArray.cpp b/xpcom/ds/nsSupportsArray.cpp
5744--- a/xpcom/ds/nsSupportsArray.cpp
5745+++ b/xpcom/ds/nsSupportsArray.cpp
5746@@ -107,27 +107,28 @@ SupportsStats::~SupportsStats()
5747 printf("\t%d: %d\n",i,MaxElements[i]);
5748 }
5749 }
5750
5751 // Just so constructor/destructor get called
5752 SupportsStats gSupportsStats;
5753 #endif
5754
5755-nsresult
5756-nsQueryElementAt::operator()( const nsIID& aIID, void** aResult ) const
5757+void*
5758+nsQueryElementAt::operator()( const nsIID& aIID ) const
5759 {
5760+ void* result = nsnull;
5761 nsresult status = mCollection
5762- ? mCollection->QueryElementAt(mIndex, aIID, aResult)
5763+ ? mCollection->QueryElementAt(mIndex, aIID, &result)
5764 : NS_ERROR_NULL_POINTER;
5765
5766 if ( mErrorPtr )
5767 *mErrorPtr = status;
5768
5769- return status;
5770+ return result;
5771 }
5772
5773 static const PRInt32 kGrowArrayBy = 8;
5774 static const PRInt32 kLinearThreshold = 16 * sizeof(nsISupports *);
5775
5776 nsSupportsArray::nsSupportsArray()
5777 {
5778 mArray = mAutoArray;
5779diff --git a/xpcom/glue/nsArrayUtils.cpp b/xpcom/glue/nsArrayUtils.cpp
5780--- a/xpcom/glue/nsArrayUtils.cpp
5781+++ b/xpcom/glue/nsArrayUtils.cpp
5782@@ -36,20 +36,21 @@
5783 *
5784 * ***** END LICENSE BLOCK ***** */
5785
5786 #include "nsArrayUtils.h"
5787
5788 //
5789 // do_QueryElementAt helper stuff
5790 //
5791-nsresult
5792-nsQueryArrayElementAt::operator()(const nsIID& aIID, void** aResult) const
5793+void*
5794+nsQueryArrayElementAt::operator()(const nsIID& aIID) const
5795 {
5796+ void* result = nsnull;
5797 nsresult status = mArray
5798- ? mArray->QueryElementAt(mIndex, aIID, aResult)
5799+ ? mArray->QueryElementAt(mIndex, aIID, &result)
5800 : NS_ERROR_NULL_POINTER;
5801
5802 if (mErrorPtr)
5803 *mErrorPtr = status;
5804
5805- return status;
5806+ return result;
5807 }
5808diff --git a/xpcom/glue/nsArrayUtils.h b/xpcom/glue/nsArrayUtils.h
5809--- a/xpcom/glue/nsArrayUtils.h
5810+++ b/xpcom/glue/nsArrayUtils.h
5811@@ -50,17 +50,17 @@ class NS_COM_GLUE nsQueryArrayElementAt
5812 nsresult* aErrorPtr)
5813 : mArray(aArray),
5814 mIndex(aIndex),
5815 mErrorPtr(aErrorPtr)
5816 {
5817 // nothing else to do here
5818 }
5819
5820- virtual nsresult NS_FASTCALL operator()(const nsIID& aIID, void**) const;
5821+ virtual void* NS_FASTCALL operator()(const nsIID& aIID) const;
5822
5823 private:
5824 nsIArray* mArray;
5825 PRUint32 mIndex;
5826 nsresult* mErrorPtr;
5827 };
5828
5829 inline
5830diff --git a/xpcom/glue/nsCOMPtr.cpp b/xpcom/glue/nsCOMPtr.cpp
5831--- a/xpcom/glue/nsCOMPtr.cpp
5832+++ b/xpcom/glue/nsCOMPtr.cpp
5833@@ -33,50 +33,50 @@
5834 * and other provisions required by the GPL or the LGPL. If you do not delete
5835 * the provisions above, a recipient may use your version of this file under
5836 * the terms of any one of the MPL, the GPL or the LGPL.
5837 *
5838 * ***** END LICENSE BLOCK ***** */
5839
5840 #include "nsCOMPtr.h"
5841
5842-nsresult
5843-nsQueryInterface::operator()( const nsIID& aIID, void** answer ) const
5844+void*
5845+nsQueryInterface::operator()( const nsIID& aIID ) const
5846+ {
5847+ void* result = nsnull;
5848+ if ( mRawPtr )
5849+ {
5850+ result = mRawPtr->QueryInterfaceFast(aIID);
5851+#ifdef NSCAP_FEATURE_TEST_NONNULL_QUERY_SUCCEEDS
5852+ NS_ASSERTION(result, "interface not found---were you expecting that?");
5853+#endif
5854+ }
5855+
5856+ return result;
5857+ }
5858+
5859+void*
5860+nsQueryInterfaceWithError::operator()( const nsIID& aIID ) const
5861 {
5862 nsresult status;
5863+ void* result = nsnull;
5864 if ( mRawPtr )
5865 {
5866- status = mRawPtr->QueryInterface(aIID, answer);
5867+ result = mRawPtr->QueryInterfaceFast(aIID);
5868+ status = result ? NS_OK : NS_ERROR_NO_INTERFACE;
5869 #ifdef NSCAP_FEATURE_TEST_NONNULL_QUERY_SUCCEEDS
5870- NS_ASSERTION(NS_SUCCEEDED(status), "interface not found---were you expecting that?");
5871-#endif
5872- }
5873- else
5874- status = NS_ERROR_NULL_POINTER;
5875-
5876- return status;
5877- }
5878-
5879-nsresult
5880-nsQueryInterfaceWithError::operator()( const nsIID& aIID, void** answer ) const
5881- {
5882- nsresult status;
5883- if ( mRawPtr )
5884- {
5885- status = mRawPtr->QueryInterface(aIID, answer);
5886-#ifdef NSCAP_FEATURE_TEST_NONNULL_QUERY_SUCCEEDS
5887- NS_ASSERTION(NS_SUCCEEDED(status), "interface not found---were you expecting that?");
5888+ NS_ASSERTION(result, "interface not found---were you expecting that?");
5889 #endif
5890 }
5891 else
5892 status = NS_ERROR_NULL_POINTER;
5893
5894 if ( mErrorPtr )
5895 *mErrorPtr = status;
5896- return status;
5897+ return result;
5898 }
5899
5900 nsCOMPtr_base::~nsCOMPtr_base()
5901 {
5902 NSCAP_LOG_RELEASE(this, mRawPtr);
5903 if ( mRawPtr )
5904 NSCAP_RELEASE(this, mRawPtr);
5905 }
5906@@ -87,73 +87,59 @@ nsCOMPtr_base::assign_with_AddRef( nsISu
5907 if ( rawPtr )
5908 NSCAP_ADDREF(this, rawPtr);
5909 assign_assuming_AddRef(rawPtr);
5910 }
5911
5912 void
5913 nsCOMPtr_base::assign_from_qi( const nsQueryInterface qi, const nsIID& iid )
5914 {
5915- void* newRawPtr;
5916- if ( NS_FAILED( qi(iid, &newRawPtr) ) )
5917- newRawPtr = 0;
5918+ void* newRawPtr = qi(iid);
5919 assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr));
5920 }
5921
5922 void
5923 nsCOMPtr_base::assign_from_qi_with_error( const nsQueryInterfaceWithError& qi, const nsIID& iid )
5924 {
5925- void* newRawPtr;
5926- if ( NS_FAILED( qi(iid, &newRawPtr) ) )
5927- newRawPtr = 0;
5928+ void* newRawPtr = qi(iid);
5929 assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr));
5930 }
5931
5932 void
5933 nsCOMPtr_base::assign_from_gs_cid( const nsGetServiceByCID gs, const nsIID& iid )
5934 {
5935- void* newRawPtr;
5936- if ( NS_FAILED( gs(iid, &newRawPtr) ) )
5937- newRawPtr = 0;
5938+ void* newRawPtr = gs(iid);
5939 assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr));
5940 }
5941
5942 void
5943 nsCOMPtr_base::assign_from_gs_cid_with_error( const nsGetServiceByCIDWithError& gs, const nsIID& iid )
5944 {
5945- void* newRawPtr;
5946- if ( NS_FAILED( gs(iid, &newRawPtr) ) )
5947- newRawPtr = 0;
5948+ void* newRawPtr = gs(iid);
5949 assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr));
5950 }
5951
5952 void
5953 nsCOMPtr_base::assign_from_gs_contractid( const nsGetServiceByContractID gs, const nsIID& iid )
5954 {
5955- void* newRawPtr;
5956- if ( NS_FAILED( gs(iid, &newRawPtr) ) )
5957- newRawPtr = 0;
5958+ void* newRawPtr = gs(iid);
5959 assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr));
5960 }
5961
5962 void
5963 nsCOMPtr_base::assign_from_gs_contractid_with_error( const nsGetServiceByContractIDWithError& gs, const nsIID& iid )
5964 {
5965- void* newRawPtr;
5966- if ( NS_FAILED( gs(iid, &newRawPtr) ) )
5967- newRawPtr = 0;
5968+ void* newRawPtr = gs(iid);
5969 assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr));
5970 }
5971
5972 void
5973 nsCOMPtr_base::assign_from_helper( const nsCOMPtr_helper& helper, const nsIID& iid )
5974 {
5975- void* newRawPtr;
5976- if ( NS_FAILED( helper(iid, &newRawPtr) ) )
5977- newRawPtr = 0;
5978+ void* newRawPtr = helper(iid);
5979 assign_assuming_AddRef(static_cast<nsISupports*>(newRawPtr));
5980 }
5981
5982 void**
5983 nsCOMPtr_base::begin_assignment()
5984 {
5985 assign_assuming_AddRef(0);
5986 return reinterpret_cast<void**>(&mRawPtr);
5987diff --git a/xpcom/glue/nsCOMPtr.h b/xpcom/glue/nsCOMPtr.h
5988--- a/xpcom/glue/nsCOMPtr.h
5989+++ b/xpcom/glue/nsCOMPtr.h
5990@@ -259,17 +259,17 @@ class nsCOMPtr_helper
5991 - it matches the type requested with the supplied |nsIID| argument
5992 - its constructor provides an optional |nsresult*| that |operator()| can fill
5993 in with an error when it is executed
5994
5995 See |class nsGetInterface| for an example.
5996 */
5997 {
5998 public:
5999- virtual nsresult NS_FASTCALL operator()( const nsIID&, void** ) const = 0;
6000+ virtual void* NS_FASTCALL operator()( const nsIID& ) const = 0;
6001 };
6002
6003 /*
6004 |nsQueryInterface| could have been implemented as an |nsCOMPtr_helper| to
6005 avoid adding specialized machinery in |nsCOMPtr|, But |do_QueryInterface|
6006 is called often enough that the codesize savings are big enough to
6007 warrant the specialcasing.
6008 */
6009@@ -283,33 +283,33 @@ nsQueryInterface
6010 public:
6011 explicit
6012 nsQueryInterface( nsISupports* aRawPtr )
6013 : mRawPtr(aRawPtr)
6014 {
6015 // nothing else to do here
6016 }
6017
6018- nsresult NS_FASTCALL operator()( const nsIID& aIID, void** ) const;
6019+ void* NS_FASTCALL operator()( const nsIID& aIID ) const;
6020
6021 private:
6022 nsISupports* mRawPtr;
6023 };
6024
6025 class NS_COM_GLUE nsQueryInterfaceWithError
6026 {
6027 public:
6028 nsQueryInterfaceWithError( nsISupports* aRawPtr, nsresult* error )
6029 : mRawPtr(aRawPtr),
6030 mErrorPtr(error)
6031 {
6032 // nothing else to do here
6033 }
6034
6035- nsresult NS_FASTCALL operator()( const nsIID& aIID, void** ) const;
6036+ void* NS_FASTCALL operator()( const nsIID& aIID ) const;
6037
6038 private:
6039 nsISupports* mRawPtr;
6040 nsresult* mErrorPtr;
6041 };
6042
6043 inline
6044 nsQueryInterface
6045@@ -351,67 +351,67 @@ do_QueryInterface( already_AddRefed<T>&,
6046 class NS_COM_GLUE nsGetServiceByCID
6047 {
6048 public:
6049 explicit nsGetServiceByCID(const nsCID& aCID)
6050 : mCID(aCID)
6051 {
6052 // nothing else to do
6053 }
6054-
6055- nsresult NS_FASTCALL operator()( const nsIID&, void** ) const;
6056-
6057+
6058+ void* NS_FASTCALL operator()( const nsIID& ) const;
6059+
6060 private:
6061 const nsCID& mCID;
6062 };
6063
6064 class NS_COM_GLUE nsGetServiceByCIDWithError
6065 {
6066 public:
6067 nsGetServiceByCIDWithError( const nsCID& aCID, nsresult* aErrorPtr )
6068 : mCID(aCID),
6069 mErrorPtr(aErrorPtr)
6070 {
6071 // nothing else to do
6072 }
6073-
6074- nsresult NS_FASTCALL operator()( const nsIID&, void** ) const;
6075-
6076+
6077+ void* NS_FASTCALL operator()( const nsIID& ) const;
6078+
6079 private:
6080 const nsCID& mCID;
6081 nsresult* mErrorPtr;
6082 };
6083
6084 class NS_COM_GLUE nsGetServiceByContractID
6085 {
6086 public:
6087 explicit nsGetServiceByContractID(const char* aContractID)
6088 : mContractID(aContractID)
6089 {
6090 // nothing else to do
6091 }
6092-
6093- nsresult NS_FASTCALL operator()( const nsIID&, void** ) const;
6094-
6095+
6096+ void* NS_FASTCALL operator()( const nsIID& ) const;
6097+
6098 private:
6099 const char* mContractID;
6100 };
6101
6102 class NS_COM_GLUE nsGetServiceByContractIDWithError
6103 {
6104 public:
6105 nsGetServiceByContractIDWithError(const char* aContractID, nsresult* aErrorPtr)
6106 : mContractID(aContractID),
6107 mErrorPtr(aErrorPtr)
6108 {
6109 // nothing else to do
6110 }
6111-
6112- nsresult NS_FASTCALL operator()( const nsIID&, void** ) const;
6113-
6114+
6115+ void* NS_FASTCALL operator()( const nsIID& ) const;
6116+
6117 private:
6118 const char* mContractID;
6119 nsresult* mErrorPtr;
6120 };
6121
6122 class
6123 nsCOMPtr_base
6124 /*
6125@@ -1163,79 +1163,65 @@ nsCOMPtr<T>::assign_with_AddRef( nsISupp
6126 NSCAP_ADDREF(this, rawPtr);
6127 assign_assuming_AddRef(reinterpret_cast<T*>(rawPtr));
6128 }
6129
6130 template <class T>
6131 void
6132 nsCOMPtr<T>::assign_from_qi( const nsQueryInterface qi, const nsIID& aIID )
6133 {
6134- void* newRawPtr;
6135- if ( NS_FAILED( qi(aIID, &newRawPtr) ) )
6136- newRawPtr = 0;
6137+ void* newRawPtr = qi(aIID);
6138 assign_assuming_AddRef(static_cast<T*>(newRawPtr));
6139 }
6140
6141 template <class T>
6142 void
6143 nsCOMPtr<T>::assign_from_qi_with_error( const nsQueryInterfaceWithError& qi, const nsIID& aIID )
6144 {
6145- void* newRawPtr;
6146- if ( NS_FAILED( qi(aIID, &newRawPtr) ) )
6147- newRawPtr = 0;
6148+ void* newRawPtr = qi(aIID);
6149 assign_assuming_AddRef(static_cast<T*>(newRawPtr));
6150 }
6151
6152 template <class T>
6153 void
6154 nsCOMPtr<T>::assign_from_gs_cid( const nsGetServiceByCID gs, const nsIID& aIID )
6155 {
6156- void* newRawPtr;
6157- if ( NS_FAILED( gs(aIID, &newRawPtr) ) )
6158- newRawPtr = 0;
6159+ void* newRawPtr = gs(aIID);
6160 assign_assuming_AddRef(static_cast<T*>(newRawPtr));
6161 }
6162
6163 template <class T>
6164 void
6165 nsCOMPtr<T>::assign_from_gs_cid_with_error( const nsGetServiceByCIDWithError& gs, const nsIID& aIID )
6166 {
6167- void* newRawPtr;
6168- if ( NS_FAILED( gs(aIID, &newRawPtr) ) )
6169- newRawPtr = 0;
6170+ void* newRawPtr = gs(aIID);
6171 assign_assuming_AddRef(static_cast<T*>(newRawPtr));
6172 }
6173
6174 template <class T>
6175 void
6176 nsCOMPtr<T>::assign_from_gs_contractid( const nsGetServiceByContractID gs, const nsIID& aIID )
6177 {
6178- void* newRawPtr;
6179- if ( NS_FAILED( gs(aIID, &newRawPtr) ) )
6180- newRawPtr = 0;
6181+ void* newRawPtr = gs(aIID);
6182 assign_assuming_AddRef(static_cast<T*>(newRawPtr));
6183 }
6184
6185 template <class T>
6186 void
6187 nsCOMPtr<T>::assign_from_gs_contractid_with_error( const nsGetServiceByContractIDWithError& gs, const nsIID& aIID )
6188 {
6189- void* newRawPtr;
6190- if ( NS_FAILED( gs(aIID, &newRawPtr) ) )
6191- newRawPtr = 0;
6192+ void* newRawPtr = gs(aIID);
6193 assign_assuming_AddRef(static_cast<T*>(newRawPtr));
6194 }
6195
6196 template <class T>
6197 void
6198 nsCOMPtr<T>::assign_from_helper( const nsCOMPtr_helper& helper, const nsIID& aIID )
6199 {
6200- void* newRawPtr;
6201- if ( NS_FAILED( helper(aIID, &newRawPtr) ) )
6202- newRawPtr = 0;
6203+ void* newRawPtr = helper(aIID);
6204 assign_assuming_AddRef(static_cast<T*>(newRawPtr));
6205 }
6206
6207 template <class T>
6208 void**
6209 nsCOMPtr<T>::begin_assignment()
6210 {
6211 assign_assuming_AddRef(0);
6212diff --git a/xpcom/glue/nsComponentManagerUtils.cpp b/xpcom/glue/nsComponentManagerUtils.cpp
6213--- a/xpcom/glue/nsComponentManagerUtils.cpp
6214+++ b/xpcom/glue/nsComponentManagerUtils.cpp
6215@@ -188,108 +188,99 @@ CallGetClassObject(const char *aContract
6216
6217 return compMgr->
6218 nsComponentManagerImpl::GetClassObjectByContractID(aContractID, aIID,
6219 aResult);
6220 }
6221
6222 #endif
6223
6224-nsresult
6225-nsCreateInstanceByCID::operator()( const nsIID& aIID, void** aInstancePtr ) const
6226+void*
6227+nsCreateInstanceByCID::operator()( const nsIID& aIID ) const
6228 {
6229- nsresult status = CallCreateInstance(mCID, mOuter, aIID, aInstancePtr);
6230- if ( NS_FAILED(status) )
6231- *aInstancePtr = 0;
6232+ void *instancePtr = nsnull;
6233+ nsresult status = CallCreateInstance(mCID, mOuter, aIID, &instancePtr);
6234 if ( mErrorPtr )
6235 *mErrorPtr = status;
6236- return status;
6237+ return instancePtr;
6238 }
6239
6240-nsresult
6241-nsCreateInstanceByContractID::operator()( const nsIID& aIID, void** aInstancePtr ) const
6242+void*
6243+nsCreateInstanceByContractID::operator()( const nsIID& aIID) const
6244 {
6245- nsresult status = CallCreateInstance(mContractID, mOuter, aIID, aInstancePtr);
6246- if (NS_FAILED(status))
6247- *aInstancePtr = 0;
6248+ void *instancePtr = nsnull;
6249+ nsresult status = CallCreateInstance(mContractID, mOuter, aIID, &instancePtr);
6250 if ( mErrorPtr )
6251 *mErrorPtr = status;
6252- return status;
6253+ return instancePtr;
6254 }
6255
6256-nsresult
6257-nsCreateInstanceFromFactory::operator()( const nsIID& aIID, void** aInstancePtr ) const
6258+void*
6259+nsCreateInstanceFromFactory::operator()( const nsIID& aIID) const
6260 {
6261- nsresult status = mFactory->CreateInstance(mOuter, aIID, aInstancePtr);
6262- if ( NS_FAILED(status) )
6263- *aInstancePtr = 0;
6264+ void *instancePtr = nsnull;
6265+ nsresult status = mFactory->CreateInstance(mOuter, aIID, &instancePtr);
6266 if ( mErrorPtr )
6267 *mErrorPtr = status;
6268- return status;
6269+ return instancePtr;
6270 }
6271
6272
6273-nsresult
6274-nsGetClassObjectByCID::operator()( const nsIID& aIID, void** aInstancePtr ) const
6275+void*
6276+nsGetClassObjectByCID::operator()( const nsIID& aIID) const
6277 {
6278- nsresult status = CallGetClassObject(mCID, aIID, aInstancePtr);
6279- if ( NS_FAILED(status) )
6280- *aInstancePtr = 0;
6281+ void *instancePtr = nsnull;
6282+ nsresult status = CallGetClassObject(mCID, aIID, &instancePtr);
6283 if ( mErrorPtr )
6284 *mErrorPtr = status;
6285- return status;
6286+ return instancePtr;
6287 }
6288
6289-nsresult
6290-nsGetClassObjectByContractID::operator()( const nsIID& aIID, void** aInstancePtr ) const
6291+void*
6292+nsGetClassObjectByContractID::operator()( const nsIID& aIID) const
6293 {
6294- nsresult status = CallGetClassObject(mContractID, aIID, aInstancePtr);
6295- if ( NS_FAILED(status) )
6296- *aInstancePtr = 0;
6297+ void *instancePtr = nsnull;
6298+ nsresult status = CallGetClassObject(mContractID, aIID, &instancePtr);
6299 if ( mErrorPtr )
6300 *mErrorPtr = status;
6301- return status;
6302+ return instancePtr;
6303 }
6304
6305
6306-nsresult
6307-nsGetServiceByCID::operator()( const nsIID& aIID, void** aInstancePtr ) const
6308+void*
6309+nsGetServiceByCID::operator()( const nsIID& aIID) const
6310 {
6311- nsresult status = CallGetService(mCID, aIID, aInstancePtr);
6312- if ( NS_FAILED(status) )
6313- *aInstancePtr = 0;
6314+ void *instancePtr = nsnull;
6315+ CallGetService(mCID, aIID, &instancePtr);
6316
6317- return status;
6318+ return instancePtr;
6319 }
6320
6321-nsresult
6322-nsGetServiceByCIDWithError::operator()( const nsIID& aIID, void** aInstancePtr ) const
6323+void*
6324+nsGetServiceByCIDWithError::operator()( const nsIID& aIID) const
6325 {
6326- nsresult status = CallGetService(mCID, aIID, aInstancePtr);
6327- if ( NS_FAILED(status) )
6328- *aInstancePtr = 0;
6329+ void *instancePtr = nsnull;
6330+ nsresult status = CallGetService(mCID, aIID, &instancePtr);
6331
6332 if ( mErrorPtr )
6333 *mErrorPtr = status;
6334- return status;
6335+ return instancePtr;
6336 }
6337
6338-nsresult
6339-nsGetServiceByContractID::operator()( const nsIID& aIID, void** aInstancePtr ) const
6340+void*
6341+nsGetServiceByContractID::operator()( const nsIID& aIID) const
6342 {
6343- nsresult status = CallGetService(mContractID, aIID, aInstancePtr);
6344- if ( NS_FAILED(status) )
6345- *aInstancePtr = 0;
6346-
6347- return status;
6348+ void *instancePtr = nsnull;
6349+ CallGetService(mContractID, aIID, &instancePtr);
6350+
6351+ return instancePtr;
6352 }
6353
6354-nsresult
6355-nsGetServiceByContractIDWithError::operator()( const nsIID& aIID, void** aInstancePtr ) const
6356+void*
6357+nsGetServiceByContractIDWithError::operator()( const nsIID& aIID) const
6358 {
6359- nsresult status = CallGetService(mContractID, aIID, aInstancePtr);
6360- if ( NS_FAILED(status) )
6361- *aInstancePtr = 0;
6362-
6363+ void *instancePtr = nsnull;
6364+ nsresult status = CallGetService(mContractID, aIID, &instancePtr);
6365+
6366 if ( mErrorPtr )
6367 *mErrorPtr = status;
6368- return status;
6369+ return instancePtr;
6370 }
6371diff --git a/xpcom/glue/nsComponentManagerUtils.h b/xpcom/glue/nsComponentManagerUtils.h
6372--- a/xpcom/glue/nsComponentManagerUtils.h
6373+++ b/xpcom/glue/nsComponentManagerUtils.h
6374@@ -73,57 +73,57 @@ class NS_COM_GLUE nsCreateInstanceByCID
6375 public:
6376 nsCreateInstanceByCID( const nsCID& aCID, nsISupports* aOuter, nsresult* aErrorPtr )
6377 : mCID(aCID),
6378 mOuter(aOuter),
6379 mErrorPtr(aErrorPtr)
6380 {
6381 // nothing else to do here
6382 }
6383-
6384- virtual nsresult NS_FASTCALL operator()( const nsIID&, void** ) const;
6385-
6386+
6387+ virtual void* NS_FASTCALL operator()( const nsIID& ) const;
6388+
6389 private:
6390 const nsCID& mCID;
6391 nsISupports* mOuter;
6392 nsresult* mErrorPtr;
6393 };
6394
6395 class NS_COM_GLUE nsCreateInstanceByContractID : public nsCOMPtr_helper
6396 {
6397 public:
6398 nsCreateInstanceByContractID( const char* aContractID, nsISupports* aOuter, nsresult* aErrorPtr )
6399 : mContractID(aContractID),
6400 mOuter(aOuter),
6401 mErrorPtr(aErrorPtr)
6402 {
6403 // nothing else to do here
6404 }
6405-
6406- virtual nsresult NS_FASTCALL operator()( const nsIID&, void** ) const;
6407-
6408+
6409+ virtual void* NS_FASTCALL operator()( const nsIID& ) const;
6410+
6411 private:
6412 const char* mContractID;
6413 nsISupports* mOuter;
6414 nsresult* mErrorPtr;
6415 };
6416
6417 class NS_COM_GLUE nsCreateInstanceFromFactory : public nsCOMPtr_helper
6418 {
6419 public:
6420 nsCreateInstanceFromFactory( nsIFactory* aFactory, nsISupports* aOuter, nsresult* aErrorPtr )
6421 : mFactory(aFactory),
6422 mOuter(aOuter),
6423 mErrorPtr(aErrorPtr)
6424 {
6425 // nothing else to do here
6426 }
6427-
6428- virtual nsresult NS_FASTCALL operator()( const nsIID&, void** ) const;
6429-
6430+
6431+ virtual void* NS_FASTCALL operator()( const nsIID& ) const;
6432+
6433 private:
6434 nsIFactory* mFactory;
6435 nsISupports* mOuter;
6436 nsresult* mErrorPtr;
6437 };
6438
6439
6440 inline
6441@@ -173,36 +173,36 @@ class NS_COM_GLUE nsGetClassObjectByCID
6442 {
6443 public:
6444 nsGetClassObjectByCID( const nsCID& aCID, nsresult* aErrorPtr )
6445 : mCID(aCID),
6446 mErrorPtr(aErrorPtr)
6447 {
6448 // nothing else to do here
6449 }
6450-
6451- virtual nsresult NS_FASTCALL operator()( const nsIID&, void** ) const;
6452-
6453+
6454+ virtual void* NS_FASTCALL operator()( const nsIID& ) const;
6455+
6456 private:
6457 const nsCID& mCID;
6458 nsresult* mErrorPtr;
6459 };
6460
6461 class NS_COM_GLUE nsGetClassObjectByContractID : public nsCOMPtr_helper
6462 {
6463 public:
6464 nsGetClassObjectByContractID( const char* aContractID, nsresult* aErrorPtr )
6465 : mContractID(aContractID),
6466 mErrorPtr(aErrorPtr)
6467 {
6468 // nothing else to do here
6469 }
6470-
6471- virtual nsresult NS_FASTCALL operator()( const nsIID&, void** ) const;
6472-
6473+
6474+ virtual void* NS_FASTCALL operator()( const nsIID& ) const;
6475+
6476 private:
6477 const char* mContractID;
6478 nsresult* mErrorPtr;
6479 };
6480
6481 /**
6482 * do_GetClassObject can be used to improve performance of callers
6483 * that call |CreateInstance| many times. They can cache the factory
6484diff --git a/xpcom/glue/nsCycleCollectionParticipant.h b/xpcom/glue/nsCycleCollectionParticipant.h
6485--- a/xpcom/glue/nsCycleCollectionParticipant.h
6486+++ b/xpcom/glue/nsCycleCollectionParticipant.h
6487@@ -191,24 +191,22 @@ public:
6488 #define NS_CYCLE_COLLECTION_INNERNAME \
6489 _cycleCollectorGlobal
6490
6491 #define NS_CYCLE_COLLECTION_NAME(_class) \
6492 _class::NS_CYCLE_COLLECTION_INNERNAME
6493
6494 #define NS_IMPL_QUERY_CYCLE_COLLECTION(_class) \
6495 if ( aIID.Equals(NS_GET_IID(nsXPCOMCycleCollectionParticipant)) ) { \
6496- *aInstancePtr = & NS_CYCLE_COLLECTION_NAME(_class); \
6497- return NS_OK; \
6498+ return & NS_CYCLE_COLLECTION_NAME(_class); \
6499 } else
6500
6501 #define NS_IMPL_QUERY_CYCLE_COLLECTION_ISUPPORTS(_class) \
6502 if ( aIID.Equals(NS_GET_IID(nsCycleCollectionISupports)) ) { \
6503- *aInstancePtr = NS_CYCLE_COLLECTION_CLASSNAME(_class)::Upcast(this); \
6504- return NS_OK; \
6505+ return NS_CYCLE_COLLECTION_CLASSNAME(_class)::Upcast(this); \
6506 } else
6507
6508 #define NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION(_class) \
6509 NS_IMPL_QUERY_CYCLE_COLLECTION(_class)
6510
6511 #define NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION_ISUPPORTS(_class) \
6512 NS_IMPL_QUERY_CYCLE_COLLECTION_ISUPPORTS(_class)
6513
6514@@ -220,30 +218,27 @@ public:
6515 NS_INTERFACE_MAP_BEGIN(_class) \
6516 NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(_class)
6517
6518 #define NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(_class) \
6519 NS_INTERFACE_MAP_BEGIN(_class) \
6520 NS_INTERFACE_MAP_ENTRY_CYCLE_COLLECTION(_class)
6521
6522 #define NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(_class) \
6523- if (rv == NS_OK) return rv; \
6524+ if (result) return result; \
6525 nsISupports* foundInterface; \
6526 NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(_class)
6527
6528 #define NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(_class) \
6529- NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \
6530+ NS_IMETHODIMP_(void*) _class::QueryInterfaceFast(REFNSIID aIID) \
6531 { \
6532- NS_PRECONDITION(aInstancePtr, "null out param"); \
6533- \
6534 if ( aIID.Equals(NS_GET_IID(nsXPCOMCycleCollectionParticipant)) ) { \
6535- *aInstancePtr = &NS_CYCLE_COLLECTION_NAME(_class); \
6536- return NS_OK; \
6537+ return &NS_CYCLE_COLLECTION_NAME(_class); \
6538 } \
6539- nsresult rv;
6540+ void* result;
6541
6542 #define NS_CYCLE_COLLECTION_UPCAST(obj, clazz) \
6543 NS_CYCLE_COLLECTION_CLASSNAME(clazz)::Upcast(obj)
6544
6545 ///////////////////////////////////////////////////////////////////////////////
6546 // Helpers for implementing nsCycleCollectionParticipant::Unlink
6547 ///////////////////////////////////////////////////////////////////////////////
6548
6549diff --git a/xpcom/glue/nsIInterfaceRequestorUtils.cpp b/xpcom/glue/nsIInterfaceRequestorUtils.cpp
6550--- a/xpcom/glue/nsIInterfaceRequestorUtils.cpp
6551+++ b/xpcom/glue/nsIInterfaceRequestorUtils.cpp
6552@@ -34,31 +34,28 @@
6553 * the provisions above, a recipient may use your version of this file under
6554 * the terms of any one of the MPL, the GPL or the LGPL.
6555 *
6556 * ***** END LICENSE BLOCK ***** */
6557
6558 #include "nsIInterfaceRequestor.h"
6559 #include "nsIInterfaceRequestorUtils.h"
6560
6561-nsresult
6562-nsGetInterface::operator()( const nsIID& aIID, void** aInstancePtr ) const
6563+void*
6564+nsGetInterface::operator()( const nsIID& aIID) const
6565 {
6566 nsresult status;
6567+ void* instancePtr = nsnull;
6568
6569 if ( mSource )
6570 {
6571 nsCOMPtr<nsIInterfaceRequestor> factoryPtr = do_QueryInterface(mSource, &status);
6572
6573 if ( factoryPtr )
6574- status = factoryPtr->GetInterface(aIID, aInstancePtr);
6575- else
6576- status = NS_ERROR_NO_INTERFACE;
6577+ status = factoryPtr->GetInterface(aIID, &instancePtr);
6578 }
6579 else
6580 status = NS_ERROR_NULL_POINTER;
6581
6582- if ( NS_FAILED(status) )
6583- *aInstancePtr = 0;
6584 if ( mErrorPtr )
6585 *mErrorPtr = status;
6586- return status;
6587+ return instancePtr;
6588 }
6589diff --git a/xpcom/glue/nsIInterfaceRequestorUtils.h b/xpcom/glue/nsIInterfaceRequestorUtils.h
6590--- a/xpcom/glue/nsIInterfaceRequestorUtils.h
6591+++ b/xpcom/glue/nsIInterfaceRequestorUtils.h
6592@@ -60,17 +60,17 @@ class NS_COM_GLUE nsGetInterface : publi
6593 public:
6594 nsGetInterface( nsISupports* aSource, nsresult* error )
6595 : mSource(aSource),
6596 mErrorPtr(error)
6597 {
6598 // nothing else to do here
6599 }
6600
6601- virtual nsresult NS_FASTCALL operator()( const nsIID&, void** ) const;
6602+ virtual void* NS_FASTCALL operator()( const nsIID& ) const;
6603
6604 private:
6605 nsISupports* mSource;
6606 nsresult* mErrorPtr;
6607 };
6608
6609 inline
6610 const nsGetInterface
6611diff --git a/xpcom/glue/nsISupportsImpl.cpp b/xpcom/glue/nsISupportsImpl.cpp
6612--- a/xpcom/glue/nsISupportsImpl.cpp
6613+++ b/xpcom/glue/nsISupportsImpl.cpp
6614@@ -32,28 +32,26 @@
6615 * and other provisions required by the GPL or the LGPL. If you do not delete
6616 * the provisions above, a recipient may use your version of this file under
6617 * the terms of any one of the MPL, the GPL or the LGPL.
6618 *
6619 * ***** END LICENSE BLOCK ***** */
6620
6621 #include "nsISupportsImpl.h"
6622
6623-nsresult NS_FASTCALL
6624+void* NS_FASTCALL
6625 NS_TableDrivenQI(void* aThis, const QITableEntry* entries,
6626- REFNSIID aIID, void **aInstancePtr)
6627+ REFNSIID aIID)
6628 {
6629 while (entries->iid) {
6630 if (aIID.Equals(*entries->iid)) {
6631 nsISupports* r =
6632 reinterpret_cast<nsISupports*>
6633 (reinterpret_cast<char*>(aThis) + entries->offset);
6634 NS_ADDREF(r);
6635- *aInstancePtr = r;
6636- return NS_OK;
6637+ return r;
6638 }
6639
6640 ++entries;
6641 }
6642
6643- *aInstancePtr = nsnull;
6644- return NS_ERROR_NO_INTERFACE;
6645+ return nsnull;
6646 }
6647diff --git a/xpcom/glue/nsISupportsImpl.h b/xpcom/glue/nsISupportsImpl.h
6648--- a/xpcom/glue/nsISupportsImpl.h
6649+++ b/xpcom/glue/nsISupportsImpl.h
6650@@ -271,34 +271,32 @@ class nsAutoRefCnt {
6651 nsrefcnt operator--(int);
6652 nsrefcnt mValue;
6653 };
6654
6655 ///////////////////////////////////////////////////////////////////////////////
6656
6657 /**
6658 * Declare the reference count variable and the implementations of the
6659- * AddRef and QueryInterface methods.
6660+ * AddRef and QueryInterfaceFast methods.
6661 */
6662
6663 #define NS_DECL_ISUPPORTS \
6664 public: \
6665- NS_IMETHOD QueryInterface(REFNSIID aIID, \
6666- void** aInstancePtr); \
6667+ NS_IMETHOD_(void*) QueryInterfaceFast(REFNSIID aIID); \
6668 NS_IMETHOD_(nsrefcnt) AddRef(void); \
6669 NS_IMETHOD_(nsrefcnt) Release(void); \
6670 protected: \
6671 nsAutoRefCnt mRefCnt; \
6672 NS_DECL_OWNINGTHREAD \
6673 public:
6674
6675 #define NS_DECL_CYCLE_COLLECTING_ISUPPORTS \
6676 public: \
6677- NS_IMETHOD QueryInterface(REFNSIID aIID, \
6678- void** aInstancePtr); \
6679+ NS_IMETHOD_(void*) QueryInterfaceFast(REFNSIID aIID); \
6680 NS_IMETHOD_(nsrefcnt) AddRef(void); \
6681 NS_IMETHOD_(nsrefcnt) Release(void); \
6682 void UnmarkPurple() \
6683 { \
6684 mRefCnt.unmarkPurple(); \
6685 } \
6686 protected: \
6687 nsCycleCollectingAutoRefCnt mRefCnt; \
6688@@ -472,50 +470,47 @@ NS_IMETHODIMP_(nsrefcnt) _class::Release
6689
6690 #define NS_IMPL_CYCLE_COLLECTING_RELEASE(_class) \
6691 NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_DESTROY(_class, delete (this))
6692
6693
6694 ///////////////////////////////////////////////////////////////////////////////
6695
6696 /**
6697- * There are two ways of implementing QueryInterface, and we use both:
6698+ * There are two ways of implementing QueryInterfaceFast, and we use both:
6699 *
6700- * Table-driven QueryInterface uses a static table of IID->offset mappings
6701+ * Table-driven QueryInterfaceFast uses a static table of IID->offset mappings
6702 * and a shared helper function. Using it tends to reduce codesize and improve
6703 * runtime performance (due to processor cache hits).
6704 *
6705- * Macro-driven QueryInterface generates a QueryInterface function directly
6706- * using common macros. This is necessary if special QueryInterface features
6707+ * Macro-driven QueryInterfaceFast generates a QueryInterfaceFast function directly
6708+ * using common macros. This is necessary if special QueryInterfaceFast features
6709 * are being used (such as tearoffs and conditional interfaces).
6710 *
6711 * These methods can be combined into a table-driven function call followed
6712 * by custom code for tearoffs and conditionals.
6713 */
6714
6715 struct QITableEntry
6716 {
6717 const nsIID *iid; // null indicates end of the QITableEntry array
6718 PROffset32 offset;
6719 };
6720
6721-NS_COM_GLUE nsresult NS_FASTCALL
6722-NS_TableDrivenQI(void* aThis, const QITableEntry* entries,
6723- REFNSIID aIID, void **aInstancePtr);
6724+NS_COM_GLUE void* NS_FASTCALL
6725+NS_TableDrivenQI(void* aThis, const QITableEntry* entries, REFNSIID aIID);
6726
6727 /**
6728 * Implement table-driven queryinterface
6729 */
6730
6731 #define NS_INTERFACE_TABLE_HEAD(_class) \
6732-NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \
6733+NS_IMETHODIMP_(void*) _class::QueryInterfaceFast(REFNSIID aIID) \
6734 { \
6735- NS_ASSERTION(aInstancePtr, \
6736- "QueryInterface requires a non-NULL destination!"); \
6737- nsresult rv = NS_ERROR_FAILURE;
6738+ void* result = nsnull;
6739
6740 #define NS_INTERFACE_TABLE_BEGIN \
6741 static const QITableEntry table[] = {
6742
6743 #define NS_INTERFACE_TABLE_ENTRY(_class, _interface) \
6744 { &_interface::COMTypeInfo<int>::kIID, \
6745 PROffset32(reinterpret_cast<char*>( \
6746 static_cast<_interface*>((_class*) 0x1000)) - \
6747@@ -528,55 +523,52 @@ NS_IMETHODIMP _class::QueryInterface(REF
6748 static_cast<_interface*>( \
6749 static_cast<_implClass*>( \
6750 (_class*) 0x1000))) - \
6751 reinterpret_cast<char*>((_class*) 0x1000)) \
6752 },
6753
6754 #define NS_INTERFACE_TABLE_END_WITH_PTR(_ptr) \
6755 { nsnull, 0 } }; \
6756- rv = NS_TableDrivenQI(static_cast<void*>(_ptr), \
6757- table, aIID, aInstancePtr);
6758+ result = NS_TableDrivenQI(static_cast<void*>(_ptr), table, aIID);
6759
6760 #define NS_INTERFACE_TABLE_END \
6761 NS_INTERFACE_TABLE_END_WITH_PTR(this)
6762
6763 #define NS_INTERFACE_TABLE_TAIL \
6764- return rv; \
6765+ return result; \
6766 }
6767
6768 #define NS_INTERFACE_TABLE_TAIL_INHERITING(_baseclass) \
6769- if (NS_SUCCEEDED(rv)) \
6770- return rv; \
6771- return _baseclass::QueryInterface(aIID, aInstancePtr); \
6772+ if (result) \
6773+ return result; \
6774+ return _baseclass::QueryInterfaceFast(aIID); \
6775 }
6776
6777 #define NS_INTERFACE_TABLE_TAIL_USING_AGGREGATOR(_aggregator) \
6778- if (NS_SUCCEEDED(rv)) \
6779- return rv; \
6780+ if (result) \
6781+ return result; \
6782 NS_ASSERTION(_aggregator, "null aggregator"); \
6783- return _aggregator->QueryInterface(aIID, aInstancePtr) \
6784+ return _aggregator->QueryInterfaceFast(aIID); \
6785 }
6786
6787 /**
6788 * This implements query interface with two assumptions: First, the
6789 * class in question implements nsISupports and its own interface and
6790 * nothing else. Second, the implementation of the class's primary
6791 * inheritance chain leads to its own interface.
6792 *
6793 * @param _class The name of the class implementing the method
6794 * @param _classiiddef The name of the #define symbol that defines the IID
6795 * for the class (e.g. NS_ISUPPORTS_IID)
6796 */
6797
6798 #define NS_IMPL_QUERY_HEAD(_class) \
6799-NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \
6800+NS_IMETHODIMP_(void*) _class::QueryInterfaceFast(REFNSIID aIID) \
6801 { \
6802- NS_ASSERTION(aInstancePtr, \
6803- "QueryInterface requires a non-NULL destination!"); \
6804 nsISupports* foundInterface;
6805
6806 #define NS_IMPL_QUERY_BODY(_interface) \
6807 if ( aIID.Equals(NS_GET_IID(_interface)) ) \
6808 foundInterface = static_cast<_interface*>(this); \
6809 else
6810
6811 #define NS_IMPL_QUERY_BODY_CONDITIONAL(_interface, condition) \
6812@@ -592,55 +584,46 @@ NS_IMETHODIMP _class::QueryInterface(REF
6813
6814 #define NS_IMPL_QUERY_BODY_AGGREGATED(_interface, _aggregate) \
6815 if ( aIID.Equals(NS_GET_IID(_interface)) ) \
6816 foundInterface = static_cast<_interface*>(_aggregate); \
6817 else
6818
6819 #define NS_IMPL_QUERY_TAIL_GUTS \
6820 foundInterface = 0; \
6821- nsresult status; \
6822- if ( !foundInterface ) \
6823- status = NS_NOINTERFACE; \
6824- else \
6825+ if ( foundInterface ) \
6826 { \
6827 NS_ADDREF(foundInterface); \
6828- status = NS_OK; \
6829 } \
6830- *aInstancePtr = foundInterface; \
6831- return status; \
6832+ return foundInterface; \
6833 }
6834
6835 #define NS_IMPL_QUERY_TAIL_INHERITING(_baseclass) \
6836 foundInterface = 0; \
6837- nsresult status; \
6838 if ( !foundInterface ) \
6839- status = _baseclass::QueryInterface(aIID, (void**)&foundInterface); \
6840+ foundInterface = static_cast<nsISupports*> \
6841+ (_baseclass::QueryInterfaceFast(aIID)); \
6842 else \
6843 { \
6844 NS_ADDREF(foundInterface); \
6845- status = NS_OK; \
6846 } \
6847- *aInstancePtr = foundInterface; \
6848- return status; \
6849+ return foundInterface; \
6850 }
6851
6852 #define NS_IMPL_QUERY_TAIL_USING_AGGREGATOR(_aggregator) \
6853 foundInterface = 0; \
6854- nsresult status; \
6855 if ( !foundInterface ) { \
6856 NS_ASSERTION(_aggregator, "null aggregator"); \
6857- status = _aggregator->QueryInterface(aIID, (void**)&foundInterface); \
6858+ foundInterface = static_cast<nsISupports*> \
6859+ (_aggregator->QueryInterfaceFast(aIID)); \
6860 } else \
6861 { \
6862 NS_ADDREF(foundInterface); \
6863- status = NS_OK; \
6864 } \
6865- *aInstancePtr = foundInterface; \
6866- return status; \
6867+ return foundInterface; \
6868 }
6869
6870 #define NS_IMPL_QUERY_TAIL(_supports_interface) \
6871 NS_IMPL_QUERY_BODY_AMBIGUOUS(nsISupports, _supports_interface) \
6872 NS_IMPL_QUERY_TAIL_GUTS
6873
6874
6875 /*
6876@@ -882,18 +865,17 @@ NS_IMETHODIMP _class::QueryInterface(REF
6877 * class Bar : public Foo, public nsIBar { // both provide nsISupports
6878 * public:
6879 * NS_DECL_ISUPPORTS_INHERITED
6880 * ...other nsIBar and Bar methods...
6881 * };
6882 */
6883 #define NS_DECL_ISUPPORTS_INHERITED \
6884 public: \
6885- NS_IMETHOD QueryInterface(REFNSIID aIID, \
6886- void** aInstancePtr); \
6887+ NS_IMETHOD_(void*) QueryInterfaceFast(REFNSIID aIID); \
6888 NS_IMETHOD_(nsrefcnt) AddRef(void); \
6889 NS_IMETHOD_(nsrefcnt) Release(void); \
6890
6891 /**
6892 * These macros can be used in conjunction with NS_DECL_ISUPPORTS_INHERITED
6893 * to implement the nsISupports methods, forwarding the invocations to a
6894 * superclass that already implements nsISupports.
6895 *
6896@@ -1239,17 +1221,17 @@ NS_IMETHODIMP_(nsrefcnt) Class::Release(
6897 NS_IMPL_ADDREF_INHERITED(Class, Super) \
6898 NS_IMPL_RELEASE_INHERITED(Class, Super) \
6899 /*
6900 * Macro to glue together a QI that starts with an interface table
6901 * and segues into an interface map (e.g. it uses singleton classinfo
6902 * or tearoffs).
6903 */
6904 #define NS_INTERFACE_TABLE_TO_MAP_SEGUE \
6905- if (rv == NS_OK) return rv; \
6906+ if (result) return result; \
6907 nsISupports* foundInterface;
6908
6909
6910 ///////////////////////////////////////////////////////////////////////////////
6911 /**
6912 *
6913 * Threadsafe implementations of the ISupports convenience macros.
6914 *
6915diff --git a/xpcom/glue/nsISupportsUtils.h b/xpcom/glue/nsISupportsUtils.h
6916--- a/xpcom/glue/nsISupportsUtils.h
6917+++ b/xpcom/glue/nsISupportsUtils.h
6918@@ -174,14 +174,15 @@ ns_if_addref( T expr )
6919 // a type-safe shortcut for calling the |QueryInterface()| member function
6920 template <class T, class DestinationType>
6921 inline
6922 nsresult
6923 CallQueryInterface( T* aSource, DestinationType** aDestination )
6924 {
6925 NS_PRECONDITION(aSource, "null parameter");
6926 NS_PRECONDITION(aDestination, "null parameter");
6927-
6928- return aSource->QueryInterface(NS_GET_TEMPLATE_IID(DestinationType),
6929- reinterpret_cast<void**>(aDestination));
6930+
6931+ *aDestination = static_cast<DestinationType*>
6932+ (aSource->QueryInterfaceFast(NS_GET_TEMPLATE_IID(DestinationType)));
6933+ return (*aDestination) ? NS_OK : NS_ERROR_NO_INTERFACE;
6934 }
6935
6936 #endif /* __nsISupportsUtils_h */
6937diff --git a/xpcom/glue/nsIWeakReferenceUtils.h b/xpcom/glue/nsIWeakReferenceUtils.h
6938--- a/xpcom/glue/nsIWeakReferenceUtils.h
6939+++ b/xpcom/glue/nsIWeakReferenceUtils.h
6940@@ -71,17 +71,17 @@ class NS_COM_GLUE nsQueryReferent : publ
6941 public:
6942 nsQueryReferent( nsIWeakReference* aWeakPtr, nsresult* error )
6943 : mWeakPtr(aWeakPtr),
6944 mErrorPtr(error)
6945 {
6946 // nothing else to do here
6947 }
6948
6949- virtual nsresult NS_FASTCALL operator()( const nsIID& aIID, void** ) const;
6950+ virtual void* NS_FASTCALL operator()( const nsIID& aIID ) const;
6951
6952 private:
6953 nsIWeakReference* mWeakPtr;
6954 nsresult* mErrorPtr;
6955 };
6956
6957 inline
6958 const nsQueryReferent
6959diff --git a/xpcom/glue/nsServiceManagerUtils.h b/xpcom/glue/nsServiceManagerUtils.h
6960--- a/xpcom/glue/nsServiceManagerUtils.h
6961+++ b/xpcom/glue/nsServiceManagerUtils.h
6962@@ -75,18 +75,18 @@ class nsGetServiceFromCategory : public
6963 nsGetServiceFromCategory(const char* aCategory, const char* aEntry,
6964 nsresult* aErrorPtr)
6965 : mCategory(aCategory),
6966 mEntry(aEntry),
6967 mErrorPtr(aErrorPtr)
6968 {
6969 // nothing else to do
6970 }
6971-
6972- virtual nsresult NS_FASTCALL operator()( const nsIID&, void** ) const;
6973+
6974+ virtual void* NS_FASTCALL operator()( const nsIID& ) const;
6975 protected:
6976 const char* mCategory;
6977 const char* mEntry;
6978 nsresult* mErrorPtr;
6979 };
6980
6981 inline
6982 const nsGetServiceFromCategory
6983diff --git a/xpcom/glue/nsWeakReference.cpp b/xpcom/glue/nsWeakReference.cpp
6984--- a/xpcom/glue/nsWeakReference.cpp
6985+++ b/xpcom/glue/nsWeakReference.cpp
6986@@ -74,31 +74,32 @@ class nsWeakReference : public nsIWeakRe
6987 // ...called (only) by an |nsSupportsWeakReference| from _its_ dtor.
6988 {
6989 mReferent = 0;
6990 }
6991
6992 nsSupportsWeakReference* mReferent;
6993 };
6994
6995-nsresult
6996-nsQueryReferent::operator()( const nsIID& aIID, void** answer ) const
6997+void*
6998+nsQueryReferent::operator()( const nsIID& aIID ) const
6999 {
7000+ void* answer = 0;
7001 nsresult status;
7002 if ( mWeakPtr )
7003 {
7004- if ( NS_FAILED(status = mWeakPtr->QueryReferent(aIID, answer)) )
7005- *answer = 0;
7006+ if ( NS_FAILED(status = mWeakPtr->QueryReferent(aIID, &answer)) )
7007+ answer = 0;
7008 }
7009 else
7010 status = NS_ERROR_NULL_POINTER;
7011
7012 if ( mErrorPtr )
7013 *mErrorPtr = status;
7014- return status;
7015+ return answer;
7016 }
7017
7018 NS_COM_GLUE nsIWeakReference* // or else |already_AddRefed<nsIWeakReference>|
7019 NS_GetWeakReference( nsISupports* aInstancePtr, nsresult* aErrorPtr )
7020 {
7021 nsresult status;
7022
7023 nsIWeakReference* result = nsnull;
7024diff --git a/xpcom/io/nsDirectoryService.cpp b/xpcom/io/nsDirectoryService.cpp
7025--- a/xpcom/io/nsDirectoryService.cpp
7026+++ b/xpcom/io/nsDirectoryService.cpp
7027@@ -257,17 +257,18 @@ nsDirectoryService::Create(nsISupports *
7028 NS_ENSURE_ARG_POINTER(aResult);
7029 NS_ENSURE_NO_AGGREGATION(outer);
7030
7031 if (!gService)
7032 {
7033 return NS_ERROR_NOT_INITIALIZED;
7034 }
7035
7036- return gService->QueryInterface(aIID, aResult);
7037+ *aResult = gService->QueryInterfaceFast(aIID);
7038+ return (*aResult) ? NS_OK : NS_ERROR_NO_INTERFACE;
7039 }
7040
7041 #define DIR_ATOM(name_, value_) nsIAtom* nsDirectoryService::name_ = nsnull;
7042 #include "nsDirectoryServiceAtomList.h"
7043 #undef DIR_ATOM
7044
7045 #define DIR_ATOM(name_, value_) NS_STATIC_ATOM_BUFFER(name_##_buffer, value_)
7046 #include "nsDirectoryServiceAtomList.h"
7047diff --git a/xpcom/io/nsLocalFileOS2.cpp b/xpcom/io/nsLocalFileOS2.cpp
7048--- a/xpcom/io/nsLocalFileOS2.cpp
7049+++ b/xpcom/io/nsLocalFileOS2.cpp
7050@@ -596,21 +596,21 @@ nsLocalFile::nsLocalFileConstructor(nsIS
7051 {
7052 NS_ENSURE_ARG_POINTER(aInstancePtr);
7053 NS_ENSURE_NO_AGGREGATION(outer);
7054
7055 nsLocalFile* inst = new nsLocalFile();
7056 if (inst == NULL)
7057 return NS_ERROR_OUT_OF_MEMORY;
7058
7059- nsresult rv = inst->QueryInterface(aIID, aInstancePtr);
7060- if (NS_FAILED(rv))
7061+ *aInstancePtr = inst->QueryInterfaceFast(aIID);
7062+ if (!*aInstancePtr)
7063 {
7064 delete inst;
7065- return rv;
7066+ return NS_ERROR_NO_INTERFACE;
7067 }
7068 return NS_OK;
7069 }
7070
7071
7072 //-----------------------------------------------------------------------------
7073 // nsLocalFile::nsISupports
7074 //-----------------------------------------------------------------------------
7075diff --git a/xpcom/io/nsLocalFileUnix.cpp b/xpcom/io/nsLocalFileUnix.cpp
7076--- a/xpcom/io/nsLocalFileUnix.cpp
7077+++ b/xpcom/io/nsLocalFileUnix.cpp
7078@@ -293,17 +293,18 @@ nsLocalFile::nsLocalFileConstructor(nsIS
7079 NS_ENSURE_ARG_POINTER(aInstancePtr);
7080 NS_ENSURE_NO_AGGREGATION(outer);
7081
7082 *aInstancePtr = nsnull;
7083
7084 nsCOMPtr<nsIFile> inst = new nsLocalFile();
7085 if (!inst)
7086 return NS_ERROR_OUT_OF_MEMORY;
7087- return inst->QueryInterface(aIID, aInstancePtr);
7088+ *aInstancePtr = inst->QueryInterfaceFast(aIID);
7089+ return (*aInstancePtr) ? NS_OK : NS_ERROR_NO_INTERFACE;
7090 }
7091
7092 PRBool
7093 nsLocalFile::FillStatCache() {
7094 if (STAT(mPath.get(), &mCachedStat) == -1) {
7095 // try lstat it may be a symlink
7096 if (LSTAT(mPath.get(), &mCachedStat) == -1) {
7097 return PR_FALSE;
7098diff --git a/xpcom/io/nsLocalFileWin.cpp b/xpcom/io/nsLocalFileWin.cpp
7099--- a/xpcom/io/nsLocalFileWin.cpp
7100+++ b/xpcom/io/nsLocalFileWin.cpp
7101@@ -718,21 +718,21 @@ nsLocalFile::nsLocalFileConstructor(nsIS
7102 {
7103 NS_ENSURE_ARG_POINTER(aInstancePtr);
7104 NS_ENSURE_NO_AGGREGATION(outer);
7105
7106 nsLocalFile* inst = new nsLocalFile();
7107 if (inst == NULL)
7108 return NS_ERROR_OUT_OF_MEMORY;
7109
7110- nsresult rv = inst->QueryInterface(aIID, aInstancePtr);
7111- if (NS_FAILED(rv))
7112+ *aInstancePtr = inst->QueryInterfaceFast(aIID);
7113+ if (!*aInstancePtr)
7114 {
7115 delete inst;
7116- return rv;
7117+ return NS_ERROR_NO_INTERFACE;
7118 }
7119 return NS_OK;
7120 }
7121
7122
7123 //-----------------------------------------------------------------------------
7124 // nsLocalFile::nsISupports
7125 //-----------------------------------------------------------------------------
7126diff --git a/xpcom/io/nsMultiplexInputStream.cpp b/xpcom/io/nsMultiplexInputStream.cpp
7127--- a/xpcom/io/nsMultiplexInputStream.cpp
7128+++ b/xpcom/io/nsMultiplexInputStream.cpp
7129@@ -415,20 +415,20 @@ nsMultiplexInputStreamConstructor(nsISup
7130 if (outer)
7131 return NS_ERROR_NO_AGGREGATION;
7132
7133 nsMultiplexInputStream *inst = new nsMultiplexInputStream();
7134 if (!inst)
7135 return NS_ERROR_OUT_OF_MEMORY;
7136
7137 NS_ADDREF(inst);
7138- nsresult rv = inst->QueryInterface(iid, result);
7139+ *result = inst->QueryInterfaceFast(iid);
7140 NS_RELEASE(inst);
7141
7142- return rv;
7143+ return (*result) ? NS_OK : NS_ERROR_NO_INTERFACE;
7144 }
7145
7146 PRBool
7147 nsMultiplexInputStream::Read(const IPC::Message *aMsg, void **aIter)
7148 {
7149 using IPC::ReadParam;
7150
7151 PRUint32 count;
7152diff --git a/xpcom/io/nsStringStream.cpp b/xpcom/io/nsStringStream.cpp
7153--- a/xpcom/io/nsStringStream.cpp
7154+++ b/xpcom/io/nsStringStream.cpp
7155@@ -460,13 +460,13 @@ nsStringInputStreamConstructor(nsISuppor
7156
7157 NS_ENSURE_TRUE(!outer, NS_ERROR_NO_AGGREGATION);
7158
7159 nsStringInputStream *inst = new nsStringInputStream();
7160 if (!inst)
7161 return NS_ERROR_OUT_OF_MEMORY;
7162
7163 NS_ADDREF(inst);
7164- nsresult rv = inst->QueryInterface(iid, result);
7165+ *result = inst->QueryInterfaceFast(iid);
7166 NS_RELEASE(inst);
7167
7168- return rv;
7169+ return (*result) ? NS_OK : NS_ERROR_NO_INTERFACE;
7170 }
7171diff --git a/xpcom/proxy/src/nsProxyEvent.cpp b/xpcom/proxy/src/nsProxyEvent.cpp
7172--- a/xpcom/proxy/src/nsProxyEvent.cpp
7173+++ b/xpcom/proxy/src/nsProxyEvent.cpp
7174@@ -80,45 +80,44 @@ class nsProxyCallCompletedEvent : public
7175 {
7176 public:
7177 nsProxyCallCompletedEvent(nsProxyObjectCallInfo *info)
7178 : mInfo(info)
7179 {}
7180
7181 NS_DECL_NSIRUNNABLE
7182
7183- NS_IMETHOD QueryInterface(REFNSIID aIID, void **aResult);
7184+ NS_IMETHOD_(void*) QueryInterfaceFast(REFNSIID aIID);
7185
7186 private:
7187 nsProxyObjectCallInfo *mInfo;
7188 };
7189
7190 NS_IMETHODIMP
7191 nsProxyCallCompletedEvent::Run()
7192 {
7193 NS_ASSERTION(mInfo, "no info");
7194 mInfo->SetCompleted();
7195 return NS_OK;
7196 }
7197
7198 NS_DEFINE_IID(kFilterIID, NS_PROXYEVENT_FILTER_IID);
7199
7200-NS_IMETHODIMP
7201-nsProxyCallCompletedEvent::QueryInterface(REFNSIID aIID, void **aResult)
7202+NS_IMETHODIMP_(void*)
7203+nsProxyCallCompletedEvent::QueryInterfaceFast(REFNSIID aIID)
7204 {
7205 // We are explicitly breaking XPCOM rules here by returning a different
7206- // object from QueryInterface. We do this so that
7207+ // object from QueryInterfaceFast. We do this so that
7208 // nsProxyThreadFilter::AcceptEvent can know whether we are an event that
7209 // needs to be allowed through during a synchronous proxy call.
7210 if (aIID.Equals(kFilterIID)) {
7211- *aResult = mInfo;
7212 mInfo->AddRef();
7213- return NS_OK;
7214+ return mInfo;
7215 }
7216- return nsRunnable::QueryInterface(aIID, aResult);
7217+ return nsRunnable::QueryInterfaceFast(aIID);
7218 }
7219
7220 //-----------------------------------------------------------------------------
7221
7222 NS_IMETHODIMP
7223 nsProxyObject::nsProxyObjectDestructorEvent::Run()
7224 {
7225 delete mDoomed;
7226@@ -155,25 +154,24 @@ nsProxyObjectCallInfo::~nsProxyObjectCal
7227 CopyStrings(PR_FALSE);
7228
7229 mOwner = nsnull;
7230
7231 if (mParameterList)
7232 free(mParameterList);
7233 }
7234
7235-NS_IMETHODIMP
7236-nsProxyObjectCallInfo::QueryInterface(REFNSIID aIID, void **aResult)
7237+NS_IMETHODIMP_(void*)
7238+nsProxyObjectCallInfo::QueryInterfaceFast(REFNSIID aIID)
7239 {
7240 if (aIID.Equals(kFilterIID)) {
7241- *aResult = this;
7242 AddRef();
7243- return NS_OK;
7244+ return this;
7245 }
7246- return nsRunnable::QueryInterface(aIID, aResult);
7247+ return nsRunnable::QueryInterfaceFast(aIID);
7248 }
7249
7250 NS_IMETHODIMP
7251 nsProxyObjectCallInfo::Run()
7252 {
7253 PROXY_LOG(("PROXY(%p): Run\n", this));
7254
7255 mResult = NS_InvokeByIndex(mOwner->GetProxiedInterface(),
7256@@ -396,83 +394,80 @@ nsProxyObject::LockedRelease()
7257 pom->LockedRemove(this);
7258
7259 MutexAutoUnlock unlock(pom->GetLock());
7260 delete this;
7261
7262 return 0;
7263 }
7264
7265-NS_IMETHODIMP
7266-nsProxyObject::QueryInterface(REFNSIID aIID, void **aResult)
7267+NS_IMETHODIMP_(void*)
7268+nsProxyObject::QueryInterfaceFast(REFNSIID aIID)
7269 {
7270 if (aIID.Equals(GetIID())) {
7271- *aResult = this;
7272 AddRef();
7273- return NS_OK;
7274+ return this;
7275 }
7276
7277 if (aIID.Equals(NS_GET_IID(nsISupports))) {
7278- *aResult = static_cast<nsISupports*>(this);
7279 AddRef();
7280- return NS_OK;
7281+ return static_cast<nsISupports*>(this);
7282 }
7283
7284 nsProxyObjectManager *pom = nsProxyObjectManager::GetInstance();
7285 NS_ASSERTION(pom, "Deleting a proxy without a global proxy-object-manager.");
7286
7287 MutexAutoLock lock(pom->GetLock());
7288- return LockedFind(aIID, aResult);
7289+ return LockedFind(aIID);
7290 }
7291
7292-nsresult
7293-nsProxyObject::LockedFind(REFNSIID aIID, void **aResult)
7294+void*
7295+nsProxyObject::LockedFind(REFNSIID aIID)
7296 {
7297 // This method is only called when the global lock is held.
7298 #ifdef DEBUG
7299 nsProxyObjectManager::GetInstance()->GetLock().AssertCurrentThreadOwns();
7300 #endif
7301
7302 nsProxyEventObject *peo;
7303
7304 for (peo = mFirst; peo; peo = peo->mNext) {
7305 if (peo->GetClass()->GetProxiedIID().Equals(aIID)) {
7306- *aResult = static_cast<nsISupports*>(peo->mXPTCStub);
7307 peo->LockedAddRef();
7308- return NS_OK;
7309+ return static_cast<nsISupports*>(peo->mXPTCStub);
7310 }
7311 }
7312
7313 nsProxyEventObject *newpeo;
7314
7315 // Both GetClass and QueryInterface call out to XPCOM, so we unlock for them
7316 nsProxyObjectManager* pom = nsProxyObjectManager::GetInstance();
7317 {
7318 MutexAutoUnlock unlock(pom->GetLock());
7319
7320 nsProxyEventClass *pec;
7321 nsresult rv = pom->GetClass(aIID, &pec);
7322 if (NS_FAILED(rv))
7323- return rv;
7324+ return nsnull;
7325
7326 nsISomeInterface* newInterface;
7327 rv = mRealObject->QueryInterface(aIID, (void**) &newInterface);
7328 if (NS_FAILED(rv))
7329- return rv;
7330+ return nsnull;
7331
7332 newpeo = new nsProxyEventObject(this, pec,
7333 already_AddRefed<nsISomeInterface>(newInterface), &rv);
7334 if (!newpeo) {
7335 NS_RELEASE(newInterface);
7336- return NS_ERROR_OUT_OF_MEMORY;
7337+ return nsnull;
7338 }
7339
7340 if (NS_FAILED(rv)) {
7341 delete newpeo;
7342- return rv;
7343+ return nsnull;
7344 }
7345 }
7346
7347 // Now that we're locked again, check for races by repeating the
7348 // linked-list check.
7349 for (peo = mFirst; peo; peo = peo->mNext) {
7350 if (peo->GetClass()->GetProxiedIID().Equals(aIID)) {
7351 // Best to AddRef for our caller before unlocking.
7352@@ -480,28 +475,26 @@ nsProxyObject::LockedFind(REFNSIID aIID,
7353
7354 {
7355 // Deleting an nsProxyEventObject can call Release on an
7356 // nsProxyObject, which can only happen when not holding
7357 // the lock.
7358 MutexAutoUnlock unlock(pom->GetLock());
7359 delete newpeo;
7360 }
7361- *aResult = static_cast<nsISupports*>(peo->mXPTCStub);
7362- return NS_OK;
7363+ return static_cast<nsISupports*>(peo->mXPTCStub);
7364 }
7365 }
7366
7367 newpeo->mNext = mFirst;
7368 mFirst = newpeo;
7369
7370 newpeo->LockedAddRef();
7371
7372- *aResult = static_cast<nsISupports*>(newpeo->mXPTCStub);
7373- return NS_OK;
7374+ return static_cast<nsISupports*>(newpeo->mXPTCStub);
7375 }
7376
7377 void
7378 nsProxyObject::LockedRemove(nsProxyEventObject *peo)
7379 {
7380 nsProxyEventObject **i;
7381 for (i = &mFirst; *i; i = &((*i)->mNext)) {
7382 if (*i == peo) {
7383diff --git a/xpcom/proxy/src/nsProxyEventObject.cpp b/xpcom/proxy/src/nsProxyEventObject.cpp
7384--- a/xpcom/proxy/src/nsProxyEventObject.cpp
7385+++ b/xpcom/proxy/src/nsProxyEventObject.cpp
7386@@ -112,27 +112,26 @@ nsProxyEventObject::Release(void)
7387 }
7388
7389 // call the destructor outside of the lock so that we aren't holding the
7390 // lock when we release the object
7391 delete this;
7392 return 0;
7393 }
7394
7395-NS_IMETHODIMP
7396-nsProxyEventObject::QueryInterface(REFNSIID aIID, void** aInstancePtr)
7397+NS_IMETHODIMP_(void*)
7398+nsProxyEventObject::QueryInterfaceFast(REFNSIID aIID)
7399 {
7400 if( aIID.Equals(GetClass()->GetProxiedIID()) )
7401 {
7402- *aInstancePtr = static_cast<nsISupports*>(mXPTCStub);
7403 NS_ADDREF_THIS();
7404- return NS_OK;
7405+ return static_cast<nsISupports*>(mXPTCStub);
7406 }
7407-
7408- return mProxyObject->QueryInterface(aIID, aInstancePtr);
7409+
7410+ return mProxyObject->QueryInterfaceFast(aIID);
7411 }
7412
7413 //
7414 // nsXPTCStubBase implementation...
7415 //
7416
7417 nsresult
7418 nsProxyEventObject::convertMiniVariantToVariant(const XPTMethodDescriptor *methodInfo,
7419diff --git a/xpcom/proxy/src/nsProxyEventPrivate.h b/xpcom/proxy/src/nsProxyEventPrivate.h
7420--- a/xpcom/proxy/src/nsProxyEventPrivate.h
7421+++ b/xpcom/proxy/src/nsProxyEventPrivate.h
7422@@ -116,17 +116,17 @@ public:
7423
7424 // these are the equivalents of AddRef/Release, but must be called
7425 // while holding the global POM lock
7426 nsrefcnt LockedAddRef();
7427 nsrefcnt LockedRelease();
7428
7429 // LockedFind should be called holding the POM lock. It will
7430 // temporarily unlock the lock during execution.
7431- nsresult LockedFind(REFNSIID iid, void **aResult);
7432+ void* LockedFind(REFNSIID iid);
7433
7434 void LockedRemove(nsProxyEventObject* aObject);
7435
7436 friend class nsProxyObjectManager;
7437 private:
7438 ~nsProxyObject();
7439
7440 PRInt32 mProxyType;
7441@@ -212,17 +212,17 @@ private:
7442 * A class representing a particular proxied method call.
7443 */
7444 class nsProxyObjectCallInfo : public nsRunnable
7445 {
7446 public:
7447
7448 NS_DECL_NSIRUNNABLE
7449
7450- NS_IMETHOD QueryInterface(REFNSIID aIID, void **aResult);
7451+ NS_IMETHOD_(void*) QueryInterfaceFast(REFNSIID aIID);
7452
7453 NS_DECLARE_STATIC_IID_ACCESSOR(NS_PROXYEVENT_IID)
7454
7455 nsProxyObjectCallInfo(nsProxyEventObject* owner,
7456 const XPTMethodDescriptor *methodInfo,
7457 PRUint32 methodIndex,
7458 nsXPTCVariant* parameterList,
7459 PRUint32 parameterCount);
7460diff --git a/xpcom/proxy/src/nsProxyObjectManager.cpp b/xpcom/proxy/src/nsProxyObjectManager.cpp
7461--- a/xpcom/proxy/src/nsProxyObjectManager.cpp
7462+++ b/xpcom/proxy/src/nsProxyObjectManager.cpp
7463@@ -232,39 +232,43 @@ nsProxyObjectManager::GetProxyForObject(
7464 nsCOMPtr<nsISupports> realEQ = do_QueryInterface(aTarget);
7465
7466 nsProxyEventKey rootKey(realObj, realEQ, proxyType);
7467
7468 {
7469 MutexAutoLock lock(mProxyCreationLock);
7470 nsProxyLockedRefPtr root =
7471 (nsProxyObject*) mProxyObjectMap.Get(&rootKey);
7472- if (root)
7473- return root->LockedFind(aIID, aProxyObject);
7474+ if (root) {
7475+ *aProxyObject = root->LockedFind(aIID);
7476+ return (*aProxyObject) ? NS_OK : NS_ERROR_NO_INTERFACE;
7477+ }
7478 }
7479
7480 // don't lock while creating the nsProxyObject
7481 nsProxyObject *newRoot = new nsProxyObject(aTarget, proxyType, realObj);
7482 if (!newRoot)
7483 return NS_ERROR_OUT_OF_MEMORY;
7484
7485 // lock again, and check for a race putting into mProxyObjectMap
7486 {
7487 MutexAutoLock lock(mProxyCreationLock);
7488 nsProxyLockedRefPtr root =
7489 (nsProxyObject*) mProxyObjectMap.Get(&rootKey);
7490 if (root) {
7491 delete newRoot;
7492- return root->LockedFind(aIID, aProxyObject);
7493+ *aProxyObject = root->LockedFind(aIID);
7494+ return (*aProxyObject) ? NS_OK : NS_ERROR_NO_INTERFACE;
7495 }
7496
7497 mProxyObjectMap.Put(&rootKey, newRoot);
7498
7499 nsProxyLockedRefPtr kungFuDeathGrip(newRoot);
7500- return newRoot->LockedFind(aIID, aProxyObject);
7501+ *aProxyObject = newRoot->LockedFind(aIID);
7502+ return (*aProxyObject) ? NS_OK : NS_ERROR_NO_INTERFACE;
7503 }
7504 }
7505
7506 void
7507 nsProxyObjectManager::LockedRemove(nsProxyObject *aProxy)
7508 {
7509 nsCOMPtr<nsISupports> realEQ = do_QueryInterface(aProxy->GetTarget());
7510
7511diff --git a/xpcom/proxy/tests/proxy-create-threadsafety.cpp b/xpcom/proxy/tests/proxy-create-threadsafety.cpp
7512--- a/xpcom/proxy/tests/proxy-create-threadsafety.cpp
7513+++ b/xpcom/proxy/tests/proxy-create-threadsafety.cpp
7514@@ -156,20 +156,18 @@ public:
7515 return NS_ERROR_NOT_IMPLEMENTED;
7516 }
7517
7518 NS_IMETHOD GetType(PRUint16 *_retval)
7519 {
7520 return NS_ERROR_NOT_IMPLEMENTED;
7521 }
7522
7523- NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr)
7524+ NS_IMETHOD_(void*) QueryInterfaceFast(REFNSIID aIID)
7525 {
7526- NS_ASSERTION(aInstancePtr,
7527- "QueryInterface requires a non-NULL destination!");
7528 nsISupports* foundInterface;
7529 if ( aIID.Equals(NS_GET_IID(nsIRunnable)) ) {
7530 foundInterface = static_cast<nsIRunnable*>(this);
7531 } else if ( aIID.Equals(NS_GET_IID(nsITestProxy)) ) {
7532 foundInterface = static_cast<nsITestProxy*>(this);
7533 } else if ( aIID.Equals(NS_GET_IID(nsISupports)) ) {
7534 foundInterface = NS_ISUPPORTS_CAST(nsIRunnable*, this);
7535 } else if ( aIID.Equals(NS_GET_IID(nsISupportsPrimitive)) ) {
7536@@ -178,50 +176,45 @@ public:
7537 switch(mCounter) {
7538 case 0:
7539 ++mCounter;
7540 {
7541 /* be evil here and hang */
7542 MutexAutoUnlock counterUnlock(mCounterLock);
7543 ReentrantMonitorAutoEnter evilReentrantMonitor(mEvilReentrantMonitor);
7544 nsresult rv = evilReentrantMonitor.Wait();
7545- NS_ENSURE_SUCCESS(rv, rv);
7546+ NS_ENSURE_SUCCESS(rv, nsnull);
7547 break;
7548 }
7549 case 1:
7550 ++mCounter;
7551 {
7552 /* okay, we had our fun, un-hang */
7553 MutexAutoUnlock counterUnlock(mCounterLock);
7554 ReentrantMonitorAutoEnter evilReentrantMonitor(mEvilReentrantMonitor);
7555 nsresult rv = evilReentrantMonitor.Notify();
7556- NS_ENSURE_SUCCESS(rv, rv);
7557+ NS_ENSURE_SUCCESS(rv, nsnull);
7558 break;
7559 }
7560 default: {
7561 /* nothing special here */
7562 ++mCounter;
7563 }
7564 }
7565 ++mCounter;
7566 }
7567 // remeber to admit to supporting this interface
7568 foundInterface = static_cast<nsISupportsPrimitive*>(this);
7569 } else {
7570 foundInterface = nsnull;
7571 }
7572- nsresult status;
7573- if (!foundInterface) {
7574- status = NS_ERROR_NO_INTERFACE;
7575- } else {
7576+ if (foundInterface) {
7577 NS_ADDREF(foundInterface);
7578- status = NS_OK;
7579 }
7580- *aInstancePtr = foundInterface;
7581- return status;
7582+ return foundInterface;
7583 }
7584
7585 NS_IMETHOD_(nsrefcnt) AddRef(void);
7586 NS_IMETHOD_(nsrefcnt) Release(void);
7587
7588 protected:
7589 nsAutoRefCnt mRefCnt;
7590 NS_DECL_OWNINGTHREAD
7591diff --git a/xpcom/reflect/xptcall/src/xptcall.cpp b/xpcom/reflect/xptcall/src/xptcall.cpp
7592--- a/xpcom/reflect/xptcall/src/xptcall.cpp
7593+++ b/xpcom/reflect/xptcall/src/xptcall.cpp
7594@@ -35,27 +35,25 @@
7595 *
7596 * ***** END LICENSE BLOCK ***** */
7597
7598 /* entry point wrappers. */
7599
7600 #include "xptcprivate.h"
7601 #include "xptiprivate.h"
7602
7603-NS_IMETHODIMP
7604-nsXPTCStubBase::QueryInterface(REFNSIID aIID,
7605- void **aInstancePtr)
7606+NS_IMETHODIMP_(void*)
7607+nsXPTCStubBase::QueryInterfaceFast(REFNSIID aIID)
7608 {
7609 if (aIID.Equals(mEntry->IID())) {
7610 NS_ADDREF_THIS();
7611- *aInstancePtr = static_cast<nsISupports*>(this);
7612- return NS_OK;
7613+ return static_cast<nsISupports*>(this);
7614 }
7615
7616- return mOuter->QueryInterface(aIID, aInstancePtr);
7617+ return mOuter->QueryInterfaceFast(aIID);
7618 }
7619
7620 NS_IMETHODIMP_(nsrefcnt)
7621 nsXPTCStubBase::AddRef()
7622 {
7623 return mOuter->AddRef();
7624 }
7625
7626diff --git a/xpcom/reflect/xptcall/tests/TestXPTCInvoke.cpp b/xpcom/reflect/xptcall/tests/TestXPTCInvoke.cpp
7627--- a/xpcom/reflect/xptcall/tests/TestXPTCInvoke.cpp
7628+++ b/xpcom/reflect/xptcall/tests/TestXPTCInvoke.cpp
7629@@ -1162,44 +1162,34 @@ FooBarImpl::FooBarImpl() : MyName("FooBa
7630 NS_ADDREF_THIS();
7631 }
7632
7633 const char* FooBarImpl::ImplName()
7634 {
7635 return MyName;
7636 }
7637
7638-NS_IMETHODIMP
7639-FooBarImpl::QueryInterface(REFNSIID aIID, void** aInstancePtr)
7640+NS_IMETHODIMP_(void*)
7641+FooBarImpl::QueryInterfaceFast(REFNSIID aIID)
7642 {
7643- if (NULL == aInstancePtr) {
7644- return NS_ERROR_NULL_POINTER;
7645- }
7646-
7647- *aInstancePtr = NULL;
7648-
7649-
7650 if (aIID.Equals(NS_GET_IID(nsIFoo))) {
7651- *aInstancePtr = (void*) static_cast<nsIFoo*>(this);
7652 NS_ADDREF_THIS();
7653- return NS_OK;
7654+ return (void*) static_cast<nsIFoo*>(this);
7655 }
7656 if (aIID.Equals(NS_GET_IID(nsIBar))) {
7657- *aInstancePtr = (void*) static_cast<nsIBar*>(this);
7658 NS_ADDREF_THIS();
7659- return NS_OK;
7660+ return (void*) static_cast<nsIBar*>(this);
7661 }
7662
7663 if (aIID.Equals(NS_GET_IID(nsISupports))) {
7664- *aInstancePtr = (void*) static_cast<nsISupports*>
7665- (static_cast<nsIFoo*>(this));
7666 NS_ADDREF_THIS();
7667- return NS_OK;
7668+ return (void*) static_cast<nsISupports*>
7669+ (static_cast<nsIFoo*>(this));
7670 }
7671- return NS_NOINTERFACE;
7672+ return nsnull;
7673 }
7674
7675 NS_IMPL_ADDREF(FooBarImpl)
7676 NS_IMPL_RELEASE(FooBarImpl)
7677
7678
7679 static void DoMultipleInheritenceTest()
7680 {
7681@@ -1208,18 +1198,18 @@ static void DoMultipleInheritenceTest()
7682 return;
7683
7684 nsIFoo* foo;
7685 nsIBar* bar;
7686
7687 nsXPTCVariant var[1];
7688
7689 printf("\n");
7690- if(NS_SUCCEEDED(impl->QueryInterface(NS_GET_IID(nsIFoo), (void**)&foo)) &&
7691- NS_SUCCEEDED(impl->QueryInterface(NS_GET_IID(nsIBar), (void**)&bar)))
7692+ if ((foo = impl->QueryInterfaceFast(NS_GET_IID(nsIFoo))) &&
7693+ (bar = impl->QueryInterfaceFast(NS_GET_IID(nsIBar))))
7694 {
7695 printf("impl == %p\n", static_cast<void*>(impl));
7696 printf("foo == %p\n", static_cast<void*>(foo));
7697 printf("bar == %p\n", static_cast<void*>(bar));
7698
7699 printf("Calling Foo...\n");
7700 printf("direct calls:\n");
7701 foo->FooMethod1(1);
7702@@ -1333,44 +1323,34 @@ NS_IMETHODIMP FooBarImpl2::BarMethod1(PR
7703
7704 NS_IMETHODIMP FooBarImpl2::BarMethod2(PRInt32 i)
7705 {
7706 printf("\tFooBarImpl2::BarMethod2 called with i == %d, local value = %x\n",
7707 i, value);
7708 return NS_OK;
7709 }
7710
7711-NS_IMETHODIMP
7712-FooBarImpl2::QueryInterface(REFNSIID aIID, void** aInstancePtr)
7713+NS_IMETHODIMP_(void*)
7714+FooBarImpl2::QueryInterfaceFast(REFNSIID aIID)
7715 {
7716- if (NULL == aInstancePtr) {
7717- return NS_ERROR_NULL_POINTER;
7718- }
7719-
7720- *aInstancePtr = NULL;
7721-
7722-
7723 if (aIID.Equals(NS_GET_IID(nsIFoo))) {
7724- *aInstancePtr = (void*) static_cast<nsIFoo2*>(this);
7725 NS_ADDREF_THIS();
7726- return NS_OK;
7727+ return (void*) static_cast<nsIFoo2*>(this);
7728 }
7729 if (aIID.Equals(NS_GET_IID(nsIBar))) {
7730- *aInstancePtr = (void*) static_cast<nsIBar2*>(this);
7731 NS_ADDREF_THIS();
7732- return NS_OK;
7733+ return (void*) static_cast<nsIBar2*>(this);
7734 }
7735
7736 if (aIID.Equals(NS_GET_IID(nsISupports))) {
7737- *aInstancePtr = (void*) static_cast<nsISupports*>
7738- (static_cast<nsIFoo2*>(this));
7739 NS_ADDREF_THIS();
7740- return NS_OK;
7741+ return (void*) static_cast<nsISupports*>
7742+ (static_cast<nsIFoo2*>(this));
7743 }
7744- return NS_NOINTERFACE;
7745+ return nsnull;
7746 }
7747
7748 NS_IMPL_ADDREF(FooBarImpl2)
7749 NS_IMPL_RELEASE(FooBarImpl2)
7750
7751 static void DoMultipleInheritenceTest2()
7752 {
7753 FooBarImpl2* impl = new FooBarImpl2();
7754diff --git a/xpcom/tests/TestCOMPtr.cpp b/xpcom/tests/TestCOMPtr.cpp
7755--- a/xpcom/tests/TestCOMPtr.cpp
7756+++ b/xpcom/tests/TestCOMPtr.cpp
7757@@ -50,19 +50,17 @@ class IFoo : public nsISupports
7758 public:
7759 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IFOO_IID)
7760
7761 public:
7762 IFoo();
7763 // virtual dtor because IBar uses our Release()
7764 virtual ~IFoo();
7765
7766- NS_IMETHOD_(nsrefcnt) AddRef();
7767- NS_IMETHOD_(nsrefcnt) Release();
7768- NS_IMETHOD QueryInterface( const nsIID&, void** );
7769+ NS_DECL_ISUPPORTS
7770
7771 static void print_totals();
7772
7773 private:
7774 unsigned int refcount_;
7775
7776 static unsigned int total_constructions_;
7777 static unsigned int total_destructions_;
7778@@ -158,38 +156,34 @@ IFoo::Release()
7779 printf(" delete IFoo@%p\n", static_cast<void*>(this));
7780 printf("<<IFoo@%p::Release()\n", static_cast<void*>(this));
7781 delete this;
7782 }
7783
7784 return newcount;
7785 }
7786
7787-nsresult
7788-IFoo::QueryInterface( const nsIID& aIID, void** aResult )
7789+void*
7790+IFoo::QueryInterfaceFast( const nsIID& aIID )
7791 {
7792- printf("IFoo@%p::QueryInterface()\n", static_cast<void*>(this));
7793+ printf("IFoo@%p::QueryInterfaceFast()\n", static_cast<void*>(this));
7794 nsISupports* rawPtr = 0;
7795- nsresult status = NS_OK;
7796
7797 if ( aIID.Equals(GetIID()) )
7798 rawPtr = this;
7799 else
7800 {
7801 nsID iid_of_ISupports = NS_ISUPPORTS_IID;
7802 if ( aIID.Equals(iid_of_ISupports) )
7803 rawPtr = static_cast<nsISupports*>(this);
7804- else
7805- status = NS_ERROR_NO_INTERFACE;
7806 }
7807
7808 NS_IF_ADDREF(rawPtr);
7809- *aResult = rawPtr;
7810
7811- return status;
7812+ return rawPtr;
7813 }
7814
7815 nsresult
7816 CreateIFoo( void** result )
7817 // a typical factory function (that calls AddRef)
7818 {
7819 printf(">>CreateIFoo() --> ");
7820 IFoo* foop = new IFoo;
7821@@ -233,55 +227,51 @@ class IBar : public IFoo
7822 {
7823 public:
7824 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IBAR_IID)
7825
7826 public:
7827 IBar();
7828 virtual ~IBar();
7829
7830- NS_IMETHOD QueryInterface( const nsIID&, void** );
7831+ NS_IMETHOD_(void*) QueryInterfaceFast( const nsIID& );
7832 };
7833
7834 NS_DEFINE_STATIC_IID_ACCESSOR(IBar, NS_IBAR_IID)
7835
7836 IBar::IBar()
7837 {
7838 printf(" new IBar@%p\n", static_cast<void*>(this));
7839 }
7840
7841 IBar::~IBar()
7842 {
7843 printf("IBar@%p::~IBar()\n", static_cast<void*>(this));
7844 }
7845
7846-nsresult
7847-IBar::QueryInterface( const nsID& aIID, void** aResult )
7848+void*
7849+IBar::QueryInterfaceFast( const nsID& aIID )
7850 {
7851- printf("IBar@%p::QueryInterface()\n", static_cast<void*>(this));
7852+ printf("IBar@%p::QueryInterfaceFast()\n", static_cast<void*>(this));
7853 nsISupports* rawPtr = 0;
7854- nsresult status = NS_OK;
7855
7856 if ( aIID.Equals(GetIID()) )
7857 rawPtr = this;
7858 else if ( aIID.Equals(NS_GET_IID(IFoo)) )
7859 rawPtr = static_cast<IFoo*>(this);
7860 else
7861 {
7862 nsID iid_of_ISupports = NS_ISUPPORTS_IID;
7863 if ( aIID.Equals(iid_of_ISupports) )
7864 rawPtr = static_cast<nsISupports*>(this);
7865- else
7866- status = NS_ERROR_NO_INTERFACE;
7867 }
7868
7869 NS_IF_ADDREF(rawPtr);
7870- *aResult = rawPtr;
7871
7872- return status;
7873+ return rawPtr;
7874 }
7875
7876
7877
7878 nsresult
7879 CreateIBar( void** result )
7880 // a typical factory function (that calls AddRef)
7881 {
7882diff --git a/xpcom/tests/TestHashtables.cpp b/xpcom/tests/TestHashtables.cpp
7883--- a/xpcom/tests/TestHashtables.cpp
7884+++ b/xpcom/tests/TestHashtables.cpp
7885@@ -225,19 +225,17 @@ nsCEnum(const nsACString& aKey, nsAutoPt
7886
7887 class IFoo : public nsISupports
7888 {
7889 public:
7890 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IFOO_IID)
7891
7892 IFoo();
7893
7894- NS_IMETHOD_(nsrefcnt) AddRef();
7895- NS_IMETHOD_(nsrefcnt) Release();
7896- NS_IMETHOD QueryInterface( const nsIID&, void** );
7897+ NS_DECL_ISUPPORTS
7898
7899 NS_IMETHOD SetString(const nsACString& /*in*/ aString);
7900 NS_IMETHOD GetString(nsACString& /*out*/ aString);
7901
7902 static void print_totals();
7903
7904 private:
7905 ~IFoo();
7906@@ -300,38 +298,34 @@ IFoo::Release()
7907 printf(" delete IFoo@%p\n", static_cast<void*>(this));
7908 printf("<<IFoo@%p::Release()\n", static_cast<void*>(this));
7909 delete this;
7910 }
7911
7912 return newcount;
7913 }
7914
7915-nsresult
7916-IFoo::QueryInterface( const nsIID& aIID, void** aResult )
7917+void*
7918+IFoo::QueryInterfaceFast( const nsIID& aIID )
7919 {
7920- printf("IFoo@%p::QueryInterface()\n", static_cast<void*>(this));
7921+ printf("IFoo@%p::QueryInterfaceFast()\n", static_cast<void*>(this));
7922 nsISupports* rawPtr = 0;
7923- nsresult status = NS_OK;
7924
7925 if ( aIID.Equals(GetIID()) )
7926 rawPtr = this;
7927 else
7928 {
7929 nsID iid_of_ISupports = NS_ISUPPORTS_IID;
7930 if ( aIID.Equals(iid_of_ISupports) )
7931 rawPtr = static_cast<nsISupports*>(this);
7932- else
7933- status = NS_ERROR_NO_INTERFACE;
7934 }
7935
7936 NS_IF_ADDREF(rawPtr);
7937- *aResult = rawPtr;
7938
7939- return status;
7940+ return rawPtr;
7941 }
7942
7943 nsresult
7944 IFoo::SetString(const nsACString& aString)
7945 {
7946 mString = aString;
7947 return NS_OK;
7948 }
7949diff --git a/xpcom/tests/TestRefPtr.cpp b/xpcom/tests/TestRefPtr.cpp
7950--- a/xpcom/tests/TestRefPtr.cpp
7951+++ b/xpcom/tests/TestRefPtr.cpp
7952@@ -51,19 +51,17 @@ class Foo : public nsISupports
7953 public:
7954 NS_DECLARE_STATIC_IID_ACCESSOR(NS_FOO_IID)
7955
7956 public:
7957 Foo();
7958 // virtual dtor because Bar uses our Release()
7959 virtual ~Foo();
7960
7961- NS_IMETHOD_(nsrefcnt) AddRef();
7962- NS_IMETHOD_(nsrefcnt) Release();
7963- NS_IMETHOD QueryInterface( const nsIID&, void** );
7964+ NS_DECL_ISUPPORTS
7965
7966 static void print_totals();
7967
7968 private:
7969 unsigned int refcount_;
7970
7971 static unsigned int total_constructions_;
7972 static unsigned int total_destructions_;
7973@@ -159,38 +157,34 @@ Foo::Release()
7974 printf(" delete Foo@%p\n", static_cast<void*>(this));
7975 printf("<<Foo@%p::Release()\n", static_cast<void*>(this));
7976 delete this;
7977 }
7978
7979 return newcount;
7980 }
7981
7982-nsresult
7983-Foo::QueryInterface( const nsIID& aIID, void** aResult )
7984+void*
7985+Foo::QueryInterfaceFast( const nsIID& aIID )
7986 {
7987- printf("Foo@%p::QueryInterface()\n", static_cast<void*>(this));
7988+ printf("Foo@%p::QueryInterfaceFast()\n", static_cast<void*>(this));
7989 nsISupports* rawPtr = 0;
7990- nsresult status = NS_OK;
7991
7992 if ( aIID.Equals(GetIID()) )
7993 rawPtr = this;
7994 else
7995 {
7996 nsID iid_of_ISupports = NS_ISUPPORTS_IID;
7997 if ( aIID.Equals(iid_of_ISupports) )
7998 rawPtr = static_cast<nsISupports*>(this);
7999- else
8000- status = NS_ERROR_NO_INTERFACE;
8001 }
8002
8003 NS_IF_ADDREF(rawPtr);
8004- *aResult = rawPtr;
8005
8006- return status;
8007+ return rawPtr;
8008 }
8009
8010 nsresult
8011 CreateFoo( void** result )
8012 // a typical factory function (that calls AddRef)
8013 {
8014 printf(">>CreateFoo() --> ");
8015 Foo* foop = new Foo;
8016@@ -234,55 +228,51 @@ class Bar : public Foo
8017 {
8018 public:
8019 NS_DECLARE_STATIC_IID_ACCESSOR(NS_BAR_IID)
8020
8021 public:
8022 Bar();
8023 virtual ~Bar();
8024
8025- NS_IMETHOD QueryInterface( const nsIID&, void** );
8026+ NS_IMETHOD_(void*) QueryInterfaceFast( const nsIID& );
8027 };
8028
8029 NS_DEFINE_STATIC_IID_ACCESSOR(Bar, NS_BAR_IID)
8030
8031 Bar::Bar()
8032 {
8033 printf(" new Bar@%p\n", static_cast<void*>(this));
8034 }
8035
8036 Bar::~Bar()
8037 {
8038 printf("Bar@%p::~Bar()\n", static_cast<void*>(this));
8039 }
8040
8041-nsresult
8042-Bar::QueryInterface( const nsID& aIID, void** aResult )
8043+void*
8044+Bar::QueryInterfaceFast( const nsID& aIID )
8045 {
8046- printf("Bar@%p::QueryInterface()\n", static_cast<void*>(this));
8047+ printf("Bar@%p::QueryInterfaceFast()\n", static_cast<void*>(this));
8048 nsISupports* rawPtr = 0;
8049- nsresult status = NS_OK;
8050
8051 if ( aIID.Equals(GetIID()) )
8052 rawPtr = this;
8053 else if ( aIID.Equals(NS_GET_IID(Foo)) )
8054 rawPtr = static_cast<Foo*>(this);
8055 else
8056 {
8057 nsID iid_of_ISupports = NS_ISUPPORTS_IID;
8058 if ( aIID.Equals(iid_of_ISupports) )
8059 rawPtr = static_cast<nsISupports*>(this);
8060- else
8061- status = NS_ERROR_NO_INTERFACE;
8062 }
8063
8064 NS_IF_ADDREF(rawPtr);
8065- *aResult = rawPtr;
8066
8067- return status;
8068+ return rawPtr;
8069 }
8070
8071
8072
8073 nsresult
8074 CreateBar( void** result )
8075 // a typical factory function (that calls AddRef)
8076 {
8077diff --git a/xpfe/appshell/src/nsChromeTreeOwner.cpp b/xpfe/appshell/src/nsChromeTreeOwner.cpp
8078--- a/xpfe/appshell/src/nsChromeTreeOwner.cpp
8079+++ b/xpfe/appshell/src/nsChromeTreeOwner.cpp
8080@@ -159,20 +159,22 @@ NS_IMETHODIMP nsChromeTreeOwner::GetInte
8081 return mXULWindow->GetInterface(aIID, aSink);
8082 }
8083 if (aIID.Equals(NS_GET_IID(nsIEmbeddingSiteWindow2))) {
8084 NS_ENSURE_STATE(mXULWindow);
8085 return mXULWindow->GetInterface(aIID, aSink);
8086 }
8087 if (aIID.Equals(NS_GET_IID(nsIXULWindow))) {
8088 NS_ENSURE_STATE(mXULWindow);
8089- return mXULWindow->QueryInterface(aIID, aSink);
8090+ *aSink = mXULWindow->QueryInterfaceFast(aIID);
8091+ return (*aSink) ? NS_OK : NS_ERROR_NO_INTERFACE;
8092 }
8093
8094- return QueryInterface(aIID, aSink);
8095+ *aSink = QueryInterfaceFast(aIID);
8096+ return (*aSink) ? NS_OK : NS_ERROR_NO_INTERFACE;
8097 }
8098
8099 //*****************************************************************************
8100 // nsChromeTreeOwner::nsIDocShellTreeOwner
8101 //*****************************************************************************
8102
8103 NS_IMETHODIMP nsChromeTreeOwner::FindItemWithName(const PRUnichar* aName,
8104 nsIDocShellTreeItem* aRequestor, nsIDocShellTreeItem* aOriginalRequestor,
8105diff --git a/xpfe/appshell/src/nsContentTreeOwner.cpp b/xpfe/appshell/src/nsContentTreeOwner.cpp
8106--- a/xpfe/appshell/src/nsContentTreeOwner.cpp
8107+++ b/xpfe/appshell/src/nsContentTreeOwner.cpp
8108@@ -179,20 +179,22 @@ NS_IMETHODIMP nsContentTreeOwner::GetInt
8109 if (thing)
8110 return thing->GetInterface(aIID, aSink);
8111 }
8112 return NS_ERROR_FAILURE;
8113 }
8114
8115 if (aIID.Equals(NS_GET_IID(nsIXULWindow))) {
8116 NS_ENSURE_STATE(mXULWindow);
8117- return mXULWindow->QueryInterface(aIID, aSink);
8118+ *aSink = mXULWindow->QueryInterfaceFast(aIID);
8119+ return (*aSink) ? NS_OK : NS_ERROR_NO_INTERFACE;
8120 }
8121
8122- return QueryInterface(aIID, aSink);
8123+ *aSink = QueryInterfaceFast(aIID);
8124+ return (*aSink) ? NS_OK : NS_ERROR_NO_INTERFACE;
8125 }
8126
8127 //*****************************************************************************
8128 // nsContentTreeOwner::nsIDocShellTreeOwner
8129 //*****************************************************************************
8130
8131 NS_IMETHODIMP nsContentTreeOwner::FindItemWithName(const PRUnichar* aName,
8132 nsIDocShellTreeItem* aRequestor, nsIDocShellTreeItem* aOriginalRequestor,
8133diff --git a/xpfe/appshell/src/nsXULWindow.cpp b/xpfe/appshell/src/nsXULWindow.cpp
8134--- a/xpfe/appshell/src/nsXULWindow.cpp
8135+++ b/xpfe/appshell/src/nsXULWindow.cpp
8136@@ -206,29 +206,30 @@ NS_IMETHODIMP nsXULWindow::GetInterface(
8137 rv = GetWindowDOMWindow(&domWindow);
8138 nsIDOMWindowInternal* domWindowInternal =
8139 static_cast<nsIDOMWindowInternal*>(domWindow);
8140 *aSink = domWindowInternal;
8141 return rv;
8142 }
8143 if (aIID.Equals(NS_GET_IID(nsIWebBrowserChrome)) &&
8144 NS_SUCCEEDED(EnsureContentTreeOwner()) &&
8145- NS_SUCCEEDED(mContentTreeOwner->QueryInterface(aIID, aSink)))
8146+ (*aSink = mContentTreeOwner->QueryInterfaceFast(aIID)))
8147 return NS_OK;
8148
8149 if (aIID.Equals(NS_GET_IID(nsIEmbeddingSiteWindow)) &&
8150 NS_SUCCEEDED(EnsureContentTreeOwner()) &&
8151- NS_SUCCEEDED(mContentTreeOwner->QueryInterface(aIID, aSink)))
8152+ (*aSink = mContentTreeOwner->QueryInterfaceFast(aIID)))
8153 return NS_OK;
8154 if (aIID.Equals(NS_GET_IID(nsIEmbeddingSiteWindow2)) &&
8155 NS_SUCCEEDED(EnsureContentTreeOwner()) &&
8156- NS_SUCCEEDED(mContentTreeOwner->QueryInterface(aIID, aSink)))
8157+ (*aSink = mContentTreeOwner->QueryInterfaceFast(aIID)))
8158 return NS_OK;
8159
8160- return QueryInterface(aIID, aSink);
8161+ *aSink = QueryInterfaceFast(aIID);
8162+ return (*aSink) ? NS_OK : NS_ERROR_NO_INTERFACE;
8163 }
8164
8165 //*****************************************************************************
8166 // nsXULWindow::nsIXULWindow
8167 //*****************************************************************************
8168
8169 NS_IMETHODIMP nsXULWindow::GetDocShell(nsIDocShell** aDocShell)
8170 {