Bug 1568157 - Part 5: Move the NodePicker initialization into a getter. r=yulia
[gecko.git] / layout / generic / nsFrameState.cpp
bloba590490206cc816c81a31e17190b8ed98e290e32
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* constants for frame state bits and a type to store them in a uint64_t */
9 #include "nsFrameState.h"
11 #include "nsBlockFrame.h"
12 #include "nsBoxFrame.h"
13 #include "nsBulletFrame.h"
14 #include "nsFlexContainerFrame.h"
15 #include "nsGridContainerFrame.h"
16 #include "nsGfxScrollFrame.h"
17 #include "nsIFrame.h"
18 #include "nsSVGDisplayableFrame.h"
19 #include "nsImageFrame.h"
20 #include "nsInlineFrame.h"
21 #include "nsPlaceholderFrame.h"
22 #include "nsRubyTextFrame.h"
23 #include "nsRubyTextContainerFrame.h"
24 #include "nsSVGContainerFrame.h"
25 #include "nsTableCellFrame.h"
26 #include "nsTableRowFrame.h"
27 #include "nsTableRowGroupFrame.h"
28 #include "nsTextFrame.h"
30 namespace mozilla {
32 #ifdef DEBUG
33 nsCString GetFrameState(nsIFrame* aFrame) {
34 nsCString result;
35 AutoTArray<const char*, 3> groups;
37 nsFrameState state = aFrame->GetStateBits();
39 if (state == nsFrameState(0)) {
40 result.Assign('0');
41 return result;
44 # define FRAME_STATE_GROUP_CLASS(name_, class_) \
45 { \
46 class_* frame = do_QueryFrame(aFrame); \
47 if (frame && \
48 (groups.IsEmpty() || strcmp(groups.LastElement(), #name_))) { \
49 groups.AppendElement(#name_); \
50 } \
52 # define FRAME_STATE_BIT(group_, value_, name_) \
53 if ((state & NS_FRAME_STATE_BIT(value_)) && groups.Contains(#group_)) { \
54 if (!result.IsEmpty()) { \
55 result.InsertLiteral(" | ", 0); \
56 } \
57 result.InsertLiteral(#name_, 0); \
58 state = state & ~NS_FRAME_STATE_BIT(value_); \
60 # include "nsFrameStateBits.h"
61 # undef FRAME_STATE_GROUP_CLASS
62 # undef FRAME_STATE_BIT
64 if (state) {
65 result.AppendPrintf(" | 0x%0" PRIx64, static_cast<uint64_t>(state));
68 return result;
71 void PrintFrameState(nsIFrame* aFrame) {
72 printf("%s\n", GetFrameState(aFrame).get());
75 enum class FrameStateGroupId {
76 # define FRAME_STATE_GROUP_NAME(name_) name_,
77 # include "nsFrameStateBits.h"
78 # undef FRAME_STATE_GROUP_NAME
80 LENGTH
83 void DebugVerifyFrameStateBits() {
84 // Build an array of all of the bits used by each group. While
85 // building this we assert that a bit isn't used multiple times within
86 // the same group.
87 nsFrameState bitsUsedPerGroup[size_t(FrameStateGroupId::LENGTH)] = {
88 nsFrameState(0)};
90 # define FRAME_STATE_BIT(group_, value_, name_) \
91 { \
92 auto bit = NS_FRAME_STATE_BIT(value_); \
93 size_t group = size_t(FrameStateGroupId::group_); \
94 MOZ_ASSERT(!(bitsUsedPerGroup[group] & bit), #name_ \
95 " must not use a bit already declared within its group"); \
96 bitsUsedPerGroup[group] |= bit; \
99 # include "nsFrameStateBits.h"
100 # undef FRAME_STATE_BIT
102 // FIXME: Can we somehow check across the groups as well??? In other
103 // words, find the pairs of groups that could be used on the same
104 // frame (Generic paired with everything else, and a few other pairs),
105 // and check that we don't have bits in common between those pairs.
108 #endif
110 } // namespace mozilla