Bug 920377 part.24 Get rid of nsSelectionEvent r=roc
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 01 Oct 2013 16:23:01 +0900
changeset 163248 43bc4b6c0535890dad6dcedce94edb9b0093fe7e
parent 163247 d0b1a13f856d40b5e75505210d57151f8565d203
child 163249 5f1f90c96c91c478a376f5103916b382ba0fb299
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs920377
milestone27.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 920377 part.24 Get rid of nsSelectionEvent r=roc
content/events/src/nsContentEventHandler.cpp
content/events/src/nsContentEventHandler.h
content/events/src/nsEventStateManager.cpp
dom/base/nsDOMWindowUtils.cpp
dom/ipc/PBrowser.ipdl
dom/ipc/TabChild.cpp
dom/ipc/TabChild.h
dom/ipc/TabParent.cpp
dom/ipc/TabParent.h
widget/BasicEvents.h
widget/EventForwards.h
widget/TextEvents.h
widget/android/nsWindow.cpp
widget/cocoa/TextInputHandler.mm
widget/gtk/nsGtkIMModule.cpp
widget/nsGUIEventIPC.h
widget/windows/nsTextStore.cpp
widget/xpwidgets/PuppetWidget.cpp
--- a/content/events/src/nsContentEventHandler.cpp
+++ b/content/events/src/nsContentEventHandler.cpp
@@ -109,17 +109,17 @@ nsContentEventHandler::Init(WidgetQueryC
   NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
 
   aEvent->mReply.mFocusedWidget = frame->GetNearestWidget();
 
   return NS_OK;
 }
 
 nsresult
-nsContentEventHandler::Init(nsSelectionEvent* aEvent)
+nsContentEventHandler::Init(WidgetSelectionEvent* aEvent)
 {
   NS_ASSERTION(aEvent, "aEvent must not be null");
 
   nsresult rv = InitCommon();
   NS_ENSURE_SUCCESS(rv, rv);
 
   aEvent->mSucceeded = false;
 
@@ -1047,17 +1047,17 @@ static void AdjustRangeForSelection(nsIC
       break;
     brContent = node->GetChildAt(--offset - 1);
   }
   *aNode = node;
   *aOffset = std::max(offset, 0);
 }
 
 nsresult
-nsContentEventHandler::OnSelectionEvent(nsSelectionEvent* aEvent)
+nsContentEventHandler::OnSelectionEvent(WidgetSelectionEvent* aEvent)
 {
   aEvent->mSucceeded = false;
 
   // Get selection to manipulate
   // XXX why do we need to get them from ISM? This method should work fine
   //     without ISM.
   nsresult rv = nsIMEStateManager::
       GetFocusSelectionAndRoot(getter_AddRefs(mSelection),
--- a/content/events/src/nsContentEventHandler.h
+++ b/content/events/src/nsContentEventHandler.h
@@ -45,27 +45,27 @@ public:
   nsresult OnQuerySelectionAsTransferable(
              mozilla::WidgetQueryContentEvent* aEvent);
   // NS_QUERY_CHARACTER_AT_POINT event handler
   nsresult OnQueryCharacterAtPoint(mozilla::WidgetQueryContentEvent* aEvent);
   // NS_QUERY_DOM_WIDGET_HITTEST event handler
   nsresult OnQueryDOMWidgetHittest(mozilla::WidgetQueryContentEvent* aEvent);
 
   // NS_SELECTION_* event
-  nsresult OnSelectionEvent(nsSelectionEvent* aEvent);
+  nsresult OnSelectionEvent(mozilla::WidgetSelectionEvent* aEvent);
 
 protected:
   nsPresContext* mPresContext;
   nsCOMPtr<nsIPresShell> mPresShell;
   nsCOMPtr<nsISelection> mSelection;
   nsRefPtr<nsRange> mFirstSelectedRange;
   nsCOMPtr<nsIContent> mRootContent;
 
   nsresult Init(mozilla::WidgetQueryContentEvent* aEvent);
-  nsresult Init(nsSelectionEvent* aEvent);
+  nsresult Init(mozilla::WidgetSelectionEvent* aEvent);
 
   // InitCommon() is called from each Init().
   nsresult InitCommon();
 
 public:
   // FlatText means the text that is generated from DOM tree. The BR elements
   // are replaced to native linefeeds. Other elements are ignored.
 
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -1051,26 +1051,26 @@ nsEventStateManager::PreHandleEvent(nsPr
       // XXX remote event
       nsContentEventHandler handler(mPresContext);
       handler.OnQueryDOMWidgetHittest(
         static_cast<WidgetQueryContentEvent*>(aEvent));
     }
     break;
   case NS_SELECTION_SET:
     {
-      nsSelectionEvent *selectionEvent =
-          static_cast<nsSelectionEvent*>(aEvent);
+      WidgetSelectionEvent *selectionEvent =
+          static_cast<WidgetSelectionEvent*>(aEvent);
       if (IsTargetCrossProcess(selectionEvent)) {
         // Will not be handled locally, remote the event
         if (GetCrossProcessTarget()->SendSelectionEvent(*selectionEvent))
           selectionEvent->mSucceeded = true;
         break;
       }
       nsContentEventHandler handler(mPresContext);
-      handler.OnSelectionEvent((nsSelectionEvent*)aEvent);
+      handler.OnSelectionEvent(static_cast<WidgetSelectionEvent*>(aEvent));
     }
     break;
   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:
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -1965,17 +1965,17 @@ nsDOMWindowUtils::SendSelectionSetEvent(
   }
 
   // get the widget to send the event to
   nsCOMPtr<nsIWidget> widget = GetWidget();
   if (!widget) {
     return NS_ERROR_FAILURE;
   }
 
-  nsSelectionEvent selectionEvent(true, NS_SELECTION_SET, widget);
+  WidgetSelectionEvent selectionEvent(true, NS_SELECTION_SET, widget);
   InitEvent(selectionEvent);
 
   selectionEvent.mOffset = aOffset;
   selectionEvent.mLength = aLength;
   selectionEvent.mReversed = aReverse;
 
   nsEventStatus status;
   nsresult rv = widget->DispatchEvent(&selectionEvent, status);
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -41,17 +41,17 @@ using nsIMEUpdatePreference;
 using nsIntPoint;
 using nsIntRect;
 using nsIntSize;
 using mozilla::WidgetKeyboardEvent;
 using nsMouseEvent;
 using nsMouseScrollEvent;
 using mozilla::WheelEvent;
 using nsRect;
-using nsSelectionEvent;
+using mozilla::WidgetSelectionEvent;
 using mozilla::WidgetTextEvent;
 using mozilla::WidgetTouchEvent;
 using RemoteDOMEvent;
 using mozilla::dom::ScreenOrientation;
 using mozilla::layers::TextureFactoryIdentifier;
 using mozilla::CSSIntPoint;
 using mozilla::CSSToScreenScale;
 namespace mozilla {
@@ -379,17 +379,17 @@ child:
              int32_t aCharCode,
              int32_t aModifiers,
              bool aPreventDefault);
 
     CompositionEvent(WidgetCompositionEvent event);
 
     TextEvent(WidgetTextEvent event);
 
-    SelectionEvent(nsSelectionEvent event);
+    SelectionEvent(WidgetSelectionEvent event);
 
     /**
      * Activate event forwarding from client to parent.
      */
     ActivateFrameEvent(nsString aType, bool capture);
 
     LoadRemoteScript(nsString aURL);
 
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -1894,19 +1894,19 @@ TabChild::RecvTextEvent(const WidgetText
 {
   WidgetTextEvent localEvent(event);
   DispatchWidgetEvent(localEvent);
   IPC::ParamTraits<WidgetTextEvent>::Free(event);
   return true;
 }
 
 bool
-TabChild::RecvSelectionEvent(const nsSelectionEvent& event)
+TabChild::RecvSelectionEvent(const WidgetSelectionEvent& event)
 {
-  nsSelectionEvent localEvent(event);
+  WidgetSelectionEvent localEvent(event);
   DispatchWidgetEvent(localEvent);
   return true;
 }
 
 nsEventStatus
 TabChild::DispatchWidgetEvent(nsGUIEvent& event)
 {
   if (!mWidget)
--- a/dom/ipc/TabChild.h
+++ b/dom/ipc/TabChild.h
@@ -222,17 +222,17 @@ public:
     virtual bool RecvRealTouchMoveEvent(const WidgetTouchEvent& event);
     virtual bool RecvKeyEvent(const nsString& aType,
                               const int32_t&  aKeyCode,
                               const int32_t&  aCharCode,
                               const int32_t&  aModifiers,
                               const bool&     aPreventDefault);
     virtual bool RecvCompositionEvent(const mozilla::WidgetCompositionEvent& event);
     virtual bool RecvTextEvent(const mozilla::WidgetTextEvent& event);
-    virtual bool RecvSelectionEvent(const nsSelectionEvent& event);
+    virtual bool RecvSelectionEvent(const mozilla::WidgetSelectionEvent& event);
     virtual bool RecvActivateFrameEvent(const nsString& aType, const bool& capture);
     virtual bool RecvLoadRemoteScript(const nsString& aURL);
     virtual bool RecvAsyncMessage(const nsString& aMessage,
                                   const ClonedMessageData& aData,
                                   const InfallibleTArray<CpowEntry>& aCpows);
 
     virtual PDocumentRendererChild*
     AllocPDocumentRendererChild(const nsRect& documentRect, const gfxMatrix& transform,
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -1025,17 +1025,17 @@ TabParent::SendTextEvent(WidgetTextEvent
   mIMESelectionAnchor = mIMESelectionFocus =
       mIMECompositionStart + event.theText.Length();
 
   event.seqno = ++mIMESeqno;
   return PBrowserParent::SendTextEvent(event);
 }
 
 bool
-TabParent::SendSelectionEvent(nsSelectionEvent& event)
+TabParent::SendSelectionEvent(WidgetSelectionEvent& event)
 {
   if (mIsDestroyed) {
     return false;
   }
   mIMESelectionAnchor = event.mOffset + (event.mReversed ? event.mLength : 0);
   mIMESelectionFocus = event.mOffset + (!event.mReversed ? event.mLength : 0);
   event.seqno = ++mIMESeqno;
   return PBrowserParent::SendSelectionEvent(event);
--- a/dom/ipc/TabParent.h
+++ b/dom/ipc/TabParent.h
@@ -222,17 +222,17 @@ public:
     NS_DECL_NSISECUREBROWSERUI
 
     void HandleDelayedDialogs();
 
     static TabParent *GetIMETabParent() { return mIMETabParent; }
     bool HandleQueryContentEvent(mozilla::WidgetQueryContentEvent& aEvent);
     bool SendCompositionEvent(mozilla::WidgetCompositionEvent& event);
     bool SendTextEvent(mozilla::WidgetTextEvent& event);
-    bool SendSelectionEvent(nsSelectionEvent& event);
+    bool SendSelectionEvent(mozilla::WidgetSelectionEvent& event);
 
     static TabParent* GetFrom(nsFrameLoader* aFrameLoader);
     static TabParent* GetFrom(nsIContent* aContent);
 
     ContentParent* Manager() { return mManager; }
 
 protected:
     bool ReceiveMessage(const nsString& aMessage,
--- a/widget/BasicEvents.h
+++ b/widget/BasicEvents.h
@@ -330,17 +330,17 @@ enum nsEventStructType
 #define NS_SIMPLE_GESTURE_EDGE_CANCELED  (NS_SIMPLE_GESTURE_EVENT_START+13)
 #define NS_SIMPLE_GESTURE_EDGE_COMPLETED (NS_SIMPLE_GESTURE_EVENT_START+14)
 
 // These are used to send native events to plugins.
 #define NS_PLUGIN_EVENT_START            3600
 #define NS_PLUGIN_INPUT_EVENT            (NS_PLUGIN_EVENT_START)
 #define NS_PLUGIN_FOCUS_EVENT            (NS_PLUGIN_EVENT_START+1)
 
-// Events to manipulate selection (nsSelectionEvent)
+// Events to manipulate selection (WidgetSelectionEvent)
 #define NS_SELECTION_EVENT_START        3700
 // Clear any previous selection and set the given range as the selection
 #define NS_SELECTION_SET                (NS_SELECTION_EVENT_START)
 
 // Events of commands for the contents
 #define NS_CONTENT_COMMAND_EVENT_START  3800
 #define NS_CONTENT_COMMAND_CUT          (NS_CONTENT_COMMAND_EVENT_START)
 #define NS_CONTENT_COMMAND_COPY         (NS_CONTENT_COMMAND_EVENT_START+1)
--- a/widget/EventForwards.h
+++ b/widget/EventForwards.h
@@ -102,17 +102,16 @@ class WidgetPluginEvent;
 class InternalMutationEvent;
 } // namespace mozilla
 
 // TODO: Remove following typedefs
 typedef mozilla::WidgetEvent               nsEvent;
 typedef mozilla::WidgetGUIEvent            nsGUIEvent;
 typedef mozilla::WidgetInputEvent          nsInputEvent;
 typedef mozilla::InternalUIEvent           nsUIEvent;
-typedef mozilla::WidgetSelectionEvent      nsSelectionEvent;
 typedef mozilla::WidgetMouseEventBase      nsMouseEvent_base;
 typedef mozilla::WidgetMouseEvent          nsMouseEvent;
 typedef mozilla::WidgetDragEvent           nsDragEvent;
 typedef mozilla::WidgetMouseScrollEvent    nsMouseScrollEvent;
 
 namespace mozilla {
 typedef WidgetWheelEvent                   WheelEvent;
 }
--- a/widget/TextEvents.h
+++ b/widget/TextEvents.h
@@ -528,12 +528,9 @@ public:
   // Cluster-based or character-based
   bool mExpandToClusterBoundary;
   // true if setting selection succeeded.
   bool mSucceeded;
 };
 
 } // namespace mozilla
 
-// TODO: Remove following typedefs
-typedef mozilla::WidgetSelectionEvent    nsSelectionEvent;
-
 #endif // mozilla_TextEvents_h__
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1899,17 +1899,17 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *
                   selection event is not passed on to Java
 
                 Text updates are passed on, so the Java text can shadow the
                   Gecko text
             */
             AutoIMEMask selMask(mIMEMaskSelectionUpdate);
             RemoveIMEComposition();
             {
-                nsSelectionEvent event(true, NS_SELECTION_SET, this);
+                WidgetSelectionEvent event(true, NS_SELECTION_SET, this);
                 InitEvent(event, nullptr);
                 event.mOffset = uint32_t(ae->Start());
                 event.mLength = uint32_t(ae->End() - ae->Start());
                 event.mExpandToClusterBoundary = false;
                 DispatchEvent(&event);
             }
 
             if (!mIMEKeyEvents.IsEmpty()) {
@@ -1948,17 +1948,17 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *
             /*
                 Set Gecko selection to ae->Start() to ae->End()
 
                 Selection updates are masked to prevent Java from being
                   notified of the new selection
             */
             AutoIMEMask selMask(mIMEMaskSelectionUpdate);
             RemoveIMEComposition();
-            nsSelectionEvent selEvent(true, NS_SELECTION_SET, this);
+            WidgetSelectionEvent selEvent(true, NS_SELECTION_SET, this);
             InitEvent(selEvent, nullptr);
 
             int32_t start = ae->Start(), end = ae->End();
 
             if (start < 0 || end < 0) {
                 WidgetQueryContentEvent event(true, NS_QUERY_SELECTED_TEXT,
                                               this);
                 InitEvent(event, nullptr);
@@ -2016,17 +2016,17 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *
 
             WidgetTextEvent event(true, NS_TEXT_TEXT, this);
             InitEvent(event, nullptr);
 
             event.rangeArray = mIMERanges.Elements();
             event.rangeCount = mIMERanges.Length();
 
             {
-                nsSelectionEvent event(true, NS_SELECTION_SET, this);
+                WidgetSelectionEvent event(true, NS_SELECTION_SET, this);
                 InitEvent(event, nullptr);
                 event.mOffset = uint32_t(ae->Start());
                 event.mLength = uint32_t(ae->End() - ae->Start());
                 event.mExpandToClusterBoundary = false;
                 DispatchEvent(&event);
             }
             {
                 WidgetQueryContentEvent queryEvent(true,
--- a/widget/cocoa/TextInputHandler.mm
+++ b/widget/cocoa/TextInputHandler.mm
@@ -4373,17 +4373,17 @@ TextInputHandlerBase::AttachNativeKeyEve
 }
 
 bool
 TextInputHandlerBase::SetSelection(NSRange& aRange)
 {
   MOZ_ASSERT(!Destroyed());
 
   nsRefPtr<TextInputHandlerBase> kungFuDeathGrip(this);
-  nsSelectionEvent selectionEvent(true, NS_SELECTION_SET, mWidget);
+  WidgetSelectionEvent selectionEvent(true, NS_SELECTION_SET, mWidget);
   selectionEvent.mOffset = aRange.location;
   selectionEvent.mLength = aRange.length;
   selectionEvent.mReversed = false;
   selectionEvent.mExpandToClusterBoundary = false;
   DispatchEvent(selectionEvent);
   NS_ENSURE_TRUE(selectionEvent.mSucceeded, false);
   return !Destroyed();
 }
--- a/widget/gtk/nsGtkIMModule.cpp
+++ b/widget/gtk/nsGtkIMModule.cpp
@@ -1491,18 +1491,18 @@ nsGtkIMModule::DeleteText(const int32_t 
     }
 
     gchar* charAtOffset =
         g_utf8_offset_to_pointer(utf8Str.get(), offsetInUTF8Characters);
     gchar* charAtEnd =
         g_utf8_offset_to_pointer(utf8Str.get(), endInUTF8Characters);
 
     // Set selection to delete
-    nsSelectionEvent selectionEvent(true, NS_SELECTION_SET,
-                                    mLastFocusedWindow);
+    WidgetSelectionEvent selectionEvent(true, NS_SELECTION_SET,
+                                        mLastFocusedWindow);
 
     nsDependentCSubstring utf8StrBeforeOffset(utf8Str, 0,
                                               charAtOffset - utf8Str.get());
     selectionEvent.mOffset =
         NS_ConvertUTF8toUTF16(utf8StrBeforeOffset).Length();
 
     nsDependentCSubstring utf8DeletingStr(utf8Str,
                                           utf8StrBeforeOffset.Length(),
--- a/widget/nsGUIEventIPC.h
+++ b/widget/nsGUIEventIPC.h
@@ -436,19 +436,19 @@ struct ParamTraits<mozilla::WidgetQueryC
            ReadParam(aMsg, aIter, &aResult->mReply.mRect) &&
            ReadParam(aMsg, aIter, &aResult->mReply.mReversed) &&
            ReadParam(aMsg, aIter, &aResult->mReply.mHasSelection) &&
            ReadParam(aMsg, aIter, &aResult->mReply.mWidgetIsHit);
   }
 };
 
 template<>
-struct ParamTraits<nsSelectionEvent>
+struct ParamTraits<mozilla::WidgetSelectionEvent>
 {
-  typedef nsSelectionEvent paramType;
+  typedef mozilla::WidgetSelectionEvent paramType;
 
   static void Write(Message* aMsg, const paramType& aParam)
   {
     WriteParam(aMsg, static_cast<nsGUIEvent>(aParam));
     WriteParam(aMsg, aParam.seqno);
     WriteParam(aMsg, aParam.mOffset);
     WriteParam(aMsg, aParam.mLength);
     WriteParam(aMsg, aParam.mReversed);
--- a/widget/windows/nsTextStore.cpp
+++ b/widget/windows/nsTextStore.cpp
@@ -846,17 +846,17 @@ nsTextStore::FlushPendingActions()
                ("TSF: 0x%p   nsTextStore::FlushPendingActions() "
                 "flushing COMPOSITION_START={ mSelectionStart=%d, "
                 "mSelectionLength=%d }",
                 this, action.mSelectionStart, action.mSelectionLength));
 
         MOZ_ASSERT(mComposition.mLastData.IsEmpty());
 
         // Select composition range so the new composition replaces the range
-        nsSelectionEvent selectionSet(true, NS_SELECTION_SET, mWidget);
+        WidgetSelectionEvent selectionSet(true, NS_SELECTION_SET, mWidget);
         mWidget->InitEvent(selectionSet);
         selectionSet.mOffset = static_cast<uint32_t>(action.mSelectionStart);
         selectionSet.mLength = static_cast<uint32_t>(action.mSelectionLength);
         selectionSet.mReversed = false;
         mWidget->DispatchWindowEvent(&selectionSet);
         if (!selectionSet.mSucceeded) {
           PR_LOG(sTextStoreLog, PR_LOG_ERROR,
                  ("TSF: 0x%p   nsTextStore::FlushPendingActions() "
@@ -1012,17 +1012,17 @@ nsTextStore::FlushPendingActions()
       case PendingAction::SELECTION_SET: {
         PR_LOG(sTextStoreLog, PR_LOG_DEBUG,
                ("TSF: 0x%p   nsTextStore::FlushPendingActions() "
                 "flushing SELECTION_SET={ mSelectionStart=%d, "
                 "mSelectionLength=%d, mSelectionReversed=%s }",
                 this, action.mSelectionStart, action.mSelectionLength,
                 GetBoolName(action.mSelectionReversed)));
 
-        nsSelectionEvent selectionSet(true, NS_SELECTION_SET, mWidget);
+        WidgetSelectionEvent selectionSet(true, NS_SELECTION_SET, mWidget);
         selectionSet.mOffset = 
           static_cast<uint32_t>(action.mSelectionStart);
         selectionSet.mLength =
           static_cast<uint32_t>(action.mSelectionLength);
         selectionSet.mReversed = action.mSelectionReversed;
         break;
       }
       default:
--- a/widget/xpwidgets/PuppetWidget.cpp
+++ b/widget/xpwidgets/PuppetWidget.cpp
@@ -280,17 +280,17 @@ PuppetWidget::DispatchEvent(nsGUIEvent* 
       return NS_OK;
     break;
   case NS_TEXT_EVENT:
     mIMELastReceivedSeqno = static_cast<WidgetTextEvent*>(event)->seqno;
     if (mIMELastReceivedSeqno < mIMELastBlurSeqno)
       return NS_OK;
     break;
   case NS_SELECTION_EVENT:
-    mIMELastReceivedSeqno = static_cast<nsSelectionEvent*>(event)->seqno;
+    mIMELastReceivedSeqno = static_cast<WidgetSelectionEvent*>(event)->seqno;
     if (mIMELastReceivedSeqno < mIMELastBlurSeqno)
       return NS_OK;
     break;
   default:
     break;
   }
 
   if (mAttachedWidgetListener) {