Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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)
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 */
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
52 };
54 inline nsFrameState operator|(nsFrameState aLeft, nsFrameState aRight)
55 {
56 return nsFrameState(nsFrameState_size_t(aLeft) | nsFrameState_size_t(aRight));
57 }
59 inline nsFrameState operator&(nsFrameState aLeft, nsFrameState aRight)
60 {
61 return nsFrameState(nsFrameState_size_t(aLeft) & nsFrameState_size_t(aRight));
62 }
64 inline nsFrameState& operator|=(nsFrameState& aLeft, nsFrameState aRight)
65 {
66 aLeft = aLeft | aRight;
67 return aLeft;
68 }
70 inline nsFrameState& operator&=(nsFrameState& aLeft, nsFrameState aRight)
71 {
72 aLeft = aLeft & aRight;
73 return aLeft;
74 }
76 inline nsFrameState operator~(nsFrameState aRight)
77 {
78 return nsFrameState(~nsFrameState_size_t(aRight));
79 }
81 inline nsFrameState operator^(nsFrameState aLeft, nsFrameState aRight)
82 {
83 return nsFrameState(nsFrameState_size_t(aLeft) ^ nsFrameState_size_t(aRight));
84 }
86 inline nsFrameState& operator^=(nsFrameState& aLeft, nsFrameState aRight)
87 {
88 aLeft = aLeft ^ aRight;
89 return aLeft;
90 }
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
103 }
105 #endif /* nsFrameState_h_ */