michael@0: // IWYU pragma: private, include "nsDisplayList.h" michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * vim: set ts=2 sw=2 et tw=78: michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: */ michael@0: michael@0: /** michael@0: * It's useful to be able to dynamically check the type of certain items. michael@0: * Every subclass of nsDisplayItem must have a new type added here for the purposes michael@0: * of easy comparison and matching of items in different display lists. michael@0: * michael@0: * This is #included inside nsDisplayItem. michael@0: */ michael@0: michael@0: michael@0: enum Type { michael@0: TYPE_ZERO = 0, /** Spacer so that the first item starts at 1 */ michael@0: michael@0: #define DECLARE_DISPLAY_ITEM_TYPE(name) TYPE_##name, michael@0: #define DECLARE_DISPLAY_ITEM_TYPE_FLAGS(name,flags) TYPE_##name, michael@0: #include "nsDisplayItemTypesList.h" michael@0: #undef DECLARE_DISPLAY_ITEM_TYPE michael@0: #undef DECLARE_DISPLAY_ITEM_TYPE_FLAGS michael@0: michael@0: TYPE_MAX michael@0: }; michael@0: michael@0: enum { michael@0: // Number of bits needed to represent all types michael@0: TYPE_BITS = 8 michael@0: }; michael@0: michael@0: enum DisplayItemFlags { michael@0: TYPE_RENDERS_NO_IMAGES = 1 << 0 michael@0: }; michael@0: michael@0: static const char* DisplayItemTypeName(Type aType) michael@0: { michael@0: switch (aType) { michael@0: #define DECLARE_DISPLAY_ITEM_TYPE(name) case TYPE_##name: return #name; michael@0: #define DECLARE_DISPLAY_ITEM_TYPE_FLAGS(name,flags) case TYPE_##name: return #name; michael@0: #include "nsDisplayItemTypesList.h" michael@0: #undef DECLARE_DISPLAY_ITEM_TYPE michael@0: #undef DECLARE_DISPLAY_ITEM_TYPE_FLAGS michael@0: michael@0: default: return "TYPE_UNKNOWN"; michael@0: } michael@0: } michael@0: michael@0: static uint8_t GetDisplayItemFlagsForType(Type aType) michael@0: { michael@0: static const uint8_t flags[TYPE_MAX] = { michael@0: 0 michael@0: #define DECLARE_DISPLAY_ITEM_TYPE(name) ,0 michael@0: #define DECLARE_DISPLAY_ITEM_TYPE_FLAGS(name,flags) ,flags michael@0: #include "nsDisplayItemTypesList.h" michael@0: #undef DECLARE_DISPLAY_ITEM_TYPE michael@0: #undef DECLARE_DISPLAY_ITEM_TYPE_FLAGS michael@0: }; michael@0: michael@0: return flags[aType]; michael@0: } michael@0: michael@0: static Type GetDisplayItemTypeFromKey(uint32_t aDisplayItemKey) michael@0: { michael@0: static const uint32_t typeMask = (1 << TYPE_BITS) - 1; michael@0: Type type = static_cast(aDisplayItemKey & typeMask); michael@0: NS_ASSERTION(type > TYPE_ZERO && type < TYPE_MAX, "Invalid display item type!"); michael@0: return type; michael@0: }