From 2ebdb299d2c5a9951d268bb1ff5c63e7649b655f Mon Sep 17 00:00:00 2001 From: Eric Rahm Date: Wed, 18 Mar 2020 12:30:50 +0000 Subject: [PATCH] Bug 1623181 - Remove nsAutoPtr usage from widget/gtk. r=stransky Differential Revision: https://phabricator.services.mozilla.com/D67243 --HG-- extra : moz-landing-system : lando --- widget/gtk/nsClipboard.cpp | 4 ++-- widget/gtk/nsClipboard.h | 3 ++- widget/gtk/nsClipboardWayland.cpp | 8 ++++---- widget/gtk/nsClipboardWayland.h | 7 ++++--- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/widget/gtk/nsClipboard.cpp b/widget/gtk/nsClipboard.cpp index e87a82aa1425..2ea0bd2e3efc 100644 --- a/widget/gtk/nsClipboard.cpp +++ b/widget/gtk/nsClipboard.cpp @@ -91,10 +91,10 @@ NS_IMPL_ISUPPORTS(nsClipboard, nsIClipboard, nsIObserver) nsresult nsClipboard::Init(void) { if (gfxPlatformGtk::GetPlatform()->IsX11Display()) { - mContext = new nsRetrievalContextX11(); + mContext = MakeUnique(); #if defined(MOZ_WAYLAND) } else { - mContext = new nsRetrievalContextWayland(); + mContext = MakeUnique(); #endif } NS_ASSERTION(mContext, "Missing nsRetrievalContext for nsClipboard!"); diff --git a/widget/gtk/nsClipboard.h b/widget/gtk/nsClipboard.h index d2eef46e3cad..95b6eb828aaa 100644 --- a/widget/gtk/nsClipboard.h +++ b/widget/gtk/nsClipboard.h @@ -8,6 +8,7 @@ #ifndef __nsClipboard_h_ #define __nsClipboard_h_ +#include "mozilla/UniquePtr.h" #include "nsIClipboard.h" #include "nsIObserver.h" #include @@ -78,7 +79,7 @@ class nsClipboard : public nsIClipboard, public nsIObserver { nsCOMPtr mGlobalOwner; nsCOMPtr mSelectionTransferable; nsCOMPtr mGlobalTransferable; - nsAutoPtr mContext; + mozilla::UniquePtr mContext; }; extern const int kClipboardTimeout; diff --git a/widget/gtk/nsClipboardWayland.cpp b/widget/gtk/nsClipboardWayland.cpp index 9da9236d5741..eaf191e1a7cf 100644 --- a/widget/gtk/nsClipboardWayland.cpp +++ b/widget/gtk/nsClipboardWayland.cpp @@ -446,7 +446,7 @@ void nsRetrievalContextWayland::SetClipboardDataOffer( NS_ASSERTION(dataOffer, "We're missing stored clipboard data offer!"); if (dataOffer) { g_hash_table_remove(mActiveOffers, aWaylandDataOffer); - mClipboardOffer = dataOffer; + mClipboardOffer = WrapUnique(dataOffer); } } } @@ -464,7 +464,7 @@ void nsRetrievalContextWayland::SetPrimaryDataOffer( NS_ASSERTION(dataOffer, "We're missing primary data offer!"); if (dataOffer) { g_hash_table_remove(mActiveOffers, aPrimaryDataOffer); - mPrimaryOffer = dataOffer; + mPrimaryOffer = WrapUnique(dataOffer); } } } @@ -758,7 +758,7 @@ const char* nsRetrievalContextWayland::GetClipboardData( wayland_clipboard_contents_received, new FastTrackClipboard(mClipboardRequestNumber, this)); } else { - DataOffer* dataOffer = + const auto& dataOffer = (selection == GDK_SELECTION_PRIMARY) ? mPrimaryOffer : mClipboardOffer; if (!dataOffer) { // Something went wrong. We're requested to provide clipboard data @@ -781,7 +781,7 @@ const char* nsRetrievalContextWayland::GetClipboardText( LOGCLIP(("nsRetrievalContextWayland::GetClipboardText\n")); GdkAtom selection = GetSelectionAtom(aWhichClipboard); - DataOffer* dataOffer = + const auto& dataOffer = (selection == GDK_SELECTION_PRIMARY) ? mPrimaryOffer : mClipboardOffer; if (!dataOffer) return nullptr; diff --git a/widget/gtk/nsClipboardWayland.h b/widget/gtk/nsClipboardWayland.h index 4aacb443d91d..fcdef785746f 100644 --- a/widget/gtk/nsClipboardWayland.h +++ b/widget/gtk/nsClipboardWayland.h @@ -12,6 +12,7 @@ #include #include +#include "mozilla/UniquePtr.h" #include "nsClipboard.h" #include "nsWaylandDisplay.h" #include "mozwayland/mozwayland.h" @@ -100,7 +101,7 @@ class nsWaylandDragContext : public nsISupports { private: virtual ~nsWaylandDragContext() = default; - nsAutoPtr mDataOffer; + mozilla::UniquePtr mDataOffer; wl_display* mDisplay; uint32_t mTime; GtkWidget* mGtkWidget; @@ -142,8 +143,8 @@ class nsRetrievalContextWayland : public nsRetrievalContext { // Data offers provided by Wayland data device GHashTable* mActiveOffers; - nsAutoPtr mClipboardOffer; - nsAutoPtr mPrimaryOffer; + mozilla::UniquePtr mClipboardOffer; + mozilla::UniquePtr mPrimaryOffer; RefPtr mDragContext; int mClipboardRequestNumber;