Bumping manifests a=b2g-bump
[gecko.git] / layout / generic / nsFrameState.h
blob99615f6382ec862c73d77866d1cee682308dbb14
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /* constants for frame state bits and a type to store them in a uint64_t */
8 #ifndef nsFrameState_h_
9 #define nsFrameState_h_
11 #include <stdint.h>
13 #ifdef DEBUG
14 #include "nsString.h"
16 class nsIFrame;
17 #endif
19 typedef uint64_t nsFrameState_size_t;
21 #define NS_FRAME_STATE_BIT(n_) (nsFrameState(nsFrameState_size_t(1) << (n_)))
23 #if (_MSC_VER == 1600)
25 * Visual Studio 2010 has trouble with the sized enum. Although sized enums
26 * are supported, two problems arise:
28 * 1. Implicit conversions from the enum type to the equivalently sized
29 * integer size are not performed, leading to many compile errors.
30 * 2. Even with explicit casts added to avoid the errors from (1), odd
31 * test failures result, which might well be due to a compiler bug.
33 * So with VS2010 we use consts for the state bits and forgo the increased
34 * type safety of the enum. (Visual Studio 2012 has no problem with
35 * nsFrameState being a sized enum, however.)
38 typedef nsFrameState_size_t nsFrameState;
40 #define FRAME_STATE_BIT(group_, value_, name_) \
41 const nsFrameState name_ = NS_FRAME_STATE_BIT(value_);
42 #include "nsFrameStateBits.h"
43 #undef FRAME_STATE_BIT
45 #else
47 enum nsFrameState : nsFrameState_size_t {
48 #define FRAME_STATE_BIT(group_, value_, name_) \
49 name_ = NS_FRAME_STATE_BIT(value_),
50 #include "nsFrameStateBits.h"
51 #undef FRAME_STATE_BIT
54 inline nsFrameState operator|(nsFrameState aLeft, nsFrameState aRight)
56 return nsFrameState(nsFrameState_size_t(aLeft) | nsFrameState_size_t(aRight));
59 inline nsFrameState operator&(nsFrameState aLeft, nsFrameState aRight)
61 return nsFrameState(nsFrameState_size_t(aLeft) & nsFrameState_size_t(aRight));
64 inline nsFrameState& operator|=(nsFrameState& aLeft, nsFrameState aRight)
66 aLeft = aLeft | aRight;
67 return aLeft;
70 inline nsFrameState& operator&=(nsFrameState& aLeft, nsFrameState aRight)
72 aLeft = aLeft & aRight;
73 return aLeft;
76 inline nsFrameState operator~(nsFrameState aRight)
78 return nsFrameState(~nsFrameState_size_t(aRight));
81 inline nsFrameState operator^(nsFrameState aLeft, nsFrameState aRight)
83 return nsFrameState(nsFrameState_size_t(aLeft) ^ nsFrameState_size_t(aRight));
86 inline nsFrameState& operator^=(nsFrameState& aLeft, nsFrameState aRight)
88 aLeft = aLeft ^ aRight;
89 return aLeft;
92 #endif
94 // Bits 20-31 and 60-63 of the frame state are reserved for implementations.
95 #define NS_FRAME_IMPL_RESERVED nsFrameState(0xF0000000FFF00000)
96 #define NS_FRAME_RESERVED ~NS_FRAME_IMPL_RESERVED
98 namespace mozilla {
99 #ifdef DEBUG
100 nsCString GetFrameState(nsIFrame* aFrame);
101 void PrintFrameState(nsIFrame* aFrame);
102 #endif
105 #endif /* nsFrameState_h_ */