summaryrefslogtreecommitdiffstats
path: root/layout/generic/nsFrameState.cpp
blob: 92b8e8324dfb142eb5c25e40bf36ea97f6fa27cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/. */

/* constants for frame state bits and a type to store them in a uint64_t */

#include "nsFrameState.h"

#include "nsBlockFrame.h"
#include "nsBoxFrame.h"
#include "nsBulletFrame.h"
#include "nsFlexContainerFrame.h"
#include "nsGridContainerFrame.h"
#include "nsGfxScrollFrame.h"
#include "nsIFrame.h"
#include "nsISVGChildFrame.h"
#include "nsImageFrame.h"
#include "nsInlineFrame.h"
#include "nsPlaceholderFrame.h"
#include "nsRubyTextFrame.h"
#include "nsRubyTextContainerFrame.h"
#include "nsSVGContainerFrame.h"
#include "nsTableCellFrame.h"
#include "nsTableRowFrame.h"
#include "nsTableRowGroupFrame.h"
#include "nsTextFrame.h"

namespace mozilla {

#ifdef DEBUG
nsCString
GetFrameState(nsIFrame* aFrame)
{
  nsCString result;
  AutoTArray<const char*,3> groups;

  nsFrameState state = aFrame->GetStateBits();

  if (state == nsFrameState(0)) {
    result.Assign('0');
    return result;
  }

#define FRAME_STATE_GROUP(name_, class_)                                      \
  {                                                                           \
    class_* frame = do_QueryFrame(aFrame);                                    \
    if (frame && (groups.IsEmpty() || strcmp(groups.LastElement(), #name_))) {\
      groups.AppendElement(#name_);                                           \
    }                                                                         \
  }
#define FRAME_STATE_BIT(group_, value_, name_)                                \
  if ((state & NS_FRAME_STATE_BIT(value_)) && groups.Contains(#group_)) {     \
    if (!result.IsEmpty()) {                                                  \
      result.Insert(" | ", 0);                                                \
    }                                                                         \
    result.Insert(#name_, 0);                                                 \
    state = state & ~NS_FRAME_STATE_BIT(value_);                              \
  }
#include "nsFrameStateBits.h"
#undef FRAME_STATE_GROUP
#undef FRAME_STATE_BIT

  if (state) {
    result.AppendPrintf(" | 0x%0llx", state);
  }

  return result;
}

void
PrintFrameState(nsIFrame* aFrame)
{
  printf("%s\n", GetFrameState(aFrame).get());
}
#endif

} // namespace mozilla