tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsStyleStructFwd.h (2024B)


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