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 // IWYU pragma: private, include "nsDisplayList.h"
10 * It's useful to be able to dynamically check the type of certain items.
11 * Every subclass of nsDisplayItem must have a new type added here for the
12 * purposes of easy comparison and matching of items in different display lists.
15 #ifndef NSDISPLAYITEMTYPES_H_
16 #define NSDISPLAYITEMTYPES_H_
18 enum class DisplayItemType
: uint8_t {
19 TYPE_ZERO
= 0, /** Spacer so that the first item starts at 1 */
21 #define DECLARE_DISPLAY_ITEM_TYPE(name, flags) TYPE_##name,
22 #include "nsDisplayItemTypesList.h"
23 #undef DECLARE_DISPLAY_ITEM_TYPE
29 // Number of bits needed to represent all types
33 enum DisplayItemFlags
{
34 TYPE_RENDERS_NO_IMAGES
= 1 << 0,
35 TYPE_IS_CONTENTFUL
= 1 << 1,
36 TYPE_IS_CONTAINER
= 1 << 2
39 inline const char* DisplayItemTypeName(DisplayItemType aType
) {
41 #define DECLARE_DISPLAY_ITEM_TYPE(name, flags) \
42 case DisplayItemType::TYPE_##name: \
44 #include "nsDisplayItemTypesList.h"
45 #undef DECLARE_DISPLAY_ITEM_TYPE
48 return "TYPE_UNKNOWN";
52 inline uint8_t GetDisplayItemFlagsForType(DisplayItemType aType
) {
53 static const uint8_t flags
[static_cast<uint32_t>(DisplayItemType::TYPE_MAX
)] =
55 #define DECLARE_DISPLAY_ITEM_TYPE(name, flags) , flags
56 #include "nsDisplayItemTypesList.h"
57 #undef DECLARE_DISPLAY_ITEM_TYPE
60 return flags
[static_cast<uint32_t>(aType
)];
63 inline DisplayItemType
GetDisplayItemTypeFromKey(uint32_t aDisplayItemKey
) {
64 static const uint32_t typeMask
= (1 << TYPE_BITS
) - 1;
65 DisplayItemType type
=
66 static_cast<DisplayItemType
>(aDisplayItemKey
& typeMask
);
68 type
>= DisplayItemType::TYPE_ZERO
&& type
< DisplayItemType::TYPE_MAX
,
69 "Invalid display item type!");
73 #endif /*NSDISPLAYITEMTYPES_H_*/