mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-20 08:51:04 +00:00
Bug 1418724 - part 2 - Force reflow of all content when locale prefs change, so that we can pick up modifications to the preferred ordering of CJK fonts without requiring restart or page reload. r=m_kato
This commit is contained in:
parent
6ac9fda68b
commit
09faef79f5
@ -129,16 +129,22 @@ static gfxFontListPrefObserver* gFontListPrefObserver = nullptr;
|
||||
|
||||
NS_IMPL_ISUPPORTS(gfxFontListPrefObserver, nsIObserver)
|
||||
|
||||
#define LOCALES_CHANGED_TOPIC "intl:system-locales-changed"
|
||||
|
||||
NS_IMETHODIMP
|
||||
gfxFontListPrefObserver::Observe(nsISupports *aSubject,
|
||||
const char *aTopic,
|
||||
const char16_t *aData)
|
||||
{
|
||||
NS_ASSERTION(!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID), "invalid topic");
|
||||
NS_ASSERTION(!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) ||
|
||||
!strcmp(aTopic, LOCALES_CHANGED_TOPIC), "invalid topic");
|
||||
// XXX this could be made to only clear out the cache for the prefs that were changed
|
||||
// but it probably isn't that big a deal.
|
||||
gfxPlatformFontList::PlatformFontList()->ClearLangGroupPrefFonts();
|
||||
gfxFontCache::GetCache()->AgeAllGenerations();
|
||||
if (XRE_IsParentProcess() && !strcmp(aTopic, LOCALES_CHANGED_TOPIC)) {
|
||||
gfxPlatform::ForceGlobalReflow();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -202,6 +208,11 @@ gfxPlatformFontList::gfxPlatformFontList(bool aNeedFullnamePostscriptNames)
|
||||
NS_ADDREF(gFontListPrefObserver);
|
||||
Preferences::AddStrongObservers(gFontListPrefObserver, kObservedPrefs);
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
||||
if (obs) {
|
||||
obs->AddObserver(gFontListPrefObserver, LOCALES_CHANGED_TOPIC, false);
|
||||
}
|
||||
|
||||
// Only the parent process listens for whitelist changes; it will then
|
||||
// notify its children to rebuild their font lists.
|
||||
if (XRE_IsParentProcess()) {
|
||||
@ -218,6 +229,12 @@ gfxPlatformFontList::~gfxPlatformFontList()
|
||||
ClearLangGroupPrefFonts();
|
||||
NS_ASSERTION(gFontListPrefObserver, "There is no font list pref observer");
|
||||
Preferences::RemoveObservers(gFontListPrefObserver, kObservedPrefs);
|
||||
|
||||
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
||||
if (obs) {
|
||||
obs->RemoveObserver(gFontListPrefObserver, LOCALES_CHANGED_TOPIC);
|
||||
}
|
||||
|
||||
if (XRE_IsParentProcess()) {
|
||||
Preferences::UnregisterCallback(FontWhitelistPrefChanged,
|
||||
kFontSystemWhitelistPref);
|
||||
@ -1655,6 +1672,7 @@ gfxPlatformFontList::ClearLangGroupPrefFonts()
|
||||
prefFontsLangGroup[j] = nullptr;
|
||||
}
|
||||
}
|
||||
mCJKPrefLangs.Clear();
|
||||
}
|
||||
|
||||
// Support for memory reporting
|
||||
|
@ -406,6 +406,9 @@ nsPresContext::Destroy()
|
||||
Preferences::UnregisterCallback(nsPresContext::PrefChangedCallback,
|
||||
kUseStandinsForNativeColors,
|
||||
this);
|
||||
Preferences::UnregisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"intl.accept_languages",
|
||||
this);
|
||||
|
||||
mRefreshDriver = nullptr;
|
||||
}
|
||||
@ -773,7 +776,8 @@ nsPresContext::PreferenceChanged(const char* aPrefName)
|
||||
mMissingFonts = nullptr;
|
||||
}
|
||||
}
|
||||
if (StringBeginsWith(prefName, NS_LITERAL_CSTRING("font."))) {
|
||||
if (StringBeginsWith(prefName, NS_LITERAL_CSTRING("font.")) ||
|
||||
prefName.EqualsLiteral("intl.accept_languages")) {
|
||||
// Changes to font family preferences don't change anything in the
|
||||
// computed style data, so the style system won't generate a reflow
|
||||
// hint for us. We need to do that manually.
|
||||
@ -976,6 +980,9 @@ nsPresContext::Init(nsDeviceContext* aDeviceContext)
|
||||
Preferences::RegisterCallback(nsPresContext::PrefChangedCallback,
|
||||
kUseStandinsForNativeColors,
|
||||
this);
|
||||
Preferences::RegisterCallback(nsPresContext::PrefChangedCallback,
|
||||
"intl.accept_languages",
|
||||
this);
|
||||
|
||||
nsresult rv = mEventManager->Init();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
Loading…
x
Reference in New Issue
Block a user