Backed out changeset 41045faa0ef6 due to leaks

This commit is contained in:
Jonas Sicking 2009-01-23 15:08:41 -08:00
Родитель c4c9640ef1
Коммит d25702e3ce
14 изменённых файлов: 39 добавлений и 140 удалений

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

@ -1105,11 +1105,6 @@ public:
virtual void EnumerateExternalResources(nsSubDocEnumFunc aCallback,
void* aData) = 0;
/**
* Dispatch DOMContentLoaded and DOMFrameContentLoaded events
*/
virtual void DispatchContentLoadedEvents() = 0;
/**
* Return whether the document is currently showing (in the sense of
* OnPageShow() having been called already and OnPageHide() not having been

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

@ -349,20 +349,19 @@ nsContentSink::ScriptAvailable(nsresult aResult,
mParser->ScriptExecuting();
}
if (count == 0) {
return NS_OK;
}
// aElement will not be in mScriptElements if a <script> was added
// using the DOM during loading, or if the script was inline and thus
// never blocked.
NS_ASSERTION(count == 0 ||
mScriptElements.IndexOf(aElement) == PRUint32(count - 1) ||
NS_ASSERTION(mScriptElements.IndexOf(aElement) == PRUint32(count - 1) ||
mScriptElements.IndexOf(aElement) == PRUint32(-1),
"script found at unexpected position");
// Check if this is the element we were waiting for
if (count == 0 || aElement != mScriptElements[count - 1]) {
if (mDidGetReadyToCallDidBuildModelCall &&
!mScriptLoader->HasPendingOrCurrentScripts()) {
ContinueInterruptedParsingAsyncIfEnabled();
}
if (aElement != mScriptElements[count - 1]) {
return NS_OK;
}
@ -388,7 +387,7 @@ nsContentSink::ScriptAvailable(nsresult aResult,
// script load, assuming that that error code means that the user
// stopped the load through some action (like clicking a link). See
// http://bugzilla.mozilla.org/show_bug.cgi?id=243392.
ContinueInterruptedParsingAsyncIfEnabled();
ContinueInterruptedParsingAsync();
}
}
@ -407,10 +406,6 @@ nsContentSink::ScriptEvaluated(nsresult aResult,
// Check if this is the element we were waiting for
PRInt32 count = mScriptElements.Count();
if (count == 0 || aElement != mScriptElements[count - 1]) {
if (mDidGetReadyToCallDidBuildModelCall &&
!mScriptLoader->HasPendingOrCurrentScripts()) {
ContinueInterruptedParsingAsyncIfEnabled();
}
return NS_OK;
}
@ -421,7 +416,9 @@ nsContentSink::ScriptEvaluated(nsresult aResult,
PostEvaluateScript(aElement);
}
ContinueInterruptedParsingAsyncIfEnabled();
if (mParser && mParser->IsParserEnabled()) {
ContinueInterruptedParsingAsync();
}
return NS_OK;
}
@ -1744,25 +1741,12 @@ nsContentSink::ContinueInterruptedParsingIfEnabled()
}
void
nsContentSink::ContinueInterruptedParsingAsyncIfEnabled()
nsContentSink::ContinueInterruptedParsingAsync()
{
if (mParser && mParser->IsParserEnabled()) {
nsCOMPtr<nsIRunnable> ev = new nsRunnableMethod<nsContentSink>(this,
&nsContentSink::ContinueInterruptedParsingIfEnabled);
nsCOMPtr<nsIRunnable> ev = new nsRunnableMethod<nsContentSink>(this,
&nsContentSink::ContinueInterruptedParsingIfEnabled);
NS_DispatchToCurrentThread(ev);
}
}
PRBool
nsContentSink::ReadyToCallDidBuildModelImpl()
{
if (!mDidGetReadyToCallDidBuildModelCall && mDocument) {
mDocument->DispatchContentLoadedEvents();
}
mDidGetReadyToCallDidBuildModelCall = PR_TRUE;
return !mScriptLoader || !mScriptLoader->HasPendingOrCurrentScripts();
NS_DispatchToCurrentThread(ev);
}
// URIs: action, href, src, longdesc, usemap, cite

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

@ -138,7 +138,6 @@ class nsContentSink : public nsICSSLoaderObserver,
NS_HIDDEN_(nsresult) DidProcessATokenImpl(void);
NS_HIDDEN_(void) WillBuildModelImpl(void);
NS_HIDDEN_(void) DidBuildModelImpl(void);
NS_HIDDEN_(PRBool) ReadyToCallDidBuildModelImpl(void);
NS_HIDDEN_(void) DropParserAndPerfHint(void);
void NotifyAppend(nsIContent* aContent, PRUint32 aStartIndex);
@ -300,7 +299,7 @@ private:
protected:
void ContinueInterruptedParsingAsyncIfEnabled();
void ContinueInterruptedParsingAsync();
void ContinueInterruptedParsingIfEnabled();
nsCOMPtr<nsIDocument> mDocument;
@ -351,7 +350,6 @@ protected:
PRUint8 mDeferredLayoutStart : 1;
// If true, we deferred notifications until sheets load
PRUint8 mDeferredFlushTags : 1;
PRUint8 mDidGetReadyToCallDidBuildModelCall : 1;
// -- Can interrupt parsing members --
PRUint32 mDelayTimerStart;

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

@ -3893,8 +3893,6 @@ nsDocument::RemoveIDTargetObserver(nsIAtom* aID,
void
nsDocument::DispatchContentLoadedEvents()
{
SetReadyStateInternal(READYSTATE_INTERACTIVE);
// If you add early returns from this method, make sure you're
// calling UnblockOnload properly.
@ -3968,7 +3966,9 @@ nsDocument::DispatchContentLoadedEvents()
} while (parent);
}
mScriptLoader->EndDeferringScripts();
if (mScriptLoader) {
mScriptLoader->EndDeferringScripts();
}
UnblockOnload(PR_TRUE);
}
@ -3985,6 +3985,17 @@ nsDocument::EndLoad()
}
NS_DOCUMENT_NOTIFY_OBSERVERS(EndLoad, (this));
SetReadyStateInternal(READYSTATE_INTERACTIVE);
if (!mSynchronousDOMContentLoaded) {
nsRefPtr<nsIRunnable> ev =
new nsRunnableMethod<nsDocument>(this,
&nsDocument::DispatchContentLoadedEvents);
NS_DispatchToCurrentThread(ev);
} else {
DispatchContentLoadedEvents();
}
}
void

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

@ -981,7 +981,6 @@ public:
ExternalResourceLoad** aPendingLoad);
virtual NS_HIDDEN_(void)
EnumerateExternalResources(nsSubDocEnumFunc aCallback, void* aData);
virtual void DispatchContentLoadedEvents();
#ifdef MOZ_SMIL
nsSMILAnimationController* GetAnimationController();
@ -1026,6 +1025,8 @@ protected:
static PRBool CheckGetElementByIdArg(const nsIAtom* aId);
nsIdentifierMapEntry* GetElementByIdInternal(nsIAtom* aID);
void DispatchContentLoadedEvents();
void RetrieveRelevantHeaders(nsIChannel *aChannel);
static PRBool TryChannelCharset(nsIChannel *aChannel,
@ -1181,6 +1182,8 @@ protected:
PRPackedBool mDelayFrameLoaderInitialization:1;
PRPackedBool mSynchronousDOMContentLoaded:1;
// If true, we have an input encoding. If this is false, then the
// document was created entirely in memory
PRPackedBool mHaveInputEncoding:1;

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

@ -208,14 +208,6 @@ public:
*/
void EndDeferringScripts();
/**
* Returns the number of pending scripts, deferred or not.
*/
PRUint32 HasPendingOrCurrentScripts()
{
return mCurrentScript || GetFirstPendingRequest();
}
/**
* Adds aURI to the preload list and starts loading it.
*

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

@ -282,7 +282,6 @@ _TEST_FILES = test_bug5141.html \
file_XHRSendData_doc.xml \
file_XHRSendData_doc.xml^headers^ \
test_bug466751.xhtml \
test_bug461555.html \
$(NULL)
# Disabled for now. Mochitest isn't reliable enough for these.

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

@ -1,64 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=461555
-->
<head>
<title>Test for Bug 461555</title>
<script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body onload="done()">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=461555">Mozilla Bug 461555</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<script>
SimpleTest.waitForExplicitFinish();
function writeIt(n) {
document.write("<span>" + n + "</span>");
}
var recur = 0;
function externalScript() {
if (++recur == 3) {
return;
}
base = (recur-1) * 4
writeIt(7 + base);
s = document.createElement("script");
s.src = "data:text/plain,writeIt(" + (9+base) + ");writeIt(" + (10+base) + ");externalScript();";
document.body.appendChild(s);
writeIt(8 + base);
}
function done() {
nodes = document.getElementsByTagName('span');
is(nodes.length, 14, "wrong length");
for (i = 0; i < nodes.length; ++i) {
is(nodes[i].textContent, i+1, "wrong order");
}
SimpleTest.finish();
}
document.addEventListener("DOMContentLoaded", function() {
writeIt(3);
}, false);
writeIt(1);
</script>
<script defer>
writeIt(4);
</script>
<script>
writeIt(2);
</script>
<script defer src="data:text/plain,writeIt(5);writeIt(6);"></script>
<script defer src="data:text/plain,externalScript();"></script>

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

@ -185,7 +185,6 @@ public:
NS_IMETHOD WillParse(void);
NS_IMETHOD WillBuildModel(void);
NS_IMETHOD DidBuildModel(void);
virtual PRBool ReadyToCallDidBuildModel(void);
NS_IMETHOD WillInterrupt(void);
NS_IMETHOD WillResume(void);
NS_IMETHOD SetParser(nsIParser* aParser);
@ -1838,12 +1837,6 @@ HTMLContentSink::DidBuildModel(void)
return NS_OK;
}
PRBool
HTMLContentSink::ReadyToCallDidBuildModel()
{
return ReadyToCallDidBuildModelImpl();
}
NS_IMETHODIMP
HTMLContentSink::SetParser(nsIParser* aParser)
{

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

@ -383,12 +383,6 @@ nsXMLContentSink::DidBuildModel()
return NS_OK;
}
PRBool
nsXMLContentSink::ReadyToCallDidBuildModel()
{
return ReadyToCallDidBuildModelImpl();
}
NS_IMETHODIMP
nsXMLContentSink::OnDocumentCreated(nsIDocument* aResultDocument)
{

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

@ -93,7 +93,6 @@ public:
NS_IMETHOD WillParse(void);
NS_IMETHOD WillBuildModel(void);
NS_IMETHOD DidBuildModel(void);
virtual PRBool ReadyToCallDidBuildModel(void);
NS_IMETHOD WillInterrupt(void);
NS_IMETHOD WillResume(void);
NS_IMETHOD SetParser(nsIParser* aParser);

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

@ -540,8 +540,10 @@ nsXMLDocument::EndLoad()
mChannelIsPending = PR_FALSE;
mLoopingForSyncLoad = PR_FALSE;
mSynchronousDOMContentLoaded = (mLoadedAsData || mLoadedAsInteractiveData);
nsDocument::EndLoad();
if (mLoadedAsData || mLoadedAsInteractiveData) {
if (mSynchronousDOMContentLoaded) {
mSynchronousDOMContentLoaded = PR_FALSE;
nsDocument::SetReadyStateInternal(nsIDocument::READYSTATE_COMPLETE);
// Generate a document load event for the case when an XML
// document was loaded as pure data without any presentation

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

@ -56,8 +56,8 @@
class nsIParser;
#define NS_ICONTENT_SINK_IID \
{ 0xcfa3643b, 0xee60, 0x4bf0, \
{ 0xbc, 0x83, 0x49, 0x95, 0xdb, 0xbc, 0xda, 0x75 } }
{ 0x94ec4df1, 0x6885, 0x4b1f, \
{ 0x85, 0x10, 0xe3, 0x5f, 0x4f, 0x36, 0xea, 0xaa } }
class nsIContentSink : public nsISupports {
public:
@ -88,12 +88,6 @@ public:
*/
NS_IMETHOD DidBuildModel()=0;
/**
* Thie method gets caller right before DidBuildModel is called.
* If false
*/
virtual PRBool ReadyToCallDidBuildModel() { return PR_TRUE; };
/**
* This method gets called when the parser gets i/o blocked,
* and wants to notify the sink that it may be a while before

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

@ -1525,8 +1525,7 @@ nsParser::DidBuildModel(nsresult anErrorCode)
if (IsComplete()) {
if (mParserContext && !mParserContext->mPrevContext) {
if (mParserContext->mDTD && mSink &&
mSink->ReadyToCallDidBuildModel()) {
if (mParserContext->mDTD) {
result = mParserContext->mDTD->DidBuildModel(anErrorCode,PR_TRUE,this,mSink);
}