/work/obj-fuzz/dist/include/mozilla/ServoUtils.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | /* some utilities for stylo */ |
8 | | |
9 | | #ifndef mozilla_ServoUtils_h |
10 | | #define mozilla_ServoUtils_h |
11 | | |
12 | | #include "mozilla/Assertions.h" |
13 | | #include "mozilla/TypeTraits.h" |
14 | | #include "MainThreadUtils.h" |
15 | | |
16 | | namespace mozilla { |
17 | | |
18 | | // Defined in ServoBindings.cpp. |
19 | | void AssertIsMainThreadOrServoFontMetricsLocked(); |
20 | | |
21 | | class ServoStyleSet; |
22 | | extern ServoStyleSet* sInServoTraversal; |
23 | | inline bool IsInServoTraversal() |
24 | 0 | { |
25 | 0 | // The callers of this function are generally main-thread-only _except_ |
26 | 0 | // for potentially running during the Servo traversal, in which case they may |
27 | 0 | // take special paths that avoid writing to caches and the like. In order |
28 | 0 | // to allow those callers to branch efficiently without checking TLS, we |
29 | 0 | // maintain this static boolean. However, the danger is that those callers |
30 | 0 | // are generally unprepared to deal with non-Servo-but-also-non-main-thread |
31 | 0 | // callers, and are likely to take the main-thread codepath if this function |
32 | 0 | // returns false. So we assert against other non-main-thread callers here. |
33 | 0 | MOZ_ASSERT(sInServoTraversal || NS_IsMainThread()); |
34 | 0 | return sInServoTraversal; |
35 | 0 | } |
36 | | } // namespace mozilla |
37 | | |
38 | | #endif // mozilla_ServoUtils_h |