Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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/.
7 */
9 /**
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.
13 *
14 * This is #included inside nsDisplayItem.
15 */
18 enum Type {
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
27 TYPE_MAX
28 };
30 enum {
31 // Number of bits needed to represent all types
32 TYPE_BITS = 8
33 };
35 enum DisplayItemFlags {
36 TYPE_RENDERS_NO_IMAGES = 1 << 0
37 };
39 static const char* DisplayItemTypeName(Type aType)
40 {
41 switch (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";
49 }
50 }
52 static uint8_t GetDisplayItemFlagsForType(Type aType)
53 {
54 static const uint8_t flags[TYPE_MAX] = {
55 0
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
61 };
63 return flags[aType];
64 }
66 static Type GetDisplayItemTypeFromKey(uint32_t aDisplayItemKey)
67 {
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!");
71 return type;
72 }