michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* constants for frame state bits and a type to store them in a uint64_t */ michael@0: michael@0: #ifndef nsFrameState_h_ michael@0: #define nsFrameState_h_ michael@0: michael@0: #include michael@0: michael@0: #ifdef DEBUG michael@0: #include "nsString.h" michael@0: michael@0: class nsIFrame; michael@0: #endif michael@0: michael@0: typedef uint64_t nsFrameState_size_t; michael@0: michael@0: #define NS_FRAME_STATE_BIT(n_) (nsFrameState(nsFrameState_size_t(1) << (n_))) michael@0: michael@0: #if (_MSC_VER == 1600) michael@0: /* michael@0: * Visual Studio 2010 has trouble with the sized enum. Although sized enums michael@0: * are supported, two problems arise: michael@0: * michael@0: * 1. Implicit conversions from the enum type to the equivalently sized michael@0: * integer size are not performed, leading to many compile errors. michael@0: * 2. Even with explicit casts added to avoid the errors from (1), odd michael@0: * test failures result, which might well be due to a compiler bug. michael@0: * michael@0: * So with VS2010 we use consts for the state bits and forgo the increased michael@0: * type safety of the enum. (Visual Studio 2012 has no problem with michael@0: * nsFrameState being a sized enum, however.) michael@0: */ michael@0: michael@0: typedef nsFrameState_size_t nsFrameState; michael@0: michael@0: #define FRAME_STATE_BIT(group_, value_, name_) \ michael@0: const nsFrameState name_ = NS_FRAME_STATE_BIT(value_); michael@0: #include "nsFrameStateBits.h" michael@0: #undef FRAME_STATE_BIT michael@0: michael@0: #else michael@0: michael@0: enum nsFrameState : nsFrameState_size_t { michael@0: #define FRAME_STATE_BIT(group_, value_, name_) \ michael@0: name_ = NS_FRAME_STATE_BIT(value_), michael@0: #include "nsFrameStateBits.h" michael@0: #undef FRAME_STATE_BIT michael@0: }; michael@0: michael@0: inline nsFrameState operator|(nsFrameState aLeft, nsFrameState aRight) michael@0: { michael@0: return nsFrameState(nsFrameState_size_t(aLeft) | nsFrameState_size_t(aRight)); michael@0: } michael@0: michael@0: inline nsFrameState operator&(nsFrameState aLeft, nsFrameState aRight) michael@0: { michael@0: return nsFrameState(nsFrameState_size_t(aLeft) & nsFrameState_size_t(aRight)); michael@0: } michael@0: michael@0: inline nsFrameState& operator|=(nsFrameState& aLeft, nsFrameState aRight) michael@0: { michael@0: aLeft = aLeft | aRight; michael@0: return aLeft; michael@0: } michael@0: michael@0: inline nsFrameState& operator&=(nsFrameState& aLeft, nsFrameState aRight) michael@0: { michael@0: aLeft = aLeft & aRight; michael@0: return aLeft; michael@0: } michael@0: michael@0: inline nsFrameState operator~(nsFrameState aRight) michael@0: { michael@0: return nsFrameState(~nsFrameState_size_t(aRight)); michael@0: } michael@0: michael@0: inline nsFrameState operator^(nsFrameState aLeft, nsFrameState aRight) michael@0: { michael@0: return nsFrameState(nsFrameState_size_t(aLeft) ^ nsFrameState_size_t(aRight)); michael@0: } michael@0: michael@0: inline nsFrameState& operator^=(nsFrameState& aLeft, nsFrameState aRight) michael@0: { michael@0: aLeft = aLeft ^ aRight; michael@0: return aLeft; michael@0: } michael@0: michael@0: #endif michael@0: michael@0: // Bits 20-31 and 60-63 of the frame state are reserved for implementations. michael@0: #define NS_FRAME_IMPL_RESERVED nsFrameState(0xF0000000FFF00000) michael@0: #define NS_FRAME_RESERVED ~NS_FRAME_IMPL_RESERVED michael@0: michael@0: namespace mozilla { michael@0: #ifdef DEBUG michael@0: nsCString GetFrameState(nsIFrame* aFrame); michael@0: void PrintFrameState(nsIFrame* aFrame); michael@0: #endif michael@0: } michael@0: michael@0: #endif /* nsFrameState_h_ */