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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 "nsImageFrame.h"
#include "nsInlineFrame.h"
#include "nsPageFrame.h"
#include "nsPlaceholderFrame.h"
#include "nsRubyTextFrame.h"
#include "nsRubyTextContainerFrame.h"
#include "nsTableCellFrame.h"
#include "nsTableRowFrame.h"
#include "nsTableRowGroupFrame.h"
#include "nsTextFrame.h"
#include "mozilla/ISVGDisplayableFrame.h"
#include "mozilla/SVGContainerFrame.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_CLASS(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.InsertLiteral(" | ", 0); \
} \
result.InsertLiteral(#name_, 0); \
state = state & ~NS_FRAME_STATE_BIT(value_); \
}
# include "nsFrameStateBits.h"
# undef FRAME_STATE_GROUP_CLASS
# undef FRAME_STATE_BIT
if (state) {
result.AppendPrintf(" | 0x%0" PRIx64, static_cast<uint64_t>(state));
}
return result;
}
void PrintFrameState(nsIFrame* aFrame) {
printf("%s\n", GetFrameState(aFrame).get());
}
enum class FrameStateGroupId {
# define FRAME_STATE_GROUP_NAME(name_) name_,
# include "nsFrameStateBits.h"
# undef FRAME_STATE_GROUP_NAME
LENGTH
};
void DebugVerifyFrameStateBits() {
// Build an array of all of the bits used by each group. While
// building this we assert that a bit isn't used multiple times within
// the same group.
nsFrameState bitsUsedPerGroup[size_t(FrameStateGroupId::LENGTH)] = {
nsFrameState(0)};
# define FRAME_STATE_BIT(group_, value_, name_) \
{ \
auto bit = NS_FRAME_STATE_BIT(value_); \
size_t group = size_t(FrameStateGroupId::group_); \
MOZ_ASSERT(!(bitsUsedPerGroup[group] & bit), #name_ \
" must not use a bit already declared within its group"); \
bitsUsedPerGroup[group] |= bit; \
}
# include "nsFrameStateBits.h"
# undef FRAME_STATE_BIT
// FIXME: Can we somehow check across the groups as well??? In other
// words, find the pairs of groups that could be used on the same
// frame (Generic paired with everything else, and a few other pairs),
// and check that we don't have bits in common between those pairs.
}
#endif
} // namespace mozilla
|