layout/base/nsDisplayItemTypes.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // IWYU pragma: private, include "nsDisplayList.h"
michael@0 2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0 3 * vim: set ts=2 sw=2 et tw=78:
michael@0 4 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 5 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 7 */
michael@0 8
michael@0 9 /**
michael@0 10 * It's useful to be able to dynamically check the type of certain items.
michael@0 11 * Every subclass of nsDisplayItem must have a new type added here for the purposes
michael@0 12 * of easy comparison and matching of items in different display lists.
michael@0 13 *
michael@0 14 * This is #included inside nsDisplayItem.
michael@0 15 */
michael@0 16
michael@0 17
michael@0 18 enum Type {
michael@0 19 TYPE_ZERO = 0, /** Spacer so that the first item starts at 1 */
michael@0 20
michael@0 21 #define DECLARE_DISPLAY_ITEM_TYPE(name) TYPE_##name,
michael@0 22 #define DECLARE_DISPLAY_ITEM_TYPE_FLAGS(name,flags) TYPE_##name,
michael@0 23 #include "nsDisplayItemTypesList.h"
michael@0 24 #undef DECLARE_DISPLAY_ITEM_TYPE
michael@0 25 #undef DECLARE_DISPLAY_ITEM_TYPE_FLAGS
michael@0 26
michael@0 27 TYPE_MAX
michael@0 28 };
michael@0 29
michael@0 30 enum {
michael@0 31 // Number of bits needed to represent all types
michael@0 32 TYPE_BITS = 8
michael@0 33 };
michael@0 34
michael@0 35 enum DisplayItemFlags {
michael@0 36 TYPE_RENDERS_NO_IMAGES = 1 << 0
michael@0 37 };
michael@0 38
michael@0 39 static const char* DisplayItemTypeName(Type aType)
michael@0 40 {
michael@0 41 switch (aType) {
michael@0 42 #define DECLARE_DISPLAY_ITEM_TYPE(name) case TYPE_##name: return #name;
michael@0 43 #define DECLARE_DISPLAY_ITEM_TYPE_FLAGS(name,flags) case TYPE_##name: return #name;
michael@0 44 #include "nsDisplayItemTypesList.h"
michael@0 45 #undef DECLARE_DISPLAY_ITEM_TYPE
michael@0 46 #undef DECLARE_DISPLAY_ITEM_TYPE_FLAGS
michael@0 47
michael@0 48 default: return "TYPE_UNKNOWN";
michael@0 49 }
michael@0 50 }
michael@0 51
michael@0 52 static uint8_t GetDisplayItemFlagsForType(Type aType)
michael@0 53 {
michael@0 54 static const uint8_t flags[TYPE_MAX] = {
michael@0 55 0
michael@0 56 #define DECLARE_DISPLAY_ITEM_TYPE(name) ,0
michael@0 57 #define DECLARE_DISPLAY_ITEM_TYPE_FLAGS(name,flags) ,flags
michael@0 58 #include "nsDisplayItemTypesList.h"
michael@0 59 #undef DECLARE_DISPLAY_ITEM_TYPE
michael@0 60 #undef DECLARE_DISPLAY_ITEM_TYPE_FLAGS
michael@0 61 };
michael@0 62
michael@0 63 return flags[aType];
michael@0 64 }
michael@0 65
michael@0 66 static Type GetDisplayItemTypeFromKey(uint32_t aDisplayItemKey)
michael@0 67 {
michael@0 68 static const uint32_t typeMask = (1 << TYPE_BITS) - 1;
michael@0 69 Type type = static_cast<Type>(aDisplayItemKey & typeMask);
michael@0 70 NS_ASSERTION(type > TYPE_ZERO && type < TYPE_MAX, "Invalid display item type!");
michael@0 71 return type;
michael@0 72 }

mercurial