зеркало из https://github.com/mozilla/gecko-dev.git
Restore missing deserialization call to the XUL content sink's OpenScript method, to avoid slow-loading a .js file already in the FastLoad file from a previous session (188744, r=jrgm, sr=ben).
This commit is contained in:
Родитель
b8d97d8b8c
Коммит
b11fb7ca9d
|
@ -5202,8 +5202,11 @@ nsXULPrototypeScript::DeserializeOutOfLineScript(nsIObjectInputStream* aInput,
|
|||
nsCOMPtr<nsIFastLoadService> fastLoadService;
|
||||
cache->GetFastLoadService(getter_AddRefs(fastLoadService));
|
||||
|
||||
nsCOMPtr<nsIObjectInputStream> objectInput;
|
||||
if (fastLoadService)
|
||||
// Allow callers to pass null for aInput, meaning
|
||||
// "use the FastLoad service's default input stream."
|
||||
// See nsXULContentSink.cpp for one use of this.
|
||||
nsCOMPtr<nsIObjectInputStream> objectInput = aInput;
|
||||
if (! objectInput && fastLoadService)
|
||||
fastLoadService->GetInputStream(getter_AddRefs(objectInput));
|
||||
|
||||
if (objectInput) {
|
||||
|
@ -5233,7 +5236,7 @@ nsXULPrototypeScript::DeserializeOutOfLineScript(nsIObjectInputStream* aInput,
|
|||
nsCAutoString spec;
|
||||
mSrcURI->GetAsciiSpec(spec);
|
||||
rv = fastLoadService->StartMuxedDocument(mSrcURI, spec.get(),
|
||||
nsIFastLoadService::NS_FASTLOAD_READ);
|
||||
nsIFastLoadService::NS_FASTLOAD_READ);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = fastLoadService->SelectMuxedDocument(mSrcURI, getter_AddRefs(oldURI));
|
||||
} else {
|
||||
|
@ -5247,8 +5250,9 @@ nsXULPrototypeScript::DeserializeOutOfLineScript(nsIObjectInputStream* aInput,
|
|||
rv = NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
// Don't reflect errors into rv: mJSObject will be null
|
||||
// after any error, which suffices to cause the script to
|
||||
// We do reflect errors into rv, but our caller may want to
|
||||
// ignore our return value, because mJSObject will be null
|
||||
// after any error, and that suffices to cause the script to
|
||||
// be reloaded (from the src= URI, if any) and recompiled.
|
||||
// We're better off slow-loading than bailing out due to a
|
||||
// FastLoad error.
|
||||
|
@ -5258,7 +5262,7 @@ nsXULPrototypeScript::DeserializeOutOfLineScript(nsIObjectInputStream* aInput,
|
|||
if (NS_SUCCEEDED(rv) && mSrcURI) {
|
||||
rv = fastLoadService->EndMuxedDocument(mSrcURI);
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (NS_SUCCEEDED(rv) && oldURI) {
|
||||
nsCOMPtr<nsIURI> tempURI;
|
||||
rv = fastLoadService->SelectMuxedDocument(oldURI, getter_AddRefs(tempURI));
|
||||
|
||||
|
|
|
@ -1437,6 +1437,22 @@ XULContentSinkImpl::OpenScript(const PRUnichar** aAttributes,
|
|||
delete script;
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Attempt to deserialize an out-of-line script from the FastLoad
|
||||
// file right away. Otherwise we'll end up reloading the script and
|
||||
// corrupting the FastLoad file trying to serialize it, in the case
|
||||
// where it's already there.
|
||||
nsCOMPtr<nsIDocument> doc(do_QueryReferent(mDocument));
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObject;
|
||||
doc->GetScriptGlobalObject(getter_AddRefs(globalObject));
|
||||
if (globalObject) {
|
||||
nsCOMPtr<nsIScriptContext> scriptContext;
|
||||
globalObject->GetContext(getter_AddRefs(scriptContext));
|
||||
if (scriptContext)
|
||||
script->DeserializeOutOfLineScript(nsnull, scriptContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsVoidArray* children;
|
||||
|
|
|
@ -5804,13 +5804,14 @@ nsXULDocument::OnStreamComplete(nsIStreamLoader* aLoader,
|
|||
if (useXULCache)
|
||||
gXULCache->GetFastLoadService(getter_AddRefs(fastLoadService));
|
||||
|
||||
nsresult rv2 = NS_OK;
|
||||
if (fastLoadService) {
|
||||
nsCAutoString urispec;
|
||||
uri->GetAsciiSpec(urispec);
|
||||
rv = fastLoadService->StartMuxedDocument(uri, urispec.get(),
|
||||
nsIFastLoadService::NS_FASTLOAD_WRITE);
|
||||
NS_ASSERTION(rv != NS_ERROR_NOT_AVAILABLE, "reading FastLoad?!");
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv2 = fastLoadService->StartMuxedDocument(uri, urispec.get(),
|
||||
nsIFastLoadService::NS_FASTLOAD_WRITE);
|
||||
NS_ASSERTION(rv2 != NS_ERROR_NOT_AVAILABLE, "reading FastLoad?!");
|
||||
if (NS_SUCCEEDED(rv2)) {
|
||||
nsCOMPtr<nsIURI> oldURI;
|
||||
fastLoadService->SelectMuxedDocument(uri, getter_AddRefs(oldURI));
|
||||
}
|
||||
|
@ -5825,7 +5826,7 @@ nsXULDocument::OnStreamComplete(nsIStreamLoader* aLoader,
|
|||
// XXXbe maybe we should...
|
||||
// NB: we don't need to Select mDocumentURL again, because scripts
|
||||
// load after their including prototype document has fully loaded.
|
||||
if (fastLoadService)
|
||||
if (fastLoadService && NS_SUCCEEDED(rv2))
|
||||
fastLoadService->EndMuxedDocument(uri);
|
||||
|
||||
aStatus = rv;
|
||||
|
@ -5848,8 +5849,8 @@ nsXULDocument::OnStreamComplete(nsIStreamLoader* aLoader,
|
|||
// not cache that script object without a prototype cache entry
|
||||
// containing a companion nsXULPrototypeScript node that owns a
|
||||
// GC root protecting the script object. Otherwise, the script
|
||||
// cache entry will dangle once uncached prototype document is
|
||||
// released when its owning nsXULDocument is unloaded.
|
||||
// cache entry will dangle once the uncached prototype document
|
||||
// is released when its owning nsXULDocument is unloaded.
|
||||
//
|
||||
// (See http://bugzilla.mozilla.org/show_bug.cgi?id=98207 for
|
||||
// the true crime story.)
|
||||
|
|
|
@ -257,7 +257,7 @@ nsXULPrototypeCache::GetPrototype(nsIURI* aURI, nsIXULPrototypeDocument** _resul
|
|||
gFastLoadService->GetInputStream(getter_AddRefs(objectInput));
|
||||
|
||||
rv = StartFastLoadingURI(aURI, nsIFastLoadService::NS_FASTLOAD_READ);
|
||||
if (NS_SUCCEEDED (rv)) {
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIURI> oldURI;
|
||||
gFastLoadService->SelectMuxedDocument(aURI, getter_AddRefs(oldURI));
|
||||
|
||||
|
@ -663,7 +663,7 @@ nsXULPrototypeCache::WritePrototype(nsIXULPrototypeDocument* aPrototypeDocument)
|
|||
|
||||
if (objectOutput) {
|
||||
rv = StartFastLoadingURI(protoURI, nsIFastLoadService::NS_FASTLOAD_WRITE);
|
||||
if (NS_SUCCEEDED (rv)) {
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Re-select the URL of the current prototype, as out-of-line script loads
|
||||
// may have changed
|
||||
nsCOMPtr<nsIURI> oldURI;
|
||||
|
@ -827,18 +827,16 @@ nsXULPrototypeCache::StartFastLoad(nsIURI* aURI)
|
|||
{
|
||||
nsresult rv;
|
||||
|
||||
PRBool isChrome = PR_FALSE;
|
||||
nsCAutoString path;
|
||||
aURI->GetPath(path);
|
||||
PRInt32 length = path.Length();
|
||||
const nsACString& extn = Substring(path, path.Length()-4, 4);
|
||||
if (! extn.Equals(NS_LITERAL_CSTRING(".xul")))
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
nsIURIKey key(aURI);
|
||||
|
||||
// Test gFastLoadList to decide whether this is the first nsXULDocument
|
||||
// participating in FastLoad. If gFastLoadList is non-null, this document
|
||||
// Test gFastLoadFile to decide whether this is the first nsXULDocument
|
||||
// participating in FastLoad. If gFastLoadFile is non-null, this document
|
||||
// must not be first, but it can join the FastLoad process. Examples of
|
||||
// multiple master documents participating include hiddenWindow.xul and
|
||||
// navigator.xul on the Mac, and multiple-app-component (e.g., mailnews
|
||||
|
|
Загрузка…
Ссылка в новой задаче