This commit is contained in:
scc%netscape.com 1999-05-10 20:46:31 +00:00
Родитель a791673124
Коммит fa3fd7fb39
6 изменённых файлов: 969 добавлений и 0 удалений

145
xpcom/tests/SizeTest01.cpp Normal file
Просмотреть файл

@ -0,0 +1,145 @@
// Test01.cpp
#include "nsIDOMNode.h"
#include "nsCOMPtr.h"
#include "nsIPtr.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".
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.
For these tests, all reasonable optimizations were enabled and exceptions were
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
|AddRef|ed and |Release|d appropriately; calling through the pointer to a function
supplied by the underlying COM interface.
Windows:
raw_optimized 31 bytes
raw, nsCOMPtr* 34
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
not referenced, and which can be stripped by the linker.
Also note that on all platforms, each use of the |NS_DEFINE_IID| macro adds 16 bytes of static
data per file, while GetIID() has the same code profile and adds only 16 bytes of data to the entire
program, reguardless of the number of uses (greater than one).
*/
void
Test01_raw( nsIDOMNode* aDOMNode, nsString* aResult )
// m140, w34
{
/*
This test is designed to be more like a typical large function where,
because you are working with several resources, you don't just return when
one of them is |NULL|. Similarly: |Test01_nsCOMPtr00|, and |Test01_nsIPtr00|.
*/
nsIDOMNode* node = aDOMNode;
NS_IF_ADDREF(node);
if ( node )
node->GetNodeName(*aResult);
NS_IF_RELEASE(node);
}
void
Test01_raw_optimized( nsIDOMNode* aDOMNode, nsString* aResult )
// m112, w31
{
/*
This test simulates smaller functions where you _do_ just return
|NULL| at the first sign of trouble. Similarly: |Test01_nsCOMPtr01|,
and |Test01_nsIPtr01|.
*/
/*
This test produces smaller code that |Test01_raw| because it avoids
the three tests: |NS_IF_...|, and |if ( node )|.
*/
// -- the following code is assumed, but is commented out so we compare only
// the relevent generated code
// if ( !aDOMNode )
// return;
nsIDOMNode* node = aDOMNode;
NS_ADDREF(node);
node->GetNodeName(*aResult);
NS_RELEASE(node);
}
void
Test01_nsCOMPtr( nsIDOMNode* aDOMNode, nsString* aResult )
// m120, w46/34
{
nsCOMPtr<nsIDOMNode> node = aDOMNode;
if ( node )
node->GetNodeName(*aResult);
}
void
Test01_nsCOMPtr_optimized( nsIDOMNode* aDOMNode, nsString* aResult )
// m112, w42/38
{
// if ( !aDOMNode )
// return;
nsCOMPtr<nsIDOMNode> 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);
}

113
xpcom/tests/SizeTest02.cpp Normal file
Просмотреть файл

@ -0,0 +1,113 @@
// Test02.cpp
#include "nsIDOMNode.h"
#include "nsCOMPtr.h"
#include "nsIPtr.h"
#ifdef __MWERKS__
#pragma exceptions off
#endif
static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
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".
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.
For these tests, all reasonable optimizations were enabled and exceptions were
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|;
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|.
Windows:
raw01 52
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)
*/
void // nsresult
Test02_Raw00( nsISupports* aDOMNode, nsString* aResult )
// m144, w66
{
// -- the following code is assumed, but is commented out so we compare only
// the relevent generated code
// if ( !aDOMNode )
// return NS_ERROR_NULL_POINTER;
nsIDOMNode* node = 0;
nsresult status = aDOMNode->QueryInterface(kIDOMNodeIID, (void**)&node);
if ( NS_SUCCEEDED(status) )
{
node->GetNodeName(*aResult);
}
NS_IF_RELEASE(node);
// return status;
}
void // nsresult
Test02_Raw01( nsISupports* aDOMNode, nsString* aResult )
// m128, w52
{
// if ( !aDOMNode )
// return NS_ERROR_NULL_POINTER;
nsIDOMNode* node;
nsresult status = aDOMNode->QueryInterface(kIDOMNodeIID, (void**)&node);
if ( NS_SUCCEEDED(status) )
{
node->GetNodeName(*aResult);
NS_RELEASE(node);
}
// return status;
}
void // nsresult
Test02_nsCOMPtr( nsISupports* aDOMNode, nsString* aResult )
// m120, w63/68
{
nsresult status;
nsCOMPtr<nsIDOMNode> node = do_QueryInterface(aDOMNode, &status);
if ( node )
node->GetNodeName(*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(kIDOMNodeIID, node.Query());
if ( NS_SUCCEEDED(status) )
node->GetNodeName(*aResult);
// return status;
}

139
xpcom/tests/SizeTest03.cpp Normal file
Просмотреть файл

@ -0,0 +1,139 @@
// Test03.cpp
#include "nsIDOMNode.h"
#include "nsCOMPtr.h"
#include "nsIPtr.h"
#ifdef __MWERKS__
#pragma exceptions off
#endif
NS_DEF_PTR(nsIDOMNode);
/*
Windows:
nsCOMPtr_optimized* 45
raw_optimized 48
nsCOMPtr_optimized 50
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
Test03_raw( nsIDOMNode* aDOMNode, nsString* aResult )
// m140, w62
{
// -- the following code is assumed, but is commented out so we compare only
// the relevent generated code
// if ( !aDOMNode || !aResult )
// return NS_ERROR_NULL_POINTER;
nsIDOMNode* parent = 0;
nsresult status = aDOMNode->GetParentNode(&parent);
if ( NS_SUCCEEDED(status) )
{
parent->GetNodeName(*aResult);
}
NS_IF_RELEASE(parent);
// return status;
}
void // nsresult
Test03_raw_optimized( nsIDOMNode* aDOMNode, nsString* aResult )
// m124, w48
{
// if ( !aDOMNode || !aResult )
// return NS_ERROR_NULL_POINTER;
nsIDOMNode* parent;
nsresult status = aDOMNode->GetParentNode(&parent);
if ( NS_SUCCEEDED(status) )
{
parent->GetNodeName(*aResult);
NS_RELEASE(parent);
}
// return status;
}
void // nsresult
Test03_nsCOMPtr( nsIDOMNode* aDOMNode, nsString* aResult )
// m144, w54/59
{
// if ( !aDOMNode || !aResult )
// return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIDOMNode> parent;
nsresult status = aDOMNode->GetParentNode( getter_AddRefs(parent) );
if ( parent )
parent->GetNodeName(*aResult);
// return status;
}
void // nsresult
Test03_nsCOMPtr_optimized( nsIDOMNode* aDOMNode, nsString* aResult )
// m112, w50/45
{
// if ( !aDOMNode || !aResult )
// return NS_ERROR_NULL_POINTER;
nsIDOMNode* temp;
nsresult status = aDOMNode->GetParentNode(&temp);
nsCOMPtr<nsIDOMNode> parent( dont_AddRef(temp) );
if ( parent )
parent->GetNodeName(*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;
}

Просмотреть файл

@ -0,0 +1,94 @@
// Test04.cpp
#include "nsIDOMNode.h"
#include "nsCOMPtr.h"
#include "nsIPtr.h"
#ifdef __MWERKS__
#pragma exceptions off
#endif
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
{
public:
Test04_Raw();
~Test04_Raw();
void /*nsresult*/ SetNode( nsIDOMNode* newNode );
private:
nsIDOMNode* mNode;
};
Test04_Raw::Test04_Raw()
: mNode(0)
{
// nothing else to do here
}
Test04_Raw::~Test04_Raw()
{
NS_IF_RELEASE(mNode);
}
void // nsresult
Test04_Raw::SetNode( nsIDOMNode* newNode )
// m120, w36
{
NS_IF_ADDREF(newNode);
NS_IF_RELEASE(mNode);
mNode = newNode;
// return NS_OK;
}
class Test04_nsCOMPtr
{
public:
void /*nsresult*/ SetNode( nsIDOMNode* newNode );
private:
nsCOMPtr<nsIDOMNode> mNode;
};
void // nsresult
Test04_nsCOMPtr::SetNode( nsIDOMNode* newNode )
// m36, w13/13
{
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();
}

103
xpcom/tests/SizeTest05.cpp Normal file
Просмотреть файл

@ -0,0 +1,103 @@
// Test05.cpp
#include "nsIDOMNode.h"
#include "nsCOMPtr.h"
#include "nsIPtr.h"
#ifdef __MWERKS__
#pragma exceptions off
#endif
NS_DEF_PTR(nsIDOMNode);
/*
Windows:
raw, nsCOMPtr, nsIPtr 21 bytes
Macintosh:
Raw, nsCOMPtr, nsIPtr 64 bytes
*/
class Test04_Raw
{
public:
Test04_Raw();
~Test04_Raw();
void /*nsresult*/ GetNode( nsIDOMNode** aNode );
private:
nsIDOMNode* mNode;
};
Test04_Raw::Test04_Raw()
: mNode(0)
{
// nothing else to do here
}
Test04_Raw::~Test04_Raw()
{
NS_IF_RELEASE(mNode);
}
void // nsresult
Test04_Raw::GetNode( nsIDOMNode** aNode )
// m64, w21
{
// if ( !aNode )
// return NS_ERROR_NULL_POINTER;
*aNode = mNode;
NS_IF_ADDREF(*aNode);
// return NS_OK;
}
class Test04_nsCOMPtr
{
public:
void /*nsresult*/ GetNode( nsIDOMNode** aNode );
private:
nsCOMPtr<nsIDOMNode> mNode;
};
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 )
// m64, w21
{
// if ( !aNode )
// return NS_ERROR_NULL_POINTER;
*aNode = mNode;
NS_IF_ADDREF(*aNode);
// return NS_OK;
}

375
xpcom/tests/SizeTest06.cpp Normal file
Просмотреть файл

@ -0,0 +1,375 @@
// Test06.cpp
#include "nsIDOMWindow.h"
#include "nsIScriptGlobalObject.h"
#include "nsIWebShell.h"
#include "nsIWebShellWindow.h"
#include "nsCOMPtr.h"
#include "nsIPtr.h"
static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
static NS_DEFINE_IID(kIWebShellWindowIID, NS_IWEBSHELL_WINDOW_IID);
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
nsIPtr01 168 + 196
nsIPtr 220 + 196
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)
nsIPtr01 464 (1.5467)
nsIPtr 564 (1.8800)
*/
void // nsresult
Test06_raw( nsIDOMWindow* aDOMWindow, nsIWebShellWindow** aWebShellWindow )
// m388, w214
{
// if ( !aDOMWindow )
// return NS_ERROR_NULL_POINTER;
nsIScriptGlobalObject* scriptGlobalObject = 0;
nsresult status = aDOMWindow->QueryInterface(kIScriptGlobalObjectIID, (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(kIWebShellWindowIID, (void**)aWebShellWindow);
else
(*aWebShellWindow) = 0;
NS_IF_RELEASE(webShellContainer);
NS_IF_RELEASE(rootWebShell);
NS_IF_RELEASE(webShell);
NS_IF_RELEASE(scriptGlobalObject);
// return status;
}
void // nsresult
Test06_raw_optimized( nsIDOMWindow* aDOMWindow, nsIWebShellWindow** aWebShellWindow )
// m332, w191
{
// if ( !aDOMWindow )
// return NS_ERROR_NULL_POINTER;
(*aWebShellWindow) = 0;
nsIScriptGlobalObject* scriptGlobalObject;
nsresult status = aDOMWindow->QueryInterface(kIScriptGlobalObjectIID, (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(kIWebShellWindowIID, (void**)aWebShellWindow);
NS_RELEASE(webShellContainer);
}
NS_RELEASE(rootWebShell);
}
NS_RELEASE(webShell);
}
NS_RELEASE(scriptGlobalObject);
}
// return status;
}
void
Test06_nsCOMPtr_as_found( nsIDOMWindow* aDOMWindow, nsCOMPtr<nsIWebShellWindow>* aWebShellWindow )
// m344, w181/201
{
// if ( !aDOMWindow )
// return;
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject = do_QueryInterface(aDOMWindow);
nsCOMPtr<nsIWebShell> webShell;
if ( scriptGlobalObject )
scriptGlobalObject->GetWebShell( getter_AddRefs(webShell) );
nsCOMPtr<nsIWebShell> rootWebShell;
if ( webShell )
webShell->GetRootWebShellEvenIfChrome( *getter_AddRefs(rootWebShell) );
nsCOMPtr<nsIWebShellContainer> webShellContainer;
if ( rootWebShell )
rootWebShell->GetContainer( *getter_AddRefs(webShellContainer) );
(*aWebShellWindow) = do_QueryInterface(webShellContainer);
}
void // nsresult
Test06_nsCOMPtr00( nsIDOMWindow* aDOMWindow, nsIWebShellWindow** aWebShellWindow )
// m328, w191/199
{
// if ( !aDOMWindow )
// return NS_ERROR_NULL_POINTER;
nsresult status;
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject = do_QueryInterface(aDOMWindow, &status);
nsIWebShell* temp0;
if ( scriptGlobalObject )
scriptGlobalObject->GetWebShell(&temp0);
nsCOMPtr<nsIWebShell> webShell = dont_AddRef(temp0);
if ( webShell )
status = webShell->GetRootWebShellEvenIfChrome(temp0);
nsCOMPtr<nsIWebShell> rootWebShell = dont_AddRef(temp0);
nsIWebShellContainer* temp1;
if ( rootWebShell )
status = rootWebShell->GetContainer(temp1);
nsCOMPtr<nsIWebShellContainer> webShellContainer = dont_AddRef(temp1);
if ( webShellContainer )
status = webShellContainer->QueryInterface(nsIWebShellWindow::GetIID(), (void**)aWebShellWindow);
else
(*aWebShellWindow) = 0;
// return status;
}
void // nsresult
Test06_nsCOMPtr_optimized( nsIDOMWindow* aDOMWindow, nsCOMPtr<nsIWebShellWindow>* aWebShellWindow )
// m300, w176/182
{
// if ( !aDOMWindow )
// return NS_ERROR_NULL_POINTER;
nsresult status;
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject = do_QueryInterface(aDOMWindow, &status);
nsIWebShell* temp0;
if ( scriptGlobalObject )
scriptGlobalObject->GetWebShell(&temp0);
nsCOMPtr<nsIWebShell> webShell = dont_AddRef(temp0);
if ( webShell )
status = webShell->GetRootWebShellEvenIfChrome(temp0);
nsCOMPtr<nsIWebShell> rootWebShell = dont_AddRef(temp0);
nsIWebShellContainer* temp1;
if ( rootWebShell )
status = rootWebShell->GetContainer(temp1);
nsCOMPtr<nsIWebShellContainer> webShellContainer = dont_AddRef(temp1);
(*aWebShellWindow) = do_QueryInterface(webShellContainer, &status);
// return status;
}
void // nsresult
Test06_nsCOMPtr02( nsIDOMWindow* aDOMWindow, nsIWebShellWindow** aWebShellWindow )
// m320, w187/184
{
// if ( !aDOMWindow )
// return NS_ERROR_NULL_POINTER;
(*aWebShellWindow) = 0;
nsresult status;
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject = do_QueryInterface(aDOMWindow, &status);
if ( scriptGlobalObject )
{
nsIWebShell* temp0;
scriptGlobalObject->GetWebShell(&temp0);
nsCOMPtr<nsIWebShell> webShell = dont_AddRef(temp0);
if ( webShell )
{
status = webShell->GetRootWebShellEvenIfChrome(temp0);
nsCOMPtr<nsIWebShell> rootWebShell = dont_AddRef(temp0);
if ( rootWebShell )
{
nsIWebShellContainer* temp1;
status = rootWebShell->GetContainer(temp1);
nsCOMPtr<nsIWebShellContainer> webShellContainer = dont_AddRef(temp1);
if ( webShellContainer )
status = webShellContainer->QueryInterface(nsIWebShellWindow::GetIID(), (void**)aWebShellWindow);
}
}
}
// return status;
}
void // nsresult
Test06_nsCOMPtr03( nsIDOMWindow* aDOMWindow, nsCOMPtr<nsIWebShellWindow>* aWebShellWindow )
// m332, w189/188
{
// if ( !aDOMWindow )
// return NS_ERROR_NULL_POINTER;
(*aWebShellWindow) = 0;
nsresult status;
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject = do_QueryInterface(aDOMWindow, &status);
if ( scriptGlobalObject )
{
nsIWebShell* temp0;
scriptGlobalObject->GetWebShell(&temp0);
nsCOMPtr<nsIWebShell> webShell = dont_AddRef(temp0);
if ( webShell )
{
status = webShell->GetRootWebShellEvenIfChrome(temp0);
nsCOMPtr<nsIWebShell> rootWebShell = dont_AddRef(temp0);
if ( rootWebShell )
{
nsIWebShellContainer* temp1;
status = rootWebShell->GetContainer(temp1);
nsCOMPtr<nsIWebShellContainer> webShellContainer = dont_AddRef(temp1);
(*aWebShellWindow) = do_QueryInterface(webShellContainer, &status);
}
}
}
// return status;
}
void // nsresult
Test06_nsIPtr( nsIDOMWindow* aDOMWindow, nsIWebShellWindow** aWebShellWindow )
// m564, w220
{
// if ( !aDOMWindow )
// return NS_ERROR_NULL_POINTER;
nsIScriptGlobalObjectPtr scriptGlobalObject;
nsresult status = aDOMWindow->QueryInterface(kIScriptGlobalObjectIID, 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(kIWebShellWindowIID, (void**)aWebShellWindow);
else
(*aWebShellWindow) = 0;
// return status;
}
void // nsresult
Test06_nsIPtr01( nsIDOMWindow* aDOMWindow, nsIWebShellWindowPtr* aWebShellWindow )
// m464, w168
{
// if ( !aDOMWindow )
// return NS_ERROR_NULL_POINTER;
nsIScriptGlobalObject* temp0;
nsresult status = aDOMWindow->QueryInterface(kIScriptGlobalObjectIID, (void**)&temp0);
nsIScriptGlobalObjectPtr scriptGlobalObject = temp0;
nsIWebShell* temp1;
if ( scriptGlobalObject.IsNotNull() )
scriptGlobalObject->GetWebShell(&temp1);
nsIWebShellPtr webShell = temp1;
if ( webShell.IsNotNull() )
status = webShell->GetRootWebShellEvenIfChrome(temp1);
nsIWebShellPtr rootWebShell;
nsIWebShellContainer* temp2;
if ( rootWebShell.IsNotNull() )
status = rootWebShell->GetContainer(temp2);
nsIWebShellContainerPtr webShellContainer = temp2;
if ( webShellContainer.IsNotNull() )
status = webShellContainer->QueryInterface(kIWebShellWindowIID, aWebShellWindow->Query());
else
(*aWebShellWindow) = 0;
// return status;
}
void // nsresult
Test06_nsIPtr_optimized( nsIDOMWindow* aDOMWindow, nsIWebShellWindow** aWebShellWindow )
// m400, w137
{
// if ( !aDOMWindow )
// return NS_ERROR_NULL_POINTER;
nsIScriptGlobalObject* temp0;
nsresult status = aDOMWindow->QueryInterface(kIScriptGlobalObjectIID, (void**)&temp0);
nsIScriptGlobalObjectPtr scriptGlobalObject = temp0;
nsIWebShell* temp1;
if ( scriptGlobalObject.IsNotNull() )
scriptGlobalObject->GetWebShell(&temp1);
nsIWebShellPtr webShell = temp1;
if ( webShell.IsNotNull() )
status = webShell->GetRootWebShellEvenIfChrome(temp1);
nsIWebShellPtr rootWebShell;
nsIWebShellContainer* temp2;
if ( rootWebShell.IsNotNull() )
status = rootWebShell->GetContainer(temp2);
nsIWebShellContainerPtr webShellContainer = temp2;
if ( webShellContainer.IsNotNull() )
status = webShellContainer->QueryInterface(kIWebShellWindowIID, (void**)aWebShellWindow);
else
(*aWebShellWindow) = 0;
// return status;
}