Merge inbound to mozilla-central. a=merge

This commit is contained in:
Margareta Eliza Balazs 2018-09-18 17:33:09 +03:00
Родитель c0d8c0ec57 ec73ee3318
Коммит fdb780335d
24 изменённых файлов: 158 добавлений и 1583 удалений

Просмотреть файл

@ -121,7 +121,9 @@ const startupPhases = {
}},
};
if (Services.prefs.getBoolPref("browser.startup.blankWindow")) {
if (Services.prefs.getBoolPref("browser.startup.blankWindow") &&
Services.prefs.getCharPref("lightweightThemes.selectedThemeID") ==
"default-theme@mozilla.org") {
startupPhases["before profile selection"].whitelist.components.add("XULStore.js");
}

Просмотреть файл

@ -308,6 +308,12 @@ let ACTORS = {
if (!Services.prefs.getBoolPref("browser.startup.blankWindow", false))
return;
// Until bug 1450626 and bug 1488384 are fixed, skip the blank window when
// using a non-default theme.
if (Services.prefs.getCharPref("lightweightThemes.selectedThemeID", "") !=
"default-theme@mozilla.org")
return;
let store = Services.xulStore;
let getValue = attr =>
store.getValue(AppConstants.BROWSER_CHROME_URL, "main-window", attr);

Просмотреть файл

@ -1020,7 +1020,9 @@ ContentEventHandler::GenerateFlatFontRanges(const RawRange& aRawRange,
const FontFamilyName& fontName = fontList.IsEmpty() ?
FontFamilyName(fontList.GetDefaultFontType()) :
fontList.GetFontlist()->mNames[0];
fontName.AppendToString(fontRange->mFontName, false);
nsAutoCString name;
fontName.AppendToString(name, false);
AppendUTF8toUTF16(name, fontRange->mFontName);
fontRange->mFontSize =
frame->PresContext()->AppUnitsToDevPixels(font.size);
}

Просмотреть файл

@ -17,18 +17,10 @@
#include "mozilla/RefPtr.h" // for RefPtr
#include "nsColor.h" // for nsColor and NS_RGBA
#include "nsCoord.h" // for nscoord
#include "nsStringFwd.h" // for nsAString
#include "nsString.h" // for nsString
#include "nsTArray.h" // for nsTArray
struct gfxFontStyle;
// XXX we need a method to enumerate all of the possible fonts on the
// system across family, weight, style, size, etc. But not here!
// Enumerator callback function. Return false to stop
typedef bool (*nsFontFamilyEnumFunc)(const nsString& aFamily, bool aGeneric, void *aData);
// IDs for generic fonts
// NOTE: 0, 1 are reserved for the special IDs of the default variable
// and fixed fonts in the presentation context, see nsPresContext.h

Просмотреть файл

@ -1536,14 +1536,14 @@ gfxFT2FontList::GetSystemFontList(InfallibleTArray<FontListEntry>* retValue)
static void
LoadSkipSpaceLookupCheck(nsTHashtable<nsCStringHashKey>& aSkipSpaceLookupCheck)
{
AutoTArray<nsString, 5> skiplist;
AutoTArray<nsCString, 5> skiplist;
gfxFontUtils::GetPrefsFontList(
"font.whitelist.skip_default_features_space_check",
skiplist);
uint32_t numFonts = skiplist.Length();
for (uint32_t i = 0; i < numFonts; i++) {
ToLowerCase(skiplist[i]);
aSkipSpaceLookupCheck.PutEntry(NS_ConvertUTF16toUTF8(skiplist[i]));
aSkipSpaceLookupCheck.PutEntry(skiplist[i]);
}
}

Просмотреть файл

@ -1865,7 +1865,7 @@ gfxFcPlatformFontList::GetDefaultFontForPlatform(const gfxFontStyle* aStyle)
// Get the default font by using a fake name to retrieve the first
// scalable font that fontconfig suggests for the given language.
PrefFontList* prefFonts =
FindGenericFamilies(NS_LITERAL_STRING("-moz-default"), aStyle->language);
FindGenericFamilies(NS_LITERAL_CSTRING("-moz-default"), aStyle->language);
NS_ASSERTION(prefFonts, "null list of generic fonts");
if (prefFonts && !prefFonts->IsEmpty()) {
return (*prefFonts)[0];
@ -1944,10 +1944,9 @@ gfxFcPlatformFontList::FindAndAddFamilies(const nsACString& aFamily,
}
// fontconfig generics? use fontconfig to determine the family for lang
NS_ConvertUTF8toUTF16 family16(familyName);
if (isDeprecatedGeneric ||
mozilla::FontFamilyName::Convert(family16).IsGeneric()) {
PrefFontList* prefFonts = FindGenericFamilies(family16, language);
mozilla::FontFamilyName::Convert(familyName).IsGeneric()) {
PrefFontList* prefFonts = FindGenericFamilies(familyName, language);
if (prefFonts && !prefFonts->IsEmpty()) {
aOutput->AppendElements(*prefFonts);
return true;
@ -2137,7 +2136,7 @@ gfxFcPlatformFontList::AddGenericFonts(mozilla::FontFamilyType aGenericType,
// By default, most font prefs on Linux map to "use fontconfig"
// keywords. So only need to explicitly lookup font pref if
// non-default settings exist
NS_ConvertASCIItoUTF16 genericToLookup(generic);
nsAutoCString genericToLookup(generic);
if ((!mAlwaysUseFontconfigGenerics && aLanguage) ||
aLanguage == nsGkAtoms::x_math) {
nsAtom* langGroup = GetLangGroup(aLanguage);
@ -2162,7 +2161,8 @@ gfxFcPlatformFontList::AddGenericFonts(mozilla::FontFamilyType aGenericType,
usePrefFontList = true;
} else {
// serif, sans-serif or monospace was specified
genericToLookup.Assign(fontlistValue);
genericToLookup.Truncate();
AppendUTF16toUTF8(fontlistValue, genericToLookup);
}
}
}
@ -2230,17 +2230,15 @@ gfxFcPlatformFontList::GetFTLibrary()
}
gfxPlatformFontList::PrefFontList*
gfxFcPlatformFontList::FindGenericFamilies(const nsAString& aGeneric,
gfxFcPlatformFontList::FindGenericFamilies(const nsCString& aGeneric,
nsAtom* aLanguage)
{
// set up name
NS_ConvertUTF16toUTF8 generic(aGeneric);
nsAutoCString fcLang;
GetSampleLangForGroup(aLanguage, fcLang);
ToLowerCase(fcLang);
nsAutoCString genericLang(generic);
nsAutoCString genericLang(aGeneric);
if (fcLang.Length() > 0) {
genericLang.Append('-');
}
@ -2255,7 +2253,7 @@ gfxFcPlatformFontList::FindGenericFamilies(const nsAString& aGeneric,
// if not found, ask fontconfig to pick the appropriate font
nsAutoRef<FcPattern> genericPattern(FcPatternCreate());
FcPatternAddString(genericPattern, FC_FAMILY,
ToFcChar8Ptr(generic.get()));
ToFcChar8Ptr(aGeneric.get()));
// -- prefer scalable fonts
FcPatternAddBool(genericPattern, FC_SCALABLE, FcTrue);

Просмотреть файл

@ -360,7 +360,7 @@ protected:
// figure out which families fontconfig maps a generic to
// (aGeneric assumed already lowercase)
PrefFontList* FindGenericFamilies(const nsAString& aGeneric,
PrefFontList* FindGenericFamilies(const nsCString& aGeneric,
nsAtom* aLanguage);
// are all pref font settings set to use fontconfig generics?

Просмотреть файл

@ -6,6 +6,7 @@
#ifndef GFX_FONT_FAMILY_LIST_H
#define GFX_FONT_FAMILY_LIST_H
#include "nsAtom.h"
#include "nsDebug.h"
#include "nsISupportsImpl.h"
#include "nsString.h"
@ -50,7 +51,7 @@ enum FontFamilyType : uint8_t {
enum QuotedName { eQuotedName, eUnquotedName };
/**
* font family name, a string for the name if not a generic and
* font family name, an Atom for the name if not a generic and
* a font type indicated named family or which generic family
*/
@ -60,7 +61,7 @@ struct FontFamilyName final {
{}
// named font family - e.g. Helvetica
explicit FontFamilyName(const nsAString& aFamilyName,
explicit FontFamilyName(nsAtom* aFamilyName,
QuotedName aQuoted = eUnquotedName) {
mType = (aQuoted == eQuotedName) ? eFamily_named_quoted : eFamily_named;
mName = aFamilyName;
@ -69,7 +70,7 @@ struct FontFamilyName final {
explicit FontFamilyName(const nsACString& aFamilyName,
QuotedName aQuoted = eUnquotedName) {
mType = (aQuoted == eQuotedName) ? eFamily_named_quoted : eFamily_named;
mName.Append(NS_ConvertUTF8toUTF16(aFamilyName));
mName = NS_Atomize(aFamilyName);
}
// generic font family - e.g. sans-serif
@ -78,7 +79,7 @@ struct FontFamilyName final {
aType != eFamily_named_quoted &&
aType != eFamily_none,
"expected a generic font type");
mName.Truncate();
mName = nullptr;
mType = aType;
}
@ -95,16 +96,16 @@ struct FontFamilyName final {
return !IsNamed();
}
void AppendToString(nsAString& aFamilyList, bool aQuotes = true) const {
void AppendToString(nsACString& aFamilyList, bool aQuotes = true) const {
switch (mType) {
case eFamily_named:
aFamilyList.Append(mName);
aFamilyList.Append(nsAtomCString(mName));
break;
case eFamily_named_quoted:
if (aQuotes) {
aFamilyList.Append('"');
}
aFamilyList.Append(mName);
aFamilyList.Append(nsAtomCString(mName));
if (aQuotes) {
aFamilyList.Append('"');
}
@ -134,7 +135,7 @@ struct FontFamilyName final {
// helper method that converts generic names to the right enum value
static FontFamilyName
Convert(const nsAString& aFamilyOrGenericName) {
Convert(const nsACString& aFamilyOrGenericName) {
// should only be passed a single font - not entirely correct, a family
// *could* have a comma in it but in practice never does so
// for debug purposes this is fine
@ -161,13 +162,8 @@ struct FontFamilyName final {
return FontFamilyName(genericType);
}
// memory reporting
size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const {
return mName.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
}
FontFamilyType mType;
nsString mName; // empty if mType != eFamily_named
RefPtr<nsAtom> mName; // null if mType != eFamily_named
};
inline bool
@ -194,7 +190,7 @@ public:
{
}
SharedFontList(const nsAString& aFamilyName, QuotedName aQuoted)
SharedFontList(nsAtom* aFamilyName, QuotedName aQuoted)
: mNames { FontFamilyName(aFamilyName, aQuoted) }
{
}
@ -234,9 +230,6 @@ public:
size_t n = 0;
n += aMallocSizeOf(this);
n += mNames.ShallowSizeOfExcludingThis(aMallocSizeOf);
for (const FontFamilyName& name : mNames) {
n += name.SizeOfExcludingThis(aMallocSizeOf);
}
return n;
}
@ -278,7 +271,7 @@ public:
{
}
FontFamilyList(const nsAString& aFamilyName,
FontFamilyList(nsAtom* aFamilyName,
QuotedName aQuoted)
: mFontlist(MakeNotNull<SharedFontList*>(aFamilyName, aQuoted))
, mDefaultFontType(eFamily_none)
@ -394,7 +387,7 @@ public:
SetFontlist(std::move(names));
}
void ToString(nsAString& aFamilyList,
void ToString(nsACString& aFamilyList,
bool aQuotes = true,
bool aIncludeDefault = false) const {
const nsTArray<FontFamilyName>& names = mFontlist->mNames;
@ -420,15 +413,14 @@ public:
}
// searches for a specific non-generic name, lowercase comparison
bool Contains(const nsAString& aFamilyName) const {
nsAutoString fam(aFamilyName);
bool Contains(const nsACString& aFamilyName) const {
NS_ConvertUTF8toUTF16 fam(aFamilyName);
ToLowerCase(fam);
for (const FontFamilyName& name : mFontlist->mNames) {
if (name.mType != eFamily_named &&
name.mType != eFamily_named_quoted) {
if (!name.IsNamed()) {
continue;
}
nsAutoString listname(name.mName);
nsAtomString listname(name.mName);
ToLowerCase(listname);
if (listname.Equals(fam)) {
return true;

Просмотреть файл

@ -824,19 +824,19 @@ gfxFontUtils::MapCharToGlyph(const uint8_t *aCmapBuf, uint32_t aBufLength,
return gid;
}
void gfxFontUtils::ParseFontList(const nsAString& aFamilyList,
nsTArray<nsString>& aFontList)
void gfxFontUtils::ParseFontList(const nsACString& aFamilyList,
nsTArray<nsCString>& aFontList)
{
const char16_t kComma = char16_t(',');
const char kComma = ',';
// append each font name to the list
nsAutoString fontname;
const char16_t *p, *p_end;
nsAutoCString fontname;
const char *p, *p_end;
aFamilyList.BeginReading(p);
aFamilyList.EndReading(p_end);
while (p < p_end) {
const char16_t *nameStart = p;
const char *nameStart = p;
while (++p != p_end && *p != kComma)
/* nothing */ ;
@ -853,11 +853,11 @@ void gfxFontUtils::ParseFontList(const nsAString& aFamilyList,
}
void gfxFontUtils::AppendPrefsFontList(const char *aPrefName,
nsTArray<nsString>& aFontList)
nsTArray<nsCString>& aFontList)
{
// get the list of single-face font families
nsAutoString fontlistValue;
nsresult rv = Preferences::GetString(aPrefName, fontlistValue);
nsAutoCString fontlistValue;
nsresult rv = Preferences::GetCString(aPrefName, fontlistValue);
if (NS_FAILED(rv)) {
return;
}
@ -866,7 +866,7 @@ void gfxFontUtils::AppendPrefsFontList(const char *aPrefName,
}
void gfxFontUtils::GetPrefsFontList(const char *aPrefName,
nsTArray<nsString>& aFontList)
nsTArray<nsCString>& aFontList)
{
aFontList.Clear();
AppendPrefsFontList(aPrefName, aFontList);

Просмотреть файл

@ -962,16 +962,16 @@ public:
// parse a simple list of font family names into
// an array of strings
static void ParseFontList(const nsAString& aFamilyList,
nsTArray<nsString>& aFontList);
static void ParseFontList(const nsACString& aFamilyList,
nsTArray<nsCString>& aFontList);
// for a given font list pref name, append list of font names
static void AppendPrefsFontList(const char *aPrefName,
nsTArray<nsString>& aFontList);
nsTArray<nsCString>& aFontList);
// for a given font list pref name, initialize a list of font names
static void GetPrefsFontList(const char *aPrefName,
nsTArray<nsString>& aFontList);
nsTArray<nsCString>& aFontList);
// generate a unique font name
static nsresult MakeUniqueUserFontName(nsAString& aName);

Просмотреть файл

@ -1244,12 +1244,12 @@ gfxMacPlatformFontList::InitFontListForPlatform()
void
gfxMacPlatformFontList::InitSingleFaceList()
{
AutoTArray<nsString, 10> singleFaceFonts;
AutoTArray<nsCString, 10> singleFaceFonts;
gfxFontUtils::GetPrefsFontList("font.single-face-list", singleFaceFonts);
for (const auto& singleFaceFamily : singleFaceFonts) {
for (auto& familyName : singleFaceFonts) {
LOG_FONTLIST(("(fontlist-singleface) face name: %s\n",
NS_ConvertUTF16toUTF8(singleFaceFamily).get()));
familyName.get()));
// Each entry in the "single face families" list is expected to be a
// colon-separated pair of FaceName:Family,
// where FaceName is the individual face name (psname) of a font
@ -1257,7 +1257,6 @@ gfxMacPlatformFontList::InitSingleFaceList()
// and Family is the standard family to which that face belongs.
// The only such face listed by default is
// Osaka-Mono:Osaka
NS_ConvertUTF16toUTF8 familyName(singleFaceFamily);
auto colon = familyName.FindChar(':');
if (colon == kNotFound) {
continue;

Просмотреть файл

@ -275,7 +275,7 @@ const uint32_t kNumGenerics = 5;
void
gfxPlatformFontList::ApplyWhitelist()
{
nsTArray<nsString> list;
nsTArray<nsCString> list;
gfxFontUtils::GetPrefsFontList(kFontSystemWhitelistPref, list);
uint32_t numFonts = list.Length();
mFontFamilyWhitelistActive = (numFonts > 0);
@ -285,7 +285,7 @@ gfxPlatformFontList::ApplyWhitelist()
nsTHashtable<nsCStringHashKey> familyNamesWhitelist;
for (uint32_t i = 0; i < numFonts; i++) {
nsAutoCString key;
ToLowerCase(NS_ConvertUTF16toUTF8(list[i]), key);
ToLowerCase(list[i], key);
familyNamesWhitelist.PutEntry(key);
}
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
@ -507,13 +507,13 @@ gfxPlatformFontList::LookupInFaceNameLists(const nsACString& aFaceName)
void
gfxPlatformFontList::PreloadNamesList()
{
AutoTArray<nsString, 10> preloadFonts;
AutoTArray<nsCString, 10> preloadFonts;
gfxFontUtils::GetPrefsFontList("font.preload-names-list", preloadFonts);
uint32_t numFonts = preloadFonts.Length();
for (uint32_t i = 0; i < numFonts; i++) {
nsAutoCString key;
GenerateFontListKey(NS_ConvertUTF16toUTF8(preloadFonts[i]), key);
GenerateFontListKey(preloadFonts[i], key);
// only search canonical names!
gfxFontFamily *familyEntry = mFontFamilies.GetWeak(key);
@ -527,12 +527,12 @@ gfxPlatformFontList::PreloadNamesList()
void
gfxPlatformFontList::LoadBadUnderlineList()
{
AutoTArray<nsString, 10> blacklist;
AutoTArray<nsCString, 10> blacklist;
gfxFontUtils::GetPrefsFontList("font.blacklist.underline_offset", blacklist);
uint32_t numFonts = blacklist.Length();
for (uint32_t i = 0; i < numFonts; i++) {
nsAutoCString key;
GenerateFontListKey(NS_ConvertUTF16toUTF8(blacklist[i]), key);
GenerateFontListKey(blacklist[i], key);
mBadUnderlineFamilyNames.PutEntry(key);
}
}
@ -911,12 +911,12 @@ gfxPlatformFontList::GetDefaultFontFamily(const nsACString& aLangGroup,
return nullptr;
}
AutoTArray<nsString,4> names;
AutoTArray<nsCString,4> names;
gfxFontUtils::AppendPrefsFontList(
NameListPref(aGenericFamily, aLangGroup).get(), names);
for (nsString& name : names) {
gfxFontFamily* fontFamily = FindFamily(NS_ConvertUTF16toUTF8(name));
for (const nsCString& name : names) {
gfxFontFamily* fontFamily = FindFamily(name);
if (fontFamily) {
return fontFamily;
}
@ -972,7 +972,7 @@ gfxPlatformFontList::ResolveGenericFontNames(
return;
}
AutoTArray<nsString,4> genericFamilies;
AutoTArray<nsCString,4> genericFamilies;
// load family for "font.name.generic.lang"
gfxFontUtils::AppendPrefsFontList(
@ -993,7 +993,7 @@ gfxPlatformFontList::ResolveGenericFontNames(
printf("%s ===> ", prefFontName.get());
for (uint32_t k = 0; k < aGenericFamilies->Length(); k++) {
if (k > 0) printf(", ");
printf("%s", NS_ConvertUTF16toUTF8(aGenericFamilies[k]->Name()).get());
printf("%s", aGenericFamilies[k]->Name().get());
}
printf("\n");
#endif
@ -1004,7 +1004,7 @@ gfxPlatformFontList::ResolveEmojiFontNames(
nsTArray<RefPtr<gfxFontFamily>>* aGenericFamilies)
{
// emoji preference has no lang name
AutoTArray<nsString,4> genericFamilies;
AutoTArray<nsCString,4> genericFamilies;
nsAutoCString prefFontListName("font.name-list.emoji");
gfxFontUtils::AppendPrefsFontList(prefFontListName.get(), genericFamilies);
@ -1016,17 +1016,17 @@ gfxPlatformFontList::ResolveEmojiFontNames(
void
gfxPlatformFontList::GetFontFamiliesFromGenericFamilies(
nsTArray<nsString>& aGenericNameFamilies,
nsTArray<nsCString>& aGenericNameFamilies,
nsAtom* aLangGroup,
nsTArray<RefPtr<gfxFontFamily>>* aGenericFamilies)
{
// lookup and add platform fonts uniquely
for (const nsString& genericFamily : aGenericNameFamilies) {
for (const nsCString& genericFamily : aGenericNameFamilies) {
gfxFontStyle style;
style.language = aLangGroup;
style.systemFont = false;
AutoTArray<FamilyAndGeneric,10> families;
FindAndAddFamilies(NS_ConvertUTF16toUTF8(genericFamily),
FindAndAddFamilies(genericFamily,
&families, FindFamiliesFlags(0),
&style);
for (const FamilyAndGeneric& f : families) {

Просмотреть файл

@ -520,7 +520,7 @@ protected:
void
GetFontFamiliesFromGenericFamilies(
nsTArray<nsString>& aGenericFamilies,
nsTArray<nsCString>& aGenericFamilies,
nsAtom* aLangGroup,
nsTArray<RefPtr<gfxFontFamily>>* aFontFamilies);

Просмотреть файл

@ -1830,7 +1830,7 @@ gfxFontGroup::BuildFontList()
// lookup fonts in the fontlist
for (const FontFamilyName& name : mFamilyList.GetFontlist()->mNames) {
if (name.IsNamed()) {
AddPlatformFont(NS_ConvertUTF16toUTF8(name.mName), fonts);
AddPlatformFont(nsAtomCString(name.mName), fonts);
} else {
pfl->AddGenericFonts(name.mType, mStyle.language, fonts);
if (mTextPerf) {
@ -2082,10 +2082,10 @@ gfxFontGroup::GetDefaultFont()
gfxCriticalError() << fontInitInfo.get();
char msg[256]; // CHECK buffer length if revising message below
nsAutoString familiesString;
nsAutoCString familiesString;
mFamilyList.ToString(familiesString);
SprintfLiteral(msg, "unable to find a usable font (%.220s)",
NS_ConvertUTF16toUTF8(familiesString).get());
familiesString.get());
MOZ_CRASH_UNSAFE_OOL(msg);
}
@ -2435,7 +2435,7 @@ gfxFontGroup::InitTextRun(DrawTarget* aDrawTarget,
if (MOZ_UNLIKELY(MOZ_LOG_TEST(log, LogLevel::Warning))) {
nsAutoCString lang;
mStyle.language->ToUTF8String(lang);
nsAutoString families;
nsAutoCString families;
mFamilyList.ToString(families);
nsAutoCString str((const char*)aString, aLength);
nsAutoString styleString;
@ -2445,7 +2445,7 @@ gfxFontGroup::InitTextRun(DrawTarget* aDrawTarget,
"len %d weight: %g stretch: %g%% style: %s size: %6.2f %zu-byte "
"TEXTRUN [%s] ENDTEXTRUN\n",
(mStyle.systemFont ? "textrunui" : "textrun"),
NS_ConvertUTF16toUTF8(families).get(),
families.get(),
(mFamilyList.GetDefaultFontType() == eFamily_serif ?
"serif" :
(mFamilyList.GetDefaultFontType() == eFamily_sans_serif ?
@ -2484,7 +2484,7 @@ gfxFontGroup::InitTextRun(DrawTarget* aDrawTarget,
if (MOZ_UNLIKELY(MOZ_LOG_TEST(log, LogLevel::Warning))) {
nsAutoCString lang;
mStyle.language->ToUTF8String(lang);
nsAutoString families;
nsAutoCString families;
mFamilyList.ToString(families);
nsAutoString styleString;
nsStyleUtil::AppendFontSlantStyle(mStyle.style, styleString);
@ -2494,7 +2494,7 @@ gfxFontGroup::InitTextRun(DrawTarget* aDrawTarget,
"len %d weight: %g stretch: %g%% style: %s size: %6.2f "
"%zu-byte TEXTRUN [%s] ENDTEXTRUN\n",
(mStyle.systemFont ? "textrunui" : "textrun"),
NS_ConvertUTF16toUTF8(families).get(),
families.get(),
(mFamilyList.GetDefaultFontType() == eFamily_serif ?
"serif" :
(mFamilyList.GetDefaultFontType() == eFamily_sans_serif ?
@ -3278,7 +3278,7 @@ void gfxFontGroup::ComputeRanges(nsTArray<gfxTextRange>& aRanges,
if (MOZ_UNLIKELY(MOZ_LOG_TEST(log, LogLevel::Debug))) {
nsAutoCString lang;
mStyle.language->ToUTF8String(lang);
nsAutoString families;
nsAutoCString families;
mFamilyList.ToString(families);
// collect the font matched for each range
@ -3310,7 +3310,7 @@ void gfxFontGroup::ComputeRanges(nsTArray<gfxTextRange>& aRanges,
("(%s-fontmatching) fontgroup: [%s] default: %s lang: %s script: %d"
"%s\n",
(mStyle.systemFont ? "textrunui" : "textrun"),
NS_ConvertUTF16toUTF8(families).get(),
families.get(),
(mFamilyList.GetDefaultFontType() == eFamily_serif ?
"serif" :
(mFamilyList.GetDefaultFontType() == eFamily_sans_serif ?

Просмотреть файл

@ -1081,11 +1081,10 @@ bool
gfxUserFontSet::ContainsUserFontSetFonts(const FontFamilyList& aFontList) const
{
for (const FontFamilyName& name : aFontList.GetFontlist()->mNames) {
if (name.mType != eFamily_named &&
name.mType != eFamily_named_quoted) {
if (!name.IsNamed()) {
continue;
}
if (LookupFamily(NS_ConvertUTF16toUTF8(name.mName))) {
if (LookupFamily(nsAtomCString(name.mName))) {
return true;
}
}

Просмотреть файл

@ -133,8 +133,8 @@ LangGroupFontPrefs::Initialize(nsAtom* aLangGroupAtom)
// XXX "font.name.variable."? There is no such pref...
MAKE_FONT_PREF_KEY(pref, "font.name.variable.", langGroup);
nsAutoString value;
Preferences::GetString(pref.get(), value);
nsAutoCString value;
Preferences::GetCString(pref.get(), value);
if (!value.IsEmpty()) {
FontFamilyName defaultVariableName = FontFamilyName::Convert(value);
FontFamilyType defaultType = defaultVariableName.mType;
@ -149,7 +149,7 @@ LangGroupFontPrefs::Initialize(nsAtom* aLangGroupAtom)
}
else {
MAKE_FONT_PREF_KEY(pref, "font.default.", langGroup);
Preferences::GetString(pref.get(), value);
Preferences::GetCString(pref.get(), value);
if (!value.IsEmpty()) {
FontFamilyName defaultVariableName = FontFamilyName::Convert(value);
FontFamilyType defaultType = defaultVariableName.mType;

Просмотреть файл

@ -10082,7 +10082,8 @@ nsLayoutUtils::ComputeSystemFont(nsFont* aSystemFont, LookAndFeel::FontID aFontI
nsAutoString systemFontName;
if (LookAndFeel::GetFont(aFontID, systemFontName, fontStyle, devPerCSS)) {
systemFontName.Trim("\"'");
aSystemFont->fontlist = FontFamilyList(systemFontName, eUnquotedName);
aSystemFont->fontlist =
FontFamilyList(NS_ConvertUTF16toUTF8(systemFontName), eUnquotedName);
aSystemFont->fontlist.SetDefaultFontType(eFamily_none);
aSystemFont->style = fontStyle.style;
aSystemFont->systemFont = fontStyle.systemFont;

Просмотреть файл

@ -162,25 +162,26 @@ Clean(nsString& aValue)
// helper to load a MathFont Property File
static nsresult
LoadProperties(const nsString& aName,
LoadProperties(const nsACString& aName,
nsCOMPtr<nsIPersistentProperties>& aProperties)
{
nsAutoString uriStr;
nsAutoCString uriStr;
uriStr.AssignLiteral("resource://gre/res/fonts/mathfont");
uriStr.Append(aName);
uriStr.StripWhitespace(); // that may come from aName
uriStr.AppendLiteral(".properties");
return NS_LoadPersistentPropertiesFromURISpec(getter_AddRefs(aProperties),
NS_ConvertUTF16toUTF8(uriStr));
uriStr);
}
class nsPropertiesTable final : public nsGlyphTable {
public:
explicit nsPropertiesTable(const nsString& aPrimaryFontName)
explicit nsPropertiesTable(const nsACString& aPrimaryFontName)
: mState(NS_TABLE_STATE_EMPTY)
{
MOZ_COUNT_CTOR(nsPropertiesTable);
mGlyphCodeFonts.AppendElement(FontFamilyName(aPrimaryFontName, eUnquotedName));
mGlyphCodeFonts.AppendElement(FontFamilyName(aPrimaryFontName,
eUnquotedName));
}
~nsPropertiesTable()
@ -286,13 +287,13 @@ nsPropertiesTable::ElementAt(DrawTarget* /* aDrawTarget */,
if (mState == NS_TABLE_STATE_ERROR) return kNullGlyph;
// Load glyph properties if this is the first time we have been here
if (mState == NS_TABLE_STATE_EMPTY) {
nsAutoString primaryFontName;
nsAutoCString primaryFontName;
mGlyphCodeFonts[0].AppendToString(primaryFontName);
nsresult rv = LoadProperties(primaryFontName, mGlyphProperties);
#ifdef DEBUG
nsAutoCString uriStr;
uriStr.AssignLiteral("resource://gre/res/fonts/mathfont");
LossyAppendUTF16toASCII(primaryFontName, uriStr);
uriStr.Append(primaryFontName);
uriStr.StripWhitespace(); // that may come from mGlyphCodeFonts
uriStr.AppendLiteral(".properties");
printf("Loading %s ... %s\n",
@ -314,7 +315,8 @@ nsPropertiesTable::ElementAt(DrawTarget* /* aDrawTarget */,
rv = mGlyphProperties->GetStringProperty(key, value);
if (NS_FAILED(rv)) break;
Clean(value);
mGlyphCodeFonts.AppendElement(FontFamilyName(value, eUnquotedName)); // i.e., mGlyphCodeFonts[i] holds this font name
mGlyphCodeFonts.AppendElement(FontFamilyName(NS_ConvertUTF16toUTF8(value),
eUnquotedName)); // i.e., mGlyphCodeFonts[i] holds this font name
}
}
@ -366,7 +368,7 @@ nsPropertiesTable::ElementAt(DrawTarget* /* aDrawTarget */,
return kNullGlyph;
}
// The char cannot be handled if this font is not installed
if (!mGlyphCodeFonts[font].mName.Length()) {
if (!mGlyphCodeFonts[font].mName) {
return kNullGlyph;
}
}
@ -613,7 +615,7 @@ public:
nsPropertiesTable mUnicodeTable;
nsGlyphTableList()
: mUnicodeTable(NS_LITERAL_STRING("Unicode"))
: mUnicodeTable(NS_LITERAL_CSTRING("Unicode"))
{
}
@ -622,11 +624,11 @@ public:
// Add a glyph table in the list, return the new table that was added
nsGlyphTable*
AddGlyphTable(const nsString& aPrimaryFontName);
AddGlyphTable(const nsACString& aPrimaryFontName);
// Find the glyph table in the list corresponding to the given font family.
nsGlyphTable*
GetGlyphTableFor(const nsAString& aFamily);
GetGlyphTableFor(const nsACString& aFamily);
private:
~nsGlyphTableList()
@ -694,7 +696,7 @@ nsGlyphTableList::Finalize()
}
nsGlyphTable*
nsGlyphTableList::AddGlyphTable(const nsString& aPrimaryFontName)
nsGlyphTableList::AddGlyphTable(const nsACString& aPrimaryFontName)
{
// See if there is already a special table for this family.
nsGlyphTable* glyphTable = GetGlyphTableFor(aPrimaryFontName);
@ -707,15 +709,15 @@ nsGlyphTableList::AddGlyphTable(const nsString& aPrimaryFontName)
}
nsGlyphTable*
nsGlyphTableList::GetGlyphTableFor(const nsAString& aFamily)
nsGlyphTableList::GetGlyphTableFor(const nsACString& aFamily)
{
for (int32_t i = 0; i < PropertiesTableCount(); i++) {
nsPropertiesTable* glyphTable = PropertiesTableAt(i);
const FontFamilyName& primaryFontName = glyphTable->PrimaryFontName();
nsAutoString primaryFontNameStr;
nsAutoCString primaryFontNameStr;
primaryFontName.AppendToString(primaryFontNameStr);
// TODO: would be nice to consider StripWhitespace and other aliasing
if (primaryFontNameStr.Equals(aFamily, nsCaseInsensitiveStringComparator())) {
if (primaryFontNameStr.Equals(aFamily, nsCaseInsensitiveCStringComparator())) {
return glyphTable;
}
}
@ -744,7 +746,7 @@ InitCharGlobals()
// observer and will be deleted at shutdown. We now add some private
// per font-family tables for stretchy operators, in order of preference.
// Do not include the Unicode table in this list.
if (!glyphTableList->AddGlyphTable(NS_LITERAL_STRING("STIXGeneral"))) {
if (!glyphTableList->AddGlyphTable(NS_LITERAL_CSTRING("STIXGeneral"))) {
rv = NS_ERROR_OUT_OF_MEMORY;
}
@ -1445,7 +1447,7 @@ nsMathMLChar::StretchEnumContext::EnumCallback(const FontFamilyName& aFamily,
} else {
// Otherwise try to find a .properties file corresponding to that font
// family or fallback to the Unicode table.
nsAutoString familyName;
nsAutoCString familyName;
unquotedFamilyName.AppendToString(familyName);
glyphTable = gGlyphTableList->GetGlyphTableFor(familyName);
}
@ -1477,10 +1479,11 @@ nsMathMLChar::StretchEnumContext::EnumCallback(const FontFamilyName& aFamily,
static void
AppendFallbacks(nsTArray<FontFamilyName>& aNames,
const nsTArray<nsString>& aFallbacks)
const nsTArray<nsCString>& aFallbacks)
{
for (const nsString& fallback : aFallbacks) {
aNames.AppendElement(FontFamilyName(fallback, eUnquotedName));
for (const nsCString& fallback : aFallbacks) {
aNames.AppendElement(FontFamilyName(fallback,
eUnquotedName));
}
}
@ -1488,7 +1491,7 @@ AppendFallbacks(nsTArray<FontFamilyName>& aNames,
// when no generic present
static void
InsertMathFallbacks(FontFamilyList& aFamilyList,
nsTArray<nsString>& aFallbacks)
nsTArray<nsCString>& aFallbacks)
{
nsTArray<FontFamilyName> mergedList;
@ -1649,7 +1652,7 @@ nsMathMLChar::StretchInternal(nsIFrame* aForFrame,
// really shouldn't be doing things this way but for now
// insert fallbacks into the list
AutoTArray<nsString, 16> mathFallbacks;
AutoTArray<nsCString, 16> mathFallbacks;
gfxFontUtils::GetPrefsFontList("font.name.serif.x-math", mathFallbacks);
gfxFontUtils::AppendPrefsFontList("font.name-list.serif.x-math",
mathFallbacks);

Просмотреть файл

@ -295,8 +295,12 @@ FontFaceSet::FindMatchingFontFaces(const nsAString& aFont,
nsTHashtable<nsPtrHashKey<FontFace>> matchingFaces;
for (const FontFamilyName& fontFamilyName : familyList->mNames) {
if (!fontFamilyName.IsNamed()) {
continue;
}
RefPtr<gfxFontFamily> family =
mUserFontSet->LookupFamily(NS_ConvertUTF16toUTF8(fontFamilyName.mName));
mUserFontSet->LookupFamily(nsAtomCString(fontFamilyName.mName));
if (!family) {
continue;

Просмотреть файл

@ -1141,13 +1141,7 @@ Gecko_nsTArray_FontFamilyName_AppendNamed(nsTArray<FontFamilyName>* aNames,
nsAtom* aName,
bool aQuoted)
{
FontFamilyName family;
aName->ToString(family.mName);
if (aQuoted) {
family.mType = eFamily_named_quoted;
}
aNames->AppendElement(family);
aNames->AppendElement(FontFamilyName(aName, aQuoted ? eQuotedName : eUnquotedName));
}
void

Просмотреть файл

@ -31,8 +31,7 @@ ComputedStyleContainsFont(ComputedStyle* aComputedStyle,
}
// first, check if the family name is in the fontlist
NS_ConvertUTF8toUTF16 familyName(aFont->FamilyName());
if (!aComputedStyle->StyleFont()->mFont.fontlist.Contains(familyName)) {
if (!aComputedStyle->StyleFont()->mFont.fontlist.Contains(aFont->FamilyName())) {
return false;
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -483,16 +483,19 @@ impl SingleFontFamily {
FontFamilyType::eFamily_fantasy => SingleFontFamily::Generic(atom!("fantasy")),
FontFamilyType::eFamily_moz_fixed => SingleFontFamily::Generic(atom!("-moz-fixed")),
FontFamilyType::eFamily_named => {
let name = Atom::from(&*family.mName);
let name = unsafe { Atom::from_raw(family.mName.mRawPtr) };
SingleFontFamily::FamilyName(FamilyName {
name,
syntax: FamilyNameSyntax::Identifiers,
})
},
FontFamilyType::eFamily_named_quoted => SingleFontFamily::FamilyName(FamilyName {
name: (&*family.mName).into(),
FontFamilyType::eFamily_named_quoted => {
let name = unsafe { Atom::from_raw(family.mName.mRawPtr) };
SingleFontFamily::FamilyName(FamilyName {
name,
syntax: FamilyNameSyntax::Quoted,
}),
})
},
_ => panic!("Found unexpected font FontFamilyType"),
}
}
@ -538,9 +541,15 @@ impl Hash for FontFamilyList {
where
H: Hasher,
{
use string_cache::WeakAtom;
for name in self.0.mNames.iter() {
name.mType.hash(state);
name.mName.hash(state);
if !name.mName.mRawPtr.is_null() {
unsafe {
WeakAtom::new(name.mName.mRawPtr).hash(state);
}
}
}
}
}
@ -552,7 +561,7 @@ impl PartialEq for FontFamilyList {
return false;
}
for (a, b) in self.0.mNames.iter().zip(other.0.mNames.iter()) {
if a.mType != b.mType || &*a.mName != &*b.mName {
if a.mType != b.mType || a.mName.mRawPtr != b.mName.mRawPtr {
return false;
}
}

Просмотреть файл

@ -26,4 +26,6 @@ Error and stacktrace produced by client.
<!--
See https://searchfox.org/mozilla-central/source/testing/geckodriver/doc/TraceLogs.md
for how to produce a trace-level log.
For trace logs with more than 20 lines please add its contents as attachment.
-->