|
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/. */ |
|
5 |
|
6 /* constants for frame state bits and a type to store them in a uint64_t */ |
|
7 |
|
8 #ifndef nsFrameState_h_ |
|
9 #define nsFrameState_h_ |
|
10 |
|
11 #include <stdint.h> |
|
12 |
|
13 #ifdef DEBUG |
|
14 #include "nsString.h" |
|
15 |
|
16 class nsIFrame; |
|
17 #endif |
|
18 |
|
19 typedef uint64_t nsFrameState_size_t; |
|
20 |
|
21 #define NS_FRAME_STATE_BIT(n_) (nsFrameState(nsFrameState_size_t(1) << (n_))) |
|
22 |
|
23 #if (_MSC_VER == 1600) |
|
24 /* |
|
25 * Visual Studio 2010 has trouble with the sized enum. Although sized enums |
|
26 * are supported, two problems arise: |
|
27 * |
|
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. |
|
32 * |
|
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.) |
|
36 */ |
|
37 |
|
38 typedef nsFrameState_size_t nsFrameState; |
|
39 |
|
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 |
|
44 |
|
45 #else |
|
46 |
|
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 |
|
52 }; |
|
53 |
|
54 inline nsFrameState operator|(nsFrameState aLeft, nsFrameState aRight) |
|
55 { |
|
56 return nsFrameState(nsFrameState_size_t(aLeft) | nsFrameState_size_t(aRight)); |
|
57 } |
|
58 |
|
59 inline nsFrameState operator&(nsFrameState aLeft, nsFrameState aRight) |
|
60 { |
|
61 return nsFrameState(nsFrameState_size_t(aLeft) & nsFrameState_size_t(aRight)); |
|
62 } |
|
63 |
|
64 inline nsFrameState& operator|=(nsFrameState& aLeft, nsFrameState aRight) |
|
65 { |
|
66 aLeft = aLeft | aRight; |
|
67 return aLeft; |
|
68 } |
|
69 |
|
70 inline nsFrameState& operator&=(nsFrameState& aLeft, nsFrameState aRight) |
|
71 { |
|
72 aLeft = aLeft & aRight; |
|
73 return aLeft; |
|
74 } |
|
75 |
|
76 inline nsFrameState operator~(nsFrameState aRight) |
|
77 { |
|
78 return nsFrameState(~nsFrameState_size_t(aRight)); |
|
79 } |
|
80 |
|
81 inline nsFrameState operator^(nsFrameState aLeft, nsFrameState aRight) |
|
82 { |
|
83 return nsFrameState(nsFrameState_size_t(aLeft) ^ nsFrameState_size_t(aRight)); |
|
84 } |
|
85 |
|
86 inline nsFrameState& operator^=(nsFrameState& aLeft, nsFrameState aRight) |
|
87 { |
|
88 aLeft = aLeft ^ aRight; |
|
89 return aLeft; |
|
90 } |
|
91 |
|
92 #endif |
|
93 |
|
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 |
|
97 |
|
98 namespace mozilla { |
|
99 #ifdef DEBUG |
|
100 nsCString GetFrameState(nsIFrame* aFrame); |
|
101 void PrintFrameState(nsIFrame* aFrame); |
|
102 #endif |
|
103 } |
|
104 |
|
105 #endif /* nsFrameState_h_ */ |