1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/generic/nsFrameState.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,105 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/* constants for frame state bits and a type to store them in a uint64_t */ 1.10 + 1.11 +#ifndef nsFrameState_h_ 1.12 +#define nsFrameState_h_ 1.13 + 1.14 +#include <stdint.h> 1.15 + 1.16 +#ifdef DEBUG 1.17 +#include "nsString.h" 1.18 + 1.19 +class nsIFrame; 1.20 +#endif 1.21 + 1.22 +typedef uint64_t nsFrameState_size_t; 1.23 + 1.24 +#define NS_FRAME_STATE_BIT(n_) (nsFrameState(nsFrameState_size_t(1) << (n_))) 1.25 + 1.26 +#if (_MSC_VER == 1600) 1.27 +/* 1.28 + * Visual Studio 2010 has trouble with the sized enum. Although sized enums 1.29 + * are supported, two problems arise: 1.30 + * 1.31 + * 1. Implicit conversions from the enum type to the equivalently sized 1.32 + * integer size are not performed, leading to many compile errors. 1.33 + * 2. Even with explicit casts added to avoid the errors from (1), odd 1.34 + * test failures result, which might well be due to a compiler bug. 1.35 + * 1.36 + * So with VS2010 we use consts for the state bits and forgo the increased 1.37 + * type safety of the enum. (Visual Studio 2012 has no problem with 1.38 + * nsFrameState being a sized enum, however.) 1.39 + */ 1.40 + 1.41 +typedef nsFrameState_size_t nsFrameState; 1.42 + 1.43 +#define FRAME_STATE_BIT(group_, value_, name_) \ 1.44 +const nsFrameState name_ = NS_FRAME_STATE_BIT(value_); 1.45 +#include "nsFrameStateBits.h" 1.46 +#undef FRAME_STATE_BIT 1.47 + 1.48 +#else 1.49 + 1.50 +enum nsFrameState : nsFrameState_size_t { 1.51 +#define FRAME_STATE_BIT(group_, value_, name_) \ 1.52 + name_ = NS_FRAME_STATE_BIT(value_), 1.53 +#include "nsFrameStateBits.h" 1.54 +#undef FRAME_STATE_BIT 1.55 +}; 1.56 + 1.57 +inline nsFrameState operator|(nsFrameState aLeft, nsFrameState aRight) 1.58 +{ 1.59 + return nsFrameState(nsFrameState_size_t(aLeft) | nsFrameState_size_t(aRight)); 1.60 +} 1.61 + 1.62 +inline nsFrameState operator&(nsFrameState aLeft, nsFrameState aRight) 1.63 +{ 1.64 + return nsFrameState(nsFrameState_size_t(aLeft) & nsFrameState_size_t(aRight)); 1.65 +} 1.66 + 1.67 +inline nsFrameState& operator|=(nsFrameState& aLeft, nsFrameState aRight) 1.68 +{ 1.69 + aLeft = aLeft | aRight; 1.70 + return aLeft; 1.71 +} 1.72 + 1.73 +inline nsFrameState& operator&=(nsFrameState& aLeft, nsFrameState aRight) 1.74 +{ 1.75 + aLeft = aLeft & aRight; 1.76 + return aLeft; 1.77 +} 1.78 + 1.79 +inline nsFrameState operator~(nsFrameState aRight) 1.80 +{ 1.81 + return nsFrameState(~nsFrameState_size_t(aRight)); 1.82 +} 1.83 + 1.84 +inline nsFrameState operator^(nsFrameState aLeft, nsFrameState aRight) 1.85 +{ 1.86 + return nsFrameState(nsFrameState_size_t(aLeft) ^ nsFrameState_size_t(aRight)); 1.87 +} 1.88 + 1.89 +inline nsFrameState& operator^=(nsFrameState& aLeft, nsFrameState aRight) 1.90 +{ 1.91 + aLeft = aLeft ^ aRight; 1.92 + return aLeft; 1.93 +} 1.94 + 1.95 +#endif 1.96 + 1.97 +// Bits 20-31 and 60-63 of the frame state are reserved for implementations. 1.98 +#define NS_FRAME_IMPL_RESERVED nsFrameState(0xF0000000FFF00000) 1.99 +#define NS_FRAME_RESERVED ~NS_FRAME_IMPL_RESERVED 1.100 + 1.101 +namespace mozilla { 1.102 +#ifdef DEBUG 1.103 +nsCString GetFrameState(nsIFrame* aFrame); 1.104 +void PrintFrameState(nsIFrame* aFrame); 1.105 +#endif 1.106 +} 1.107 + 1.108 +#endif /* nsFrameState_h_ */