зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1883799 - Rename nsIAsyncGetClipboardData to nsIClipboardDataSnapshot; r=nika
Differential Revision: https://phabricator.services.mozilla.com/D214135
This commit is contained in:
Родитель
04648c9c83
Коммит
7493831832
|
@ -7658,7 +7658,7 @@ void nsGlobalWindowInner::SetCurrentPasteDataTransfer(
|
|||
MOZ_ASSERT_IF(aDataTransfer, aDataTransfer->GetEventMessage() == ePaste);
|
||||
MOZ_ASSERT_IF(aDataTransfer, aDataTransfer->ClipboardType() ==
|
||||
nsIClipboard::kGlobalClipboard);
|
||||
MOZ_ASSERT_IF(aDataTransfer, aDataTransfer->GetAsyncGetClipboardData());
|
||||
MOZ_ASSERT_IF(aDataTransfer, aDataTransfer->GetClipboardDataSnapshot());
|
||||
mCurrentPasteDataTransfer = aDataTransfer;
|
||||
}
|
||||
|
||||
|
|
|
@ -112,12 +112,12 @@ class ClipboardGetCallbackForRead final : public ClipboardGetCallback {
|
|||
|
||||
// nsIClipboardGetDataSnapshotCallback
|
||||
NS_IMETHOD OnSuccess(
|
||||
nsIAsyncGetClipboardData* aAsyncGetClipboardData) override {
|
||||
nsIClipboardDataSnapshot* aClipboardDataSnapshot) override {
|
||||
MOZ_ASSERT(mPromise);
|
||||
MOZ_ASSERT(aAsyncGetClipboardData);
|
||||
MOZ_ASSERT(aClipboardDataSnapshot);
|
||||
|
||||
nsTArray<nsCString> flavorList;
|
||||
nsresult rv = aAsyncGetClipboardData->GetFlavorList(flavorList);
|
||||
nsresult rv = aClipboardDataSnapshot->GetFlavorList(flavorList);
|
||||
if (NS_FAILED(rv)) {
|
||||
return OnError(rv);
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ class ClipboardGetCallbackForRead final : public ClipboardGetCallback {
|
|||
if (flavorList.Contains(format)) {
|
||||
auto entry = MakeRefPtr<ClipboardItem::ItemEntry>(
|
||||
mGlobal, NS_ConvertUTF8toUTF16(format));
|
||||
entry->LoadDataFromSystemClipboard(aAsyncGetClipboardData);
|
||||
entry->LoadDataFromSystemClipboard(aClipboardDataSnapshot);
|
||||
entries.AppendElement(std::move(entry));
|
||||
}
|
||||
}
|
||||
|
@ -170,13 +170,13 @@ class ClipboardGetCallbackForReadText final
|
|||
|
||||
// nsIClipboardGetDataSnapshotCallback
|
||||
NS_IMETHOD OnSuccess(
|
||||
nsIAsyncGetClipboardData* aAsyncGetClipboardData) override {
|
||||
nsIClipboardDataSnapshot* aClipboardDataSnapshot) override {
|
||||
MOZ_ASSERT(mPromise);
|
||||
MOZ_ASSERT(!mTransferable);
|
||||
MOZ_ASSERT(aAsyncGetClipboardData);
|
||||
MOZ_ASSERT(aClipboardDataSnapshot);
|
||||
|
||||
AutoTArray<nsCString, 3> flavors;
|
||||
nsresult rv = aAsyncGetClipboardData->GetFlavorList(flavors);
|
||||
nsresult rv = aClipboardDataSnapshot->GetFlavorList(flavors);
|
||||
if (NS_FAILED(rv)) {
|
||||
return OnError(rv);
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ class ClipboardGetCallbackForReadText final
|
|||
return OnComplete(NS_OK);
|
||||
}
|
||||
|
||||
rv = aAsyncGetClipboardData->GetData(mTransferable, this);
|
||||
rv = aClipboardDataSnapshot->GetData(mTransferable, this);
|
||||
if (NS_FAILED(rv)) {
|
||||
return OnError(rv);
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ NS_IMPL_ISUPPORTS(ClipboardGetCallbackForReadText,
|
|||
void Clipboard::RequestRead(Promise& aPromise, const ReadRequestType& aType,
|
||||
nsPIDOMWindowInner& aOwner,
|
||||
nsIPrincipal& aSubjectPrincipal,
|
||||
nsIAsyncGetClipboardData& aRequest) {
|
||||
nsIClipboardDataSnapshot& aRequest) {
|
||||
#ifdef DEBUG
|
||||
bool isValid = false;
|
||||
MOZ_ASSERT(NS_SUCCEEDED(aRequest.GetValid(&isValid)) && isValid);
|
||||
|
@ -346,14 +346,14 @@ already_AddRefed<Promise> Clipboard::ReadHelper(nsIPrincipal& aSubjectPrincipal,
|
|||
// webpage access to the clipboard.
|
||||
if (RefPtr<DataTransfer> dataTransfer =
|
||||
nsGlobalWindowInner::Cast(owner)->GetCurrentPasteDataTransfer()) {
|
||||
// If there is valid nsIAsyncGetClipboardData, use it directly.
|
||||
if (nsCOMPtr<nsIAsyncGetClipboardData> asyncGetClipboardData =
|
||||
dataTransfer->GetAsyncGetClipboardData()) {
|
||||
// If there is valid nsIClipboardDataSnapshot, use it directly.
|
||||
if (nsCOMPtr<nsIClipboardDataSnapshot> clipboardDataSnapshot =
|
||||
dataTransfer->GetClipboardDataSnapshot()) {
|
||||
bool isValid = false;
|
||||
asyncGetClipboardData->GetValid(&isValid);
|
||||
clipboardDataSnapshot->GetValid(&isValid);
|
||||
if (isValid) {
|
||||
RequestRead(*p, aType, *owner, aSubjectPrincipal,
|
||||
*asyncGetClipboardData);
|
||||
*clipboardDataSnapshot);
|
||||
return p.forget();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
class nsIAsyncGetClipboardData;
|
||||
class nsIClipboardDataSnapshot;
|
||||
|
||||
namespace mozilla::dom {
|
||||
|
||||
|
@ -81,7 +81,7 @@ class Clipboard : public DOMEventTargetHelper {
|
|||
|
||||
void RequestRead(Promise& aPromise, const ReadRequestType& aType,
|
||||
nsPIDOMWindowInner& aOwner, nsIPrincipal& aSubjectPrincipal,
|
||||
nsIAsyncGetClipboardData& aRequest);
|
||||
nsIClipboardDataSnapshot& aRequest);
|
||||
};
|
||||
|
||||
} // namespace mozilla::dom
|
||||
|
|
|
@ -135,7 +135,7 @@ NS_IMETHODIMP ClipboardItem::ItemEntry::OnComplete(nsresult aResult) {
|
|||
}
|
||||
|
||||
void ClipboardItem::ItemEntry::LoadDataFromSystemClipboard(
|
||||
nsIAsyncGetClipboardData* aDataGetter) {
|
||||
nsIClipboardDataSnapshot* aDataGetter) {
|
||||
MOZ_ASSERT(aDataGetter);
|
||||
// XXX maybe we could consider adding a method to check whether the union
|
||||
// object is uninitialized or initialized.
|
||||
|
|
|
@ -57,7 +57,7 @@ class ClipboardItem final : public nsWrapperCache {
|
|||
RefPtr<GetDataPromise> GetData();
|
||||
|
||||
// Load data from system clipboard.
|
||||
void LoadDataFromSystemClipboard(nsIAsyncGetClipboardData* aDataGetter);
|
||||
void LoadDataFromSystemClipboard(nsIClipboardDataSnapshot* aDataGetter);
|
||||
void LoadDataFromDataPromise(Promise& aDataPromise);
|
||||
|
||||
// If clipboard data is in the process of loading from either system
|
||||
|
|
|
@ -637,7 +637,7 @@ void DataTransfer::GetExternalClipboardFormats(const bool& aPlainTextOnly,
|
|||
// GetExternalTransferableFormats() too since those methods should
|
||||
// work similarly.
|
||||
|
||||
MOZ_ASSERT(!mAsyncGetClipboardData);
|
||||
MOZ_ASSERT(!mClipboardDataSnapshot);
|
||||
|
||||
RefPtr<WindowContext> wc = GetWindowContext();
|
||||
if (NS_WARN_IF(!wc)) {
|
||||
|
@ -653,33 +653,33 @@ void DataTransfer::GetExternalClipboardFormats(const bool& aPlainTextOnly,
|
|||
}
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsIAsyncGetClipboardData> asyncGetClipboardData;
|
||||
nsCOMPtr<nsIClipboardDataSnapshot> clipboardDataSnapshot;
|
||||
if (aPlainTextOnly) {
|
||||
rv = clipboard->GetDataSnapshotSync(
|
||||
AutoTArray<nsCString, 1>{nsLiteralCString(kTextMime)}, mClipboardType,
|
||||
wc, getter_AddRefs(asyncGetClipboardData));
|
||||
wc, getter_AddRefs(clipboardDataSnapshot));
|
||||
} else {
|
||||
AutoTArray<nsCString, ArrayLength(kNonPlainTextExternalFormats)> formats;
|
||||
formats.AppendElements(Span<const nsCString>(kNonPlainTextExternalFormats));
|
||||
rv = clipboard->GetDataSnapshotSync(formats, mClipboardType, wc,
|
||||
getter_AddRefs(asyncGetClipboardData));
|
||||
getter_AddRefs(clipboardDataSnapshot));
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv) || !asyncGetClipboardData) {
|
||||
if (NS_FAILED(rv) || !clipboardDataSnapshot) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Order is important for DataTransfer; ensure the returned list items follow
|
||||
// the sequence specified in kNonPlainTextExternalFormats.
|
||||
AutoTArray<nsCString, ArrayLength(kNonPlainTextExternalFormats)> flavors;
|
||||
asyncGetClipboardData->GetFlavorList(flavors);
|
||||
clipboardDataSnapshot->GetFlavorList(flavors);
|
||||
for (const auto& format : kNonPlainTextExternalFormats) {
|
||||
if (flavors.Contains(format)) {
|
||||
aResult.AppendElement(format);
|
||||
}
|
||||
}
|
||||
|
||||
mAsyncGetClipboardData = asyncGetClipboardData;
|
||||
mClipboardDataSnapshot = clipboardDataSnapshot;
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
@ -1206,7 +1206,7 @@ void DataTransfer::Disconnect() {
|
|||
|
||||
void DataTransfer::ClearAll() {
|
||||
mItems->ClearAllItems();
|
||||
mAsyncGetClipboardData = nullptr;
|
||||
mClipboardDataSnapshot = nullptr;
|
||||
}
|
||||
|
||||
uint32_t DataTransfer::MozItemCount() const { return mItems->MozItemCount(); }
|
||||
|
@ -1289,8 +1289,8 @@ already_AddRefed<WindowContext> DataTransfer::GetWindowContext() const {
|
|||
return do_AddRef(innerWindow->GetWindowContext());
|
||||
}
|
||||
|
||||
nsIAsyncGetClipboardData* DataTransfer::GetAsyncGetClipboardData() const {
|
||||
return mAsyncGetClipboardData;
|
||||
nsIClipboardDataSnapshot* DataTransfer::GetClipboardDataSnapshot() const {
|
||||
return mClipboardDataSnapshot;
|
||||
}
|
||||
|
||||
nsresult DataTransfer::CacheExternalData(const char* aFormat, uint32_t aIndex,
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "mozilla/dom/DataTransferItemList.h"
|
||||
#include "mozilla/dom/File.h"
|
||||
|
||||
class nsIAsyncGetClipboardData;
|
||||
class nsIClipboardDataSnapshot;
|
||||
class nsINode;
|
||||
class nsITransferable;
|
||||
class nsILoadContext;
|
||||
|
@ -423,7 +423,7 @@ class DataTransfer final : public nsISupports, public nsWrapperCache {
|
|||
|
||||
already_AddRefed<WindowContext> GetWindowContext() const;
|
||||
|
||||
nsIAsyncGetClipboardData* GetAsyncGetClipboardData() const;
|
||||
nsIClipboardDataSnapshot* GetClipboardDataSnapshot() const;
|
||||
|
||||
protected:
|
||||
// Retrieve a list of clipboard formats supported
|
||||
|
@ -510,10 +510,10 @@ class DataTransfer final : public nsISupports, public nsWrapperCache {
|
|||
// drag and drop.
|
||||
int32_t mClipboardType;
|
||||
|
||||
// The nsIAsyncGetClipboardData that is used for getting clipboard formats.
|
||||
// The nsIClipboardDataSnapshot that is used for getting clipboard formats.
|
||||
// XXXedgar we should get the actual data from this in the future, see bug
|
||||
// 1879401.
|
||||
nsCOMPtr<nsIAsyncGetClipboardData> mAsyncGetClipboardData;
|
||||
nsCOMPtr<nsIClipboardDataSnapshot> mClipboardDataSnapshot;
|
||||
|
||||
// The items contained with the DataTransfer
|
||||
RefPtr<DataTransferItemList> mItems;
|
||||
|
|
|
@ -3572,15 +3572,15 @@ namespace {
|
|||
|
||||
static Result<ClipboardReadRequest, nsresult> CreateClipboardReadRequest(
|
||||
ContentParent& aContentParent,
|
||||
nsIAsyncGetClipboardData& aAsyncGetClipboardData) {
|
||||
nsIClipboardDataSnapshot& aClipboardDataSnapshot) {
|
||||
nsTArray<nsCString> flavors;
|
||||
nsresult rv = aAsyncGetClipboardData.GetFlavorList(flavors);
|
||||
nsresult rv = aClipboardDataSnapshot.GetFlavorList(flavors);
|
||||
if (NS_FAILED(rv)) {
|
||||
return Err(rv);
|
||||
}
|
||||
|
||||
auto requestParent = MakeNotNull<RefPtr<ClipboardReadRequestParent>>(
|
||||
&aContentParent, &aAsyncGetClipboardData);
|
||||
&aContentParent, &aClipboardDataSnapshot);
|
||||
|
||||
// Open a remote endpoint for our PClipboardReadRequest actor.
|
||||
ManagedEndpoint<PClipboardReadRequestChild> childEndpoint =
|
||||
|
@ -3605,12 +3605,12 @@ class ClipboardGetCallback final : public nsIClipboardGetDataSnapshotCallback {
|
|||
|
||||
// nsIClipboardGetDataSnapshotCallback
|
||||
NS_IMETHOD OnSuccess(
|
||||
nsIAsyncGetClipboardData* aAsyncGetClipboardData) override {
|
||||
nsIClipboardDataSnapshot* aClipboardDataSnapshot) override {
|
||||
MOZ_ASSERT(mContentParent);
|
||||
MOZ_ASSERT(aAsyncGetClipboardData);
|
||||
MOZ_ASSERT(aClipboardDataSnapshot);
|
||||
|
||||
auto result =
|
||||
CreateClipboardReadRequest(*mContentParent, *aAsyncGetClipboardData);
|
||||
CreateClipboardReadRequest(*mContentParent, *aClipboardDataSnapshot);
|
||||
if (result.isErr()) {
|
||||
return OnError(result.unwrapErr());
|
||||
}
|
||||
|
@ -3701,16 +3701,16 @@ mozilla::ipc::IPCResult ContentParent::RecvGetClipboardDataSnapshotSync(
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAsyncGetClipboardData> asyncGetClipboardData;
|
||||
nsCOMPtr<nsIClipboardDataSnapshot> clipboardDataSnapshot;
|
||||
nsresult rv =
|
||||
clipboard->GetDataSnapshotSync(aTypes, aWhichClipboard, requestingWindow,
|
||||
getter_AddRefs(asyncGetClipboardData));
|
||||
getter_AddRefs(clipboardDataSnapshot));
|
||||
if (NS_FAILED(rv)) {
|
||||
*aRequestOrError = rv;
|
||||
return IPC_OK();
|
||||
}
|
||||
|
||||
auto result = CreateClipboardReadRequest(*this, *asyncGetClipboardData);
|
||||
auto result = CreateClipboardReadRequest(*this, *clipboardDataSnapshot);
|
||||
if (result.isErr()) {
|
||||
*aRequestOrError = result.unwrapErr();
|
||||
return IPC_OK();
|
||||
|
|
|
@ -71,7 +71,7 @@ static Result<nsCOMPtr<nsITransferable>, nsresult> CreateTransferable(
|
|||
IPCResult ClipboardReadRequestParent::RecvGetData(
|
||||
const nsTArray<nsCString>& aFlavors, GetDataResolver&& aResolver) {
|
||||
bool valid = false;
|
||||
if (NS_FAILED(mAsyncGetClipboardData->GetValid(&valid)) || !valid) {
|
||||
if (NS_FAILED(mClipboardDataSnapshot->GetValid(&valid)) || !valid) {
|
||||
Unused << PClipboardReadRequestParent::Send__delete__(this);
|
||||
aResolver(NS_ERROR_FAILURE);
|
||||
return IPC_OK();
|
||||
|
@ -92,7 +92,7 @@ IPCResult ClipboardReadRequestParent::RecvGetData(
|
|||
manager = mManager](nsresult aRv) {
|
||||
if (NS_FAILED(aRv)) {
|
||||
bool valid = false;
|
||||
if (NS_FAILED(self->mAsyncGetClipboardData->GetValid(&valid)) ||
|
||||
if (NS_FAILED(self->mClipboardDataSnapshot->GetValid(&valid)) ||
|
||||
!valid) {
|
||||
Unused << PClipboardReadRequestParent::Send__delete__(self);
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ IPCResult ClipboardReadRequestParent::RecvGetData(
|
|||
trans, &ipcTransferableData, false /* aInSyncMessage */, manager);
|
||||
resolver(std::move(ipcTransferableData));
|
||||
});
|
||||
nsresult rv = mAsyncGetClipboardData->GetData(trans, callback);
|
||||
nsresult rv = mClipboardDataSnapshot->GetData(trans, callback);
|
||||
if (NS_FAILED(rv)) {
|
||||
callback->OnComplete(rv);
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@ class ClipboardReadRequestParent final : public PClipboardReadRequestParent {
|
|||
|
||||
public:
|
||||
ClipboardReadRequestParent(ContentParent* aManager,
|
||||
nsIAsyncGetClipboardData* aAsyncGetClipboardData)
|
||||
: mManager(aManager), mAsyncGetClipboardData(aAsyncGetClipboardData) {}
|
||||
nsIClipboardDataSnapshot* aClipboardDataSnapshot)
|
||||
: mManager(aManager), mClipboardDataSnapshot(aClipboardDataSnapshot) {}
|
||||
|
||||
NS_INLINE_DECL_REFCOUNTING(ClipboardReadRequestParent, override)
|
||||
|
||||
|
@ -31,7 +31,7 @@ class ClipboardReadRequestParent final : public PClipboardReadRequestParent {
|
|||
~ClipboardReadRequestParent() = default;
|
||||
|
||||
RefPtr<ContentParent> mManager;
|
||||
nsCOMPtr<nsIAsyncGetClipboardData> mAsyncGetClipboardData;
|
||||
nsCOMPtr<nsIClipboardDataSnapshot> mClipboardDataSnapshot;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -515,12 +515,12 @@ void nsBaseClipboard::MaybeRetryGetAvailableFlavors(
|
|||
}
|
||||
|
||||
if (sequenceNumber == sequenceNumberOrError.unwrap()) {
|
||||
auto asyncGetClipboardData =
|
||||
mozilla::MakeRefPtr<AsyncGetClipboardData>(
|
||||
auto clipboardDataSnapshot =
|
||||
mozilla::MakeRefPtr<ClipboardDataSnapshot>(
|
||||
aWhichClipboard, sequenceNumber,
|
||||
std::move(aFlavorsOrError.unwrap()), false, self,
|
||||
requestingWindowContext);
|
||||
callback->OnSuccess(asyncGetClipboardData);
|
||||
callback->OnSuccess(clipboardDataSnapshot);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -597,7 +597,7 @@ NS_IMETHODIMP nsBaseClipboard::GetDataSnapshot(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIAsyncGetClipboardData>
|
||||
already_AddRefed<nsIClipboardDataSnapshot>
|
||||
nsBaseClipboard::MaybeCreateGetRequestFromClipboardCache(
|
||||
const nsTArray<nsCString>& aFlavorList, int32_t aClipboardType,
|
||||
mozilla::dom::WindowContext* aRequestingWindowContext) {
|
||||
|
@ -640,7 +640,7 @@ nsBaseClipboard::MaybeCreateGetRequestFromClipboardCache(
|
|||
|
||||
// XXX Do we need to check system clipboard for the flavors that cannot
|
||||
// be found in cache?
|
||||
return mozilla::MakeAndAddRef<AsyncGetClipboardData>(
|
||||
return mozilla::MakeAndAddRef<ClipboardDataSnapshot>(
|
||||
aClipboardType, clipboardCache->GetSequenceNumber(), std::move(results),
|
||||
true /* aFromCache */, this, aRequestingWindowContext);
|
||||
}
|
||||
|
@ -651,10 +651,10 @@ void nsBaseClipboard::GetDataSnapshotInternal(
|
|||
nsIClipboardGetDataSnapshotCallback* aCallback) {
|
||||
MOZ_ASSERT(nsIClipboard::IsClipboardTypeSupported(aClipboardType));
|
||||
|
||||
if (nsCOMPtr<nsIAsyncGetClipboardData> asyncGetClipboardData =
|
||||
if (nsCOMPtr<nsIClipboardDataSnapshot> clipboardDataSnapshot =
|
||||
MaybeCreateGetRequestFromClipboardCache(aFlavorList, aClipboardType,
|
||||
aRequestingWindowContext)) {
|
||||
aCallback->OnSuccess(asyncGetClipboardData);
|
||||
aCallback->OnSuccess(clipboardDataSnapshot);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -668,7 +668,7 @@ void nsBaseClipboard::GetDataSnapshotInternal(
|
|||
NS_IMETHODIMP nsBaseClipboard::GetDataSnapshotSync(
|
||||
const nsTArray<nsCString>& aFlavorList, int32_t aWhichClipboard,
|
||||
mozilla::dom::WindowContext* aRequestingWindowContext,
|
||||
nsIAsyncGetClipboardData** _retval) {
|
||||
nsIClipboardDataSnapshot** _retval) {
|
||||
MOZ_CLIPBOARD_LOG("%s: clipboard=%d", __FUNCTION__, aWhichClipboard);
|
||||
|
||||
*_retval = nullptr;
|
||||
|
@ -683,10 +683,10 @@ NS_IMETHODIMP nsBaseClipboard::GetDataSnapshotSync(
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (nsCOMPtr<nsIAsyncGetClipboardData> asyncGetClipboardData =
|
||||
if (nsCOMPtr<nsIClipboardDataSnapshot> clipboardDataSnapshot =
|
||||
MaybeCreateGetRequestFromClipboardCache(aFlavorList, aWhichClipboard,
|
||||
aRequestingWindowContext)) {
|
||||
asyncGetClipboardData.forget(_retval);
|
||||
clipboardDataSnapshot.forget(_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -708,7 +708,7 @@ NS_IMETHODIMP nsBaseClipboard::GetDataSnapshotSync(
|
|||
}
|
||||
|
||||
*_retval =
|
||||
mozilla::MakeAndAddRef<AsyncGetClipboardData>(
|
||||
mozilla::MakeAndAddRef<ClipboardDataSnapshot>(
|
||||
aWhichClipboard, sequenceNumberOrError.unwrap(), std::move(results),
|
||||
false /* aFromCache */, this, aRequestingWindowContext)
|
||||
.take();
|
||||
|
@ -953,10 +953,10 @@ void nsBaseClipboard::RequestUserConfirmation(
|
|||
promise->AppendNativeHandler(sUserConfirmationRequest);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsBaseClipboard::AsyncGetClipboardData,
|
||||
nsIAsyncGetClipboardData)
|
||||
NS_IMPL_ISUPPORTS(nsBaseClipboard::ClipboardDataSnapshot,
|
||||
nsIClipboardDataSnapshot)
|
||||
|
||||
nsBaseClipboard::AsyncGetClipboardData::AsyncGetClipboardData(
|
||||
nsBaseClipboard::ClipboardDataSnapshot::ClipboardDataSnapshot(
|
||||
int32_t aClipboardType, int32_t aSequenceNumber,
|
||||
nsTArray<nsCString>&& aFlavors, bool aFromCache,
|
||||
nsBaseClipboard* aClipboard,
|
||||
|
@ -972,22 +972,22 @@ nsBaseClipboard::AsyncGetClipboardData::AsyncGetClipboardData(
|
|||
mClipboard->nsIClipboard::IsClipboardTypeSupported(mClipboardType));
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBaseClipboard::AsyncGetClipboardData::GetValid(
|
||||
NS_IMETHODIMP nsBaseClipboard::ClipboardDataSnapshot::GetValid(
|
||||
bool* aOutResult) {
|
||||
*aOutResult = IsValid();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBaseClipboard::AsyncGetClipboardData::GetFlavorList(
|
||||
NS_IMETHODIMP nsBaseClipboard::ClipboardDataSnapshot::GetFlavorList(
|
||||
nsTArray<nsCString>& aFlavors) {
|
||||
aFlavors.AppendElements(mFlavors);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBaseClipboard::AsyncGetClipboardData::GetData(
|
||||
NS_IMETHODIMP nsBaseClipboard::ClipboardDataSnapshot::GetData(
|
||||
nsITransferable* aTransferable,
|
||||
nsIAsyncClipboardRequestCallback* aCallback) {
|
||||
MOZ_CLIPBOARD_LOG("AsyncGetClipboardData::GetData: %p", this);
|
||||
MOZ_CLIPBOARD_LOG("ClipboardDataSnapshot::GetData: %p", this);
|
||||
|
||||
if (!aTransferable || !aCallback) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
|
@ -1077,7 +1077,7 @@ NS_IMETHODIMP nsBaseClipboard::AsyncGetClipboardData::GetData(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
bool nsBaseClipboard::AsyncGetClipboardData::IsValid() {
|
||||
bool nsBaseClipboard::ClipboardDataSnapshot::IsValid() {
|
||||
if (!mClipboard) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ class nsBaseClipboard : public nsIClipboard {
|
|||
NS_IMETHOD GetDataSnapshotSync(
|
||||
const nsTArray<nsCString>& aFlavorList, int32_t aWhichClipboard,
|
||||
mozilla::dom::WindowContext* aRequestingWindowContext,
|
||||
nsIAsyncGetClipboardData** _retval) override final;
|
||||
nsIClipboardDataSnapshot** _retval) override final;
|
||||
NS_IMETHOD EmptyClipboard(int32_t aWhichClipboard) override final;
|
||||
NS_IMETHOD HasDataMatchingFlavors(const nsTArray<nsCString>& aFlavorList,
|
||||
int32_t aWhichClipboard,
|
||||
|
@ -137,19 +137,19 @@ class nsBaseClipboard : public nsIClipboard {
|
|||
nsCOMPtr<nsIAsyncClipboardRequestCallback> mCallback;
|
||||
};
|
||||
|
||||
class AsyncGetClipboardData final : public nsIAsyncGetClipboardData {
|
||||
class ClipboardDataSnapshot final : public nsIClipboardDataSnapshot {
|
||||
public:
|
||||
AsyncGetClipboardData(
|
||||
ClipboardDataSnapshot(
|
||||
int32_t aClipboardType, int32_t aSequenceNumber,
|
||||
nsTArray<nsCString>&& aFlavors, bool aFromCache,
|
||||
nsBaseClipboard* aClipboard,
|
||||
mozilla::dom::WindowContext* aRequestingWindowContext);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIASYNCGETCLIPBOARDDATA
|
||||
NS_DECL_NSICLIPBOARDDATASNAPSHOT
|
||||
|
||||
private:
|
||||
virtual ~AsyncGetClipboardData() = default;
|
||||
virtual ~ClipboardDataSnapshot() = default;
|
||||
bool IsValid();
|
||||
|
||||
// The clipboard type defined in nsIClipboard.
|
||||
|
@ -222,7 +222,7 @@ class nsBaseClipboard : public nsIClipboard {
|
|||
nsIPrincipal* aRequestingPrincipal,
|
||||
nsIClipboardGetDataSnapshotCallback* aCallback);
|
||||
|
||||
already_AddRefed<nsIAsyncGetClipboardData>
|
||||
already_AddRefed<nsIClipboardDataSnapshot>
|
||||
MaybeCreateGetRequestFromClipboardCache(
|
||||
const nsTArray<nsCString>& aFlavorList, int32_t aClipboardType,
|
||||
mozilla::dom::WindowContext* aRequestingWindowContext);
|
||||
|
|
|
@ -88,18 +88,18 @@ nsClipboardProxy::GetData(nsITransferable* aTransferable,
|
|||
|
||||
namespace {
|
||||
|
||||
class AsyncGetClipboardDataProxy final : public nsIAsyncGetClipboardData {
|
||||
class ClipboardDataSnapshotProxy final : public nsIClipboardDataSnapshot {
|
||||
public:
|
||||
explicit AsyncGetClipboardDataProxy(ClipboardReadRequestChild* aActor)
|
||||
explicit ClipboardDataSnapshotProxy(ClipboardReadRequestChild* aActor)
|
||||
: mActor(aActor) {
|
||||
MOZ_ASSERT(mActor);
|
||||
}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIASYNCGETCLIPBOARDDATA
|
||||
NS_DECL_NSICLIPBOARDDATASNAPSHOT
|
||||
|
||||
private:
|
||||
virtual ~AsyncGetClipboardDataProxy() {
|
||||
virtual ~ClipboardDataSnapshotProxy() {
|
||||
MOZ_ASSERT(mActor);
|
||||
if (mActor->CanSend()) {
|
||||
PClipboardReadRequestChild::Send__delete__(mActor);
|
||||
|
@ -109,22 +109,22 @@ class AsyncGetClipboardDataProxy final : public nsIAsyncGetClipboardData {
|
|||
RefPtr<ClipboardReadRequestChild> mActor;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(AsyncGetClipboardDataProxy, nsIAsyncGetClipboardData)
|
||||
NS_IMPL_ISUPPORTS(ClipboardDataSnapshotProxy, nsIClipboardDataSnapshot)
|
||||
|
||||
NS_IMETHODIMP AsyncGetClipboardDataProxy::GetValid(bool* aOutResult) {
|
||||
NS_IMETHODIMP ClipboardDataSnapshotProxy::GetValid(bool* aOutResult) {
|
||||
MOZ_ASSERT(mActor);
|
||||
*aOutResult = mActor->CanSend();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP AsyncGetClipboardDataProxy::GetFlavorList(
|
||||
NS_IMETHODIMP ClipboardDataSnapshotProxy::GetFlavorList(
|
||||
nsTArray<nsCString>& aFlavorList) {
|
||||
MOZ_ASSERT(mActor);
|
||||
aFlavorList.AppendElements(mActor->FlavorList());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP AsyncGetClipboardDataProxy::GetData(
|
||||
NS_IMETHODIMP ClipboardDataSnapshotProxy::GetData(
|
||||
nsITransferable* aTransferable,
|
||||
nsIAsyncClipboardRequestCallback* aCallback) {
|
||||
if (!aTransferable || !aCallback) {
|
||||
|
@ -183,8 +183,8 @@ NS_IMETHODIMP AsyncGetClipboardDataProxy::GetData(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
static Result<RefPtr<AsyncGetClipboardDataProxy>, nsresult>
|
||||
CreateAsyncGetClipboardDataProxy(
|
||||
static Result<RefPtr<ClipboardDataSnapshotProxy>, nsresult>
|
||||
CreateClipboardDataSnapshotProxy(
|
||||
ClipboardReadRequestOrError&& aClipboardReadRequestOrError) {
|
||||
if (aClipboardReadRequestOrError.type() ==
|
||||
ClipboardReadRequestOrError::Tnsresult) {
|
||||
|
@ -202,7 +202,7 @@ CreateAsyncGetClipboardDataProxy(
|
|||
return Err(NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
return MakeRefPtr<AsyncGetClipboardDataProxy>(requestChild);
|
||||
return MakeRefPtr<ClipboardDataSnapshotProxy>(requestChild);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -231,7 +231,7 @@ NS_IMETHODIMP nsClipboardProxy::GetDataSnapshot(
|
|||
/* resolve */
|
||||
[callback = nsCOMPtr{aCallback}](
|
||||
ClipboardReadRequestOrError&& aClipboardReadRequestOrError) {
|
||||
auto result = CreateAsyncGetClipboardDataProxy(
|
||||
auto result = CreateClipboardDataSnapshotProxy(
|
||||
std::move(aClipboardReadRequestOrError));
|
||||
if (result.isErr()) {
|
||||
callback->OnError(result.unwrapErr());
|
||||
|
@ -251,7 +251,7 @@ NS_IMETHODIMP nsClipboardProxy::GetDataSnapshot(
|
|||
NS_IMETHODIMP nsClipboardProxy::GetDataSnapshotSync(
|
||||
const nsTArray<nsCString>& aFlavorList, int32_t aWhichClipboard,
|
||||
mozilla::dom::WindowContext* aRequestingWindowContext,
|
||||
nsIAsyncGetClipboardData** _retval) {
|
||||
nsIClipboardDataSnapshot** _retval) {
|
||||
*_retval = nullptr;
|
||||
|
||||
if (aFlavorList.IsEmpty()) {
|
||||
|
@ -268,7 +268,7 @@ NS_IMETHODIMP nsClipboardProxy::GetDataSnapshotSync(
|
|||
ClipboardReadRequestOrError requestOrError;
|
||||
contentChild->SendGetClipboardDataSnapshotSync(
|
||||
aFlavorList, aWhichClipboard, aRequestingWindowContext, &requestOrError);
|
||||
auto result = CreateAsyncGetClipboardDataProxy(std::move(requestOrError));
|
||||
auto result = CreateClipboardDataSnapshotProxy(std::move(requestOrError));
|
||||
if (result.isErr()) {
|
||||
return result.unwrapErr();
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ interface nsIAsyncClipboardRequestCallback : nsISupports
|
|||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(c18ea2f7-6b6f-4a38-9ab3-a8781fdfcc39)]
|
||||
interface nsIAsyncGetClipboardData : nsISupports {
|
||||
interface nsIClipboardDataSnapshot : nsISupports {
|
||||
/**
|
||||
* Determines whether this request is still valid (e.g., the clipboard content
|
||||
* associated with this request is not stale).
|
||||
|
@ -85,7 +85,7 @@ interface nsIClipboardGetDataSnapshotCallback : nsISupports
|
|||
/**
|
||||
* Indicates that the clipboard get request has succeeded.
|
||||
*/
|
||||
void onSuccess(in nsIAsyncGetClipboardData aAsyncGetClipboardData);
|
||||
void onSuccess(in nsIClipboardDataSnapshot aClipboardDataSnapshot);
|
||||
|
||||
/**
|
||||
* Indicates that the clipboard get request has rejected.
|
||||
|
@ -208,7 +208,7 @@ interface nsIClipboard : nsISupports
|
|||
* @return nsIAsyncSetClipboardData if successful.
|
||||
* @throws if the request can not be made.
|
||||
*/
|
||||
nsIAsyncGetClipboardData getDataSnapshotSync(in Array<ACString> aFlavorList,
|
||||
nsIClipboardDataSnapshot getDataSnapshotSync(in Array<ACString> aFlavorList,
|
||||
in long aWhichClipboard,
|
||||
[optional] in WindowContext aRequestingWindowContext);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче