mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 04:41:11 +00:00
Bug 1809713 - Make nsIClipboard ClipboardType an enum. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D213742
This commit is contained in:
parent
ffe11a66be
commit
59643a0bd4
@ -3114,7 +3114,8 @@ void ContentParent::OnVarChanged(const GfxVarUpdate& aVar) {
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvSetClipboard(
|
||||
const IPCTransferable& aTransferable, const int32_t& aWhichClipboard,
|
||||
const IPCTransferable& aTransferable,
|
||||
const nsIClipboard::ClipboardType& aWhichClipboard,
|
||||
const MaybeDiscarded<WindowContext>& aRequestingWindowContext) {
|
||||
// aRequestingPrincipal is allowed to be nullptr here.
|
||||
|
||||
@ -3174,7 +3175,8 @@ ContentParent::CreateClipboardTransferable(const nsTArray<nsCString>& aTypes) {
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvGetClipboard(
|
||||
nsTArray<nsCString>&& aTypes, const int32_t& aWhichClipboard,
|
||||
nsTArray<nsCString>&& aTypes,
|
||||
const nsIClipboard::ClipboardType& aWhichClipboard,
|
||||
const MaybeDiscarded<WindowContext>& aRequestingWindowContext,
|
||||
IPCTransferableDataOrError* aTransferableDataOrError) {
|
||||
nsresult rv;
|
||||
@ -3223,7 +3225,7 @@ mozilla::ipc::IPCResult ContentParent::RecvGetClipboard(
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvEmptyClipboard(
|
||||
const int32_t& aWhichClipboard) {
|
||||
const nsIClipboard::ClipboardType& aWhichClipboard) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIClipboard> clipboard(do_GetService(kCClipboardCID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, IPC_OK());
|
||||
@ -3234,8 +3236,8 @@ mozilla::ipc::IPCResult ContentParent::RecvEmptyClipboard(
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvClipboardHasType(
|
||||
nsTArray<nsCString>&& aTypes, const int32_t& aWhichClipboard,
|
||||
bool* aHasType) {
|
||||
nsTArray<nsCString>&& aTypes,
|
||||
const nsIClipboard::ClipboardType& aWhichClipboard, bool* aHasType) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIClipboard> clipboard(do_GetService(kCClipboardCID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, IPC_OK());
|
||||
@ -3313,7 +3315,8 @@ NS_IMPL_ISUPPORTS(ClipboardGetCallback, nsIClipboardGetDataSnapshotCallback)
|
||||
} // namespace
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvGetClipboardDataSnapshot(
|
||||
nsTArray<nsCString>&& aTypes, const int32_t& aWhichClipboard,
|
||||
nsTArray<nsCString>&& aTypes,
|
||||
const nsIClipboard::ClipboardType& aWhichClipboard,
|
||||
const MaybeDiscarded<WindowContext>& aRequestingWindowContext,
|
||||
mozilla::NotNull<nsIPrincipal*> aRequestingPrincipal,
|
||||
GetClipboardDataSnapshotResolver&& aResolver) {
|
||||
@ -3356,7 +3359,8 @@ mozilla::ipc::IPCResult ContentParent::RecvGetClipboardDataSnapshot(
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult ContentParent::RecvGetClipboardDataSnapshotSync(
|
||||
nsTArray<nsCString>&& aTypes, const int32_t& aWhichClipboard,
|
||||
nsTArray<nsCString>&& aTypes,
|
||||
const nsIClipboard::ClipboardType& aWhichClipboard,
|
||||
const MaybeDiscarded<WindowContext>& aRequestingWindowContext,
|
||||
ClipboardReadRequestOrError* aRequestOrError) {
|
||||
// If the requesting context has been discarded, cancel the paste.
|
||||
@ -3399,7 +3403,7 @@ mozilla::ipc::IPCResult ContentParent::RecvGetClipboardDataSnapshotSync(
|
||||
|
||||
already_AddRefed<PClipboardWriteRequestParent>
|
||||
ContentParent::AllocPClipboardWriteRequestParent(
|
||||
const int32_t& aClipboardType,
|
||||
const nsIClipboard::ClipboardType& aClipboardType,
|
||||
const MaybeDiscarded<WindowContext>& aSettingWindowContext) {
|
||||
WindowContext* settingWindowContext = nullptr;
|
||||
if (!aSettingWindowContext.IsDiscarded()) {
|
||||
|
@ -942,34 +942,39 @@ class ContentParent final : public PContentParent,
|
||||
const MaybeDiscarded<BrowsingContext>& aContext);
|
||||
|
||||
mozilla::ipc::IPCResult RecvSetClipboard(
|
||||
const IPCTransferable& aTransferable, const int32_t& aWhichClipboard,
|
||||
const IPCTransferable& aTransferable,
|
||||
const nsIClipboard::ClipboardType& aWhichClipboard,
|
||||
const MaybeDiscarded<WindowContext>& aRequestingWindowContext);
|
||||
|
||||
mozilla::ipc::IPCResult RecvGetClipboard(
|
||||
nsTArray<nsCString>&& aTypes, const int32_t& aWhichClipboard,
|
||||
nsTArray<nsCString>&& aTypes,
|
||||
const nsIClipboard::ClipboardType& aWhichClipboard,
|
||||
const MaybeDiscarded<WindowContext>& aRequestingWindowContext,
|
||||
IPCTransferableDataOrError* aTransferableDataOrError);
|
||||
|
||||
mozilla::ipc::IPCResult RecvEmptyClipboard(const int32_t& aWhichClipboard);
|
||||
mozilla::ipc::IPCResult RecvEmptyClipboard(
|
||||
const nsIClipboard::ClipboardType& aWhichClipboard);
|
||||
|
||||
mozilla::ipc::IPCResult RecvClipboardHasType(nsTArray<nsCString>&& aTypes,
|
||||
const int32_t& aWhichClipboard,
|
||||
bool* aHasType);
|
||||
mozilla::ipc::IPCResult RecvClipboardHasType(
|
||||
nsTArray<nsCString>&& aTypes,
|
||||
const nsIClipboard::ClipboardType& aWhichClipboard, bool* aHasType);
|
||||
|
||||
mozilla::ipc::IPCResult RecvGetClipboardDataSnapshot(
|
||||
nsTArray<nsCString>&& aTypes, const int32_t& aWhichClipboard,
|
||||
nsTArray<nsCString>&& aTypes,
|
||||
const nsIClipboard::ClipboardType& aWhichClipboard,
|
||||
const MaybeDiscarded<WindowContext>& aRequestingWindowContext,
|
||||
mozilla::NotNull<nsIPrincipal*> aRequestingPrincipal,
|
||||
GetClipboardDataSnapshotResolver&& aResolver);
|
||||
|
||||
mozilla::ipc::IPCResult RecvGetClipboardDataSnapshotSync(
|
||||
nsTArray<nsCString>&& aTypes, const int32_t& aWhichClipboard,
|
||||
nsTArray<nsCString>&& aTypes,
|
||||
const nsIClipboard::ClipboardType& aWhichClipboard,
|
||||
const MaybeDiscarded<WindowContext>& aRequestingWindowContext,
|
||||
ClipboardReadRequestOrError* aRequestOrError);
|
||||
|
||||
already_AddRefed<PClipboardWriteRequestParent>
|
||||
AllocPClipboardWriteRequestParent(
|
||||
const int32_t& aClipboardType,
|
||||
const nsIClipboard::ClipboardType& aClipboardType,
|
||||
const MaybeDiscarded<WindowContext>& aSettingWindowContext);
|
||||
|
||||
mozilla::ipc::IPCResult RecvGetIconForExtension(const nsACString& aFileExt,
|
||||
|
@ -84,6 +84,7 @@ include "mozilla/ipc/ByteBufUtils.h";
|
||||
include "mozilla/ipc/TransportSecurityInfoUtils.h";
|
||||
include "mozilla/ipc/URIUtils.h";
|
||||
include "mozilla/net/NeckoMessageUtils.h";
|
||||
include "mozilla/widget/WidgetMessageUtils.h";
|
||||
include "mozilla/PermissionDelegateIPCUtils.h";
|
||||
|
||||
[RefCounted] using class nsIDOMGeoPosition from "nsGeoPositionIPCSerialiser.h";
|
||||
@ -163,6 +164,7 @@ using mozilla::PerfStats::MetricMask from "mozilla/PerfStats.h";
|
||||
using nsIDNSService::ResolverMode from "nsIDNSService.h";
|
||||
using mozilla::dom::UserActivation::Modifiers from "mozilla/dom/UserActivation.h";
|
||||
using mozilla::dom::PrivateAttributionImpressionType from "mozilla/dom/PrivateAttributionIPCUtils.h";
|
||||
using nsIClipboard::ClipboardType from "nsIClipboard.h";
|
||||
|
||||
union ChromeRegistryItem
|
||||
{
|
||||
@ -1210,32 +1212,32 @@ parent:
|
||||
|
||||
// Places the items within dataTransfer on the clipboard.
|
||||
async SetClipboard(IPCTransferable aTransferable,
|
||||
int32_t aWhichClipboard, MaybeDiscardedWindowContext aRequestingWindowContext);
|
||||
ClipboardType aWhichClipboard, MaybeDiscardedWindowContext aRequestingWindowContext);
|
||||
|
||||
// Given a list of supported types, returns the clipboard data for the
|
||||
// first type that matches.
|
||||
// aRequestingWindowContext is the window that is requesting the clipboard,
|
||||
// which is used for content analysis.
|
||||
sync GetClipboard(nsCString[] aTypes, int32_t aWhichClipboard,
|
||||
sync GetClipboard(nsCString[] aTypes, ClipboardType aWhichClipboard,
|
||||
MaybeDiscardedWindowContext aRequestingWindowContext)
|
||||
returns (IPCTransferableDataOrError transferableDataOrError);
|
||||
|
||||
// Requests getting data from clipboard.
|
||||
async GetClipboardDataSnapshot(nsCString[] aTypes, int32_t aWhichClipboard,
|
||||
async GetClipboardDataSnapshot(nsCString[] aTypes, ClipboardType aWhichClipboard,
|
||||
MaybeDiscardedWindowContext aRequestingWindowContext,
|
||||
nsIPrincipal aRequestingPrincipal)
|
||||
returns (ClipboardReadRequestOrError aClipboardReadRequestOrError);
|
||||
|
||||
// Requests getting data from clipboard.
|
||||
sync GetClipboardDataSnapshotSync(nsCString[] aTypes, int32_t aWhichClipboard,
|
||||
sync GetClipboardDataSnapshotSync(nsCString[] aTypes, ClipboardType aWhichClipboard,
|
||||
MaybeDiscardedWindowContext aRequestingWindowContext)
|
||||
returns (ClipboardReadRequestOrError aClipboardReadRequestOrError);
|
||||
|
||||
// Clears the clipboard.
|
||||
async EmptyClipboard(int32_t aWhichClipboard);
|
||||
async EmptyClipboard(ClipboardType aWhichClipboard);
|
||||
|
||||
// Returns true if data of one of the specified types is on the clipboard.
|
||||
sync ClipboardHasType(nsCString[] aTypes, int32_t aWhichClipboard)
|
||||
sync ClipboardHasType(nsCString[] aTypes, ClipboardType aWhichClipboard)
|
||||
returns (bool hasType);
|
||||
|
||||
/**
|
||||
@ -1248,7 +1250,7 @@ parent:
|
||||
* to possibly bypass Content Analysis if a set clipboard and get clipboard
|
||||
* operation are done on the same page.
|
||||
*/
|
||||
async PClipboardWriteRequest(int32_t aClipboardType, MaybeDiscardedWindowContext aSettingWindowContext);
|
||||
async PClipboardWriteRequest(ClipboardType aClipboardType, MaybeDiscardedWindowContext aSettingWindowContext);
|
||||
|
||||
sync GetIconForExtension(nsCString aFileExt, uint32_t aIconSize)
|
||||
returns (uint8_t[] bits);
|
||||
|
@ -8,6 +8,7 @@
|
||||
#define mozilla_AutoCopyListener_h
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/dom/Selection.h"
|
||||
#include "mozilla/StaticPrefs_clipboard.h"
|
||||
#include "nsIClipboard.h"
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "mozilla/GfxMessageUtils.h"
|
||||
#include "mozilla/LookAndFeel.h"
|
||||
#include "mozilla/widget/ThemeChangeKind.h"
|
||||
#include "nsIClipboard.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsStyleConsts.h"
|
||||
|
||||
@ -71,6 +72,12 @@ struct ParamTraits<mozilla::DimensionKind>
|
||||
DEFINE_IPC_SERIALIZER_WITH_FIELDS(mozilla::DimensionRequest, mDimensionKind, mX,
|
||||
mY, mWidth, mHeight);
|
||||
|
||||
template <>
|
||||
struct ParamTraits<nsIClipboard::ClipboardType>
|
||||
: public ContiguousEnumSerializerInclusive<
|
||||
nsIClipboard::ClipboardType, nsIClipboard::kSelectionClipboard,
|
||||
nsIClipboard::kSelectionCache> {};
|
||||
|
||||
} // namespace IPC
|
||||
|
||||
#endif // WidgetMessageUtils_h
|
||||
|
@ -47,7 +47,8 @@ nsClipboardProxy::SetData(nsITransferable* aTransferable,
|
||||
IPCTransferable ipcTransferable;
|
||||
nsContentUtils::TransferableToIPCTransferable(aTransferable, &ipcTransferable,
|
||||
false, nullptr);
|
||||
child->SendSetClipboard(std::move(ipcTransferable), aWhichClipboard,
|
||||
child->SendSetClipboard(std::move(ipcTransferable),
|
||||
nsIClipboard::ClipboardType(aWhichClipboard),
|
||||
aWindowContext);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -59,7 +60,8 @@ NS_IMETHODIMP nsClipboardProxy::AsyncSetData(
|
||||
RefPtr<ClipboardWriteRequestChild> request =
|
||||
MakeRefPtr<ClipboardWriteRequestChild>(aCallback);
|
||||
ContentChild::GetSingleton()->SendPClipboardWriteRequestConstructor(
|
||||
request, aWhichClipboard, aSettingWindowContext);
|
||||
request, nsIClipboard::ClipboardType(aWhichClipboard),
|
||||
aSettingWindowContext);
|
||||
request.forget(_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -84,14 +86,15 @@ nsClipboardProxy::GetData(nsITransferable* aTransferable,
|
||||
if (!contentAnalysis) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if (!contentAnalysis->SendGetClipboard(types, aWhichClipboard,
|
||||
aWindowContext->InnerWindowId(),
|
||||
&transferableOrError)) {
|
||||
if (!contentAnalysis->SendGetClipboard(
|
||||
types, nsIClipboard::ClipboardType(aWhichClipboard),
|
||||
aWindowContext->InnerWindowId(), &transferableOrError)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
} else {
|
||||
if (!ContentChild::GetSingleton()->SendGetClipboard(
|
||||
types, aWhichClipboard, aWindowContext, &transferableOrError)) {
|
||||
types, nsIClipboard::ClipboardType(aWhichClipboard), aWindowContext,
|
||||
&transferableOrError)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
};
|
||||
}
|
||||
@ -243,9 +246,9 @@ NS_IMETHODIMP nsClipboardProxy::GetDataSnapshot(
|
||||
}
|
||||
|
||||
ContentChild::GetSingleton()
|
||||
->SendGetClipboardDataSnapshot(aFlavorList, aWhichClipboard,
|
||||
aRequestingWindowContext,
|
||||
WrapNotNull(aRequestingPrincipal))
|
||||
->SendGetClipboardDataSnapshot(
|
||||
aFlavorList, nsIClipboard::ClipboardType(aWhichClipboard),
|
||||
aRequestingWindowContext, WrapNotNull(aRequestingPrincipal))
|
||||
->Then(
|
||||
GetMainThreadSerialEventTarget(), __func__,
|
||||
/* resolve */
|
||||
@ -287,7 +290,8 @@ NS_IMETHODIMP nsClipboardProxy::GetDataSnapshotSync(
|
||||
ContentChild* contentChild = ContentChild::GetSingleton();
|
||||
ClipboardReadRequestOrError requestOrError;
|
||||
contentChild->SendGetClipboardDataSnapshotSync(
|
||||
aFlavorList, aWhichClipboard, aRequestingWindowContext, &requestOrError);
|
||||
aFlavorList, nsIClipboard::ClipboardType(aWhichClipboard),
|
||||
aRequestingWindowContext, &requestOrError);
|
||||
auto result = CreateClipboardDataSnapshotProxy(std::move(requestOrError));
|
||||
if (result.isErr()) {
|
||||
return result.unwrapErr();
|
||||
@ -299,7 +303,8 @@ NS_IMETHODIMP nsClipboardProxy::GetDataSnapshotSync(
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsClipboardProxy::EmptyClipboard(int32_t aWhichClipboard) {
|
||||
ContentChild::GetSingleton()->SendEmptyClipboard(aWhichClipboard);
|
||||
ContentChild::GetSingleton()->SendEmptyClipboard(
|
||||
nsIClipboard::ClipboardType(aWhichClipboard));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -309,8 +314,8 @@ nsClipboardProxy::HasDataMatchingFlavors(const nsTArray<nsCString>& aFlavorList,
|
||||
bool* aHasType) {
|
||||
*aHasType = false;
|
||||
|
||||
ContentChild::GetSingleton()->SendClipboardHasType(aFlavorList,
|
||||
aWhichClipboard, aHasType);
|
||||
ContentChild::GetSingleton()->SendClipboardHasType(
|
||||
aFlavorList, nsIClipboard::ClipboardType(aWhichClipboard), aHasType);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -99,11 +99,13 @@ interface nsIClipboardGetDataSnapshotCallback : nsISupports
|
||||
[scriptable, builtinclass, uuid(ceaa0047-647f-4b8e-ad1c-aff9fa62aa51)]
|
||||
interface nsIClipboard : nsISupports
|
||||
{
|
||||
const long kSelectionClipboard = 0;
|
||||
const long kGlobalClipboard = 1;
|
||||
const long kFindClipboard = 2;
|
||||
cenum ClipboardType : 32 {
|
||||
kSelectionClipboard = 0,
|
||||
kGlobalClipboard = 1,
|
||||
kFindClipboard = 2,
|
||||
// Used to cache current selection on (nsClipboard) for macOS service menu.
|
||||
const long kSelectionCache = 3;
|
||||
kSelectionCache = 3,
|
||||
};
|
||||
|
||||
%{ C++
|
||||
static const uint32_t kClipboardTypeCount = kSelectionCache + 1;
|
||||
|
Loading…
Reference in New Issue
Block a user