Bug 1729642 - patch 1 - Make shutdown of nsLanguageAtomService explicit instead of relying on ClearOnShutdown. r=platform-i18n-reviewers,dminor

Differential Revision: https://phabricator.services.mozilla.com/D125587
This commit is contained in:
Jonathan Kew 2021-09-14 18:51:49 +00:00
parent 005ecf476c
commit da9c992100
3 changed files with 9 additions and 2 deletions

View File

@ -80,16 +80,19 @@ static constexpr struct {
{"Thai", nsGkAtoms::th},
{"Tibt", nsGkAtoms::x_tibt}};
static UniquePtr<nsLanguageAtomService> gLangAtomService;
// static
nsLanguageAtomService* nsLanguageAtomService::GetService() {
static UniquePtr<nsLanguageAtomService> gLangAtomService;
if (!gLangAtomService) {
gLangAtomService = MakeUnique<nsLanguageAtomService>();
ClearOnShutdown(&gLangAtomService);
}
return gLangAtomService.get();
}
// static
void nsLanguageAtomService::Shutdown() { gLangAtomService = nullptr; }
nsStaticAtom* nsLanguageAtomService::LookupLanguage(
const nsACString& aLanguage) {
nsAutoCString lowered(aLanguage);

View File

@ -28,6 +28,8 @@ class nsLanguageAtomService final {
public:
static nsLanguageAtomService* GetService();
static void Shutdown();
nsStaticAtom* LookupLanguage(const nsACString& aLanguage);
already_AddRefed<nsAtom> LookupCharSet(NotNull<const Encoding*> aCharSet);
nsAtom* GetLocaleLanguage();

View File

@ -51,6 +51,7 @@
#include "mozilla/dom/HTMLDNSPrefetch.h"
#include "mozilla/dom/HTMLInputElement.h"
#include "mozilla/dom/SVGElementFactory.h"
#include "nsLanguageAtomService.h"
#include "nsMathMLAtoms.h"
#include "nsMathMLOperators.h"
#include "Navigator.h"
@ -319,6 +320,7 @@ void nsLayoutStatics::Shutdown() {
HTMLDNSPrefetch::Shutdown();
nsCSSRendering::Shutdown();
StaticPresData::Shutdown();
nsLanguageAtomService::Shutdown();
#ifdef DEBUG
nsIFrame::DisplayReflowShutdown();
#endif