1 // IWYU pragma: private, include "nsDisplayList.h"
2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * vim: set ts=2 sw=2 et tw=78:
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
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 purposes
12 * of easy comparison and matching of items in different display lists.
14 * This is #included inside nsDisplayItem.
19 TYPE_ZERO
= 0, /** Spacer so that the first item starts at 1 */
21 #define DECLARE_DISPLAY_ITEM_TYPE(name) TYPE_##name,
22 #define DECLARE_DISPLAY_ITEM_TYPE_FLAGS(name,flags) TYPE_##name,
23 #include "nsDisplayItemTypesList.h"
24 #undef DECLARE_DISPLAY_ITEM_TYPE
25 #undef DECLARE_DISPLAY_ITEM_TYPE_FLAGS
31 // Number of bits needed to represent all types
35 enum DisplayItemFlags
{
36 TYPE_RENDERS_NO_IMAGES
= 1 << 0
39 static const char* DisplayItemTypeName(Type aType
)
42 #define DECLARE_DISPLAY_ITEM_TYPE(name) case TYPE_##name: return #name;
43 #define DECLARE_DISPLAY_ITEM_TYPE_FLAGS(name,flags) case TYPE_##name: return #name;
44 #include "nsDisplayItemTypesList.h"
45 #undef DECLARE_DISPLAY_ITEM_TYPE
46 #undef DECLARE_DISPLAY_ITEM_TYPE_FLAGS
48 default: return "TYPE_UNKNOWN";
52 static uint8_t GetDisplayItemFlagsForType(Type aType
)
54 static const uint8_t flags
[TYPE_MAX
] = {
56 #define DECLARE_DISPLAY_ITEM_TYPE(name) ,0
57 #define DECLARE_DISPLAY_ITEM_TYPE_FLAGS(name,flags) ,flags
58 #include "nsDisplayItemTypesList.h"
59 #undef DECLARE_DISPLAY_ITEM_TYPE
60 #undef DECLARE_DISPLAY_ITEM_TYPE_FLAGS
66 static Type
GetDisplayItemTypeFromKey(uint32_t aDisplayItemKey
)
68 static const uint32_t typeMask
= (1 << TYPE_BITS
) - 1;
69 Type type
= static_cast<Type
>(aDisplayItemKey
& typeMask
);
70 NS_ASSERTION(type
> TYPE_ZERO
&& type
< TYPE_MAX
, "Invalid display item type!");