1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsLayoutStatics_h__
8 #define nsLayoutStatics_h__
11 #include "MainThreadUtils.h"
12 #include "nsISupportsImpl.h"
15 // This isn't really a class, it's a namespace for static methods.
16 // Documents and other objects can hold a reference to the layout static
17 // objects so that they last past the xpcom-shutdown notification.
19 class nsLayoutStatics
{
21 // Called by the layout module constructor. This call performs an AddRef()
23 static nsresult
Initialize();
25 static void AddRef() {
26 NS_ASSERTION(NS_IsMainThread(),
27 "nsLayoutStatics reference counting must be on main thread");
29 NS_ASSERTION(sLayoutStaticRefcnt
,
30 "nsLayoutStatics already dropped to zero!");
32 ++sLayoutStaticRefcnt
;
33 NS_LOG_ADDREF(&sLayoutStaticRefcnt
, sLayoutStaticRefcnt
, "nsLayoutStatics",
36 static void Release() {
37 NS_ASSERTION(NS_IsMainThread(),
38 "nsLayoutStatics reference counting must be on main thread");
40 --sLayoutStaticRefcnt
;
41 NS_LOG_RELEASE(&sLayoutStaticRefcnt
, sLayoutStaticRefcnt
,
44 if (!sLayoutStaticRefcnt
) Shutdown();
51 static void Shutdown();
53 static nsrefcnt sLayoutStaticRefcnt
;
56 #endif // nsLayoutStatics_h__