Bug 1034999 - fix XUL cache and overlay system to ignore refs/hashes, r=smaug,mossop

This commit is contained in:
Gijs Kruitbosch 2014-09-16 14:57:45 +02:00
parent b610351b77
commit 71fe07483f
2 changed files with 32 additions and 6 deletions

View File

@ -681,7 +681,11 @@ NS_IMETHODIMP
nsChromeRegistryChrome::GetStyleOverlays(nsIURI *aChromeURL,
nsISimpleEnumerator **aResult)
{
const nsCOMArray<nsIURI>* parray = mStyleHash.GetArray(aChromeURL);
nsCOMPtr<nsIURI> chromeURLWithoutHash;
if (aChromeURL) {
aChromeURL->CloneIgnoringRef(getter_AddRefs(chromeURLWithoutHash));
}
const nsCOMArray<nsIURI>* parray = mStyleHash.GetArray(chromeURLWithoutHash);
if (!parray)
return NS_NewEmptyEnumerator(aResult);
@ -692,7 +696,11 @@ NS_IMETHODIMP
nsChromeRegistryChrome::GetXULOverlays(nsIURI *aChromeURL,
nsISimpleEnumerator **aResult)
{
const nsCOMArray<nsIURI>* parray = mOverlayHash.GetArray(aChromeURL);
nsCOMPtr<nsIURI> chromeURLWithoutHash;
if (aChromeURL) {
aChromeURL->CloneIgnoringRef(getter_AddRefs(chromeURLWithoutHash));
}
const nsCOMArray<nsIURI>* parray = mOverlayHash.GetArray(chromeURLWithoutHash);
if (!parray)
return NS_NewEmptyEnumerator(aResult);
@ -895,7 +903,10 @@ nsChromeRegistryChrome::ManifestOverlay(ManifestProcessingContext& cx, int linen
return;
}
mOverlayHash.Add(baseuri, overlayuri);
nsCOMPtr<nsIURI> baseuriWithoutHash;
baseuri->CloneIgnoringRef(getter_AddRefs(baseuriWithoutHash));
mOverlayHash.Add(baseuriWithoutHash, overlayuri);
}
void
@ -920,7 +931,10 @@ nsChromeRegistryChrome::ManifestStyle(ManifestProcessingContext& cx, int lineno,
return;
}
mStyleHash.Add(baseuri, overlayuri);
nsCOMPtr<nsIURI> baseuriWithoutHash;
baseuri->CloneIgnoringRef(getter_AddRefs(baseuriWithoutHash));
mStyleHash.Add(baseuriWithoutHash, overlayuri);
}
void

View File

@ -131,7 +131,13 @@ nsXULPrototypeCache::Observe(nsISupports* aSubject,
nsXULPrototypeDocument*
nsXULPrototypeCache::GetPrototype(nsIURI* aURI)
{
nsXULPrototypeDocument* protoDoc = mPrototypeTable.GetWeak(aURI);
if (!aURI)
return nullptr;
nsCOMPtr<nsIURI> uriWithoutRef;
aURI->CloneIgnoringRef(getter_AddRefs(uriWithoutRef));
nsXULPrototypeDocument* protoDoc = mPrototypeTable.GetWeak(uriWithoutRef);
if (protoDoc)
return protoDoc;
@ -164,7 +170,13 @@ nsXULPrototypeCache::GetPrototype(nsIURI* aURI)
nsresult
nsXULPrototypeCache::PutPrototype(nsXULPrototypeDocument* aDocument)
{
nsCOMPtr<nsIURI> uri = aDocument->GetURI();
if (!aDocument->GetURI()) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIURI> uri;
aDocument->GetURI()->CloneIgnoringRef(getter_AddRefs(uri));
// Put() releases any old value and addrefs the new one
mPrototypeTable.Put(uri, aDocument);