Bug 1494671 - Make the CompositorHitTestInfo globals constexpr. r=froydnj
authorBotond Ballo <botond@mozilla.com>
Mon, 01 Oct 2018 20:09:10 +0000
changeset 494798 8fb46c61e091b2b812ebeee76466abb520cf4f85
parent 494797 dd9071744c9f93df9891ea5ca1a203594be815d2
child 494799 cb01170872de75622282968dbc8bccaab391be0d
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1494671
milestone64.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 1494671 - Make the CompositorHitTestInfo globals constexpr. r=froydnj Depends on D7323 Differential Revision: https://phabricator.services.mozilla.com/D7324
gfx/src/CompositorHitTestInfo.h
mfbt/EnumSet.h
--- a/gfx/src/CompositorHitTestInfo.h
+++ b/gfx/src/CompositorHitTestInfo.h
@@ -47,24 +47,24 @@ enum class CompositorHitTestFlags : uint
   // is received within a timeout period, the event may be dropped.
   // Only meaningful in combination with eDispatchToContent.
   eRequiresTargetConfirmation,
 };
 
 using CompositorHitTestInfo = EnumSet<CompositorHitTestFlags, uint32_t>;
 
 // A CompositorHitTestInfo with none of the flags set
-const CompositorHitTestInfo CompositorHitTestInvisibleToHit;
+constexpr CompositorHitTestInfo CompositorHitTestInvisibleToHit;
 
 // Mask to check for all the touch-action flags at once
-const CompositorHitTestInfo CompositorHitTestTouchActionMask =
-  CompositorHitTestInfo(CompositorHitTestFlags::eTouchActionPanXDisabled) +
-  CompositorHitTestInfo(CompositorHitTestFlags::eTouchActionPanYDisabled) +
-  CompositorHitTestInfo(CompositorHitTestFlags::eTouchActionPinchZoomDisabled) +
-  CompositorHitTestInfo(CompositorHitTestFlags::eTouchActionDoubleTapZoomDisabled);
+constexpr CompositorHitTestInfo CompositorHitTestTouchActionMask(
+  CompositorHitTestFlags::eTouchActionPanXDisabled,
+  CompositorHitTestFlags::eTouchActionPanYDisabled,
+  CompositorHitTestFlags::eTouchActionPinchZoomDisabled,
+  CompositorHitTestFlags::eTouchActionDoubleTapZoomDisabled);
 
 } // namespace gfx
 
 
 // Used for IPDL serialization. The 'value' have to be the biggest enum from CompositorHitTestFlags.
 template <>
 struct MaxEnumValue<::mozilla::gfx::CompositorHitTestFlags>
 {
--- a/mfbt/EnumSet.h
+++ b/mfbt/EnumSet.h
@@ -26,55 +26,55 @@ namespace mozilla {
  */
 template<typename T,
          typename Serialized = typename std::make_unsigned<typename std::underlying_type<T>::type>::type>
 class EnumSet
 {
 public:
   typedef T valueType;
 
-  EnumSet()
+  constexpr EnumSet()
     : mBitField(0)
   {
   }
 
-  MOZ_IMPLICIT EnumSet(T aEnum)
+  constexpr MOZ_IMPLICIT EnumSet(T aEnum)
     : mBitField(bitFor(aEnum))
   { }
 
-  EnumSet(T aEnum1, T aEnum2)
+  constexpr EnumSet(T aEnum1, T aEnum2)
     : mBitField(bitFor(aEnum1) |
                 bitFor(aEnum2))
   {
   }
 
-  EnumSet(T aEnum1, T aEnum2, T aEnum3)
+  constexpr EnumSet(T aEnum1, T aEnum2, T aEnum3)
     : mBitField(bitFor(aEnum1) |
                 bitFor(aEnum2) |
                 bitFor(aEnum3))
   {
   }
 
-  EnumSet(T aEnum1, T aEnum2, T aEnum3, T aEnum4)
+  constexpr EnumSet(T aEnum1, T aEnum2, T aEnum3, T aEnum4)
     : mBitField(bitFor(aEnum1) |
                 bitFor(aEnum2) |
                 bitFor(aEnum3) |
                 bitFor(aEnum4))
   {
   }
 
   MOZ_IMPLICIT EnumSet(std::initializer_list<T> list)
     : mBitField(0)
   {
     for (auto value : list) {
       (*this) += value;
     }
   }
 
-  EnumSet(const EnumSet& aEnumSet)
+  constexpr EnumSet(const EnumSet& aEnumSet)
     : mBitField(aEnumSet.mBitField)
   {
   }
 
   /**
    * Add an element
    */
   void operator+=(T aEnum)
@@ -337,17 +337,17 @@ public:
     return ConstIterator(*this, 0);
   }
 
   ConstIterator end() const {
     return ConstIterator(*this, kMaxBits);
   }
 
 private:
-  static Serialized bitFor(T aEnum)
+  constexpr static Serialized bitFor(T aEnum)
   {
     auto bitNumber = static_cast<Serialized>(aEnum);
     MOZ_DIAGNOSTIC_ASSERT(bitNumber < kMaxBits);
     return Serialized(1) << bitNumber;
   }
 
   void incVersion() {
 #ifdef DEBUG