diff --git a/dom/base/nsCopySupport.cpp b/dom/base/nsCopySupport.cpp index b33bc4e9cdbf..b791469747ee 100644 --- a/dom/base/nsCopySupport.cpp +++ b/dom/base/nsCopySupport.cpp @@ -632,7 +632,7 @@ nsCopySupport::FireClipboardEvent(EventMessage aEventMessage, } NS_ASSERTION(aEventMessage == eCut || aEventMessage == eCopy || - aEventMessage == NS_PASTE, + aEventMessage == ePaste, "Invalid clipboard event type"); nsCOMPtr presShell = aPresShell; @@ -688,7 +688,7 @@ nsCopySupport::FireClipboardEvent(EventMessage aEventMessage, nsRefPtr clipboardData; if (chromeShell || Preferences::GetBool("dom.event.clipboardevents.enabled", true)) { clipboardData = - new DataTransfer(piWindow, aEventMessage, aEventMessage == NS_PASTE, + new DataTransfer(piWindow, aEventMessage, aEventMessage == ePaste, aClipboardType); nsEventStatus status = nsEventStatus_eIgnore; @@ -703,7 +703,7 @@ nsCopySupport::FireClipboardEvent(EventMessage aEventMessage, // No need to do anything special during a paste. Either an event listener // took care of it and cancelled the event, or the caller will handle it. // Return true to indicate that the event wasn't cancelled. - if (aEventMessage == NS_PASTE) { + if (aEventMessage == ePaste) { // Clear and mark the clipboardData as readonly. This prevents someone // from reading the clipboard contents after the paste event has fired. if (clipboardData) { diff --git a/dom/base/nsCopySupport.h b/dom/base/nsCopySupport.h index 3be3c71c2383..ea0b85f224ed 100644 --- a/dom/base/nsCopySupport.h +++ b/dom/base/nsCopySupport.h @@ -65,7 +65,7 @@ class nsCopySupport /** * Fires a cut, copy or paste event, on the given presshell, depending * on the value of aEventMessage, which should be either eCut, eCopy or - * NS_PASTE, and perform the default copy action if the event was not + * ePaste, and perform the default copy action if the event was not * cancelled. * * If aSelection is specified, then this selection is used as the target diff --git a/dom/events/ClipboardEvent.cpp b/dom/events/ClipboardEvent.cpp index e0cb21feae80..2428600f2d89 100644 --- a/dom/events/ClipboardEvent.cpp +++ b/dom/events/ClipboardEvent.cpp @@ -109,7 +109,7 @@ ClipboardEvent::GetClipboardData() } else { event->clipboardData = new DataTransfer(ToSupports(this), event->mMessage, - event->mMessage == NS_PASTE, + event->mMessage == ePaste, nsIClipboard::kGlobalClipboard); } } diff --git a/dom/events/DataTransfer.cpp b/dom/events/DataTransfer.cpp index f45ff2f5666d..74849bec4252 100644 --- a/dom/events/DataTransfer.cpp +++ b/dom/events/DataTransfer.cpp @@ -92,7 +92,7 @@ DataTransfer::DataTransfer(nsISupports* aParent, EventMessage aEventMessage, aEventMessage == eLegacyDragGesture) { mReadOnly = false; } else if (mIsExternal) { - if (aEventMessage == NS_PASTE) { + if (aEventMessage == ePaste) { CacheExternalClipboardFormats(); } else if (aEventMessage >= eDragDropEventFirst && aEventMessage <= eDragDropEventLast) { @@ -271,7 +271,7 @@ DataTransfer::GetFiles(ErrorResult& aRv) { if (mEventMessage != eDrop && mEventMessage != eLegacyDragDrop && - mEventMessage != NS_PASTE) { + mEventMessage != ePaste) { return nullptr; } @@ -544,7 +544,7 @@ DataTransfer::MozTypesAt(uint32_t aIndex, ErrorResult& aRv) // Only the first item is valid for clipboard events if (aIndex > 0 && (mEventMessage == eCut || mEventMessage == eCopy || - mEventMessage == NS_PASTE)) { + mEventMessage == ePaste)) { aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); return nullptr; } @@ -585,7 +585,7 @@ DataTransfer::MozGetDataAt(const nsAString& aFormat, uint32_t aIndex, // Only the first item is valid for clipboard events if (aIndex > 0 && (mEventMessage == eCut || mEventMessage == eCopy || - mEventMessage == NS_PASTE)) { + mEventMessage == ePaste)) { return NS_ERROR_DOM_INDEX_SIZE_ERR; } @@ -604,7 +604,7 @@ DataTransfer::MozGetDataAt(const nsAString& aFormat, uint32_t aIndex, nsIPrincipal* principal = nullptr; if (mIsCrossDomainSubFrameDrop || (mEventMessage != eDrop && mEventMessage != eLegacyDragDrop && - mEventMessage != NS_PASTE && + mEventMessage != ePaste && !nsContentUtils::IsCallerChrome())) { principal = nsContentUtils::SubjectPrincipal(); } @@ -697,7 +697,7 @@ DataTransfer::MozSetDataAt(const nsAString& aFormat, nsIVariant* aData, // Only the first item is valid for clipboard events if (aIndex > 0 && (mEventMessage == eCut || mEventMessage == eCopy || - mEventMessage == NS_PASTE)) { + mEventMessage == ePaste)) { return NS_ERROR_DOM_INDEX_SIZE_ERR; } @@ -743,7 +743,7 @@ DataTransfer::MozClearDataAt(const nsAString& aFormat, uint32_t aIndex, // Only the first item is valid for clipboard events if (aIndex > 0 && (mEventMessage == eCut || mEventMessage == eCopy || - mEventMessage == NS_PASTE)) { + mEventMessage == ePaste)) { aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR); return; } @@ -759,7 +759,7 @@ DataTransfer::MozClearDataAtHelper(const nsAString& aFormat, uint32_t aIndex, MOZ_ASSERT(aIndex < mItems.Length()); MOZ_ASSERT(aIndex == 0 || (mEventMessage != eCut && mEventMessage != eCopy && - mEventMessage != NS_PASTE)); + mEventMessage != ePaste)); nsAutoString format; GetRealFormat(aFormat, format); @@ -1258,7 +1258,7 @@ DataTransfer::CacheExternalDragFormats() void DataTransfer::CacheExternalClipboardFormats() { - NS_ASSERTION(mEventMessage == NS_PASTE, + NS_ASSERTION(mEventMessage == ePaste, "caching clipboard data for invalid event"); // Called during the constructor for paste events to cache the formats @@ -1318,7 +1318,7 @@ DataTransfer::FillInExternalData(TransferItem& aItem, uint32_t aIndex) trans->Init(nullptr); trans->AddDataFlavor(format); - if (mEventMessage == NS_PASTE) { + if (mEventMessage == ePaste) { MOZ_ASSERT(aIndex == 0, "index in clipboard must be 0"); nsCOMPtr clipboard = do_GetService("@mozilla.org/widget/clipboard;1"); diff --git a/dom/events/EventNameList.h b/dom/events/EventNameList.h index 0e9d86109468..cdd39fd8d136 100644 --- a/dom/events/EventNameList.h +++ b/dom/events/EventNameList.h @@ -430,7 +430,7 @@ EVENT(cut, EventNameType_HTMLXUL, eClipboardEventClass) EVENT(paste, - NS_PASTE, + ePaste, EventNameType_HTMLXUL, eClipboardEventClass) // Gecko-specific extensions that apply to elements diff --git a/editor/libeditor/nsHTMLDataTransfer.cpp b/editor/libeditor/nsHTMLDataTransfer.cpp index 9a8be0c21d1b..930514ee2e41 100644 --- a/editor/libeditor/nsHTMLDataTransfer.cpp +++ b/editor/libeditor/nsHTMLDataTransfer.cpp @@ -1323,8 +1323,9 @@ bool nsHTMLEditor::HavePrivateHTMLFlavor(nsIClipboard *aClipboard) NS_IMETHODIMP nsHTMLEditor::Paste(int32_t aSelectionType) { - if (!FireClipboardEvent(NS_PASTE, aSelectionType)) + if (!FireClipboardEvent(ePaste, aSelectionType)) { return NS_OK; + } // Get Clipboard Service nsresult rv; @@ -1406,8 +1407,9 @@ NS_IMETHODIMP nsHTMLEditor::PasteTransferable(nsITransferable *aTransferable) { // Use an invalid value for the clipboard type as data comes from aTransferable // and we don't currently implement a way to put that in the data transfer yet. - if (!FireClipboardEvent(NS_PASTE, nsIClipboard::kGlobalClipboard)) + if (!FireClipboardEvent(ePaste, nsIClipboard::kGlobalClipboard)) { return NS_OK; + } // handle transferable hooks nsCOMPtr domdoc = GetDOMDocument(); @@ -1424,8 +1426,9 @@ NS_IMETHODIMP nsHTMLEditor::PasteTransferable(nsITransferable *aTransferable) // NS_IMETHODIMP nsHTMLEditor::PasteNoFormatting(int32_t aSelectionType) { - if (!FireClipboardEvent(NS_PASTE, aSelectionType)) + if (!FireClipboardEvent(ePaste, aSelectionType)) { return NS_OK; + } ForceCompositionEnd(); diff --git a/editor/libeditor/nsPlaintextDataTransfer.cpp b/editor/libeditor/nsPlaintextDataTransfer.cpp index cc85aa9ff3e4..e4973181f4b0 100644 --- a/editor/libeditor/nsPlaintextDataTransfer.cpp +++ b/editor/libeditor/nsPlaintextDataTransfer.cpp @@ -322,8 +322,9 @@ nsresult nsPlaintextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent) NS_IMETHODIMP nsPlaintextEditor::Paste(int32_t aSelectionType) { - if (!FireClipboardEvent(NS_PASTE, aSelectionType)) + if (!FireClipboardEvent(ePaste, aSelectionType)) { return NS_OK; + } // Get Clipboard Service nsresult rv; @@ -355,8 +356,9 @@ NS_IMETHODIMP nsPlaintextEditor::PasteTransferable(nsITransferable *aTransferabl { // Use an invalid value for the clipboard type as data comes from aTransferable // and we don't currently implement a way to put that in the data transfer yet. - if (!FireClipboardEvent(NS_PASTE, -1)) + if (!FireClipboardEvent(ePaste, -1)) { return NS_OK; + } if (!IsModifiable()) return NS_OK; diff --git a/editor/libeditor/nsPlaintextEditor.cpp b/editor/libeditor/nsPlaintextEditor.cpp index de85adfbdcda..45a7b35bc763 100644 --- a/editor/libeditor/nsPlaintextEditor.cpp +++ b/editor/libeditor/nsPlaintextEditor.cpp @@ -1173,7 +1173,7 @@ nsPlaintextEditor::FireClipboardEvent(EventMessage aEventMessage, int32_t aSelectionType, bool* aActionTaken) { - if (aEventMessage == NS_PASTE) { + if (aEventMessage == ePaste) { ForceCompositionEnd(); } diff --git a/widget/EventMessageList.h b/widget/EventMessageList.h index 11113d4c208a..20a06b72f015 100644 --- a/widget/EventMessageList.h +++ b/widget/EventMessageList.h @@ -209,7 +209,7 @@ NS_EVENT_MESSAGE(eXULCommand, eXULCommandEventFirst) NS_EVENT_MESSAGE(eClipboardEventFirst, 3100) NS_EVENT_MESSAGE(eCopy, eClipboardEventFirst) NS_EVENT_MESSAGE(eCut, eClipboardEventFirst + 1) -NS_EVENT_MESSAGE(NS_PASTE, eClipboardEventFirst + 2) +NS_EVENT_MESSAGE(ePaste, eClipboardEventFirst + 2) // Query the content information NS_EVENT_MESSAGE(NS_QUERY_CONTENT_EVENT_START, 3200)