Bug 900090 - make various bits of nsEventStates constexpr to avoid static constructors; r=smaug
authorNathan Froyd <froydnj@mozilla.com>
Wed, 31 Jul 2013 13:08:35 -0400
changeset 153254 acd3d7236e945d9ee6374e8dea18d5a1026db150
parent 153253 3934bfa0985cde0aca7dfc313dd159daafd9c077
child 153255 ce80cccb2e62e30667d36c112dbfdef434bbd8c4
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs900090
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 900090 - make various bits of nsEventStates constexpr to avoid static constructors; r=smaug
content/events/public/nsEventStates.h
--- a/content/events/public/nsEventStates.h
+++ b/content/events/public/nsEventStates.h
@@ -1,65 +1,66 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsEventStates_h__
 #define nsEventStates_h__
 
+#include "mozilla/Attributes.h"
 #include "nsDebug.h"
 
 /**
  * nsEventStates is the class used to represent the event states of nsIContent
  * instances. These states are calculated by IntrinsicState() and
  * ContentStatesChanged() has to be called when one of them changes thus
  * informing the layout/style engine of the change.
  * Event states are associated with pseudo-classes.
  */
 class nsEventStates
 {
 public:
   typedef uint64_t InternalType;
 
-  nsEventStates()
+  MOZ_CONSTEXPR nsEventStates()
     : mStates(0)
   { }
 
   // NOTE: the ideal scenario would be to have the default constructor public
   // setting mStates to 0 and this constructor (without = 0) private.
   // 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) {
     mStates = aEventStates.mStates;
     return *this;
   }
 
-  nsEventStates operator|(const nsEventStates& aEventStates) const {
+  nsEventStates MOZ_CONSTEXPR operator|(const nsEventStates& aEventStates) const {
     return nsEventStates(mStates | aEventStates.mStates);
   }
 
   nsEventStates& operator|=(const nsEventStates& aEventStates) {
     mStates |= aEventStates.mStates;
     return *this;
   }
 
   // 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);
   }
 
   nsEventStates& operator&=(const nsEventStates& aEventStates) {
     mStates &= aEventStates.mStates;
     return *this;
   }