Bug 920377 part.4 Get rid of nsContentCommandEvent r=roc
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 27 Sep 2013 15:20:54 +0900
changeset 148948 5c6b7f254a3b33949cafd0d1e2de63ab1ebb2a44
parent 148947 1ba8d22427b0241ac424f24ed983f5b803cad7c2
child 148949 7fc126f540f8f5b1e72ae65ace3b7eeb2554b210
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersroc
bugs920377
milestone27.0a1
Bug 920377 part.4 Get rid of nsContentCommandEvent r=roc
content/events/src/nsEventStateManager.cpp
content/events/src/nsEventStateManager.h
dom/base/nsDOMWindowUtils.cpp
widget/EventForwards.h
widget/MiscEvents.h
widget/cocoa/TextInputHandler.mm
widget/cocoa/nsChildView.mm
widget/gtk/nsGtkIMModule.cpp
widget/gtk/nsWindow.cpp
widget/qt/nsWindow.cpp
widget/windows/WinMouseScrollHandler.cpp
widget/windows/nsWindow.cpp
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -1068,22 +1068,23 @@ nsEventStateManager::PreHandleEvent(nsPr
   case NS_CONTENT_COMMAND_CUT:
   case NS_CONTENT_COMMAND_COPY:
   case NS_CONTENT_COMMAND_PASTE:
   case NS_CONTENT_COMMAND_DELETE:
   case NS_CONTENT_COMMAND_UNDO:
   case NS_CONTENT_COMMAND_REDO:
   case NS_CONTENT_COMMAND_PASTE_TRANSFERABLE:
     {
-      DoContentCommandEvent(static_cast<nsContentCommandEvent*>(aEvent));
+      DoContentCommandEvent(static_cast<WidgetContentCommandEvent*>(aEvent));
     }
     break;
   case NS_CONTENT_COMMAND_SCROLL:
     {
-      DoContentCommandScrollEvent(static_cast<nsContentCommandEvent*>(aEvent));
+      DoContentCommandScrollEvent(
+        static_cast<WidgetContentCommandEvent*>(aEvent));
     }
     break;
   case NS_TEXT_TEXT:
     {
       nsTextEvent *textEvent = static_cast<nsTextEvent*>(aEvent);
       if (IsTargetCrossProcess(textEvent)) {
         // Will not be handled locally, remote the event
         if (GetCrossProcessTarget()->SendTextEvent(*textEvent)) {
@@ -4916,17 +4917,17 @@ nsEventStateManager::IsShellVisible(nsID
 
   // We should be doing some additional checks here so that
   // we don't tab into hidden tabs of tabbrowser.  -bryner
 
   return isVisible;
 }
 
 nsresult
-nsEventStateManager::DoContentCommandEvent(nsContentCommandEvent* aEvent)
+nsEventStateManager::DoContentCommandEvent(WidgetContentCommandEvent* aEvent)
 {
   EnsureDocument(mPresContext);
   NS_ENSURE_TRUE(mDocument, NS_ERROR_FAILURE);
   nsCOMPtr<nsPIDOMWindow> window(mDocument->GetWindow());
   NS_ENSURE_TRUE(window, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsPIWindowRoot> root = window->GetTopWindowRoot();
   NS_ENSURE_TRUE(root, NS_ERROR_FAILURE);
@@ -4991,32 +4992,33 @@ nsEventStateManager::DoContentCommandEve
       NS_ENSURE_SUCCESS(rv, rv);
     }
   }
   aEvent->mSucceeded = true;
   return NS_OK;
 }
 
 nsresult
-nsEventStateManager::DoContentCommandScrollEvent(nsContentCommandEvent* aEvent)
+nsEventStateManager::DoContentCommandScrollEvent(
+                       WidgetContentCommandEvent* aEvent)
 {
   NS_ENSURE_TRUE(mPresContext, NS_ERROR_NOT_AVAILABLE);
   nsIPresShell* ps = mPresContext->GetPresShell();
   NS_ENSURE_TRUE(ps, NS_ERROR_NOT_AVAILABLE);
   NS_ENSURE_TRUE(aEvent->mScroll.mAmount != 0, NS_ERROR_INVALID_ARG);
 
   nsIScrollableFrame::ScrollUnit scrollUnit;
   switch (aEvent->mScroll.mUnit) {
-    case nsContentCommandEvent::eCmdScrollUnit_Line:
+    case WidgetContentCommandEvent::eCmdScrollUnit_Line:
       scrollUnit = nsIScrollableFrame::LINES;
       break;
-    case nsContentCommandEvent::eCmdScrollUnit_Page:
+    case WidgetContentCommandEvent::eCmdScrollUnit_Page:
       scrollUnit = nsIScrollableFrame::PAGES;
       break;
-    case nsContentCommandEvent::eCmdScrollUnit_Whole:
+    case WidgetContentCommandEvent::eCmdScrollUnit_Whole:
       scrollUnit = nsIScrollableFrame::WHOLE;
       break;
     default:
       return NS_ERROR_INVALID_ARG;
   }
 
   aEvent->mSucceeded = true;
 
--- a/content/events/src/nsEventStateManager.h
+++ b/content/events/src/nsEventStateManager.h
@@ -699,18 +699,19 @@ protected:
   /**
    * Set the fields of aEvent to reflect the mouse position and modifier keys
    * that were set when the user first pressed the mouse button (stored by
    * BeginTrackingDragGesture). aEvent->widget must be
    * mCurrentTarget->GetNearestWidget().
    */
   void FillInEventFromGestureDown(nsMouseEvent* aEvent);
 
-  nsresult DoContentCommandEvent(nsContentCommandEvent* aEvent);
-  nsresult DoContentCommandScrollEvent(nsContentCommandEvent* aEvent);
+  nsresult DoContentCommandEvent(mozilla::WidgetContentCommandEvent* aEvent);
+  nsresult DoContentCommandScrollEvent(
+             mozilla::WidgetContentCommandEvent* aEvent);
 
   void DoQuerySelectedText(nsQueryContentEvent* aEvent);
 
   bool RemoteQueryContentEvent(nsEvent *aEvent);
   mozilla::dom::TabParent *GetCrossProcessTarget();
   bool IsTargetCrossProcess(nsGUIEvent *aEvent);
 
   bool DispatchCrossProcessEvent(nsEvent* aEvent, nsFrameLoader* remote,
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -2010,17 +2010,17 @@ nsDOMWindowUtils::SendContentCommandEven
     msg = NS_CONTENT_COMMAND_UNDO;
   else if (aType.EqualsLiteral("redo"))
     msg = NS_CONTENT_COMMAND_REDO;
   else if (aType.EqualsLiteral("pasteTransferable"))
     msg = NS_CONTENT_COMMAND_PASTE_TRANSFERABLE;
   else
     return NS_ERROR_FAILURE;
 
-  nsContentCommandEvent event(true, msg, widget);
+  WidgetContentCommandEvent event(true, msg, widget);
   if (msg == NS_CONTENT_COMMAND_PASTE_TRANSFERABLE) {
     event.mTransferable = aTransferable;
   }
 
   nsEventStatus status;
   return widget->DispatchEvent(&event, status);
 }
 
--- a/widget/EventForwards.h
+++ b/widget/EventForwards.h
@@ -131,11 +131,10 @@ typedef mozilla::WidgetTouchEvent       
 typedef mozilla::InternalScriptErrorEvent  nsScriptErrorEvent;
 typedef mozilla::InternalScrollPortEvent   nsScrollPortEvent;
 typedef mozilla::InternalScrollAreaEvent   nsScrollAreaEvent;
 typedef mozilla::InternalFormEvent         nsFormEvent;
 typedef mozilla::InternalClipboardEvent    nsClipboardEvent;
 typedef mozilla::InternalFocusEvent        nsFocusEvent;
 typedef mozilla::InternalTransitionEvent   nsTransitionEvent;
 typedef mozilla::InternalAnimationEvent    nsAnimationEvent;
-typedef mozilla::WidgetContentCommandEvent nsContentCommandEvent;
 
 #endif // mozilla_EventForwards_h__
--- a/widget/MiscEvents.h
+++ b/widget/MiscEvents.h
@@ -110,12 +110,9 @@ public:
 
   // If true, this event needs to be retargeted to focused document.
   // Otherwise, never retargeted. Defaults to false.
   bool retargetToFocusedDocument;
 };
 
 } // namespace mozilla
 
-// TODO: Remove following typedefs
-typedef mozilla::WidgetContentCommandEvent nsContentCommandEvent;
-
 #endif // mozilla_MiscEvents_h__
--- a/widget/cocoa/TextInputHandler.mm
+++ b/widget/cocoa/TextInputHandler.mm
@@ -2021,18 +2021,19 @@ TextInputHandler::InsertText(NSAttribute
     // If this is caused by a key input, the keypress event which will be
     // dispatched later should cause the delete.  Therefore, nothing to do here.
     // Although, we're not sure if such case is actually possible.
     if (!currentKeyEvent) {
       return;
     }
     // Delete the selected range.
     nsRefPtr<TextInputHandler> kungFuDeathGrip(this);
-    nsContentCommandEvent deleteCommandEvent(true, NS_CONTENT_COMMAND_DELETE,
-                                             mWidget);
+    WidgetContentCommandEvent deleteCommandEvent(true,
+                                                 NS_CONTENT_COMMAND_DELETE,
+                                                 mWidget);
     DispatchEvent(deleteCommandEvent);
     NS_ENSURE_TRUE_VOID(deleteCommandEvent.mSucceeded);
     // Be aware! The widget might be destroyed here.
     return;
   }
 
   if (str.Length() != 1 || IsIMEComposing()) {
     InsertTextAsCommittingComposition(aAttrString, aReplacementRange);
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -5773,17 +5773,19 @@ static int32_t RoundUp(double aDouble)
         // This might destroy our widget (and null out mGeckoChild).
         mGeckoChild->DispatchWindowEvent(event);
         if (!mGeckoChild || !event.mSucceeded || !event.mReply.mHasSelection)
           result = nil;
       }
 
       // Determine if we can paste (if receiving data from the service).
       if (mGeckoChild && returnType) {
-        nsContentCommandEvent command(true, NS_CONTENT_COMMAND_PASTE_TRANSFERABLE, mGeckoChild, true);
+        WidgetContentCommandEvent command(true,
+                                          NS_CONTENT_COMMAND_PASTE_TRANSFERABLE,
+                                          mGeckoChild, true);
         // This might possibly destroy our widget (and null out mGeckoChild).
         mGeckoChild->DispatchWindowEvent(command);
         if (!mGeckoChild || !command.mSucceeded || !command.mIsEnabled)
           result = nil;
       }
     }
   }
 
@@ -5870,19 +5872,19 @@ static int32_t RoundUp(double aDouble)
   trans->AddDataFlavor(kHTMLMime);
 
   rv = nsClipboard::TransferableFromPasteboard(trans, pboard);
   if (NS_FAILED(rv))
     return NO;
 
   NS_ENSURE_TRUE(mGeckoChild, false);
 
-  nsContentCommandEvent command(true,
-                                NS_CONTENT_COMMAND_PASTE_TRANSFERABLE,
-                                mGeckoChild);
+  WidgetContentCommandEvent command(true,
+                                    NS_CONTENT_COMMAND_PASTE_TRANSFERABLE,
+                                    mGeckoChild);
   command.mTransferable = trans;
   mGeckoChild->DispatchWindowEvent(command);
   
   return command.mSucceeded && command.mIsEnabled;
 }
 
 #pragma mark -
 
--- a/widget/gtk/nsGtkIMModule.cpp
+++ b/widget/gtk/nsGtkIMModule.cpp
@@ -1519,19 +1519,19 @@ nsGtkIMModule::DeleteText(const int32_t 
         lastFocusedWindow->Destroyed()) {
         PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
             ("    FAILED, setting selection caused focus change "
              "or window destroyed"));
         return NS_ERROR_FAILURE;
     }
 
     // Delete the selection
-    nsContentCommandEvent contentCommandEvent(true,
-                                              NS_CONTENT_COMMAND_DELETE,
-                                              mLastFocusedWindow);
+    WidgetContentCommandEvent contentCommandEvent(true,
+                                                  NS_CONTENT_COMMAND_DELETE,
+                                                  mLastFocusedWindow);
     mLastFocusedWindow->DispatchEvent(&contentCommandEvent, status);
 
     if (!contentCommandEvent.mSucceeded ||
         lastFocusedWindow != mLastFocusedWindow ||
         lastFocusedWindow->Destroyed()) {
         PR_LOG(gGtkIMLog, PR_LOG_ALWAYS,
             ("    FAILED, deleting the selection caused focus change "
              "or window destroyed"));
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -2887,17 +2887,17 @@ nsWindow::DispatchCommandEvent(nsIAtom* 
     DispatchEvent(&event, status);
     return TRUE;
 }
 
 bool
 nsWindow::DispatchContentCommandEvent(int32_t aMsg)
 {
   nsEventStatus status;
-  nsContentCommandEvent event(true, aMsg, this);
+  WidgetContentCommandEvent event(true, aMsg, this);
   DispatchEvent(&event, status);
   return TRUE;
 }
 
 static bool
 IsCtrlAltTab(GdkEventKey *aEvent)
 {
     return aEvent->keyval == GDK_Tab &&
--- a/widget/qt/nsWindow.cpp
+++ b/widget/qt/nsWindow.cpp
@@ -1465,17 +1465,17 @@ nsWindow::DispatchCommandEvent(nsIAtom* 
     DispatchEvent(&event, status);
 
     return status;
 }
 
 nsEventStatus
 nsWindow::DispatchContentCommandEvent(int32_t aMsg)
 {
-    nsContentCommandEvent event(true, aMsg, this);
+    WidgetContentCommandEvent event(true, aMsg, this);
 
     nsEventStatus status;
     DispatchEvent(&event, status);
 
     return status;
 }
 
 nsEventStatus
--- a/widget/windows/WinMouseScrollHandler.cpp
+++ b/widget/windows/WinMouseScrollHandler.cpp
@@ -551,43 +551,50 @@ MouseScrollHandler::ProcessNativeScrollM
 
   PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
     ("MouseScroll::ProcessNativeScrollMessage: aWidget=%p, "
      "aMessage=%s, wParam=0x%08X, lParam=0x%08X",
      aWidget, aMessage == WM_VSCROLL ? "WM_VSCROLL" : "WM_HSCROLL",
      aWParam, aLParam));
 
   // Scroll message generated by external application
-  nsContentCommandEvent commandEvent(true, NS_CONTENT_COMMAND_SCROLL, aWidget);
+  WidgetContentCommandEvent commandEvent(true, NS_CONTENT_COMMAND_SCROLL,
+                                         aWidget);
 
   commandEvent.mScroll.mIsHorizontal = (aMessage == WM_HSCROLL);
 
   switch (LOWORD(aWParam)) {
     case SB_LINEUP:   // SB_LINELEFT
-      commandEvent.mScroll.mUnit = nsContentCommandEvent::eCmdScrollUnit_Line;
+      commandEvent.mScroll.mUnit =
+        WidgetContentCommandEvent::eCmdScrollUnit_Line;
       commandEvent.mScroll.mAmount = -1;
       break;
     case SB_LINEDOWN: // SB_LINERIGHT
-      commandEvent.mScroll.mUnit = nsContentCommandEvent::eCmdScrollUnit_Line;
+      commandEvent.mScroll.mUnit =
+        WidgetContentCommandEvent::eCmdScrollUnit_Line;
       commandEvent.mScroll.mAmount = 1;
       break;
     case SB_PAGEUP:   // SB_PAGELEFT
-      commandEvent.mScroll.mUnit = nsContentCommandEvent::eCmdScrollUnit_Page;
+      commandEvent.mScroll.mUnit =
+        WidgetContentCommandEvent::eCmdScrollUnit_Page;
       commandEvent.mScroll.mAmount = -1;
       break;
     case SB_PAGEDOWN: // SB_PAGERIGHT
-      commandEvent.mScroll.mUnit = nsContentCommandEvent::eCmdScrollUnit_Page;
+      commandEvent.mScroll.mUnit =
+        WidgetContentCommandEvent::eCmdScrollUnit_Page;
       commandEvent.mScroll.mAmount = 1;
       break;
     case SB_TOP:      // SB_LEFT
-      commandEvent.mScroll.mUnit = nsContentCommandEvent::eCmdScrollUnit_Whole;
+      commandEvent.mScroll.mUnit =
+        WidgetContentCommandEvent::eCmdScrollUnit_Whole;
       commandEvent.mScroll.mAmount = -1;
       break;
     case SB_BOTTOM:   // SB_RIGHT
-      commandEvent.mScroll.mUnit = nsContentCommandEvent::eCmdScrollUnit_Whole;
+      commandEvent.mScroll.mUnit =
+        WidgetContentCommandEvent::eCmdScrollUnit_Whole;
       commandEvent.mScroll.mAmount = 1;
       break;
     default:
       return false;
   }
   // XXX If this is a plugin window, we should dispatch the event from
   //     parent window.
   DispatchEvent(aWidget, commandEvent);
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -5099,17 +5099,18 @@ nsWindow::ProcessMessage(UINT msg, WPARA
           contentCommandMessage = NS_CONTENT_COMMAND_REDO;
           break;
         case APPCOMMAND_UNDO:
           contentCommandMessage = NS_CONTENT_COMMAND_UNDO;
           break;
       }
 
       if (contentCommandMessage) {
-        nsContentCommandEvent contentCommand(true, contentCommandMessage, this);
+        WidgetContentCommandEvent contentCommand(true, contentCommandMessage,
+                                                 this);
         DispatchWindowEvent(&contentCommand);
         // tell the driver that we handled the event
         *aRetValue = 1;
         result = true;
       }
       // default = false - tell the driver that the event was not handled
     }
     break;
@@ -5351,92 +5352,92 @@ nsWindow::ProcessMessage(UINT msg, WPARA
           mGesture.SetWinGestureSupport(mWnd, gestureNotifyEvent.panDirection);
       }
       result = false; //should always bubble to DefWindowProc
     }
     break;
 
     case WM_CLEAR:
     {
-      nsContentCommandEvent command(true, NS_CONTENT_COMMAND_DELETE, this);
+      WidgetContentCommandEvent command(true, NS_CONTENT_COMMAND_DELETE, this);
       DispatchWindowEvent(&command);
       result = true;
     }
     break;
 
     case WM_CUT:
     {
-      nsContentCommandEvent command(true, NS_CONTENT_COMMAND_CUT, this);
+      WidgetContentCommandEvent command(true, NS_CONTENT_COMMAND_CUT, this);
       DispatchWindowEvent(&command);
       result = true;
     }
     break;
 
     case WM_COPY:
     {
-      nsContentCommandEvent command(true, NS_CONTENT_COMMAND_COPY, this);
+      WidgetContentCommandEvent command(true, NS_CONTENT_COMMAND_COPY, this);
       DispatchWindowEvent(&command);
       result = true;
     }
     break;
 
     case WM_PASTE:
     {
-      nsContentCommandEvent command(true, NS_CONTENT_COMMAND_PASTE, this);
+      WidgetContentCommandEvent command(true, NS_CONTENT_COMMAND_PASTE, this);
       DispatchWindowEvent(&command);
       result = true;
     }
     break;
 
     case EM_UNDO:
     {
-      nsContentCommandEvent command(true, NS_CONTENT_COMMAND_UNDO, this);
+      WidgetContentCommandEvent command(true, NS_CONTENT_COMMAND_UNDO, this);
       DispatchWindowEvent(&command);
       *aRetValue = (LRESULT)(command.mSucceeded && command.mIsEnabled);
       result = true;
     }
     break;
 
     case EM_REDO:
     {
-      nsContentCommandEvent command(true, NS_CONTENT_COMMAND_REDO, this);
+      WidgetContentCommandEvent command(true, NS_CONTENT_COMMAND_REDO, this);
       DispatchWindowEvent(&command);
       *aRetValue = (LRESULT)(command.mSucceeded && command.mIsEnabled);
       result = true;
     }
     break;
 
     case EM_CANPASTE:
     {
       // Support EM_CANPASTE message only when wParam isn't specified or
       // is plain text format.
       if (wParam == 0 || wParam == CF_TEXT || wParam == CF_UNICODETEXT) {
-        nsContentCommandEvent command(true, NS_CONTENT_COMMAND_PASTE,
-                                      this, true);
+        WidgetContentCommandEvent command(true, NS_CONTENT_COMMAND_PASTE,
+                                          this, true);
         DispatchWindowEvent(&command);
         *aRetValue = (LRESULT)(command.mSucceeded && command.mIsEnabled);
         result = true;
       }
     }
     break;
 
     case EM_CANUNDO:
     {
-      nsContentCommandEvent command(true, NS_CONTENT_COMMAND_UNDO,
-                                    this, true);
+      WidgetContentCommandEvent command(true, NS_CONTENT_COMMAND_UNDO,
+                                        this, true);
       DispatchWindowEvent(&command);
       *aRetValue = (LRESULT)(command.mSucceeded && command.mIsEnabled);
       result = true;
     }
     break;
 
     case EM_CANREDO:
     {
-      nsContentCommandEvent command(true, NS_CONTENT_COMMAND_REDO,
-                                    this, true);
+      WidgetContentCommandEvent command(true, NS_CONTENT_COMMAND_REDO,
+                                        this, true);
       DispatchWindowEvent(&command);
       *aRetValue = (LRESULT)(command.mSucceeded && command.mIsEnabled);
       result = true;
     }
     break;
 
     default:
     {