mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 977991 patch 0 - Add bitwise operators to nsRestyleHint. r=birtles
This avoids having to cast back to nsRestyleHint after using bitwise operators, and allows |= (etc.). (In the future we should consider converting nsRestyleHint, and probably also nsChangeHint, to use MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS.)
This commit is contained in:
parent
e5f6879ca0
commit
81bd9c7023
@ -9,6 +9,7 @@
|
||||
#define nsChangeHint_h___
|
||||
|
||||
#include "nsDebug.h"
|
||||
#include "mozilla/Types.h"
|
||||
|
||||
// Defines for various style related constants
|
||||
|
||||
@ -322,5 +323,46 @@ enum nsRestyleHint {
|
||||
eRestyle_ForceDescendants = (1<<9),
|
||||
};
|
||||
|
||||
// The functions below need an integral type to cast to to avoid
|
||||
// infinite recursion.
|
||||
typedef decltype(nsRestyleHint(0) + nsRestyleHint(0)) nsRestyleHint_size_t;
|
||||
|
||||
inline nsRestyleHint operator|(nsRestyleHint aLeft, nsRestyleHint aRight)
|
||||
{
|
||||
return nsRestyleHint(nsRestyleHint_size_t(aLeft) |
|
||||
nsRestyleHint_size_t(aRight));
|
||||
}
|
||||
|
||||
inline nsRestyleHint operator&(nsRestyleHint aLeft, nsRestyleHint aRight)
|
||||
{
|
||||
return nsRestyleHint(nsRestyleHint_size_t(aLeft) &
|
||||
nsRestyleHint_size_t(aRight));
|
||||
}
|
||||
|
||||
inline nsRestyleHint& operator|=(nsRestyleHint& aLeft, nsRestyleHint aRight)
|
||||
{
|
||||
return aLeft = aLeft | aRight;
|
||||
}
|
||||
|
||||
inline nsRestyleHint& operator&=(nsRestyleHint& aLeft, nsRestyleHint aRight)
|
||||
{
|
||||
return aLeft = aLeft & aRight;
|
||||
}
|
||||
|
||||
inline nsRestyleHint operator~(nsRestyleHint aArg)
|
||||
{
|
||||
return nsRestyleHint(~nsRestyleHint_size_t(aArg));
|
||||
}
|
||||
|
||||
inline nsRestyleHint operator^(nsRestyleHint aLeft, nsRestyleHint aRight)
|
||||
{
|
||||
return nsRestyleHint(nsRestyleHint_size_t(aLeft) ^
|
||||
nsRestyleHint_size_t(aRight));
|
||||
}
|
||||
|
||||
inline nsRestyleHint operator^=(nsRestyleHint& aLeft, nsRestyleHint aRight)
|
||||
{
|
||||
return aLeft = aLeft ^ aRight;
|
||||
}
|
||||
|
||||
#endif /* nsChangeHint_h___ */
|
||||
|
Loading…
Reference in New Issue
Block a user