Backed out 2 changesets (bug 903746) for causing non-unified build bustages on nsIPri...
[gecko.git] / layout / style / ServoUtils.h
blob5c8df84fecac717a65f33271f832835dd25a5f12
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 /* some utilities for Gecko to use for Servo initialization and assertions */
9 #ifndef mozilla_ServoUtils_h
10 #define mozilla_ServoUtils_h
12 #include "mozilla/Assertions.h"
13 #include "MainThreadUtils.h"
15 namespace mozilla {
17 // Defined in GeckoBindings.cpp.
18 void InitializeServo();
19 void ShutdownServo();
20 void AssertIsMainThreadOrServoFontMetricsLocked();
22 class ServoStyleSet;
23 extern ServoStyleSet* sInServoTraversal;
24 inline bool IsInServoTraversal() {
25 // The callers of this function are generally main-thread-only _except_
26 // for potentially running during the Servo traversal, in which case they may
27 // take special paths that avoid writing to caches and the like. In order
28 // to allow those callers to branch efficiently without checking TLS, we
29 // maintain this static boolean. However, the danger is that those callers
30 // are generally unprepared to deal with non-Servo-but-also-non-main-thread
31 // callers, and are likely to take the main-thread codepath if this function
32 // returns false. So we assert against other non-main-thread callers here.
33 MOZ_ASSERT(sInServoTraversal || NS_IsMainThread());
34 return sInServoTraversal;
36 } // namespace mozilla
38 #endif // mozilla_ServoUtils_h