Bug 1166840 - Remove document argument from nsIClipboardHelper.copyString{,ToClipboard}. r=ehsan

This commit is contained in:
Birunthan Mohanathas 2015-05-21 21:50:09 +01:00
parent bb7ff5cd7f
commit 8b4520f330
4 changed files with 10 additions and 18 deletions

View File

@ -1263,7 +1263,7 @@ EncodeSourceSurfaceInternal(SourceSurface* aSurface,
} else {
nsCOMPtr<nsIClipboardHelper> clipboard(do_GetService("@mozilla.org/widget/clipboardhelper;1", &rv));
if (clipboard) {
clipboard->CopyString(NS_ConvertASCIItoUTF16(string), nullptr);
clipboard->CopyString(NS_ConvertASCIItoUTF16(string));
}
}
return NS_OK;

View File

@ -2643,8 +2643,7 @@ NS_IMETHODIMP nsDocumentViewer::CopyLinkLocation()
NS_ENSURE_SUCCESS(rv, rv);
// copy the href onto the clipboard
nsCOMPtr<nsIDOMDocument> doc = do_QueryInterface(mDocument);
return clipboard->CopyString(locationText, doc);
return clipboard->CopyString(locationText);
}
NS_IMETHODIMP nsDocumentViewer::CopyImage(int32_t aCopyFlags)

View File

@ -40,8 +40,7 @@ nsClipboardHelper::~nsClipboardHelper()
NS_IMETHODIMP
nsClipboardHelper::CopyStringToClipboard(const nsAString& aString,
int32_t aClipboardID,
nsIDOMDocument* aDocument)
int32_t aClipboardID)
{
nsresult rv;
@ -76,9 +75,7 @@ nsClipboardHelper::CopyStringToClipboard(const nsAString& aString,
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(trans, NS_ERROR_FAILURE);
nsCOMPtr<nsIDocument> doc = do_QueryInterface(aDocument);
nsILoadContext* loadContext = doc ? doc->GetLoadContext() : nullptr;
trans->Init(loadContext);
trans->Init(nullptr);
// Add the text data flavor to the transferable
rv = trans->AddDataFlavor(kUnicodeMime);
@ -113,12 +110,12 @@ nsClipboardHelper::CopyStringToClipboard(const nsAString& aString,
}
NS_IMETHODIMP
nsClipboardHelper::CopyString(const nsAString& aString, nsIDOMDocument* aDocument)
nsClipboardHelper::CopyString(const nsAString& aString)
{
nsresult rv;
// copy to the global clipboard. it's bad if this fails in any way.
rv = CopyStringToClipboard(aString, nsIClipboard::kGlobalClipboard, aDocument);
rv = CopyStringToClipboard(aString, nsIClipboard::kGlobalClipboard);
NS_ENSURE_SUCCESS(rv, rv);
// unix also needs us to copy to the selection clipboard. this will
@ -130,7 +127,7 @@ nsClipboardHelper::CopyString(const nsAString& aString, nsIDOMDocument* aDocumen
// if this fails in any way other than "not being unix", we'll get
// the assertion we need in CopyStringToClipboard, and we needn't
// assert again here.
CopyStringToClipboard(aString, nsIClipboard::kSelectionClipboard, aDocument);
CopyStringToClipboard(aString, nsIClipboard::kSelectionClipboard);
return NS_OK;
}

View File

@ -17,26 +17,22 @@ interface nsIDOMDocument;
* helper service for common uses of nsIClipboard.
*/
[scriptable, uuid(c9d5a750-c3a8-11e1-9b21-0800200c9a66)]
[scriptable, uuid(438307fd-0c68-4d79-922a-f6cc9550cd02)]
interface nsIClipboardHelper : nsISupports
{
/**
* copy string to given clipboard
*
* @param aString, the string to copy to the clipboard
* @param aDoc, the source document for the string, if available
* @param aClipboardID, the ID of the clipboard to copy to
* (eg. kSelectionClipboard -- see nsIClipboard.idl)
*/
void copyStringToClipboard(in AString aString, in long aClipboardID, [optional] in nsIDOMDocument aDoc);
void copyStringToClipboard(in AString aString, in long aClipboardID);
/**
* copy string to (default) clipboard
*
* @param aString, the string to copy to the clipboard
* @param aDoc, the source document for the string, if available
*/
void copyString(in AString aString, [optional] in nsIDOMDocument aDoc);
void copyString(in AString aString);
};