зеркало из https://github.com/mozilla/pjs.git
84136[MLK] - Avoid getting document-parser-sink circularity by delaying StartDocumentLoad call.
r=heikki sr=hyatt a=asa
This commit is contained in:
Родитель
d3f6f9a89d
Коммит
87bbd168a3
|
@ -1223,14 +1223,6 @@ nsXBLService::FetchBindingDocument(nsIContent* aBoundElement, nsIDocument* aBoun
|
|||
rv = NS_OpenURI(getter_AddRefs(channel), aURI, nsnull, loadGroup);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Call StartDocumentLoad
|
||||
nsCOMPtr<nsIStreamListener> listener;
|
||||
if (NS_FAILED(rv = xmlDoc->StartDocumentLoad("loadAsData", channel,
|
||||
loadGroup, nsnull, getter_AddRefs(listener)))) {
|
||||
NS_ERROR("Failure to init XBL doc prior to load.");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> tagName;
|
||||
if (aBoundElement)
|
||||
aBoundElement->GetTag(*getter_AddRefs(tagName));
|
||||
|
@ -1238,9 +1230,19 @@ nsXBLService::FetchBindingDocument(nsIContent* aBoundElement, nsIDocument* aBoun
|
|||
if (tagName.get() == kScrollbarAtom || IsResourceURI(aURI))
|
||||
aForceSyncLoad = PR_TRUE;
|
||||
|
||||
nsCOMPtr<nsIStreamListener> listener;
|
||||
if(!aForceSyncLoad) {
|
||||
if (NS_FAILED(rv = xmlDoc->StartDocumentLoad("loadAsData",
|
||||
channel,
|
||||
loadGroup,
|
||||
nsnull,
|
||||
getter_AddRefs(listener)))) {
|
||||
NS_ERROR("Failure to init XBL doc prior to load.");
|
||||
return rv;
|
||||
}
|
||||
// We can be asynchronous
|
||||
nsXBLStreamListener* xblListener = new nsXBLStreamListener(this, listener, aBoundDocument, doc);
|
||||
NS_ENSURE_TRUE(xblListener,NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsCOMPtr<nsIDOMEventReceiver> rec(do_QueryInterface(doc));
|
||||
rec->AddEventListener(NS_LITERAL_STRING("load"), (nsIDOMLoadListener*)xblListener, PR_FALSE);
|
||||
|
@ -1266,7 +1268,6 @@ nsXBLService::FetchBindingDocument(nsIContent* aBoundElement, nsIDocument* aBoun
|
|||
|
||||
// Now do a blocking synchronous parse of the file.
|
||||
nsCOMPtr<nsIInputStream> in;
|
||||
PRUint32 sourceOffset = 0;
|
||||
rv = channel->Open(getter_AddRefs(in));
|
||||
|
||||
// If we couldn't open the channel, then just return.
|
||||
|
@ -1275,16 +1276,25 @@ nsXBLService::FetchBindingDocument(nsIContent* aBoundElement, nsIDocument* aBoun
|
|||
request = do_QueryInterface(channel);
|
||||
|
||||
NS_ASSERTION(request != nsnull, "no request info");
|
||||
|
||||
NS_ASSERTION(in != nsnull, "no input stream");
|
||||
if (! in) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ENSURE_TRUE(in,NS_ERROR_FAILURE);
|
||||
|
||||
nsProxyStream* proxy = new nsProxyStream();
|
||||
if (! proxy)
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ENSURE_TRUE(proxy,NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
// Call StartDocumentLoad
|
||||
if (NS_FAILED(rv = xmlDoc->StartDocumentLoad("loadAsData",
|
||||
channel,
|
||||
loadGroup,
|
||||
nsnull,
|
||||
getter_AddRefs(listener)))) {
|
||||
NS_ERROR("Failure to init XBL doc prior to load.");
|
||||
return rv;
|
||||
}
|
||||
|
||||
listener->OnStartRequest(request, nsnull);
|
||||
|
||||
while (PR_TRUE) {
|
||||
char buf[1024];
|
||||
PRUint32 readCount;
|
||||
|
@ -1297,6 +1307,7 @@ nsXBLService::FetchBindingDocument(nsIContent* aBoundElement, nsIDocument* aBoun
|
|||
|
||||
proxy->SetBuffer(buf, readCount);
|
||||
|
||||
PRUint32 sourceOffset = 0;
|
||||
rv = listener->OnDataAvailable(request, nsnull, proxy, sourceOffset, readCount);
|
||||
sourceOffset += readCount;
|
||||
if (NS_FAILED(rv))
|
||||
|
|
Загрузка…
Ссылка в новой задаче