pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/www/firefox Apply upstream patches for Bu...
details: https://anonhg.NetBSD.org/pkgsrc/rev/41a7b18a5d4d
branches: trunk
changeset: 306930:41a7b18a5d4d
user: martin <martin%pkgsrc.org@localhost>
date: Sun Apr 29 13:27:08 2018 +0000
description:
Apply upstream patches for Bug 1447925 - pasting from clipboard did not
work from non-UTF8 applications.
Ride todays (unrelated) rev bump.
diffstat:
www/firefox/distinfo | 6 +-
www/firefox/patches/patch-widget_gtk_nsClipboard.cpp | 30 +
www/firefox/patches/patch-widget_gtk_nsClipboard.h | 30 +
www/firefox/patches/patch-widget_gtk_nsClipboardX11.cpp | 264 ++++++++++++++++
www/firefox/patches/patch-widget_gtk_nsClipboardX11.h | 92 +++++
5 files changed, 421 insertions(+), 1 deletions(-)
diffs (truncated from 452 to 300 lines):
diff -r bea80059ee5c -r 41a7b18a5d4d www/firefox/distinfo
--- a/www/firefox/distinfo Sun Apr 29 13:07:22 2018 +0000
+++ b/www/firefox/distinfo Sun Apr 29 13:27:08 2018 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.312 2018/04/14 07:05:14 ryoon Exp $
+$NetBSD: distinfo,v 1.313 2018/04/29 13:27:08 martin Exp $
SHA1 (firefox-59.0.2.tar.bz2) = 8fcf726b4d23716c7ff2b7ebc6527782b5bafe9c
RMD160 (firefox-59.0.2.tar.bz2) = ff7ab2f9da93eda98de8aecb4563cfd176b896d9
@@ -79,6 +79,10 @@
SHA1 (patch-toolkit_moz.configure) = 78f5c46931ae3426e65eddbea7e0552bcc6a19e0
SHA1 (patch-toolkit_mozapps_installer_packager.mk) = 6f557fb732f0b9dabf059ffac0400d3db4e79e47
SHA1 (patch-toolkit_xre_glxtest.cpp) = cf048491778610454b914400e53072afedd96e7b
+SHA1 (patch-widget_gtk_nsClipboard.cpp) = 0a56631f05c2ead36b7a80a3cfe0ee7621047df1
+SHA1 (patch-widget_gtk_nsClipboard.h) = fab72d12326b9cef1a2041fa3d3eb2794e85d349
+SHA1 (patch-widget_gtk_nsClipboardX11.cpp) = 684ae1bc2fdca6edc4928b635d100435f8ecbf60
+SHA1 (patch-widget_gtk_nsClipboardX11.h) = 2902af4227b65e0594dcb2ef6fbd16d6d0850f58
SHA1 (patch-xpcom_base_nscore.h) = d7c96eda884d7f370442749c43caba50da61bbe4
SHA1 (patch-xpcom_build_BinaryPath.h) = 88a815a142356bf76024e5a4326b677122c844c1
SHA1 (patch-xpcom_build_XPCOMInit.cpp) = 1e7cc3a7fd9515b10307fafa2b01ed689320bd54
diff -r bea80059ee5c -r 41a7b18a5d4d www/firefox/patches/patch-widget_gtk_nsClipboard.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/www/firefox/patches/patch-widget_gtk_nsClipboard.cpp Sun Apr 29 13:27:08 2018 +0000
@@ -0,0 +1,30 @@
+$NetBSD: patch-widget_gtk_nsClipboard.cpp,v 1.1 2018/04/29 13:27:08 martin Exp $
+
+Upstream fixes for Bug 1447925 -
+ Add GetClipboardText() to get text data from clipboard
+ Use GetClipboardText() to get text data at nsClipboard::GetData()
+
+--- widget/gtk/nsClipboard.cpp.orig 2018-04-29 12:56:52.405590187 +0000
++++ widget/gtk/nsClipboard.cpp
+@@ -301,11 +301,8 @@ nsClipboard::GetData(nsITransferable *aT
+ // 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
+@@ -314,7 +311,7 @@ nsClipboard::GetData(nsITransferable *aT
+ }
+
+ // 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,
diff -r bea80059ee5c -r 41a7b18a5d4d www/firefox/patches/patch-widget_gtk_nsClipboard.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/www/firefox/patches/patch-widget_gtk_nsClipboard.h Sun Apr 29 13:27:08 2018 +0000
@@ -0,0 +1,30 @@
+$NetBSD: patch-widget_gtk_nsClipboard.h,v 1.1 2018/04/29 13:27:08 martin Exp $
+
+Upstream fixes for Bug 1447925 -
+ Add GetClipboardText() to get text data from clipboard
+ Use GetClipboardText() to get text data at nsClipboard::GetData()
+
+--- widget/gtk/nsClipboard.h.orig 2018-04-29 12:56:52.405642009 +0000
++++ widget/gtk/nsClipboard.h
+@@ -13,16 +13,18 @@
+ #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;
+
diff -r bea80059ee5c -r 41a7b18a5d4d www/firefox/patches/patch-widget_gtk_nsClipboardX11.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/www/firefox/patches/patch-widget_gtk_nsClipboardX11.cpp Sun Apr 29 13:27:08 2018 +0000
@@ -0,0 +1,264 @@
+$NetBSD: patch-widget_gtk_nsClipboardX11.cpp,v 1.1 2018/04/29 13:27:08 martin Exp $
+
+Upstream fixes for Bug 1447925 -
+ Add GetClipboardText() to get text data from clipboard
+ Use GetClipboardText() to get text data at nsClipboard::GetData()
+
+--- widget/gtk/nsClipboardX11.cpp.orig 2018-04-29 12:56:52.405706053 +0000
++++ widget/gtk/nsClipboardX11.cpp
+@@ -62,8 +62,10 @@ selection_request_filter(GdkXEvent *gdk_
+
+ nsRetrievalContextX11::nsRetrievalContextX11()
+ : mState(INITIAL)
+- , mData(nullptr)
+ , mClipboardRequestNumber(0)
++ , mClipboardData(nullptr)
++ , mClipboardDataLength(0)
++ , mTargetMIMEType(gdk_atom_intern("TARGETS", FALSE))
+ {
+ // A custom event filter to workaround attempting to dereference a null
+ // selection requestor in GTK3 versions before 3.11.3. See bug 1178799.
+@@ -139,13 +141,11 @@ checkEventProc(Display *display, XEvent
+ return False;
+ }
+
+-void *
+-nsRetrievalContextX11::Wait()
++bool
++nsRetrievalContextX11::WaitForX11Content()
+ {
+ if (mState == COMPLETED) { // the request completed synchronously
+- void *data = mData;
+- mData = nullptr;
+- return data;
++ return true;
+ }
+
+ GdkDisplay *gdkDisplay = gdk_display_get_default();
+@@ -181,9 +181,7 @@ nsRetrievalContextX11::Wait()
+ DispatchPropertyNotifyEvent(context.cbWidget, &xevent);
+
+ if (mState == COMPLETED) {
+- void *data = mData;
+- mData = nullptr;
+- return data;
++ return true;
+ }
+ }
+
+@@ -200,11 +198,12 @@ nsRetrievalContextX11::Wait()
+ printf("exceeded clipboard timeout\n");
+ #endif
+ mState = TIMED_OUT;
+- return nullptr;
++ return false;
+ }
+
+ // Call this when data has been retrieved.
+-void nsRetrievalContextX11::Complete(GtkSelectionData* aData,
++void nsRetrievalContextX11::Complete(ClipboardDataType aDataType,
++ const void* aData,
+ int aDataRequestNumber)
+ {
+ if (mClipboardRequestNumber != aDataRequestNumber) {
+@@ -214,8 +213,54 @@ void nsRetrievalContextX11::Complete(Gtk
+
+ if (mState == INITIAL) {
+ mState = COMPLETED;
+- mData = gtk_selection_data_get_length(aData) >= 0 ?
+- gtk_selection_data_copy(aData) : nullptr;
++
++ MOZ_ASSERT(mClipboardData == nullptr &&
++ mClipboardDataLength == 0,
++ "We're leaking clipboard data!");
++
++ switch (aDataType) {
++ case CLIPBOARD_TEXT:
++ {
++ const char* text = static_cast<const char*>(aData);
++ if (text) {
++ mClipboardDataLength = sizeof(char) * (strlen(text) + 1);
++ mClipboardData = moz_xmalloc(mClipboardDataLength);
++ memcpy(mClipboardData, text, mClipboardDataLength);
++ }
++ }
++ break;
++ case CLIPBOARD_TARGETS:
++ {
++ const GtkSelectionData *selection =
++ static_cast<const GtkSelectionData *>(aData);
++
++ gint n_targets = 0;
++ GdkAtom *targets = nullptr;
++
++ if (!gtk_selection_data_get_targets(selection, &targets, &n_targets) ||
++ !n_targets) {
++ return;
++ }
++
++ mClipboardData = targets;
++ mClipboardDataLength = n_targets;
++ }
++ break;
++ case CLIPBOARD_DATA:
++ {
++ const GtkSelectionData *selection =
++ static_cast<const GtkSelectionData *>(aData);
++
++ gint dataLength = gtk_selection_data_get_length(selection);
++ if (dataLength > 0) {
++ mClipboardDataLength = dataLength;
++ mClipboardData = moz_xmalloc(dataLength);
++ memcpy(mClipboardData, gtk_selection_data_get_data(selection),
++ dataLength);
++ }
++ }
++ break;
++ }
+ } else {
+ // Already timed out
+ MOZ_ASSERT(mState == TIMED_OUT);
+@@ -233,12 +278,24 @@ clipboard_contents_received(GtkClipboard
+ delete handler;
+ }
+
+-GtkSelectionData*
+-nsRetrievalContextX11::WaitForContents(GtkClipboard *clipboard,
+- const char *aMimeType)
++static void
++clipboard_text_received(GtkClipboard *clipboard,
++ const gchar *text,
++ gpointer data)
++{
++ ClipboardRequestHandler *handler =
++ static_cast<ClipboardRequestHandler*>(data);
++ handler->Complete(text);
++ delete handler;
++}
++
++bool
++nsRetrievalContextX11::WaitForClipboardData(ClipboardDataType aDataType,
++ GtkClipboard *clipboard,
++ const char *aMimeType)
+ {
+ mState = INITIAL;
+- NS_ASSERTION(!mData, "Leaking clipboard content!");
++ NS_ASSERTION(!mClipboardData, "Leaking clipboard content!");
+
+ // Call ClipboardRequestHandler() with unique clipboard request number.
+ // The request number pairs gtk_clipboard_request_contents() data request
+@@ -246,39 +303,45 @@ nsRetrievalContextX11::WaitForContents(G
+ // is provided by Gtk.
+ mClipboardRequestNumber++;
+ ClipboardRequestHandler* handler =
+- new ClipboardRequestHandler(this, mClipboardRequestNumber);
++ new ClipboardRequestHandler(this, aDataType, mClipboardRequestNumber);
++
++ switch (aDataType) {
++ case CLIPBOARD_DATA:
++ gtk_clipboard_request_contents(clipboard,
++ gdk_atom_intern(aMimeType, FALSE), clipboard_contents_received,
++ handler);
++ break;
++ case CLIPBOARD_TEXT:
++ gtk_clipboard_request_text(clipboard, clipboard_text_received,
++ handler);
++ break;
++ case CLIPBOARD_TARGETS:
++ gtk_clipboard_request_contents(clipboard,
++ mTargetMIMEType, clipboard_contents_received,
++ handler);
++ break;
++ }
+
+- gtk_clipboard_request_contents(clipboard,
+- gdk_atom_intern(aMimeType, FALSE),
+- clipboard_contents_received,
+- handler);
+- return static_cast<GtkSelectionData*>(Wait());
++ return WaitForX11Content();
+ }
+
+ GdkAtom*
+ nsRetrievalContextX11::GetTargets(int32_t aWhichClipboard, int* aTargetNums)
+ {
+- *aTargetNums = 0;
+-
+- GtkClipboard *clipboard =
+- gtk_clipboard_get(GetSelectionAtom(aWhichClipboard));
+-
+- GtkSelectionData *selection_data = WaitForContents(clipboard, "TARGETS");
+- if (!selection_data)
+- return nullptr;
++ GtkClipboard *clipboard =
++ gtk_clipboard_get(GetSelectionAtom(aWhichClipboard));
+
+- gint n_targets = 0;
+- GdkAtom *targets = nullptr;
++ if (!WaitForClipboardData(CLIPBOARD_TARGETS, clipboard))
++ return nullptr;
+
+- if (!gtk_selection_data_get_targets(selection_data, &targets, &n_targets) ||
+- !n_targets) {
+- return nullptr;
+- }
++ *aTargetNums = mClipboardDataLength;
++ GdkAtom* targets = static_cast<GdkAtom*>(mClipboardData);
+
+- gtk_selection_data_free(selection_data);
Home |
Main Index |
Thread Index |
Old Index