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 /* 8 * Forward declarations to avoid including all of nsStyleStruct.h. 9 */ 10 11 #ifndef nsStyleStructFwd_h_ 12 #define nsStyleStructFwd_h_ 13 14 namespace mozilla { 15 16 enum class StyleStructID : uint32_t { 17 /* 18 * Define the constants eStyleStruct_Font, etc. 19 * 20 * The C++ standard, section 7.2, guarantees that enums begin with 0 and 21 * increase by 1. 22 * 23 * Note that we rely on the inherited structs being before the rest in 24 * ComputedStyle. 25 */ 26 #define STYLE_STRUCT_INHERITED(name) name, 27 #define STYLE_STRUCT_RESET(name) 28 #include "nsStyleStructList.h" 29 #undef STYLE_STRUCT_INHERITED 30 #undef STYLE_STRUCT_RESET 31 32 #define STYLE_STRUCT_RESET(name) name, 33 #define STYLE_STRUCT_INHERITED(name) 34 #include "nsStyleStructList.h" 35 #undef STYLE_STRUCT_INHERITED 36 #undef STYLE_STRUCT_RESET 37 }; 38 39 struct StyleStructConstants { 40 static const uint32_t kStyleStructCount = 41 #define STYLE_STRUCT_RESET(name) 1 + 42 #define STYLE_STRUCT_INHERITED(name) 1 + 43 #include "nsStyleStructList.h" 44 #undef STYLE_STRUCT_INHERITED 45 #undef STYLE_STRUCT_RESET 46 0; 47 48 static const uint32_t kInheritedStyleStructCount = 49 #define STYLE_STRUCT_RESET(name) 50 #define STYLE_STRUCT_INHERITED(name) 1 + 51 #include "nsStyleStructList.h" 52 #undef STYLE_STRUCT_INHERITED 53 #undef STYLE_STRUCT_RESET 54 0; 55 56 static const uint32_t kResetStyleStructCount = 57 #define STYLE_STRUCT_RESET(name) 1 + 58 #define STYLE_STRUCT_INHERITED(name) 59 #include "nsStyleStructList.h" 60 #undef STYLE_STRUCT_INHERITED 61 #undef STYLE_STRUCT_RESET 62 0; 63 64 static_assert(kStyleStructCount <= 32, "Bitmasks must be bigger!"); 65 66 static const uint32_t kAllStructsMask = (1 << kStyleStructCount) - 1; 67 static const uint32_t kInheritedStructsMask = 68 (1 << kInheritedStyleStructCount) - 1; 69 static const uint32_t kResetStructsMask = 70 kAllStructsMask & (~kInheritedStructsMask); 71 BitForStyleStructConstants72 static uint32_t BitFor(StyleStructID aID) { 73 return 1 << static_cast<uint32_t>(aID); 74 } 75 }; 76 77 } // namespace mozilla 78 79 #endif /* nsStyleStructFwd_h_ */ 80