Backed out 2 changesets (bug 1832701) for causing bc failures on browser_test_clipboardcache.js. CLOSED TREE

Backed out changeset 888814f19788 (bug 1832701)
Backed out changeset 1946d69582b0 (bug 1832701)
This commit is contained in:
Iulian Moraru
2023-05-16 15:54:58 +03:00
parent 0f6c5aa440
commit 020a15b35d
24 changed files with 309 additions and 347 deletions

View File

@@ -7834,8 +7834,8 @@ void nsContentUtils::CallOnAllRemoteChildren(
} }
} }
bool nsContentUtils::IPCTransferableDataItemHasKnownFlavor( bool nsContentUtils::IPCDataTransferItemHasKnownFlavor(
const IPCTransferableDataItem& aItem) { const IPCDataTransferItem& aItem) {
// Unknown types are converted to kCustomTypesMime. // Unknown types are converted to kCustomTypesMime.
if (aItem.flavor().EqualsASCII(kCustomTypesMime)) { if (aItem.flavor().EqualsASCII(kCustomTypesMime)) {
return true; return true;
@@ -7850,16 +7850,16 @@ bool nsContentUtils::IPCTransferableDataItemHasKnownFlavor(
return false; return false;
} }
nsresult nsContentUtils::IPCTransferableDataToTransferable( nsresult nsContentUtils::IPCTransferableToTransferable(
const IPCTransferableData& aTransferableData, bool aAddDataFlavor, const IPCDataTransfer& aDataTransfer, bool aAddDataFlavor,
nsITransferable* aTransferable, const bool aFilterUnknownFlavors) { nsITransferable* aTransferable, const bool aFilterUnknownFlavors) {
nsresult rv; nsresult rv;
const nsTArray<IPCTransferableDataItem>& items = aTransferableData.items(); const nsTArray<IPCDataTransferItem>& items = aDataTransfer.items();
for (const auto& item : items) { for (const auto& item : items) {
if (aFilterUnknownFlavors && !IPCTransferableDataItemHasKnownFlavor(item)) { if (aFilterUnknownFlavors && !IPCDataTransferItemHasKnownFlavor(item)) {
NS_WARNING( NS_WARNING(
"Ignoring unknown flavor in " "Ignoring unknown flavor in "
"nsContentUtils::IPCTransferableDataToTransferable"); "nsContentUtils::IPCTransferableToTransferable");
continue; continue;
} }
@@ -7869,8 +7869,8 @@ nsresult nsContentUtils::IPCTransferableDataToTransferable(
nsCOMPtr<nsISupports> transferData; nsCOMPtr<nsISupports> transferData;
switch (item.data().type()) { switch (item.data().type()) {
case IPCTransferableDataType::TIPCTransferableDataString: { case IPCDataTransferData::TIPCDataTransferString: {
const auto& data = item.data().get_IPCTransferableDataString(); const auto& data = item.data().get_IPCDataTransferString();
nsCOMPtr<nsISupportsString> dataWrapper = nsCOMPtr<nsISupportsString> dataWrapper =
do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv); do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@@ -7881,8 +7881,8 @@ nsresult nsContentUtils::IPCTransferableDataToTransferable(
transferData = dataWrapper; transferData = dataWrapper;
break; break;
} }
case IPCTransferableDataType::TIPCTransferableDataCString: { case IPCDataTransferData::TIPCDataTransferCString: {
const auto& data = item.data().get_IPCTransferableDataCString(); const auto& data = item.data().get_IPCDataTransferCString();
nsCOMPtr<nsISupportsCString> dataWrapper = nsCOMPtr<nsISupportsCString> dataWrapper =
do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID, &rv); do_CreateInstance(NS_SUPPORTS_CSTRING_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@@ -7893,8 +7893,8 @@ nsresult nsContentUtils::IPCTransferableDataToTransferable(
transferData = dataWrapper; transferData = dataWrapper;
break; break;
} }
case IPCTransferableDataType::TIPCTransferableDataInputStream: { case IPCDataTransferData::TIPCDataTransferInputStream: {
const auto& data = item.data().get_IPCTransferableDataInputStream(); const auto& data = item.data().get_IPCDataTransferInputStream();
nsCOMPtr<nsIInputStream> stream; nsCOMPtr<nsIInputStream> stream;
rv = NS_NewByteInputStream(getter_AddRefs(stream), rv = NS_NewByteInputStream(getter_AddRefs(stream),
AsChars(data.data().AsSpan()), AsChars(data.data().AsSpan()),
@@ -7903,21 +7903,21 @@ nsresult nsContentUtils::IPCTransferableDataToTransferable(
transferData = stream.forget(); transferData = stream.forget();
break; break;
} }
case IPCTransferableDataType::TIPCTransferableDataImageContainer: { case IPCDataTransferData::TIPCDataTransferImageContainer: {
const auto& data = item.data().get_IPCTransferableDataImageContainer(); const auto& data = item.data().get_IPCDataTransferImageContainer();
nsCOMPtr<imgIContainer> container; nsCOMPtr<imgIContainer> container;
rv = DeserializeTransferableDataImageContainer( rv = DeserializeDataTransferImageContainer(data,
data, getter_AddRefs(container)); getter_AddRefs(container));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
transferData = container; transferData = container;
break; break;
} }
case IPCTransferableDataType::TIPCTransferableDataBlob: { case IPCDataTransferData::TIPCDataTransferBlob: {
const auto& data = item.data().get_IPCTransferableDataBlob(); const auto& data = item.data().get_IPCDataTransferBlob();
transferData = IPCBlobUtils::Deserialize(data.blob()); transferData = IPCBlobUtils::Deserialize(data.blob());
break; break;
} }
case IPCTransferableDataType::T__None: case IPCDataTransferData::T__None:
MOZ_ASSERT_UNREACHABLE(); MOZ_ASSERT_UNREACHABLE();
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
@@ -7928,15 +7928,15 @@ nsresult nsContentUtils::IPCTransferableDataToTransferable(
return NS_OK; return NS_OK;
} }
nsresult nsContentUtils::IPCTransferableDataToTransferable( nsresult nsContentUtils::IPCTransferableToTransferable(
const IPCTransferableData& aTransferableData, const bool& aIsPrivateData, const IPCDataTransfer& aDataTransfer, const bool& aIsPrivateData,
nsIPrincipal* aRequestingPrincipal, nsIPrincipal* aRequestingPrincipal,
const nsContentPolicyType& aContentPolicyType, bool aAddDataFlavor, const nsContentPolicyType& aContentPolicyType, bool aAddDataFlavor,
nsITransferable* aTransferable, const bool aFilterUnknownFlavors) { nsITransferable* aTransferable, const bool aFilterUnknownFlavors) {
aTransferable->SetIsPrivateData(aIsPrivateData); aTransferable->SetIsPrivateData(aIsPrivateData);
nsresult rv = IPCTransferableDataToTransferable( nsresult rv = IPCTransferableToTransferable(
aTransferableData, aAddDataFlavor, aTransferable, aFilterUnknownFlavors); aDataTransfer, aAddDataFlavor, aTransferable, aFilterUnknownFlavors);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
aTransferable->SetRequestingPrincipal(aRequestingPrincipal); aTransferable->SetRequestingPrincipal(aRequestingPrincipal);
@@ -7944,47 +7944,27 @@ nsresult nsContentUtils::IPCTransferableDataToTransferable(
return NS_OK; return NS_OK;
} }
nsresult nsContentUtils::IPCTransferableToTransferable( nsresult nsContentUtils::IPCTransferableItemToVariant(
const IPCTransferable& aIPCTransferable, bool aAddDataFlavor, const IPCDataTransferItem& aDataTransferItem,
nsITransferable* aTransferable, const bool aFilterUnknownFlavors) { nsIWritableVariant* aVariant) {
nsresult rv =
IPCTransferableDataToTransferable(aIPCTransferable.data(), aAddDataFlavor,
aTransferable, aFilterUnknownFlavors);
NS_ENSURE_SUCCESS(rv, rv);
aTransferable->SetIsPrivateData(aIPCTransferable.isPrivateData());
aTransferable->SetRequestingPrincipal(aIPCTransferable.requestingPrincipal());
if (aIPCTransferable.cookieJarSettings().isSome()) {
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
net::CookieJarSettings::Deserialize(
aIPCTransferable.cookieJarSettings().ref(),
getter_AddRefs(cookieJarSettings));
aTransferable->SetCookieJarSettings(cookieJarSettings);
}
aTransferable->SetContentPolicyType(aIPCTransferable.contentPolicyType());
aTransferable->SetReferrerInfo(aIPCTransferable.referrerInfo());
return NS_OK;
}
nsresult nsContentUtils::IPCTransferableDataItemToVariant(
const IPCTransferableDataItem& aItem, nsIWritableVariant* aVariant) {
MOZ_ASSERT(aVariant); MOZ_ASSERT(aVariant);
switch (aItem.data().type()) { switch (aDataTransferItem.data().type()) {
case IPCTransferableDataType::TIPCTransferableDataString: { case IPCDataTransferData::TIPCDataTransferString: {
const auto& data = aItem.data().get_IPCTransferableDataString(); const auto& data = aDataTransferItem.data().get_IPCDataTransferString();
return aVariant->SetAsAString(nsDependentSubstring( return aVariant->SetAsAString(nsDependentSubstring(
reinterpret_cast<const char16_t*>(data.data().Data()), reinterpret_cast<const char16_t*>(data.data().Data()),
data.data().Size() / sizeof(char16_t))); data.data().Size() / sizeof(char16_t)));
} }
case IPCTransferableDataType::TIPCTransferableDataCString: { case IPCDataTransferData::TIPCDataTransferCString: {
const auto& data = aItem.data().get_IPCTransferableDataCString(); const auto& data = aDataTransferItem.data().get_IPCDataTransferCString();
return aVariant->SetAsACString(nsDependentCSubstring( return aVariant->SetAsACString(nsDependentCSubstring(
reinterpret_cast<const char*>(data.data().Data()), reinterpret_cast<const char*>(data.data().Data()),
data.data().Size())); data.data().Size()));
} }
case IPCTransferableDataType::TIPCTransferableDataInputStream: { case IPCDataTransferData::TIPCDataTransferInputStream: {
const auto& data = aItem.data().get_IPCTransferableDataInputStream(); const auto& data =
aDataTransferItem.data().get_IPCDataTransferInputStream();
nsCOMPtr<nsIInputStream> stream; nsCOMPtr<nsIInputStream> stream;
nsresult rv = NS_NewByteInputStream(getter_AddRefs(stream), nsresult rv = NS_NewByteInputStream(getter_AddRefs(stream),
AsChars(data.data().AsSpan()), AsChars(data.data().AsSpan()),
@@ -7992,20 +7972,21 @@ nsresult nsContentUtils::IPCTransferableDataItemToVariant(
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
return aVariant->SetAsISupports(stream); return aVariant->SetAsISupports(stream);
} }
case IPCTransferableDataType::TIPCTransferableDataImageContainer: { case IPCDataTransferData::TIPCDataTransferImageContainer: {
const auto& data = aItem.data().get_IPCTransferableDataImageContainer(); const auto& data =
aDataTransferItem.data().get_IPCDataTransferImageContainer();
nsCOMPtr<imgIContainer> container; nsCOMPtr<imgIContainer> container;
nsresult rv = DeserializeTransferableDataImageContainer( nsresult rv = DeserializeDataTransferImageContainer(
data, getter_AddRefs(container)); data, getter_AddRefs(container));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
return aVariant->SetAsISupports(container); return aVariant->SetAsISupports(container);
} }
case IPCTransferableDataType::TIPCTransferableDataBlob: { case IPCDataTransferData::TIPCDataTransferBlob: {
const auto& data = aItem.data().get_IPCTransferableDataBlob(); const auto& data = aDataTransferItem.data().get_IPCDataTransferBlob();
RefPtr<BlobImpl> blobImpl = IPCBlobUtils::Deserialize(data.blob()); RefPtr<BlobImpl> blobImpl = IPCBlobUtils::Deserialize(data.blob());
return aVariant->SetAsISupports(blobImpl); return aVariant->SetAsISupports(blobImpl);
} }
case IPCTransferableDataType::T__None: case IPCDataTransferData::T__None:
break; break;
} }
@@ -8013,19 +7994,18 @@ nsresult nsContentUtils::IPCTransferableDataItemToVariant(
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }
void nsContentUtils::TransferablesToIPCTransferableDatas( void nsContentUtils::TransferablesToIPCTransferables(
nsIArray* aTransferables, nsTArray<IPCTransferableData>& aIPC, nsIArray* aTransferables, nsTArray<IPCDataTransfer>& aIPC,
bool aInSyncMessage, mozilla::dom::ContentParent* aParent) { bool aInSyncMessage, mozilla::dom::ContentParent* aParent) {
aIPC.Clear(); aIPC.Clear();
if (aTransferables) { if (aTransferables) {
uint32_t transferableCount = 0; uint32_t transferableCount = 0;
aTransferables->GetLength(&transferableCount); aTransferables->GetLength(&transferableCount);
for (uint32_t i = 0; i < transferableCount; ++i) { for (uint32_t i = 0; i < transferableCount; ++i) {
IPCTransferableData* dt = aIPC.AppendElement(); IPCDataTransfer* dt = aIPC.AppendElement();
nsCOMPtr<nsITransferable> transferable = nsCOMPtr<nsITransferable> transferable =
do_QueryElementAt(aTransferables, i); do_QueryElementAt(aTransferables, i);
TransferableToIPCTransferableData(transferable, dt, aInSyncMessage, TransferableToIPCTransferable(transferable, dt, aInSyncMessage, aParent);
aParent);
} }
} }
} }
@@ -8071,9 +8051,8 @@ static already_AddRefed<DataSourceSurface> BigBufferToDataSurface(
aStride); aStride);
} }
nsresult nsContentUtils::DeserializeTransferableDataImageContainer( nsresult nsContentUtils::DeserializeDataTransferImageContainer(
const IPCTransferableDataImageContainer& aData, const IPCDataTransferImageContainer& aData, imgIContainer** aContainer) {
imgIContainer** aContainer) {
const IntSize size(aData.width(), aData.height()); const IntSize size(aData.width(), aData.height());
size_t maxBufferSize = 0; size_t maxBufferSize = 0;
size_t usedBufferSize = 0; size_t usedBufferSize = 0;
@@ -8107,20 +8086,20 @@ bool nsContentUtils::IsFlavorImage(const nsACString& aFlavor) {
// FIXME: This can probably be removed once bug 1783240 lands, as `nsString` // FIXME: This can probably be removed once bug 1783240 lands, as `nsString`
// will be implicitly serialized in shmem when sent over IPDL directly. // will be implicitly serialized in shmem when sent over IPDL directly.
static IPCTransferableDataString AsIPCTransferableDataString( static IPCDataTransferString AsIPCDataTransferString(
Span<const char16_t> aInput) { Span<const char16_t> aInput) {
return IPCTransferableDataString{BigBuffer(AsBytes(aInput))}; return IPCDataTransferString{BigBuffer(AsBytes(aInput))};
} }
// FIXME: This can probably be removed once bug 1783240 lands, as `nsCString` // FIXME: This can probably be removed once bug 1783240 lands, as `nsCString`
// will be implicitly serialized in shmem when sent over IPDL directly. // will be implicitly serialized in shmem when sent over IPDL directly.
static IPCTransferableDataCString AsIPCTransferableDataCString( static IPCDataTransferCString AsIPCDataTransferCString(
Span<const char> aInput) { Span<const char> aInput) {
return IPCTransferableDataCString{BigBuffer(AsBytes(aInput))}; return IPCDataTransferCString{BigBuffer(AsBytes(aInput))};
} }
void nsContentUtils::TransferableToIPCTransferableData( void nsContentUtils::TransferableToIPCTransferable(
nsITransferable* aTransferable, IPCTransferableData* aTransferableData, nsITransferable* aTransferable, IPCDataTransfer* aIPCDataTransfer,
bool aInSyncMessage, mozilla::dom::ContentParent* aParent) { bool aInSyncMessage, mozilla::dom::ContentParent* aParent) {
MOZ_ASSERT_IF(XRE_IsParentProcess(), aParent); MOZ_ASSERT_IF(XRE_IsParentProcess(), aParent);
@@ -8150,27 +8129,24 @@ void nsContentUtils::TransferableToIPCTransferableData(
// and for OSX we need to create // and for OSX we need to create
// nsContentAreaDragDropDataProvider as nsIFlavorDataProvider. // nsContentAreaDragDropDataProvider as nsIFlavorDataProvider.
if (flavorStr.EqualsLiteral(kFilePromiseMime)) { if (flavorStr.EqualsLiteral(kFilePromiseMime)) {
IPCTransferableDataItem* item = IPCDataTransferItem* item = aIPCDataTransfer->items().AppendElement();
aTransferableData->items().AppendElement();
item->flavor() = flavorStr; item->flavor() = flavorStr;
item->data() = item->data() =
AsIPCTransferableDataString(NS_ConvertUTF8toUTF16(flavorStr)); AsIPCDataTransferString(NS_ConvertUTF8toUTF16(flavorStr));
continue; continue;
} }
// Empty element, transfer only the flavor // Empty element, transfer only the flavor
IPCTransferableDataItem* item = IPCDataTransferItem* item = aIPCDataTransfer->items().AppendElement();
aTransferableData->items().AppendElement();
item->flavor() = flavorStr; item->flavor() = flavorStr;
item->data() = AsIPCTransferableDataString(EmptyString()); item->data() = AsIPCDataTransferString(EmptyString());
continue; continue;
} }
// We need to handle nsIInputStream before nsISupportsCString, otherwise // We need to handle nsIInputStream before nsISupportsCString, otherwise
// nsStringInputStream would be converted into a wrong type. // nsStringInputStream would be converted into a wrong type.
if (nsCOMPtr<nsIInputStream> stream = do_QueryInterface(data)) { if (nsCOMPtr<nsIInputStream> stream = do_QueryInterface(data)) {
IPCTransferableDataItem* item = IPCDataTransferItem* item = aIPCDataTransfer->items().AppendElement();
aTransferableData->items().AppendElement();
item->flavor() = flavorStr; item->flavor() = flavorStr;
nsCString imageData; nsCString imageData;
DebugOnly<nsresult> rv = DebugOnly<nsresult> rv =
@@ -8182,7 +8158,7 @@ void nsContentUtils::TransferableToIPCTransferableData(
// `nsCString` will be implicitly serialized in shmem when sent over // `nsCString` will be implicitly serialized in shmem when sent over
// IPDL directly. // IPDL directly.
item->data() = item->data() =
IPCTransferableDataInputStream(BigBuffer(AsBytes(Span(imageData)))); IPCDataTransferInputStream(BigBuffer(AsBytes(Span(imageData))));
continue; continue;
} }
@@ -8190,10 +8166,9 @@ void nsContentUtils::TransferableToIPCTransferableData(
nsAutoString dataAsString; nsAutoString dataAsString;
MOZ_ALWAYS_SUCCEEDS(text->GetData(dataAsString)); MOZ_ALWAYS_SUCCEEDS(text->GetData(dataAsString));
IPCTransferableDataItem* item = IPCDataTransferItem* item = aIPCDataTransfer->items().AppendElement();
aTransferableData->items().AppendElement();
item->flavor() = flavorStr; item->flavor() = flavorStr;
item->data() = AsIPCTransferableDataString(dataAsString); item->data() = AsIPCDataTransferString(dataAsString);
continue; continue;
} }
@@ -8201,10 +8176,9 @@ void nsContentUtils::TransferableToIPCTransferableData(
nsAutoCString dataAsString; nsAutoCString dataAsString;
MOZ_ALWAYS_SUCCEEDS(ctext->GetData(dataAsString)); MOZ_ALWAYS_SUCCEEDS(ctext->GetData(dataAsString));
IPCTransferableDataItem* item = IPCDataTransferItem* item = aIPCDataTransfer->items().AppendElement();
aTransferableData->items().AppendElement();
item->flavor() = flavorStr; item->flavor() = flavorStr;
item->data() = AsIPCTransferableDataCString(dataAsString); item->data() = AsIPCDataTransferCString(dataAsString);
continue; continue;
} }
@@ -8230,12 +8204,11 @@ void nsContentUtils::TransferableToIPCTransferableData(
continue; continue;
} }
IPCTransferableDataItem* item = IPCDataTransferItem* item = aIPCDataTransfer->items().AppendElement();
aTransferableData->items().AppendElement();
item->flavor() = flavorStr; item->flavor() = flavorStr;
mozilla::gfx::IntSize size = dataSurface->GetSize(); mozilla::gfx::IntSize size = dataSurface->GetSize();
item->data() = IPCTransferableDataImageContainer( item->data() = IPCDataTransferImageContainer(
std::move(*surfaceData), size.width, size.height, stride, std::move(*surfaceData), size.width, size.height, stride,
dataSurface->GetFormat()); dataSurface->GetFormat());
continue; continue;
@@ -8292,39 +8265,14 @@ void nsContentUtils::TransferableToIPCTransferableData(
continue; continue;
} }
IPCTransferableDataItem* item = IPCDataTransferItem* item = aIPCDataTransfer->items().AppendElement();
aTransferableData->items().AppendElement();
item->flavor() = flavorStr; item->flavor() = flavorStr;
item->data() = IPCTransferableDataBlob(ipcBlob); item->data() = IPCDataTransferBlob(ipcBlob);
} }
} }
} }
} }
void nsContentUtils::TransferableToIPCTransferable(
nsITransferable* aTransferable, IPCTransferable* aIPCTransferable,
bool aInSyncMessage, mozilla::dom::ContentParent* aParent) {
IPCTransferableData ipcTransferableData;
TransferableToIPCTransferableData(aTransferable, &ipcTransferableData,
aInSyncMessage, aParent);
Maybe<net::CookieJarSettingsArgs> cookieJarSettingsArgs;
if (nsCOMPtr<nsICookieJarSettings> cookieJarSettings =
aTransferable->GetCookieJarSettings()) {
net::CookieJarSettingsArgs args;
net::CookieJarSettings::Cast(cookieJarSettings)->Serialize(args);
cookieJarSettingsArgs = Some(std::move(args));
}
aIPCTransferable->data() = std::move(ipcTransferableData);
aIPCTransferable->isPrivateData() = aTransferable->GetIsPrivateData();
aIPCTransferable->requestingPrincipal() =
aTransferable->GetRequestingPrincipal();
aIPCTransferable->cookieJarSettings() = std::move(cookieJarSettingsArgs);
aIPCTransferable->contentPolicyType() = aTransferable->GetContentPolicyType();
aIPCTransferable->referrerInfo() = aTransferable->GetReferrerInfo();
}
Maybe<BigBuffer> nsContentUtils::GetSurfaceData(DataSourceSurface& aSurface, Maybe<BigBuffer> nsContentUtils::GetSurfaceData(DataSourceSurface& aSurface,
size_t* aLength, size_t* aLength,
int32_t* aStride) { int32_t* aStride) {

View File

@@ -182,10 +182,9 @@ class Element;
class Event; class Event;
class EventTarget; class EventTarget;
class HTMLInputElement; class HTMLInputElement;
class IPCTransferable; class IPCDataTransfer;
class IPCTransferableData; class IPCDataTransferImageContainer;
class IPCTransferableDataImageContainer; class IPCDataTransferItem;
class IPCTransferableDataItem;
struct LifecycleCallbackArgs; struct LifecycleCallbackArgs;
class MessageBroadcaster; class MessageBroadcaster;
class NodeInfo; class NodeInfo;
@@ -2849,8 +2848,8 @@ class nsContentUtils {
* Given an IPCDataTransferImageContainer construct an imgIContainer for the * Given an IPCDataTransferImageContainer construct an imgIContainer for the
* image encoded by the transfer item. * image encoded by the transfer item.
*/ */
static nsresult DeserializeTransferableDataImageContainer( static nsresult DeserializeDataTransferImageContainer(
const mozilla::dom::IPCTransferableDataImageContainer& aData, const mozilla::dom::IPCDataTransferImageContainer& aData,
imgIContainer** aContainer); imgIContainer** aContainer);
/** /**
@@ -2859,42 +2858,30 @@ class nsContentUtils {
*/ */
static bool IsFlavorImage(const nsACString& aFlavor); static bool IsFlavorImage(const nsACString& aFlavor);
static bool IPCTransferableDataItemHasKnownFlavor( static bool IPCDataTransferItemHasKnownFlavor(
const mozilla::dom::IPCTransferableDataItem& aItem); const mozilla::dom::IPCDataTransferItem& aItem);
static nsresult IPCTransferableDataToTransferable( static nsresult IPCTransferableToTransferable(
const mozilla::dom::IPCTransferableData& aTransferableData, const mozilla::dom::IPCDataTransfer& aDataTransfer, bool aAddDataFlavor,
bool aAddDataFlavor, nsITransferable* aTransferable, nsITransferable* aTransferable, const bool aFilterUnknownFlavors);
const bool aFilterUnknownFlavors);
static nsresult IPCTransferableDataToTransferable( static nsresult IPCTransferableToTransferable(
const mozilla::dom::IPCTransferableData& aTransferableData, const mozilla::dom::IPCDataTransfer& aDataTransfer,
const bool& aIsPrivateData, nsIPrincipal* aRequestingPrincipal, const bool& aIsPrivateData, nsIPrincipal* aRequestingPrincipal,
const nsContentPolicyType& aContentPolicyType, bool aAddDataFlavor, const nsContentPolicyType& aContentPolicyType, bool aAddDataFlavor,
nsITransferable* aTransferable, const bool aFilterUnknownFlavors); nsITransferable* aTransferable, const bool aFilterUnknownFlavors);
static nsresult IPCTransferableToTransferable( static nsresult IPCTransferableItemToVariant(
const mozilla::dom::IPCTransferable& aIPCTransferable, const mozilla::dom::IPCDataTransferItem& aDataTransferItem,
bool aAddDataFlavor, nsITransferable* aTransferable,
const bool aFilterUnknownFlavors);
static nsresult IPCTransferableDataItemToVariant(
const mozilla::dom::IPCTransferableDataItem& aItem,
nsIWritableVariant* aVariant); nsIWritableVariant* aVariant);
static void TransferablesToIPCTransferableDatas( static void TransferablesToIPCTransferables(
nsIArray* aTransferables, nsIArray* aTransferables, nsTArray<mozilla::dom::IPCDataTransfer>& aIPC,
nsTArray<mozilla::dom::IPCTransferableData>& aIPC, bool aInSyncMessage, bool aInSyncMessage, mozilla::dom::ContentParent* aParent);
mozilla::dom::ContentParent* aParent);
static void TransferableToIPCTransferableData(
nsITransferable* aTransferable,
mozilla::dom::IPCTransferableData* aTransferableData, bool aInSyncMessage,
mozilla::dom::ContentParent* aParent);
static void TransferableToIPCTransferable( static void TransferableToIPCTransferable(
nsITransferable* aTransferable, nsITransferable* aTransferable,
mozilla::dom::IPCTransferable* aIPCTransferable, bool aInSyncMessage, mozilla::dom::IPCDataTransfer* aIPCDataTransfer, bool aInSyncMessage,
mozilla::dom::ContentParent* aParent); mozilla::dom::ContentParent* aParent);
/* /*

View File

@@ -6065,15 +6065,15 @@ nsresult EventStateManager::DoContentCommandEvent(
BrowserParent* remote = BrowserParent::GetFocused(); BrowserParent* remote = BrowserParent::GetFocused();
if (remote) { if (remote) {
nsCOMPtr<nsITransferable> transferable = aEvent->mTransferable; nsCOMPtr<nsITransferable> transferable = aEvent->mTransferable;
IPCTransferableData ipcTransferableData; IPCDataTransfer ipcDataTransfer;
nsContentUtils::TransferableToIPCTransferableData( nsContentUtils::TransferableToIPCTransferable(
transferable, &ipcTransferableData, false, remote->Manager()); transferable, &ipcDataTransfer, false, remote->Manager());
bool isPrivateData = transferable->GetIsPrivateData(); bool isPrivateData = transferable->GetIsPrivateData();
nsCOMPtr<nsIPrincipal> requestingPrincipal = nsCOMPtr<nsIPrincipal> requestingPrincipal =
transferable->GetRequestingPrincipal(); transferable->GetRequestingPrincipal();
nsContentPolicyType contentPolicyType = nsContentPolicyType contentPolicyType =
transferable->GetContentPolicyType(); transferable->GetContentPolicyType();
remote->SendPasteTransferable(std::move(ipcTransferableData), remote->SendPasteTransferable(std::move(ipcDataTransfer),
isPrivateData, requestingPrincipal, isPrivateData, requestingPrincipal,
contentPolicyType); contentPolicyType);
rv = NS_OK; rv = NS_OK;

View File

@@ -20,13 +20,12 @@ namespace mozilla::dom {
RemoteDragStartData::~RemoteDragStartData() = default; RemoteDragStartData::~RemoteDragStartData() = default;
RemoteDragStartData::RemoteDragStartData( RemoteDragStartData::RemoteDragStartData(
BrowserParent* aBrowserParent, BrowserParent* aBrowserParent, nsTArray<IPCDataTransfer>&& aDataTransfer,
nsTArray<IPCTransferableData>&& aTransferableData,
const LayoutDeviceIntRect& aRect, nsIPrincipal* aPrincipal, const LayoutDeviceIntRect& aRect, nsIPrincipal* aPrincipal,
nsIContentSecurityPolicy* aCsp, nsICookieJarSettings* aCookieJarSettings, nsIContentSecurityPolicy* aCsp, nsICookieJarSettings* aCookieJarSettings,
WindowContext* aSourceWindowContext, WindowContext* aSourceTopWindowContext) WindowContext* aSourceWindowContext, WindowContext* aSourceTopWindowContext)
: mBrowserParent(aBrowserParent), : mBrowserParent(aBrowserParent),
mTransferableData(std::move(aTransferableData)), mDataTransfer(std::move(aDataTransfer)),
mRect(aRect), mRect(aRect),
mPrincipal(aPrincipal), mPrincipal(aPrincipal),
mCsp(aCsp), mCsp(aCsp),
@@ -42,10 +41,10 @@ void RemoteDragStartData::AddInitialDnDDataTo(
NS_IF_ADDREF(*aCsp = mCsp); NS_IF_ADDREF(*aCsp = mCsp);
NS_IF_ADDREF(*aCookieJarSettings = mCookieJarSettings); NS_IF_ADDREF(*aCookieJarSettings = mCookieJarSettings);
for (uint32_t i = 0; i < mTransferableData.Length(); ++i) { for (uint32_t i = 0; i < mDataTransfer.Length(); ++i) {
nsTArray<IPCTransferableDataItem>& itemArray = mTransferableData[i].items(); nsTArray<IPCDataTransferItem>& itemArray = mDataTransfer[i].items();
for (auto& item : itemArray) { for (auto& item : itemArray) {
if (!nsContentUtils::IPCTransferableDataItemHasKnownFlavor(item)) { if (!nsContentUtils::IPCDataTransferItemHasKnownFlavor(item)) {
NS_WARNING( NS_WARNING(
"Ignoring unknown flavor in " "Ignoring unknown flavor in "
"RemoteDragStartData::AddInitialDnDDataTo"); "RemoteDragStartData::AddInitialDnDDataTo");
@@ -61,7 +60,7 @@ void RemoteDragStartData::AddInitialDnDDataTo(
variant->SetAsISupports(flavorDataProvider); variant->SetAsISupports(flavorDataProvider);
} else { } else {
nsresult rv = nsresult rv =
nsContentUtils::IPCTransferableDataItemToVariant(item, variant); nsContentUtils::IPCTransferableItemToVariant(item, variant);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
continue; continue;
} }
@@ -76,7 +75,7 @@ void RemoteDragStartData::AddInitialDnDDataTo(
} }
// Clear things that are no longer needed. // Clear things that are no longer needed.
mTransferableData.Clear(); mDataTransfer.Clear();
mPrincipal = nullptr; mPrincipal = nullptr;
} }

View File

@@ -27,7 +27,7 @@ class RemoteDragStartData {
NS_INLINE_DECL_REFCOUNTING(RemoteDragStartData) NS_INLINE_DECL_REFCOUNTING(RemoteDragStartData)
RemoteDragStartData(BrowserParent* aBrowserParent, RemoteDragStartData(BrowserParent* aBrowserParent,
nsTArray<IPCTransferableData>&& aTransferableData, nsTArray<IPCDataTransfer>&& aDataTransfer,
const LayoutDeviceIntRect& aRect, const LayoutDeviceIntRect& aRect,
nsIPrincipal* aPrincipal, nsIContentSecurityPolicy* aCsp, nsIPrincipal* aPrincipal, nsIContentSecurityPolicy* aCsp,
nsICookieJarSettings* aCookieJarSettings, nsICookieJarSettings* aCookieJarSettings,
@@ -59,7 +59,7 @@ class RemoteDragStartData {
virtual ~RemoteDragStartData(); virtual ~RemoteDragStartData();
RefPtr<BrowserParent> mBrowserParent; RefPtr<BrowserParent> mBrowserParent;
nsTArray<IPCTransferableData> mTransferableData; nsTArray<IPCDataTransfer> mDataTransfer;
const LayoutDeviceIntRect mRect; const LayoutDeviceIntRect mRect;
nsCOMPtr<nsIPrincipal> mPrincipal; nsCOMPtr<nsIPrincipal> mPrincipal;
nsCOMPtr<nsIContentSecurityPolicy> mCsp; nsCOMPtr<nsIContentSecurityPolicy> mCsp;

View File

@@ -2135,7 +2135,7 @@ mozilla::ipc::IPCResult BrowserChild::RecvNormalPriorityInsertText(
} }
mozilla::ipc::IPCResult BrowserChild::RecvPasteTransferable( mozilla::ipc::IPCResult BrowserChild::RecvPasteTransferable(
const IPCTransferableData& aTransferableData, const bool& aIsPrivateData, const IPCDataTransfer& aDataTransfer, const bool& aIsPrivateData,
nsIPrincipal* aRequestingPrincipal, nsIPrincipal* aRequestingPrincipal,
const nsContentPolicyType& aContentPolicyType) { const nsContentPolicyType& aContentPolicyType) {
nsresult rv; nsresult rv;
@@ -2144,10 +2144,9 @@ mozilla::ipc::IPCResult BrowserChild::RecvPasteTransferable(
NS_ENSURE_SUCCESS(rv, IPC_OK()); NS_ENSURE_SUCCESS(rv, IPC_OK());
trans->Init(nullptr); trans->Init(nullptr);
rv = nsContentUtils::IPCTransferableDataToTransferable( rv = nsContentUtils::IPCTransferableToTransferable(
aTransferableData, aIsPrivateData, aRequestingPrincipal, aDataTransfer, aIsPrivateData, aRequestingPrincipal, aContentPolicyType,
aContentPolicyType, true /* aAddDataFlavor */, trans, true /* aAddDataFlavor */, trans, false /* aFilterUnknownFlavors */);
false /* aFilterUnknownFlavors */);
NS_ENSURE_SUCCESS(rv, IPC_OK()); NS_ENSURE_SUCCESS(rv, IPC_OK());
nsCOMPtr<nsIDocShell> ourDocShell = do_GetInterface(WebNavigation()); nsCOMPtr<nsIDocShell> ourDocShell = do_GetInterface(WebNavigation());

View File

@@ -410,7 +410,7 @@ class BrowserChild final : public nsMessageManagerScriptExecutor,
MOZ_CAN_RUN_SCRIPT_BOUNDARY MOZ_CAN_RUN_SCRIPT_BOUNDARY
mozilla::ipc::IPCResult RecvPasteTransferable( mozilla::ipc::IPCResult RecvPasteTransferable(
const IPCTransferableData& aTransferableData, const bool& aIsPrivateData, const IPCDataTransfer& aDataTransfer, const bool& aIsPrivateData,
nsIPrincipal* aRequestingPrincipal, nsIPrincipal* aRequestingPrincipal,
const nsContentPolicyType& aContentPolicyType); const nsContentPolicyType& aContentPolicyType);

View File

@@ -3132,11 +3132,11 @@ bool BrowserParent::SendInsertText(const nsString& aStringToInsert) {
} }
bool BrowserParent::SendPasteTransferable( bool BrowserParent::SendPasteTransferable(
IPCTransferableData&& aTransferableData, const bool& aIsPrivateData, IPCDataTransfer&& aDataTransfer, const bool& aIsPrivateData,
nsIPrincipal* aRequestingPrincipal, nsIPrincipal* aRequestingPrincipal,
const nsContentPolicyType& aContentPolicyType) { const nsContentPolicyType& aContentPolicyType) {
return PBrowserParent::SendPasteTransferable( return PBrowserParent::SendPasteTransferable(
std::move(aTransferableData), aIsPrivateData, aRequestingPrincipal, std::move(aDataTransfer), aIsPrivateData, aRequestingPrincipal,
aContentPolicyType); aContentPolicyType);
} }
@@ -3733,7 +3733,7 @@ nsresult BrowserParent::HandleEvent(Event* aEvent) {
} }
mozilla::ipc::IPCResult BrowserParent::RecvInvokeDragSession( mozilla::ipc::IPCResult BrowserParent::RecvInvokeDragSession(
nsTArray<IPCTransferableData>&& aTransferables, const uint32_t& aAction, nsTArray<IPCDataTransfer>&& aTransfers, const uint32_t& aAction,
Maybe<BigBuffer>&& aVisualDnDData, const uint32_t& aStride, Maybe<BigBuffer>&& aVisualDnDData, const uint32_t& aStride,
const gfx::SurfaceFormat& aFormat, const LayoutDeviceIntRect& aDragRect, const gfx::SurfaceFormat& aFormat, const LayoutDeviceIntRect& aDragRect,
nsIPrincipal* aPrincipal, nsIContentSecurityPolicy* aCsp, nsIPrincipal* aPrincipal, nsIContentSecurityPolicy* aCsp,
@@ -3756,7 +3756,7 @@ mozilla::ipc::IPCResult BrowserParent::RecvInvokeDragSession(
getter_AddRefs(cookieJarSettings)); getter_AddRefs(cookieJarSettings));
RefPtr<RemoteDragStartData> dragStartData = new RemoteDragStartData( RefPtr<RemoteDragStartData> dragStartData = new RemoteDragStartData(
this, std::move(aTransferables), aDragRect, aPrincipal, aCsp, this, std::move(aTransfers), aDragRect, aPrincipal, aCsp,
cookieJarSettings, aSourceWindowContext.GetMaybeDiscarded(), cookieJarSettings, aSourceWindowContext.GetMaybeDiscarded(),
aSourceTopWindowContext.GetMaybeDiscarded()); aSourceTopWindowContext.GetMaybeDiscarded());

View File

@@ -607,7 +607,7 @@ class BrowserParent final : public PBrowserParent,
bool SendInsertText(const nsString& aStringToInsert); bool SendInsertText(const nsString& aStringToInsert);
bool SendPasteTransferable(IPCTransferableData&& aTransferableData, bool SendPasteTransferable(IPCDataTransfer&& aDataTransfer,
const bool& aIsPrivateData, const bool& aIsPrivateData,
nsIPrincipal* aRequestingPrincipal, nsIPrincipal* aRequestingPrincipal,
const nsContentPolicyType& aContentPolicyType); const nsContentPolicyType& aContentPolicyType);
@@ -667,7 +667,7 @@ class BrowserParent final : public PBrowserParent,
void LayerTreeUpdate(const LayersObserverEpoch& aEpoch, bool aActive); void LayerTreeUpdate(const LayersObserverEpoch& aEpoch, bool aActive);
mozilla::ipc::IPCResult RecvInvokeDragSession( mozilla::ipc::IPCResult RecvInvokeDragSession(
nsTArray<IPCTransferableData>&& aTransferables, const uint32_t& aAction, nsTArray<IPCDataTransfer>&& aTransfers, const uint32_t& aAction,
Maybe<BigBuffer>&& aVisualDnDData, const uint32_t& aStride, Maybe<BigBuffer>&& aVisualDnDData, const uint32_t& aStride,
const gfx::SurfaceFormat& aFormat, const LayoutDeviceIntRect& aDragRect, const gfx::SurfaceFormat& aFormat, const LayoutDeviceIntRect& aDragRect,
nsIPrincipal* aPrincipal, nsIContentSecurityPolicy* aCsp, nsIPrincipal* aPrincipal, nsIContentSecurityPolicy* aCsp,
@@ -675,7 +675,7 @@ class BrowserParent final : public PBrowserParent,
const MaybeDiscarded<WindowContext>& aSourceWindowContext, const MaybeDiscarded<WindowContext>& aSourceWindowContext,
const MaybeDiscarded<WindowContext>& aSourceTopWindowContext); const MaybeDiscarded<WindowContext>& aSourceTopWindowContext);
void AddInitialDnDDataTo(IPCTransferableData* aTransferableData, void AddInitialDnDDataTo(DataTransfer* aDataTransfer,
nsIPrincipal** aPrincipal); nsIPrincipal** aPrincipal);
bool TakeDragVisualization(RefPtr<mozilla::gfx::SourceSurface>& aSurface, bool TakeDragVisualization(RefPtr<mozilla::gfx::SourceSurface>& aSurface,

View File

@@ -3228,7 +3228,7 @@ bool ContentChild::DeallocPWebBrowserPersistDocumentChild(
mozilla::ipc::IPCResult ContentChild::RecvInvokeDragSession( mozilla::ipc::IPCResult ContentChild::RecvInvokeDragSession(
const MaybeDiscarded<WindowContext>& aSourceWindowContext, const MaybeDiscarded<WindowContext>& aSourceWindowContext,
const MaybeDiscarded<WindowContext>& aSourceTopWindowContext, const MaybeDiscarded<WindowContext>& aSourceTopWindowContext,
nsTArray<IPCTransferableData>&& aTransferables, const uint32_t& aAction) { nsTArray<IPCDataTransfer>&& aTransfers, const uint32_t& aAction) {
nsCOMPtr<nsIDragService> dragService = nsCOMPtr<nsIDragService> dragService =
do_GetService("@mozilla.org/widget/dragservice;1"); do_GetService("@mozilla.org/widget/dragservice;1");
if (dragService) { if (dragService) {
@@ -3243,11 +3243,11 @@ mozilla::ipc::IPCResult ContentChild::RecvInvokeDragSession(
// Check if we are receiving any file objects. If we are we will want // Check if we are receiving any file objects. If we are we will want
// to hide any of the other objects coming in from content. // to hide any of the other objects coming in from content.
bool hasFiles = false; bool hasFiles = false;
for (uint32_t i = 0; i < aTransferables.Length() && !hasFiles; ++i) { for (uint32_t i = 0; i < aTransfers.Length() && !hasFiles; ++i) {
auto& items = aTransferables[i].items(); auto& items = aTransfers[i].items();
for (uint32_t j = 0; j < items.Length() && !hasFiles; ++j) { for (uint32_t j = 0; j < items.Length() && !hasFiles; ++j) {
if (items[j].data().type() == if (items[j].data().type() ==
IPCTransferableDataType::TIPCTransferableDataBlob) { IPCDataTransferData::TIPCDataTransferBlob) {
hasFiles = true; hasFiles = true;
} }
} }
@@ -3256,13 +3256,13 @@ mozilla::ipc::IPCResult ContentChild::RecvInvokeDragSession(
// Add the entries from the IPC to the new DataTransfer // Add the entries from the IPC to the new DataTransfer
nsCOMPtr<DataTransfer> dataTransfer = nsCOMPtr<DataTransfer> dataTransfer =
new DataTransfer(nullptr, eDragStart, false, -1); new DataTransfer(nullptr, eDragStart, false, -1);
for (uint32_t i = 0; i < aTransferables.Length(); ++i) { for (uint32_t i = 0; i < aTransfers.Length(); ++i) {
auto& items = aTransferables[i].items(); auto& items = aTransfers[i].items();
for (uint32_t j = 0; j < items.Length(); ++j) { for (uint32_t j = 0; j < items.Length(); ++j) {
const IPCTransferableDataItem& item = items[j]; const IPCDataTransferItem& item = items[j];
RefPtr<nsVariantCC> variant = new nsVariantCC(); RefPtr<nsVariantCC> variant = new nsVariantCC();
nsresult rv = nsresult rv =
nsContentUtils::IPCTransferableDataItemToVariant(item, variant); nsContentUtils::IPCTransferableItemToVariant(item, variant);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
continue; continue;
} }
@@ -3270,8 +3270,8 @@ mozilla::ipc::IPCResult ContentChild::RecvInvokeDragSession(
// We should hide this data from content if we have a file, and we // We should hide this data from content if we have a file, and we
// aren't a file. // aren't a file.
bool hidden = bool hidden =
hasFiles && item.data().type() != hasFiles &&
IPCTransferableDataType::TIPCTransferableDataBlob; item.data().type() != IPCDataTransferData::TIPCDataTransferBlob;
dataTransfer->SetDataWithPrincipalFromOtherProcess( dataTransfer->SetDataWithPrincipalFromOtherProcess(
NS_ConvertUTF8toUTF16(item.flavor()), variant, i, NS_ConvertUTF8toUTF16(item.flavor()), variant, i,
nsContentUtils::GetSystemPrincipal(), hidden); nsContentUtils::GetSystemPrincipal(), hidden);

View File

@@ -415,7 +415,7 @@ class ContentChild final : public PContentChild,
mozilla::ipc::IPCResult RecvInvokeDragSession( mozilla::ipc::IPCResult RecvInvokeDragSession(
const MaybeDiscarded<WindowContext>& aSourceWindowContext, const MaybeDiscarded<WindowContext>& aSourceWindowContext,
const MaybeDiscarded<WindowContext>& aSourceTopWindowContext, const MaybeDiscarded<WindowContext>& aSourceTopWindowContext,
nsTArray<IPCTransferableData>&& aTransferables, const uint32_t& aAction); nsTArray<IPCDataTransfer>&& aTransfers, const uint32_t& aAction);
MOZ_CAN_RUN_SCRIPT_BOUNDARY MOZ_CAN_RUN_SCRIPT_BOUNDARY
mozilla::ipc::IPCResult RecvEndDragSession( mozilla::ipc::IPCResult RecvEndDragSession(

View File

@@ -3467,13 +3467,16 @@ void ContentParent::OnVarChanged(const GfxVarUpdate& aVar) {
} }
mozilla::ipc::IPCResult ContentParent::RecvSetClipboard( mozilla::ipc::IPCResult ContentParent::RecvSetClipboard(
const IPCTransferable& aTransferable, const int32_t& aWhichClipboard) { const IPCDataTransfer& aDataTransfer, const bool& aIsPrivateData,
nsIPrincipal* aRequestingPrincipal,
mozilla::Maybe<CookieJarSettingsArgs> aCookieJarSettingsArgs,
const nsContentPolicyType& aContentPolicyType,
nsIReferrerInfo* aReferrerInfo, const int32_t& aWhichClipboard) {
// aRequestingPrincipal is allowed to be nullptr here. // aRequestingPrincipal is allowed to be nullptr here.
if (!ValidatePrincipal(aTransferable.requestingPrincipal(), if (!ValidatePrincipal(aRequestingPrincipal,
{ValidatePrincipalOptions::AllowNullPtr})) { {ValidatePrincipalOptions::AllowNullPtr})) {
LogAndAssertFailedPrincipalValidationInfo( LogAndAssertFailedPrincipalValidationInfo(aRequestingPrincipal, __func__);
aTransferable.requestingPrincipal(), __func__);
} }
nsresult rv; nsresult rv;
@@ -3484,10 +3487,18 @@ mozilla::ipc::IPCResult ContentParent::RecvSetClipboard(
do_CreateInstance("@mozilla.org/widget/transferable;1", &rv); do_CreateInstance("@mozilla.org/widget/transferable;1", &rv);
NS_ENSURE_SUCCESS(rv, IPC_OK()); NS_ENSURE_SUCCESS(rv, IPC_OK());
trans->Init(nullptr); trans->Init(nullptr);
trans->SetReferrerInfo(aReferrerInfo);
if (aCookieJarSettingsArgs.isSome()) {
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
net::CookieJarSettings::Deserialize(aCookieJarSettingsArgs.ref(),
getter_AddRefs(cookieJarSettings));
trans->SetCookieJarSettings(cookieJarSettings);
}
rv = nsContentUtils::IPCTransferableToTransferable( rv = nsContentUtils::IPCTransferableToTransferable(
aTransferable, true /* aAddDataFlavor */, trans, aDataTransfer, aIsPrivateData, aRequestingPrincipal, aContentPolicyType,
true /* aFilterUnknownFlavors */); true /* aAddDataFlavor */, trans, true /* aFilterUnknownFlavors */);
NS_ENSURE_SUCCESS(rv, IPC_OK()); NS_ENSURE_SUCCESS(rv, IPC_OK());
clipboard->SetData(trans, nullptr, aWhichClipboard); clipboard->SetData(trans, nullptr, aWhichClipboard);
@@ -3524,7 +3535,7 @@ static Result<nsCOMPtr<nsITransferable>, nsresult> CreateTransferable(
mozilla::ipc::IPCResult ContentParent::RecvGetClipboard( mozilla::ipc::IPCResult ContentParent::RecvGetClipboard(
nsTArray<nsCString>&& aTypes, const int32_t& aWhichClipboard, nsTArray<nsCString>&& aTypes, const int32_t& aWhichClipboard,
IPCTransferableData* aTransferableData) { IPCDataTransfer* aDataTransfer) {
nsresult rv; nsresult rv;
// Retrieve clipboard // Retrieve clipboard
nsCOMPtr<nsIClipboard> clipboard(do_GetService(kCClipboardCID, &rv)); nsCOMPtr<nsIClipboard> clipboard(do_GetService(kCClipboardCID, &rv));
@@ -3542,8 +3553,8 @@ mozilla::ipc::IPCResult ContentParent::RecvGetClipboard(
nsCOMPtr<nsITransferable> trans = result.unwrap(); nsCOMPtr<nsITransferable> trans = result.unwrap();
clipboard->GetData(trans, aWhichClipboard); clipboard->GetData(trans, aWhichClipboard);
nsContentUtils::TransferableToIPCTransferableData( nsContentUtils::TransferableToIPCTransferable(
trans, aTransferableData, true /* aInSyncMessage */, this); trans, aDataTransfer, true /* aInSyncMessage */, this);
return IPC_OK(); return IPC_OK();
} }
@@ -3620,14 +3631,13 @@ mozilla::ipc::IPCResult ContentParent::RecvGetClipboardAsync(
// Get data from clipboard // Get data from clipboard
nsCOMPtr<nsITransferable> trans = result.unwrap(); nsCOMPtr<nsITransferable> trans = result.unwrap();
clipboard->AsyncGetData(trans, nsIClipboard::kGlobalClipboard) clipboard->AsyncGetData(trans, nsIClipboard::kGlobalClipboard)
->Then( ->Then(GetMainThreadSerialEventTarget(), __func__,
GetMainThreadSerialEventTarget(), __func__, [trans, aResolver, self = RefPtr{this}](
[trans, aResolver, GenericPromise::ResolveOrRejectValue&& aValue) {
self = RefPtr{this}](GenericPromise::ResolveOrRejectValue&& aValue) { IPCDataTransfer ipcDataTransfer;
IPCTransferableData ipcTransferableData; nsContentUtils::TransferableToIPCTransferable(
nsContentUtils::TransferableToIPCTransferableData( trans, &ipcDataTransfer, false /* aInSyncMessage */, self);
trans, &ipcTransferableData, false /* aInSyncMessage */, self); aResolver(std::move(ipcDataTransfer));
aResolver(std::move(ipcTransferableData));
}); });
return IPC_OK(); return IPC_OK();
} }
@@ -5459,7 +5469,7 @@ void ContentParent::MaybeInvokeDragSession(BrowserParent* aParent) {
nsCOMPtr<nsIDragSession> session; nsCOMPtr<nsIDragSession> session;
dragService->GetCurrentSession(getter_AddRefs(session)); dragService->GetCurrentSession(getter_AddRefs(session));
if (session) { if (session) {
nsTArray<IPCTransferableData> ipcTransferables; nsTArray<IPCDataTransfer> dataTransfers;
RefPtr<DataTransfer> transfer = session->GetDataTransfer(); RefPtr<DataTransfer> transfer = session->GetDataTransfer();
if (!transfer) { if (!transfer) {
// Pass eDrop to get DataTransfer with external // Pass eDrop to get DataTransfer with external
@@ -5474,8 +5484,8 @@ void ContentParent::MaybeInvokeDragSession(BrowserParent* aParent) {
nsCOMPtr<nsILoadContext> lc = nsCOMPtr<nsILoadContext> lc =
aParent ? aParent->GetLoadContext() : nullptr; aParent ? aParent->GetLoadContext() : nullptr;
nsCOMPtr<nsIArray> transferables = transfer->GetTransferables(lc); nsCOMPtr<nsIArray> transferables = transfer->GetTransferables(lc);
nsContentUtils::TransferablesToIPCTransferableDatas( nsContentUtils::TransferablesToIPCTransferables(
transferables, ipcTransferables, false, this); transferables, dataTransfers, false, this);
uint32_t action; uint32_t action;
session->GetDragAction(&action); session->GetDragAction(&action);
@@ -5484,7 +5494,7 @@ void ContentParent::MaybeInvokeDragSession(BrowserParent* aParent) {
RefPtr<WindowContext> sourceTopWC; RefPtr<WindowContext> sourceTopWC;
session->GetSourceTopWindowContext(getter_AddRefs(sourceTopWC)); session->GetSourceTopWindowContext(getter_AddRefs(sourceTopWC));
mozilla::Unused << SendInvokeDragSession( mozilla::Unused << SendInvokeDragSession(
sourceWC, sourceTopWC, std::move(ipcTransferables), action); sourceWC, sourceTopWC, std::move(dataTransfers), action);
} }
} }
} }

View File

@@ -994,12 +994,16 @@ class ContentParent final : public PContentParent,
mozilla::ipc::IPCResult RecvGetGfxVars(nsTArray<GfxVarUpdate>* aVars); mozilla::ipc::IPCResult RecvGetGfxVars(nsTArray<GfxVarUpdate>* aVars);
mozilla::ipc::IPCResult RecvSetClipboard(const IPCTransferable& aTransferable, mozilla::ipc::IPCResult RecvSetClipboard(
const int32_t& aWhichClipboard); const IPCDataTransfer& aDataTransfer, const bool& aIsPrivateData,
nsIPrincipal* aRequestingPrincipal,
mozilla::Maybe<CookieJarSettingsArgs> aCookieJarSettingsArgs,
const nsContentPolicyType& aContentPolicyType,
nsIReferrerInfo* aReferrerInfo, const int32_t& aWhichClipboard);
mozilla::ipc::IPCResult RecvGetClipboard( mozilla::ipc::IPCResult RecvGetClipboard(nsTArray<nsCString>&& aTypes,
nsTArray<nsCString>&& aTypes, const int32_t& aWhichClipboard, const int32_t& aWhichClipboard,
IPCTransferableData* aTransferableData); IPCDataTransfer* aDataTransfer);
mozilla::ipc::IPCResult RecvEmptyClipboard(const int32_t& aWhichClipboard); mozilla::ipc::IPCResult RecvEmptyClipboard(const int32_t& aWhichClipboard);

View File

@@ -100,6 +100,62 @@ struct MessageData {
MessageDataType data; MessageDataType data;
}; };
struct IPCDataTransferString
{
BigBuffer data;
};
struct IPCDataTransferCString
{
BigBuffer data;
};
struct IPCDataTransferInputStream
{
// NOTE: Editor currently relies on these input streams being synchronous, so
// we can't safely serialize them using IPCStream (see bug 1778565). Instead,
// they're serialized as a `BigBuffer`, and converted to a nsStringInputStream
// on the receiving side. If we are able to use async streams reliably in the
// future, we could consider switching the code which adds `nsIInputStream`s
// to the transferable to use `BlobImpl` instead, for more consistency between
// image formats.
BigBuffer data;
};
struct IPCDataTransferImageContainer
{
BigBuffer data;
uint32_t width;
uint32_t height;
uint32_t stride;
SurfaceFormat format;
};
struct IPCDataTransferBlob
{
IPCBlob blob;
};
union IPCDataTransferData
{
IPCDataTransferString;
IPCDataTransferCString;
IPCDataTransferInputStream;
IPCDataTransferImageContainer;
IPCDataTransferBlob;
};
struct IPCDataTransferItem
{
nsCString flavor;
IPCDataTransferData data;
};
struct IPCDataTransfer
{
IPCDataTransferItem[] items;
};
struct ScreenDetails { struct ScreenDetails {
LayoutDeviceIntRect rect; LayoutDeviceIntRect rect;
DesktopIntRect rectDisplayPix; DesktopIntRect rectDisplayPix;

View File

@@ -1,88 +0,0 @@
/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* vim: set sw=4 ts=8 et tw=80 ft=cpp : */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
include "mozilla/GfxMessageUtils.h";
include "mozilla/dom/PermissionMessageUtils.h";
include IPCBlob;
include NeckoChannelParams;
using mozilla::gfx::SurfaceFormat from "mozilla/gfx/Types.h";
[RefCounted] using class nsIPrincipal from "nsIPrincipal.h";
[RefCounted] using class nsIReferrerInfo from "nsIReferrerInfo.h";
[MoveOnly] using class mozilla::ipc::BigBuffer from "mozilla/ipc/BigBuffer.h";
namespace mozilla {
namespace dom {
struct IPCTransferableDataString
{
BigBuffer data;
};
struct IPCTransferableDataCString
{
BigBuffer data;
};
struct IPCTransferableDataInputStream
{
// NOTE: Editor currently relies on these input streams being synchronous, so
// we can't safely serialize them using IPCStream (see bug 1778565). Instead,
// they're serialized as a `BigBuffer`, and converted to a nsStringInputStream
// on the receiving side. If we are able to use async streams reliably in the
// future, we could consider switching the code which adds `nsIInputStream`s
// to the transferable to use `BlobImpl` instead, for more consistency between
// image formats.
BigBuffer data;
};
struct IPCTransferableDataImageContainer
{
BigBuffer data;
uint32_t width;
uint32_t height;
uint32_t stride;
SurfaceFormat format;
};
struct IPCTransferableDataBlob
{
IPCBlob blob;
};
union IPCTransferableDataType
{
IPCTransferableDataString;
IPCTransferableDataCString;
IPCTransferableDataInputStream;
IPCTransferableDataImageContainer;
IPCTransferableDataBlob;
};
struct IPCTransferableDataItem
{
nsCString flavor;
IPCTransferableDataType data;
};
struct IPCTransferableData
{
IPCTransferableDataItem[] items;
};
struct IPCTransferable
{
IPCTransferableData data;
bool isPrivateData;
nullable nsIPrincipal requestingPrincipal;
CookieJarSettingsArgs? cookieJarSettings;
nsContentPolicyType contentPolicyType;
nullable nsIReferrerInfo referrerInfo;
};
} // namespace dom
} // namespace mozilla

View File

@@ -23,7 +23,6 @@ include NeckoChannelParams;
include WindowGlobalTypes; include WindowGlobalTypes;
include IPCBlob; include IPCBlob;
include IPCStream; include IPCStream;
include IPCTransferable;
include URIParams; include URIParams;
include PPrintingTypes; include PPrintingTypes;
include PTabContext; include PTabContext;
@@ -629,7 +628,7 @@ parent:
[Nested=inside_sync] sync DispatchKeyboardEvent(WidgetKeyboardEvent event); [Nested=inside_sync] sync DispatchKeyboardEvent(WidgetKeyboardEvent event);
[Nested=inside_sync] sync DispatchTouchEvent(WidgetTouchEvent event); [Nested=inside_sync] sync DispatchTouchEvent(WidgetTouchEvent event);
async InvokeDragSession(IPCTransferableData[] transfers, uint32_t action, async InvokeDragSession(IPCDataTransfer[] transfers, uint32_t action,
BigBuffer? visualData, BigBuffer? visualData,
uint32_t stride, SurfaceFormat format, uint32_t stride, SurfaceFormat format,
LayoutDeviceIntRect dragRect, LayoutDeviceIntRect dragRect,
@@ -865,8 +864,7 @@ child:
* Call PasteTransferable via a controller on the content process * Call PasteTransferable via a controller on the content process
* to handle the command content event, "pasteTransferable". * to handle the command content event, "pasteTransferable".
*/ */
// XXX Do we really need data other than IPCTransferableData? See bug 1833172. async PasteTransferable(IPCDataTransfer aDataTransfer,
async PasteTransferable(IPCTransferableData aTransferableData,
bool aIsPrivateData, bool aIsPrivateData,
nullable nsIPrincipal aRequestingPrincipal, nullable nsIPrincipal aRequestingPrincipal,
nsContentPolicyType aContentPolicyType); nsContentPolicyType aContentPolicyType);

View File

@@ -48,7 +48,6 @@ include DOMTypes;
include WindowGlobalTypes; include WindowGlobalTypes;
include IPCBlob; include IPCBlob;
include IPCStream; include IPCStream;
include IPCTransferable;
include PPrintingTypes; include PPrintingTypes;
include PTabContext; include PTabContext;
include ProtocolTypes; include ProtocolTypes;
@@ -463,8 +462,8 @@ struct IPCImage {
ImageIntSize size; ImageIntSize size;
}; };
union IPCTransferableDataOrError { union IPCDataTransferOrError {
IPCTransferableData; IPCDataTransfer;
nsresult; nsresult;
}; };
@@ -822,7 +821,7 @@ child:
async InvokeDragSession(MaybeDiscardedWindowContext aSourceWindowContext, async InvokeDragSession(MaybeDiscardedWindowContext aSourceWindowContext,
MaybeDiscardedWindowContext aSourceTopWindowContext, MaybeDiscardedWindowContext aSourceTopWindowContext,
IPCTransferableData[] transfers, uint32_t action); IPCDataTransfer[] transfers, uint32_t action);
async EndDragSession(bool aDoneDrag, bool aUserCancelled, async EndDragSession(bool aDoneDrag, bool aUserCancelled,
LayoutDeviceIntPoint aDragEndPoint, LayoutDeviceIntPoint aDragEndPoint,
@@ -1218,20 +1217,25 @@ parent:
bool fromChromeContext, ClonedMessageData stack); bool fromChromeContext, ClonedMessageData stack);
// Places the items within dataTransfer on the clipboard. // Places the items within dataTransfer on the clipboard.
async SetClipboard(IPCTransferable aTransferable, async SetClipboard(IPCDataTransfer aDataTransfer,
bool aIsPrivateData,
nullable nsIPrincipal aRequestingPrincipal,
CookieJarSettingsArgs? cookieJarSettings,
nsContentPolicyType aContentPolicyType,
nullable nsIReferrerInfo aReferrerInfo,
int32_t aWhichClipboard); int32_t aWhichClipboard);
// Given a list of supported types, returns the clipboard data for the // Given a list of supported types, returns the clipboard data for the
// first type that matches. // first type that matches.
sync GetClipboard(nsCString[] aTypes, int32_t aWhichClipboard) sync GetClipboard(nsCString[] aTypes, int32_t aWhichClipboard)
returns (IPCTransferableData transferableData); returns (IPCDataTransfer dataTransfer);
// Returns a list of formats supported by the clipboard // Returns a list of formats supported by the clipboard
sync GetExternalClipboardFormats(int32_t aWhichClipboard, bool aPlainTextOnly) returns (nsCString[] aTypes); sync GetExternalClipboardFormats(int32_t aWhichClipboard, bool aPlainTextOnly) returns (nsCString[] aTypes);
// Given a list of supported types, returns the clipboard data for the // Given a list of supported types, returns the clipboard data for the
// first type that matches. // first type that matches.
async GetClipboardAsync(nsCString[] aTypes, int32_t aWhichClipboard) returns (IPCTransferableDataOrError transferableData); async GetClipboardAsync(nsCString[] aTypes, int32_t aWhichClipboard) returns (IPCDataTransferOrError dataTransfer);
// Clears the clipboard. // Clears the clipboard.
async EmptyClipboard(int32_t aWhichClipboard); async EmptyClipboard(int32_t aWhichClipboard);

View File

@@ -168,7 +168,6 @@ PREPROCESSED_IPDL_SOURCES += [
IPDL_SOURCES += [ IPDL_SOURCES += [
"DOMTypes.ipdlh", "DOMTypes.ipdlh",
"IPCTransferable.ipdlh",
"MemoryReportTypes.ipdlh", "MemoryReportTypes.ipdlh",
"PColorPicker.ipdl", "PColorPicker.ipdl",
"PContentPermission.ipdlh", "PContentPermission.ipdlh",

View File

@@ -32,10 +32,20 @@ ClipboardWriteRequestChild::SetData(nsITransferable* aTransferable,
#endif #endif
mIsValid = false; mIsValid = false;
IPCTransferable ipcTransferable; IPCDataTransfer ipcDataTransfer;
nsContentUtils::TransferableToIPCTransferable(aTransferable, &ipcTransferable, nsContentUtils::TransferableToIPCTransferable(aTransferable, &ipcDataTransfer,
false, nullptr); false, nullptr);
SendSetData(std::move(ipcTransferable)); Maybe<net::CookieJarSettingsArgs> cookieJarSettingsArgs;
if (nsCOMPtr<nsICookieJarSettings> cookieJarSettings =
aTransferable->GetCookieJarSettings()) {
net::CookieJarSettingsArgs args;
net::CookieJarSettings::Cast(cookieJarSettings)->Serialize(args);
cookieJarSettingsArgs = Some(std::move(args));
}
SendSetData(std::move(ipcDataTransfer), aTransferable->GetIsPrivateData(),
aTransferable->GetRequestingPrincipal(), cookieJarSettingsArgs,
aTransferable->GetContentPolicyType(),
aTransferable->GetReferrerInfo());
return NS_OK; return NS_OK;
} }

View File

@@ -55,12 +55,16 @@ NS_IMETHODIMP ClipboardWriteRequestParent::OnComplete(nsresult aResult) {
} }
IPCResult ClipboardWriteRequestParent::RecvSetData( IPCResult ClipboardWriteRequestParent::RecvSetData(
const IPCTransferable& aTransferable) { const IPCDataTransfer& aDataTransfer, const bool& aIsPrivateData,
nsIPrincipal* aRequestingPrincipal,
Maybe<CookieJarSettingsArgs> aCookieJarSettingsArgs,
const nsContentPolicyType& aContentPolicyType,
nsIReferrerInfo* aReferrerInfo) {
if (!mManager->ValidatePrincipal( if (!mManager->ValidatePrincipal(
aTransferable.requestingPrincipal(), aRequestingPrincipal,
{ContentParent::ValidatePrincipalOptions::AllowNullPtr})) { {ContentParent::ValidatePrincipalOptions::AllowNullPtr})) {
ContentParent::LogAndAssertFailedPrincipalValidationInfo( ContentParent::LogAndAssertFailedPrincipalValidationInfo(
aTransferable.requestingPrincipal(), __func__); aRequestingPrincipal, __func__);
} }
if (!mAsyncSetClipboardData) { if (!mAsyncSetClipboardData) {
@@ -76,9 +80,16 @@ IPCResult ClipboardWriteRequestParent::RecvSetData(
} }
trans->Init(nullptr); trans->Init(nullptr);
trans->SetReferrerInfo(aReferrerInfo);
if (aCookieJarSettingsArgs.isSome()) {
nsCOMPtr<nsICookieJarSettings> cookieJarSettings;
net::CookieJarSettings::Deserialize(aCookieJarSettingsArgs.ref(),
getter_AddRefs(cookieJarSettings));
trans->SetCookieJarSettings(cookieJarSettings);
}
rv = nsContentUtils::IPCTransferableToTransferable( rv = nsContentUtils::IPCTransferableToTransferable(
aTransferable, true /* aAddDataFlavor */, trans, aDataTransfer, aIsPrivateData, aRequestingPrincipal, aContentPolicyType,
true /* aFilterUnknownFlavors */); true /* aAddDataFlavor */, trans, true /* aFilterUnknownFlavors */);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
mAsyncSetClipboardData->Abort(rv); mAsyncSetClipboardData->Abort(rv);
return IPC_OK(); return IPC_OK();

View File

@@ -29,7 +29,12 @@ class ClipboardWriteRequestParent final
nsresult Init(const int32_t& aClipboardType); nsresult Init(const int32_t& aClipboardType);
IPCResult RecvSetData(const IPCTransferable& aTransferable); IPCResult RecvSetData(const IPCDataTransfer& aDataTransfer,
const bool& aIsPrivateData,
nsIPrincipal* aRequestingPrincipal,
Maybe<CookieJarSettingsArgs> aCookieJarSettingsArgs,
const nsContentPolicyType& aContentPolicyType,
nsIReferrerInfo* aReferrerInfo);
IPCResult Recv__delete__(nsresult aReason); IPCResult Recv__delete__(nsresult aReason);
void ActorDestroy(ActorDestroyReason aReason) override final; void ActorDestroy(ActorDestroyReason aReason) override final;

View File

@@ -5,7 +5,6 @@
include protocol PContent; include protocol PContent;
include DOMTypes; include DOMTypes;
include IPCTransferable;
include NeckoChannelParams; include NeckoChannelParams;
using nsContentPolicyType from "nsIContentPolicy.h"; using nsContentPolicyType from "nsIContentPolicy.h";
@@ -16,7 +15,12 @@ protocol PClipboardWriteRequest {
manager PContent; manager PContent;
parent: parent:
async SetData(IPCTransferable aTransferable); async SetData(IPCDataTransfer aDataTransfer,
bool aIsPrivateData,
nullable nsIPrincipal aRequestingPrincipal,
CookieJarSettingsArgs? cookieJarSettings,
nsContentPolicyType aContentPolicyType,
nullable nsIReferrerInfo aReferrerInfo);
both: both:
async __delete__(nsresult aResult); async __delete__(nsresult aResult);

View File

@@ -35,10 +35,27 @@ nsClipboardProxy::SetData(nsITransferable* aTransferable,
#endif #endif
ContentChild* child = ContentChild::GetSingleton(); ContentChild* child = ContentChild::GetSingleton();
IPCTransferable ipcTransferable;
nsContentUtils::TransferableToIPCTransferable(aTransferable, &ipcTransferable, IPCDataTransfer ipcDataTransfer;
nsContentUtils::TransferableToIPCTransferable(aTransferable, &ipcDataTransfer,
false, nullptr); false, nullptr);
child->SendSetClipboard(std::move(ipcTransferable), aWhichClipboard);
Maybe<mozilla::net::CookieJarSettingsArgs> cookieJarSettingsArgs;
if (nsCOMPtr<nsICookieJarSettings> cookieJarSettings =
aTransferable->GetCookieJarSettings()) {
mozilla::net::CookieJarSettingsArgs args;
mozilla::net::CookieJarSettings::Cast(cookieJarSettings)->Serialize(args);
cookieJarSettingsArgs = Some(args);
}
bool isPrivateData = aTransferable->GetIsPrivateData();
nsCOMPtr<nsIPrincipal> requestingPrincipal =
aTransferable->GetRequestingPrincipal();
nsContentPolicyType contentPolicyType = aTransferable->GetContentPolicyType();
nsCOMPtr<nsIReferrerInfo> referrerInfo = aTransferable->GetReferrerInfo();
child->SendSetClipboard(std::move(ipcDataTransfer), isPrivateData,
requestingPrincipal, cookieJarSettingsArgs,
contentPolicyType, referrerInfo, aWhichClipboard);
return NS_OK; return NS_OK;
} }
@@ -59,11 +76,11 @@ nsClipboardProxy::GetData(nsITransferable* aTransferable,
nsTArray<nsCString> types; nsTArray<nsCString> types;
aTransferable->FlavorsTransferableCanImport(types); aTransferable->FlavorsTransferableCanImport(types);
IPCTransferableData transferable; IPCDataTransfer dataTransfer;
ContentChild::GetSingleton()->SendGetClipboard(types, aWhichClipboard, ContentChild::GetSingleton()->SendGetClipboard(types, aWhichClipboard,
&transferable); &dataTransfer);
return nsContentUtils::IPCTransferableDataToTransferable( return nsContentUtils::IPCTransferableToTransferable(
transferable, false /* aAddDataFlavor */, aTransferable, dataTransfer, false /* aAddDataFlavor */, aTransferable,
false /* aFilterUnknownFlavors */); false /* aFilterUnknownFlavors */);
} }
@@ -152,17 +169,16 @@ RefPtr<GenericPromise> nsClipboardProxy::AsyncGetData(
->Then( ->Then(
GetMainThreadSerialEventTarget(), __func__, GetMainThreadSerialEventTarget(), __func__,
/* resolve */ /* resolve */
[promise, transferable]( [promise,
const IPCTransferableDataOrError& ipcTransferableDataOrError) { transferable](const IPCDataTransferOrError& ipcDataTransferOrError) {
if (ipcTransferableDataOrError.type() == if (ipcDataTransferOrError.type() ==
IPCTransferableDataOrError::Tnsresult) { IPCDataTransferOrError::Tnsresult) {
promise->Reject(ipcTransferableDataOrError.get_nsresult(), promise->Reject(ipcDataTransferOrError.get_nsresult(), __func__);
__func__);
return; return;
} }
nsresult rv = nsContentUtils::IPCTransferableDataToTransferable( nsresult rv = nsContentUtils::IPCTransferableToTransferable(
ipcTransferableDataOrError.get_IPCTransferableData(), ipcDataTransferOrError.get_IPCDataTransfer(),
false /* aAddDataFlavor */, transferable, false /* aAddDataFlavor */, transferable,
false /* aFilterUnknownFlavors */); false /* aFilterUnknownFlavors */);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {

View File

@@ -34,9 +34,9 @@ nsresult nsDragServiceProxy::InvokeDragSessionImpl(
NS_ENSURE_STATE(mSourceDocument->GetDocShell()); NS_ENSURE_STATE(mSourceDocument->GetDocShell());
BrowserChild* child = BrowserChild::GetFrom(mSourceDocument->GetDocShell()); BrowserChild* child = BrowserChild::GetFrom(mSourceDocument->GetDocShell());
NS_ENSURE_STATE(child); NS_ENSURE_STATE(child);
nsTArray<mozilla::dom::IPCTransferableData> transferables; nsTArray<mozilla::dom::IPCDataTransfer> dataTransfers;
nsContentUtils::TransferablesToIPCTransferableDatas( nsContentUtils::TransferablesToIPCTransferables(
aArrayTransferables, transferables, false, nullptr); aArrayTransferables, dataTransfers, false, nullptr);
nsCOMPtr<nsIPrincipal> principal; nsCOMPtr<nsIPrincipal> principal;
if (mSourceNode) { if (mSourceNode) {
@@ -78,7 +78,7 @@ nsresult nsDragServiceProxy::InvokeDragSessionImpl(
} }
mozilla::Unused << child->SendInvokeDragSession( mozilla::Unused << child->SendInvokeDragSession(
std::move(transferables), aActionType, std::move(surfaceData), std::move(dataTransfers), aActionType, std::move(surfaceData),
stride, dataSurface->GetFormat(), dragRect, principal, csp, csArgs, stride, dataSurface->GetFormat(), dragRect, principal, csp, csArgs,
mSourceWindowContext, mSourceTopWindowContext); mSourceWindowContext, mSourceTopWindowContext);
StartDragSession(); StartDragSession();
@@ -88,7 +88,7 @@ nsresult nsDragServiceProxy::InvokeDragSessionImpl(
} }
mozilla::Unused << child->SendInvokeDragSession( mozilla::Unused << child->SendInvokeDragSession(
std::move(transferables), aActionType, Nothing(), 0, std::move(dataTransfers), aActionType, Nothing(), 0,
static_cast<SurfaceFormat>(0), dragRect, principal, csp, csArgs, static_cast<SurfaceFormat>(0), dragRect, principal, csp, csArgs,
mSourceWindowContext, mSourceTopWindowContext); mSourceWindowContext, mSourceTopWindowContext);
StartDragSession(); StartDragSession();