Bug 1557905. Stop using [array] in nsIFontEnumerator. r=jfkthame

Differential Revision: https://phabricator.services.mozilla.com/D34265

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Boris Zbarsky 2019-06-08 08:50:47 +00:00
parent 7209af0ada
commit 4fcc4016bd
4 changed files with 13 additions and 41 deletions

View File

@ -12,12 +12,10 @@ interface nsIFontEnumerator : nsISupports
/**
* Return a sorted array of the names of all installed fonts.
*
* @param aCount returns number of names returned
* @param aResult returns array of names
* @return array of names
* @return void
*/
void EnumerateAllFonts(out uint32_t aCount,
[retval, array, size_is(aCount)] out wstring aResult);
Array<AString> EnumerateAllFonts();
/**
* Return a sorted array of names of fonts that support the given language
@ -25,12 +23,10 @@ interface nsIFontEnumerator : nsISupports
*
* @param aLangGroup language group
* @param aGeneric CSS generic font
* @param aCount returns number of names returned
* @param aResult returns array of names
* @return array of names
* @return void
*/
void EnumerateFonts(in string aLangGroup, in string aGeneric,
out uint32_t aCount, [retval, array, size_is(aCount)] out wstring aResult);
Array<AString> EnumerateFonts(in string aLangGroup, in string aGeneric);
/**
* Return a promise that resolves to a sorted array of the names of all

View File

@ -23,20 +23,14 @@ NS_IMPL_ISUPPORTS(nsThebesFontEnumerator, nsIFontEnumerator)
nsThebesFontEnumerator::nsThebesFontEnumerator() {}
NS_IMETHODIMP
nsThebesFontEnumerator::EnumerateAllFonts(uint32_t* aCount,
char16_t*** aResult) {
return EnumerateFonts(nullptr, nullptr, aCount, aResult);
nsThebesFontEnumerator::EnumerateAllFonts(nsTArray<nsString>& aResult) {
return EnumerateFonts(nullptr, nullptr, aResult);
}
NS_IMETHODIMP
nsThebesFontEnumerator::EnumerateFonts(const char* aLangGroup,
const char* aGeneric, uint32_t* aCount,
char16_t*** aResult) {
NS_ENSURE_ARG_POINTER(aCount);
NS_ENSURE_ARG_POINTER(aResult);
nsTArray<nsString> fontList;
const char* aGeneric,
nsTArray<nsString>& aResult) {
nsAutoCString generic;
if (aGeneric)
generic.Assign(aGeneric);
@ -51,26 +45,8 @@ nsThebesFontEnumerator::EnumerateFonts(const char* aLangGroup,
langGroupAtom = NS_Atomize(lowered);
}
nsresult rv =
gfxPlatform::GetPlatform()->GetFontList(langGroupAtom, generic, fontList);
if (NS_FAILED(rv)) {
*aCount = 0;
*aResult = nullptr;
/* XXX in this case, do we want to return the CSS generics? */
return NS_OK;
}
char16_t** fs = static_cast<char16_t**>(
moz_xmalloc(fontList.Length() * sizeof(char16_t*)));
for (uint32_t i = 0; i < fontList.Length(); i++) {
fs[i] = ToNewUnicode(fontList[i]);
}
*aResult = fs;
*aCount = fontList.Length();
return NS_OK;
return gfxPlatform::GetPlatform()->GetFontList(langGroupAtom, generic,
aResult);
}
struct EnumerateFontsPromise final {

View File

@ -33,8 +33,8 @@ var CI = SpecialPowers.Ci;
var fe =
CC["@mozilla.org/gfx/fontenumerator;1"].createInstance(CI.nsIFontEnumerator);
var serifFonts = fe.EnumerateFonts("x-western", "serif", {});
var monospaceFonts = fe.EnumerateFonts("x-western", "monospace", {});
var serifFonts = fe.EnumerateFonts("x-western", "serif");
var monospaceFonts = fe.EnumerateFonts("x-western", "monospace");
function table_width_for_font(font) {
tableElement.style.fontFamily = '"' + font + '"';

View File

@ -28,7 +28,7 @@ var CI = SpecialPowers.Ci;
var fe =
CC["@mozilla.org/gfx/fontenumerator;1"].createInstance(CI.nsIFontEnumerator);
var allFonts = fe.EnumerateFonts(null, null, {});
var allFonts = fe.EnumerateFonts(null, null);
var idx = 0;
var list = "";