mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-28 05:10:49 +00:00
Bug 1493955 - Store floating-point preferences in a locale-independent way r=njn
Differential Revision: https://phabricator.services.mozilla.com/D6796 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
09ed84ec91
commit
7089fe7369
@ -2394,6 +2394,7 @@ nsPrefBranch::GetFloatPref(const char* aPrefName, float* aRetVal)
|
||||
nsAutoCString stringVal;
|
||||
nsresult rv = GetCharPref(aPrefName, stringVal);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// ToFloat() does a locale-independent conversion.
|
||||
*aRetVal = stringVal.ToFloat(&rv);
|
||||
}
|
||||
|
||||
@ -5035,6 +5036,7 @@ Preferences::GetFloat(const char* aPrefName,
|
||||
nsAutoCString result;
|
||||
nsresult rv = Preferences::GetCString(aPrefName, result, aKind);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// ToFloat() does a locale-independent conversion.
|
||||
*aResult = result.ToFloat(&rv);
|
||||
}
|
||||
return rv;
|
||||
@ -5845,7 +5847,9 @@ static void
|
||||
SetPref_float(const char* aName, float aDefaultValue)
|
||||
{
|
||||
PrefValue value;
|
||||
nsPrintfCString defaultValue("%f", aDefaultValue);
|
||||
// Convert the value in a locale-independent way.
|
||||
nsAutoCString defaultValue;
|
||||
defaultValue.AppendFloat(aDefaultValue);
|
||||
value.mStringVal = defaultValue.get();
|
||||
pref_SetPref(aName,
|
||||
PrefType::String,
|
||||
@ -5973,8 +5977,7 @@ InitVarCachePref(const nsACString& aName,
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: this will eventually become used
|
||||
MOZ_MAYBE_UNUSED static void
|
||||
static void
|
||||
InitVarCachePref(const nsACString& aName,
|
||||
float* aCache,
|
||||
float aDefaultValue,
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsString.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsWeakReference.h"
|
||||
@ -309,7 +308,9 @@ public:
|
||||
float aValue,
|
||||
PrefValueKind aKind = PrefValueKind::User)
|
||||
{
|
||||
return SetCString(aPrefName, nsPrintfCString("%f", aValue), aKind);
|
||||
nsAutoCString value;
|
||||
value.AppendFloat(aValue);
|
||||
return SetCString(aPrefName, value, aKind);
|
||||
}
|
||||
|
||||
static nsresult SetCString(const char* aPrefName,
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsScriptSecurityManager.h"
|
||||
#include "nsSandboxFlags.h"
|
||||
#include "prtime.h"
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "nsILoadInfo.h"
|
||||
#include "nsIXULRuntime.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "nsQueryObject.h"
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
#include "other/CombinedStacks.h"
|
||||
#include "other/ProcessedStack.h"
|
||||
#include "nsPrintfCString.h"
|
||||
|
||||
using namespace mozilla::Telemetry;
|
||||
using namespace TelemetryTestHelpers;
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "InfallibleVector.h"
|
||||
#include "MemorySnapshot.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "ParentInternal.h"
|
||||
#include "ProcessRecordReplay.h"
|
||||
#include "ProcessRedirect.h"
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "mozilla/SchedulerGroup.h"
|
||||
#include "nsCycleCollector.h"
|
||||
#include "nsIThread.h"
|
||||
#include "nsPrintfCString.h"
|
||||
#include "nsThread.h"
|
||||
#include "nsThreadManager.h"
|
||||
#include "PrioritizedEventQueue.h"
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsILabelableRunnable.h"
|
||||
#include "nsPrintfCString.h"
|
||||
|
||||
// Windows silliness. winbase.h defines an empty no-argument Yield macro.
|
||||
#undef Yield
|
||||
|
Loading…
x
Reference in New Issue
Block a user