mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 660121 Remove all pref related methods from nsContentUtils r=roc
This commit is contained in:
parent
a28bd9e01f
commit
85c451e309
@ -77,7 +77,6 @@ static fp_except_t oldmask = fpsetmask(~allmask);
|
||||
#include "nsTArray.h"
|
||||
#include "nsTextFragment.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIPrefBranch2.h"
|
||||
#include "mozilla/AutoRestore.h"
|
||||
#include "nsINode.h"
|
||||
#include "nsHashtable.h"
|
||||
@ -104,7 +103,6 @@ class imgIDecoderObserver;
|
||||
class imgIRequest;
|
||||
class imgILoader;
|
||||
class imgICache;
|
||||
class nsIPrefBranch2;
|
||||
class nsIImageLoadingContent;
|
||||
class nsIDOMHTMLFormElement;
|
||||
class nsIDOMDocument;
|
||||
@ -129,8 +127,6 @@ class nsPIDOMWindow;
|
||||
class nsPIDOMEventTarget;
|
||||
class nsIPresShell;
|
||||
class nsIXPConnectJSObjectHolder;
|
||||
class nsPrefOldCallback;
|
||||
class nsPrefObserverHashKey;
|
||||
#ifdef MOZ_XTF
|
||||
class nsIXTFService;
|
||||
#endif
|
||||
@ -146,11 +142,6 @@ struct nsIntMargin;
|
||||
class nsPIDOMWindow;
|
||||
class nsIDocumentLoaderFactory;
|
||||
|
||||
#ifndef have_PrefChangedFunc_typedef
|
||||
typedef int (*PR_CALLBACK PrefChangedFunc)(const char *, void *);
|
||||
#define have_PrefChangedFunc_typedef
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
namespace layers {
|
||||
@ -561,17 +552,6 @@ public:
|
||||
static void SplitExpatName(const PRUnichar *aExpatName, nsIAtom **aPrefix,
|
||||
nsIAtom **aTagName, PRInt32 *aNameSpaceID);
|
||||
|
||||
static void RegisterPrefCallback(const char *aPref,
|
||||
PrefChangedFunc aCallback,
|
||||
void * aClosure);
|
||||
static void UnregisterPrefCallback(const char *aPref,
|
||||
PrefChangedFunc aCallback,
|
||||
void * aClosure);
|
||||
static void AddBoolPrefVarCache(const char* aPref, PRBool* aVariable,
|
||||
PRBool aDefault = PR_FALSE);
|
||||
static void AddIntPrefVarCache(const char* aPref, PRInt32* aVariable,
|
||||
PRInt32 aDefault = 0);
|
||||
|
||||
// Get a permission-manager setting for the given uri and type.
|
||||
// If the pref doesn't exist or if it isn't ALLOW_ACTION, PR_FALSE is
|
||||
// returned, otherwise PR_TRUE is returned.
|
||||
@ -1791,11 +1771,6 @@ private:
|
||||
static nsIXTFService *sXTFService;
|
||||
#endif
|
||||
|
||||
static nsIPrefBranch2 *sPrefBranch;
|
||||
// For old compatibility of RegisterPrefCallback
|
||||
static nsRefPtrHashtable<nsPrefObserverHashKey, nsPrefOldCallback>
|
||||
*sPrefCallbackTable;
|
||||
|
||||
static bool sImgLoaderInitialized;
|
||||
static void InitImgLoader();
|
||||
|
||||
|
@ -44,7 +44,6 @@
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsCSPService.h"
|
||||
#include "nsIContentSecurityPolicy.h"
|
||||
#include "nsIChannelPolicy.h"
|
||||
@ -55,6 +54,9 @@
|
||||
#include "nsChannelProperties.h"
|
||||
#include "nsIAsyncVerifyRedirectCallback.h"
|
||||
#include "nsAsyncRedirectVerifyHelper.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
/* Keeps track of whether or not CSP is enabled */
|
||||
PRBool CSPService::sCSPEnabled = PR_TRUE;
|
||||
@ -65,7 +67,7 @@ static PRLogModuleInfo* gCspPRLog;
|
||||
|
||||
CSPService::CSPService()
|
||||
{
|
||||
nsContentUtils::AddBoolPrefVarCache("security.csp.enable", &sCSPEnabled);
|
||||
Preferences::AddBoolVarCache(&sCSPEnabled, "security.csp.enable");
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
if (!gCspPRLog)
|
||||
|
@ -102,6 +102,9 @@
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsHTMLDNSPrefetch.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
PRLogModuleInfo* gContentSinkLogModuleInfo;
|
||||
|
||||
@ -232,11 +235,11 @@ PRBool nsContentSink::sCanInterruptParser;
|
||||
void
|
||||
nsContentSink::InitializeStatics()
|
||||
{
|
||||
nsContentUtils::AddBoolPrefVarCache("content.notify.ontimer",
|
||||
&sNotifyOnTimer, PR_TRUE);
|
||||
Preferences::AddBoolVarCache(&sNotifyOnTimer,
|
||||
"content.notify.ontimer", PR_TRUE);
|
||||
// -1 means never.
|
||||
nsContentUtils::AddIntPrefVarCache("content.notify.backoffcount",
|
||||
&sBackoffCount, -1);
|
||||
Preferences::AddIntVarCache(&sBackoffCount,
|
||||
"content.notify.backoffcount", -1);
|
||||
// The gNotificationInterval has a dramatic effect on how long it
|
||||
// takes to initially display content for slow connections.
|
||||
// The current value provides good
|
||||
@ -244,29 +247,28 @@ nsContentSink::InitializeStatics()
|
||||
// in page load time. If this value is set below 1/10 of second
|
||||
// it starts to impact page load performance.
|
||||
// see bugzilla bug 72138 for more info.
|
||||
nsContentUtils::AddIntPrefVarCache("content.notify.interval",
|
||||
&sNotificationInterval,
|
||||
120000);
|
||||
nsContentUtils::AddIntPrefVarCache("content.sink.interactive_deflect_count",
|
||||
&sInteractiveDeflectCount, 0);
|
||||
nsContentUtils::AddIntPrefVarCache("content.sink.perf_deflect_count",
|
||||
&sPerfDeflectCount, 200);
|
||||
nsContentUtils::AddIntPrefVarCache("content.sink.pending_event_mode",
|
||||
&sPendingEventMode, 1);
|
||||
nsContentUtils::AddIntPrefVarCache("content.sink.event_probe_rate",
|
||||
&sEventProbeRate, 1);
|
||||
nsContentUtils::AddIntPrefVarCache("content.sink.interactive_parse_time",
|
||||
&sInteractiveParseTime, 3000);
|
||||
nsContentUtils::AddIntPrefVarCache("content.sink.perf_parse_time",
|
||||
&sPerfParseTime, 360000);
|
||||
nsContentUtils::AddIntPrefVarCache("content.sink.interactive_time",
|
||||
&sInteractiveTime, 750000);
|
||||
nsContentUtils::AddIntPrefVarCache("content.sink.initial_perf_time",
|
||||
&sInitialPerfTime, 2000000);
|
||||
nsContentUtils::AddIntPrefVarCache("content.sink.enable_perf_mode",
|
||||
&sEnablePerfMode, 0);
|
||||
nsContentUtils::AddBoolPrefVarCache("content.interrupt.parsing",
|
||||
&sCanInterruptParser, PR_TRUE);
|
||||
Preferences::AddIntVarCache(&sNotificationInterval,
|
||||
"content.notify.interval", 120000);
|
||||
Preferences::AddIntVarCache(&sInteractiveDeflectCount,
|
||||
"content.sink.interactive_deflect_count", 0);
|
||||
Preferences::AddIntVarCache(&sPerfDeflectCount,
|
||||
"content.sink.perf_deflect_count", 200);
|
||||
Preferences::AddIntVarCache(&sPendingEventMode,
|
||||
"content.sink.pending_event_mode", 1);
|
||||
Preferences::AddIntVarCache(&sEventProbeRate,
|
||||
"content.sink.event_probe_rate", 1);
|
||||
Preferences::AddIntVarCache(&sInteractiveParseTime,
|
||||
"content.sink.interactive_parse_time", 3000);
|
||||
Preferences::AddIntVarCache(&sPerfParseTime,
|
||||
"content.sink.perf_parse_time", 360000);
|
||||
Preferences::AddIntVarCache(&sInteractiveTime,
|
||||
"content.sink.interactive_time", 750000);
|
||||
Preferences::AddIntVarCache(&sInitialPerfTime,
|
||||
"content.sink.initial_perf_time", 2000000);
|
||||
Preferences::AddIntVarCache(&sEnablePerfMode,
|
||||
"content.sink.enable_perf_mode", 0);
|
||||
Preferences::AddBoolVarCache(&sCanInterruptParser,
|
||||
"content.interrupt.parsing", PR_TRUE);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -49,9 +49,6 @@
|
||||
#include "nsAString.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch2.h"
|
||||
#include "nsIPrefLocalizedString.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIScriptContext.h"
|
||||
@ -233,7 +230,6 @@ nsIIOService *nsContentUtils::sIOService;
|
||||
#ifdef MOZ_XTF
|
||||
nsIXTFService *nsContentUtils::sXTFService = nsnull;
|
||||
#endif
|
||||
nsIPrefBranch2 *nsContentUtils::sPrefBranch = nsnull;
|
||||
imgILoader *nsContentUtils::sImgLoader;
|
||||
imgICache *nsContentUtils::sImgCache;
|
||||
nsIConsoleService *nsContentUtils::sConsoleService;
|
||||
@ -267,9 +263,6 @@ PRBool nsContentUtils::sAllowXULXBL_for_file = PR_FALSE;
|
||||
|
||||
PRBool nsContentUtils::sInitialized = PR_FALSE;
|
||||
|
||||
nsRefPtrHashtable<nsPrefObserverHashKey, nsPrefOldCallback>
|
||||
*nsContentUtils::sPrefCallbackTable = nsnull;
|
||||
|
||||
static PLDHashTable sEventListenerManagersHash;
|
||||
|
||||
class EventListenerManagerMapEntry : public PLDHashEntryHdr
|
||||
@ -319,108 +312,6 @@ class nsSameOriginChecker : public nsIChannelEventSink,
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
};
|
||||
|
||||
class nsPrefObserverHashKey : public PLDHashEntryHdr {
|
||||
public:
|
||||
typedef nsPrefObserverHashKey* KeyType;
|
||||
typedef const nsPrefObserverHashKey* KeyTypePointer;
|
||||
|
||||
static const nsPrefObserverHashKey* KeyToPointer(nsPrefObserverHashKey *aKey)
|
||||
{
|
||||
return aKey;
|
||||
}
|
||||
|
||||
static PLDHashNumber HashKey(const nsPrefObserverHashKey *aKey)
|
||||
{
|
||||
PRUint32 strHash = nsCRT::HashCode(aKey->mPref.BeginReading(),
|
||||
aKey->mPref.Length());
|
||||
return PR_ROTATE_LEFT32(strHash, 4) ^
|
||||
NS_PTR_TO_UINT32(aKey->mCallback);
|
||||
}
|
||||
|
||||
nsPrefObserverHashKey(const char *aPref, PrefChangedFunc aCallback) :
|
||||
mPref(aPref), mCallback(aCallback) { }
|
||||
|
||||
nsPrefObserverHashKey(const nsPrefObserverHashKey *aOther) :
|
||||
mPref(aOther->mPref), mCallback(aOther->mCallback)
|
||||
{ }
|
||||
|
||||
PRBool KeyEquals(const nsPrefObserverHashKey *aOther) const
|
||||
{
|
||||
return mCallback == aOther->mCallback &&
|
||||
mPref.Equals(aOther->mPref);
|
||||
}
|
||||
|
||||
nsPrefObserverHashKey *GetKey() const
|
||||
{
|
||||
return const_cast<nsPrefObserverHashKey*>(this);
|
||||
}
|
||||
|
||||
enum { ALLOW_MEMMOVE = PR_TRUE };
|
||||
|
||||
public:
|
||||
nsCString mPref;
|
||||
PrefChangedFunc mCallback;
|
||||
};
|
||||
|
||||
// For nsContentUtils::RegisterPrefCallback/UnregisterPrefCallback
|
||||
class nsPrefOldCallback : public nsIObserver,
|
||||
public nsPrefObserverHashKey
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
public:
|
||||
nsPrefOldCallback(const char *aPref, PrefChangedFunc aCallback)
|
||||
: nsPrefObserverHashKey(aPref, aCallback) { }
|
||||
|
||||
~nsPrefOldCallback() {
|
||||
Preferences::RemoveObserver(this, mPref.get());
|
||||
}
|
||||
|
||||
void AppendClosure(void *aClosure) {
|
||||
mClosures.AppendElement(aClosure);
|
||||
}
|
||||
|
||||
void RemoveClosure(void *aClosure) {
|
||||
mClosures.RemoveElement(aClosure);
|
||||
}
|
||||
|
||||
PRBool HasNoClosures() {
|
||||
return mClosures.Length() == 0;
|
||||
}
|
||||
|
||||
public:
|
||||
nsTArray<void *> mClosures;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsPrefOldCallback, nsIObserver)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrefOldCallback::Observe(nsISupports *aSubject,
|
||||
const char *aTopic,
|
||||
const PRUnichar *aData)
|
||||
{
|
||||
NS_ASSERTION(!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID),
|
||||
"invalid topic");
|
||||
NS_LossyConvertUTF16toASCII data(aData);
|
||||
for (PRUint32 i = 0; i < mClosures.Length(); i++) {
|
||||
mCallback(data.get(), mClosures.ElementAt(i));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
struct PrefCacheData {
|
||||
void* cacheLocation;
|
||||
union {
|
||||
PRBool defaultValueBool;
|
||||
PRInt32 defaultValueInt;
|
||||
};
|
||||
};
|
||||
|
||||
nsTArray<nsAutoPtr<PrefCacheData> >* sPrefCacheData = nsnull;
|
||||
|
||||
// static
|
||||
nsresult
|
||||
nsContentUtils::Init()
|
||||
@ -431,11 +322,6 @@ nsContentUtils::Init()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
sPrefCacheData = new nsTArray<nsAutoPtr<PrefCacheData> >();
|
||||
|
||||
// It's ok to not have a pref service.
|
||||
CallGetService(NS_PREFSERVICE_CONTRACTID, &sPrefBranch);
|
||||
|
||||
nsresult rv = NS_GetNameSpaceManager(&sNameSpaceManager);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
@ -493,8 +379,8 @@ nsContentUtils::Init()
|
||||
sBlockedScriptRunners = new nsCOMArray<nsIRunnable>;
|
||||
NS_ENSURE_TRUE(sBlockedScriptRunners, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsContentUtils::AddBoolPrefVarCache("dom.allow_XUL_XBL_for_file",
|
||||
&sAllowXULXBL_for_file);
|
||||
Preferences::AddBoolVarCache(&sAllowXULXBL_for_file,
|
||||
"dom.allow_XUL_XBL_for_file");
|
||||
|
||||
sInitialized = PR_TRUE;
|
||||
|
||||
@ -1123,9 +1009,10 @@ nsContentUtils::OfflineAppAllowed(nsIURI *aURI)
|
||||
}
|
||||
|
||||
PRBool allowed;
|
||||
nsresult rv = updateService->OfflineAppAllowedForURI(aURI,
|
||||
sPrefBranch,
|
||||
&allowed);
|
||||
nsresult rv =
|
||||
updateService->OfflineAppAllowedForURI(aURI,
|
||||
Preferences::GetRootBranch(),
|
||||
&allowed);
|
||||
return NS_SUCCEEDED(rv) && allowed;
|
||||
}
|
||||
|
||||
@ -1141,7 +1028,7 @@ nsContentUtils::OfflineAppAllowed(nsIPrincipal *aPrincipal)
|
||||
|
||||
PRBool allowed;
|
||||
nsresult rv = updateService->OfflineAppAllowed(aPrincipal,
|
||||
sPrefBranch,
|
||||
Preferences::GetRootBranch(),
|
||||
&allowed);
|
||||
return NS_SUCCEEDED(rv) && allowed;
|
||||
}
|
||||
@ -1161,15 +1048,6 @@ nsContentUtils::Shutdown()
|
||||
for (i = 0; i < PropertiesFile_COUNT; ++i)
|
||||
NS_IF_RELEASE(sStringBundles[i]);
|
||||
|
||||
// Clean up c-style's observer
|
||||
if (sPrefCallbackTable) {
|
||||
delete sPrefCallbackTable;
|
||||
sPrefCallbackTable = nsnull;
|
||||
}
|
||||
|
||||
delete sPrefCacheData;
|
||||
sPrefCacheData = nsnull;
|
||||
|
||||
NS_IF_RELEASE(sStringBundleService);
|
||||
NS_IF_RELEASE(sConsoleService);
|
||||
NS_IF_RELEASE(sDOMScriptObjectFactory);
|
||||
@ -1187,7 +1065,6 @@ nsContentUtils::Shutdown()
|
||||
#endif
|
||||
NS_IF_RELEASE(sImgLoader);
|
||||
NS_IF_RELEASE(sImgCache);
|
||||
NS_IF_RELEASE(sPrefBranch);
|
||||
#ifdef IBMBIDI
|
||||
NS_IF_RELEASE(sBidiKeyboard);
|
||||
#endif
|
||||
@ -2580,109 +2457,6 @@ nsContentUtils::IsDraggableLink(const nsIContent* aContent) {
|
||||
return aContent->IsLink(getter_AddRefs(absURI));
|
||||
}
|
||||
|
||||
// RegisterPrefCallback/UnregisterPrefCallback are for backward compatiblity
|
||||
// with c-style observers.
|
||||
|
||||
// static
|
||||
void
|
||||
nsContentUtils::RegisterPrefCallback(const char *aPref,
|
||||
PrefChangedFunc aCallback,
|
||||
void * aClosure)
|
||||
{
|
||||
if (sPrefBranch) {
|
||||
if (!sPrefCallbackTable) {
|
||||
sPrefCallbackTable =
|
||||
new nsRefPtrHashtable<nsPrefObserverHashKey, nsPrefOldCallback>();
|
||||
sPrefCallbackTable->Init();
|
||||
}
|
||||
|
||||
nsPrefObserverHashKey hashKey(aPref, aCallback);
|
||||
nsRefPtr<nsPrefOldCallback> callback;
|
||||
sPrefCallbackTable->Get(&hashKey, getter_AddRefs(callback));
|
||||
if (callback) {
|
||||
callback->AppendClosure(aClosure);
|
||||
return;
|
||||
}
|
||||
|
||||
callback = new nsPrefOldCallback(aPref, aCallback);
|
||||
callback->AppendClosure(aClosure);
|
||||
if (NS_SUCCEEDED(sPrefBranch->AddObserver(aPref, callback, PR_FALSE))) {
|
||||
sPrefCallbackTable->Put(callback, callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void
|
||||
nsContentUtils::UnregisterPrefCallback(const char *aPref,
|
||||
PrefChangedFunc aCallback,
|
||||
void * aClosure)
|
||||
{
|
||||
if (sPrefBranch) {
|
||||
if (!sPrefCallbackTable) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsPrefObserverHashKey hashKey(aPref, aCallback);
|
||||
nsRefPtr<nsPrefOldCallback> callback;
|
||||
sPrefCallbackTable->Get(&hashKey, getter_AddRefs(callback));
|
||||
|
||||
if (callback) {
|
||||
callback->RemoveClosure(aClosure);
|
||||
if (callback->HasNoClosures()) {
|
||||
// Delete the callback since its list of closures is empty.
|
||||
sPrefCallbackTable->Remove(callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
BoolVarChanged(const char *aPref, void *aClosure)
|
||||
{
|
||||
PrefCacheData* cache = static_cast<PrefCacheData*>(aClosure);
|
||||
*((PRBool*)cache->cacheLocation) =
|
||||
Preferences::GetBool(aPref, cache->defaultValueBool);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
nsContentUtils::AddBoolPrefVarCache(const char *aPref,
|
||||
PRBool* aCache,
|
||||
PRBool aDefault)
|
||||
{
|
||||
*aCache = Preferences::GetBool(aPref, aDefault);
|
||||
PrefCacheData* data = new PrefCacheData;
|
||||
data->cacheLocation = aCache;
|
||||
data->defaultValueBool = aDefault;
|
||||
sPrefCacheData->AppendElement(data);
|
||||
RegisterPrefCallback(aPref, BoolVarChanged, data);
|
||||
}
|
||||
|
||||
static int
|
||||
IntVarChanged(const char *aPref, void *aClosure)
|
||||
{
|
||||
PrefCacheData* cache = static_cast<PrefCacheData*>(aClosure);
|
||||
*((PRInt32*)cache->cacheLocation) =
|
||||
Preferences::GetInt(aPref, cache->defaultValueInt);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
nsContentUtils::AddIntPrefVarCache(const char *aPref,
|
||||
PRInt32* aCache,
|
||||
PRInt32 aDefault)
|
||||
{
|
||||
*aCache = Preferences::GetInt(aPref, aDefault);
|
||||
PrefCacheData* data = new PrefCacheData;
|
||||
data->cacheLocation = aCache;
|
||||
data->defaultValueInt = aDefault;
|
||||
sPrefCacheData->AppendElement(data);
|
||||
RegisterPrefCallback(aPref, IntVarChanged, data);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsContentUtils::IsSitePermAllow(nsIURI* aURI, const char* aType)
|
||||
{
|
||||
|
@ -60,6 +60,9 @@
|
||||
#include "nsClassHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsStreamUtils.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
#define PREFLIGHT_CACHE_SIZE 100
|
||||
|
||||
@ -369,8 +372,10 @@ NS_IMPL_ISUPPORTS5(nsCORSListenerProxy, nsIStreamListener,
|
||||
void
|
||||
nsCORSListenerProxy::Startup()
|
||||
{
|
||||
nsContentUtils::AddBoolPrefVarCache("content.cors.disable", &gDisableCORS);
|
||||
nsContentUtils::AddBoolPrefVarCache("content.cors.no_private_data", &gDisableCORSPrivateData);
|
||||
Preferences::AddBoolVarCache(&gDisableCORS,
|
||||
"content.cors.disable");
|
||||
Preferences::AddBoolVarCache(&gDisableCORSPrivateData,
|
||||
"content.cors.no_private_data");
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
@ -54,7 +54,6 @@
|
||||
#include "nsIDNSRecord.h"
|
||||
#include "nsIDNSService.h"
|
||||
#include "nsICancelable.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsGkAtoms.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsThreadUtils.h"
|
||||
@ -97,8 +96,8 @@ nsHTMLDNSPrefetch::Initialize()
|
||||
|
||||
sPrefetches->Activate();
|
||||
|
||||
nsContentUtils::AddBoolPrefVarCache("network.dns.disablePrefetchFromHTTPS",
|
||||
&sDisablePrefetchHTTPSPref);
|
||||
Preferences::AddBoolVarCache(&sDisablePrefetchHTTPSPref,
|
||||
"network.dns.disablePrefetchFromHTTPS");
|
||||
|
||||
// Default is false, so we need an explicit call to prime the cache.
|
||||
sDisablePrefetchHTTPSPref =
|
||||
|
@ -599,9 +599,8 @@ nsHTMLDocument::StartAutodetection(nsIDocShell *aDocShell, nsACString& aCharset,
|
||||
gPlugDetector = PR_TRUE;
|
||||
}
|
||||
|
||||
nsContentUtils::RegisterPrefCallback("intl.charset.detector",
|
||||
MyPrefChangedCallback,
|
||||
nsnull);
|
||||
Preferences::RegisterCallback(MyPrefChangedCallback,
|
||||
"intl.charset.detector");
|
||||
|
||||
gInitDetector = PR_TRUE;
|
||||
}
|
||||
|
@ -52,7 +52,6 @@ using namespace mozilla::dom;
|
||||
#include "nsAudioStream.h"
|
||||
#include "nsAlgorithm.h"
|
||||
#include "VideoUtils.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
extern "C" {
|
||||
#include "sydneyaudio/sydney_audio.h"
|
||||
@ -347,16 +346,12 @@ void nsAudioStream::InitLibrary()
|
||||
#endif
|
||||
gVolumeScaleLock = new mozilla::Mutex("nsAudioStream::gVolumeScaleLock");
|
||||
VolumeScaleChanged(nsnull, nsnull);
|
||||
nsContentUtils::RegisterPrefCallback("media.volume_scale",
|
||||
VolumeScaleChanged,
|
||||
nsnull);
|
||||
Preferences::RegisterCallback(VolumeScaleChanged, "media.volume_scale");
|
||||
}
|
||||
|
||||
void nsAudioStream::ShutdownLibrary()
|
||||
{
|
||||
nsContentUtils::UnregisterPrefCallback("media.volume_scale",
|
||||
VolumeScaleChanged,
|
||||
nsnull);
|
||||
Preferences::UnregisterCallback(VolumeScaleChanged, "media.volume_scale");
|
||||
delete gVolumeScaleLock;
|
||||
gVolumeScaleLock = nsnull;
|
||||
}
|
||||
|
@ -90,6 +90,9 @@
|
||||
#endif
|
||||
#include "nsIDOMLoadListener.h"
|
||||
#include "nsIDOMEventGroup.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
#define NS_MAX_XBL_BINDING_RECURSION 20
|
||||
|
||||
@ -511,9 +514,8 @@ nsXBLService::nsXBLService(void)
|
||||
if (gRefCnt == 1) {
|
||||
gClassTable = new nsHashtable();
|
||||
}
|
||||
|
||||
nsContentUtils::AddBoolPrefVarCache("layout.debug.enable_data_xbl",
|
||||
&gAllowDataURIs);
|
||||
|
||||
Preferences::AddBoolVarCache(&gAllowDataURIs, "layout.debug.enable_data_xbl");
|
||||
}
|
||||
|
||||
nsXBLService::~nsXBLService(void)
|
||||
|
@ -128,7 +128,9 @@
|
||||
#include "nsCCUncollectableMarker.h"
|
||||
#include "nsURILoader.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@ -278,9 +280,8 @@ nsXULDocument::~nsXULDocument()
|
||||
|
||||
delete mTemplateBuilderTable;
|
||||
|
||||
nsContentUtils::UnregisterPrefCallback("intl.uidirection.",
|
||||
nsXULDocument::DirectionChanged,
|
||||
this);
|
||||
Preferences::UnregisterCallback(nsXULDocument::DirectionChanged,
|
||||
"intl.uidirection.", this);
|
||||
|
||||
if (--gRefCnt == 0) {
|
||||
NS_IF_RELEASE(gRDFService);
|
||||
@ -1984,9 +1985,8 @@ nsXULDocument::Init()
|
||||
}
|
||||
}
|
||||
|
||||
nsContentUtils::RegisterPrefCallback("intl.uidirection.",
|
||||
nsXULDocument::DirectionChanged,
|
||||
this);
|
||||
Preferences::RegisterCallback(nsXULDocument::DirectionChanged,
|
||||
"intl.uidirection.", this);
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
if (! gXULLog)
|
||||
|
@ -42,7 +42,6 @@
|
||||
|
||||
#include "nsXULPrototypeCache.h"
|
||||
|
||||
#include "nsContentUtils.h"
|
||||
#include "plstr.h"
|
||||
#include "nsXULPrototypeDocument.h"
|
||||
#include "nsCSSStyleSheet.h"
|
||||
@ -137,9 +136,8 @@ NS_NewXULPrototypeCache(nsISupports* aOuter, REFNSIID aIID, void** aResult)
|
||||
// XXX Ignore return values.
|
||||
gDisableXULCache =
|
||||
Preferences::GetBool(kDisableXULCachePref, gDisableXULCache);
|
||||
nsContentUtils::RegisterPrefCallback(kDisableXULCachePref,
|
||||
DisableXULCacheChangedCallback,
|
||||
nsnull);
|
||||
Preferences::RegisterCallback(DisableXULCacheChangedCallback,
|
||||
kDisableXULCachePref);
|
||||
|
||||
nsresult rv = result->QueryInterface(aIID, aResult);
|
||||
|
||||
@ -732,12 +730,10 @@ nsXULPrototypeCache::StartFastLoad(nsIURI* aURI)
|
||||
gChecksumXULFastLoadFile =
|
||||
Preferences::GetBool(kChecksumXULFastLoadFilePref,
|
||||
gChecksumXULFastLoadFile);
|
||||
nsContentUtils::RegisterPrefCallback(kDisableXULFastLoadPref,
|
||||
FastLoadPrefChangedCallback,
|
||||
nsnull);
|
||||
nsContentUtils::RegisterPrefCallback(kChecksumXULFastLoadFilePref,
|
||||
FastLoadPrefChangedCallback,
|
||||
nsnull);
|
||||
Preferences::RegisterCallback(FastLoadPrefChangedCallback,
|
||||
kDisableXULFastLoadPref);
|
||||
Preferences::RegisterCallback(FastLoadPrefChangedCallback,
|
||||
kChecksumXULFastLoadFilePref);
|
||||
|
||||
if (gDisableXULFastLoad)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
@ -907,15 +907,15 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow)
|
||||
|
||||
if (gRefCnt == 1) {
|
||||
#if !(defined(NS_DEBUG) || defined(MOZ_ENABLE_JS_DUMP))
|
||||
nsContentUtils::AddBoolPrefVarCache("browser.dom.window.dump.enabled",
|
||||
&gDOMWindowDumpEnabled);
|
||||
Preferences::AddBoolVarCache(&gDOMWindowDumpEnabled,
|
||||
"browser.dom.window.dump.enabled");
|
||||
#endif
|
||||
nsContentUtils::AddIntPrefVarCache("dom.min_timeout_value",
|
||||
&gMinTimeoutValue,
|
||||
DEFAULT_MIN_TIMEOUT_VALUE);
|
||||
nsContentUtils::AddIntPrefVarCache("dom.min_background_timeout_value",
|
||||
&gMinBackgroundTimeoutValue,
|
||||
DEFAULT_MIN_BACKGROUND_TIMEOUT_VALUE);
|
||||
Preferences::AddIntVarCache(&gMinTimeoutValue,
|
||||
"dom.min_timeout_value",
|
||||
DEFAULT_MIN_TIMEOUT_VALUE);
|
||||
Preferences::AddIntVarCache(&gMinBackgroundTimeoutValue,
|
||||
"dom.min_background_timeout_value",
|
||||
DEFAULT_MIN_BACKGROUND_TIMEOUT_VALUE);
|
||||
}
|
||||
|
||||
if (gDumpFile == nsnull) {
|
||||
|
@ -1035,9 +1035,8 @@ nsJSContext::nsJSContext(JSRuntime *aRuntime)
|
||||
::JS_SetOptions(mContext, mDefaultJSOptions);
|
||||
|
||||
// Watch for the JS boolean options
|
||||
nsContentUtils::RegisterPrefCallback(js_options_dot_str,
|
||||
JSOptionChangedCallback,
|
||||
this);
|
||||
Preferences::RegisterCallback(JSOptionChangedCallback,
|
||||
js_options_dot_str, this);
|
||||
|
||||
::JS_SetOperationCallback(mContext, DOMOperationCallback);
|
||||
|
||||
@ -1089,9 +1088,8 @@ nsJSContext::DestroyJSContext()
|
||||
::JS_SetContextPrivate(mContext, nsnull);
|
||||
|
||||
// Unregister our "javascript.options.*" pref-changed callback.
|
||||
nsContentUtils::UnregisterPrefCallback(js_options_dot_str,
|
||||
JSOptionChangedCallback,
|
||||
this);
|
||||
Preferences::UnregisterCallback(JSOptionChangedCallback,
|
||||
js_options_dot_str, this);
|
||||
|
||||
PRBool do_gc = mGCOnDestruction && !sGCTimer;
|
||||
|
||||
@ -3763,38 +3761,32 @@ nsJSRuntime::Init()
|
||||
JS_SetStructuredCloneCallbacks(sRuntime, &cloneCallbacks);
|
||||
|
||||
// Set these global xpconnect options...
|
||||
nsContentUtils::RegisterPrefCallback("dom.max_script_run_time",
|
||||
MaxScriptRunTimePrefChangedCallback,
|
||||
nsnull);
|
||||
Preferences::RegisterCallback(MaxScriptRunTimePrefChangedCallback,
|
||||
"dom.max_script_run_time");
|
||||
MaxScriptRunTimePrefChangedCallback("dom.max_script_run_time", nsnull);
|
||||
|
||||
nsContentUtils::RegisterPrefCallback("dom.max_chrome_script_run_time",
|
||||
MaxScriptRunTimePrefChangedCallback,
|
||||
nsnull);
|
||||
Preferences::RegisterCallback(MaxScriptRunTimePrefChangedCallback,
|
||||
"dom.max_chrome_script_run_time");
|
||||
MaxScriptRunTimePrefChangedCallback("dom.max_chrome_script_run_time",
|
||||
nsnull);
|
||||
|
||||
nsContentUtils::RegisterPrefCallback("dom.report_all_js_exceptions",
|
||||
ReportAllJSExceptionsPrefChangedCallback,
|
||||
nsnull);
|
||||
Preferences::RegisterCallback(ReportAllJSExceptionsPrefChangedCallback,
|
||||
"dom.report_all_js_exceptions");
|
||||
ReportAllJSExceptionsPrefChangedCallback("dom.report_all_js_exceptions",
|
||||
nsnull);
|
||||
|
||||
nsContentUtils::RegisterPrefCallback("javascript.options.mem.high_water_mark",
|
||||
SetMemoryHighWaterMarkPrefChangedCallback,
|
||||
nsnull);
|
||||
Preferences::RegisterCallback(SetMemoryHighWaterMarkPrefChangedCallback,
|
||||
"javascript.options.mem.high_water_mark");
|
||||
SetMemoryHighWaterMarkPrefChangedCallback("javascript.options.mem.high_water_mark",
|
||||
nsnull);
|
||||
|
||||
nsContentUtils::RegisterPrefCallback("javascript.options.mem.max",
|
||||
SetMemoryMaxPrefChangedCallback,
|
||||
nsnull);
|
||||
Preferences::RegisterCallback(SetMemoryMaxPrefChangedCallback,
|
||||
"javascript.options.mem.max");
|
||||
SetMemoryMaxPrefChangedCallback("javascript.options.mem.max",
|
||||
nsnull);
|
||||
|
||||
nsContentUtils::RegisterPrefCallback("javascript.options.mem.gc_per_compartment",
|
||||
SetMemoryGCModePrefChangedCallback,
|
||||
nsnull);
|
||||
Preferences::RegisterCallback(SetMemoryGCModePrefChangedCallback,
|
||||
"javascript.options.mem.gc_per_compartment");
|
||||
SetMemoryGCModePrefChangedCallback("javascript.options.mem.gc_per_compartment",
|
||||
nsnull);
|
||||
|
||||
|
@ -67,6 +67,9 @@
|
||||
#include "IndexedDatabaseManager.h"
|
||||
#include "LazyIdleThread.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
#define PREF_INDEXEDDB_QUOTA "dom.indexedDB.warningQuota"
|
||||
|
||||
@ -536,8 +539,8 @@ IDBFactory::Create(nsPIDOMWindow* aWindow)
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsContentUtils::AddIntPrefVarCache(PREF_INDEXEDDB_QUOTA, &gIndexedDBQuota,
|
||||
DEFAULT_QUOTA);
|
||||
Preferences::AddIntVarCache(&gIndexedDBQuota, PREF_INDEXEDDB_QUOTA,
|
||||
DEFAULT_QUOTA);
|
||||
}
|
||||
|
||||
nsRefPtr<IDBFactory> factory = new IDBFactory();
|
||||
|
@ -59,7 +59,6 @@
|
||||
#include "PluginIdentifierParent.h"
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsCRT.h"
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
#include "nsExceptionHandler.h"
|
||||
@ -127,7 +126,7 @@ PluginModuleParent::PluginModuleParent(const char* aFilePath)
|
||||
NS_ERROR("Out of memory");
|
||||
}
|
||||
|
||||
nsContentUtils::RegisterPrefCallback(kTimeoutPref, TimeoutChanged, this);
|
||||
Preferences::RegisterCallback(TimeoutChanged, kTimeoutPref, this);
|
||||
}
|
||||
|
||||
PluginModuleParent::~PluginModuleParent()
|
||||
@ -152,7 +151,7 @@ PluginModuleParent::~PluginModuleParent()
|
||||
mSubprocess = nsnull;
|
||||
}
|
||||
|
||||
nsContentUtils::UnregisterPrefCallback(kTimeoutPref, TimeoutChanged, this);
|
||||
Preferences::UnregisterCallback(TimeoutChanged, kTimeoutPref, this);
|
||||
}
|
||||
|
||||
#ifdef MOZ_CRASHREPORTER
|
||||
|
@ -518,16 +518,13 @@ nsresult nsGeolocationService::Init()
|
||||
{
|
||||
mTimeout = Preferences::GetInt("geo.timeout", 6000);
|
||||
|
||||
nsContentUtils::RegisterPrefCallback("geo.ignore.location_filter",
|
||||
GeoIgnoreLocationFilterChangedCallback,
|
||||
nsnull);
|
||||
Preferences::RegisterCallback(GeoIgnoreLocationFilterChangedCallback,
|
||||
"geo.ignore.location_filter");
|
||||
|
||||
GeoIgnoreLocationFilterChangedCallback("geo.ignore.location_filter", nsnull);
|
||||
|
||||
|
||||
nsContentUtils::RegisterPrefCallback("geo.enabled",
|
||||
GeoEnabledChangedCallback,
|
||||
nsnull);
|
||||
Preferences::RegisterCallback(GeoEnabledChangedCallback, "geo.enabled");
|
||||
|
||||
GeoEnabledChangedCallback("geo.enabled", nsnull);
|
||||
|
||||
|
@ -1567,8 +1567,7 @@ nsDOMThreadService::RegisterPrefCallbacks()
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
for (PRUint32 index = 0; index < NS_ARRAY_LENGTH(sPrefsToWatch); index++) {
|
||||
nsContentUtils::RegisterPrefCallback(sPrefsToWatch[index], PrefCallback,
|
||||
nsnull);
|
||||
Preferences::RegisterCallback(PrefCallback, sPrefsToWatch[index]);
|
||||
PrefCallback(sPrefsToWatch[index], nsnull);
|
||||
}
|
||||
}
|
||||
@ -1578,8 +1577,7 @@ nsDOMThreadService::UnregisterPrefCallbacks()
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
for (PRUint32 index = 0; index < NS_ARRAY_LENGTH(sPrefsToWatch); index++) {
|
||||
nsContentUtils::UnregisterPrefCallback(sPrefsToWatch[index], PrefCallback,
|
||||
nsnull);
|
||||
Preferences::UnregisterCallback(PrefCallback, sPrefsToWatch[index]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,13 +196,11 @@ nsPlaintextEditor::GetDefaultEditorPrefs(PRInt32 &aNewlineHandling,
|
||||
PRInt32 &aCaretStyle)
|
||||
{
|
||||
if (sNewlineHandlingPref == -1) {
|
||||
nsContentUtils::RegisterPrefCallback("editor.singleLine.pasteNewlines",
|
||||
EditorPrefsChangedCallback,
|
||||
nsnull);
|
||||
Preferences::RegisterCallback(EditorPrefsChangedCallback,
|
||||
"editor.singleLine.pasteNewlines");
|
||||
EditorPrefsChangedCallback("editor.singleLine.pasteNewlines", nsnull);
|
||||
nsContentUtils::RegisterPrefCallback("layout.selection.caret_style",
|
||||
EditorPrefsChangedCallback,
|
||||
nsnull);
|
||||
Preferences::RegisterCallback(EditorPrefsChangedCallback,
|
||||
"layout.selection.caret_style");
|
||||
EditorPrefsChangedCallback("layout.selection.caret_style", nsnull);
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ LayerManagerD3D9::Initialize()
|
||||
/* XXX: this preference and blacklist code should move out of the layer manager */
|
||||
PRBool forceAccelerate = PR_FALSE;
|
||||
if (prefs) {
|
||||
// we should use AddBoolPrefVarCache
|
||||
// we should use Preferences::AddBoolVarCache
|
||||
prefs->GetBoolPref("layers.acceleration.force-enabled",
|
||||
&forceAccelerate);
|
||||
}
|
||||
|
@ -289,42 +289,44 @@ nsPresContext::~nsPresContext()
|
||||
}
|
||||
|
||||
// Unregister preference callbacks
|
||||
nsContentUtils::UnregisterPrefCallback("font.",
|
||||
nsPresContext::PrefChangedCallback,
|
||||
this);
|
||||
nsContentUtils::UnregisterPrefCallback("browser.display.",
|
||||
nsPresContext::PrefChangedCallback,
|
||||
this);
|
||||
nsContentUtils::UnregisterPrefCallback("browser.underline_anchors",
|
||||
nsPresContext::PrefChangedCallback,
|
||||
this);
|
||||
nsContentUtils::UnregisterPrefCallback("browser.anchor_color",
|
||||
nsPresContext::PrefChangedCallback,
|
||||
this);
|
||||
nsContentUtils::UnregisterPrefCallback("browser.active_color",
|
||||
nsPresContext::PrefChangedCallback,
|
||||
this);
|
||||
nsContentUtils::UnregisterPrefCallback("browser.visited_color",
|
||||
nsPresContext::PrefChangedCallback,
|
||||
this);
|
||||
nsContentUtils::UnregisterPrefCallback("image.animation_mode",
|
||||
nsPresContext::PrefChangedCallback,
|
||||
this);
|
||||
Preferences::UnregisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"font.",
|
||||
this);
|
||||
Preferences::UnregisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"browser.display.",
|
||||
this);
|
||||
Preferences::UnregisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"browser.underline_anchors",
|
||||
this);
|
||||
Preferences::UnregisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"browser.anchor_color",
|
||||
this);
|
||||
Preferences::UnregisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"browser.active_color",
|
||||
this);
|
||||
Preferences::UnregisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"browser.visited_color",
|
||||
this);
|
||||
Preferences::UnregisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"image.animation_mode",
|
||||
this);
|
||||
#ifdef IBMBIDI
|
||||
nsContentUtils::UnregisterPrefCallback("bidi.", PrefChangedCallback, this);
|
||||
Preferences::UnregisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"bidi.",
|
||||
this);
|
||||
#endif // IBMBIDI
|
||||
nsContentUtils::UnregisterPrefCallback("dom.send_after_paint_to_content",
|
||||
nsPresContext::PrefChangedCallback,
|
||||
this);
|
||||
nsContentUtils::UnregisterPrefCallback("gfx.font_rendering.",
|
||||
nsPresContext::PrefChangedCallback,
|
||||
this);
|
||||
nsContentUtils::UnregisterPrefCallback("layout.css.dpi",
|
||||
nsPresContext::PrefChangedCallback,
|
||||
this);
|
||||
nsContentUtils::UnregisterPrefCallback("layout.css.devPixelsPerPx",
|
||||
nsPresContext::PrefChangedCallback,
|
||||
this);
|
||||
Preferences::UnregisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"dom.send_after_paint_to_content",
|
||||
this);
|
||||
Preferences::UnregisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"gfx.font_rendering.",
|
||||
this);
|
||||
Preferences::UnregisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"layout.css.dpi",
|
||||
this);
|
||||
Preferences::UnregisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"layout.css.devPixelsPerPx",
|
||||
this);
|
||||
|
||||
NS_IF_RELEASE(mDeviceContext);
|
||||
NS_IF_RELEASE(mLookAndFeel);
|
||||
@ -955,42 +957,44 @@ nsPresContext::Init(nsDeviceContext* aDeviceContext)
|
||||
mLangService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);
|
||||
|
||||
// Register callbacks so we're notified when the preferences change
|
||||
nsContentUtils::RegisterPrefCallback("font.",
|
||||
nsPresContext::PrefChangedCallback,
|
||||
this);
|
||||
nsContentUtils::RegisterPrefCallback("browser.display.",
|
||||
nsPresContext::PrefChangedCallback,
|
||||
this);
|
||||
nsContentUtils::RegisterPrefCallback("browser.underline_anchors",
|
||||
nsPresContext::PrefChangedCallback,
|
||||
this);
|
||||
nsContentUtils::RegisterPrefCallback("browser.anchor_color",
|
||||
nsPresContext::PrefChangedCallback,
|
||||
this);
|
||||
nsContentUtils::RegisterPrefCallback("browser.active_color",
|
||||
nsPresContext::PrefChangedCallback,
|
||||
this);
|
||||
nsContentUtils::RegisterPrefCallback("browser.visited_color",
|
||||
nsPresContext::PrefChangedCallback,
|
||||
this);
|
||||
nsContentUtils::RegisterPrefCallback("image.animation_mode",
|
||||
nsPresContext::PrefChangedCallback,
|
||||
this);
|
||||
Preferences::RegisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"font.",
|
||||
this);
|
||||
Preferences::RegisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"browser.display.",
|
||||
this);
|
||||
Preferences::RegisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"browser.underline_anchors",
|
||||
this);
|
||||
Preferences::RegisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"browser.anchor_color",
|
||||
this);
|
||||
Preferences::RegisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"browser.active_color",
|
||||
this);
|
||||
Preferences::RegisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"browser.visited_color",
|
||||
this);
|
||||
Preferences::RegisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"image.animation_mode",
|
||||
this);
|
||||
#ifdef IBMBIDI
|
||||
nsContentUtils::RegisterPrefCallback("bidi.", PrefChangedCallback,
|
||||
this);
|
||||
Preferences::RegisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"bidi.",
|
||||
this);
|
||||
#endif
|
||||
nsContentUtils::RegisterPrefCallback("dom.send_after_paint_to_content",
|
||||
nsPresContext::PrefChangedCallback,
|
||||
this);
|
||||
nsContentUtils::RegisterPrefCallback("gfx.font_rendering.", PrefChangedCallback,
|
||||
this);
|
||||
nsContentUtils::RegisterPrefCallback("layout.css.dpi",
|
||||
nsPresContext::PrefChangedCallback,
|
||||
this);
|
||||
nsContentUtils::RegisterPrefCallback("layout.css.devPixelsPerPx",
|
||||
nsPresContext::PrefChangedCallback,
|
||||
this);
|
||||
Preferences::RegisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"dom.send_after_paint_to_content",
|
||||
this);
|
||||
Preferences::RegisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"gfx.font_rendering.",
|
||||
this);
|
||||
Preferences::RegisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"layout.css.dpi",
|
||||
this);
|
||||
Preferences::RegisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"layout.css.devPixelsPerPx",
|
||||
this);
|
||||
|
||||
rv = mEventManager->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -1720,8 +1720,8 @@ PresShell::PresShell()
|
||||
if (!registeredReporter) {
|
||||
NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(LayoutPresShell));
|
||||
NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(LayoutBidi));
|
||||
nsContentUtils::AddBoolPrefVarCache("layout.reflow.synthMouseMove",
|
||||
&sSynthMouseMove, PR_TRUE);
|
||||
Preferences::AddBoolVarCache(&sSynthMouseMove,
|
||||
"layout.reflow.synthMouseMove", PR_TRUE);
|
||||
registeredReporter = true;
|
||||
}
|
||||
|
||||
|
@ -67,9 +67,9 @@ static PRBool sPrecisePref;
|
||||
/* static */ void
|
||||
nsRefreshDriver::InitializeStatics()
|
||||
{
|
||||
nsContentUtils::AddBoolPrefVarCache("layout.frame_rate.precise",
|
||||
&sPrecisePref,
|
||||
PR_FALSE);
|
||||
Preferences::AddBoolVarCache(&sPrecisePref,
|
||||
"layout.frame_rate.precise",
|
||||
PR_FALSE);
|
||||
}
|
||||
// Compute the interval to use for the refresh driver timer, in
|
||||
// milliseconds
|
||||
|
@ -39,7 +39,6 @@
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsFrameSetFrame.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsLeafFrame.h"
|
||||
#include "nsHTMLContainerFrame.h"
|
||||
@ -241,8 +240,8 @@ nsHTMLFramesetFrame::~nsHTMLFramesetFrame()
|
||||
delete[] mChildFrameborder;
|
||||
delete[] mChildBorderColors;
|
||||
|
||||
nsContentUtils::UnregisterPrefCallback(kFrameResizePref,
|
||||
FrameResizePrefCallback, this);
|
||||
Preferences::UnregisterCallback(FrameResizePrefCallback,
|
||||
kFrameResizePref, this);
|
||||
}
|
||||
|
||||
NS_QUERYFRAME_HEAD(nsHTMLFramesetFrame)
|
||||
@ -974,8 +973,8 @@ nsHTMLFramesetFrame::Reflow(nsPresContext* aPresContext,
|
||||
|
||||
PRBool firstTime = (GetStateBits() & NS_FRAME_FIRST_REFLOW) != 0;
|
||||
if (firstTime) {
|
||||
nsContentUtils::RegisterPrefCallback(kFrameResizePref,
|
||||
FrameResizePrefCallback, this);
|
||||
Preferences::RegisterCallback(FrameResizePrefCallback,
|
||||
kFrameResizePref, this);
|
||||
mForceFrameResizability = Preferences::GetBool(kFrameResizePref);
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,6 @@
|
||||
#include "nsTableCellFrame.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIPercentHeightObserver.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#ifdef IBMBIDI
|
||||
@ -1626,8 +1625,7 @@ static PRBool BlinkIsAllowed(void)
|
||||
{
|
||||
if (!sPrefIsLoaded) {
|
||||
// Set up a listener and check the initial value
|
||||
nsContentUtils::RegisterPrefCallback("browser.blink_allowed", PrefsChanged,
|
||||
nsnull);
|
||||
Preferences::RegisterCallback(PrefsChanged, "browser.blink_allowed");
|
||||
PrefsChanged(nsnull, nsnull);
|
||||
sPrefIsLoaded = PR_TRUE;
|
||||
}
|
||||
|
@ -962,10 +962,8 @@ NS_IMPL_ISUPPORTS1(nsCSSRuleProcessor, nsIStyleRuleProcessor)
|
||||
/* static */ nsresult
|
||||
nsCSSRuleProcessor::Startup()
|
||||
{
|
||||
nsContentUtils::AddBoolPrefVarCache(VISITED_PSEUDO_PREF,
|
||||
&gSupportVisitedPseudo);
|
||||
// We want to default to true, not false as AddBoolPrefVarCache does.
|
||||
gSupportVisitedPseudo = Preferences::GetBool(VISITED_PSEUDO_PREF, PR_TRUE);
|
||||
Preferences::AddBoolVarCache(&gSupportVisitedPseudo, VISITED_PSEUDO_PREF,
|
||||
PR_TRUE);
|
||||
|
||||
gPrivateBrowsingObserver = new nsPrivateBrowsingObserver();
|
||||
NS_ENSURE_TRUE(gPrivateBrowsingObserver, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
@ -56,7 +56,7 @@
|
||||
#include "nsIConsoleService.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/css/Loader.h"
|
||||
#include "nsCSSStyleSheet.h"
|
||||
@ -348,7 +348,7 @@ nsCSSScanner::InitGlobals()
|
||||
NS_ASSERTION(gConsoleService && gScriptErrorFactory,
|
||||
"unexpected null pointer without failure");
|
||||
|
||||
nsContentUtils::RegisterPrefCallback(CSS_ERRORS_PREF, CSSErrorsPrefChanged, nsnull);
|
||||
Preferences::RegisterCallback(CSSErrorsPrefChanged, CSS_ERRORS_PREF);
|
||||
CSSErrorsPrefChanged(CSS_ERRORS_PREF, nsnull);
|
||||
#endif
|
||||
return PR_TRUE;
|
||||
@ -358,7 +358,7 @@ nsCSSScanner::InitGlobals()
|
||||
nsCSSScanner::ReleaseGlobals()
|
||||
{
|
||||
#ifdef CSS_REPORT_PARSE_ERRORS
|
||||
nsContentUtils::UnregisterPrefCallback(CSS_ERRORS_PREF, CSSErrorsPrefChanged, nsnull);
|
||||
Preferences::UnregisterCallback(CSSErrorsPrefChanged, CSS_ERRORS_PREF);
|
||||
NS_IF_RELEASE(gConsoleService);
|
||||
NS_IF_RELEASE(gScriptErrorFactory);
|
||||
NS_IF_RELEASE(gStringBundle);
|
||||
|
@ -189,7 +189,7 @@ NS_SMILEnabled()
|
||||
if (!sInitialized) {
|
||||
/* check and register ourselves with the pref */
|
||||
gSMILEnabled = Preferences::GetBool(SMIL_PREF_STR);
|
||||
nsContentUtils::RegisterPrefCallback(SMIL_PREF_STR, SMILPrefChanged, nsnull);
|
||||
Preferences::RegisterCallback(SMILPrefChanged, SMIL_PREF_STR);
|
||||
|
||||
sInitialized = PR_TRUE;
|
||||
}
|
||||
|
@ -55,7 +55,6 @@
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsContentUtils.h"
|
||||
#ifdef MOZ_XUL
|
||||
#include "nsXULPopupManager.h"
|
||||
#endif
|
||||
@ -82,8 +81,8 @@ nsXULTooltipListener::nsXULTooltipListener()
|
||||
{
|
||||
if (sTooltipListenerCount++ == 0) {
|
||||
// register the callback so we get notified of updates
|
||||
nsContentUtils::RegisterPrefCallback("browser.chrome.toolbar_tips",
|
||||
ToolbarTipsPrefChanged, nsnull);
|
||||
Preferences::RegisterCallback(ToolbarTipsPrefChanged,
|
||||
"browser.chrome.toolbar_tips");
|
||||
|
||||
// Call the pref callback to initialize our state.
|
||||
ToolbarTipsPrefChanged("browser.chrome.toolbar_tips", nsnull);
|
||||
@ -99,8 +98,8 @@ nsXULTooltipListener::~nsXULTooltipListener()
|
||||
|
||||
if (--sTooltipListenerCount == 0) {
|
||||
// Unregister our pref observer
|
||||
nsContentUtils::UnregisterPrefCallback("browser.chrome.toolbar_tips",
|
||||
ToolbarTipsPrefChanged, nsnull);
|
||||
Preferences::UnregisterCallback(ToolbarTipsPrefChanged,
|
||||
"browser.chrome.toolbar_tips");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,6 +57,11 @@ class nsString;
|
||||
class nsAdoptingString;
|
||||
class nsAdoptingCString;
|
||||
|
||||
#ifndef have_PrefChangedFunc_typedef
|
||||
typedef int (*PR_CALLBACK PrefChangedFunc)(const char *, void *);
|
||||
#define have_PrefChangedFunc_typedef
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class Preferences : public nsIPrefService,
|
||||
@ -204,6 +209,32 @@ public:
|
||||
static nsresult RemoveObservers(nsIObserver* aObserver,
|
||||
const char** aPrefs);
|
||||
|
||||
/**
|
||||
* Registers/Unregisters the callback function for the aPref.
|
||||
*/
|
||||
static nsresult RegisterCallback(PrefChangedFunc aCallback,
|
||||
const char* aPref,
|
||||
void* aClosure = nsnull);
|
||||
static nsresult UnregisterCallback(PrefChangedFunc aCallback,
|
||||
const char* aPref,
|
||||
void* aClosure = nsnull);
|
||||
|
||||
/**
|
||||
* Adds the aVariable to cache table. aVariable must be a pointer for a
|
||||
* static variable. The value will be modified when the pref value is
|
||||
* changed but note that even if you modified it, the value isn't assigned to
|
||||
* the pref.
|
||||
*/
|
||||
static nsresult AddBoolVarCache(PRBool* aVariable,
|
||||
const char* aPref,
|
||||
PRBool aDefault = PR_FALSE);
|
||||
static nsresult AddIntVarCache(PRInt32* aVariable,
|
||||
const char* aPref,
|
||||
PRInt32 aDefault = 0);
|
||||
static nsresult AddUintVarCache(PRUint32* aVariable,
|
||||
const char* aPref,
|
||||
PRUint32 aDefault = 0);
|
||||
|
||||
protected:
|
||||
nsresult NotifyServiceObservers(const char *aSubject);
|
||||
nsresult UseDefaultPrefFile();
|
||||
|
@ -73,6 +73,9 @@
|
||||
#include "mozilla/Omnijar.h"
|
||||
#include "nsZipArchive.h"
|
||||
|
||||
#include "nsTArray.h"
|
||||
#include "nsRefPtrHashtable.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
// Definitions
|
||||
@ -87,6 +90,105 @@ static nsresult pref_LoadPrefsInDirList(const char *listId);
|
||||
Preferences* Preferences::sPreferences = nsnull;
|
||||
PRBool Preferences::sShutdown = PR_FALSE;
|
||||
|
||||
class ValueObserverHashKey : public PLDHashEntryHdr {
|
||||
public:
|
||||
typedef ValueObserverHashKey* KeyType;
|
||||
typedef const ValueObserverHashKey* KeyTypePointer;
|
||||
|
||||
static const ValueObserverHashKey* KeyToPointer(ValueObserverHashKey *aKey)
|
||||
{
|
||||
return aKey;
|
||||
}
|
||||
|
||||
static PLDHashNumber HashKey(const ValueObserverHashKey *aKey)
|
||||
{
|
||||
PRUint32 strHash = nsCRT::HashCode(aKey->mPrefName.BeginReading(),
|
||||
aKey->mPrefName.Length());
|
||||
return PR_ROTATE_LEFT32(strHash, 4) ^ NS_PTR_TO_UINT32(aKey->mCallback);
|
||||
}
|
||||
|
||||
ValueObserverHashKey(const char *aPref, PrefChangedFunc aCallback) :
|
||||
mPrefName(aPref), mCallback(aCallback) { }
|
||||
|
||||
ValueObserverHashKey(const ValueObserverHashKey *aOther) :
|
||||
mPrefName(aOther->mPrefName), mCallback(aOther->mCallback)
|
||||
{ }
|
||||
|
||||
PRBool KeyEquals(const ValueObserverHashKey *aOther) const
|
||||
{
|
||||
return mCallback == aOther->mCallback && mPrefName == aOther->mPrefName;
|
||||
}
|
||||
|
||||
ValueObserverHashKey *GetKey() const
|
||||
{
|
||||
return const_cast<ValueObserverHashKey*>(this);
|
||||
}
|
||||
|
||||
enum { ALLOW_MEMMOVE = PR_TRUE };
|
||||
|
||||
nsCString mPrefName;
|
||||
PrefChangedFunc mCallback;
|
||||
};
|
||||
|
||||
class ValueObserver : public nsIObserver,
|
||||
public ValueObserverHashKey
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
ValueObserver(const char *aPref, PrefChangedFunc aCallback)
|
||||
: ValueObserverHashKey(aPref, aCallback) { }
|
||||
|
||||
~ValueObserver() {
|
||||
Preferences::RemoveObserver(this, mPrefName.get());
|
||||
}
|
||||
|
||||
void AppendClosure(void *aClosure) {
|
||||
mClosures.AppendElement(aClosure);
|
||||
}
|
||||
|
||||
void RemoveClosure(void *aClosure) {
|
||||
mClosures.RemoveElement(aClosure);
|
||||
}
|
||||
|
||||
PRBool HasNoClosures() {
|
||||
return mClosures.Length() == 0;
|
||||
}
|
||||
|
||||
nsTArray<void*> mClosures;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(ValueObserver, nsIObserver)
|
||||
|
||||
NS_IMETHODIMP
|
||||
ValueObserver::Observe(nsISupports *aSubject,
|
||||
const char *aTopic,
|
||||
const PRUnichar *aData)
|
||||
{
|
||||
NS_ASSERTION(!nsCRT::strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID),
|
||||
"invalid topic");
|
||||
NS_ConvertUTF16toUTF8 data(aData);
|
||||
for (PRUint32 i = 0; i < mClosures.Length(); i++) {
|
||||
mCallback(data.get(), mClosures.ElementAt(i));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
struct CacheData {
|
||||
void* cacheLocation;
|
||||
union {
|
||||
PRBool defaultValueBool;
|
||||
PRInt32 defaultValueInt;
|
||||
PRUint32 defaultValueUint;
|
||||
};
|
||||
};
|
||||
|
||||
static nsTArray<nsAutoPtr<CacheData> >* gCacheData = nsnull;
|
||||
static nsRefPtrHashtable<ValueObserverHashKey,
|
||||
ValueObserver>* gObserverTable = nsnull;
|
||||
|
||||
// static
|
||||
Preferences*
|
||||
Preferences::GetInstance()
|
||||
@ -115,8 +217,15 @@ Preferences::InitStaticMembers()
|
||||
NS_ADDREF(sPreferences);
|
||||
if (NS_FAILED(sPreferences->Init()) || !sPreferences->mRootBranch) {
|
||||
NS_RELEASE(sPreferences);
|
||||
return PR_FALSE;
|
||||
}
|
||||
return sPreferences != nsnull;
|
||||
|
||||
gCacheData = new nsTArray<nsAutoPtr<CacheData> >();
|
||||
|
||||
gObserverTable = new nsRefPtrHashtable<ValueObserverHashKey, ValueObserver>();
|
||||
gObserverTable->Init();
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
// static
|
||||
@ -125,6 +234,12 @@ Preferences::Shutdown()
|
||||
{
|
||||
sShutdown = PR_TRUE; // Don't create the singleton instance after here.
|
||||
NS_IF_RELEASE(sPreferences);
|
||||
|
||||
delete gCacheData;
|
||||
gCacheData = nsnull;
|
||||
|
||||
delete gObserverTable;
|
||||
gObserverTable = nsnull;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -1233,4 +1348,120 @@ Preferences::RemoveObservers(nsIObserver* aObserver,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
Preferences::RegisterCallback(PrefChangedFunc aCallback,
|
||||
const char* aPref,
|
||||
void* aClosure)
|
||||
{
|
||||
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
ValueObserverHashKey hashKey(aPref, aCallback);
|
||||
nsRefPtr<ValueObserver> observer;
|
||||
gObserverTable->Get(&hashKey, getter_AddRefs(observer));
|
||||
if (observer) {
|
||||
observer->AppendClosure(aClosure);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
observer = new ValueObserver(aPref, aCallback);
|
||||
observer->AppendClosure(aClosure);
|
||||
nsresult rv = AddStrongObserver(observer, aPref);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return gObserverTable->Put(observer, observer) ? NS_OK :
|
||||
NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
Preferences::UnregisterCallback(PrefChangedFunc aCallback,
|
||||
const char* aPref,
|
||||
void* aClosure)
|
||||
{
|
||||
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
ValueObserverHashKey hashKey(aPref, aCallback);
|
||||
nsRefPtr<ValueObserver> observer;
|
||||
gObserverTable->Get(&hashKey, getter_AddRefs(observer));
|
||||
if (!observer) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
observer->RemoveClosure(aClosure);
|
||||
if (observer->HasNoClosures()) {
|
||||
// Delete the callback since its list of closures is empty.
|
||||
gObserverTable->Remove(observer);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static int BoolVarChanged(const char* aPref, void* aClosure)
|
||||
{
|
||||
CacheData* cache = static_cast<CacheData*>(aClosure);
|
||||
*((PRBool*)cache->cacheLocation) =
|
||||
Preferences::GetBool(aPref, cache->defaultValueBool);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
Preferences::AddBoolVarCache(PRBool* aCache,
|
||||
const char* aPref,
|
||||
PRBool aDefault)
|
||||
{
|
||||
NS_ASSERTION(aCache, "aCache must not be NULL");
|
||||
*aCache = GetBool(aPref, aDefault);
|
||||
CacheData* data = new CacheData();
|
||||
data->cacheLocation = aCache;
|
||||
data->defaultValueBool = aDefault;
|
||||
gCacheData->AppendElement(data);
|
||||
return RegisterCallback(BoolVarChanged, aPref, data);
|
||||
}
|
||||
|
||||
static int IntVarChanged(const char* aPref, void* aClosure)
|
||||
{
|
||||
CacheData* cache = static_cast<CacheData*>(aClosure);
|
||||
*((PRInt32*)cache->cacheLocation) =
|
||||
Preferences::GetInt(aPref, cache->defaultValueInt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
Preferences::AddIntVarCache(PRInt32* aCache,
|
||||
const char* aPref,
|
||||
PRInt32 aDefault)
|
||||
{
|
||||
NS_ASSERTION(aCache, "aCache must not be NULL");
|
||||
*aCache = Preferences::GetInt(aPref, aDefault);
|
||||
CacheData* data = new CacheData();
|
||||
data->cacheLocation = aCache;
|
||||
data->defaultValueInt = aDefault;
|
||||
gCacheData->AppendElement(data);
|
||||
return RegisterCallback(IntVarChanged, aPref, data);
|
||||
}
|
||||
|
||||
static int UintVarChanged(const char* aPref, void* aClosure)
|
||||
{
|
||||
CacheData* cache = static_cast<CacheData*>(aClosure);
|
||||
*((PRUint32*)cache->cacheLocation) =
|
||||
Preferences::GetUint(aPref, cache->defaultValueUint);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
Preferences::AddUintVarCache(PRUint32* aCache,
|
||||
const char* aPref,
|
||||
PRUint32 aDefault)
|
||||
{
|
||||
NS_ASSERTION(aCache, "aCache must not be NULL");
|
||||
*aCache = Preferences::GetUint(aPref, aDefault);
|
||||
CacheData* data = new CacheData();
|
||||
data->cacheLocation = aCache;
|
||||
data->defaultValueUint = aDefault;
|
||||
gCacheData->AppendElement(data);
|
||||
return RegisterCallback(UintVarChanged, aPref, data);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -35,7 +35,6 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsHtml5AttributeName.h"
|
||||
#include "nsHtml5ElementName.h"
|
||||
#include "nsHtml5HtmlAttributes.h"
|
||||
@ -49,6 +48,9 @@
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
// static
|
||||
PRBool nsHtml5Module::sEnabled = PR_FALSE;
|
||||
@ -60,8 +62,8 @@ nsIThread* nsHtml5Module::sMainThread = nsnull;
|
||||
void
|
||||
nsHtml5Module::InitializeStatics()
|
||||
{
|
||||
nsContentUtils::AddBoolPrefVarCache("html5.parser.enable", &sEnabled);
|
||||
nsContentUtils::AddBoolPrefVarCache("html5.offmainthread", &sOffMainThread);
|
||||
Preferences::AddBoolVarCache(&sEnabled, "html5.parser.enable");
|
||||
Preferences::AddBoolVarCache(&sOffMainThread, "html5.offmainthread");
|
||||
nsHtml5Atoms::AddRefAtoms();
|
||||
nsHtml5AttributeName::initializeStatics();
|
||||
nsHtml5ElementName::initializeStatics();
|
||||
|
@ -65,10 +65,10 @@ PRInt32 nsHtml5StreamParser::sTimerSubsequentDelay = 120;
|
||||
void
|
||||
nsHtml5StreamParser::InitializeStatics()
|
||||
{
|
||||
nsContentUtils::AddIntPrefVarCache("html5.flushtimer.initialdelay",
|
||||
&sTimerInitialDelay);
|
||||
nsContentUtils::AddIntPrefVarCache("html5.flushtimer.subsequentdelay",
|
||||
&sTimerSubsequentDelay);
|
||||
Preferences::AddIntVarCache(&sTimerInitialDelay,
|
||||
"html5.flushtimer.initialdelay");
|
||||
Preferences::AddIntVarCache(&sTimerSubsequentDelay,
|
||||
"html5.flushtimer.subsequentdelay");
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user