Bug 1649121: part 88) Declare some methods around `DataTransfer` `const`. r=masayuki

Helps reasoning about them.

Differential Revision: https://phabricator.services.mozilla.com/D90528
This commit is contained in:
Mirko Brodesser 2020-09-17 08:52:42 +00:00
Родитель 88a65a9f0d
Коммит 60e705c860
4 изменённых файлов: 13 добавлений и 11 удалений

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

@ -336,7 +336,8 @@ bool DataTransfer::HasType(const nsAString& aType) const {
bool DataTransfer::HasFile() const { return mItems->HasFile(); } bool DataTransfer::HasFile() const { return mItems->HasFile(); }
void DataTransfer::GetData(const nsAString& aFormat, nsAString& aData, void DataTransfer::GetData(const nsAString& aFormat, nsAString& aData,
nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) { nsIPrincipal& aSubjectPrincipal,
ErrorResult& aRv) const {
// return an empty string if data for the format was not found // return an empty string if data for the format was not found
aData.Truncate(); aData.Truncate();
@ -481,7 +482,7 @@ already_AddRefed<DOMStringList> DataTransfer::MozTypesAt(
nsresult DataTransfer::GetDataAtNoSecurityCheck(const nsAString& aFormat, nsresult DataTransfer::GetDataAtNoSecurityCheck(const nsAString& aFormat,
uint32_t aIndex, uint32_t aIndex,
nsIVariant** aData) { nsIVariant** aData) const {
return GetDataAtInternal(aFormat, aIndex, return GetDataAtInternal(aFormat, aIndex,
nsContentUtils::GetSystemPrincipal(), aData); nsContentUtils::GetSystemPrincipal(), aData);
} }
@ -489,7 +490,7 @@ nsresult DataTransfer::GetDataAtNoSecurityCheck(const nsAString& aFormat,
nsresult DataTransfer::GetDataAtInternal(const nsAString& aFormat, nsresult DataTransfer::GetDataAtInternal(const nsAString& aFormat,
uint32_t aIndex, uint32_t aIndex,
nsIPrincipal* aSubjectPrincipal, nsIPrincipal* aSubjectPrincipal,
nsIVariant** aData) { nsIVariant** aData) const {
*aData = nullptr; *aData = nullptr;
if (aFormat.IsEmpty()) { if (aFormat.IsEmpty()) {

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

@ -202,7 +202,7 @@ class DataTransfer final : public nsISupports, public nsWrapperCache {
bool HasFile() const; bool HasFile() const;
void GetData(const nsAString& aFormat, nsAString& aData, void GetData(const nsAString& aFormat, nsAString& aData,
nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv); nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv) const;
void SetData(const nsAString& aFormat, const nsAString& aData, void SetData(const nsAString& aFormat, const nsAString& aData,
nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv); nsIPrincipal& aSubjectPrincipal, ErrorResult& aRv);
@ -281,7 +281,7 @@ class DataTransfer final : public nsISupports, public nsWrapperCache {
mozilla::dom::Element* GetDragTarget() const { return mDragTarget; } mozilla::dom::Element* GetDragTarget() const { return mDragTarget; }
nsresult GetDataAtNoSecurityCheck(const nsAString& aFormat, uint32_t aIndex, nsresult GetDataAtNoSecurityCheck(const nsAString& aFormat, uint32_t aIndex,
nsIVariant** aData); nsIVariant** aData) const;
DataTransferItemList* Items() const { return mItems; } DataTransferItemList* Items() const { return mItems; }
@ -421,7 +421,7 @@ class DataTransfer final : public nsISupports, public nsWrapperCache {
FileList* GetFilesInternal(ErrorResult& aRv, nsIPrincipal* aSubjectPrincipal); FileList* GetFilesInternal(ErrorResult& aRv, nsIPrincipal* aSubjectPrincipal);
nsresult GetDataAtInternal(const nsAString& aFormat, uint32_t aIndex, nsresult GetDataAtInternal(const nsAString& aFormat, uint32_t aIndex,
nsIPrincipal* aSubjectPrincipal, nsIPrincipal* aSubjectPrincipal,
nsIVariant** aData); nsIVariant** aData) const;
nsresult SetDataAtInternal(const nsAString& aFormat, nsIVariant* aData, nsresult SetDataAtInternal(const nsAString& aFormat, nsIVariant* aData,
uint32_t aIndex, nsIPrincipal* aSubjectPrincipal); uint32_t aIndex, nsIPrincipal* aSubjectPrincipal);

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

@ -4172,9 +4172,10 @@ class HTMLEditor final : public TextEditor,
* InsertFromDataTransfer() is called only when user drops data into * InsertFromDataTransfer() is called only when user drops data into
* this editor. Don't use this method for other purposes. * this editor. Don't use this method for other purposes.
*/ */
MOZ_CAN_RUN_SCRIPT nsresult InsertFromDataTransfer( MOZ_CAN_RUN_SCRIPT nsresult
dom::DataTransfer* aDataTransfer, int32_t aIndex, Document* aSourceDoc, InsertFromDataTransfer(const dom::DataTransfer* aDataTransfer, int32_t aIndex,
const EditorDOMPoint& aDroppedAt, bool aDoDeleteSelection); Document* aSourceDoc, const EditorDOMPoint& aDroppedAt,
bool aDoDeleteSelection);
bool HavePrivateHTMLFlavor(nsIClipboard* clipboard); bool HavePrivateHTMLFlavor(nsIClipboard* clipboard);

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

@ -1771,7 +1771,7 @@ nsresult HTMLEditor::InsertFromTransferable(nsITransferable* aTransferable,
return NS_OK; return NS_OK;
} }
static void GetStringFromDataTransfer(DataTransfer* aDataTransfer, static void GetStringFromDataTransfer(const DataTransfer* aDataTransfer,
const nsAString& aType, int32_t aIndex, const nsAString& aType, int32_t aIndex,
nsString& aOutputString) { nsString& aOutputString) {
nsCOMPtr<nsIVariant> variant; nsCOMPtr<nsIVariant> variant;
@ -1788,7 +1788,7 @@ static void GetStringFromDataTransfer(DataTransfer* aDataTransfer,
nsContentUtils::PlatformToDOMLineBreaks(aOutputString); nsContentUtils::PlatformToDOMLineBreaks(aOutputString);
} }
nsresult HTMLEditor::InsertFromDataTransfer(DataTransfer* aDataTransfer, nsresult HTMLEditor::InsertFromDataTransfer(const DataTransfer* aDataTransfer,
int32_t aIndex, int32_t aIndex,
Document* aSourceDoc, Document* aSourceDoc,
const EditorDOMPoint& aDroppedAt, const EditorDOMPoint& aDroppedAt,