diff --git a/gfx/src/nsThebesGfxFactory.cpp b/gfx/src/nsThebesGfxFactory.cpp index 13720f9a5cd4..8cfadc297059 100644 --- a/gfx/src/nsThebesGfxFactory.cpp +++ b/gfx/src/nsThebesGfxFactory.cpp @@ -18,20 +18,6 @@ #include "nsScriptableRegion.h" // for nsScriptableRegion #include "nsThebesFontEnumerator.h" // for nsThebesFontEnumerator -// This class doesn't do anything; its only purpose is to give -// gfxPlatform::Init a way to force this component to be registered, -// so that gfxPlatform::Shutdown will be called at an appropriate -// time. (Component teardown is the only shutdown hook that runs -// late enough; see bug 651498.) - -namespace { -class GfxInitialization MOZ_FINAL : public nsISupports { - NS_DECL_ISUPPORTS -}; - -NS_IMPL_ISUPPORTS0(GfxInitialization) -} - NS_GENERIC_FACTORY_CONSTRUCTOR(nsThebesFontEnumerator) static nsresult @@ -49,32 +35,21 @@ nsScriptableRegionConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult return scriptableRgn->QueryInterface(aIID, aResult); } -NS_GENERIC_FACTORY_CONSTRUCTOR(GfxInitialization) - NS_DEFINE_NAMED_CID(NS_FONT_ENUMERATOR_CID); NS_DEFINE_NAMED_CID(NS_SCRIPTABLE_REGION_CID); -NS_DEFINE_NAMED_CID(NS_GFX_INITIALIZATION_CID); static const mozilla::Module::CIDEntry kThebesCIDs[] = { { &kNS_FONT_ENUMERATOR_CID, false, nullptr, nsThebesFontEnumeratorConstructor }, { &kNS_SCRIPTABLE_REGION_CID, false, nullptr, nsScriptableRegionConstructor }, - { &kNS_GFX_INITIALIZATION_CID, false, nullptr, GfxInitializationConstructor }, { nullptr } }; static const mozilla::Module::ContractIDEntry kThebesContracts[] = { { "@mozilla.org/gfx/fontenumerator;1", &kNS_FONT_ENUMERATOR_CID }, { "@mozilla.org/gfx/region;1", &kNS_SCRIPTABLE_REGION_CID }, - { "@mozilla.org/gfx/init;1", &kNS_GFX_INITIALIZATION_CID }, { nullptr } }; -static void -nsThebesGfxModuleDtor() -{ - gfxPlatform::Shutdown(); -} - static const mozilla::Module kThebesModule = { mozilla::Module::kVersion, kThebesCIDs, @@ -82,7 +57,7 @@ static const mozilla::Module kThebesModule = { nullptr, nullptr, nullptr, - nsThebesGfxModuleDtor + nullptr }; NSMODULE_DEFN(nsGfxModule) = &kThebesModule; diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index bc30af6409ea..1b174091bac2 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -421,11 +421,6 @@ gfxPlatform::Init() mozilla::layers::InitGralloc(); #endif - // Force registration of the gfx component, thus arranging for - // ::Shutdown to be called. - nsCOMPtr forceReg - = do_CreateInstance("@mozilla.org/gfx/init;1"); - Preferences::RegisterCallbackAndCall(RecordingPrefChanged, "gfx.2d.recording", nullptr); CreateCMSOutputProfile(); diff --git a/layout/build/nsLayoutModule.cpp b/layout/build/nsLayoutModule.cpp index ace98b8e7121..58a84212bf66 100644 --- a/layout/build/nsLayoutModule.cpp +++ b/layout/build/nsLayoutModule.cpp @@ -70,6 +70,7 @@ #include "nsDOMBlobBuilder.h" #include "nsDOMFileReader.h" +#include "gfxPlatform.h" #include "nsFormData.h" #include "nsHostObjectProtocolHandler.h" #include "nsHostObjectURI.h" @@ -1250,6 +1251,10 @@ LayoutModuleDtor() nsContentUtils::XPCOMShutdown(); nsScriptSecurityManager::Shutdown(); xpcModuleDtor(); + + // Layout depends heavily on gfx, so we want to make sure that gfx is shut + // down after all the layout cleanup runs. + gfxPlatform::Shutdown(); } static const mozilla::Module kLayoutModule = {