Bug 1730456 - InitPlatformFontList should reframe. r=jfkthame

I don't know why it didn't broadcast the reflow request to child
processes... Perhaps it doesn't have to?

Differential Revision: https://phabricator.services.mozilla.com/D126128
This commit is contained in:
Emilio Cobos Álvarez 2021-09-23 16:35:32 +00:00
Родитель b3c27b86d4
Коммит e37caecb95
3 изменённых файлов: 22 добавлений и 19 удалений

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

@ -2215,7 +2215,8 @@ void gfxPlatform::FlushFontAndWordCaches() {
}
/* static */
void gfxPlatform::ForceGlobalReflow(NeedsReframe aNeedsReframe) {
void gfxPlatform::ForceGlobalReflow(NeedsReframe aNeedsReframe,
BroadcastToChildren aBroadcastToChildren) {
MOZ_ASSERT(NS_IsMainThread());
const bool reframe = aNeedsReframe == NeedsReframe::Yes;
// Send a notification that will be observed by PresShells in this process
@ -2224,7 +2225,8 @@ void gfxPlatform::ForceGlobalReflow(NeedsReframe aNeedsReframe) {
char16_t needsReframe[] = {char16_t(reframe), 0};
obs->NotifyObservers(nullptr, "font-info-updated", needsReframe);
}
if (XRE_IsParentProcess()) {
if (XRE_IsParentProcess() &&
aBroadcastToChildren == BroadcastToChildren::Yes) {
// Propagate the change to child processes.
for (auto* process :
dom::ContentParent::AllProcesses(dom::ContentParent::eLive)) {

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

@ -607,13 +607,19 @@ class gfxPlatform : public mozilla::layers::MemoryPressureListener {
int32_t GetBidiNumeralOption();
/**
* This is a bit ugly, but useful... force all presContexts to reflow,
* by toggling a preference that they observe. This is used when
* something about platform settings changes that might have an effect
* on layout, such as font rendering settings that influence metrics.
* Force all presContexts to reflow (and reframe if needed).
*
* This is used when something about platform settings changes that might have
* an effect on layout, such as font rendering settings that influence
* metrics, or installed fonts.
*
* By default it also broadcast it to child processes, but some callers might
* not need it if they implement their own notification.
*/
enum class NeedsReframe : bool { No, Yes };
static void ForceGlobalReflow(NeedsReframe);
enum class BroadcastToChildren : bool { No, Yes };
static void ForceGlobalReflow(NeedsReframe,
BroadcastToChildren = BroadcastToChildren::Yes);
static void FlushFontAndWordCaches();

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

@ -471,22 +471,17 @@ bool gfxPlatformFontList::InitFontList() {
gfxPlatform::PurgeSkiaFontCache();
// There's no need to broadcast this reflow request to child processes, as
// ContentParent::NotifyUpdatedFonts deals with it by re-entering into this
// function on child processes.
if (NS_IsMainThread()) {
nsCOMPtr<nsIObserverService> obs =
mozilla::services::GetObserverService();
if (obs) {
// Notify any current presContexts that fonts are being updated, so
// existing caches will no longer be valid.
obs->NotifyObservers(nullptr, "font-info-updated", nullptr);
}
gfxPlatform::ForceGlobalReflow(gfxPlatform::NeedsReframe::Yes,
gfxPlatform::BroadcastToChildren::No);
} else {
NS_DispatchToMainThread(
NS_NewRunnableFunction("font-info-updated notification callback", [] {
nsCOMPtr<nsIObserverService> obs =
mozilla::services::GetObserverService();
if (obs) {
obs->NotifyObservers(nullptr, "font-info-updated", nullptr);
}
gfxPlatform::ForceGlobalReflow(gfxPlatform::NeedsReframe::Yes,
gfxPlatform::BroadcastToChildren::No);
}));
}