зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1557501. Stop using [array] in nsIPrefBranch. r=njn
Differential Revision: https://phabricator.services.mozilla.com/D34032 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
6b74e0f7de
Коммит
89baee69d9
|
@ -2376,12 +2376,11 @@ bool gfxFcPlatformFontList::PrefFontListsUseOnlyGenerics() {
|
|||
static const char kFontNamePrefix[] = "font.name.";
|
||||
|
||||
bool prefFontsUseOnlyGenerics = true;
|
||||
uint32_t count;
|
||||
char** names;
|
||||
nsresult rv = Preferences::GetRootBranch()->GetChildList(kFontNamePrefix,
|
||||
&count, &names);
|
||||
if (NS_SUCCEEDED(rv) && count) {
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
nsTArray<nsCString> names;
|
||||
nsresult rv =
|
||||
Preferences::GetRootBranch()->GetChildList(kFontNamePrefix, names);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
for (auto& name : names) {
|
||||
// Check whether all font.name prefs map to generic keywords
|
||||
// and that the pref name and keyword match.
|
||||
// Ex: font.name.serif.ar ==> "serif" (ok)
|
||||
|
@ -2393,12 +2392,13 @@ bool gfxFcPlatformFontList::PrefFontListsUseOnlyGenerics() {
|
|||
// font.name-list.serif.ar ==> "Something, serif"
|
||||
// (return false)
|
||||
|
||||
nsDependentCString prefName(names[i] + ArrayLength(kFontNamePrefix) - 1);
|
||||
nsDependentCSubstring prefName =
|
||||
Substring(name, ArrayLength(kFontNamePrefix) - 1);
|
||||
nsCCharSeparatedTokenizer tokenizer(prefName, '.');
|
||||
const nsDependentCSubstring& generic = tokenizer.nextToken();
|
||||
const nsDependentCSubstring& langGroup = tokenizer.nextToken();
|
||||
nsAutoCString fontPrefValue;
|
||||
Preferences::GetCString(names[i], fontPrefValue);
|
||||
Preferences::GetCString(name.get(), fontPrefValue);
|
||||
if (fontPrefValue.IsEmpty()) {
|
||||
// The font name list may have two or more family names as comma
|
||||
// separated list. In such case, not matching with generic font
|
||||
|
@ -2414,7 +2414,6 @@ bool gfxFcPlatformFontList::PrefFontListsUseOnlyGenerics() {
|
|||
break;
|
||||
}
|
||||
}
|
||||
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, names);
|
||||
}
|
||||
return prefFontsUseOnlyGenerics;
|
||||
}
|
||||
|
|
|
@ -278,16 +278,15 @@ void nsHyphenationManager::LoadAliases() {
|
|||
if (!prefRootBranch) {
|
||||
return;
|
||||
}
|
||||
uint32_t prefCount;
|
||||
char** prefNames;
|
||||
nsresult rv = prefRootBranch->GetChildList(kIntlHyphenationAliasPrefix,
|
||||
&prefCount, &prefNames);
|
||||
if (NS_SUCCEEDED(rv) && prefCount > 0) {
|
||||
for (uint32_t i = 0; i < prefCount; ++i) {
|
||||
nsTArray<nsCString> prefNames;
|
||||
nsresult rv =
|
||||
prefRootBranch->GetChildList(kIntlHyphenationAliasPrefix, prefNames);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
for (auto& prefName : prefNames) {
|
||||
nsAutoCString value;
|
||||
rv = Preferences::GetCString(prefNames[i], value);
|
||||
rv = Preferences::GetCString(prefName.get(), value);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsAutoCString alias(prefNames[i]);
|
||||
nsAutoCString alias(prefName);
|
||||
alias.Cut(0, sizeof(kIntlHyphenationAliasPrefix) - 1);
|
||||
ToLowerCase(alias);
|
||||
ToLowerCase(value);
|
||||
|
@ -296,6 +295,5 @@ void nsHyphenationManager::LoadAliases() {
|
|||
mHyphAliases.Put(aliasAtom, valueAtom);
|
||||
}
|
||||
}
|
||||
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(prefCount, prefNames);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2575,24 +2575,15 @@ nsPrefBranch::DeleteBranch(const char* aStartingAt) {
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPrefBranch::GetChildList(const char* aStartingAt, uint32_t* aCount,
|
||||
char*** aChildArray) {
|
||||
char** outArray;
|
||||
int32_t numPrefs;
|
||||
int32_t dwIndex;
|
||||
AutoTArray<nsCString, 32> prefArray;
|
||||
|
||||
nsPrefBranch::GetChildList(const char* aStartingAt,
|
||||
nsTArray<nsCString>& aChildArray) {
|
||||
NS_ENSURE_ARG(aStartingAt);
|
||||
NS_ENSURE_ARG_POINTER(aCount);
|
||||
NS_ENSURE_ARG_POINTER(aChildArray);
|
||||
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
*aChildArray = nullptr;
|
||||
*aCount = 0;
|
||||
|
||||
// This will contain a list of all the pref name strings. Allocated on the
|
||||
// stack for speed.
|
||||
AutoTArray<nsCString, 32> prefArray;
|
||||
|
||||
const PrefName& parent = GetPrefName(aStartingAt);
|
||||
size_t parentLen = parent.Length();
|
||||
|
@ -2604,22 +2595,12 @@ nsPrefBranch::GetChildList(const char* aStartingAt, uint32_t* aCount,
|
|||
|
||||
// Now that we've built up the list, run the callback on all the matching
|
||||
// elements.
|
||||
numPrefs = prefArray.Length();
|
||||
|
||||
if (numPrefs) {
|
||||
outArray = (char**)moz_xmalloc(numPrefs * sizeof(char*));
|
||||
|
||||
for (dwIndex = 0; dwIndex < numPrefs; ++dwIndex) {
|
||||
// we need to lop off mPrefRoot in case the user is planning to pass this
|
||||
// back to us because if they do we are going to add mPrefRoot again.
|
||||
const nsCString& element = prefArray[dwIndex];
|
||||
outArray[dwIndex] =
|
||||
(char*)moz_xmemdup(element.get() + mPrefRoot.Length(),
|
||||
element.Length() - mPrefRoot.Length() + 1);
|
||||
}
|
||||
*aChildArray = outArray;
|
||||
aChildArray.SetCapacity(prefArray.Length());
|
||||
for (auto& element : prefArray) {
|
||||
// we need to lop off mPrefRoot in case the user is planning to pass this
|
||||
// back to us because if they do we are going to add mPrefRoot again.
|
||||
aChildArray.AppendElement(Substring(element, mPrefRoot.Length()));
|
||||
}
|
||||
*aCount = numPrefs;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -336,8 +336,7 @@ interface nsIPrefBranch : nsISupports
|
|||
* @param aStartingAt The point on the branch at which to start enumerating
|
||||
* the child preferences. Pass in "" to enumerate all
|
||||
* preferences referenced by this branch.
|
||||
* @param aCount Receives the number of elements in the array.
|
||||
* @param aChildArray Receives the array of child preferences.
|
||||
* @return The array of child preferences.
|
||||
*
|
||||
* @note
|
||||
* This method can be called on either a default or user branch but, in
|
||||
|
@ -345,9 +344,7 @@ interface nsIPrefBranch : nsISupports
|
|||
*
|
||||
* @throws Error The preference(s) do not exist or an error occurred.
|
||||
*/
|
||||
void getChildList(in string aStartingAt,
|
||||
[optional] out unsigned long aCount,
|
||||
[array, size_is(aCount), retval] out string aChildArray);
|
||||
Array<ACString> getChildList(in string aStartingAt);
|
||||
|
||||
/**
|
||||
* Called to reset all of the preferences referenced by this branch to their
|
||||
|
|
|
@ -828,15 +828,13 @@ nsresult nsUrlClassifierUtils::ReadProvidersFromPrefs(ProviderDictType& aDict) {
|
|||
|
||||
// We've got a pref branch for "browser.safebrowsing.provider.".
|
||||
// Enumerate all children prefs and parse providers.
|
||||
uint32_t childCount;
|
||||
char** childArray;
|
||||
rv = prefBranch->GetChildList("", &childCount, &childArray);
|
||||
nsTArray<nsCString> childArray;
|
||||
rv = prefBranch->GetChildList("", childArray);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Collect providers from childArray.
|
||||
nsTHashtable<nsCStringHashKey> providers;
|
||||
for (uint32_t i = 0; i < childCount; i++) {
|
||||
nsCString child(childArray[i]);
|
||||
for (auto& child : childArray) {
|
||||
auto dotPos = child.FindChar('.');
|
||||
if (dotPos < 0) {
|
||||
continue;
|
||||
|
@ -846,7 +844,6 @@ nsresult nsUrlClassifierUtils::ReadProvidersFromPrefs(ProviderDictType& aDict) {
|
|||
|
||||
providers.PutEntry(provider);
|
||||
}
|
||||
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(childCount, childArray);
|
||||
|
||||
// Now we have all providers. Check which one owns |aTableName|.
|
||||
// e.g. The owning lists of provider "google" is defined in
|
||||
|
|
|
@ -32,7 +32,7 @@ const prefs = [
|
|||
var providers = {};
|
||||
|
||||
var branch = SpecialPowers.Services.prefs.getBranch("browser.safebrowsing.provider.");
|
||||
var children = branch.getChildList("", {});
|
||||
var children = branch.getChildList("");
|
||||
|
||||
for (var child of children) {
|
||||
var prefComponents = child.split(".");
|
||||
|
|
|
@ -35,16 +35,14 @@ NS_IMPL_ISUPPORTS(LogModulePrefWatcher, nsIObserver)
|
|||
* pref to false, or use the MOZ_LOG_FILE and MOZ_LOG_MODULES env vars.
|
||||
*/
|
||||
static void ResetExistingPrefs() {
|
||||
uint32_t count;
|
||||
char** names;
|
||||
nsresult rv = Preferences::GetRootBranch()->GetChildList(kLoggingPrefPrefix,
|
||||
&count, &names);
|
||||
if (NS_SUCCEEDED(rv) && count) {
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
nsTArray<nsCString> names;
|
||||
nsresult rv =
|
||||
Preferences::GetRootBranch()->GetChildList(kLoggingPrefPrefix, names);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
for (auto& name : names) {
|
||||
// Clearing the pref will cause it to reload, thus resetting the log level
|
||||
Preferences::ClearUser(names[i]);
|
||||
Preferences::ClearUser(name.get());
|
||||
}
|
||||
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, names);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,14 +110,12 @@ static void LoadExistingPrefs() {
|
|||
return;
|
||||
}
|
||||
|
||||
uint32_t count;
|
||||
char** names;
|
||||
nsresult rv = root->GetChildList(kLoggingPrefPrefix, &count, &names);
|
||||
if (NS_SUCCEEDED(rv) && count) {
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
LoadPrefValue(names[i]);
|
||||
nsTArray<nsCString> names;
|
||||
nsresult rv = root->GetChildList(kLoggingPrefPrefix, names);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
for (auto& name : names) {
|
||||
LoadPrefValue(name.get());
|
||||
}
|
||||
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(count, names);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче