diff --git a/content/base/public/nsCopySupport.h b/content/base/public/nsCopySupport.h index cc4200c2db7..28905ae5a2d 100644 --- a/content/base/public/nsCopySupport.h +++ b/content/base/public/nsCopySupport.h @@ -80,14 +80,11 @@ class nsCopySupport * responsible for removing the content during a cut operation if true is * returned. * - * aClipboardType specifies which clipboard to use, from nsIClipboard. - * * If the event is cancelled or an error occurs, false will be returned. */ static bool FireClipboardEvent(int32_t aType, - int32_t aClipboardType, - nsIPresShell* aPresShell, - nsISelection* aSelection); + nsIPresShell* aPresShell, + nsISelection* aSelection); }; #endif diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 6a8375919ba..16af08c0748 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -4959,7 +4959,7 @@ nsContentUtils::SetDataTransferInEvent(nsDragEvent* aDragEvent) // means, for instance calling the drag service directly, or a drag // from another application. In either case, a new dataTransfer should // be created that reflects the data. - initialDataTransfer = new nsDOMDataTransfer(aDragEvent->message, true, -1); + initialDataTransfer = new nsDOMDataTransfer(aDragEvent->message, true); NS_ENSURE_TRUE(initialDataTransfer, NS_ERROR_OUT_OF_MEMORY); diff --git a/content/base/src/nsCopySupport.cpp b/content/base/src/nsCopySupport.cpp index 796fff3e51c..6f249da5629 100644 --- a/content/base/src/nsCopySupport.cpp +++ b/content/base/src/nsCopySupport.cpp @@ -573,7 +573,7 @@ nsCopySupport::CanCopy(nsIDocument* aDocument) } bool -nsCopySupport::FireClipboardEvent(int32_t aType, int32_t aClipboardType, nsIPresShell* aPresShell, nsISelection* aSelection) +nsCopySupport::FireClipboardEvent(int32_t aType, nsIPresShell* aPresShell, nsISelection* aSelection) { NS_ASSERTION(aType == NS_CUT || aType == NS_COPY || aType == NS_PASTE, "Invalid clipboard event type"); @@ -633,7 +633,7 @@ nsCopySupport::FireClipboardEvent(int32_t aType, int32_t aClipboardType, nsIPres bool doDefault = true; nsRefPtr clipboardData; if (Preferences::GetBool("dom.event.clipboardevents.enabled", true)) { - clipboardData = new nsDOMDataTransfer(aType, aType == NS_PASTE, aClipboardType); + clipboardData = new nsDOMDataTransfer(aType, aType == NS_PASTE); nsEventStatus status = nsEventStatus_eIgnore; nsClipboardEvent evt(true, aType); @@ -675,7 +675,7 @@ nsCopySupport::FireClipboardEvent(int32_t aType, int32_t aClipboardType, nsIPres return false; } // call the copy code - rv = HTMLCopy(sel, doc, aClipboardType); + rv = HTMLCopy(sel, doc, nsIClipboard::kGlobalClipboard); if (NS_FAILED(rv)) { return false; } @@ -692,7 +692,7 @@ nsCopySupport::FireClipboardEvent(int32_t aType, int32_t aClipboardType, nsIPres NS_ENSURE_TRUE(transferable, false); // put the transferable on the clipboard - rv = clipboard->SetData(transferable, nullptr, aClipboardType); + rv = clipboard->SetData(transferable, nullptr, nsIClipboard::kGlobalClipboard); if (NS_FAILED(rv)) { return false; } diff --git a/content/events/src/nsDOMClipboardEvent.cpp b/content/events/src/nsDOMClipboardEvent.cpp index 7ebde924e2a..baf1025422c 100644 --- a/content/events/src/nsDOMClipboardEvent.cpp +++ b/content/events/src/nsDOMClipboardEvent.cpp @@ -7,7 +7,6 @@ #include "nsContentUtils.h" #include "nsClientRect.h" #include "nsDOMDataTransfer.h" -#include "nsIClipboard.h" nsDOMClipboardEvent::nsDOMClipboardEvent(mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext, @@ -69,7 +68,7 @@ nsDOMClipboardEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal, // Always create a clipboardData for the copy event. If this is changed to // support other types of events, make sure that read/write privileges are // checked properly within nsDOMDataTransfer. - clipboardData = new nsDOMDataTransfer(NS_COPY, false, -1); + clipboardData = new nsDOMDataTransfer(NS_COPY, false); clipboardData->SetData(aParam.mDataType, aParam.mData); } } @@ -94,10 +93,10 @@ nsDOMClipboardEvent::GetClipboardData() if (!event->clipboardData) { if (mEventIsInternal) { - event->clipboardData = new nsDOMDataTransfer(NS_COPY, false, -1); + event->clipboardData = new nsDOMDataTransfer(NS_COPY, false); } else { event->clipboardData = - new nsDOMDataTransfer(event->message, event->message == NS_PASTE, nsIClipboard::kGlobalClipboard); + new nsDOMDataTransfer(event->message, event->message == NS_PASTE); } } diff --git a/content/events/src/nsDOMDataTransfer.cpp b/content/events/src/nsDOMDataTransfer.cpp index 577a50d5b34..7e84fd5649c 100644 --- a/content/events/src/nsDOMDataTransfer.cpp +++ b/content/events/src/nsDOMDataTransfer.cpp @@ -63,7 +63,7 @@ const char nsDOMDataTransfer::sEffects[8][9] = { "none", "copy", "move", "copyMove", "link", "copyLink", "linkMove", "all" }; -nsDOMDataTransfer::nsDOMDataTransfer(uint32_t aEventType, bool aIsExternal, int32_t aClipboardType) +nsDOMDataTransfer::nsDOMDataTransfer(uint32_t aEventType, bool aIsExternal) : mEventType(aEventType), mDropEffect(nsIDragService::DRAGDROP_ACTION_NONE), mEffectAllowed(nsIDragService::DRAGDROP_ACTION_UNINITIALIZED), @@ -72,7 +72,6 @@ nsDOMDataTransfer::nsDOMDataTransfer(uint32_t aEventType, bool aIsExternal, int3 mIsExternal(aIsExternal), mUserCancelled(false), mIsCrossDomainSubFrameDrop(false), - mClipboardType(aClipboardType), mDragImageX(0), mDragImageY(0) { @@ -99,7 +98,6 @@ nsDOMDataTransfer::nsDOMDataTransfer(uint32_t aEventType, bool aIsExternal, bool aUserCancelled, bool aIsCrossDomainSubFrameDrop, - int32_t aClipboardType, nsTArray >& aItems, nsIDOMElement* aDragImage, uint32_t aDragImageX, @@ -112,7 +110,6 @@ nsDOMDataTransfer::nsDOMDataTransfer(uint32_t aEventType, mIsExternal(aIsExternal), mUserCancelled(aUserCancelled), mIsCrossDomainSubFrameDrop(aIsCrossDomainSubFrameDrop), - mClipboardType(aClipboardType), mItems(aItems), mDragImage(aDragImage), mDragImageX(aDragImageX), @@ -656,7 +653,7 @@ nsDOMDataTransfer::Clone(uint32_t aEventType, bool aUserCancelled, nsDOMDataTransfer* newDataTransfer = new nsDOMDataTransfer(aEventType, mEffectAllowed, mCursorState, mIsExternal, aUserCancelled, aIsCrossDomainSubFrameDrop, - mClipboardType, mItems, mDragImage, mDragImageX, mDragImageY); + mItems, mDragImage, mDragImageX, mDragImageY); NS_ENSURE_TRUE(newDataTransfer, NS_ERROR_OUT_OF_MEMORY); *aNewDataTransfer = newDataTransfer; @@ -982,7 +979,7 @@ nsDOMDataTransfer::CacheExternalClipboardFormats() // data will only be retrieved when needed. nsCOMPtr clipboard = do_GetService("@mozilla.org/widget/clipboard;1"); - if (!clipboard || mClipboardType < 0) { + if (!clipboard) { return; } @@ -997,7 +994,8 @@ nsDOMDataTransfer::CacheExternalClipboardFormats() for (uint32_t f = 0; f < mozilla::ArrayLength(formats); ++f) { // check each format one at a time bool supported; - clipboard->HasDataMatchingFlavors(&(formats[f]), 1, mClipboardType, &supported); + clipboard->HasDataMatchingFlavors(&(formats[f]), 1, + nsIClipboard::kGlobalClipboard, &supported); // if the format is supported, add an item to the array with null as // the data. When retrieved, GetRealData will read the data. if (supported) { @@ -1038,11 +1036,11 @@ nsDOMDataTransfer::FillInExternalData(TransferItem& aItem, uint32_t aIndex) MOZ_ASSERT(aIndex == 0, "index in clipboard must be 0"); nsCOMPtr clipboard = do_GetService("@mozilla.org/widget/clipboard;1"); - if (!clipboard || mClipboardType < 0) { + if (!clipboard) { return; } - clipboard->GetData(trans, mClipboardType); + clipboard->GetData(trans, nsIClipboard::kGlobalClipboard); } else { nsCOMPtr dragSession = nsContentUtils::GetDragSession(); if (!dragSession) { diff --git a/content/events/src/nsDOMDataTransfer.h b/content/events/src/nsDOMDataTransfer.h index 7e9e50f4193..bf82a3c44d1 100644 --- a/content/events/src/nsDOMDataTransfer.h +++ b/content/events/src/nsDOMDataTransfer.h @@ -58,7 +58,6 @@ protected: bool aIsExternal, bool aUserCancelled, bool aIsCrossDomainSubFrameDrop, - int32_t aClipboardType, nsTArray >& aItems, nsIDOMElement* aDragImage, uint32_t aDragImageX, @@ -83,10 +82,8 @@ public: // paste or a drag that was started without using a data transfer. The // latter will occur when an external drag occurs, that is, a drag where the // source is another application, or a drag is started by calling the drag - // service directly. For clipboard operations, aClipboardType indicates - // which clipboard to use, from nsIClipboard, or -1 for non-clipboard operations, - // or if access to the system clipboard should not be allowed. - nsDOMDataTransfer(uint32_t aEventType, bool aIsExternal, int32_t aClipboardType); + // service directly. + nsDOMDataTransfer(uint32_t aEventType, bool aIsExternal); void GetDragTarget(nsIDOMElement** aDragTarget) { @@ -181,10 +178,6 @@ protected: // data should be prevented bool mIsCrossDomainSubFrameDrop; - // Indicates which clipboard type to use for clipboard operations. Ignored for - // drag and drop. - int32_t mClipboardType; - // array of items, each containing an array of format->data pairs nsTArray > mItems; diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index 8d39648aa69..e4cf4fce269 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/content/events/src/nsEventStateManager.cpp @@ -2027,7 +2027,7 @@ nsEventStateManager::GenerateDragGesture(nsPresContext* aPresContext, } nsRefPtr dataTransfer = - new nsDOMDataTransfer(NS_DRAGDROP_START, false, -1); + new nsDOMDataTransfer(NS_DRAGDROP_START, false); if (!dataTransfer) return; diff --git a/dom/base/nsGlobalWindowCommands.cpp b/dom/base/nsGlobalWindowCommands.cpp index 8d02ba8c9e9..a4571b4e4a5 100644 --- a/dom/base/nsGlobalWindowCommands.cpp +++ b/dom/base/nsGlobalWindowCommands.cpp @@ -25,7 +25,6 @@ #include "nsIContentViewer.h" #include "nsFocusManager.h" #include "nsCopySupport.h" -#include "nsIClipboard.h" #include "nsGUIEvent.h" #include "mozilla/Attributes.h" @@ -366,7 +365,7 @@ nsClipboardCommand::DoCommand(const char *aCommandName, nsISupports *aContext) nsCOMPtr presShell = docShell->GetPresShell(); NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); - nsCopySupport::FireClipboardEvent(NS_COPY, nsIClipboard::kGlobalClipboard, presShell, nullptr); + nsCopySupport::FireClipboardEvent(NS_COPY, presShell, nullptr); return NS_OK; } diff --git a/dom/tests/mochitest/general/Makefile.in b/dom/tests/mochitest/general/Makefile.in index a815221da6e..746a87a61b1 100644 --- a/dom/tests/mochitest/general/Makefile.in +++ b/dom/tests/mochitest/general/Makefile.in @@ -53,7 +53,6 @@ MOCHITEST_FILES = \ test_stylesheetPI.html \ test_showModalDialog.html \ file_showModalDialog.html \ - test_paste_selection.html \ $(NULL) # Disable this test until bug 795711 is fixed. diff --git a/dom/tests/mochitest/general/test_paste_selection.html b/dom/tests/mochitest/general/test_paste_selection.html deleted file mode 100644 index 61619087f4b..00000000000 --- a/dom/tests/mochitest/general/test_paste_selection.html +++ /dev/null @@ -1,106 +0,0 @@ - - - - Test for middle-click to paste selection with paste events - - - - - - -

- - - - - - - - - - diff --git a/editor/libeditor/html/nsHTMLDataTransfer.cpp b/editor/libeditor/html/nsHTMLDataTransfer.cpp index e5a0e4e379f..893390fb0a3 100644 --- a/editor/libeditor/html/nsHTMLDataTransfer.cpp +++ b/editor/libeditor/html/nsHTMLDataTransfer.cpp @@ -1341,7 +1341,7 @@ bool nsHTMLEditor::HavePrivateHTMLFlavor(nsIClipboard *aClipboard) NS_IMETHODIMP nsHTMLEditor::Paste(int32_t aSelectionType) { - if (!FireClipboardEvent(NS_PASTE, aSelectionType)) + if (!FireClipboardEvent(NS_PASTE)) return NS_OK; // Get Clipboard Service @@ -1422,9 +1422,7 @@ NS_IMETHODIMP nsHTMLEditor::Paste(int32_t aSelectionType) 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(NS_PASTE)) return NS_OK; // handle transferable hooks @@ -1442,7 +1440,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteTransferable(nsITransferable *aTransferable) // NS_IMETHODIMP nsHTMLEditor::PasteNoFormatting(int32_t aSelectionType) { - if (!FireClipboardEvent(NS_PASTE, aSelectionType)) + if (!FireClipboardEvent(NS_PASTE)) return NS_OK; ForceCompositionEnd(); diff --git a/editor/libeditor/text/nsPlaintextDataTransfer.cpp b/editor/libeditor/text/nsPlaintextDataTransfer.cpp index 081c75859d1..c84900917fd 100644 --- a/editor/libeditor/text/nsPlaintextDataTransfer.cpp +++ b/editor/libeditor/text/nsPlaintextDataTransfer.cpp @@ -322,7 +322,7 @@ nsresult nsPlaintextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent) NS_IMETHODIMP nsPlaintextEditor::Paste(int32_t aSelectionType) { - if (!FireClipboardEvent(NS_PASTE, aSelectionType)) + if (!FireClipboardEvent(NS_PASTE)) return NS_OK; // Get Clipboard Service @@ -353,9 +353,7 @@ NS_IMETHODIMP nsPlaintextEditor::Paste(int32_t aSelectionType) NS_IMETHODIMP nsPlaintextEditor::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, -1)) + if (!FireClipboardEvent(NS_PASTE)) return NS_OK; if (!IsModifiable()) diff --git a/editor/libeditor/text/nsPlaintextEditor.cpp b/editor/libeditor/text/nsPlaintextEditor.cpp index 2c4bd140eb5..38c6ede798c 100644 --- a/editor/libeditor/text/nsPlaintextEditor.cpp +++ b/editor/libeditor/text/nsPlaintextEditor.cpp @@ -1137,7 +1137,7 @@ nsPlaintextEditor::CanCutOrCopy() } bool -nsPlaintextEditor::FireClipboardEvent(int32_t aType, int32_t aSelectionType) +nsPlaintextEditor::FireClipboardEvent(int32_t aType) { if (aType == NS_PASTE) ForceCompositionEnd(); @@ -1149,7 +1149,7 @@ nsPlaintextEditor::FireClipboardEvent(int32_t aType, int32_t aSelectionType) if (NS_FAILED(GetSelection(getter_AddRefs(selection)))) return false; - if (!nsCopySupport::FireClipboardEvent(aType, aSelectionType, presShell, selection)) + if (!nsCopySupport::FireClipboardEvent(aType, presShell, selection)) return false; // If the event handler caused the editor to be destroyed, return false. @@ -1159,7 +1159,7 @@ nsPlaintextEditor::FireClipboardEvent(int32_t aType, int32_t aSelectionType) NS_IMETHODIMP nsPlaintextEditor::Cut() { - if (FireClipboardEvent(NS_CUT, nsIClipboard::kGlobalClipboard)) + if (FireClipboardEvent(NS_CUT)) return DeleteSelection(eNone, eStrip); return NS_OK; } @@ -1173,7 +1173,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanCut(bool *aCanCut) NS_IMETHODIMP nsPlaintextEditor::Copy() { - FireClipboardEvent(NS_COPY, nsIClipboard::kGlobalClipboard); + FireClipboardEvent(NS_COPY); return NS_OK; } diff --git a/editor/libeditor/text/nsPlaintextEditor.h b/editor/libeditor/text/nsPlaintextEditor.h index d40c0b6d7f3..5c065b1e598 100644 --- a/editor/libeditor/text/nsPlaintextEditor.h +++ b/editor/libeditor/text/nsPlaintextEditor.h @@ -196,7 +196,7 @@ protected: bool IsModifiable(); bool CanCutOrCopy(); - bool FireClipboardEvent(int32_t aType, int32_t aSelectionType); + bool FireClipboardEvent(int32_t aType); bool UpdateMetaCharset(nsIDOMDocument* aDocument, const nsACString& aCharacterSet); diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 8b3c0efa900..da122381f41 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -2490,7 +2490,7 @@ NS_IMETHODIMP nsDocumentViewer::SelectAll() NS_IMETHODIMP nsDocumentViewer::CopySelection() { - nsCopySupport::FireClipboardEvent(NS_COPY, nsIClipboard::kGlobalClipboard, mPresShell, nullptr); + nsCopySupport::FireClipboardEvent(NS_COPY, mPresShell, nullptr); return NS_OK; } diff --git a/testing/specialpowers/content/specialpowersAPI.js b/testing/specialpowers/content/specialpowersAPI.js index 2ecc3466922..edaba414178 100644 --- a/testing/specialpowers/content/specialpowersAPI.js +++ b/testing/specialpowers/content/specialpowersAPI.js @@ -1346,19 +1346,17 @@ SpecialPowersAPI.prototype = { sendAsyncMessage("SpecialPowers.Focus", {}); }, - getClipboardData: function(flavor, whichClipboard) { + getClipboardData: function(flavor) { if (this._cb == null) this._cb = Components.classes["@mozilla.org/widget/clipboard;1"]. getService(Components.interfaces.nsIClipboard); - if (whichClipboard === undefined) - whichClipboard = this._cb.kGlobalClipboard; var xferable = Components.classes["@mozilla.org/widget/transferable;1"]. createInstance(Components.interfaces.nsITransferable); xferable.init(this._getDocShell(content.window) .QueryInterface(Components.interfaces.nsILoadContext)); xferable.addDataFlavor(flavor); - this._cb.getData(xferable, whichClipboard); + this._cb.getData(xferable, this._cb.kGlobalClipboard); var data = {}; try { xferable.getTransferData(flavor, data, {});