Bug 1623181 - Remove nsAutoPtr usage from widget/gtk. r=stransky

Differential Revision: https://phabricator.services.mozilla.com/D67243

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Eric Rahm 2020-03-18 12:30:50 +00:00
Родитель abc5a1f51d
Коммит 2ebdb299d2
4 изменённых файлов: 12 добавлений и 10 удалений

Просмотреть файл

@ -91,10 +91,10 @@ NS_IMPL_ISUPPORTS(nsClipboard, nsIClipboard, nsIObserver)
nsresult nsClipboard::Init(void) { nsresult nsClipboard::Init(void) {
if (gfxPlatformGtk::GetPlatform()->IsX11Display()) { if (gfxPlatformGtk::GetPlatform()->IsX11Display()) {
mContext = new nsRetrievalContextX11(); mContext = MakeUnique<nsRetrievalContextX11>();
#if defined(MOZ_WAYLAND) #if defined(MOZ_WAYLAND)
} else { } else {
mContext = new nsRetrievalContextWayland(); mContext = MakeUnique<nsRetrievalContextWayland>();
#endif #endif
} }
NS_ASSERTION(mContext, "Missing nsRetrievalContext for nsClipboard!"); NS_ASSERTION(mContext, "Missing nsRetrievalContext for nsClipboard!");

Просмотреть файл

@ -8,6 +8,7 @@
#ifndef __nsClipboard_h_ #ifndef __nsClipboard_h_
#define __nsClipboard_h_ #define __nsClipboard_h_
#include "mozilla/UniquePtr.h"
#include "nsIClipboard.h" #include "nsIClipboard.h"
#include "nsIObserver.h" #include "nsIObserver.h"
#include <gtk/gtk.h> #include <gtk/gtk.h>
@ -78,7 +79,7 @@ class nsClipboard : public nsIClipboard, public nsIObserver {
nsCOMPtr<nsIClipboardOwner> mGlobalOwner; nsCOMPtr<nsIClipboardOwner> mGlobalOwner;
nsCOMPtr<nsITransferable> mSelectionTransferable; nsCOMPtr<nsITransferable> mSelectionTransferable;
nsCOMPtr<nsITransferable> mGlobalTransferable; nsCOMPtr<nsITransferable> mGlobalTransferable;
nsAutoPtr<nsRetrievalContext> mContext; mozilla::UniquePtr<nsRetrievalContext> mContext;
}; };
extern const int kClipboardTimeout; extern const int kClipboardTimeout;

Просмотреть файл

@ -446,7 +446,7 @@ void nsRetrievalContextWayland::SetClipboardDataOffer(
NS_ASSERTION(dataOffer, "We're missing stored clipboard data offer!"); NS_ASSERTION(dataOffer, "We're missing stored clipboard data offer!");
if (dataOffer) { if (dataOffer) {
g_hash_table_remove(mActiveOffers, aWaylandDataOffer); 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!"); NS_ASSERTION(dataOffer, "We're missing primary data offer!");
if (dataOffer) { if (dataOffer) {
g_hash_table_remove(mActiveOffers, aPrimaryDataOffer); g_hash_table_remove(mActiveOffers, aPrimaryDataOffer);
mPrimaryOffer = dataOffer; mPrimaryOffer = WrapUnique(dataOffer);
} }
} }
} }
@ -758,7 +758,7 @@ const char* nsRetrievalContextWayland::GetClipboardData(
wayland_clipboard_contents_received, wayland_clipboard_contents_received,
new FastTrackClipboard(mClipboardRequestNumber, this)); new FastTrackClipboard(mClipboardRequestNumber, this));
} else { } else {
DataOffer* dataOffer = const auto& dataOffer =
(selection == GDK_SELECTION_PRIMARY) ? mPrimaryOffer : mClipboardOffer; (selection == GDK_SELECTION_PRIMARY) ? mPrimaryOffer : mClipboardOffer;
if (!dataOffer) { if (!dataOffer) {
// Something went wrong. We're requested to provide clipboard data // Something went wrong. We're requested to provide clipboard data
@ -781,7 +781,7 @@ const char* nsRetrievalContextWayland::GetClipboardText(
LOGCLIP(("nsRetrievalContextWayland::GetClipboardText\n")); LOGCLIP(("nsRetrievalContextWayland::GetClipboardText\n"));
GdkAtom selection = GetSelectionAtom(aWhichClipboard); GdkAtom selection = GetSelectionAtom(aWhichClipboard);
DataOffer* dataOffer = const auto& dataOffer =
(selection == GDK_SELECTION_PRIMARY) ? mPrimaryOffer : mClipboardOffer; (selection == GDK_SELECTION_PRIMARY) ? mPrimaryOffer : mClipboardOffer;
if (!dataOffer) return nullptr; if (!dataOffer) return nullptr;

Просмотреть файл

@ -12,6 +12,7 @@
#include <gdk/gdkwayland.h> #include <gdk/gdkwayland.h>
#include <nsTArray.h> #include <nsTArray.h>
#include "mozilla/UniquePtr.h"
#include "nsClipboard.h" #include "nsClipboard.h"
#include "nsWaylandDisplay.h" #include "nsWaylandDisplay.h"
#include "mozwayland/mozwayland.h" #include "mozwayland/mozwayland.h"
@ -100,7 +101,7 @@ class nsWaylandDragContext : public nsISupports {
private: private:
virtual ~nsWaylandDragContext() = default; virtual ~nsWaylandDragContext() = default;
nsAutoPtr<WaylandDataOffer> mDataOffer; mozilla::UniquePtr<WaylandDataOffer> mDataOffer;
wl_display* mDisplay; wl_display* mDisplay;
uint32_t mTime; uint32_t mTime;
GtkWidget* mGtkWidget; GtkWidget* mGtkWidget;
@ -142,8 +143,8 @@ class nsRetrievalContextWayland : public nsRetrievalContext {
// Data offers provided by Wayland data device // Data offers provided by Wayland data device
GHashTable* mActiveOffers; GHashTable* mActiveOffers;
nsAutoPtr<DataOffer> mClipboardOffer; mozilla::UniquePtr<DataOffer> mClipboardOffer;
nsAutoPtr<DataOffer> mPrimaryOffer; mozilla::UniquePtr<DataOffer> mPrimaryOffer;
RefPtr<nsWaylandDragContext> mDragContext; RefPtr<nsWaylandDragContext> mDragContext;
int mClipboardRequestNumber; int mClipboardRequestNumber;