Bug 1447925 - Use GetClipboardText() to get text data at nsClipboard::GetData(), r=jhorak
authorMartin Stransky <stransky@redhat.com>
Tue, 03 Apr 2018 10:30:37 +0200
changeset 411457 4087700190a569204fbf01035694cdb74fe9f27a
parent 411456 537057d5ac496ca79514875c88c55b755019d93b
child 411458 cf8ffb2a11f29a962fa63f38534fde94f9131848
push id33760
push useraciure@mozilla.com
push dateTue, 03 Apr 2018 21:52:50 +0000
treeherdermozilla-central@ad27045cac84 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjhorak
bugs1447925
milestone61.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 1447925 - Use GetClipboardText() to get text data at nsClipboard::GetData(), r=jhorak MozReview-Commit-ID: 3JnLLyk0BOF
widget/gtk/nsClipboard.cpp
widget/gtk/nsClipboard.h
--- a/widget/gtk/nsClipboard.cpp
+++ b/widget/gtk/nsClipboard.cpp
@@ -296,30 +296,27 @@ nsClipboard::GetData(nsITransferable *aT
 
             mContext->ReleaseClipboardData(clipboardData);
             return NS_OK;
         }
 
         // Special case text/unicode since we can convert any
         // string into text/unicode
         if (flavorStr.EqualsLiteral(kUnicodeMime)) {
-            uint32_t    clipboardDataLength;
             const char* clipboardData =
-                mContext->GetClipboardData(GTK_DEFAULT_MIME_TEXT,
-                                           aWhichClipboard,
-                                           &clipboardDataLength);
+                mContext->GetClipboardText(aWhichClipboard);
             if (!clipboardData) {
                 // If the type was text/unicode and we couldn't get
                 // text off the clipboard, run the next loop
                 // iteration.
                 continue;
             }
 
             // Convert utf-8 into our unicode format.
-            NS_ConvertUTF8toUTF16 ucs2string(clipboardData, clipboardDataLength);
+            NS_ConvertUTF8toUTF16 ucs2string(clipboardData);
             const char* unicodeData = (const char *)ToNewUnicode(ucs2string);
             uint32_t unicodeDataLength = ucs2string.Length() * 2;
             SetTransferableData(aTransferable, flavorStr,
                                 unicodeData, unicodeDataLength);
             free((void *)unicodeData);
 
             mContext->ReleaseClipboardData(clipboardData);
             return NS_OK;
--- a/widget/gtk/nsClipboard.h
+++ b/widget/gtk/nsClipboard.h
@@ -8,27 +8,28 @@
 #ifndef __nsClipboard_h_
 #define __nsClipboard_h_
 
 #include "nsIClipboard.h"
 #include "nsIObserver.h"
 #include "nsIBinaryOutputStream.h"
 #include <gtk/gtk.h>
 
-// Default Gtk MIME for text
-#define GTK_DEFAULT_MIME_TEXT "UTF8_STRING"
-
 class nsRetrievalContext {
 public:
+    // Get actual clipboard content (GetClipboardData/GetClipboardText)
+    // which has to be released by ReleaseClipboardData().
     virtual const char* GetClipboardData(const char* aMimeType,
                                          int32_t aWhichClipboard,
                                          uint32_t* aContentLength) = 0;
     virtual const char* GetClipboardText(int32_t aWhichClipboard) = 0;
     virtual void ReleaseClipboardData(const char* aClipboardData) = 0;
 
+    // Get data mime types which can be obtained from clipboard.
+    // The returned array has to be released by g_free().
     virtual GdkAtom* GetTargets(int32_t aWhichClipboard,
                                 int* aTargetNum) = 0;
 
     nsRetrievalContext() {};
     virtual ~nsRetrievalContext() {};
 
 protected:
     // Idle timeout for receiving selection and property notify events (microsec)