bug 21187

fixed the webshell leak in <textarea> and <input type=text|password>
the problem was the new nsWebShell::SetDocument() call was indirectly
causing nsHTMLDocument to instantiate a parser and fire off a parse.
bad circular references ensued. The fix is to use the "aCommand" param
to pass a hint to the nsHTMLDocument, telling it there's no need to
involve a parser.

in the simple case, we no longer leak webshells.  That is, if you open
mozilla.exe, look at a page (whether it has a text control on it or
not), and shut down the app, no webshell is leaked.  If I browse around,
sometimes we still leak a webshell somewhere.  I haven't figured out
exactly where that is yet.  A guess is history, which is in the process
of being reworked anyway.

r=mscott
a=chofmann
This commit is contained in:
buster%netscape.com 1999-12-09 07:21:34 +00:00
parent dbc3d6a9e9
commit 0edefdc22a
2 changed files with 12 additions and 8 deletions

View File

@ -103,6 +103,7 @@ static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
#undef NOISY_WEBSHELL_LEAKS
#endif
#define NOISY_WEBSHELL_LEAKS
#ifdef NOISY_WEBSHELL_LEAKS
#undef DETECT_WEBSHELL_LEAKS
#define DETECT_WEBSHELL_LEAKS
@ -4167,11 +4168,12 @@ NS_IMETHODIMP nsWebShell::SetDocument(nsIDOMDocument *aDOMDoc,
NS_ENSURE_SUCCESS(NS_OpenURI(getter_AddRefs(dummyChannel), uri, nsnull), NS_ERROR_FAILURE);
// (4) fire start document load notification
nsIStreamListener* outStreamListener=nsnull; // a valid pointer is required for the returned stream listener
NS_ENSURE_SUCCESS(doc->StartDocumentLoad("view", dummyChannel, nsnull, NS_STATIC_CAST(nsIContentViewerContainer*, this),
&outStreamListener),
nsCOMPtr<nsIStreamListener> outStreamListener; // a valid pointer is required for the returned stream listener
// XXX: warning: magic cookie! should get string "view delayedContentLoad"
// from somewhere, maybe nsIHTMLDocument?
NS_ENSURE_SUCCESS(doc->StartDocumentLoad("view delayedContentLoad", dummyChannel, nsnull, NS_STATIC_CAST(nsIContentViewerContainer*, this),
getter_AddRefs(outStreamListener)),
NS_ERROR_FAILURE);
NS_IF_RELEASE(outStreamListener);
NS_ENSURE_SUCCESS(OnStartDocumentLoad(mDocLoader, uri, "load"), NS_ERROR_FAILURE);
// (5) hook up the document and its content

View File

@ -103,6 +103,7 @@ static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
#undef NOISY_WEBSHELL_LEAKS
#endif
#define NOISY_WEBSHELL_LEAKS
#ifdef NOISY_WEBSHELL_LEAKS
#undef DETECT_WEBSHELL_LEAKS
#define DETECT_WEBSHELL_LEAKS
@ -4167,11 +4168,12 @@ NS_IMETHODIMP nsWebShell::SetDocument(nsIDOMDocument *aDOMDoc,
NS_ENSURE_SUCCESS(NS_OpenURI(getter_AddRefs(dummyChannel), uri, nsnull), NS_ERROR_FAILURE);
// (4) fire start document load notification
nsIStreamListener* outStreamListener=nsnull; // a valid pointer is required for the returned stream listener
NS_ENSURE_SUCCESS(doc->StartDocumentLoad("view", dummyChannel, nsnull, NS_STATIC_CAST(nsIContentViewerContainer*, this),
&outStreamListener),
nsCOMPtr<nsIStreamListener> outStreamListener; // a valid pointer is required for the returned stream listener
// XXX: warning: magic cookie! should get string "view delayedContentLoad"
// from somewhere, maybe nsIHTMLDocument?
NS_ENSURE_SUCCESS(doc->StartDocumentLoad("view delayedContentLoad", dummyChannel, nsnull, NS_STATIC_CAST(nsIContentViewerContainer*, this),
getter_AddRefs(outStreamListener)),
NS_ERROR_FAILURE);
NS_IF_RELEASE(outStreamListener);
NS_ENSURE_SUCCESS(OnStartDocumentLoad(mDocLoader, uri, "load"), NS_ERROR_FAILURE);
// (5) hook up the document and its content