Bug 1332195 part.1 Event handlers in TabChild, TabParent and PuppetWidget should use "a" prefix for their arguments r?smaug draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 19 Jan 2017 17:27:15 +0900
changeset 463674 cf8efa2da8036426444a35b944293ceff82ac091
parent 463673 be51f9da589a19ab79a30df2ff7f20f09f7dd758
child 463675 aece179607ce169a275fdf085a8ba15d31bd79b7
push id42140
push usermasayuki@d-toybox.com
push dateThu, 19 Jan 2017 15:28:39 +0000
reviewerssmaug
bugs1332195
milestone53.0a1
Bug 1332195 part.1 Event handlers in TabChild, TabParent and PuppetWidget should use "a" prefix for their arguments r?smaug MozReview-Commit-ID: 2c7cbOigwfU
dom/ipc/TabChild.cpp
dom/ipc/TabParent.cpp
dom/ipc/TabParent.h
widget/PuppetWidget.cpp
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -1820,50 +1820,50 @@ TabChild::UpdateRepeatedKeyEventEndTime(
 {
   if (aEvent.mIsRepeat &&
       (aEvent.mMessage == eKeyDown || aEvent.mMessage == eKeyPress)) {
     mRepeatedKeyEventTime = TimeStamp::Now();
   }
 }
 
 mozilla::ipc::IPCResult
-TabChild::RecvRealKeyEvent(const WidgetKeyboardEvent& event,
+TabChild::RecvRealKeyEvent(const WidgetKeyboardEvent& aEvent,
                            const MaybeNativeKeyBinding& aBindings)
 {
-  if (SkipRepeatedKeyEvent(event)) {
+  if (SkipRepeatedKeyEvent(aEvent)) {
     return IPC_OK();
   }
 
   AutoCacheNativeKeyCommands autoCache(mPuppetWidget);
 
-  if (event.mMessage == eKeyPress) {
+  if (aEvent.mMessage == eKeyPress) {
     // If content code called preventDefault() on a keydown event, then we don't
     // want to process any following keypress events.
     if (mIgnoreKeyPressEvent) {
       return IPC_OK();
     }
     if (aBindings.type() == MaybeNativeKeyBinding::TNativeKeyBinding) {
       const NativeKeyBinding& bindings = aBindings;
       autoCache.Cache(bindings.singleLineCommands(),
                       bindings.multiLineCommands(),
                       bindings.richTextCommands());
     } else {
       autoCache.CacheNoCommands();
     }
   }
 
-  WidgetKeyboardEvent localEvent(event);
+  WidgetKeyboardEvent localEvent(aEvent);
   localEvent.mWidget = mPuppetWidget;
   nsEventStatus status = APZCCallbackHelper::DispatchWidgetEvent(localEvent);
 
   // Update the end time of the possible repeated event so that we can skip
   // some incoming events in case event handling took long time.
   UpdateRepeatedKeyEventEndTime(localEvent);
 
-  if (event.mMessage == eKeyDown) {
+  if (aEvent.mMessage == eKeyDown) {
     mIgnoreKeyPressEvent = status == nsEventStatus_eConsumeNoDefault;
   }
 
   if (localEvent.mFlags.mIsSuppressedOrDelayed) {
     localEvent.PreventDefault();
   }
 
   // If a response is desired from the content process, resend the key event.
@@ -1889,32 +1889,32 @@ TabChild::RecvKeyEvent(const nsString& a
 {
   bool ignored = false;
   nsContentUtils::SendKeyEvent(mPuppetWidget, aType, aKeyCode, aCharCode,
                                aModifiers, aPreventDefault, &ignored);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
-TabChild::RecvCompositionEvent(const WidgetCompositionEvent& event)
+TabChild::RecvCompositionEvent(const WidgetCompositionEvent& aEvent)
 {
-  WidgetCompositionEvent localEvent(event);
+  WidgetCompositionEvent localEvent(aEvent);
   localEvent.mWidget = mPuppetWidget;
   APZCCallbackHelper::DispatchWidgetEvent(localEvent);
-  Unused << SendOnEventNeedingAckHandled(event.mMessage);
+  Unused << SendOnEventNeedingAckHandled(aEvent.mMessage);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
-TabChild::RecvSelectionEvent(const WidgetSelectionEvent& event)
+TabChild::RecvSelectionEvent(const WidgetSelectionEvent& aEvent)
 {
-  WidgetSelectionEvent localEvent(event);
+  WidgetSelectionEvent localEvent(aEvent);
   localEvent.mWidget = mPuppetWidget;
   APZCCallbackHelper::DispatchWidgetEvent(localEvent);
-  Unused << SendOnEventNeedingAckHandled(event.mMessage);
+  Unused << SendOnEventNeedingAckHandled(aEvent.mMessage);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 TabChild::RecvPasteTransferable(const IPCDataTransfer& aDataTransfer,
                                 const bool& aIsPrivateData,
                                 const IPC::Principal& aRequestingPrincipal)
 {
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -1070,93 +1070,96 @@ TabParent::SendKeyEvent(const nsAString&
                         bool aPreventDefault)
 {
   if (!mIsDestroyed) {
     Unused << PBrowserParent::SendKeyEvent(nsString(aType), aKeyCode, aCharCode,
                                            aModifiers, aPreventDefault);
   }
 }
 
-bool TabParent::SendRealMouseEvent(WidgetMouseEvent& event)
+bool
+TabParent::SendRealMouseEvent(WidgetMouseEvent& aEvent)
 {
   if (mIsDestroyed) {
     return false;
   }
-  event.mRefPoint += GetChildProcessOffset();
+  aEvent.mRefPoint += GetChildProcessOffset();
 
   nsCOMPtr<nsIWidget> widget = GetWidget();
   if (widget) {
     // When we mouseenter the tab, the tab's cursor should
     // become the current cursor.  When we mouseexit, we stop.
-    if (eMouseEnterIntoWidget == event.mMessage) {
+    if (eMouseEnterIntoWidget == aEvent.mMessage) {
       mTabSetsCursor = true;
       if (mCustomCursor) {
         widget->SetCursor(mCustomCursor, mCustomCursorHotspotX, mCustomCursorHotspotY);
       } else if (mCursor != nsCursor(-1)) {
         widget->SetCursor(mCursor);
       }
-    } else if (eMouseExitFromWidget == event.mMessage) {
+    } else if (eMouseExitFromWidget == aEvent.mMessage) {
       mTabSetsCursor = false;
     }
   }
 
   ScrollableLayerGuid guid;
   uint64_t blockId;
   ApzAwareEventRoutingToChild(&guid, &blockId, nullptr);
 
-  if (eMouseMove == event.mMessage) {
-    if (event.mReason == WidgetMouseEvent::eSynthesized) {
-      return SendSynthMouseMoveEvent(event, guid, blockId);
+  if (eMouseMove == aEvent.mMessage) {
+    if (aEvent.mReason == WidgetMouseEvent::eSynthesized) {
+      return SendSynthMouseMoveEvent(aEvent, guid, blockId);
     } else {
-      return SendRealMouseMoveEvent(event, guid, blockId);
+      return SendRealMouseMoveEvent(aEvent, guid, blockId);
     }
   }
 
-  return SendRealMouseButtonEvent(event, guid, blockId);
+  return SendRealMouseButtonEvent(aEvent, guid, blockId);
 }
 
 LayoutDeviceToCSSScale
 TabParent::GetLayoutDeviceToCSSScale()
 {
   nsCOMPtr<nsIContent> content = do_QueryInterface(mFrameElement);
   nsIDocument* doc = (content ? content->OwnerDoc() : nullptr);
   nsIPresShell* shell = (doc ? doc->GetShell() : nullptr);
   nsPresContext* ctx = (shell ? shell->GetPresContext() : nullptr);
   return LayoutDeviceToCSSScale(ctx
     ? (float)ctx->AppUnitsPerDevPixel() / nsPresContext::AppUnitsPerCSSPixel()
     : 0.0f);
 }
 
 bool
-TabParent::SendRealDragEvent(WidgetDragEvent& event, uint32_t aDragAction,
+TabParent::SendRealDragEvent(WidgetDragEvent& aEvent, uint32_t aDragAction,
                              uint32_t aDropEffect)
 {
   if (mIsDestroyed) {
     return false;
   }
-  event.mRefPoint += GetChildProcessOffset();
-  return PBrowserParent::SendRealDragEvent(event, aDragAction, aDropEffect);
+  aEvent.mRefPoint += GetChildProcessOffset();
+  return PBrowserParent::SendRealDragEvent(aEvent, aDragAction, aDropEffect);
 }
 
-LayoutDevicePoint TabParent::AdjustTapToChildWidget(const LayoutDevicePoint& aPoint)
+LayoutDevicePoint
+TabParent::AdjustTapToChildWidget(const LayoutDevicePoint& aPoint)
 {
   return aPoint + LayoutDevicePoint(GetChildProcessOffset());
 }
 
-bool TabParent::SendMouseWheelEvent(WidgetWheelEvent& event)
+bool
+TabParent::SendMouseWheelEvent(WidgetWheelEvent& aEvent)
 {
   if (mIsDestroyed) {
     return false;
   }
 
   ScrollableLayerGuid guid;
   uint64_t blockId;
   ApzAwareEventRoutingToChild(&guid, &blockId, nullptr);
-  event.mRefPoint += GetChildProcessOffset();
-  return PBrowserParent::SendMouseWheelEvent(event, guid, blockId);
+  aEvent.mRefPoint += GetChildProcessOffset();
+  return PBrowserParent::SendMouseWheelEvent(aEvent, guid, blockId);
 }
 
 mozilla::ipc::IPCResult
 TabParent::RecvDispatchWheelEvent(const mozilla::WidgetWheelEvent& aEvent)
 {
   nsCOMPtr<nsIWidget> widget = GetWidget();
   if (!widget) {
     return IPC_OK();
@@ -1409,82 +1412,87 @@ TabParent::RecvClearNativeTouchSequence(
   AutoSynthesizedEventResponder responder(this, aObserverId, "cleartouch");
   nsCOMPtr<nsIWidget> widget = GetWidget();
   if (widget) {
     widget->ClearNativeTouchSequence(responder.GetObserver());
   }
   return IPC_OK();
 }
 
-bool TabParent::SendRealKeyEvent(WidgetKeyboardEvent& event)
+bool
+TabParent::SendRealKeyEvent(WidgetKeyboardEvent& aEvent)
 {
   if (mIsDestroyed) {
     return false;
   }
-  event.mRefPoint += GetChildProcessOffset();
+  aEvent.mRefPoint += GetChildProcessOffset();
 
   MaybeNativeKeyBinding bindings;
   bindings = void_t();
-  if (event.mMessage == eKeyPress) {
+  if (aEvent.mMessage == eKeyPress) {
     nsCOMPtr<nsIWidget> widget = GetWidget();
 
     AutoTArray<mozilla::CommandInt, 4> singleLine;
     AutoTArray<mozilla::CommandInt, 4> multiLine;
     AutoTArray<mozilla::CommandInt, 4> richText;
 
-    widget->ExecuteNativeKeyBinding(nsIWidget::NativeKeyBindingsForSingleLineEditor,
-                                    event, DoCommandCallback, &singleLine);
-    widget->ExecuteNativeKeyBinding(nsIWidget::NativeKeyBindingsForMultiLineEditor,
-                                    event, DoCommandCallback, &multiLine);
-    widget->ExecuteNativeKeyBinding(nsIWidget::NativeKeyBindingsForRichTextEditor,
-                                    event, DoCommandCallback, &richText);
+    widget->ExecuteNativeKeyBinding(
+              nsIWidget::NativeKeyBindingsForSingleLineEditor,
+              aEvent, DoCommandCallback, &singleLine);
+    widget->ExecuteNativeKeyBinding(
+              nsIWidget::NativeKeyBindingsForMultiLineEditor,
+              aEvent, DoCommandCallback, &multiLine);
+    widget->ExecuteNativeKeyBinding(
+              nsIWidget::NativeKeyBindingsForRichTextEditor,
+              aEvent, DoCommandCallback, &richText);
 
     if (!singleLine.IsEmpty() || !multiLine.IsEmpty() || !richText.IsEmpty()) {
       bindings = NativeKeyBinding(singleLine, multiLine, richText);
     }
   }
 
-  return PBrowserParent::SendRealKeyEvent(event, bindings);
+  return PBrowserParent::SendRealKeyEvent(aEvent, bindings);
 }
 
-bool TabParent::SendRealTouchEvent(WidgetTouchEvent& event)
+bool
+TabParent::SendRealTouchEvent(WidgetTouchEvent& aEvent)
 {
   if (mIsDestroyed) {
     return false;
   }
 
   // PresShell::HandleEventInternal adds touches on touch end/cancel.  This
   // confuses remote content and the panning and zooming logic into thinking
   // that the added touches are part of the touchend/cancel, when actually
   // they're not.
-  if (event.mMessage == eTouchEnd || event.mMessage == eTouchCancel) {
-    for (int i = event.mTouches.Length() - 1; i >= 0; i--) {
-      if (!event.mTouches[i]->mChanged) {
-        event.mTouches.RemoveElementAt(i);
+  if (aEvent.mMessage == eTouchEnd || aEvent.mMessage == eTouchCancel) {
+    for (int i = aEvent.mTouches.Length() - 1; i >= 0; i--) {
+      if (!aEvent.mTouches[i]->mChanged) {
+        aEvent.mTouches.RemoveElementAt(i);
       }
     }
   }
 
   ScrollableLayerGuid guid;
   uint64_t blockId;
   nsEventStatus apzResponse;
   ApzAwareEventRoutingToChild(&guid, &blockId, &apzResponse);
 
   if (mIsDestroyed) {
     return false;
   }
 
   LayoutDeviceIntPoint offset = GetChildProcessOffset();
-  for (uint32_t i = 0; i < event.mTouches.Length(); i++) {
-    event.mTouches[i]->mRefPoint += offset;
+  for (uint32_t i = 0; i < aEvent.mTouches.Length(); i++) {
+    aEvent.mTouches[i]->mRefPoint += offset;
   }
 
-  return (event.mMessage == eTouchMove) ?
-    PBrowserParent::SendRealTouchMoveEvent(event, guid, blockId, apzResponse) :
-    PBrowserParent::SendRealTouchEvent(event, guid, blockId, apzResponse);
+  return (aEvent.mMessage == eTouchMove) ?
+    PBrowserParent::SendRealTouchMoveEvent(aEvent, guid, blockId, apzResponse) :
+    PBrowserParent::SendRealTouchEvent(aEvent, guid, blockId, apzResponse);
 }
 
 bool
 TabParent::SendHandleTap(TapType aType,
                          const LayoutDevicePoint& aPoint,
                          Modifiers aModifiers,
                          const ScrollableLayerGuid& aGuid,
                          uint64_t aInputBlockId)
@@ -1935,21 +1943,21 @@ TabParent::GetChildProcessOffset()
                                                             LayoutDeviceIntPoint(0, 0),
                                                             targetFrame);
 
   return LayoutDeviceIntPoint::FromAppUnitsToNearest(
            pt, targetFrame->PresContext()->AppUnitsPerDevPixel());
 }
 
 mozilla::ipc::IPCResult
-TabParent::RecvReplyKeyEvent(const WidgetKeyboardEvent& event)
+TabParent::RecvReplyKeyEvent(const WidgetKeyboardEvent& aEvent)
 {
   NS_ENSURE_TRUE(mFrameElement, IPC_OK());
 
-  WidgetKeyboardEvent localEvent(event);
+  WidgetKeyboardEvent localEvent(aEvent);
   // Mark the event as not to be dispatched to remote process again.
   localEvent.StopCrossProcessForwarding();
 
   // Here we convert the WidgetEvent that we received to an nsIDOMEvent
   // to be able to dispatch it to the <browser> element as the target element.
   nsIDocument* doc = mFrameElement->OwnerDoc();
   nsIPresShell* presShell = doc->GetShell();
   NS_ENSURE_TRUE(presShell, IPC_OK());
@@ -2007,43 +2015,43 @@ TabParent::HandleQueryContentEvent(Widge
       break;
     default:
       break;
   }
   return true;
 }
 
 bool
-TabParent::SendCompositionEvent(WidgetCompositionEvent& event)
+TabParent::SendCompositionEvent(WidgetCompositionEvent& aEvent)
 {
   if (mIsDestroyed) {
     return false;
   }
 
-  if (!mContentCache.OnCompositionEvent(event)) {
+  if (!mContentCache.OnCompositionEvent(aEvent)) {
     return true;
   }
-  return PBrowserParent::SendCompositionEvent(event);
+  return PBrowserParent::SendCompositionEvent(aEvent);
 }
 
 bool
-TabParent::SendSelectionEvent(WidgetSelectionEvent& event)
+TabParent::SendSelectionEvent(WidgetSelectionEvent& aEvent)
 {
   if (mIsDestroyed) {
     return false;
   }
   nsCOMPtr<nsIWidget> widget = GetWidget();
   if (!widget) {
     return true;
   }
-  mContentCache.OnSelectionEvent(event);
-  if (NS_WARN_IF(!PBrowserParent::SendSelectionEvent(event))) {
+  mContentCache.OnSelectionEvent(aEvent);
+  if (NS_WARN_IF(!PBrowserParent::SendSelectionEvent(aEvent))) {
     return false;
   }
-  event.mSucceeded = true;
+  aEvent.mSucceeded = true;
   return true;
 }
 
 bool
 TabParent::SendPasteTransferable(const IPCDataTransfer& aDataTransfer,
                                  const bool& aIsPrivateData,
                                  const IPC::Principal& aRequestingPrincipal)
 {
--- a/dom/ipc/TabParent.h
+++ b/dom/ipc/TabParent.h
@@ -449,27 +449,27 @@ public:
   void SendMouseEvent(const nsAString& aType, float aX, float aY,
                       int32_t aButton, int32_t aClickCount,
                       int32_t aModifiers, bool aIgnoreRootScrollFrame);
 
   void SendKeyEvent(const nsAString& aType, int32_t aKeyCode,
                     int32_t aCharCode, int32_t aModifiers,
                     bool aPreventDefault);
 
-  bool SendRealMouseEvent(mozilla::WidgetMouseEvent& event);
+  bool SendRealMouseEvent(mozilla::WidgetMouseEvent& aEvent);
 
   bool SendRealDragEvent(mozilla::WidgetDragEvent& aEvent,
                          uint32_t aDragAction,
                          uint32_t aDropEffect);
 
-  bool SendMouseWheelEvent(mozilla::WidgetWheelEvent& event);
+  bool SendMouseWheelEvent(mozilla::WidgetWheelEvent& aEvent);
 
-  bool SendRealKeyEvent(mozilla::WidgetKeyboardEvent& event);
+  bool SendRealKeyEvent(mozilla::WidgetKeyboardEvent& aEvent);
 
-  bool SendRealTouchEvent(WidgetTouchEvent& event);
+  bool SendRealTouchEvent(WidgetTouchEvent& aEvent);
 
   bool SendHandleTap(TapType aType,
                      const LayoutDevicePoint& aPoint,
                      Modifiers aModifiers,
                      const ScrollableLayerGuid& aGuid,
                      uint64_t aInputBlockId);
 
   virtual PDocumentRendererParent*
@@ -507,19 +507,19 @@ public:
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIAUTHPROMPTPROVIDER
   NS_DECL_NSISECUREBROWSERUI
   NS_DECL_NSIWEBBROWSERPERSISTABLE
 
   bool HandleQueryContentEvent(mozilla::WidgetQueryContentEvent& aEvent);
 
-  bool SendCompositionEvent(mozilla::WidgetCompositionEvent& event);
+  bool SendCompositionEvent(mozilla::WidgetCompositionEvent& aEvent);
 
-  bool SendSelectionEvent(mozilla::WidgetSelectionEvent& event);
+  bool SendSelectionEvent(mozilla::WidgetSelectionEvent& aEvent);
 
   bool SendPasteTransferable(const IPCDataTransfer& aDataTransfer,
                              const bool& aIsPrivateData,
                              const IPC::Principal& aRequestingPrincipal);
 
   static TabParent* GetFrom(nsFrameLoader* aFrameLoader);
 
   static TabParent* GetFrom(nsIFrameLoader* aFrameLoader);
--- a/widget/PuppetWidget.cpp
+++ b/widget/PuppetWidget.cpp
@@ -301,50 +301,50 @@ PuppetWidget::Invalidate(const LayoutDev
   if (!mDirtyRegion.IsEmpty() && !mPaintTask.IsPending()) {
     mPaintTask = new PaintTask(this);
     NS_DispatchToCurrentThread(mPaintTask.get());
     return;
   }
 }
 
 void
-PuppetWidget::InitEvent(WidgetGUIEvent& event, LayoutDeviceIntPoint* aPoint)
+PuppetWidget::InitEvent(WidgetGUIEvent& aEvent, LayoutDeviceIntPoint* aPoint)
 {
   if (nullptr == aPoint) {
-    event.mRefPoint = LayoutDeviceIntPoint(0, 0);
+    aEvent.mRefPoint = LayoutDeviceIntPoint(0, 0);
   } else {
     // use the point override if provided
-    event.mRefPoint = *aPoint;
+    aEvent.mRefPoint = *aPoint;
   }
-  event.mTime = PR_Now() / 1000;
+  aEvent.mTime = PR_Now() / 1000;
 }
 
 nsresult
-PuppetWidget::DispatchEvent(WidgetGUIEvent* event, nsEventStatus& aStatus)
+PuppetWidget::DispatchEvent(WidgetGUIEvent* aEvent, nsEventStatus& aStatus)
 {
 #ifdef DEBUG
-  debug_DumpEvent(stdout, event->mWidget, event, "PuppetWidget", 0);
+  debug_DumpEvent(stdout, aEvent->mWidget, aEvent, "PuppetWidget", 0);
 #endif
 
   MOZ_ASSERT(!mChild || mChild->mWindowType == eWindowType_popup,
              "Unexpected event dispatch!");
 
   AutoCacheNativeKeyCommands autoCache(this);
-  if ((event->mFlags.mIsSynthesizedForTests ||
-       event->mFlags.mIsSuppressedOrDelayed) && !mNativeKeyCommandsValid) {
-    WidgetKeyboardEvent* keyEvent = event->AsKeyboardEvent();
+  if ((aEvent->mFlags.mIsSynthesizedForTests ||
+       aEvent->mFlags.mIsSuppressedOrDelayed) && !mNativeKeyCommandsValid) {
+    WidgetKeyboardEvent* keyEvent = aEvent->AsKeyboardEvent();
     if (keyEvent) {
       mTabChild->RequestNativeKeyBindings(&autoCache, keyEvent);
     }
   }
 
-  if (event->mClass == eCompositionEventClass) {
+  if (aEvent->mClass == eCompositionEventClass) {
     // Store the latest native IME context of parent process's widget or
     // TextEventDispatcher if it's in this process.
-    WidgetCompositionEvent* compositionEvent = event->AsCompositionEvent();
+    WidgetCompositionEvent* compositionEvent = aEvent->AsCompositionEvent();
 #ifdef DEBUG
     if (mNativeIMEContext.IsValid() &&
         mNativeIMEContext != compositionEvent->mNativeIMEContext) {
       RefPtr<TextComposition> composition =
         IMEStateManager::GetTextCompositionFor(this);
       MOZ_ASSERT(!composition,
         "When there is composition caused by old native IME context, "
         "composition events caused by different native IME context are not "
@@ -352,17 +352,18 @@ PuppetWidget::DispatchEvent(WidgetGUIEve
     }
 #endif // #ifdef DEBUG
     mNativeIMEContext = compositionEvent->mNativeIMEContext;
   }
 
   aStatus = nsEventStatus_eIgnore;
 
   if (GetCurrentWidgetListener()) {
-    aStatus = GetCurrentWidgetListener()->HandleEvent(event, mUseAttachedEvents);
+    aStatus =
+      GetCurrentWidgetListener()->HandleEvent(aEvent, mUseAttachedEvents);
   }
 
   return NS_OK;
 }
 
 nsEventStatus
 PuppetWidget::DispatchInputEvent(WidgetInputEvent* aEvent)
 {