Bug 1839316: part 5) Guard the "fetchpriority" attribute behind a pref. r=kershaw...
[gecko.git] / widget / windows / nsToolkit.cpp
blob6eea9c958f979076f956eed74e6782644f2818a2
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "nsToolkit.h"
7 #include "nsAppShell.h"
8 #include "nsWindow.h"
9 #include "nsWidgetsCID.h"
10 #include "prmon.h"
11 #include "prtime.h"
12 #include "nsComponentManagerUtils.h"
13 #include <objbase.h>
14 #include "WinUtils.h"
16 #include "nsUXThemeData.h"
18 // unknwn.h is needed to build with WIN32_LEAN_AND_MEAN
19 #include <unknwn.h>
21 using namespace mozilla::widget;
23 nsToolkit* nsToolkit::gToolkit = nullptr;
24 HINSTANCE nsToolkit::mDllInstance = 0;
26 //-------------------------------------------------------------------------
28 // constructor
30 //-------------------------------------------------------------------------
31 nsToolkit::nsToolkit() {
32 MOZ_COUNT_CTOR(nsToolkit);
34 #if defined(MOZ_STATIC_COMPONENT_LIBS)
35 nsToolkit::Startup(GetModuleHandle(nullptr));
36 #endif
39 //-------------------------------------------------------------------------
41 // destructor
43 //-------------------------------------------------------------------------
44 nsToolkit::~nsToolkit() { MOZ_COUNT_DTOR(nsToolkit); }
46 void nsToolkit::Startup(HMODULE hModule) {
47 nsToolkit::mDllInstance = hModule;
48 WinUtils::Initialize();
51 void nsToolkit::Shutdown() {
52 delete gToolkit;
53 gToolkit = nullptr;
56 //-------------------------------------------------------------------------
58 // Return the nsToolkit for the current thread. If a toolkit does not
59 // yet exist, then one will be created...
61 //-------------------------------------------------------------------------
62 // static
63 nsToolkit* nsToolkit::GetToolkit() {
64 if (!gToolkit) {
65 gToolkit = new nsToolkit();
68 return gToolkit;