# HG changeset patch # User Martin Stransky # Date 1522744237 -7200 # Node ID 4087700190a569204fbf01035694cdb74fe9f27a # Parent a72b2783280332f15a826c32b39d572dbe806975 Bug 1447925 - Use GetClipboardText() to get text data at nsClipboard::GetData(), r=jhorak MozReview-Commit-ID: 3JnLLyk0BOF diff --git a/widget/gtk/nsClipboard.cpp b/widget/gtk/nsClipboard.cpp --- 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; diff --git a/widget/gtk/nsClipboard.h b/widget/gtk/nsClipboard.h --- 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 -// 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)