Files
palemoon27/dom/xul/nsXULPrototypeCache.cpp
T
roytam1 1e24b22ef4 remove nsINetUtil_ESR_38, fixup and import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1150366 - Remove duplicate d3.js. r=jsantell (71f991da6)
- Bug 1175352 - Refactor LoadInfo arguments to be more self contained (r=bent) (3f7d08164)
- Bug 1181533 - Add nsCRTGlue.h and prtime.h includes to nsDownloadManager.cpp to fix --disable-safe-browsing build bustage. r=froydnj (af338edf1)
- Bug 905127 - Part 1 - Make some functions from nsNetUtil not inline. r=jduell Bug 905127 - Part 2 - remove unnecessary nsNetUtil.h includes r=jduell Bug 905127 - Make some functions from nsNetUtil not inline. r=jduell (bc47d5b3a)
- Bug 1117650 - Part 1: Move all CORS tests into dom/security/test. r=sicking (6f727387c)
- Bug 1117650 - Part 2: Move all MixedContent tests into dom/security/test. r=tanvi (73f273829)
- Bug 1004703 - ignore 'unsafe-inline' if nonce- or hash-source specifed - tests (r=sstamm) (ebf411159)
- Bug 921493 - CSP: test whitelisting of scheme-relative sources (r=dveditz) (f0618b189)
- Bug 1139569 - Optimize update function for element editors in markup view;r=mratcliffe (c60d38dca)
- Partil of Bug 1139644 - Make markupview use sdk timers instead of individual timers for each window;r=pbrosset (8bc1a4d66)
- Bug 1146568 - Avoid unsafe CPOW usage warnings in browser_markupview_tag_edit_08.js; r=bgrins Making use of the devtools test frame-script to set the test node's attributes instead of using a CPOW. (61d7eed64)
- Bug 1146568 - Avoid unsafe CPOW usage in markupview tests, in assertAttributes helper; r=bgrins (efc492d5d)
- Bug 858038 - Allow moving elements in the markupview by drag/drop; r=pbrosset (51d79c15c)
- Bug 1139644 - Flash only relevant attributes in markup view when changed;r=pbrosset (29807fa46)
- Bug 1147128 - Make sure attribute shows up in markup view after removing and setting to the previous value;r=mratcliffe (1947f7417)
- Bug 1147325 - Clear box model timer on markup view destroy. r=pbrosset Prevents 'this._inspector.toolbox is null' spam in mochitest-dt (1d6808b4a)
- Bug 921102 - 1 - Linkify URIs in the inspector; r=tromey, miker This first part adds a parser for node attributes which, given some node information and an attribute name, generates a small AST-like array of objects that tells which parts of the attribute (if any) are links, and what they link to. Using this, the markup-view generates the right HTML structure to display these parts as links. This part 1 doesn't yet allow users to follow these links. (c500e270e)
- Bug 1139667 - CSP tests for fetch(). r=ckirschb (df030457f)
- Bug 1086999 - CSP: Asterisk (*) wildcard should not allow blob:, data:, or filesystem: when matching source expressions - tests (r=sstamm) (dee0f2239)
- Bug 1117650 - Part 3: Move all CSP tests into dom/security/test. r=sstamm (29c95475c)
- Bug 1146566 - 1 - Use devtools common frame-script in markupview tests and add helper; r=bgrins (b10e42468)
- Bug 1146566 - 2 - Avoid using CPOWs in test browser_markupview_tag_edit_03.js; r=bgrins This change updates the browser_markupview_tag_edit_03.js test by making use of the getDomElementInfo message listener to retrieve information about the tested nodes without having to go through CPOWs. (07f0ee3ff)
- Bug 1036324 - Adds option to walker.parents() to not traverse DocShellTreeItems of different types (24123a5d2)
- Bug 921102 - 2 - Markup-view tests for attribute links; r=miker (f6da81799)
- Bug 901250 - Add scroll into view menu item for the inspector. r=bgrins (bfc7518b1)
- Bug 994055 - Part 1: Add a toggle sidebar panel button to the inspector. r=miker This adds a new icon, next to the searchbox (like in the debugger) to expand or collapse the sidebar panel in the inspector. The state is *not* persisted yet when the toolbox is closed. The button is hidden when the toolbox host switches to 'side'. (87730e20a)
- Bug 994055 - Part 2: Add tests for the inspector sidebar toggle button. r=miker (2872c3fbd)
- Bug 921102 - 3 - Open/copy markup-view attribute links; r=bgrins This part adds contextual menu items that become enabled when the user right clicks on an attribute that has a link. Depending on the nature of the link, a new tab will be opened or a node selected. The user can also choose to copy the link in the clipboard. (9b93485f6)
- Bug 921102 - 4 - Tests for the open/copy links on markup-view attributes; r=bgrins (861ba51f6)
2021-05-21 09:14:47 +08:00

664 lines
18 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsXULPrototypeCache.h"
#include "plstr.h"
#include "nsXULPrototypeDocument.h"
#include "nsIServiceManager.h"
#include "nsIURI.h"
#include "nsIChromeRegistry.h"
#include "nsIFile.h"
#include "nsIObjectInputStream.h"
#include "nsIObjectOutputStream.h"
#include "nsIObserverService.h"
#include "nsIStringStream.h"
#include "nsIStorageStream.h"
#include "nsAppDirectoryServiceDefs.h"
#include "js/TracingAPI.h"
#include "mozilla/CSSStyleSheet.h"
#include "mozilla/Preferences.h"
#include "mozilla/scache/StartupCache.h"
#include "mozilla/scache/StartupCacheUtils.h"
#include "mozilla/Telemetry.h"
using namespace mozilla;
using namespace mozilla::scache;
static bool gDisableXULCache = false; // enabled by default
static const char kDisableXULCachePref[] = "nglayout.debug.disable_xul_cache";
static const char kXULCacheInfoKey[] = "nsXULPrototypeCache.startupCache";
static const char kXULCachePrefix[] = "xulcache";
//----------------------------------------------------------------------
static void
UpdategDisableXULCache()
{
// Get the value of "nglayout.debug.disable_xul_cache" preference
gDisableXULCache =
Preferences::GetBool(kDisableXULCachePref, gDisableXULCache);
// Sets the flag if the XUL cache is disabled
if (gDisableXULCache) {
Telemetry::Accumulate(Telemetry::XUL_CACHE_DISABLED, true);
}
}
static void
DisableXULCacheChangedCallback(const char* aPref, void* aClosure)
{
UpdategDisableXULCache();
// Flush the cache, regardless
nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
if (cache)
cache->Flush();
}
//----------------------------------------------------------------------
nsXULPrototypeCache* nsXULPrototypeCache::sInstance = nullptr;
nsXULPrototypeCache::nsXULPrototypeCache()
{
}
nsXULPrototypeCache::~nsXULPrototypeCache()
{
FlushScripts();
}
NS_IMPL_ISUPPORTS(nsXULPrototypeCache, nsIObserver)
/* static */ nsXULPrototypeCache*
nsXULPrototypeCache::GetInstance()
{
if (!sInstance) {
NS_ADDREF(sInstance = new nsXULPrototypeCache());
UpdategDisableXULCache();
Preferences::RegisterCallback(DisableXULCacheChangedCallback,
kDisableXULCachePref);
nsCOMPtr<nsIObserverService> obsSvc =
mozilla::services::GetObserverService();
if (obsSvc) {
nsXULPrototypeCache *p = sInstance;
obsSvc->AddObserver(p, "chrome-flush-skin-caches", false);
obsSvc->AddObserver(p, "chrome-flush-caches", false);
obsSvc->AddObserver(p, "startupcache-invalidate", false);
}
}
return sInstance;
}
//----------------------------------------------------------------------
NS_IMETHODIMP
nsXULPrototypeCache::Observe(nsISupports* aSubject,
const char *aTopic,
const char16_t *aData)
{
if (!strcmp(aTopic, "chrome-flush-skin-caches")) {
FlushSkinFiles();
}
else if (!strcmp(aTopic, "chrome-flush-caches")) {
Flush();
}
else if (!strcmp(aTopic, "startupcache-invalidate")) {
AbortCaching();
}
else {
NS_WARNING("Unexpected observer topic.");
}
return NS_OK;
}
nsXULPrototypeDocument*
nsXULPrototypeCache::GetPrototype(nsIURI* aURI)
{
if (!aURI)
return nullptr;
nsCOMPtr<nsIURI> uriWithoutRef;
aURI->CloneIgnoringRef(getter_AddRefs(uriWithoutRef));
nsXULPrototypeDocument* protoDoc = mPrototypeTable.GetWeak(uriWithoutRef);
if (protoDoc)
return protoDoc;
nsresult rv = BeginCaching(aURI);
if (NS_FAILED(rv))
return nullptr;
// No prototype in XUL memory cache. Spin up the cache Service.
nsCOMPtr<nsIObjectInputStream> ois;
rv = GetInputStream(aURI, getter_AddRefs(ois));
if (NS_FAILED(rv))
return nullptr;
nsRefPtr<nsXULPrototypeDocument> newProto;
rv = NS_NewXULPrototypeDocument(getter_AddRefs(newProto));
if (NS_FAILED(rv))
return nullptr;
rv = newProto->Read(ois);
if (NS_SUCCEEDED(rv)) {
rv = PutPrototype(newProto);
} else {
newProto = nullptr;
}
mInputStreamTable.Remove(aURI);
return newProto;
}
nsresult
nsXULPrototypeCache::PutPrototype(nsXULPrototypeDocument* aDocument)
{
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);
return NS_OK;
}
nsresult
nsXULPrototypeCache::PutStyleSheet(CSSStyleSheet* aStyleSheet)
{
nsIURI* uri = aStyleSheet->GetSheetURI();
mStyleSheetTable.Put(uri, aStyleSheet);
return NS_OK;
}
JSScript*
nsXULPrototypeCache::GetScript(nsIURI* aURI)
{
return mScriptTable.Get(aURI);
}
nsresult
nsXULPrototypeCache::PutScript(nsIURI* aURI,
JS::Handle<JSScript*> aScriptObject)
{
MOZ_ASSERT(aScriptObject, "Need a non-NULL script");
#ifdef DEBUG
if (mScriptTable.Get(aURI)) {
nsAutoCString scriptName;
aURI->GetSpec(scriptName);
nsAutoCString message("Loaded script ");
message += scriptName;
message += " twice (bug 392650)";
NS_WARNING(message.get());
}
#endif
mScriptTable.Put(aURI, aScriptObject);
return NS_OK;
}
nsresult
nsXULPrototypeCache::PutXBLDocumentInfo(nsXBLDocumentInfo* aDocumentInfo)
{
nsIURI* uri = aDocumentInfo->DocumentURI();
nsRefPtr<nsXBLDocumentInfo> info;
mXBLDocTable.Get(uri, getter_AddRefs(info));
if (!info) {
mXBLDocTable.Put(uri, aDocumentInfo);
}
return NS_OK;
}
static PLDHashOperator
FlushSkinXBL(nsIURI* aKey, nsRefPtr<nsXBLDocumentInfo>& aDocInfo, void* aClosure)
{
nsAutoCString str;
aKey->GetPath(str);
PLDHashOperator ret = PL_DHASH_NEXT;
if (!strncmp(str.get(), "/skin", 5)) {
ret = PL_DHASH_REMOVE;
}
return ret;
}
static PLDHashOperator
FlushSkinSheets(nsIURI* aKey, nsRefPtr<CSSStyleSheet>& aSheet, void* aClosure)
{
nsAutoCString str;
aSheet->GetSheetURI()->GetPath(str);
PLDHashOperator ret = PL_DHASH_NEXT;
if (!strncmp(str.get(), "/skin", 5)) {
// This is a skin binding. Add the key to the list.
ret = PL_DHASH_REMOVE;
}
return ret;
}
static PLDHashOperator
FlushScopedSkinStylesheets(nsIURI* aKey, nsRefPtr<nsXBLDocumentInfo> &aDocInfo, void* aClosure)
{
aDocInfo->FlushSkinStylesheets();
return PL_DHASH_NEXT;
}
void
nsXULPrototypeCache::FlushSkinFiles()
{
// Flush out skin XBL files from the cache.
mXBLDocTable.Enumerate(FlushSkinXBL, nullptr);
// Now flush out our skin stylesheets from the cache.
mStyleSheetTable.Enumerate(FlushSkinSheets, nullptr);
// Iterate over all the remaining XBL and make sure cached
// scoped skin stylesheets are flushed and refetched by the
// prototype bindings.
mXBLDocTable.Enumerate(FlushScopedSkinStylesheets, nullptr);
}
void
nsXULPrototypeCache::FlushScripts()
{
mScriptTable.Clear();
}
void
nsXULPrototypeCache::Flush()
{
mPrototypeTable.Clear();
mScriptTable.Clear();
mStyleSheetTable.Clear();
mXBLDocTable.Clear();
}
bool
nsXULPrototypeCache::IsEnabled()
{
return !gDisableXULCache;
}
static bool gDisableXULDiskCache = false; // enabled by default
void
nsXULPrototypeCache::AbortCaching()
{
#ifdef DEBUG_brendan
NS_BREAK();
#endif
// Flush the XUL cache for good measure, in case we cached a bogus/downrev
// script, somehow.
Flush();
// Clear the cache set
mCacheURITable.Clear();
}
nsresult
nsXULPrototypeCache::WritePrototype(nsXULPrototypeDocument* aPrototypeDocument)
{
nsresult rv = NS_OK, rv2 = NS_OK;
if (!StartupCache::GetSingleton())
return NS_OK;
nsCOMPtr<nsIURI> protoURI = aPrototypeDocument->GetURI();
nsCOMPtr<nsIObjectOutputStream> oos;
rv = GetOutputStream(protoURI, getter_AddRefs(oos));
NS_ENSURE_SUCCESS(rv, rv);
rv = aPrototypeDocument->Write(oos);
NS_ENSURE_SUCCESS(rv, rv);
FinishOutputStream(protoURI);
return NS_FAILED(rv) ? rv : rv2;
}
nsresult
nsXULPrototypeCache::GetInputStream(nsIURI* uri, nsIObjectInputStream** stream)
{
nsAutoCString spec(kXULCachePrefix);
nsresult rv = PathifyURI(uri, spec);
if (NS_FAILED(rv))
return NS_ERROR_NOT_AVAILABLE;
nsAutoArrayPtr<char> buf;
uint32_t len;
nsCOMPtr<nsIObjectInputStream> ois;
StartupCache* sc = StartupCache::GetSingleton();
if (!sc)
return NS_ERROR_NOT_AVAILABLE;
rv = sc->GetBuffer(spec.get(), getter_Transfers(buf), &len);
if (NS_FAILED(rv))
return NS_ERROR_NOT_AVAILABLE;
rv = NewObjectInputStreamFromBuffer(buf, len, getter_AddRefs(ois));
NS_ENSURE_SUCCESS(rv, rv);
buf.forget();
mInputStreamTable.Put(uri, ois);
ois.forget(stream);
return NS_OK;
}
nsresult
nsXULPrototypeCache::FinishInputStream(nsIURI* uri) {
mInputStreamTable.Remove(uri);
return NS_OK;
}
nsresult
nsXULPrototypeCache::GetOutputStream(nsIURI* uri, nsIObjectOutputStream** stream)
{
nsresult rv;
nsCOMPtr<nsIObjectOutputStream> objectOutput;
nsCOMPtr<nsIStorageStream> storageStream;
bool found = mOutputStreamTable.Get(uri, getter_AddRefs(storageStream));
if (found) {
objectOutput = do_CreateInstance("mozilla.org/binaryoutputstream;1");
if (!objectOutput) return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<nsIOutputStream> outputStream
= do_QueryInterface(storageStream);
objectOutput->SetOutputStream(outputStream);
} else {
rv = NewObjectOutputWrappedStorageStream(getter_AddRefs(objectOutput),
getter_AddRefs(storageStream),
false);
NS_ENSURE_SUCCESS(rv, rv);
mOutputStreamTable.Put(uri, storageStream);
}
objectOutput.forget(stream);
return NS_OK;
}
nsresult
nsXULPrototypeCache::FinishOutputStream(nsIURI* uri)
{
nsresult rv;
StartupCache* sc = StartupCache::GetSingleton();
if (!sc)
return NS_ERROR_NOT_AVAILABLE;
nsCOMPtr<nsIStorageStream> storageStream;
bool found = mOutputStreamTable.Get(uri, getter_AddRefs(storageStream));
if (!found)
return NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIOutputStream> outputStream
= do_QueryInterface(storageStream);
outputStream->Close();
nsAutoArrayPtr<char> buf;
uint32_t len;
rv = NewBufferFromStorageStream(storageStream, getter_Transfers(buf),
&len);
NS_ENSURE_SUCCESS(rv, rv);
if (!mCacheURITable.GetEntry(uri)) {
nsAutoCString spec(kXULCachePrefix);
rv = PathifyURI(uri, spec);
if (NS_FAILED(rv))
return NS_ERROR_NOT_AVAILABLE;
rv = sc->PutBuffer(spec.get(), buf, len);
if (NS_SUCCEEDED(rv)) {
mOutputStreamTable.Remove(uri);
mCacheURITable.RemoveEntry(uri);
}
}
return rv;
}
// We have data if we're in the middle of writing it or we already
// have it in the cache.
nsresult
nsXULPrototypeCache::HasData(nsIURI* uri, bool* exists)
{
if (mOutputStreamTable.Get(uri, nullptr)) {
*exists = true;
return NS_OK;
}
nsAutoCString spec(kXULCachePrefix);
nsresult rv = PathifyURI(uri, spec);
if (NS_FAILED(rv)) {
*exists = false;
return NS_OK;
}
nsAutoArrayPtr<char> buf;
uint32_t len;
StartupCache* sc = StartupCache::GetSingleton();
if (sc)
rv = sc->GetBuffer(spec.get(), getter_Transfers(buf), &len);
else {
*exists = false;
return NS_OK;
}
*exists = NS_SUCCEEDED(rv);
return NS_OK;
}
static void
CachePrefChangedCallback(const char* aPref, void* aClosure)
{
bool wasEnabled = !gDisableXULDiskCache;
gDisableXULDiskCache =
Preferences::GetBool(kDisableXULCachePref,
gDisableXULDiskCache);
if (wasEnabled && gDisableXULDiskCache) {
nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
if (cache)
cache->AbortCaching();
}
}
nsresult
nsXULPrototypeCache::BeginCaching(nsIURI* aURI)
{
nsresult rv, tmp;
nsAutoCString path;
aURI->GetPath(path);
if (!StringEndsWith(path, NS_LITERAL_CSTRING(".xul")))
return NS_ERROR_NOT_AVAILABLE;
StartupCache* startupCache = StartupCache::GetSingleton();
if (!startupCache)
return NS_ERROR_FAILURE;
gDisableXULDiskCache =
Preferences::GetBool(kDisableXULCachePref, gDisableXULDiskCache);
Preferences::RegisterCallback(CachePrefChangedCallback,
kDisableXULCachePref);
if (gDisableXULDiskCache)
return NS_ERROR_NOT_AVAILABLE;
// Get the chrome directory to validate against the one stored in the
// cache file, or to store there if we're generating a new file.
nsCOMPtr<nsIFile> chromeDir;
rv = NS_GetSpecialDirectory(NS_APP_CHROME_DIR, getter_AddRefs(chromeDir));
if (NS_FAILED(rv))
return rv;
nsAutoCString chromePath;
rv = chromeDir->GetNativePath(chromePath);
if (NS_FAILED(rv))
return rv;
// XXXbe we assume the first package's locale is the same as the locale of
// all subsequent packages of cached chrome URIs....
nsAutoCString package;
rv = aURI->GetHost(package);
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIXULChromeRegistry> chromeReg
= do_GetService(NS_CHROMEREGISTRY_CONTRACTID, &rv);
nsAutoCString locale;
rv = chromeReg->GetSelectedLocale(package, locale);
if (NS_FAILED(rv))
return rv;
nsAutoCString fileChromePath, fileLocale;
nsAutoArrayPtr<char> buf;
uint32_t len, amtRead;
nsCOMPtr<nsIObjectInputStream> objectInput;
rv = startupCache->GetBuffer(kXULCacheInfoKey, getter_Transfers(buf),
&len);
if (NS_SUCCEEDED(rv))
rv = NewObjectInputStreamFromBuffer(buf, len, getter_AddRefs(objectInput));
if (NS_SUCCEEDED(rv)) {
buf.forget();
rv = objectInput->ReadCString(fileLocale);
tmp = objectInput->ReadCString(fileChromePath);
if (NS_FAILED(tmp)) {
rv = tmp;
}
if (NS_FAILED(rv) ||
(!fileChromePath.Equals(chromePath) ||
!fileLocale.Equals(locale))) {
// Our cache won't be valid in this case, we'll need to rewrite.
// XXX This blows away work that other consumers (like
// mozJSComponentLoader) have done, need more fine-grained control.
startupCache->InvalidateCache();
rv = NS_ERROR_UNEXPECTED;
}
} else if (rv != NS_ERROR_NOT_AVAILABLE)
// NS_ERROR_NOT_AVAILABLE is normal, usually if there's no cachefile.
return rv;
if (NS_FAILED(rv)) {
// Either the cache entry was invalid or it didn't exist, so write it now.
nsCOMPtr<nsIObjectOutputStream> objectOutput;
nsCOMPtr<nsIInputStream> inputStream;
nsCOMPtr<nsIStorageStream> storageStream;
rv = NewObjectOutputWrappedStorageStream(getter_AddRefs(objectOutput),
getter_AddRefs(storageStream),
false);
if (NS_SUCCEEDED(rv)) {
rv = objectOutput->WriteStringZ(locale.get());
tmp = objectOutput->WriteStringZ(chromePath.get());
if (NS_FAILED(tmp)) {
rv = tmp;
}
tmp = objectOutput->Close();
if (NS_FAILED(tmp)) {
rv = tmp;
}
tmp = storageStream->NewInputStream(0, getter_AddRefs(inputStream));
if (NS_FAILED(tmp)) {
rv = tmp;
}
}
if (NS_SUCCEEDED(rv)) {
uint64_t len64;
rv = inputStream->Available(&len64);
if (NS_SUCCEEDED(rv)) {
if (len64 <= UINT32_MAX)
len = (uint32_t)len64;
else
rv = NS_ERROR_FILE_TOO_BIG;
}
}
if (NS_SUCCEEDED(rv)) {
buf = new char[len];
rv = inputStream->Read(buf, len, &amtRead);
if (NS_SUCCEEDED(rv) && len == amtRead)
rv = startupCache->PutBuffer(kXULCacheInfoKey, buf, len);
else {
rv = NS_ERROR_UNEXPECTED;
}
}
// Failed again, just bail.
if (NS_FAILED(rv)) {
startupCache->InvalidateCache();
return NS_ERROR_FAILURE;
}
}
// Success! Insert this URI into the mCacheURITable
// and commit locals to globals.
mCacheURITable.PutEntry(aURI);
return NS_OK;
}
static PLDHashOperator
MarkXBLInCCGeneration(nsIURI* aKey, nsRefPtr<nsXBLDocumentInfo> &aDocInfo,
void* aClosure)
{
uint32_t* gen = static_cast<uint32_t*>(aClosure);
aDocInfo->MarkInCCGeneration(*gen);
return PL_DHASH_NEXT;
}
static PLDHashOperator
MarkXULInCCGeneration(nsIURI* aKey, nsRefPtr<nsXULPrototypeDocument> &aDoc,
void* aClosure)
{
uint32_t* gen = static_cast<uint32_t*>(aClosure);
aDoc->MarkInCCGeneration(*gen);
return PL_DHASH_NEXT;
}
void
nsXULPrototypeCache::MarkInCCGeneration(uint32_t aGeneration)
{
mXBLDocTable.Enumerate(MarkXBLInCCGeneration, &aGeneration);
mPrototypeTable.Enumerate(MarkXULInCCGeneration, &aGeneration);
}
static PLDHashOperator
MarkScriptsInGC(nsIURI* aKey, JS::Heap<JSScript*>& aScript, void* aClosure)
{
JSTracer* trc = static_cast<JSTracer*>(aClosure);
JS_CallScriptTracer(trc, &aScript, "nsXULPrototypeCache script");
return PL_DHASH_NEXT;
}
void
nsXULPrototypeCache::MarkInGC(JSTracer* aTrc)
{
mScriptTable.Enumerate(MarkScriptsInGC, aTrc);
}