Title: [187580] trunk/Source/WebCore
Revision
187580
Author
[email protected]
Date
2015-07-29 23:39:59 -0700 (Wed, 29 Jul 2015)

Log Message

[GTK] Paste data is removed from clipboard when closing browser tab
https://bugs.webkit.org/show_bug.cgi?id=144549

Reviewed by Martin Robinson.

GTK+ stores all clipboards in gtk_main or gtk_application_shutdown
when the main loop finishes. We don't use gtk_main() in the web
process, so we need to do the same and store all clipboards on
process shutdown.

* platform/gtk/PasteboardGtk.cpp:
(WebCore::Pasteboard::Pasteboard): Register the GtkClipboard.
* platform/gtk/PasteboardHelper.cpp:
(WebCore::PasteboardHelper::singleton): Make it destructible.
(WebCore::PasteboardHelper::~PasteboardHelper): Call
gtk_clipboard_store for every registered GtkClipboard.
(WebCore::PasteboardHelper::registerClipboard): Save the given
GtkClipboard.
* platform/gtk/PasteboardHelper.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (187579 => 187580)


--- trunk/Source/WebCore/ChangeLog	2015-07-30 06:26:52 UTC (rev 187579)
+++ trunk/Source/WebCore/ChangeLog	2015-07-30 06:39:59 UTC (rev 187580)
@@ -1,3 +1,25 @@
+2015-07-29  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Paste data is removed from clipboard when closing browser tab
+        https://bugs.webkit.org/show_bug.cgi?id=144549
+
+        Reviewed by Martin Robinson.
+
+        GTK+ stores all clipboards in gtk_main or gtk_application_shutdown
+        when the main loop finishes. We don't use gtk_main() in the web
+        process, so we need to do the same and store all clipboards on
+        process shutdown.
+
+        * platform/gtk/PasteboardGtk.cpp:
+        (WebCore::Pasteboard::Pasteboard): Register the GtkClipboard.
+        * platform/gtk/PasteboardHelper.cpp:
+        (WebCore::PasteboardHelper::singleton): Make it destructible.
+        (WebCore::PasteboardHelper::~PasteboardHelper): Call
+        gtk_clipboard_store for every registered GtkClipboard.
+        (WebCore::PasteboardHelper::registerClipboard): Save the given
+        GtkClipboard.
+        * platform/gtk/PasteboardHelper.h:
+
 2015-07-29  Andy VanWagoner  <[email protected]>
 
         Implement basic types for ECMAScript Internationalization API

Modified: trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp (187579 => 187580)


--- trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp	2015-07-30 06:26:52 UTC (rev 187579)
+++ trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp	2015-07-30 06:39:59 UTC (rev 187580)
@@ -76,7 +76,7 @@
 
 Pasteboard::Pasteboard(PassRefPtr<DataObjectGtk> dataObject)
     : m_dataObject(dataObject)
-    , m_gtkClipboard(0)
+    , m_gtkClipboard(nullptr)
 {
     ASSERT(m_dataObject);
 }
@@ -86,6 +86,7 @@
     , m_gtkClipboard(gtkClipboard)
 {
     ASSERT(m_dataObject);
+    PasteboardHelper::singleton().registerClipboard(gtkClipboard);
 }
 
 Pasteboard::~Pasteboard()

Modified: trunk/Source/WebCore/platform/gtk/PasteboardHelper.cpp (187579 => 187580)


--- trunk/Source/WebCore/platform/gtk/PasteboardHelper.cpp	2015-07-30 06:26:52 UTC (rev 187579)
+++ trunk/Source/WebCore/platform/gtk/PasteboardHelper.cpp	2015-07-30 06:39:59 UTC (rev 187580)
@@ -53,7 +53,7 @@
 
 PasteboardHelper& PasteboardHelper::singleton()
 {
-    static NeverDestroyed<PasteboardHelper> helper;
+    static PasteboardHelper helper;
     return helper;
 }
 
@@ -75,6 +75,12 @@
     gtk_target_list_add(m_targetList.get(), unknownAtom, 0, PasteboardHelper::TargetTypeUnknown);
 }
 
+PasteboardHelper::~PasteboardHelper()
+{
+    for (auto* clipboard : m_gtkClipboards)
+        gtk_clipboard_store(clipboard);
+}
+
 GtkTargetList* PasteboardHelper::targetList() const
 {
     return m_targetList.get();
@@ -316,5 +322,11 @@
     return gtk_clipboard_wait_is_target_available(clipboard, smartPasteAtom);
 }
 
+void PasteboardHelper::registerClipboard(GtkClipboard* clipboard)
+{
+    ASSERT(clipboard);
+    m_gtkClipboards.add(clipboard);
 }
 
+}
+

Modified: trunk/Source/WebCore/platform/gtk/PasteboardHelper.h (187579 => 187580)


--- trunk/Source/WebCore/platform/gtk/PasteboardHelper.h	2015-07-30 06:26:52 UTC (rev 187579)
+++ trunk/Source/WebCore/platform/gtk/PasteboardHelper.h	2015-07-30 06:39:59 UTC (rev 187580)
@@ -25,7 +25,7 @@
 #ifndef PasteboardHelper_h
 #define PasteboardHelper_h
 
-#include <wtf/NeverDestroyed.h>
+#include <wtf/HashSet.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/Vector.h>
 #include <wtf/glib/GRefPtr.h>
@@ -52,13 +52,14 @@
     enum PasteboardTargetType { TargetTypeMarkup, TargetTypeText, TargetTypeImage, TargetTypeURIList, TargetTypeNetscapeURL, TargetTypeSmartPaste, TargetTypeUnknown };
     bool clipboardContentSupportsSmartReplace(GtkClipboard*);
 
+    void registerClipboard(GtkClipboard*);
+
 private:
     PasteboardHelper();
-    ~PasteboardHelper() = delete;
+    ~PasteboardHelper();
 
     GRefPtr<GtkTargetList> m_targetList;
-
-    friend class WTF::NeverDestroyed<PasteboardHelper>;
+    HashSet<GtkClipboard*> m_gtkClipboards;
 };
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to