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 4ab7fd28a6
commit bc9ede8f91
24 changed files with 309 additions and 347 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -607,7 +607,7 @@ class BrowserParent final : public PBrowserParent,
bool SendInsertText(const nsString& aStringToInsert);
bool SendPasteTransferable(IPCTransferableData&& aTransferableData,
bool SendPasteTransferable(IPCDataTransfer&& aDataTransfer,
const bool& aIsPrivateData,
nsIPrincipal* aRequestingPrincipal,
const nsContentPolicyType& aContentPolicyType);
@ -667,7 +667,7 @@ class BrowserParent final : public PBrowserParent,
void LayerTreeUpdate(const LayersObserverEpoch& aEpoch, bool aActive);
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,
const gfx::SurfaceFormat& aFormat, const LayoutDeviceIntRect& aDragRect,
nsIPrincipal* aPrincipal, nsIContentSecurityPolicy* aCsp,
@ -675,7 +675,7 @@ class BrowserParent final : public PBrowserParent,
const MaybeDiscarded<WindowContext>& aSourceWindowContext,
const MaybeDiscarded<WindowContext>& aSourceTopWindowContext);
void AddInitialDnDDataTo(IPCTransferableData* aTransferableData,
void AddInitialDnDDataTo(DataTransfer* aDataTransfer,
nsIPrincipal** aPrincipal);
bool TakeDragVisualization(RefPtr<mozilla::gfx::SourceSurface>& aSurface,

View File

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

View File

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

View File

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

View File

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

View File

@ -48,7 +48,6 @@ include DOMTypes;
include WindowGlobalTypes;
include IPCBlob;
include IPCStream;
include IPCTransferable;
include PPrintingTypes;
include PTabContext;
include ProtocolTypes;
@ -463,8 +462,8 @@ struct IPCImage {
ImageIntSize size;
};
union IPCTransferableDataOrError {
IPCTransferableData;
union IPCDataTransferOrError {
IPCDataTransfer;
nsresult;
};
@ -822,7 +821,7 @@ child:
async InvokeDragSession(MaybeDiscardedWindowContext aSourceWindowContext,
MaybeDiscardedWindowContext aSourceTopWindowContext,
IPCTransferableData[] transfers, uint32_t action);
IPCDataTransfer[] transfers, uint32_t action);
async EndDragSession(bool aDoneDrag, bool aUserCancelled,
LayoutDeviceIntPoint aDragEndPoint,
@ -1218,20 +1217,25 @@ parent:
bool fromChromeContext, ClonedMessageData stack);
// 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);
// Given a list of supported types, returns the clipboard data for the
// first type that matches.
sync GetClipboard(nsCString[] aTypes, int32_t aWhichClipboard)
returns (IPCTransferableData transferableData);
returns (IPCDataTransfer dataTransfer);
// Returns a list of formats supported by the clipboard
sync GetExternalClipboardFormats(int32_t aWhichClipboard, bool aPlainTextOnly) returns (nsCString[] aTypes);
// Given a list of supported types, returns the clipboard data for the
// 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.
async EmptyClipboard(int32_t aWhichClipboard);

View File

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

View File

@ -32,10 +32,20 @@ ClipboardWriteRequestChild::SetData(nsITransferable* aTransferable,
#endif
mIsValid = false;
IPCTransferable ipcTransferable;
nsContentUtils::TransferableToIPCTransferable(aTransferable, &ipcTransferable,
IPCDataTransfer ipcDataTransfer;
nsContentUtils::TransferableToIPCTransferable(aTransferable, &ipcDataTransfer,
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;
}

View File

@ -55,12 +55,16 @@ NS_IMETHODIMP ClipboardWriteRequestParent::OnComplete(nsresult aResult) {
}
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(
aTransferable.requestingPrincipal(),
aRequestingPrincipal,
{ContentParent::ValidatePrincipalOptions::AllowNullPtr})) {
ContentParent::LogAndAssertFailedPrincipalValidationInfo(
aTransferable.requestingPrincipal(), __func__);
aRequestingPrincipal, __func__);
}
if (!mAsyncSetClipboardData) {
@ -76,9 +80,16 @@ IPCResult ClipboardWriteRequestParent::RecvSetData(
}
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(
aTransferable, true /* aAddDataFlavor */, trans,
true /* aFilterUnknownFlavors */);
aDataTransfer, aIsPrivateData, aRequestingPrincipal, aContentPolicyType,
true /* aAddDataFlavor */, trans, true /* aFilterUnknownFlavors */);
if (NS_FAILED(rv)) {
mAsyncSetClipboardData->Abort(rv);
return IPC_OK();

View File

@ -29,7 +29,12 @@ class ClipboardWriteRequestParent final
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);
void ActorDestroy(ActorDestroyReason aReason) override final;

View File

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

View File

@ -35,10 +35,27 @@ nsClipboardProxy::SetData(nsITransferable* aTransferable,
#endif
ContentChild* child = ContentChild::GetSingleton();
IPCTransferable ipcTransferable;
nsContentUtils::TransferableToIPCTransferable(aTransferable, &ipcTransferable,
IPCDataTransfer ipcDataTransfer;
nsContentUtils::TransferableToIPCTransferable(aTransferable, &ipcDataTransfer,
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;
}
@ -59,11 +76,11 @@ nsClipboardProxy::GetData(nsITransferable* aTransferable,
nsTArray<nsCString> types;
aTransferable->FlavorsTransferableCanImport(types);
IPCTransferableData transferable;
IPCDataTransfer dataTransfer;
ContentChild::GetSingleton()->SendGetClipboard(types, aWhichClipboard,
&transferable);
return nsContentUtils::IPCTransferableDataToTransferable(
transferable, false /* aAddDataFlavor */, aTransferable,
&dataTransfer);
return nsContentUtils::IPCTransferableToTransferable(
dataTransfer, false /* aAddDataFlavor */, aTransferable,
false /* aFilterUnknownFlavors */);
}
@ -152,17 +169,16 @@ RefPtr<GenericPromise> nsClipboardProxy::AsyncGetData(
->Then(
GetMainThreadSerialEventTarget(), __func__,
/* resolve */
[promise, transferable](
const IPCTransferableDataOrError& ipcTransferableDataOrError) {
if (ipcTransferableDataOrError.type() ==
IPCTransferableDataOrError::Tnsresult) {
promise->Reject(ipcTransferableDataOrError.get_nsresult(),
__func__);
[promise,
transferable](const IPCDataTransferOrError& ipcDataTransferOrError) {
if (ipcDataTransferOrError.type() ==
IPCDataTransferOrError::Tnsresult) {
promise->Reject(ipcDataTransferOrError.get_nsresult(), __func__);
return;
}
nsresult rv = nsContentUtils::IPCTransferableDataToTransferable(
ipcTransferableDataOrError.get_IPCTransferableData(),
nsresult rv = nsContentUtils::IPCTransferableToTransferable(
ipcDataTransferOrError.get_IPCDataTransfer(),
false /* aAddDataFlavor */, transferable,
false /* aFilterUnknownFlavors */);
if (NS_FAILED(rv)) {

View File

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