Back out 4ff7455f6720, "Bug 894736, pass clipboard type to data transfer so that the correct clipboard is used when pasting, r=ehsan" on a CLOSED TREE.

This commit is contained in:
Justin Lebar 2013-08-02 10:53:34 -07:00
Родитель b9b6064407
Коммит d2dcba11d3
16 изменённых файлов: 34 добавлений и 161 удалений

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

@ -80,14 +80,11 @@ class nsCopySupport
* responsible for removing the content during a cut operation if true is * responsible for removing the content during a cut operation if true is
* returned. * returned.
* *
* aClipboardType specifies which clipboard to use, from nsIClipboard.
*
* If the event is cancelled or an error occurs, false will be returned. * If the event is cancelled or an error occurs, false will be returned.
*/ */
static bool FireClipboardEvent(int32_t aType, static bool FireClipboardEvent(int32_t aType,
int32_t aClipboardType, nsIPresShell* aPresShell,
nsIPresShell* aPresShell, nsISelection* aSelection);
nsISelection* aSelection);
}; };
#endif #endif

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

@ -4959,7 +4959,7 @@ nsContentUtils::SetDataTransferInEvent(nsDragEvent* aDragEvent)
// means, for instance calling the drag service directly, or a drag // means, for instance calling the drag service directly, or a drag
// from another application. In either case, a new dataTransfer should // from another application. In either case, a new dataTransfer should
// be created that reflects the data. // 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); NS_ENSURE_TRUE(initialDataTransfer, NS_ERROR_OUT_OF_MEMORY);

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

@ -573,7 +573,7 @@ nsCopySupport::CanCopy(nsIDocument* aDocument)
} }
bool 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, NS_ASSERTION(aType == NS_CUT || aType == NS_COPY || aType == NS_PASTE,
"Invalid clipboard event type"); "Invalid clipboard event type");
@ -633,7 +633,7 @@ nsCopySupport::FireClipboardEvent(int32_t aType, int32_t aClipboardType, nsIPres
bool doDefault = true; bool doDefault = true;
nsRefPtr<nsDOMDataTransfer> clipboardData; nsRefPtr<nsDOMDataTransfer> clipboardData;
if (Preferences::GetBool("dom.event.clipboardevents.enabled", true)) { 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; nsEventStatus status = nsEventStatus_eIgnore;
nsClipboardEvent evt(true, aType); nsClipboardEvent evt(true, aType);
@ -675,7 +675,7 @@ nsCopySupport::FireClipboardEvent(int32_t aType, int32_t aClipboardType, nsIPres
return false; return false;
} }
// call the copy code // call the copy code
rv = HTMLCopy(sel, doc, aClipboardType); rv = HTMLCopy(sel, doc, nsIClipboard::kGlobalClipboard);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return false; return false;
} }
@ -692,7 +692,7 @@ nsCopySupport::FireClipboardEvent(int32_t aType, int32_t aClipboardType, nsIPres
NS_ENSURE_TRUE(transferable, false); NS_ENSURE_TRUE(transferable, false);
// put the transferable on the clipboard // put the transferable on the clipboard
rv = clipboard->SetData(transferable, nullptr, aClipboardType); rv = clipboard->SetData(transferable, nullptr, nsIClipboard::kGlobalClipboard);
if (NS_FAILED(rv)) { if (NS_FAILED(rv)) {
return false; return false;
} }

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

@ -7,7 +7,6 @@
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsClientRect.h" #include "nsClientRect.h"
#include "nsDOMDataTransfer.h" #include "nsDOMDataTransfer.h"
#include "nsIClipboard.h"
nsDOMClipboardEvent::nsDOMClipboardEvent(mozilla::dom::EventTarget* aOwner, nsDOMClipboardEvent::nsDOMClipboardEvent(mozilla::dom::EventTarget* aOwner,
nsPresContext* aPresContext, 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 // 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 // support other types of events, make sure that read/write privileges are
// checked properly within nsDOMDataTransfer. // checked properly within nsDOMDataTransfer.
clipboardData = new nsDOMDataTransfer(NS_COPY, false, -1); clipboardData = new nsDOMDataTransfer(NS_COPY, false);
clipboardData->SetData(aParam.mDataType, aParam.mData); clipboardData->SetData(aParam.mDataType, aParam.mData);
} }
} }
@ -94,10 +93,10 @@ nsDOMClipboardEvent::GetClipboardData()
if (!event->clipboardData) { if (!event->clipboardData) {
if (mEventIsInternal) { if (mEventIsInternal) {
event->clipboardData = new nsDOMDataTransfer(NS_COPY, false, -1); event->clipboardData = new nsDOMDataTransfer(NS_COPY, false);
} else { } else {
event->clipboardData = event->clipboardData =
new nsDOMDataTransfer(event->message, event->message == NS_PASTE, nsIClipboard::kGlobalClipboard); new nsDOMDataTransfer(event->message, event->message == NS_PASTE);
} }
} }

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

@ -63,7 +63,7 @@ const char nsDOMDataTransfer::sEffects[8][9] = {
"none", "copy", "move", "copyMove", "link", "copyLink", "linkMove", "all" "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), : mEventType(aEventType),
mDropEffect(nsIDragService::DRAGDROP_ACTION_NONE), mDropEffect(nsIDragService::DRAGDROP_ACTION_NONE),
mEffectAllowed(nsIDragService::DRAGDROP_ACTION_UNINITIALIZED), mEffectAllowed(nsIDragService::DRAGDROP_ACTION_UNINITIALIZED),
@ -72,7 +72,6 @@ nsDOMDataTransfer::nsDOMDataTransfer(uint32_t aEventType, bool aIsExternal, int3
mIsExternal(aIsExternal), mIsExternal(aIsExternal),
mUserCancelled(false), mUserCancelled(false),
mIsCrossDomainSubFrameDrop(false), mIsCrossDomainSubFrameDrop(false),
mClipboardType(aClipboardType),
mDragImageX(0), mDragImageX(0),
mDragImageY(0) mDragImageY(0)
{ {
@ -99,7 +98,6 @@ nsDOMDataTransfer::nsDOMDataTransfer(uint32_t aEventType,
bool aIsExternal, bool aIsExternal,
bool aUserCancelled, bool aUserCancelled,
bool aIsCrossDomainSubFrameDrop, bool aIsCrossDomainSubFrameDrop,
int32_t aClipboardType,
nsTArray<nsTArray<TransferItem> >& aItems, nsTArray<nsTArray<TransferItem> >& aItems,
nsIDOMElement* aDragImage, nsIDOMElement* aDragImage,
uint32_t aDragImageX, uint32_t aDragImageX,
@ -112,7 +110,6 @@ nsDOMDataTransfer::nsDOMDataTransfer(uint32_t aEventType,
mIsExternal(aIsExternal), mIsExternal(aIsExternal),
mUserCancelled(aUserCancelled), mUserCancelled(aUserCancelled),
mIsCrossDomainSubFrameDrop(aIsCrossDomainSubFrameDrop), mIsCrossDomainSubFrameDrop(aIsCrossDomainSubFrameDrop),
mClipboardType(aClipboardType),
mItems(aItems), mItems(aItems),
mDragImage(aDragImage), mDragImage(aDragImage),
mDragImageX(aDragImageX), mDragImageX(aDragImageX),
@ -656,7 +653,7 @@ nsDOMDataTransfer::Clone(uint32_t aEventType, bool aUserCancelled,
nsDOMDataTransfer* newDataTransfer = nsDOMDataTransfer* newDataTransfer =
new nsDOMDataTransfer(aEventType, mEffectAllowed, mCursorState, new nsDOMDataTransfer(aEventType, mEffectAllowed, mCursorState,
mIsExternal, aUserCancelled, aIsCrossDomainSubFrameDrop, mIsExternal, aUserCancelled, aIsCrossDomainSubFrameDrop,
mClipboardType, mItems, mDragImage, mDragImageX, mDragImageY); mItems, mDragImage, mDragImageX, mDragImageY);
NS_ENSURE_TRUE(newDataTransfer, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(newDataTransfer, NS_ERROR_OUT_OF_MEMORY);
*aNewDataTransfer = newDataTransfer; *aNewDataTransfer = newDataTransfer;
@ -982,7 +979,7 @@ nsDOMDataTransfer::CacheExternalClipboardFormats()
// data will only be retrieved when needed. // data will only be retrieved when needed.
nsCOMPtr<nsIClipboard> clipboard = do_GetService("@mozilla.org/widget/clipboard;1"); nsCOMPtr<nsIClipboard> clipboard = do_GetService("@mozilla.org/widget/clipboard;1");
if (!clipboard || mClipboardType < 0) { if (!clipboard) {
return; return;
} }
@ -997,7 +994,8 @@ nsDOMDataTransfer::CacheExternalClipboardFormats()
for (uint32_t f = 0; f < mozilla::ArrayLength(formats); ++f) { for (uint32_t f = 0; f < mozilla::ArrayLength(formats); ++f) {
// check each format one at a time // check each format one at a time
bool supported; 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 // if the format is supported, add an item to the array with null as
// the data. When retrieved, GetRealData will read the data. // the data. When retrieved, GetRealData will read the data.
if (supported) { if (supported) {
@ -1038,11 +1036,11 @@ nsDOMDataTransfer::FillInExternalData(TransferItem& aItem, uint32_t aIndex)
MOZ_ASSERT(aIndex == 0, "index in clipboard must be 0"); MOZ_ASSERT(aIndex == 0, "index in clipboard must be 0");
nsCOMPtr<nsIClipboard> clipboard = do_GetService("@mozilla.org/widget/clipboard;1"); nsCOMPtr<nsIClipboard> clipboard = do_GetService("@mozilla.org/widget/clipboard;1");
if (!clipboard || mClipboardType < 0) { if (!clipboard) {
return; return;
} }
clipboard->GetData(trans, mClipboardType); clipboard->GetData(trans, nsIClipboard::kGlobalClipboard);
} else { } else {
nsCOMPtr<nsIDragSession> dragSession = nsContentUtils::GetDragSession(); nsCOMPtr<nsIDragSession> dragSession = nsContentUtils::GetDragSession();
if (!dragSession) { if (!dragSession) {

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

@ -58,7 +58,6 @@ protected:
bool aIsExternal, bool aIsExternal,
bool aUserCancelled, bool aUserCancelled,
bool aIsCrossDomainSubFrameDrop, bool aIsCrossDomainSubFrameDrop,
int32_t aClipboardType,
nsTArray<nsTArray<TransferItem> >& aItems, nsTArray<nsTArray<TransferItem> >& aItems,
nsIDOMElement* aDragImage, nsIDOMElement* aDragImage,
uint32_t aDragImageX, uint32_t aDragImageX,
@ -83,10 +82,8 @@ public:
// paste or a drag that was started without using a data transfer. The // 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 // 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 // source is another application, or a drag is started by calling the drag
// service directly. For clipboard operations, aClipboardType indicates // service directly.
// which clipboard to use, from nsIClipboard, or -1 for non-clipboard operations, nsDOMDataTransfer(uint32_t aEventType, bool aIsExternal);
// or if access to the system clipboard should not be allowed.
nsDOMDataTransfer(uint32_t aEventType, bool aIsExternal, int32_t aClipboardType);
void GetDragTarget(nsIDOMElement** aDragTarget) void GetDragTarget(nsIDOMElement** aDragTarget)
{ {
@ -181,10 +178,6 @@ protected:
// data should be prevented // data should be prevented
bool mIsCrossDomainSubFrameDrop; 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 // array of items, each containing an array of format->data pairs
nsTArray<nsTArray<TransferItem> > mItems; nsTArray<nsTArray<TransferItem> > mItems;

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

@ -2027,7 +2027,7 @@ nsEventStateManager::GenerateDragGesture(nsPresContext* aPresContext,
} }
nsRefPtr<nsDOMDataTransfer> dataTransfer = nsRefPtr<nsDOMDataTransfer> dataTransfer =
new nsDOMDataTransfer(NS_DRAGDROP_START, false, -1); new nsDOMDataTransfer(NS_DRAGDROP_START, false);
if (!dataTransfer) if (!dataTransfer)
return; return;

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

@ -25,7 +25,6 @@
#include "nsIContentViewer.h" #include "nsIContentViewer.h"
#include "nsFocusManager.h" #include "nsFocusManager.h"
#include "nsCopySupport.h" #include "nsCopySupport.h"
#include "nsIClipboard.h"
#include "nsGUIEvent.h" #include "nsGUIEvent.h"
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
@ -366,7 +365,7 @@ nsClipboardCommand::DoCommand(const char *aCommandName, nsISupports *aContext)
nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell(); nsCOMPtr<nsIPresShell> presShell = docShell->GetPresShell();
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE); NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
nsCopySupport::FireClipboardEvent(NS_COPY, nsIClipboard::kGlobalClipboard, presShell, nullptr); nsCopySupport::FireClipboardEvent(NS_COPY, presShell, nullptr);
return NS_OK; return NS_OK;
} }

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

@ -53,7 +53,6 @@ MOCHITEST_FILES = \
test_stylesheetPI.html \ test_stylesheetPI.html \
test_showModalDialog.html \ test_showModalDialog.html \
file_showModalDialog.html \ file_showModalDialog.html \
test_paste_selection.html \
$(NULL) $(NULL)
# Disable this test until bug 795711 is fixed. # Disable this test until bug 795711 is fixed.

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

@ -1,106 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for middle-click to paste selection with paste events</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<input id="copy-area" value="CLIPBOARD">
<input id="paste-selection-area" value="" onpaste="pastedSelection(event)">
<input id="paste-global-area" value="" onpaste="pastedGlobal(event)">
<script>
var supportsSelectionClipboard = SpecialPowers.supportsSelectionClipboard();
function checkSelectionClipboardText(count)
{
if ((!supportsSelectionClipboard ||
SpecialPowers.getClipboardData("text/unicode", SpecialPowers.Ci.nsIClipboard.kSelectionClipboard) == "COPY TEXT") &&
SpecialPowers.getClipboardData("text/unicode", SpecialPowers.Ci.nsIClipboard.kGlobalClipboard) == "CLIPBOARD") {
pasteArea();
return;
}
if (count > 10) {
ok(false, "could not set clipboards");
pasteArea();
SimpleTest.finish();
return;
}
setTimeout(checkSelectionClipboardText, 5, count + 1);
}
function selectArea()
{
var copyArea = document.getElementById("copy-area");
copyArea.focus();
copyArea.select();
synthesizeKey("x", { accelKey: true });
if (supportsSelectionClipboard) {
var clipboardHelper = SpecialPowers.Cc["@mozilla.org/widget/clipboardhelper;1"]
.getService(SpecialPowers.Ci.nsIClipboardHelper);
clipboardHelper.copyStringToClipboard("COPY TEXT",
SpecialPowers.Ci.nsIClipboard.kSelectionClipboard,
document);
}
setTimeout(checkSelectionClipboardText, 50, 0);
}
var selectionPasted = false;
var globalPasted = false;
function pasteArea()
{
var pasteArea = document.getElementById("paste-selection-area");
pasteArea.focus();
synthesizeMouse(pasteArea, 8, 8, { button: 1 });
if (supportsSelectionClipboard) {
is(document.getElementById("paste-selection-area").value, "COPY TEXT", "data pasted properly from selection");
ok(selectionPasted, "selection event fired");
}
else {
is(pasteArea.value, "", "data pasted properly");
}
var pasteArea = document.getElementById("paste-global-area");
pasteArea.focus();
synthesizeKey("v", { accelKey: true });
ok(globalPasted, "global event fired");
is(document.getElementById("paste-global-area").value, "CLIPBOARD", "data pasted properly from global clipboard");
SimpleTest.finish();
}
function pastedSelection(event)
{
ok(supportsSelectionClipboard, "paste on middle click is valid");
// The data transfer should contain the selection data, not the global clipboard data.
is(event.clipboardData.getData("text/plain"), "COPY TEXT", "data correct in selection data transfer");
selectionPasted = true;
}
function pastedGlobal(event)
{
// The data transfer should contain the global data.
is(event.clipboardData.getData("text/plain"), "CLIPBOARD", "data correct in global clipboard data transfer");
globalPasted = true;
}
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(selectArea);
</script>
</pre>
</body>
</html>

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

@ -1341,7 +1341,7 @@ bool nsHTMLEditor::HavePrivateHTMLFlavor(nsIClipboard *aClipboard)
NS_IMETHODIMP nsHTMLEditor::Paste(int32_t aSelectionType) NS_IMETHODIMP nsHTMLEditor::Paste(int32_t aSelectionType)
{ {
if (!FireClipboardEvent(NS_PASTE, aSelectionType)) if (!FireClipboardEvent(NS_PASTE))
return NS_OK; return NS_OK;
// Get Clipboard Service // Get Clipboard Service
@ -1422,9 +1422,7 @@ NS_IMETHODIMP nsHTMLEditor::Paste(int32_t aSelectionType)
NS_IMETHODIMP nsHTMLEditor::PasteTransferable(nsITransferable *aTransferable) NS_IMETHODIMP nsHTMLEditor::PasteTransferable(nsITransferable *aTransferable)
{ {
// Use an invalid value for the clipboard type as data comes from aTransferable if (!FireClipboardEvent(NS_PASTE))
// and we don't currently implement a way to put that in the data transfer yet.
if (!FireClipboardEvent(NS_PASTE, nsIClipboard::kGlobalClipboard))
return NS_OK; return NS_OK;
// handle transferable hooks // handle transferable hooks
@ -1442,7 +1440,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteTransferable(nsITransferable *aTransferable)
// //
NS_IMETHODIMP nsHTMLEditor::PasteNoFormatting(int32_t aSelectionType) NS_IMETHODIMP nsHTMLEditor::PasteNoFormatting(int32_t aSelectionType)
{ {
if (!FireClipboardEvent(NS_PASTE, aSelectionType)) if (!FireClipboardEvent(NS_PASTE))
return NS_OK; return NS_OK;
ForceCompositionEnd(); ForceCompositionEnd();

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

@ -322,7 +322,7 @@ nsresult nsPlaintextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
NS_IMETHODIMP nsPlaintextEditor::Paste(int32_t aSelectionType) NS_IMETHODIMP nsPlaintextEditor::Paste(int32_t aSelectionType)
{ {
if (!FireClipboardEvent(NS_PASTE, aSelectionType)) if (!FireClipboardEvent(NS_PASTE))
return NS_OK; return NS_OK;
// Get Clipboard Service // Get Clipboard Service
@ -353,9 +353,7 @@ NS_IMETHODIMP nsPlaintextEditor::Paste(int32_t aSelectionType)
NS_IMETHODIMP nsPlaintextEditor::PasteTransferable(nsITransferable *aTransferable) NS_IMETHODIMP nsPlaintextEditor::PasteTransferable(nsITransferable *aTransferable)
{ {
// Use an invalid value for the clipboard type as data comes from aTransferable if (!FireClipboardEvent(NS_PASTE))
// and we don't currently implement a way to put that in the data transfer yet.
if (!FireClipboardEvent(NS_PASTE, -1))
return NS_OK; return NS_OK;
if (!IsModifiable()) if (!IsModifiable())

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

@ -1137,7 +1137,7 @@ nsPlaintextEditor::CanCutOrCopy()
} }
bool bool
nsPlaintextEditor::FireClipboardEvent(int32_t aType, int32_t aSelectionType) nsPlaintextEditor::FireClipboardEvent(int32_t aType)
{ {
if (aType == NS_PASTE) if (aType == NS_PASTE)
ForceCompositionEnd(); ForceCompositionEnd();
@ -1149,7 +1149,7 @@ nsPlaintextEditor::FireClipboardEvent(int32_t aType, int32_t aSelectionType)
if (NS_FAILED(GetSelection(getter_AddRefs(selection)))) if (NS_FAILED(GetSelection(getter_AddRefs(selection))))
return false; return false;
if (!nsCopySupport::FireClipboardEvent(aType, aSelectionType, presShell, selection)) if (!nsCopySupport::FireClipboardEvent(aType, presShell, selection))
return false; return false;
// If the event handler caused the editor to be destroyed, 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() NS_IMETHODIMP nsPlaintextEditor::Cut()
{ {
if (FireClipboardEvent(NS_CUT, nsIClipboard::kGlobalClipboard)) if (FireClipboardEvent(NS_CUT))
return DeleteSelection(eNone, eStrip); return DeleteSelection(eNone, eStrip);
return NS_OK; return NS_OK;
} }
@ -1173,7 +1173,7 @@ NS_IMETHODIMP nsPlaintextEditor::CanCut(bool *aCanCut)
NS_IMETHODIMP nsPlaintextEditor::Copy() NS_IMETHODIMP nsPlaintextEditor::Copy()
{ {
FireClipboardEvent(NS_COPY, nsIClipboard::kGlobalClipboard); FireClipboardEvent(NS_COPY);
return NS_OK; return NS_OK;
} }

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

@ -196,7 +196,7 @@ protected:
bool IsModifiable(); bool IsModifiable();
bool CanCutOrCopy(); bool CanCutOrCopy();
bool FireClipboardEvent(int32_t aType, int32_t aSelectionType); bool FireClipboardEvent(int32_t aType);
bool UpdateMetaCharset(nsIDOMDocument* aDocument, bool UpdateMetaCharset(nsIDOMDocument* aDocument,
const nsACString& aCharacterSet); const nsACString& aCharacterSet);

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

@ -2490,7 +2490,7 @@ NS_IMETHODIMP nsDocumentViewer::SelectAll()
NS_IMETHODIMP nsDocumentViewer::CopySelection() NS_IMETHODIMP nsDocumentViewer::CopySelection()
{ {
nsCopySupport::FireClipboardEvent(NS_COPY, nsIClipboard::kGlobalClipboard, mPresShell, nullptr); nsCopySupport::FireClipboardEvent(NS_COPY, mPresShell, nullptr);
return NS_OK; return NS_OK;
} }

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

@ -1346,19 +1346,17 @@ SpecialPowersAPI.prototype = {
sendAsyncMessage("SpecialPowers.Focus", {}); sendAsyncMessage("SpecialPowers.Focus", {});
}, },
getClipboardData: function(flavor, whichClipboard) { getClipboardData: function(flavor) {
if (this._cb == null) if (this._cb == null)
this._cb = Components.classes["@mozilla.org/widget/clipboard;1"]. this._cb = Components.classes["@mozilla.org/widget/clipboard;1"].
getService(Components.interfaces.nsIClipboard); getService(Components.interfaces.nsIClipboard);
if (whichClipboard === undefined)
whichClipboard = this._cb.kGlobalClipboard;
var xferable = Components.classes["@mozilla.org/widget/transferable;1"]. var xferable = Components.classes["@mozilla.org/widget/transferable;1"].
createInstance(Components.interfaces.nsITransferable); createInstance(Components.interfaces.nsITransferable);
xferable.init(this._getDocShell(content.window) xferable.init(this._getDocShell(content.window)
.QueryInterface(Components.interfaces.nsILoadContext)); .QueryInterface(Components.interfaces.nsILoadContext));
xferable.addDataFlavor(flavor); xferable.addDataFlavor(flavor);
this._cb.getData(xferable, whichClipboard); this._cb.getData(xferable, this._cb.kGlobalClipboard);
var data = {}; var data = {};
try { try {
xferable.getTransferData(flavor, data, {}); xferable.getTransferData(flavor, data, {});