Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / base / RustTypes.h
blob2bb62be902fd904c14f31993102c0b0a5a028179
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 mozilla_dom_RustTypes_h
8 #define mozilla_dom_RustTypes_h
10 #include "nsDebug.h"
12 #define STATE_HELPERS(Type) \
13 using InternalType = decltype(bits); \
15 constexpr Type() : bits{0} {} \
17 explicit constexpr Type(InternalType aBits) : bits{aBits} {} \
19 bool IsEmpty() const { return bits == 0; } \
21 bool HasAtLeastOneOfStates(Type aStates) const { \
22 return bool((*this) & aStates); \
23 } \
25 bool HasState(Type aState) const { \
26 NS_ASSERTION(!(aState.bits & (aState.bits - 1)), \
27 "When calling HasState, " \
28 "argument has to contain only one state!"); \
29 return HasAtLeastOneOfStates(aState); \
30 } \
32 bool HasAllStates(Type aStates) const { \
33 return ((*this) & aStates) == aStates; \
34 } \
36 InternalType GetInternalValue() const { return bits; }
38 #include "mozilla/dom/GeneratedElementDocumentState.h"
40 #endif