diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index a0572104d46..f9e95226c1d 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -56,7 +56,6 @@ #include "prlog.h" #include "prprf.h" #include -#include "nsIPtr.h" #include "nsISizeOfHandler.h" #include "nsIFrameManager.h" #ifdef ACCESSIBILITY diff --git a/mozilla/layout/generic/nsHTMLContainerFrame.cpp b/mozilla/layout/generic/nsHTMLContainerFrame.cpp index 07893b6295b..26c554d7b84 100644 --- a/mozilla/layout/generic/nsHTMLContainerFrame.cpp +++ b/mozilla/layout/generic/nsHTMLContainerFrame.cpp @@ -49,7 +49,6 @@ #include "nsGUIEvent.h" #include "nsIDocument.h" #include "nsIURL.h" -#include "nsIPtr.h" #include "nsPlaceholderFrame.h" #include "nsIHTMLContent.h" #include "nsHTMLParts.h" diff --git a/mozilla/layout/html/base/src/nsFrame.cpp b/mozilla/layout/html/base/src/nsFrame.cpp index a0572104d46..f9e95226c1d 100644 --- a/mozilla/layout/html/base/src/nsFrame.cpp +++ b/mozilla/layout/html/base/src/nsFrame.cpp @@ -56,7 +56,6 @@ #include "prlog.h" #include "prprf.h" #include -#include "nsIPtr.h" #include "nsISizeOfHandler.h" #include "nsIFrameManager.h" #ifdef ACCESSIBILITY diff --git a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp index 07893b6295b..26c554d7b84 100644 --- a/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp +++ b/mozilla/layout/html/base/src/nsHTMLContainerFrame.cpp @@ -49,7 +49,6 @@ #include "nsGUIEvent.h" #include "nsIDocument.h" #include "nsIURL.h" -#include "nsIPtr.h" #include "nsPlaceholderFrame.h" #include "nsIHTMLContent.h" #include "nsHTMLParts.h" diff --git a/mozilla/layout/html/table/src/nsTableOuterFrame.cpp b/mozilla/layout/html/table/src/nsTableOuterFrame.cpp index 7d0bc101bdd..cd77fdd51e4 100644 --- a/mozilla/layout/html/table/src/nsTableOuterFrame.cpp +++ b/mozilla/layout/html/table/src/nsTableOuterFrame.cpp @@ -45,7 +45,6 @@ #include "nsCSSRendering.h" #include "nsIContent.h" #include "nsVoidArray.h" -#include "nsIPtr.h" #include "prinrval.h" #include "nsHTMLIIDs.h" #include "nsLayoutAtoms.h" diff --git a/mozilla/layout/tables/nsTableOuterFrame.cpp b/mozilla/layout/tables/nsTableOuterFrame.cpp index 7d0bc101bdd..cd77fdd51e4 100644 --- a/mozilla/layout/tables/nsTableOuterFrame.cpp +++ b/mozilla/layout/tables/nsTableOuterFrame.cpp @@ -45,7 +45,6 @@ #include "nsCSSRendering.h" #include "nsIContent.h" #include "nsVoidArray.h" -#include "nsIPtr.h" #include "prinrval.h" #include "nsHTMLIIDs.h" #include "nsLayoutAtoms.h" diff --git a/mozilla/xpcom/base/MANIFEST b/mozilla/xpcom/base/MANIFEST index 8560f2faa18..6ea10174efb 100644 --- a/mozilla/xpcom/base/MANIFEST +++ b/mozilla/xpcom/base/MANIFEST @@ -6,7 +6,6 @@ nsCWeakReference.h nsError.h nsID.h nsIID.h -nsIPtr.h nsISupportsBase.h nsISupportsImpl.h nsISupportsUtils.h diff --git a/mozilla/xpcom/base/Makefile.in b/mozilla/xpcom/base/Makefile.in index 43284242724..7766ddaf513 100644 --- a/mozilla/xpcom/base/Makefile.in +++ b/mozilla/xpcom/base/Makefile.in @@ -61,7 +61,6 @@ EXPORTS = \ nsError.h \ nsID.h \ nsIID.h \ - nsIPtr.h \ nsISupportsBase.h \ nsISupportsImpl.h \ nsISupportsUtils.h \ diff --git a/mozilla/xpcom/base/makefile.win b/mozilla/xpcom/base/makefile.win index 8be3115bdd8..d6684cb8d92 100644 --- a/mozilla/xpcom/base/makefile.win +++ b/mozilla/xpcom/base/makefile.win @@ -42,7 +42,6 @@ EXPORTS = \ nsError.h \ nsID.h \ nsIID.h \ - nsIPtr.h \ nsISupportsBase.h \ nsISupportsImpl.h \ nsISupportsObsolete.h \ diff --git a/mozilla/xpcom/base/nsIPtr.h b/mozilla/xpcom/base/nsIPtr.h deleted file mode 100644 index e53b89b5801..00000000000 --- a/mozilla/xpcom/base/nsIPtr.h +++ /dev/null @@ -1,179 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: NPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Netscape Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the NPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the NPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef nsIPtr_h___ -#define nsIPtr_h___ - -#include "nsISupports.h" - -/* - * nsIPtr is an "auto-release pointer" class for nsISupports based interfaces - * - * It's intent is to be a "set and forget" pointer to help with managing - * active references to nsISupports bases objects. - * - * The pointer object ensures that the underlying pointer is always - * released whenever the value is changed or when the object leaves scope. - * - * Proper care needs to be taken when assigning pointers to a nsIPtr. - * When asigning from a C pointer (nsISupports*), the pointer presumes - * an active reference and subsumes it. When assigning from another nsIPtr, - * a new reference is established. - * - * There are 3 ways to assign a value to a nsIPtr. - * 1) Direct construction or assignment from a C pointer. - * 2) Direct construction or assignment form another nsIPtr. - * 3) Usage of an "out parameter" method. - * a) AssignRef() releases the underlying pointer and returns a reference to it. - * Useful for pointer reference out paramaters. - * b) AssignPtr() releases the underlying pointer and returns a pointer to it. - * c) Query() releases the underlying pointer and returns a (void**) pointer to it. - * Useful for calls to QueryInterface() - * 4) The SetAddRef() method. This is equivalent to an assignment followed by an AddRef(). - * - * examples: - * - * class It { - * void NS_NewFoo(nsIFoo** aFoo); - * nsIFoo* GetFoo(void); - * void GetBar(nsIBar*& aBar); - * }; - * - * nsIFooPtr foo = it->GetFoo(); - * nsIBarPtr bar; - * - * it->NS_NewFoo(foo.AssignPtr()); - * it->GetBar(bar.AssignRef()); - * it->QueryInterface(kIFooIID, foo.Query()); - * bar.SetAddRef(new Bar()); - * - * Advantages: - * Set and forget. Once a pointer is assigned to a nsIPtr, it is impossible - * to forget to release it. - * Always pre-initialized. You can't forget to initialize the pointer. - * - * Disadvantages: - * Usage of this class doesn't eliminate the need to think about ref counts - * and assign values properly, AddRef'ing as needed. - * The nsIPtr doesn't typecast exactly like a C pointer. In order to achieve - * typecasting, it may be necessary to first cast to a C pointer of the - * underlying type. - * - */ - -#define NS_DEF_PTR1(cls) \ -class cls##Ptr { \ -public: \ - cls##Ptr(void) : mPtr(0) {} \ - cls##Ptr(const cls##Ptr& aCopy) : mPtr(aCopy.mPtr) \ - { NS_IF_ADDREF(mPtr); } \ - cls##Ptr(cls* aInterface) : mPtr(aInterface) {} \ - ~cls##Ptr(void) { NS_IF_RELEASE(mPtr); } \ - cls##Ptr& operator=(const cls##Ptr& aCopy) \ - { if(mPtr == aCopy.mPtr) return *this; \ - NS_IF_ADDREF(aCopy.mPtr); \ - NS_IF_RELEASE(mPtr); \ - mPtr = aCopy.mPtr; return *this; } \ - cls##Ptr& operator=(cls* aInterface) \ - { if(mPtr == aInterface) return *this; \ - NS_IF_RELEASE(mPtr); mPtr = aInterface; \ - return *this; } \ - cls##Ptr& operator=(PRInt32 aInt) \ - { NS_IF_RELEASE(mPtr); \ - return *this; } \ - void SetAddRef(cls* aInterface) \ - { if(aInterface == mPtr) return; \ - NS_IF_ADDREF(aInterface); \ - NS_IF_RELEASE(mPtr); mPtr = aInterface; } \ - cls* AddRef(void) { NS_ADDREF(mPtr); return mPtr; } \ - cls* IfAddRef(void) \ - { NS_IF_ADDREF(mPtr); return mPtr; } \ - cls*& AssignRef(void) \ - { NS_IF_RELEASE(mPtr); return mPtr; } \ - cls** AssignPtr(void) \ - { NS_IF_RELEASE(mPtr); return &mPtr; } \ - void** Query(void) \ - { NS_IF_RELEASE(mPtr); return (void**)&mPtr; } \ - PRBool IsNull() const \ - { return PRBool(0 == mPtr); } \ - PRBool IsNotNull() const \ - { return PRBool(0 != mPtr); } \ - PRBool operator==(const cls##Ptr& aCopy) const \ - { return PRBool(mPtr == aCopy.mPtr); } \ - PRBool operator==(cls* aInterface) const \ - { return PRBool(mPtr == aInterface); } \ - PRBool operator!=(const cls##Ptr& aCopy) const \ - { return PRBool(mPtr != aCopy.mPtr); } \ - PRBool operator!=(cls* aInterface) const \ - { return PRBool(mPtr != aInterface); } \ - cls* operator->(void) { return mPtr; } \ - cls& operator*(void) { return *mPtr; } \ - operator cls*(void) { return mPtr; } \ - const cls* operator->(void) const { return mPtr; } \ - const cls& operator*(void) const { return *mPtr; } \ - operator const cls* (void) const { return mPtr; } - -#if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)) -#define NS_DEF_PTR2(cls) \ -private: \ - void* operator new(size_t size) throw () { return 0; } \ - void operator delete(void* aPtr) {} \ - cls* mPtr; -#else -#define NS_DEF_PTR2(cls) \ -private: \ - void* operator new(size_t size) { return 0; } \ - void operator delete(void* aPtr) {} \ - cls* mPtr; -#endif /* gcc 2.95 */ - -#define NS_DEF_PTR3(cls) \ -public: \ -friend inline PRBool operator==(const cls* aInterface, const cls##Ptr& aPtr) \ -{ return PRBool(aInterface == aPtr.mPtr); } \ -friend inline PRBool operator!=(const cls* aInterface, const cls##Ptr& aPtr) \ -{ return PRBool(aInterface != aPtr.mPtr); } \ -} - -#define NS_DEF_PTR(cls) \ - NS_DEF_PTR1(cls) \ - NS_DEF_PTR2(cls) \ - NS_DEF_PTR3(cls) - - -#endif // nsIPtr_h___ - diff --git a/mozilla/xpcom/tests/SizeTest01.cpp b/mozilla/xpcom/tests/SizeTest01.cpp index 28376ec43cc..2d552a366c5 100644 --- a/mozilla/xpcom/tests/SizeTest01.cpp +++ b/mozilla/xpcom/tests/SizeTest01.cpp @@ -2,16 +2,13 @@ #include "nsIDOMNode.h" #include "nsCOMPtr.h" -#include "nsIPtr.h" - - +#include "nsString.h" NS_DEF_PTR(nsIDOMNode); /* This test file compares the generated code size of similar functions between raw - COM interface pointers (|AddRef|ing and |Release|ing by hand), |nsCOMPtr|s, and - the smart-pointer macro defined in "nsIPtr.h". + COM interface pointers (|AddRef|ing and |Release|ing by hand) and |nsCOMPtr|s. Function size results were determined by examining dissassembly of the generated code. mXXX is the size of the generated code on the Macintosh. wXXX is the size on Windows. @@ -19,7 +16,7 @@ NS_DEF_PTR(nsIDOMNode); disabled (just as we build for release). The tests in this file explore only the simplest functionality: assigning a pointer - to be reference counted into a [raw, nsCOMPtr, nsIPtr] object; ensuring that it is + to be reference counted into a [raw, nsCOMPtr] object; ensuring that it is |AddRef|ed and |Release|d appropriately; calling through the pointer to a function supplied by the underlying COM interface. @@ -29,24 +26,16 @@ NS_DEF_PTR(nsIDOMNode); nsCOMPtr_optimized* 38 nsCOMPtr_optimized 42 nsCOMPtr 46 - nsIPtr, nsIPtr_optimized 34 + 196 - Macintosh: raw_optimized, nsCOMPtr_optimized 112 bytes (1.0000) nsCOMPtr 120 (1.0714) i.e., 7.14% bigger than raw_optimized et al - nsIPtr_optimized 124 (1.1071) - nsIPtr 136 (1.2143) raw 140 (1.2500) The overall difference in size between Windows and Macintosh is caused by the the PowerPC RISC architecture where every instruction is 4 bytes. - Also note that on Windows, nsIPtr generates a out-of-line destructors - which _are_ used, totalling an additional 196 bytes of code space per class used, - per file it is used in. - - On Macintosh, both nsCOMPtr and nsIPtr generate out-of-line destructors which are + On Macintosh, nsCOMPtr generates out-of-line destructors which are not referenced, and which can be stripped by the linker. */ @@ -116,26 +105,3 @@ Test01_nsCOMPtr_optimized( nsIDOMNode* aDOMNode, nsString* aResult ) nsCOMPtr node = aDOMNode; node->GetNodeName(*aResult); } - -void -Test01_nsIPtr( nsIDOMNode* aDOMNode, nsString* aResult ) - // m136, w34 - { - nsIDOMNodePtr node = aDOMNode; - node.AddRef(); - - if ( node.IsNotNull() ) - node->GetNodeName(*aResult); - } - -void -Test01_nsIPtr_optimized( nsIDOMNode* aDOMNode, nsString* aResult ) - // m124, w34 - { -// if ( !aDOMNode ) -// return; - - nsIDOMNodePtr node = aDOMNode; - node.AddRef(); - node->GetNodeName(*aResult); - } diff --git a/mozilla/xpcom/tests/SizeTest02.cpp b/mozilla/xpcom/tests/SizeTest02.cpp index c022f10db55..8515fcb1b26 100644 --- a/mozilla/xpcom/tests/SizeTest02.cpp +++ b/mozilla/xpcom/tests/SizeTest02.cpp @@ -2,7 +2,7 @@ #include "nsIDOMNode.h" #include "nsCOMPtr.h" -#include "nsIPtr.h" +#include "nsString.h" #ifdef __MWERKS__ #pragma exceptions off @@ -12,8 +12,7 @@ NS_DEF_PTR(nsIDOMNode); /* This test file compares the generated code size of similar functions between raw - COM interface pointers (|AddRef|ing and |Release|ing by hand), |nsCOMPtr|s, and - the smart-pointer macro defined in "nsIPtr.h". + COM interface pointers (|AddRef|ing and |Release|ing by hand) and |nsCOMPtr|s. Function size results were determined by examining dissassembly of the generated code. mXXX is the size of the generated code on the Macintosh. wXXX is the size on Windows. @@ -21,7 +20,7 @@ NS_DEF_PTR(nsIDOMNode); disabled (just as we build for release). The tests in this file explore more complicated functionality: assigning a pointer - to be reference counted into a [raw, nsCOMPtr, nsIPtr] object using |QueryInterface|; + to be reference counted into a [raw, nsCOMPtr] object using |QueryInterface|; ensuring that it is |AddRef|ed and |Release|d appropriately; calling through the pointer to a function supplied by the underlying COM interface. The tests in this file expand on the tests in "Test01.cpp" by adding |QueryInterface|. @@ -31,14 +30,11 @@ NS_DEF_PTR(nsIDOMNode); nsCOMPtr 63 raw 66 nsCOMPtr* 68 - nsIPtr 66 + 196 - Macintosh: nsCOMPtr 120 (1.0000) Raw01 128 (1.1429) i.e., 14.29% bigger than nsCOMPtr Raw00 144 (1.2000) - nsIPtr 196 (1.6333) */ @@ -72,7 +68,7 @@ Test02_Raw01( nsISupports* aDOMNode, nsString* aResult ) // return NS_ERROR_NULL_POINTER; nsIDOMNode* node; - nsresult status = aDOMNode->QueryInterface(NS_GET_IID(nsIDOMNode(, (void**)&node); + nsresult status = aDOMNode->QueryInterface(NS_GET_IID(nsIDOMNode), (void**)&node); if ( NS_SUCCEEDED(status) ) { node->GetNodeName(*aResult); @@ -95,18 +91,3 @@ Test02_nsCOMPtr( nsISupports* aDOMNode, nsString* aResult ) // return status; } -void // nsresult -Test02_nsIPtr( nsISupports* aDOMNode, nsString* aResult ) - // m196, w66 - { -// if ( !aDOMNode ) -// return NS_ERROR_NULL_POINTER; - - nsIDOMNodePtr node; - nsresult status = aDOMNode->QueryInterface(NS_GET_IID(nsIDOMNode), node.Query()); - - if ( NS_SUCCEEDED(status) ) - node->GetNodeName(*aResult); - -// return status; - } diff --git a/mozilla/xpcom/tests/SizeTest03.cpp b/mozilla/xpcom/tests/SizeTest03.cpp index 54d42e69b00..9ca71c72afa 100644 --- a/mozilla/xpcom/tests/SizeTest03.cpp +++ b/mozilla/xpcom/tests/SizeTest03.cpp @@ -2,7 +2,7 @@ #include "nsIDOMNode.h" #include "nsCOMPtr.h" -#include "nsIPtr.h" +#include "nsString.h" #ifdef __MWERKS__ #pragma exceptions off @@ -18,15 +18,11 @@ NS_DEF_PTR(nsIDOMNode); nsCOMPtr 54 nsCOMPtr* 59 raw 62 - nsIPtr_optimized 45 + 196 - nsIPtr 59 + 196 Macintosh: nsCOMPtr_optimized 112 (1.0000) raw_optimized 124 bytes (1.1071) i.e., 10.71% bigger than nsCOMPtr_optimized - raw, nsIPtr_optimized 140 (1.2500) nsCOMPtr 144 (1.2857) - nsIPtr 192 (1.7143) */ void // nsresult @@ -103,37 +99,3 @@ Test03_nsCOMPtr_optimized( nsIDOMNode* aDOMNode, nsString* aResult ) // return status; } - -void // nsresult -Test03_nsIPtr( nsIDOMNode* aDOMNode, nsString* aResult ) - // m192, w59 - { -// if ( !aDOMNode || !aResult ) -// return NS_ERROR_NULL_POINTER; - - nsIDOMNodePtr parent; - nsresult status = aDOMNode->GetParentNode( parent.AssignPtr() ); - if ( parent.IsNotNull() ) - parent->GetNodeName(*aResult); - -// return status; - } - -void // nsresult -Test03_nsIPtr_optimized( nsIDOMNode* aDOMNode, nsString* aResult ) - // m140, w45 - { -// if ( !aDOMNode || !aResult ) -// return NS_ERROR_NULL_POINTER; - - nsIDOMNode* temp; - nsresult status = aDOMNode->GetParentNode(&temp); - nsIDOMNodePtr parent(temp); - if ( parent.IsNotNull() ) - parent->GetNodeName(*aResult); - -// return status; - } - - - diff --git a/mozilla/xpcom/tests/SizeTest04.cpp b/mozilla/xpcom/tests/SizeTest04.cpp index 0f5be429650..aad4ee68856 100644 --- a/mozilla/xpcom/tests/SizeTest04.cpp +++ b/mozilla/xpcom/tests/SizeTest04.cpp @@ -2,7 +2,6 @@ #include "nsIDOMNode.h" #include "nsCOMPtr.h" -#include "nsIPtr.h" #ifdef __MWERKS__ #pragma exceptions off @@ -14,12 +13,10 @@ NS_DEF_PTR(nsIDOMNode); Windows: nsCOMPtr 13 raw 36 - nsIPtr 43 Macintosh: nsCOMPtr 36 bytes (1.0000) raw 120 (3.3333) i.e., 333.33% bigger than nsCOMPtr - nsIPtr 128 (3.5556) */ class Test04_Raw @@ -73,22 +70,3 @@ Test04_nsCOMPtr::SetNode( nsIDOMNode* newNode ) { mNode = newNode; } - - - -class Test04_nsIPtr - { - public: - void /*nsresult*/ SetNode( nsIDOMNode* newNode ); - - private: - nsIDOMNodePtr mNode; - }; - -void // nsresult -Test04_nsIPtr::SetNode( nsIDOMNode* newNode ) - // m128, w43 - { - mNode = newNode; - mNode.IfAddRef(); - } diff --git a/mozilla/xpcom/tests/SizeTest05.cpp b/mozilla/xpcom/tests/SizeTest05.cpp index 0d13d8fd8dc..0211610ea06 100644 --- a/mozilla/xpcom/tests/SizeTest05.cpp +++ b/mozilla/xpcom/tests/SizeTest05.cpp @@ -2,7 +2,6 @@ #include "nsIDOMNode.h" #include "nsCOMPtr.h" -#include "nsIPtr.h" #ifdef __MWERKS__ #pragma exceptions off @@ -12,17 +11,17 @@ NS_DEF_PTR(nsIDOMNode); /* Windows: - raw, nsCOMPtr, nsIPtr 21 bytes + raw, nsCOMPtr 21 bytes Macintosh: - Raw, nsCOMPtr, nsIPtr 64 bytes + Raw, nsCOMPtr 64 bytes */ -class Test04_Raw +class Test05_Raw { public: - Test04_Raw(); - ~Test04_Raw(); + Test05_Raw(); + ~Test05_Raw(); void /*nsresult*/ GetNode( nsIDOMNode** aNode ); @@ -30,19 +29,19 @@ class Test04_Raw nsIDOMNode* mNode; }; -Test04_Raw::Test04_Raw() +Test05_Raw::Test05_Raw() : mNode(0) { // nothing else to do here } -Test04_Raw::~Test04_Raw() +Test05_Raw::~Test05_Raw() { NS_IF_RELEASE(mNode); } void // nsresult -Test04_Raw::GetNode( nsIDOMNode** aNode ) +Test05_Raw::GetNode( nsIDOMNode** aNode ) // m64, w21 { // if ( !aNode ) @@ -56,7 +55,7 @@ Test04_Raw::GetNode( nsIDOMNode** aNode ) -class Test04_nsCOMPtr +class Test05_nsCOMPtr { public: void /*nsresult*/ GetNode( nsIDOMNode** aNode ); @@ -66,31 +65,7 @@ class Test04_nsCOMPtr }; void // nsresult -Test04_nsCOMPtr::GetNode( nsIDOMNode** aNode ) - // m64, w21 - { -// if ( !aNode ) -// return NS_ERROR_NULL_POINTER; - - *aNode = mNode; - NS_IF_ADDREF(*aNode); - -// return NS_OK; - } - - - -class Test04_nsIPtr - { - public: - void /*nsresult*/ GetNode( nsIDOMNode** aNode ); - - private: - nsIDOMNodePtr mNode; - }; - -void // nsresult -Test04_nsIPtr::GetNode( nsIDOMNode** aNode ) +Test05_nsCOMPtr::GetNode( nsIDOMNode** aNode ) // m64, w21 { // if ( !aNode ) diff --git a/mozilla/xpcom/tests/SizeTest06.cpp b/mozilla/xpcom/tests/SizeTest06.cpp index e965c236ef3..2c28e7f3282 100644 --- a/mozilla/xpcom/tests/SizeTest06.cpp +++ b/mozilla/xpcom/tests/SizeTest06.cpp @@ -3,339 +3,229 @@ #include "nsIDOMWindowInternal.h" #include "nsIScriptGlobalObject.h" #include "nsIWebShell.h" +#include "nsIDocShell.h" #include "nsIWebShellWindow.h" #include "nsCOMPtr.h" -#include "nsIPtr.h" NS_DEF_PTR(nsIScriptGlobalObject); NS_DEF_PTR(nsIWebShell); NS_DEF_PTR(nsIWebShellContainer); NS_DEF_PTR(nsIWebShellWindow); - /* - Windows: - nsCOMPtr_optimized 176 - nsCOMPtr_as_found 181 - nsCOMPtr_optimized* 182 - nsCOMPtr02* 184 - nsCOMPtr02 187 - nsCOMPtr02* 188 - nsCOMPtr03 189 - raw_optimized, nsCOMPtr00 191 - nsCOMPtr00* 199 - nsCOMPtr_as_found* 201 - raw 214 - nsIPtr_optimized 137 + 196 - nsIPtr 220 + 196 + /* + Windows: + nsCOMPtr_optimized 176 + nsCOMPtr_as_found 181 + nsCOMPtr_optimized* 182 + nsCOMPtr02* 184 + nsCOMPtr02 187 + nsCOMPtr02* 188 + nsCOMPtr03 189 + raw_optimized, nsCOMPtr00 191 + nsCOMPtr00* 199 + nsCOMPtr_as_found* 201 + raw 214 - Macintosh: - nsCOMPtr_optimized 300 (1.0000) - nsCOMPtr02 320 (1.0667) i.e., 6.67% bigger than nsCOMPtr_optimized - nsCOMPtr00 328 (1.0933) - raw_optimized, nsCOMPtr03 332 (1.1067) - nsCOMPtr_as_found 344 (1.1467) - raw 388 (1.2933) - nsIPtr_optimized 400 (1.3333) - nsIPtr 564 (1.8800) + Macintosh: + nsCOMPtr_optimized 300 (1.0000) + nsCOMPtr02 320 (1.0667) i.e., 6.67% bigger than nsCOMPtr_optimized + nsCOMPtr00 328 (1.0933) + raw_optimized, nsCOMPtr03 332 (1.1067) + nsCOMPtr_as_found 344 (1.1467) + raw 388 (1.2933) - */ + */ void // nsresult -Test06_raw( nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShellWindow ) - // m388, w214 - { -// if ( !aDOMWindow ) -// return NS_ERROR_NULL_POINTER; - - nsIScriptGlobalObject* scriptGlobalObject = 0; - nsresult status = aDOMWindow->QueryInterface(NS_GET_IID(nsIScriptGlobalObject), (void**)&scriptGlobalObject); - - nsIWebShell* webShell = 0; - if ( scriptGlobalObject ) - scriptGlobalObject->GetWebShell(&webShell); - - nsIWebShell* rootWebShell = 0; - if ( webShell ) - //status = webShell->GetRootWebShellEvenIfChrome(rootWebShell); - - nsIWebShellContainer* webShellContainer = 0; - if ( rootWebShell ) - status = rootWebShell->GetContainer(webShellContainer); - - if ( webShellContainer ) - status = webShellContainer->QueryInterface(NS_GET_IID(nsIWebShellWindow), (void**)aWebShellWindow); - else - (*aWebShellWindow) = 0; - - NS_IF_RELEASE(webShellContainer); - NS_IF_RELEASE(rootWebShell); - NS_IF_RELEASE(webShell); - NS_IF_RELEASE(scriptGlobalObject); - -// return status; - } - +Test06_raw(nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShellWindow) + // m388, w214 +{ +// if (!aDOMWindow) +// return NS_ERROR_NULL_POINTER; + nsIScriptGlobalObject* scriptGlobalObject = 0; + nsresult status = aDOMWindow->QueryInterface(NS_GET_IID(nsIScriptGlobalObject), (void**)&scriptGlobalObject); + nsIDocShell* docShell = 0; + if (scriptGlobalObject) + scriptGlobalObject->GetDocShell(&docShell); + nsIWebShell* webShell = 0; + if (docShell) + status=docShell->QueryInterface(NS_GET_IID(nsIWebShell), (void**)&webShell); + nsIWebShell* rootWebShell = 0; + if (webShell) + //status = webShell->GetRootWebShellEvenIfChrome(rootWebShell); + {} + nsIWebShellContainer* webShellContainer = 0; + if (rootWebShell) + status = rootWebShell->GetContainer(webShellContainer); + if (webShellContainer) + status = webShellContainer->QueryInterface(NS_GET_IID(nsIWebShellWindow), (void**)aWebShellWindow); + else + (*aWebShellWindow) = 0; + NS_IF_RELEASE(webShellContainer); + NS_IF_RELEASE(rootWebShell); + NS_IF_RELEASE(webShell); + NS_IF_RELEASE(docShell); + NS_IF_RELEASE(scriptGlobalObject); +// return status; +} void // nsresult -Test06_raw_optimized( nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShellWindow ) - // m332, w191 - { -// if ( !aDOMWindow ) -// return NS_ERROR_NULL_POINTER; - - (*aWebShellWindow) = 0; - - nsIScriptGlobalObject* scriptGlobalObject; - nsresult status = aDOMWindow->QueryInterface(NS_GET_IID(nsIScriptGlobalObject), (void**)&scriptGlobalObject); - if ( NS_SUCCEEDED(status) ) - { - nsIWebShell* webShell; - scriptGlobalObject->GetWebShell(&webShell); - if ( webShell ) - { - nsIWebShell* rootWebShell; - // status = webShell->GetRootWebShellEvenIfChrome(rootWebShell); - if ( NS_SUCCEEDED(status) ) - { - nsIWebShellContainer* webShellContainer; - status = rootWebShell->GetContainer(webShellContainer); - if ( NS_SUCCEEDED(status) ) - { - status = webShellContainer->QueryInterface(NS_GET_IID(nsIWebShellWindow), (void**)aWebShellWindow); - NS_RELEASE(webShellContainer); - } - - NS_RELEASE(rootWebShell); - } - - NS_RELEASE(webShell); - } - - NS_RELEASE(scriptGlobalObject); - } - -// return status; - } +Test06_raw_optimized(nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShellWindow) + // m332, w191 +{ +// if (!aDOMWindow) +// return NS_ERROR_NULL_POINTER; + (*aWebShellWindow) = 0; + nsIScriptGlobalObject* scriptGlobalObject; + nsresult status = aDOMWindow->QueryInterface(NS_GET_IID(nsIScriptGlobalObject), (void**)&scriptGlobalObject); + if (NS_SUCCEEDED(status)) { + nsIDocShell* docShell = 0; + scriptGlobalObject->GetDocShell(&docShell); + if (docShell) { + nsIWebShell* webShell = 0; + docShell->QueryInterface(NS_GET_IID(nsIWebShell), (void**)webShell); + if (webShell) { + nsIWebShell* rootWebShell; + // status = webShell->GetRootWebShellEvenIfChrome(rootWebShell); + if (NS_SUCCEEDED(status)) { + nsIWebShellContainer* webShellContainer; + status = rootWebShell->GetContainer(webShellContainer); + if (NS_SUCCEEDED(status)) { + status = webShellContainer->QueryInterface(NS_GET_IID(nsIWebShellWindow), (void**)aWebShellWindow); + NS_RELEASE(webShellContainer); + } + NS_RELEASE(rootWebShell); + } + NS_RELEASE(webShell); + } + NS_RELEASE(docShell); + } + NS_RELEASE(scriptGlobalObject); + } +// return status; +} void -Test06_nsCOMPtr_as_found( nsIDOMWindowInternal* aDOMWindow, nsCOMPtr* aWebShellWindow ) - // m344, w181/201 - { -// if ( !aDOMWindow ) -// return; - - nsCOMPtr scriptGlobalObject = do_QueryInterface(aDOMWindow); - - nsCOMPtr webShell; - if ( scriptGlobalObject ) - scriptGlobalObject->GetWebShell( getter_AddRefs(webShell) ); - - nsCOMPtr rootWebShell; - if ( webShell ) - //webShell->GetRootWebShellEvenIfChrome( *getter_AddRefs(rootWebShell) ); - - nsCOMPtr webShellContainer; - if ( rootWebShell ) - rootWebShell->GetContainer( *getter_AddRefs(webShellContainer) ); - - (*aWebShellWindow) = do_QueryInterface(webShellContainer); - } +Test06_nsCOMPtr_as_found(nsIDOMWindowInternal* aDOMWindow, nsCOMPtr* aWebShellWindow) + // m344, w181/201 +{ +// if (!aDOMWindow) +// return; + nsCOMPtr scriptGlobalObject = do_QueryInterface(aDOMWindow); + nsCOMPtr docShell; + if (scriptGlobalObject) + scriptGlobalObject->GetDocShell(getter_AddRefs(docShell)); + nsCOMPtr webShell; + if (docShell) + webShell = do_QueryInterface(docShell); + nsCOMPtr rootWebShell; + if (webShell) + //webShell->GetRootWebShellEvenIfChrome(*getter_AddRefs(rootWebShell)); + {} + nsCOMPtr webShellContainer; + if (rootWebShell) + rootWebShell->GetContainer(*getter_AddRefs(webShellContainer)); + (*aWebShellWindow) = do_QueryInterface(webShellContainer); +} void // nsresult -Test06_nsCOMPtr00( nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShellWindow ) - // m328, w191/199 - { -// if ( !aDOMWindow ) -// return NS_ERROR_NULL_POINTER; - - nsresult status; - nsCOMPtr scriptGlobalObject = do_QueryInterface(aDOMWindow, &status); - - nsIWebShell* temp0 = 0; - if ( scriptGlobalObject ) - scriptGlobalObject->GetWebShell(&temp0); - nsCOMPtr webShell = dont_AddRef(temp0); - - nsIWebShell* temp1 = 0; - if ( webShell ) - //status = webShell->GetRootWebShellEvenIfChrome(temp1); - nsCOMPtr rootWebShell = dont_AddRef(temp1); - - nsIWebShellContainer* temp2 = 0; - if ( rootWebShell ) - status = rootWebShell->GetContainer(temp2); - nsCOMPtr webShellContainer = dont_AddRef(temp2); - - if ( webShellContainer ) - status = webShellContainer->QueryInterface(NS_GET_IID(nsIWebShellWindow), (void**)aWebShellWindow); - else - (*aWebShellWindow) = 0; - -// return status; - } +Test06_nsCOMPtr00(nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShellWindow) + // m328, w191/199 +{ +// if (!aDOMWindow) +// return NS_ERROR_NULL_POINTER; + nsresult status; + nsCOMPtr scriptGlobalObject = do_QueryInterface(aDOMWindow, &status); + nsIDocShell* temp0 = 0; + if (scriptGlobalObject) + scriptGlobalObject->GetDocShell(&temp0); + nsCOMPtr docShell = dont_AddRef(temp0); + nsCOMPtr webShell; + if (docShell) + webShell=do_QueryInterface(docShell, &status); + nsIWebShellContainer* temp2 = 0; + if (webShell) + status = webShell->GetContainer(temp2); + nsCOMPtr webShellContainer = dont_AddRef(temp2); + if (webShellContainer) + status = webShellContainer->QueryInterface(NS_GET_IID(nsIWebShellWindow), (void**)aWebShellWindow); + else + (*aWebShellWindow) = 0; +// return status; +} void // nsresult -Test06_nsCOMPtr_optimized( nsIDOMWindowInternal* aDOMWindow, nsCOMPtr* aWebShellWindow ) - // m300, w176/182 - { -// if ( !aDOMWindow ) -// return NS_ERROR_NULL_POINTER; - - nsresult status; - nsCOMPtr scriptGlobalObject = do_QueryInterface(aDOMWindow, &status); - - nsIWebShell* temp0 = 0; - if ( scriptGlobalObject ) - scriptGlobalObject->GetWebShell(&temp0); - nsCOMPtr webShell = dont_AddRef(temp0); - - nsIWebShell* temp1 = 0; - if ( webShell ) - // status = webShell->GetRootWebShellEvenIfChrome(temp1); - nsCOMPtr rootWebShell = dont_AddRef(temp1); - - nsIWebShellContainer* temp2 = 0; - if ( rootWebShell ) - status = rootWebShell->GetContainer(temp2); - nsCOMPtr webShellContainer = dont_AddRef(temp2); - (*aWebShellWindow) = do_QueryInterface(webShellContainer, &status); - -// return status; - } +Test06_nsCOMPtr_optimized(nsIDOMWindowInternal* aDOMWindow, nsCOMPtr* aWebShellWindow) + // m300, w176/182 +{ +// if (!aDOMWindow) +// return NS_ERROR_NULL_POINTER; + nsresult status; + nsCOMPtr scriptGlobalObject = do_QueryInterface(aDOMWindow, &status); + nsIDocShell* temp0 = 0; + if (scriptGlobalObject) + scriptGlobalObject->GetDocShell(&temp0); + nsCOMPtr webShell = do_QueryInterface(temp0, &status); + nsIWebShell* temp2 = 0; + if (webShell) + // status = webShell->GetRootWebShellEvenIfChrome(temp2); + {} + nsCOMPtr rootWebShell = dont_AddRef(temp2); + nsIWebShellContainer* temp3 = 0; + if (rootWebShell) + status = rootWebShell->GetContainer(temp3); + nsCOMPtr webShellContainer = dont_AddRef(temp3); + (*aWebShellWindow) = do_QueryInterface(webShellContainer, &status); +// return status; +} void // nsresult -Test06_nsCOMPtr02( nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShellWindow ) - // m320, w187/184 - { -// if ( !aDOMWindow ) -// return NS_ERROR_NULL_POINTER; - - (*aWebShellWindow) = 0; - - nsresult status; - nsCOMPtr scriptGlobalObject = do_QueryInterface(aDOMWindow, &status); - if ( scriptGlobalObject ) - { - nsIWebShell* temp0; - scriptGlobalObject->GetWebShell(&temp0); - nsCOMPtr webShell = dont_AddRef(temp0); - - if ( webShell ) - { - // status = webShell->GetRootWebShellEvenIfChrome(temp0); - nsCOMPtr rootWebShell = dont_AddRef(temp0); - - if ( rootWebShell ) - { - nsIWebShellContainer* temp1; - status = rootWebShell->GetContainer(temp1); - nsCOMPtr webShellContainer = dont_AddRef(temp1); - - if ( webShellContainer ) - status = webShellContainer->QueryInterface(NS_GET_IID(nsIWebShellWindow), (void**)aWebShellWindow); - } - } - } - -// return status; - } +Test06_nsCOMPtr02(nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShellWindow) + // m320, w187/184 +{ +// if (!aDOMWindow) +// return NS_ERROR_NULL_POINTER; + (*aWebShellWindow) = 0; + nsresult status; + nsCOMPtr scriptGlobalObject = do_QueryInterface(aDOMWindow, &status); + if (scriptGlobalObject) { + nsIDocShell* temp0; + scriptGlobalObject->GetDocShell(&temp0); + nsCOMPtr webShell = do_QueryInterface(temp0); + if (webShell) { + nsIWebShellContainer* temp2; + status = webShell->GetContainer(temp2); + nsCOMPtr webShellContainer = dont_AddRef(temp2); + if (webShellContainer) + status = webShellContainer->QueryInterface(NS_GET_IID(nsIWebShellWindow), (void**)aWebShellWindow); + } + } +// return status; +} void // nsresult -Test06_nsCOMPtr03( nsIDOMWindowInternal* aDOMWindow, nsCOMPtr* aWebShellWindow ) - // m332, w189/188 - { -// if ( !aDOMWindow ) -// return NS_ERROR_NULL_POINTER; - - (*aWebShellWindow) = 0; - - nsresult status; - nsCOMPtr scriptGlobalObject = do_QueryInterface(aDOMWindow, &status); - if ( scriptGlobalObject ) - { - nsIWebShell* temp0; - scriptGlobalObject->GetWebShell(&temp0); - nsCOMPtr webShell = dont_AddRef(temp0); - - if ( webShell ) - { - // status = webShell->GetRootWebShellEvenIfChrome(temp0); - nsCOMPtr rootWebShell = dont_AddRef(temp0); - - if ( rootWebShell ) - { - nsIWebShellContainer* temp1; - status = rootWebShell->GetContainer(temp1); - nsCOMPtr webShellContainer = dont_AddRef(temp1); - (*aWebShellWindow) = do_QueryInterface(webShellContainer, &status); - } - } - } - -// return status; - } - -void // nsresult -Test06_nsIPtr( nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShellWindow ) - // m564, w220 - { -// if ( !aDOMWindow ) -// return NS_ERROR_NULL_POINTER; - - nsIScriptGlobalObjectPtr scriptGlobalObject; - nsresult status = aDOMWindow->QueryInterface(NS_GET_IID(nsIScriptGlobalObject), scriptGlobalObject.Query()); - - nsIWebShellPtr webShell; - if ( scriptGlobalObject.IsNotNull() ) - scriptGlobalObject->GetWebShell( webShell.AssignPtr() ); - - nsIWebShellPtr rootWebShell; - if ( webShell.IsNotNull() ) - // status = webShell->GetRootWebShellEvenIfChrome( rootWebShell.AssignRef() ); - - nsIWebShellContainerPtr webShellContainer; - if ( rootWebShell.IsNotNull() ) - status = rootWebShell->GetContainer( webShellContainer.AssignRef() ); - - if ( webShellContainer.IsNotNull() ) - status = webShellContainer->QueryInterface(NS_GET_IID(nsIWebShellWindow), (void**)aWebShellWindow); - else - (*aWebShellWindow) = 0; - -// return status; - } - -void // nsresult -Test06_nsIPtr_optimized( nsIDOMWindowInternal* aDOMWindow, nsIWebShellWindow** aWebShellWindow ) - // m400, w137 - { -// if ( !aDOMWindow ) -// return NS_ERROR_NULL_POINTER; - - nsIScriptGlobalObject* temp0; - nsresult status = aDOMWindow->QueryInterface(NS_GET_IID(nsIScriptGlobalObject), (void**)&temp0); - nsIScriptGlobalObjectPtr scriptGlobalObject = temp0; - - nsIWebShell* temp1 = 0; - if ( scriptGlobalObject.IsNotNull() ) - scriptGlobalObject->GetWebShell(&temp1); - nsIWebShellPtr webShell = temp1; - - nsIWebShell* temp2 = 0; - if ( webShell.IsNotNull() ) - // status = webShell->GetRootWebShellEvenIfChrome(temp2); - nsIWebShellPtr rootWebShell = temp2; - - nsIWebShellContainer* temp3 = 0; - if ( rootWebShell.IsNotNull() ) - status = rootWebShell->GetContainer(temp3); - nsIWebShellContainerPtr webShellContainer = temp3; - - if ( webShellContainer.IsNotNull() ) - status = webShellContainer->QueryInterface(NS_GET_IID(nsIWebShellWindow), (void**)aWebShellWindow); - else - (*aWebShellWindow) = 0; - -// return status; - } +Test06_nsCOMPtr03(nsIDOMWindowInternal* aDOMWindow, nsCOMPtr* aWebShellWindow) + // m332, w189/188 +{ +// if (!aDOMWindow) +// return NS_ERROR_NULL_POINTER; + (*aWebShellWindow) = 0; + nsresult status; + nsCOMPtr scriptGlobalObject = do_QueryInterface(aDOMWindow, &status); + if (scriptGlobalObject) { + nsIDocShell* temp0; + scriptGlobalObject->GetDocShell(&temp0); + nsCOMPtr docShell = dont_AddRef(temp0); + if (docShell) { + nsCOMPtr webShell = do_QueryInterface(docShell, &status); + if (webShell) { + nsIWebShellContainer* temp2; + status = webShell->GetContainer(temp2); + nsCOMPtr webShellContainer = dont_AddRef(temp2); + (*aWebShellWindow) = do_QueryInterface(webShellContainer, &status); + } + } + } +// return status; +}