Bug 1755481: rename `nsIClipboard::getData` to `nsIClipboard::getSomeData` and document it. r=mccr8

Before, it was confusing. One could have assumed that the method gets
the data for all flavors.

Differential Revision: https://phabricator.services.mozilla.com/D138776
This commit is contained in:
Mirko Brodesser 2022-02-16 09:03:00 +00:00
Родитель cd4ff2c4e5
Коммит 8aa76ff1d7
12 изменённых файлов: 33 добавлений и 28 удалений

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

@ -162,7 +162,8 @@ void DataTransferItem::FillInExternalData() {
return;
}
nsresult rv = clipboard->GetData(trans, mDataTransfer->ClipboardType());
nsresult rv =
clipboard->GetSomeData(trans, mDataTransfer->ClipboardType());
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}

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

@ -3319,7 +3319,7 @@ mozilla::ipc::IPCResult ContentParent::RecvGetClipboard(
trans->AddDataFlavor(aTypes[t].get());
}
clipboard->GetData(trans, aWhichClipboard);
clipboard->GetSomeData(trans, aWhichClipboard);
nsContentUtils::TransferableToIPCTransferable(trans, aDataTransfer, true,
nullptr, this);
return IPC_OK();

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

@ -2093,9 +2093,9 @@ nsresult HTMLEditor::PasteInternal(int32_t aClipboardType) {
return NS_ERROR_FAILURE;
}
// Get the Data from the clipboard
rv = clipboard->GetData(transferable, aClipboardType);
rv = clipboard->GetSomeData(transferable, aClipboardType);
if (NS_FAILED(rv)) {
NS_WARNING("nsIClipboard::GetData() failed");
NS_WARNING("nsIClipboard::GetSomeData() failed");
return rv;
}
@ -2126,9 +2126,9 @@ nsresult HTMLEditor::PasteInternal(int32_t aClipboardType) {
NS_WARNING_ASSERTION(
NS_SUCCEEDED(rvIgnored),
"nsITransferable::AddDataFlavor(kHTMLContext) failed, but ignored");
rvIgnored = clipboard->GetData(contextTransferable, aClipboardType);
rvIgnored = clipboard->GetSomeData(contextTransferable, aClipboardType);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rvIgnored),
"nsIClipboard::GetData() failed, but ignored");
"nsIClipboard::GetSomeData() failed, but ignored");
nsCOMPtr<nsISupports> contextDataObj;
rv = contextTransferable->GetTransferData(kHTMLContext,
getter_AddRefs(contextDataObj));
@ -2156,9 +2156,9 @@ nsresult HTMLEditor::PasteInternal(int32_t aClipboardType) {
NS_WARNING_ASSERTION(
NS_SUCCEEDED(rvIgnored),
"nsITransferable::AddDataFlavor(kHTMLInfo) failed, but ignored");
clipboard->GetData(infoTransferable, aClipboardType);
clipboard->GetSomeData(infoTransferable, aClipboardType);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rvIgnored),
"nsIClipboard::GetData() failed, but ignored");
"nsIClipboard::GetSomeData() failed, but ignored");
nsCOMPtr<nsISupports> infoDataObj;
rv = infoTransferable->GetTransferData(kHTMLInfo,
getter_AddRefs(infoDataObj));
@ -2288,9 +2288,9 @@ nsresult HTMLEditor::PasteNoFormattingAsAction(int32_t aSelectionType,
}
// Get the Data from the clipboard
rv = clipboard->GetData(transferable, aSelectionType);
rv = clipboard->GetSomeData(transferable, aSelectionType);
if (NS_FAILED(rv)) {
NS_WARNING("nsIClipboard::GetData() failed");
NS_WARNING("nsIClipboard::GetSomeData() failed");
return rv;
}
@ -2543,9 +2543,9 @@ nsresult HTMLEditor::PasteAsPlaintextQuotation(int32_t aSelectionType) {
"nsITransferable::AddDataFlavor(kUnicodeMime) failed, but ignored");
// Get the Data from the clipboard
rvIgnored = clipboard->GetData(transferable, aSelectionType);
rvIgnored = clipboard->GetSomeData(transferable, aSelectionType);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rvIgnored),
"nsIClipboard::GetData() failed, but ignored");
"nsIClipboard::GetSomeData() failed, but ignored");
// Now we ask the transferable for the data
// it still owns the data, we just have a pointer to it.

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

@ -517,7 +517,7 @@ nsresult TextEditor::PasteAsQuotationAsAction(int32_t aClipboardType,
}
// Get the Data from the clipboard
clipboard->GetData(trans, aClipboardType);
clipboard->GetSomeData(trans, aClipboardType);
// Now we ask the transferable for the data
// it still owns the data, we just have a pointer to it.

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

@ -206,9 +206,9 @@ nsresult TextEditor::PasteAsAction(int32_t aClipboardType,
return NS_OK; // XXX Why?
}
// Get the Data from the clipboard.
rv = clipboard->GetData(transferable, aClipboardType);
rv = clipboard->GetSomeData(transferable, aClipboardType);
if (NS_FAILED(rv)) {
NS_WARNING("nsIClipboard::GetData() failed, but ignored");
NS_WARNING("nsIClipboard::GetSomeData() failed, but ignored");
return NS_OK; // XXX Why?
}
// XXX Why don't we check this first?

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

@ -78,7 +78,8 @@ nsClipboard::SetData(nsITransferable* aTransferable, nsIClipboardOwner* anOwner,
}
NS_IMETHODIMP
nsClipboard::GetData(nsITransferable* aTransferable, int32_t aWhichClipboard) {
nsClipboard::GetSomeData(nsITransferable* aTransferable,
int32_t aWhichClipboard) {
if (aWhichClipboard != kGlobalClipboard) return NS_ERROR_NOT_IMPLEMENTED;
if (!jni::IsAvailable()) {

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

@ -743,7 +743,7 @@ nsClipboard::SetData(nsITransferable* aTransferable, nsIClipboardOwner* anOwner,
*
*/
NS_IMETHODIMP
nsClipboard::GetData(nsITransferable* aTransferable, int32_t aWhichClipboard) {
nsClipboard::GetSomeData(nsITransferable* aTransferable, int32_t aWhichClipboard) {
NS_ASSERTION(aTransferable, "clipboard given a null transferable");
bool selectClipPresent;

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

@ -420,8 +420,9 @@ bool nsClipboard::FilterImportedFlavors(int32_t aWhichClipboard,
}
NS_IMETHODIMP
nsClipboard::GetData(nsITransferable* aTransferable, int32_t aWhichClipboard) {
LOGCLIP("nsClipboard::GetData (%s)\n",
nsClipboard::GetSomeData(nsITransferable* aTransferable,
int32_t aWhichClipboard) {
LOGCLIP("nsClipboard::GetSomeData (%s)\n",
aWhichClipboard == kSelectionClipboard ? "primary" : "clipboard");
// TODO: Ensure we don't re-enter here.

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

@ -46,8 +46,8 @@ HeadlessClipboard::SetData(nsITransferable* aTransferable,
}
NS_IMETHODIMP
HeadlessClipboard::GetData(nsITransferable* aTransferable,
int32_t aWhichClipboard) {
HeadlessClipboard::GetSomeData(nsITransferable* aTransferable,
int32_t aWhichClipboard) {
if (aWhichClipboard != kGlobalClipboard) {
return NS_ERROR_NOT_IMPLEMENTED;
}

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

@ -77,8 +77,8 @@ NS_IMETHODIMP nsBaseClipboard::SetData(nsITransferable* aTransferable,
* Gets the transferable object
*
*/
NS_IMETHODIMP nsBaseClipboard::GetData(nsITransferable* aTransferable,
int32_t aWhichClipboard) {
NS_IMETHODIMP nsBaseClipboard::GetSomeData(nsITransferable* aTransferable,
int32_t aWhichClipboard) {
NS_ASSERTION(aTransferable, "clipboard given a null transferable");
MOZ_LOG(sBaseClipboardLog, LogLevel::Debug, ("%s", __FUNCTION__));

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

@ -42,8 +42,8 @@ nsClipboardProxy::SetData(nsITransferable* aTransferable,
}
NS_IMETHODIMP
nsClipboardProxy::GetData(nsITransferable* aTransferable,
int32_t aWhichClipboard) {
nsClipboardProxy::GetSomeData(nsITransferable* aTransferable,
int32_t aWhichClipboard) {
nsTArray<nsCString> types;
aTransferable->FlavorsTransferableCanImport(types);

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

@ -33,14 +33,16 @@ interface nsIClipboard : nsISupports
in long aWhichClipboard ) ;
/**
* Given a transferable, get the clipboard data.
* Filters the flavors aTransferable can import (see
* `nsITransferable::flavorsTransferableCanImport`) and gets the data for the
* first flavor. That data is set for aTransferable.
*
* @param aTransferable The transferable
* @param aWhichClipboard Specifies the clipboard to which this operation applies.
* @result NS_Ok if no errors
* @result NS_OK if no errors
*/
void getData ( in nsITransferable aTransferable, in long aWhichClipboard ) ;
void getSomeData ( in nsITransferable aTransferable, in long aWhichClipboard ) ;
/**
* This empties the clipboard and notifies the clipboard owner.