зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1620111 - Eliminate sync-IPC message ReadFontList, instead use SetXPCOMProcessAttributes to pass font list to the child process on Android. r=lsalzman,froydnj
Differential Revision: https://phabricator.services.mozilla.com/D65742 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
c1fc16a11b
Коммит
3df4ab8b5e
|
@ -2783,14 +2783,6 @@ void ContentParent::OnVarChanged(const GfxVarUpdate& aVar) {
|
|||
Unused << SendVarUpdate(aVar);
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvReadFontList(
|
||||
nsTArray<FontListEntry>* retValue) {
|
||||
#ifdef ANDROID
|
||||
gfxAndroidPlatform::GetPlatform()->GetSystemFontList(retValue);
|
||||
#endif
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvSetClipboard(
|
||||
const IPCDataTransfer& aDataTransfer, const bool& aIsPrivateData,
|
||||
const IPC::Principal& aRequestingPrincipal,
|
||||
|
|
|
@ -982,8 +982,6 @@ class ContentParent final
|
|||
|
||||
mozilla::ipc::IPCResult RecvGetGfxVars(nsTArray<GfxVarUpdate>* aVars);
|
||||
|
||||
mozilla::ipc::IPCResult RecvReadFontList(nsTArray<FontListEntry>* retValue);
|
||||
|
||||
mozilla::ipc::IPCResult RecvSetClipboard(
|
||||
const IPCDataTransfer& aDataTransfer, const bool& aIsPrivateData,
|
||||
const IPC::Principal& aRequestingPrincipal,
|
||||
|
|
|
@ -134,9 +134,13 @@ union ChromeRegistryItem
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
// SetXPCOMProcessAttributes passes an array of font data to the child,
|
||||
// but each platform needs different details so we have platform-specific
|
||||
// versions of the SystemFontListEntry type:
|
||||
#if defined(ANDROID)
|
||||
// Used on Android/B2G to pass the list of fonts on the device
|
||||
// to the child process
|
||||
struct FontListEntry {
|
||||
struct SystemFontListEntry {
|
||||
nsCString familyName;
|
||||
nsCString faceName;
|
||||
nsCString filepath;
|
||||
|
@ -145,28 +149,23 @@ struct FontListEntry {
|
|||
uint32_t styleRange;
|
||||
uint8_t index;
|
||||
};
|
||||
|
||||
#elif defined(XP_MACOSX)
|
||||
// Used on Mac OS X to pass the list of font families (not faces)
|
||||
// from chrome to content processes.
|
||||
// The entryType field distinguishes several types of font family
|
||||
// record; see gfxMacPlatformFontList.h for values and meaning.
|
||||
struct FontFamilyListEntry {
|
||||
struct SystemFontListEntry {
|
||||
nsCString familyName;
|
||||
uint8_t entryType;
|
||||
};
|
||||
|
||||
#else
|
||||
// Used on Linux to pass list of font patterns from chrome to content.
|
||||
struct FontPatternListEntry {
|
||||
// (Unused on Windows, but there needs to be a definition of the type.)
|
||||
struct SystemFontListEntry {
|
||||
nsCString pattern;
|
||||
bool appFontFamily;
|
||||
};
|
||||
|
||||
// Wrap the Font*ListEntry records in a union so the SetXPCOMProcessAttributes
|
||||
// message can pass an array of either type.
|
||||
union SystemFontListEntry {
|
||||
FontFamilyListEntry;
|
||||
FontPatternListEntry;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct DataStorageItem {
|
||||
nsCString key;
|
||||
|
@ -629,7 +628,7 @@ child:
|
|||
async SetXPCOMProcessAttributes(XPCOMInitData xpcomInit,
|
||||
StructuredCloneData initialData,
|
||||
LookAndFeelInt[] lookAndFeelIntCache,
|
||||
/* used on MacOSX and Linux only: */
|
||||
/* used on MacOSX/Linux/Android only: */
|
||||
SystemFontListEntry[] systemFontList,
|
||||
SharedMemoryHandle? sharedUASheetHandle,
|
||||
uintptr_t sharedUASheetAddress);
|
||||
|
@ -966,8 +965,6 @@ parent:
|
|||
// PrefService message
|
||||
sync GetGfxVars() returns (GfxVarUpdate[] vars);
|
||||
|
||||
sync ReadFontList() returns (FontListEntry[] retValue);
|
||||
|
||||
sync SyncMessage(nsString aMessage, ClonedMessageData aData,
|
||||
CpowEntry[] aCpows, Principal aPrincipal)
|
||||
returns (StructuredCloneData[] retval);
|
||||
|
|
|
@ -224,10 +224,6 @@ void gfxAndroidPlatform::GetCommonFallbackFonts(
|
|||
aFontList.AppendElement("Droid Sans Fallback");
|
||||
}
|
||||
|
||||
void gfxAndroidPlatform::GetSystemFontList(nsTArray<FontListEntry>* retValue) {
|
||||
gfxFT2FontList::PlatformFontList()->GetSystemFontList(retValue);
|
||||
}
|
||||
|
||||
gfxPlatformFontList* gfxAndroidPlatform::CreatePlatformFontList() {
|
||||
gfxPlatformFontList* list = new gfxFT2FontList();
|
||||
if (NS_SUCCEEDED(list->InitFontList())) {
|
||||
|
@ -237,6 +233,11 @@ gfxPlatformFontList* gfxAndroidPlatform::CreatePlatformFontList() {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
void gfxAndroidPlatform::ReadSystemFontList(
|
||||
nsTArray<SystemFontListEntry>* aFontList) {
|
||||
gfxFT2FontList::PlatformFontList()->ReadSystemFontList(aFontList);
|
||||
}
|
||||
|
||||
gfxFontGroup* gfxAndroidPlatform::CreateFontGroup(
|
||||
const FontFamilyList& aFontFamilyList, const gfxFontStyle* aStyle,
|
||||
gfxTextPerfMetrics* aTextPerf, gfxUserFontSet* aUserFontSet,
|
||||
|
|
|
@ -32,12 +32,12 @@ class gfxAndroidPlatform : public gfxPlatform {
|
|||
|
||||
gfxImageFormat GetOffscreenFormat() override { return mOffscreenFormat; }
|
||||
|
||||
// to support IPC font list (sharing between chrome and content)
|
||||
void GetSystemFontList(nsTArray<FontListEntry>* retValue);
|
||||
|
||||
// platform implementations of font functions
|
||||
gfxPlatformFontList* CreatePlatformFontList() override;
|
||||
|
||||
void ReadSystemFontList(
|
||||
nsTArray<mozilla::dom::SystemFontListEntry>* aFontList) override;
|
||||
|
||||
void GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh, Script aRunScript,
|
||||
nsTArray<const char*>& aFontList) override;
|
||||
|
||||
|
|
|
@ -1492,10 +1492,10 @@ void gfxFT2FontList::AppendFaceFromFontListEntry(const FontListEntry& aFLE,
|
|||
}
|
||||
}
|
||||
|
||||
void gfxFT2FontList::GetSystemFontList(nsTArray<FontListEntry>* retValue) {
|
||||
void gfxFT2FontList::ReadSystemFontList(nsTArray<FontListEntry>* aList) {
|
||||
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
|
||||
auto family = static_cast<FT2FontFamily*>(iter.Data().get());
|
||||
family->AddFacesToFontList(retValue);
|
||||
family->AddFacesToFontList(aList);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1530,14 +1530,15 @@ nsresult gfxFT2FontList::InitFontListForPlatform() {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// Content process: ask the Chrome process to give us the list
|
||||
nsTArray<FontListEntry> fonts;
|
||||
mozilla::dom::ContentChild::GetSingleton()->SendReadFontList(&fonts); // sync
|
||||
for (uint32_t i = 0, n = fonts.Length(); i < n; ++i) {
|
||||
// Content process: use font list passed from the chrome process via
|
||||
// the GetXPCOMProcessAttributes message.
|
||||
auto& fontList = dom::ContentChild::GetSingleton()->SystemFontList();
|
||||
for (FontListEntry& fle : fontList) {
|
||||
// We don't need to identify "standard" font files here,
|
||||
// as the faces are already sorted.
|
||||
AppendFaceFromFontListEntry(fonts[i], kUnknown);
|
||||
AppendFaceFromFontListEntry(fle, kUnknown);
|
||||
}
|
||||
|
||||
// We don't need to sort faces (because they were already sorted by the
|
||||
// chrome process, so we just maintain the existing order)
|
||||
for (auto iter = mFontFamilies.Iter(); !iter.Done(); iter.Next()) {
|
||||
|
@ -1548,7 +1549,9 @@ nsresult gfxFT2FontList::InitFontListForPlatform() {
|
|||
|
||||
LOG(("got font list from chrome process: %" PRIdPTR " faces in %" PRIu32
|
||||
" families",
|
||||
fonts.Length(), mFontFamilies.Count()));
|
||||
fontList.Length(), mFontFamilies.Count()));
|
||||
fontList.Clear();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,10 +12,9 @@
|
|||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class FontListEntry;
|
||||
class SystemFontListEntry;
|
||||
};
|
||||
}; // namespace mozilla
|
||||
using mozilla::dom::FontListEntry;
|
||||
|
||||
class FontNameCache;
|
||||
typedef struct FT_FaceRec_* FT_Face;
|
||||
|
@ -24,6 +23,8 @@ class WillShutdownObserver;
|
|||
class FTUserFontData;
|
||||
|
||||
class FT2FontEntry : public gfxFT2FontEntryBase {
|
||||
using FontListEntry = mozilla::dom::SystemFontListEntry;
|
||||
|
||||
public:
|
||||
explicit FT2FontEntry(const nsACString& aFaceName)
|
||||
: gfxFT2FontEntryBase(aFaceName), mFTFontIndex(0) {}
|
||||
|
@ -107,6 +108,8 @@ class FT2FontEntry : public gfxFT2FontEntryBase {
|
|||
};
|
||||
|
||||
class FT2FontFamily : public gfxFontFamily {
|
||||
using FontListEntry = mozilla::dom::SystemFontListEntry;
|
||||
|
||||
public:
|
||||
explicit FT2FontFamily(const nsACString& aName) : gfxFontFamily(aName) {}
|
||||
|
||||
|
@ -115,6 +118,8 @@ class FT2FontFamily : public gfxFontFamily {
|
|||
};
|
||||
|
||||
class gfxFT2FontList : public gfxPlatformFontList {
|
||||
using FontListEntry = mozilla::dom::SystemFontListEntry;
|
||||
|
||||
public:
|
||||
gfxFT2FontList();
|
||||
virtual ~gfxFT2FontList();
|
||||
|
@ -137,7 +142,7 @@ class gfxFT2FontList : public gfxPlatformFontList {
|
|||
|
||||
void WriteCache();
|
||||
|
||||
void GetSystemFontList(nsTArray<FontListEntry>* retValue);
|
||||
void ReadSystemFontList(nsTArray<FontListEntry>* aList);
|
||||
|
||||
static gfxFT2FontList* PlatformFontList() {
|
||||
return static_cast<gfxFT2FontList*>(
|
||||
|
|
|
@ -53,9 +53,6 @@ using namespace mozilla;
|
|||
using namespace mozilla::gfx;
|
||||
using namespace mozilla::unicode;
|
||||
|
||||
using mozilla::dom::FontPatternListEntry;
|
||||
using mozilla::dom::SystemFontListEntry;
|
||||
|
||||
#ifndef FC_POSTSCRIPT_NAME
|
||||
# define FC_POSTSCRIPT_NAME "postscriptname" /* String */
|
||||
#endif
|
||||
|
@ -1447,10 +1444,7 @@ nsresult gfxFcPlatformFontList::InitFontListForPlatform() {
|
|||
int fcVersion = FcGetVersion();
|
||||
bool fcCharsetParseBug = fcVersion >= 21094 && fcVersion <= 21101;
|
||||
|
||||
for (SystemFontListEntry& fle : fontList) {
|
||||
MOZ_ASSERT(fle.type() ==
|
||||
SystemFontListEntry::Type::TFontPatternListEntry);
|
||||
FontPatternListEntry& fpe(fle);
|
||||
for (FontPatternListEntry& fpe : fontList) {
|
||||
nsCString& patternStr = fpe.pattern();
|
||||
if (fcCharsetParseBug) {
|
||||
int32_t index = patternStr.Find(":charset= ");
|
||||
|
@ -1501,7 +1495,7 @@ nsresult gfxFcPlatformFontList::InitFontListForPlatform() {
|
|||
}
|
||||
|
||||
void gfxFcPlatformFontList::ReadSystemFontList(
|
||||
nsTArray<SystemFontListEntry>* retValue) {
|
||||
nsTArray<FontPatternListEntry>* retValue) {
|
||||
// Fontconfig versions below 2.9 drop the FC_FILE element in FcNameUnparse
|
||||
// (see https://bugs.freedesktop.org/show_bug.cgi?id=26718), so when using
|
||||
// an older version, we manually append it to the unparsed pattern.
|
||||
|
|
|
@ -213,6 +213,8 @@ class gfxFontconfigFont : public gfxFT2FontBase {
|
|||
};
|
||||
|
||||
class gfxFcPlatformFontList : public gfxPlatformFontList {
|
||||
using FontPatternListEntry = mozilla::dom::SystemFontListEntry;
|
||||
|
||||
public:
|
||||
gfxFcPlatformFontList();
|
||||
|
||||
|
@ -227,8 +229,7 @@ class gfxFcPlatformFontList : public gfxPlatformFontList {
|
|||
void GetFontList(nsAtom* aLangGroup, const nsACString& aGenericFamily,
|
||||
nsTArray<nsString>& aListOfFonts) override;
|
||||
|
||||
void ReadSystemFontList(
|
||||
nsTArray<mozilla::dom::SystemFontListEntry>* retValue);
|
||||
void ReadSystemFontList(nsTArray<FontPatternListEntry>* retValue);
|
||||
|
||||
gfxFontEntry* CreateFontEntry(
|
||||
mozilla::fontlist::Face* aFace,
|
||||
|
|
|
@ -105,6 +105,8 @@ class MacOSFontEntry : public gfxFontEntry {
|
|||
};
|
||||
|
||||
class gfxMacPlatformFontList : public gfxPlatformFontList {
|
||||
using FontFamilyListEntry = mozilla::dom::SystemFontListEntry;
|
||||
|
||||
public:
|
||||
static gfxMacPlatformFontList* PlatformFontList() {
|
||||
return static_cast<gfxMacPlatformFontList*>(sPlatformFontList);
|
||||
|
@ -146,7 +148,7 @@ class gfxMacPlatformFontList : public gfxPlatformFontList {
|
|||
kTextSizeSystemFontFamily = 2, // name of 'system' font at text sizes
|
||||
kDisplaySizeSystemFontFamily = 3 // 'system' font at display sizes
|
||||
};
|
||||
void ReadSystemFontList(nsTArray<mozilla::dom::SystemFontListEntry>* aList);
|
||||
void ReadSystemFontList(nsTArray<FontFamilyListEntry>* aList);
|
||||
|
||||
protected:
|
||||
FontFamily GetDefaultFontForPlatform(const gfxFontStyle* aStyle) override;
|
||||
|
|
|
@ -79,8 +79,6 @@
|
|||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::gfx;
|
||||
using mozilla::dom::SystemFontListEntry;
|
||||
using mozilla::dom::FontFamilyListEntry;
|
||||
|
||||
// indexes into the NSArray objects that the Cocoa font manager returns
|
||||
// as the available members of a family
|
||||
|
@ -875,7 +873,7 @@ void gfxMacPlatformFontList::AddFamily(CFStringRef aFamily) {
|
|||
AddFamily(NS_ConvertUTF16toUTF8(familyName), isHiddenSystemFont);
|
||||
}
|
||||
|
||||
void gfxMacPlatformFontList::ReadSystemFontList(nsTArray<SystemFontListEntry>* aList) {
|
||||
void gfxMacPlatformFontList::ReadSystemFontList(nsTArray<FontFamilyListEntry>* aList) {
|
||||
// Note: We rely on the records for mSystemTextFontFamilyName and
|
||||
// mSystemDisplayFontFamilyName (if present) being *before* the main
|
||||
// font list, so that those names are known in the content process
|
||||
|
@ -912,9 +910,7 @@ nsresult gfxMacPlatformFontList::InitFontListForPlatform() {
|
|||
// the GetXPCOMProcessAttributes message, because it's much faster than
|
||||
// querying Core Text again in the child.
|
||||
auto& fontList = dom::ContentChild::GetSingleton()->SystemFontList();
|
||||
for (SystemFontListEntry& fle : fontList) {
|
||||
MOZ_ASSERT(fle.type() == SystemFontListEntry::Type::TFontFamilyListEntry);
|
||||
FontFamilyListEntry& ffe(fle);
|
||||
for (FontFamilyListEntry& ffe : fontList) {
|
||||
switch (ffe.entryType()) {
|
||||
case kStandardFontFamily:
|
||||
AddFamily(ffe.familyName(), false);
|
||||
|
|
|
@ -987,8 +987,6 @@ description = legacy sync IPC - please add detailed description
|
|||
description = legacy sync IPC - please add detailed description
|
||||
[PContent::GetGfxVars]
|
||||
description = legacy sync IPC - please add detailed description
|
||||
[PContent::ReadFontList]
|
||||
description = legacy sync IPC - please add detailed description
|
||||
[PContent::GetClipboard]
|
||||
description = Legacy synchronous clipboard API
|
||||
[PContent::ClipboardHasType]
|
||||
|
|
Загрузка…
Ссылка в новой задаче