Bug 823369 Check mozilla::widget::EventFlags size at compile time r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Sat, 22 Dec 2012 00:07:08 +0900
changeset 125878 e797fe5eb621b5d4324c7493098818e25a383331
parent 125877 21409a401d755e20739803a2bf20db4ae6c7d914
child 125879 41c781b02e4b05f303ab40ca1018ba12af6d88a6
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs823369
milestone20.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 823369 Check mozilla::widget::EventFlags size at compile time r=smaug
widget/nsGUIEvent.h
--- a/widget/nsGUIEvent.h
+++ b/widget/nsGUIEvent.h
@@ -559,23 +559,27 @@ public:
   }
   inline EventFlags& operator|=(const EventFlags& aOther)
   {
     SetRawFlags(GetRawFlags() | aOther.GetRawFlags());
     return *this;
   }
 
 private:
-  inline void SetRawFlags(uint32_t aRawFlags)
+  typedef uint32_t RawFlags;
+
+  inline void SetRawFlags(RawFlags aRawFlags)
   {
+    MOZ_STATIC_ASSERT(sizeof(EventFlags) <= sizeof(RawFlags),
+      "mozilla::widget::EventFlags must not be bigger than the RawFlags");
     memcpy(this, &aRawFlags, sizeof(EventFlags));
   }
-  inline uint32_t GetRawFlags() const
+  inline RawFlags GetRawFlags() const
   {
-    uint32_t result = 0;
+    RawFlags result = 0;
     memcpy(&result, this, sizeof(EventFlags));
     return result;
   }
 };
 } // namespace widget
 } // namespace mozilla
 
 /**