Bug 1259661 part.1 Rename WidgetMouseEvent::reasonType to WidgetMouseEvent::Reason r?smaug draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 12 May 2016 11:17:46 +0900
changeset 366153 58305746a0f69835b2461f5d8df2dff772dccd1b
parent 365730 3461f3cae78495f100a0f7d3d2e0b89292d3ec02
child 366154 cbfe714cba78cbb088ae5295c910efe12eac98f7
push id17909
push usermasayuki@d-toybox.com
push dateThu, 12 May 2016 03:02:36 +0000
reviewerssmaug
bugs1259661
milestone49.0a1
Bug 1259661 part.1 Rename WidgetMouseEvent::reasonType to WidgetMouseEvent::Reason r?smaug MozReview-Commit-ID: 3bx2Z32rwb1
widget/MouseEvents.h
widget/nsGUIEventIPC.h
--- a/widget/MouseEvents.h
+++ b/widget/MouseEvents.h
@@ -176,17 +176,18 @@ public:
 
 class WidgetMouseEvent : public WidgetMouseEventBase, public WidgetPointerHelper
 {
 private:
   friend class mozilla::dom::PBrowserParent;
   friend class mozilla::dom::PBrowserChild;
 
 public:
-  enum reasonType
+  typedef bool ReasonType;
+  enum Reason : ReasonType
   {
     eReal,
     eSynthesized
   };
 
   enum contextType
   {
     eNormal,
@@ -196,42 +197,47 @@ public:
   enum exitType
   {
     eChild,
     eTopLevel
   };
 
 protected:
   WidgetMouseEvent()
-    : acceptActivation(false)
+    : reason(eReal)
+    , acceptActivation(false)
     , ignoreRootScrollFrame(false)
     , clickCount(0)
   {
   }
 
   WidgetMouseEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget,
-                   EventClassID aEventClassID, reasonType aReason)
+                   EventClassID aEventClassID, Reason aReason)
     : WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, aEventClassID)
+    , reason(aReason)
     , acceptActivation(false)
     , ignoreRootScrollFrame(false)
-    , reason(aReason)
     , context(eNormal)
     , exit(eChild)
     , clickCount(0)
   {
   }
 
 public:
   virtual WidgetMouseEvent* AsMouseEvent() override { return this; }
 
   WidgetMouseEvent(bool aIsTrusted, EventMessage aMessage, nsIWidget* aWidget,
-                   reasonType aReason, contextType aContext = eNormal) :
-    WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, eMouseEventClass),
-    acceptActivation(false), ignoreRootScrollFrame(false),
-    reason(aReason), context(aContext), exit(eChild), clickCount(0)
+                   Reason aReason, contextType aContext = eNormal)
+    : WidgetMouseEventBase(aIsTrusted, aMessage, aWidget, eMouseEventClass)
+    , reason(aReason)
+    , acceptActivation(false)
+    , ignoreRootScrollFrame(false)
+    , context(aContext)
+    , exit(eChild)
+    , clickCount(0)
   {
     if (aMessage == eContextMenu) {
       button = (context == eNormal) ? eRightButton : eLeftButton;
     }
   }
 
 #ifdef DEBUG
   virtual ~WidgetMouseEvent()
@@ -250,23 +256,24 @@ public:
     // Not copying widget, it is a weak reference.
     WidgetMouseEvent* result =
       new WidgetMouseEvent(false, mMessage, nullptr, reason, context);
     result->AssignMouseEventData(*this, true);
     result->mFlags = mFlags;
     return result;
   }
 
+  Reason reason;
+
   // Special return code for MOUSE_ACTIVATE to signal.
   // If the target accepts activation (1), or denies it (0).
   bool acceptActivation;
   // Whether the event should ignore scroll frame bounds during dispatch.
   bool ignoreRootScrollFrame;
 
-  reasonType reason : 4;
   contextType context : 4;
   exitType exit;
 
   /// The number of mouse clicks.
   uint32_t clickCount;
 
   void AssignMouseEventData(const WidgetMouseEvent& aEvent, bool aCopyTargets)
   {
--- a/widget/nsGUIEventIPC.h
+++ b/widget/nsGUIEventIPC.h
@@ -226,35 +226,35 @@ template<>
 struct ParamTraits<mozilla::WidgetMouseEvent>
 {
   typedef mozilla::WidgetMouseEvent paramType;
 
   static void Write(Message* aMsg, const paramType& aParam)
   {
     WriteParam(aMsg, static_cast<mozilla::WidgetMouseEventBase>(aParam));
     WriteParam(aMsg, aParam.ignoreRootScrollFrame);
-    WriteParam(aMsg, (uint8_t) aParam.reason);
+    WriteParam(aMsg, static_cast<paramType::ReasonType>(aParam.reason));
     WriteParam(aMsg, (uint8_t) aParam.context);
     WriteParam(aMsg, (uint8_t) aParam.exit);
     WriteParam(aMsg, aParam.clickCount);
   }
 
   static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
   {
     bool rv;
-    uint8_t reason = 0, context = 0, exit = 0;
+    paramType::ReasonType reason = 0;
+    uint8_t context = 0, exit = 0;
     rv = ReadParam(aMsg, aIter,
                    static_cast<mozilla::WidgetMouseEventBase*>(aResult)) &&
          ReadParam(aMsg, aIter, &aResult->ignoreRootScrollFrame) &&
          ReadParam(aMsg, aIter, &reason) &&
          ReadParam(aMsg, aIter, &context) &&
          ReadParam(aMsg, aIter, &exit) &&
          ReadParam(aMsg, aIter, &aResult->clickCount);
-    aResult->reason =
-      static_cast<mozilla::WidgetMouseEvent::reasonType>(reason);
+    aResult->reason = static_cast<paramType::Reason>(reason);
     aResult->context =
       static_cast<mozilla::WidgetMouseEvent::contextType>(context);
     aResult->exit = static_cast<mozilla::WidgetMouseEvent::exitType>(exit);
     return rv;
   }
 };