Bug 900090 - make various bits of nsEventStates constexpr to avoid static constructors; r=smaug

This commit is contained in:
Nathan Froyd 2013-07-31 13:08:35 -04:00
parent 21f1c1c878
commit 440166ff00

View File

@ -6,6 +6,7 @@
#ifndef nsEventStates_h__
#define nsEventStates_h__
#include "mozilla/Attributes.h"
#include "nsDebug.h"
/**
@ -20,7 +21,7 @@ class nsEventStates
public:
typedef uint64_t InternalType;
nsEventStates()
MOZ_CONSTEXPR nsEventStates()
: mStates(0)
{ }
@ -29,12 +30,12 @@ public:
// In that case, we could be sure that only macros at the end were creating
// nsEventStates instances with mStates set to something else than 0.
// Unfortunately, this constructor is needed at at least two places now.
explicit nsEventStates(InternalType aStates)
explicit MOZ_CONSTEXPR nsEventStates(InternalType aStates)
: mStates(aStates)
{ }
nsEventStates(const nsEventStates& aEventStates) {
mStates = aEventStates.mStates;
MOZ_CONSTEXPR nsEventStates(const nsEventStates& aEventStates)
: mStates(aEventStates.mStates) {
}
nsEventStates& operator=(const nsEventStates& aEventStates) {
@ -42,7 +43,7 @@ public:
return *this;
}
nsEventStates operator|(const nsEventStates& aEventStates) const {
nsEventStates MOZ_CONSTEXPR operator|(const nsEventStates& aEventStates) const {
return nsEventStates(mStates | aEventStates.mStates);
}
@ -54,7 +55,7 @@ public:
// NOTE: calling if (eventStates1 & eventStates2) will not build.
// This might work correctly if operator bool() is defined
// but using HasState, HasAllStates or HasAtLeastOneOfStates is recommended.
nsEventStates operator&(const nsEventStates& aEventStates) const {
nsEventStates MOZ_CONSTEXPR operator&(const nsEventStates& aEventStates) const {
return nsEventStates(mStates & aEventStates.mStates);
}