LCOV - code coverage report
Current view: top level - layout/painting - nsDisplayItemTypes.h (source / functions) Hit Total Coverage
Test: output.info Lines: 6 6 100.0 %
Date: 2017-07-14 16:53:18 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             :  */
       8             : 
       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             :  */
      16             : 
      17             : 
      18             : enum Type {
      19             :   TYPE_ZERO = 0, /** Spacer so that the first item starts at 1 */
      20             : 
      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
      26             : 
      27             :   TYPE_MAX
      28             : };
      29             : 
      30             : enum {
      31             :   // Number of bits needed to represent all types
      32             :   TYPE_BITS = 8
      33             : };
      34             : 
      35             : enum DisplayItemFlags {
      36             :   TYPE_RENDERS_NO_IMAGES = 1 << 0
      37             : };
      38             : 
      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
      47             : 
      48             :     default: return "TYPE_UNKNOWN";
      49             :   }
      50             : }
      51             : 
      52          15 : 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             :   };
      62             : 
      63          15 :   return flags[aType];
      64             : }
      65             : 
      66          15 : static Type GetDisplayItemTypeFromKey(uint32_t aDisplayItemKey)
      67             : {
      68             :   static const uint32_t typeMask = (1 << TYPE_BITS) - 1;
      69          15 :   Type type = static_cast<Type>(aDisplayItemKey & typeMask);
      70          15 :   NS_ASSERTION(type > TYPE_ZERO && type < TYPE_MAX, "Invalid display item type!");
      71          15 :   return type;
      72             : }

Generated by: LCOV version 1.13