b=497498 remove nsIDragSessionGTK r=roc
authorKarl Tomlinson <karlt+@karlt.net>
Thu, 19 Apr 2012 18:18:31 +1200
changeset 95093 ac5c8077e3539114b40254d30895ba83ffe82cf1
parent 95092 ce526785dc499ea0103c95d20c82632e9d5b6b19
child 95094 eb870a2d03f7197509e1c5fd94068979ee0d0f0d
push id1439
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 20:19:22 +0000
treeherdermozilla-aurora@ea74834dccd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs497498
milestone15.0a1
b=497498 remove nsIDragSessionGTK r=roc
widget/Makefile.in
widget/gtk2/nsDragService.cpp
widget/gtk2/nsDragService.h
widget/gtk2/nsWindow.cpp
widget/nsIDragSessionGTK.h
--- a/widget/Makefile.in
+++ b/widget/Makefile.in
@@ -120,17 +120,16 @@ endif
 ifneq (,$(filter android gonk,$(MOZ_WIDGET_TOOLKIT)))
 EXPORTS		+= \
 		nsIPrintDialogService.h \
 		$(NULL)
 endif
 
 ifneq (,$(filter qt gtk2,$(MOZ_WIDGET_TOOLKIT)))
 EXPORTS		+= \
-		nsIDragSessionGTK.h \
 		nsIPrintDialogService.h \
 		$(NULL)
 endif
 
 XPIDLSRCS	= \
 		nsIAppShell.idl \
 		nsIFilePicker.idl \
 		nsISound.idl \
--- a/widget/gtk2/nsDragService.cpp
+++ b/widget/gtk2/nsDragService.cpp
@@ -176,18 +176,17 @@ nsDragService::nsDragService()
 nsDragService::~nsDragService()
 {
     PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::~nsDragService"));
     if (mTaskSource)
         g_source_remove(mTaskSource);
 
 }
 
-NS_IMPL_ISUPPORTS_INHERITED2(nsDragService, nsBaseDragService,
-                             nsIDragSessionGTK, nsIObserver)
+NS_IMPL_ISUPPORTS_INHERITED1(nsDragService, nsBaseDragService, nsIObserver)
 
 /* static */ nsDragService*
 nsDragService::GetInstance()
 {
     static const nsIID iid = NS_DRAGSERVICE_CID;
     nsCOMPtr<nsIDragService> dragService = do_GetService(iid);
     return static_cast<nsDragService*>(dragService.get());
     // We rely on XPCOM keeping a reference to the service.
@@ -1009,68 +1008,42 @@ nsDragService::IsDataFlavorSupported(con
                    against text/unicode or application/x-moz-file)\n"));
             *_retval = true;
         }
         g_free(name);
     }
     return NS_OK;
 }
 
-// nsIDragSessionGTK
-
-NS_IMETHODIMP
-nsDragService::TargetSetLastContext(GtkWidget      *aWidget,
-                                    GdkDragContext *aContext,
-                                    guint           aTime)
-{
-    PR_LOG(sDragLm, PR_LOG_DEBUG, ("nsDragService::TargetSetLastContext"));
-    mTargetWidget = aWidget;
-    mTargetDragContext = aContext;
-    mTargetTime = aTime;
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDragService::TargetStartDragMotion(void)
-{
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDragService::TargetEndDragMotion(GtkWidget      *aWidget,
-                                   GdkDragContext *aContext,
-                                   guint           aTime)
+void
+nsDragService::ReplyToDragMotion()
 {
     PR_LOG(sDragLm, PR_LOG_DEBUG,
-           ("nsDragService::TargetEndDragMotion %d", mCanDrop));
+           ("nsDragService::ReplyToDragMotion %d", mCanDrop));
 
+    GdkDragAction action = (GdkDragAction)0;
     if (mCanDrop) {
-        GdkDragAction action;
         // notify the dragger if we can drop
         switch (mDragAction) {
         case DRAGDROP_ACTION_COPY:
           action = GDK_ACTION_COPY;
           break;
         case DRAGDROP_ACTION_LINK:
           action = GDK_ACTION_LINK;
           break;
         default:
           action = GDK_ACTION_MOVE;
           break;
         }
-        gdk_drag_status(aContext, action, aTime);
-    }
-    else {
-        gdk_drag_status(aContext, (GdkDragAction)0, aTime);
     }
 
-    return NS_OK;
+    gdk_drag_status(mTargetDragContext, action, mTargetTime);
 }
 
-NS_IMETHODIMP
+void
 nsDragService::TargetDataReceived(GtkWidget         *aWidget,
                                   GdkDragContext    *aContext,
                                   gint               aX,
                                   gint               aY,
                                   GtkSelectionData  *aSelectionData,
                                   guint              aInfo,
                                   guint32            aTime)
 {
@@ -1082,27 +1055,18 @@ nsDragService::TargetDataReceived(GtkWid
         mTargetDragData = g_malloc(mTargetDragDataLen);
         memcpy(mTargetDragData, aSelectionData->data, mTargetDragDataLen);
     }
     else {
         PR_LOG(sDragLm, PR_LOG_DEBUG,
                ("Failed to get data.  selection data len was %d\n",
                 aSelectionData->length));
     }
-    return NS_OK;
 }
 
-
-NS_IMETHODIMP
-nsDragService::TargetSetTimeCallback(nsIDragSessionGTKTimeCB aCallback)
-{
-    return NS_OK;
-}
-
-
 bool
 nsDragService::IsTargetContextList(void)
 {
     bool retval = false;
 
     // gMimeListType drags only work for drags within a single process.
     // The gtk_drag_get_source_widget() function will return NULL if the
     // source of the drag is another app, so we use it to check if a
@@ -1904,17 +1868,17 @@ nsDragService::RunScheduledTask()
     // protocol is used.
     if (task == eDragTaskMotion || positionHasChanged) {
         UpdateDragAction();
         DispatchMotionEvents();
 
         if (task == eDragTaskMotion) {
             // Reply to tell the source whether we can drop and what
             // action would be taken.
-            TargetEndDragMotion(mTargetWidget, mTargetDragContext, mTargetTime);
+            ReplyToDragMotion();
         }
     }
 
     if (task == eDragTaskDrop) {
         gboolean success = DispatchDropEvent();
 
         // Perhaps we should set the del parameter to TRUE when the drag
         // action is move, but we don't know whether the data was successfully
--- a/widget/gtk2/nsDragService.h
+++ b/widget/gtk2/nsDragService.h
@@ -37,17 +37,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsDragService_h__
 #define nsDragService_h__
 
 #include "nsBaseDragService.h"
-#include "nsIDragSessionGTK.h"
 #include "nsIObserver.h"
 #include <gtk/gtk.h>
 
 class nsWindow;
 
 #ifndef HAVE_NSGOBJECTREFTRAITS
 #define HAVE_NSGOBJECTREFTRAITS
 template <class T>
@@ -71,17 +70,16 @@ class nsAutoRefTraits<GdkDragContext> :
     public nsGObjectRefTraits<GdkDragContext> { };
 #endif
 
 /**
  * Native GTK DragService wrapper
  */
 
 class nsDragService : public nsBaseDragService,
-                      public nsIDragSessionGTK,
                       public nsIObserver
 {
 public:
     nsDragService();
     virtual ~nsDragService();
 
     NS_DECL_ISUPPORTS_INHERITED
 
@@ -98,40 +96,29 @@ public:
     // nsIDragSession
     NS_IMETHOD SetCanDrop            (bool             aCanDrop);
     NS_IMETHOD GetCanDrop            (bool            *aCanDrop);
     NS_IMETHOD GetNumDropItems       (PRUint32 * aNumItems);
     NS_IMETHOD GetData               (nsITransferable * aTransferable,
                                       PRUint32 aItemIndex);
     NS_IMETHOD IsDataFlavorSupported (const char *aDataFlavor, bool *_retval);
 
-    // nsIDragSessionGTK
+    // Methods called from nsWindow to handle responding to GTK drag
+    // destination signals
 
-    NS_IMETHOD TargetSetLastContext  (GtkWidget      *aWidget,
-                                      GdkDragContext *aContext,
-                                      guint           aTime);
-    NS_IMETHOD TargetStartDragMotion (void);
-    NS_IMETHOD TargetEndDragMotion   (GtkWidget      *aWidget,
-                                      GdkDragContext *aContext,
-                                      guint           aTime);
-    NS_IMETHOD TargetDataReceived    (GtkWidget         *aWidget,
+    static nsDragService* GetInstance();
+
+    void TargetDataReceived          (GtkWidget         *aWidget,
                                       GdkDragContext    *aContext,
                                       gint               aX,
                                       gint               aY,
                                       GtkSelectionData  *aSelection_data,
                                       guint              aInfo,
                                       guint32            aTime);
 
-    NS_IMETHOD TargetSetTimeCallback (nsIDragSessionGTKTimeCB aCallback);
-
-    static nsDragService* GetInstance();
-
-    // Methods called from nsWindow to handle responding to GTK drag
-    // destination signals
-
     gboolean ScheduleMotionEvent(nsWindow *aWindow,
                                  GdkDragContext *aDragContext,
                                  nsIntPoint aWindowPoint,
                                  guint aTime);
     void ScheduleLeaveEvent();
     gboolean ScheduleDropEvent(nsWindow *aWindow,
                                GdkDragContext *aDragContext,
                                nsIntPoint aWindowPoint,
@@ -241,13 +228,14 @@ private:
                       GdkDragContext *aDragContext,
                       nsIntPoint aWindowPoint, guint aTime);
 
     // Callback for g_idle_add_full() to run mScheduledTask.
     static gboolean TaskDispatchCallback(gpointer data);
     gboolean RunScheduledTask();
     void UpdateDragAction();
     void DispatchMotionEvents();
+    void ReplyToDragMotion();
     gboolean DispatchDropEvent();
 };
 
 #endif // nsDragService_h__
 
--- a/widget/gtk2/nsWindow.cpp
+++ b/widget/gtk2/nsWindow.cpp
@@ -50,17 +50,16 @@
 #include "prlink.h"
 #include "nsWindow.h"
 #include "nsGTKToolkit.h"
 #include "nsIRollupListener.h"
 #include "nsIDOMNode.h"
 
 #include "nsWidgetsCID.h"
 #include "nsDragService.h"
-#include "nsIDragSessionGTK.h"
 
 #include "nsGtkKeyUtils.h"
 #include "nsGtkCursors.h"
 
 #include <gtk/gtk.h>
 #if defined(MOZ_WIDGET_GTK3)
 #include <gtk/gtkx.h>
 #endif
@@ -3327,22 +3326,19 @@ nsWindow::OnDragDataReceivedEvent(GtkWid
                                   gint aY,
                                   GtkSelectionData  *aSelectionData,
                                   guint aInfo,
                                   guint aTime,
                                   gpointer aData)
 {
     LOGDRAG(("nsWindow::OnDragDataReceived(%p)\n", (void*)this));
 
-    // get our drag context
-    nsCOMPtr<nsIDragService> dragService = do_GetService(kCDragServiceCID);
-    nsCOMPtr<nsIDragSessionGTK> dragSessionGTK = do_QueryInterface(dragService);
-
-    dragSessionGTK->TargetDataReceived(aWidget, aDragContext, aX, aY,
-                                       aSelectionData, aInfo, aTime);
+    nsDragService::GetInstance()->
+        TargetDataReceived(aWidget, aDragContext, aX, aY,
+                           aSelectionData, aInfo, aTime);
 }
 
 static void
 GetBrandName(nsXPIDLString& brandName)
 {
     nsCOMPtr<nsIStringBundleService> bundleService =
         do_GetService(NS_STRINGBUNDLE_CONTRACTID);
 
deleted file mode 100644
--- a/widget/nsIDragSessionGTK.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- *
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Christopher Blizzard <blizzard@mozilla.org>.
- * Portions created by the Initial Developer are Copyright (C) 1998
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Christopher Blizzard <blizzard@mozilla.org>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef nsIDragSessionGTK_h_
-#define nsIDragSessionGTK_h_
-
-#include "nsISupports.h"
-
-#include <gtk/gtk.h>
-
-typedef void (*nsIDragSessionGTKTimeCB)(guint32 *aTime);
-
-#define NS_IDRAGSESSIONGTK_IID \
-{ 0xa6b49c42, 0x1dd1, 0x11b2, { 0xb2, 0xdf, 0xc1, 0xd6, 0x1d, 0x67, 0x45, 0xcf } }
-
-class nsIDragSessionGTK : public nsISupports {
-public:
-  NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDRAGSESSIONGTK_IID)
-
-  // Thse are all target methods - that is when the mozilla is a
-  // target of a drag.  Any methods related to when mozilla starts a
-  // drag are elsewhere.
-    
-  // this sets the last drag context used where mozilla is the target
-  // of a drag
-  NS_IMETHOD TargetSetLastContext  (GtkWidget      *aWidget,
-                                    GdkDragContext *aContext,
-                                    guint           aTime) = 0;
-  // this is called at the beginning of a drag motion event
-  NS_IMETHOD TargetStartDragMotion (void) = 0;
-  // this is called at the end of a drag motion event
-  NS_IMETHOD TargetEndDragMotion   (GtkWidget      *aWidget,
-                                    GdkDragContext *aContext,
-                                    guint           aTime) = 0;
-  // this is called when data is received after being sent above
-  NS_IMETHOD TargetDataReceived    (GtkWidget         *aWidget,
-                                    GdkDragContext    *aContext,
-                                    gint               aX,
-                                    gint               aY,
-                                    GtkSelectionData  *aSelection_data,
-                                    guint              aInfo,
-                                    guint32            aTime) = 0;
-  // this sets a callback for time related fun
-  NS_IMETHOD TargetSetTimeCallback (nsIDragSessionGTKTimeCB aCallback) = 0;
-
-};
-
-NS_DEFINE_STATIC_IID_ACCESSOR(nsIDragSessionGTK, NS_IDRAGSESSIONGTK_IID)
-
-#endif /* nsIDragSessionGTK_h_ */