Bug 971489 Simplify constructor of WidgetSimpleGestureEvent r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Sat, 15 Feb 2014 10:06:06 +0900
changeset 186090 e5ac6baf6d0b6334a31fa5cc9eefac254e614321
parent 186089 07bb55ce62e3272c06faf2c9d03e5e879051ee62
child 186091 3a17ca9fd87db91e5098fbba2fa3aa361bab7f30
push id3503
push userraliiev@mozilla.com
push dateMon, 28 Apr 2014 18:51:11 +0000
treeherdermozilla-beta@c95ac01e332e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs971489
milestone30.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 971489 Simplify constructor of WidgetSimpleGestureEvent r=smaug
dom/base/nsDOMWindowUtils.cpp
dom/events/nsDOMSimpleGestureEvent.cpp
widget/TouchEvents.h
widget/android/nsWindow.cpp
widget/cocoa/nsChildView.mm
widget/windows/nsWindow.cpp
widget/windows/winrt/MetroInput.cpp
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -1466,18 +1466,20 @@ nsDOMWindowUtils::SendSimpleGestureEvent
     msg = NS_SIMPLE_GESTURE_EDGE_STARTED;
   else if (aType.EqualsLiteral("MozEdgeUICanceled"))
     msg = NS_SIMPLE_GESTURE_EDGE_CANCELED;
   else if (aType.EqualsLiteral("MozEdgeUICompleted"))
     msg = NS_SIMPLE_GESTURE_EDGE_COMPLETED;
   else
     return NS_ERROR_FAILURE;
  
-  WidgetSimpleGestureEvent event(true, msg, widget, aDirection, aDelta);
+  WidgetSimpleGestureEvent event(true, msg, widget);
   event.modifiers = GetWidgetModifiers(aModifiers);
+  event.direction = aDirection;
+  event.delta = aDelta;
   event.clickCount = aClickCount;
   event.time = PR_IntervalNow();
 
   nsPresContext* presContext = GetPresContext();
   if (!presContext)
     return NS_ERROR_FAILURE;
 
   event.refPoint = ToWidgetPoint(CSSPoint(aX, aY), offset, presContext);
--- a/dom/events/nsDOMSimpleGestureEvent.cpp
+++ b/dom/events/nsDOMSimpleGestureEvent.cpp
@@ -9,18 +9,17 @@
 
 using namespace mozilla;
 
 nsDOMSimpleGestureEvent::nsDOMSimpleGestureEvent(mozilla::dom::EventTarget* aOwner,
                                                  nsPresContext* aPresContext,
                                                  WidgetSimpleGestureEvent* aEvent)
   : nsDOMMouseEvent(aOwner, aPresContext,
                     aEvent ? aEvent :
-                             new WidgetSimpleGestureEvent(false, 0, nullptr,
-                                                          0, 0.0))
+                             new WidgetSimpleGestureEvent(false, 0, nullptr))
 {
   NS_ASSERTION(mEvent->eventStructType == NS_SIMPLE_GESTURE_EVENT, "event type mismatch");
 
   if (aEvent) {
     mEventIsInternal = false;
   } else {
     mEventIsInternal = true;
     mEvent->time = PR_Now();
--- a/widget/TouchEvents.h
+++ b/widget/TouchEvents.h
@@ -70,40 +70,43 @@ class WidgetSimpleGestureEvent : public 
 {
 public:
   virtual WidgetSimpleGestureEvent* AsSimpleGestureEvent() MOZ_OVERRIDE
   {
     return this;
   }
 
   WidgetSimpleGestureEvent(bool aIsTrusted, uint32_t aMessage,
-                           nsIWidget* aWidget, uint32_t aDirection,
-                           double aDelta) :
-    WidgetMouseEventBase(aIsTrusted, aMessage, aWidget,
-                         NS_SIMPLE_GESTURE_EVENT),
-    allowedDirections(0), direction(aDirection), delta(aDelta), clickCount(0)
+                           nsIWidget* aWidget)
+    : WidgetMouseEventBase(aIsTrusted, aMessage, aWidget,
+                           NS_SIMPLE_GESTURE_EVENT)
+    , allowedDirections(0)
+    , direction(0)
+    , delta(0.0)
+    , clickCount(0)
   {
   }
 
-  WidgetSimpleGestureEvent(const WidgetSimpleGestureEvent& aOther) :
-    WidgetMouseEventBase(aOther.mFlags.mIsTrusted,
-                         aOther.message, aOther.widget,
-                         NS_SIMPLE_GESTURE_EVENT),
-    allowedDirections(aOther.allowedDirections), direction(aOther.direction),
-    delta(aOther.delta), clickCount(0)
+  WidgetSimpleGestureEvent(const WidgetSimpleGestureEvent& aOther)
+    : WidgetMouseEventBase(aOther.mFlags.mIsTrusted, aOther.message,
+                           aOther.widget, NS_SIMPLE_GESTURE_EVENT)
+    , allowedDirections(aOther.allowedDirections)
+    , direction(aOther.direction)
+    , delta(aOther.delta)
+    , clickCount(0)
   {
   }
 
   virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
   {
     MOZ_ASSERT(eventStructType == NS_SIMPLE_GESTURE_EVENT,
                "Duplicate() must be overridden by sub class");
     // Not copying widget, it is a weak reference.
     WidgetSimpleGestureEvent* result =
-      new WidgetSimpleGestureEvent(false, message, nullptr, direction, delta);
+      new WidgetSimpleGestureEvent(false, message, nullptr);
     result->AssignSimpleGestureEventData(*this, true);
     result->mFlags = mFlags;
     return result;
   }
 
   // See nsIDOMSimpleGestureEvent for values
   uint32_t allowedDirections;
   // See nsIDOMSimpleGestureEvent for values
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1244,18 +1244,20 @@ nsWindow::OnNativeGestureEvent(AndroidGe
   nsRefPtr<nsWindow> kungFuDeathGrip(this);
   DispatchGestureEvent(msg, 0, delta, pt, ae->Time());
 }
 
 void
 nsWindow::DispatchGestureEvent(uint32_t msg, uint32_t direction, double delta,
                                const nsIntPoint &refPoint, uint64_t time)
 {
-    WidgetSimpleGestureEvent event(true, msg, this, direction, delta);
+    WidgetSimpleGestureEvent event(true, msg, this);
 
+    event.direction = direction;
+    event.delta = delta;
     event.modifiers = 0;
     event.time = time;
     event.refPoint = LayoutDeviceIntPoint::FromUntyped(refPoint);
 
     DispatchEvent(&event);
 }
 
 
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -3987,17 +3987,17 @@ NSEvent* gLastDragMouseDownEvent = nil;
 
   nsAutoRetainCocoaObject kungFuDeathGrip(self);
 
   float deltaX = [anEvent deltaX];  // left=1.0, right=-1.0
   float deltaY = [anEvent deltaY];  // up=1.0, down=-1.0
 
   // Setup the "swipe" event.
   WidgetSimpleGestureEvent geckoEvent(true, NS_SIMPLE_GESTURE_SWIPE,
-                                      mGeckoChild, 0, 0.0);
+                                      mGeckoChild);
   [self convertCocoaMouseEvent:anEvent toGeckoEvent:&geckoEvent];
 
   // Record the left/right direction.
   if (deltaX > 0.0)
     geckoEvent.direction |= nsIDOMSimpleGestureEvent::DIRECTION_LEFT;
   else if (deltaX < 0.0)
     geckoEvent.direction |= nsIDOMSimpleGestureEvent::DIRECTION_RIGHT;
 
@@ -4056,17 +4056,18 @@ NSEvent* gLastDragMouseDownEvent = nil;
 
   case eGestureState_None:
   case eGestureState_RotateGesture:
   default:
     return;
   }
 
   // Setup the event.
-  WidgetSimpleGestureEvent geckoEvent(true, msg, mGeckoChild, 0, deltaZ);
+  WidgetSimpleGestureEvent geckoEvent(true, msg, mGeckoChild);
+  geckoEvent.delta = deltaZ;
   [self convertCocoaMouseEvent:anEvent toGeckoEvent:&geckoEvent];
 
   // Send the event.
   mGeckoChild->DispatchWindowEvent(geckoEvent);
 
   // Keep track of the cumulative magnification for the final "magnify" event.
   mCumulativeMagnification += deltaZ;
   
@@ -4080,17 +4081,17 @@ NSEvent* gLastDragMouseDownEvent = nil;
   if (!anEvent || !mGeckoChild) {
     return;
   }
 
   nsAutoRetainCocoaObject kungFuDeathGrip(self);
 
   // Setup the "double tap" event.
   WidgetSimpleGestureEvent geckoEvent(true, NS_SIMPLE_GESTURE_TAP,
-                                      mGeckoChild, 0, 0.0);
+                                      mGeckoChild);
   [self convertCocoaMouseEvent:anEvent toGeckoEvent:&geckoEvent];
   geckoEvent.clickCount = 1;
 
   // Send the event.
   mGeckoChild->DispatchWindowEvent(geckoEvent);
 
   // Clear the gesture state
   mGestureState = eGestureState_None;
@@ -4122,17 +4123,17 @@ NSEvent* gLastDragMouseDownEvent = nil;
 
   case eGestureState_None:
   case eGestureState_MagnifyGesture:
   default:
     return;
   }
 
   // Setup the event.
-  WidgetSimpleGestureEvent geckoEvent(true, msg, mGeckoChild, 0, 0.0);
+  WidgetSimpleGestureEvent geckoEvent(true, msg, mGeckoChild);
   [self convertCocoaMouseEvent:anEvent toGeckoEvent:&geckoEvent];
   geckoEvent.delta = -rotation;
   if (rotation > 0.0) {
     geckoEvent.direction = nsIDOMSimpleGestureEvent::ROTATION_COUNTERCLOCKWISE;
   } else {
     geckoEvent.direction = nsIDOMSimpleGestureEvent::ROTATION_CLOCKWISE;
   }
 
@@ -4159,30 +4160,30 @@ NSEvent* gLastDragMouseDownEvent = nil;
 
   nsAutoRetainCocoaObject kungFuDeathGrip(self);
 
   switch (mGestureState) {
   case eGestureState_MagnifyGesture:
     {
       // Setup the "magnify" event.
       WidgetSimpleGestureEvent geckoEvent(true, NS_SIMPLE_GESTURE_MAGNIFY,
-                                          mGeckoChild, 0,
-                                          mCumulativeMagnification);
+                                          mGeckoChild);
+      geckoEvent.delta = mCumulativeMagnification;
       [self convertCocoaMouseEvent:anEvent toGeckoEvent:&geckoEvent];
 
       // Send the event.
       mGeckoChild->DispatchWindowEvent(geckoEvent);
     }
     break;
 
   case eGestureState_RotateGesture:
     {
       // Setup the "rotate" event.
       WidgetSimpleGestureEvent geckoEvent(true, NS_SIMPLE_GESTURE_ROTATE,
-                                          mGeckoChild, 0, 0.0);
+                                          mGeckoChild);
       [self convertCocoaMouseEvent:anEvent toGeckoEvent:&geckoEvent];
       geckoEvent.delta = -mCumulativeRotation;
       if (mCumulativeRotation > 0.0) {
         geckoEvent.direction = nsIDOMSimpleGestureEvent::ROTATION_COUNTERCLOCKWISE;
       } else {
         geckoEvent.direction = nsIDOMSimpleGestureEvent::ROTATION_CLOCKWISE;
       }
 
@@ -4226,18 +4227,19 @@ NSEvent* gLastDragMouseDownEvent = nil;
                 withKind:(uint32_t)aMsg
        allowedDirections:(uint32_t*)aAllowedDirections
                direction:(uint32_t)aDirection
                    delta:(double)aDelta
 {
   if (!mGeckoChild)
     return false;
 
-  WidgetSimpleGestureEvent geckoEvent(true, aMsg, mGeckoChild,
-                                      aDirection, aDelta);
+  WidgetSimpleGestureEvent geckoEvent(true, aMsg, mGeckoChild);
+  geckoEvent.direction = aDirection;
+  geckoEvent.delta = aDelta;
   geckoEvent.allowedDirections = *aAllowedDirections;
   [self convertCocoaMouseEvent:aEvent toGeckoEvent:&geckoEvent];
   bool eventCancelled = mGeckoChild->DispatchWindowEvent(geckoEvent);
   *aAllowedDirections = geckoEvent.allowedDirections;
   return eventCancelled; // event cancelled == swipe should start
 }
 
 - (void)sendSwipeEndEvent:(NSEvent *)anEvent
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -6126,17 +6126,17 @@ bool nsWindow::OnGesture(WPARAM wParam, 
     }
 
     mGesture.CloseGestureInfoHandle((HGESTUREINFO)lParam);
 
     return true;
   }
 
   // Other gestures translate into simple gesture events:
-  WidgetSimpleGestureEvent event(true, 0, this, 0, 0.0);
+  WidgetSimpleGestureEvent event(true, 0, this);
   if ( !mGesture.ProcessGestureMessage(mWnd, wParam, lParam, event) ) {
     return false; // fall through to DefWndProc
   }
   
   // Polish up and send off the new event
   ModifierKeyState modifierKeyState;
   modifierKeyState.InitInputEvent(event);
   event.button    = 0;
--- a/widget/windows/winrt/MetroInput.cpp
+++ b/widget/windows/winrt/MetroInput.cpp
@@ -350,19 +350,17 @@ HRESULT
 MetroInput::OnEdgeGestureStarted(UI::Input::IEdgeGesture* sender,
                                  UI::Input::IEdgeGestureEventArgs* aArgs)
 {
 #ifdef DEBUG_INPUT
   LogFunction();
 #endif
   WidgetSimpleGestureEvent geckoEvent(true,
                                       NS_SIMPLE_GESTURE_EDGE_STARTED,
-                                      mWidget.Get(),
-                                      0,
-                                      0.0);
+                                      mWidget.Get());
   mModifierKeyState.Update();
   mModifierKeyState.InitInputEvent(geckoEvent);
   geckoEvent.time = ::GetMessageTime();
   geckoEvent.inputSource = ProcessInputTypeForGesture(aArgs);
 
   // Safe
   DispatchEventIgnoreStatus(&geckoEvent);
   return S_OK;
@@ -381,19 +379,17 @@ HRESULT
 MetroInput::OnEdgeGestureCanceled(UI::Input::IEdgeGesture* sender,
                                   UI::Input::IEdgeGestureEventArgs* aArgs)
 {
 #ifdef DEBUG_INPUT
   LogFunction();
 #endif
   WidgetSimpleGestureEvent geckoEvent(true,
                                       NS_SIMPLE_GESTURE_EDGE_CANCELED,
-                                      mWidget.Get(),
-                                      0,
-                                      0.0);
+                                      mWidget.Get());
   mModifierKeyState.Update();
   mModifierKeyState.InitInputEvent(geckoEvent);
   geckoEvent.time = ::GetMessageTime();
   geckoEvent.inputSource = ProcessInputTypeForGesture(aArgs);
 
   // Safe
   DispatchEventIgnoreStatus(&geckoEvent);
   return S_OK;
@@ -411,19 +407,17 @@ HRESULT
 MetroInput::OnEdgeGestureCompleted(UI::Input::IEdgeGesture* sender,
                                    UI::Input::IEdgeGestureEventArgs* aArgs)
 {
 #ifdef DEBUG_INPUT
   LogFunction();
 #endif
   WidgetSimpleGestureEvent geckoEvent(true,
                                       NS_SIMPLE_GESTURE_EDGE_COMPLETED,
-                                      mWidget.Get(),
-                                      0,
-                                      0.0);
+                                      mWidget.Get());
   mModifierKeyState.Update();
   mModifierKeyState.InitInputEvent(geckoEvent);
   geckoEvent.time = ::GetMessageTime();
   geckoEvent.inputSource = ProcessInputTypeForGesture(aArgs);
 
   // Safe
   DispatchEventIgnoreStatus(&geckoEvent);
   return S_OK;
@@ -933,30 +927,30 @@ MetroInput::OnManipulationCompleted(
   // should just ignore the input.
   if (isHorizontalSwipe && isVerticalSwipe) {
     return S_OK;
   }
 
   if (isHorizontalSwipe) {
     WidgetSimpleGestureEvent* swipeEvent =
       new WidgetSimpleGestureEvent(true, NS_SIMPLE_GESTURE_SWIPE,
-                                   mWidget.Get(), 0, 0.0);
+                                   mWidget.Get());
     swipeEvent->direction = delta.Translation.X > 0
                          ? nsIDOMSimpleGestureEvent::DIRECTION_RIGHT
                          : nsIDOMSimpleGestureEvent::DIRECTION_LEFT;
     swipeEvent->delta = delta.Translation.X;
     swipeEvent->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
     swipeEvent->refPoint = LayoutDeviceIntPoint::FromUntyped(MetroUtils::LogToPhys(position));
     DispatchAsyncEventIgnoreStatus(swipeEvent);
   }
 
   if (isVerticalSwipe) {
     WidgetSimpleGestureEvent* swipeEvent =
       new WidgetSimpleGestureEvent(true, NS_SIMPLE_GESTURE_SWIPE,
-                                   mWidget.Get(), 0, 0.0);
+                                   mWidget.Get());
     swipeEvent->direction = delta.Translation.Y > 0
                          ? nsIDOMSimpleGestureEvent::DIRECTION_DOWN
                          : nsIDOMSimpleGestureEvent::DIRECTION_UP;
     swipeEvent->delta = delta.Translation.Y;
     swipeEvent->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
     swipeEvent->refPoint = LayoutDeviceIntPoint::FromUntyped(MetroUtils::LogToPhys(position));
     DispatchAsyncEventIgnoreStatus(swipeEvent);
   }