Bug 1166840 - Remove document argument from nsIClipboardHelper.copyString{,ToClipboard}. r=ehsan
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Thu, 21 May 2015 21:50:09 +0100
changeset 245222 9e89159cbe385d31bd3876515ffdcfff5544571b
parent 245221 ec14eee472e5a5c5ed4be338f6d32d8716b99557
child 245223 9f6b6dd5134cf3cb0f372f815fa40a5ab6a2425a
push id28799
push userphilringnalda@gmail.com
push dateSat, 23 May 2015 20:31:44 +0000
treeherdermozilla-central@c3c0928c3cde [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1166840
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1166840 - Remove document argument from nsIClipboardHelper.copyString{,ToClipboard}. r=ehsan
gfx/thebes/gfxUtils.cpp
layout/base/nsDocumentViewer.cpp
widget/nsClipboardHelper.cpp
widget/nsIClipboardHelper.idl
--- a/gfx/thebes/gfxUtils.cpp
+++ b/gfx/thebes/gfxUtils.cpp
@@ -1258,17 +1258,17 @@ EncodeSourceSurfaceInternal(SourceSurfac
     }
 #endif
     fprintf(aFile, "%s", string.BeginReading());
   } else if (aStrOut) {
     *aStrOut = string;
   } 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;
 }
 
 static nsCString
 EncodeSourceSurfaceAsPNGURI(SourceSurface* aSurface)
 {
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -2638,18 +2638,17 @@ NS_IMETHODIMP nsDocumentViewer::CopyLink
   if (locationText.IsEmpty())
     return NS_ERROR_FAILURE;
 
   nsresult rv = NS_OK;
   nsCOMPtr<nsIClipboardHelper> clipboard(do_GetService("@mozilla.org/widget/clipboardhelper;1", &rv));
   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)
 {
   NS_ENSURE_TRUE(mPresShell, NS_ERROR_NOT_INITIALIZED);
   nsCOMPtr<nsIImageLoadingContent> node;
   GetPopupImageNode(getter_AddRefs(node));
   // make noise if we're not in an image
--- a/widget/nsClipboardHelper.cpp
+++ b/widget/nsClipboardHelper.cpp
@@ -35,18 +35,17 @@ nsClipboardHelper::~nsClipboardHelper()
 }
 
 /*****************************************************************************
  * nsIClipboardHelper methods
  *****************************************************************************/
 
 NS_IMETHODIMP
 nsClipboardHelper::CopyStringToClipboard(const nsAString& aString,
-                                         int32_t aClipboardID,
-                                         nsIDOMDocument* aDocument)
+                                         int32_t aClipboardID)
 {
   nsresult rv;
 
   // get the clipboard
   nsCOMPtr<nsIClipboard>
     clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_TRUE(clipboard, NS_ERROR_FAILURE);
@@ -71,19 +70,17 @@ nsClipboardHelper::CopyStringToClipboard
   }
 
   // create a transferable for putting data on the clipboard
   nsCOMPtr<nsITransferable>
     trans(do_CreateInstance("@mozilla.org/widget/transferable;1", &rv));
   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);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // get wStrings to hold clip data
   nsCOMPtr<nsISupportsString>
     data(do_CreateInstance("@mozilla.org/supports-string;1", &rv));
@@ -108,29 +105,29 @@ nsClipboardHelper::CopyStringToClipboard
   // put the transferable on the clipboard
   rv = clipboard->SetData(trans, nullptr, aClipboardID);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
 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
   // fail in CopyStringToClipboard if we're not on a platform that
   // supports the selection clipboard. (this could have been #ifdef
   // XP_UNIX, but using the SupportsSelectionClipboard call is the
   // more correct thing to do.
   //
   // 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;
 }
--- a/widget/nsIClipboardHelper.idl
+++ b/widget/nsIClipboardHelper.idl
@@ -12,31 +12,27 @@
 %}
 
 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);
 };