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