<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[205909] trunk/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/205909">205909</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-09-14 09:45:48 -0700 (Wed, 14 Sep 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>[GTK][Wayland] Implement clipboard support
https://bugs.webkit.org/show_bug.cgi?id=146574
Patch by Carlos Garnacho <carlosg@gnome.org> on 2016-09-14
Reviewed by Carlos Garcia Campos.
Source/WebCore:
Implement PlatformPasteboard in the GTK+ platform, and move Pasteboard
to using PasteboardStrategy so clipboard management is left to the
UIProcess.
DataObjectGtk is still used in the Pasteboard GTK implementation, it's
now just never backed by a GtkClipboard, this object is instead
serialized through PasteboardStrategy, so the UIProcess side can mirror
the content in a GtkClipboard-backed DataObjectGtk, which is then
exposed to the windowing through PlatformPasteboard/PasteboardHelper.
When requesting clipboard content, it works similarly, the UIProcess
side first updates its DataObjectGtk, which is then mirrored by the
WebProcess through the PasteboardStrategy requests.
* PlatformGTK.cmake: Added PlatformPasteboardGtk.cpp
* editing/gtk/EditorGtk.cpp:
(WebCore::Editor::writeSelectionToPasteboard): Eliminate usage of
PasteboardWebContent callback argument. This is done differently as
we have to signal back the WebProcess.
* platform/Pasteboard.h: Cleaned up of direct GTK+ dependency.
* platform/PasteboardStrategy.h: Added plumbing towards the pasteboard
proxy.
* platform/PlatformPasteboard.h:
* platform/gtk/DataObjectGtk.cpp:
(WebCore::DataObjectGtk::clearAllExceptFilenames): Clear the "smart
paste" flag if set, now that this is DataObjectGtk data.
* platform/gtk/DataObjectGtk.h:
(WebCore::DataObjectGtk::canSmartReplace):
(WebCore::DataObjectGtk::setCanSmartReplace): Added functions, in order
to flag whether a DataObjectGtk has the "smart paste" feature enabled
or not.
* platform/gtk/PasteboardGtk.cpp:
(WebCore::Pasteboard::createForCopyAndPaste):
(WebCore::Pasteboard::createForGlobalSelection):
(WebCore::Pasteboard::Pasteboard):
(WebCore::Pasteboard::writeToClipboard):
(WebCore::Pasteboard::readFromClipboard):
(WebCore::Pasteboard::writePlainText):
(WebCore::Pasteboard::write):
(WebCore::Pasteboard::writePasteboard):
(WebCore::Pasteboard::clear):
(WebCore::Pasteboard::canSmartReplace):
(WebCore::Pasteboard::read):
(WebCore::Pasteboard::hasData):
(WebCore::Pasteboard::types):
(WebCore::Pasteboard::readString):
(WebCore::Pasteboard::readFilenames): Made to use the
PasteboardStrategy instead of PasteboardHelper/GTK+ API.
* platform/gtk/PasteboardHelper.cpp:
(WebCore::PasteboardHelper::~PasteboardHelper):
(WebCore::ClipboardSetData::ClipboardSetData):
(WebCore::clearClipboardContentsCallback):
(WebCore::PasteboardHelper::writeClipboardContents): Remove the GClosure
to notify whether the global selection has been replaced. Use std:function
instead. Remove SmartPasteInclusion argument, now figured out through
DataObjectGtk canSmartPaste() member.
* platform/gtk/PasteboardHelper.h:
* platform/gtk/PlatformPasteboardGtk.cpp: Added.
(WebCore::PlatformPasteboard::PlatformPasteboard):
(WebCore::PlatformPasteboard::writeToClipboard):
(WebCore::PlatformPasteboard::readFromClipboard): Implemented
PlatformPasteboard using PasteboardHelper/GTK+ API.
Source/WebKit2:
Add the necessary plumbing for the GTK+ backend to use the
PlatformPasteboard in WebCore. All selection data is transmitted
at once through the serialization of PasteboardContentGtk/DataObjectGtk.
* PlatformGTK.cmake: Add PasteboardContentGtk.cpp and
WebPasteboardProxyGtk.cpp
* Shared/gtk/ArgumentCodersGtk.cpp:
(IPC::encode):
(IPC::decode): Renamed from encodeDataObject/decodeDataObject
and made public.
(IPC::ArgumentCoder<DragData>::encode):
(IPC::ArgumentCoder<DragData>::decode): Update DataObjectGtk
encode/decode callers. Encode the extra canSmartReplace field.
* Shared/gtk/ArgumentCodersGtk.h: Expose encode/decode methods for
DataObjectGtk.
* Shared/gtk/PasteboardContent.cpp: Added. Wraps a DataObjectGtk
so it can be serialized on WebProcess/UIProcess messaging.
(WebKit::PasteboardContent::PasteboardContent):
(WebKit::PasteboardContent::encode):
(WebKit::PasteboardContent::decode): Methods to encode/decode a
PasteboardContent.
* Shared/gtk/PasteboardContent.h: Added.
* UIProcess/WebFrameProxy.cpp:
(WebKit::WebFrameProxy::collapseSelection): Added plumbing to allow
collapsing the global selection from the UI process side.
* UIProcess/WebFrameProxy.h:
* UIProcess/WebPasteboardProxy.h:
* UIProcess/WebPasteboardProxy.messages.in: Added plumbing for the
GTK+ pasteboard proxy functions.
* UIProcess/gtk/WebPageProxyGtk.cpp:
(WebKit::WebPageProxy::editorStateChanged):
* UIProcess/gtk/WebPasteboardProxyGtk.cpp: Added.
(WebKit::WebPasteboardProxy::writeToClipboard):
(WebKit::WebPasteboardProxy::readFromClipboard): Implemented functions
hooking into the PlatformPasteboard. Per-selection (ie.
primary/clipboard) PlatformPasteboards are kept at this level, so those
are independently set and dealt with.
(WebKit::WebPasteboardProxy::setPrimarySelectionOwner):
(WebKit::WebPasteboardProxy::didDestroyFrame): Implemented functions
to manage the frame currently being currently interacted, so we can
signal back when the global selection has been replaced.
* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::writeToClipboard):
(WebKit::WebPlatformStrategies::readFromClipboard): Added methods to
send the WebProcess->UIProcess messages.
* WebProcess/WebCoreSupport/WebPlatformStrategies.h:
* WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:
(WebKit::WebEditorClient::updateGlobalSelection): Remove GClosure to
get notifications about changes in global selection ownership. This
is done through a WebPage message now, as the UI process manages the
clipboard.
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/gtk/WebPageGtk.cpp:
(WebKit::WebPage::collapseSelectionInFrame): Added methods to send
the UIProcess->WebProcess notification that the global selection has
been replaced.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorePlatformGTKcmake">trunk/Source/WebCore/PlatformGTK.cmake</a></li>
<li><a href="#trunkSourceWebCoreeditinggtkEditorGtkcpp">trunk/Source/WebCore/editing/gtk/EditorGtk.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformPasteboardh">trunk/Source/WebCore/platform/Pasteboard.h</a></li>
<li><a href="#trunkSourceWebCoreplatformPasteboardStrategyh">trunk/Source/WebCore/platform/PasteboardStrategy.h</a></li>
<li><a href="#trunkSourceWebCoreplatformPlatformPasteboardh">trunk/Source/WebCore/platform/PlatformPasteboard.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgtkDataObjectGtkcpp">trunk/Source/WebCore/platform/gtk/DataObjectGtk.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgtkDataObjectGtkh">trunk/Source/WebCore/platform/gtk/DataObjectGtk.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgtkPasteboardGtkcpp">trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgtkPasteboardHelpercpp">trunk/Source/WebCore/platform/gtk/PasteboardHelper.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgtkPasteboardHelperh">trunk/Source/WebCore/platform/gtk/PasteboardHelper.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2PlatformGTKcmake">trunk/Source/WebKit2/PlatformGTK.cmake</a></li>
<li><a href="#trunkSourceWebKit2SharedgtkArgumentCodersGtkcpp">trunk/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedgtkArgumentCodersGtkh">trunk/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebFrameProxycpp">trunk/Source/WebKit2/UIProcess/WebFrameProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebFrameProxyh">trunk/Source/WebKit2/UIProcess/WebFrameProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPasteboardProxyh">trunk/Source/WebKit2/UIProcess/WebPasteboardProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPasteboardProxymessagesin">trunk/Source/WebKit2/UIProcess/WebPasteboardProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkWebPageProxyGtkcpp">trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebPlatformStrategiescpp">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebPlatformStrategiesh">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportgtkWebEditorClientGtkcpp">trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPageh">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagemessagesin">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagegtkWebPageGtkcpp">trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgtkPlatformPasteboardGtkcpp">trunk/Source/WebCore/platform/gtk/PlatformPasteboardGtk.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedgtkPasteboardContentcpp">trunk/Source/WebKit2/Shared/gtk/PasteboardContent.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedgtkPasteboardContenth">trunk/Source/WebKit2/Shared/gtk/PasteboardContent.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkWebPasteboardProxyGtkcpp">trunk/Source/WebKit2/UIProcess/gtk/WebPasteboardProxyGtk.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebCore/ChangeLog        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -1,3 +1,73 @@
</span><ins>+2016-09-14 Carlos Garnacho <carlosg@gnome.org>
+
+ [GTK][Wayland] Implement clipboard support
+ https://bugs.webkit.org/show_bug.cgi?id=146574
+
+ Reviewed by Carlos Garcia Campos.
+
+ Implement PlatformPasteboard in the GTK+ platform, and move Pasteboard
+ to using PasteboardStrategy so clipboard management is left to the
+ UIProcess.
+
+ DataObjectGtk is still used in the Pasteboard GTK implementation, it's
+ now just never backed by a GtkClipboard, this object is instead
+ serialized through PasteboardStrategy, so the UIProcess side can mirror
+ the content in a GtkClipboard-backed DataObjectGtk, which is then
+ exposed to the windowing through PlatformPasteboard/PasteboardHelper.
+
+ When requesting clipboard content, it works similarly, the UIProcess
+ side first updates its DataObjectGtk, which is then mirrored by the
+ WebProcess through the PasteboardStrategy requests.
+
+ * PlatformGTK.cmake: Added PlatformPasteboardGtk.cpp
+ * editing/gtk/EditorGtk.cpp:
+ (WebCore::Editor::writeSelectionToPasteboard): Eliminate usage of
+ PasteboardWebContent callback argument. This is done differently as
+ we have to signal back the WebProcess.
+ * platform/Pasteboard.h: Cleaned up of direct GTK+ dependency.
+ * platform/PasteboardStrategy.h: Added plumbing towards the pasteboard
+ proxy.
+ * platform/PlatformPasteboard.h:
+ * platform/gtk/DataObjectGtk.cpp:
+ (WebCore::DataObjectGtk::clearAllExceptFilenames): Clear the "smart
+ paste" flag if set, now that this is DataObjectGtk data.
+ * platform/gtk/DataObjectGtk.h:
+ (WebCore::DataObjectGtk::canSmartReplace):
+ (WebCore::DataObjectGtk::setCanSmartReplace): Added functions, in order
+ to flag whether a DataObjectGtk has the "smart paste" feature enabled
+ or not.
+ * platform/gtk/PasteboardGtk.cpp:
+ (WebCore::Pasteboard::createForCopyAndPaste):
+ (WebCore::Pasteboard::createForGlobalSelection):
+ (WebCore::Pasteboard::Pasteboard):
+ (WebCore::Pasteboard::writeToClipboard):
+ (WebCore::Pasteboard::readFromClipboard):
+ (WebCore::Pasteboard::writePlainText):
+ (WebCore::Pasteboard::write):
+ (WebCore::Pasteboard::writePasteboard):
+ (WebCore::Pasteboard::clear):
+ (WebCore::Pasteboard::canSmartReplace):
+ (WebCore::Pasteboard::read):
+ (WebCore::Pasteboard::hasData):
+ (WebCore::Pasteboard::types):
+ (WebCore::Pasteboard::readString):
+ (WebCore::Pasteboard::readFilenames): Made to use the
+ PasteboardStrategy instead of PasteboardHelper/GTK+ API.
+ * platform/gtk/PasteboardHelper.cpp:
+ (WebCore::PasteboardHelper::~PasteboardHelper):
+ (WebCore::ClipboardSetData::ClipboardSetData):
+ (WebCore::clearClipboardContentsCallback):
+ (WebCore::PasteboardHelper::writeClipboardContents): Remove the GClosure
+ to notify whether the global selection has been replaced. Use std:function
+ instead. Remove SmartPasteInclusion argument, now figured out through
+ DataObjectGtk canSmartPaste() member.
+ * platform/gtk/PasteboardHelper.h:
+ * platform/gtk/PlatformPasteboardGtk.cpp: Added.
+ (WebCore::PlatformPasteboard::PlatformPasteboard):
+ (WebCore::PlatformPasteboard::writeToClipboard):
+ (WebCore::PlatformPasteboard::readFromClipboard): Implemented
+ PlatformPasteboard using PasteboardHelper/GTK+ API.
+
</ins><span class="cx"> 2016-09-13 Dave Hyatt <hyatt@apple.com>
</span><span class="cx">
</span><span class="cx"> [CSS Parser] Enable the new sizes parser by default
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformGTK.cmake (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformGTK.cmake        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebCore/PlatformGTK.cmake        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -221,6 +221,7 @@
</span><span class="cx"> platform/gtk/PasteboardHelper.cpp
</span><span class="cx"> platform/gtk/PlatformKeyboardEventGtk.cpp
</span><span class="cx"> platform/gtk/PlatformMouseEventGtk.cpp
</span><ins>+ platform/gtk/PlatformPasteboardGtk.cpp
</ins><span class="cx"> platform/gtk/PlatformScreenGtk.cpp
</span><span class="cx"> platform/gtk/PlatformWheelEventGtk.cpp
</span><span class="cx"> platform/gtk/RenderThemeGadget.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreeditinggtkEditorGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/gtk/EditorGtk.cpp (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/gtk/EditorGtk.cpp        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebCore/editing/gtk/EditorGtk.cpp        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -125,7 +125,6 @@
</span><span class="cx"> pasteboardContent.canSmartCopyOrDelete = canSmartCopyOrDelete();
</span><span class="cx"> pasteboardContent.text = selectedTextForDataTransfer();
</span><span class="cx"> pasteboardContent.markup = createMarkup(*selectedRange(), nullptr, AnnotateForInterchange, false, ResolveNonLocalURLs);
</span><del>- pasteboardContent.callback = nullptr;
</del><span class="cx"> pasteboard.write(pasteboardContent);
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformPasteboardh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/Pasteboard.h (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/Pasteboard.h        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebCore/platform/Pasteboard.h        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -32,11 +32,6 @@
</span><span class="cx"> #include <wtf/Vector.h>
</span><span class="cx"> #include <wtf/text/WTFString.h>
</span><span class="cx">
</span><del>-#if PLATFORM(GTK)
-typedef struct _GtkClipboard GtkClipboard;
-#include <wtf/glib/GRefPtr.h>
-#endif
-
</del><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> OBJC_CLASS NSArray;
</span><span class="cx"> OBJC_CLASS NSString;
</span><span class="lines">@@ -83,7 +78,6 @@
</span><span class="cx"> bool canSmartCopyOrDelete;
</span><span class="cx"> String text;
</span><span class="cx"> String markup;
</span><del>- GRefPtr<GClosure> callback;
</del><span class="cx"> #endif
</span><span class="cx"> };
</span><span class="cx">
</span><span class="lines">@@ -143,8 +137,8 @@
</span><span class="cx"> ~Pasteboard();
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(GTK)
</span><ins>+ explicit Pasteboard(const String& name);
</ins><span class="cx"> explicit Pasteboard(RefPtr<DataObjectGtk>&&);
</span><del>- explicit Pasteboard(GtkClipboard*);
</del><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(WIN)
</span><span class="lines">@@ -226,8 +220,11 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(GTK)
</span><ins>+ enum class ShouldIncludeSmartPaste { No, Yes };
+ void writeToClipboard(ShouldIncludeSmartPaste = ShouldIncludeSmartPaste::No);
+ void readFromClipboard();
</ins><span class="cx"> RefPtr<DataObjectGtk> m_dataObject;
</span><del>- GtkClipboard* m_gtkClipboard;
</del><ins>+ String m_name;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformPasteboardStrategyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/PasteboardStrategy.h (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/PasteboardStrategy.h        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebCore/platform/PasteboardStrategy.h        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -38,6 +38,10 @@
</span><span class="cx"> struct PasteboardImage;
</span><span class="cx"> struct PasteboardWebContent;
</span><span class="cx">
</span><ins>+#if PLATFORM(GTK)
+class DataObjectGtk;
+#endif
+
</ins><span class="cx"> class PasteboardStrategy {
</span><span class="cx"> public:
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="lines">@@ -68,6 +72,10 @@
</span><span class="cx"> virtual long setPathnamesForType(const Vector<String>&, const String& pasteboardType, const String& pasteboardName) = 0;
</span><span class="cx"> virtual long setStringForType(const String&, const String& pasteboardType, const String& pasteboardName) = 0;
</span><span class="cx"> #endif
</span><ins>+#if PLATFORM(GTK)
+ virtual void writeToClipboard(const String& pasteboardName, const RefPtr<DataObjectGtk>&) = 0;
+ virtual RefPtr<DataObjectGtk> readFromClipboard(const String& pasteboardName) = 0;
+#endif // PLATFORM(GTK)
</ins><span class="cx"> protected:
</span><span class="cx"> virtual ~PasteboardStrategy()
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformPlatformPasteboardh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/PlatformPasteboard.h (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/PlatformPasteboard.h        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebCore/platform/PlatformPasteboard.h        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -47,6 +47,10 @@
</span><span class="cx"> struct PasteboardImage;
</span><span class="cx"> struct PasteboardWebContent;
</span><span class="cx">
</span><ins>+#if PLATFORM(GTK)
+class DataObjectGtk;
+#endif
+
</ins><span class="cx"> class PlatformPasteboard {
</span><span class="cx"> public:
</span><span class="cx"> // FIXME: probably we don't need a constructor that takes a pasteboard name for iOS.
</span><span class="lines">@@ -81,6 +85,11 @@
</span><span class="cx"> WEBCORE_EXPORT URL readURL(int index, const String& pasteboardType);
</span><span class="cx"> WEBCORE_EXPORT int count();
</span><span class="cx">
</span><ins>+#if PLATFORM(GTK)
+ WEBCORE_EXPORT void writeToClipboard(const RefPtr<DataObjectGtk>&, std::function<void()>&& primarySelectionCleared);
+ WEBCORE_EXPORT RefPtr<DataObjectGtk> readFromClipboard();
+#endif
+
</ins><span class="cx"> private:
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> RetainPtr<NSPasteboard> m_pasteboard;
</span><span class="lines">@@ -88,6 +97,9 @@
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> RetainPtr<UIPasteboard> m_pasteboard;
</span><span class="cx"> #endif
</span><ins>+#if PLATFORM(GTK)
+ GtkClipboard* m_clipboard;
+#endif
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkDataObjectGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/gtk/DataObjectGtk.cpp (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/DataObjectGtk.cpp        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebCore/platform/gtk/DataObjectGtk.cpp        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -139,6 +139,7 @@
</span><span class="cx"> m_url = URL();
</span><span class="cx"> m_image = nullptr;
</span><span class="cx"> m_unknownTypeData.clear();
</span><ins>+ m_canSmartReplace = false;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void DataObjectGtk::clearAll()
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkDataObjectGtkh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/gtk/DataObjectGtk.h (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/DataObjectGtk.h        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebCore/platform/gtk/DataObjectGtk.h        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -47,6 +47,7 @@
</span><span class="cx"> bool hasURL() const { return !m_url.isEmpty() && m_url.isValid(); }
</span><span class="cx"> bool hasFilenames() const { return !m_filenames.isEmpty(); }
</span><span class="cx"> bool hasImage() const { return m_image; }
</span><ins>+ bool canSmartReplace() const { return m_canSmartReplace; }
</ins><span class="cx"> void clearURIList() { m_uriList = emptyString(); }
</span><span class="cx"> void clearURL() { m_url = URL(); }
</span><span class="cx"> void clearImage() { m_image = nullptr; }
</span><span class="lines">@@ -59,6 +60,7 @@
</span><span class="cx"> void setMarkup(const String&);
</span><span class="cx"> void setUnknownTypeData(const String& type, const String& data) { m_unknownTypeData.set(type, data); }
</span><span class="cx"> void setURIList(const String&);
</span><ins>+ void setCanSmartReplace(bool canSmartReplace) { m_canSmartReplace = canSmartReplace; }
</ins><span class="cx"> String urlLabel() const;
</span><span class="cx">
</span><span class="cx"> void clearAllExceptFilenames();
</span><span class="lines">@@ -74,6 +76,7 @@
</span><span class="cx"> Vector<String> m_filenames;
</span><span class="cx"> GRefPtr<GdkPixbuf> m_image;
</span><span class="cx"> HashMap<String, String> m_unknownTypeData;
</span><ins>+ bool m_canSmartReplace { false };
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkPasteboardGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -23,9 +23,10 @@
</span><span class="cx"> #include "DataObjectGtk.h"
</span><span class="cx"> #include "DragData.h"
</span><span class="cx"> #include "Image.h"
</span><ins>+#include "PasteboardStrategy.h"
+#include "PlatformStrategies.h"
</ins><span class="cx"> #include "URL.h"
</span><del>-#include "PasteboardHelper.h"
-#include <gtk/gtk.h>
</del><ins>+#include <wtf/NeverDestroyed.h>
</ins><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="lines">@@ -40,12 +41,12 @@
</span><span class="cx">
</span><span class="cx"> std::unique_ptr<Pasteboard> Pasteboard::createForCopyAndPaste()
</span><span class="cx"> {
</span><del>- return std::make_unique<Pasteboard>(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD));
</del><ins>+ return std::make_unique<Pasteboard>("CLIPBOARD");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> std::unique_ptr<Pasteboard> Pasteboard::createForGlobalSelection()
</span><span class="cx"> {
</span><del>- return std::make_unique<Pasteboard>(gtk_clipboard_get(GDK_SELECTION_PRIMARY));
</del><ins>+ return std::make_unique<Pasteboard>("PRIMARY");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> std::unique_ptr<Pasteboard> Pasteboard::createPrivate()
</span><span class="lines">@@ -76,17 +77,14 @@
</span><span class="cx">
</span><span class="cx"> Pasteboard::Pasteboard(RefPtr<DataObjectGtk>&& dataObject)
</span><span class="cx"> : m_dataObject(WTFMove(dataObject))
</span><del>- , m_gtkClipboard(nullptr)
</del><span class="cx"> {
</span><span class="cx"> ASSERT(m_dataObject);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-Pasteboard::Pasteboard(GtkClipboard* gtkClipboard)
</del><ins>+Pasteboard::Pasteboard(const String& name)
</ins><span class="cx"> : m_dataObject(DataObjectGtk::create())
</span><del>- , m_gtkClipboard(gtkClipboard)
</del><ins>+ , m_name(name)
</ins><span class="cx"> {
</span><del>- ASSERT(m_dataObject);
- PasteboardHelper::singleton().registerClipboard(gtkClipboard);
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> Pasteboard::~Pasteboard()
</span><span class="lines">@@ -121,6 +119,21 @@
</span><span class="cx"> return ClipboardDataTypeUnknown;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void Pasteboard::writeToClipboard(ShouldIncludeSmartPaste shouldIncludeSmartPaste)
+{
+ if (m_name.isNull())
+ return;
+ m_dataObject->setCanSmartReplace(shouldIncludeSmartPaste == ShouldIncludeSmartPaste::Yes);
+ platformStrategies()->pasteboardStrategy()->writeToClipboard(m_name, m_dataObject);
+}
+
+void Pasteboard::readFromClipboard()
+{
+ if (m_name.isNull())
+ return;
+ m_dataObject = platformStrategies()->pasteboardStrategy()->readFromClipboard(m_name);
+}
+
</ins><span class="cx"> void Pasteboard::writeString(const String& type, const String& data)
</span><span class="cx"> {
</span><span class="cx"> switch (dataObjectTypeFromHTMLClipboardType(type)) {
</span><span class="lines">@@ -147,8 +160,7 @@
</span><span class="cx"> m_dataObject->clearAll();
</span><span class="cx"> m_dataObject->setText(text);
</span><span class="cx">
</span><del>- if (m_gtkClipboard)
- PasteboardHelper::singleton().writeClipboardContents(m_gtkClipboard, *m_dataObject, (smartReplaceOption == CanSmartReplace) ? PasteboardHelper::IncludeSmartPaste : PasteboardHelper::DoNotIncludeSmartPaste);
</del><ins>+ writeToClipboard(smartReplaceOption == CanSmartReplace ? ShouldIncludeSmartPaste::Yes : ShouldIncludeSmartPaste::No);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void Pasteboard::write(const PasteboardURL& pasteboardURL)
</span><span class="lines">@@ -158,8 +170,7 @@
</span><span class="cx"> m_dataObject->clearAll();
</span><span class="cx"> m_dataObject->setURL(pasteboardURL.url, pasteboardURL.title);
</span><span class="cx">
</span><del>- if (m_gtkClipboard)
- PasteboardHelper::singleton().writeClipboardContents(m_gtkClipboard, *m_dataObject);
</del><ins>+ writeToClipboard();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void Pasteboard::write(const PasteboardImage& pasteboardImage)
</span><span class="lines">@@ -174,8 +185,7 @@
</span><span class="cx"> if (pixbuf)
</span><span class="cx"> m_dataObject->setImage(pixbuf.get());
</span><span class="cx">
</span><del>- if (m_gtkClipboard)
- PasteboardHelper::singleton().writeClipboardContents(m_gtkClipboard, *m_dataObject);
</del><ins>+ writeToClipboard();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void Pasteboard::write(const PasteboardWebContent& pasteboardContent)
</span><span class="lines">@@ -184,8 +194,7 @@
</span><span class="cx"> m_dataObject->setText(pasteboardContent.text);
</span><span class="cx"> m_dataObject->setMarkup(pasteboardContent.markup);
</span><span class="cx">
</span><del>- if (m_gtkClipboard)
- PasteboardHelper::singleton().writeClipboardContents(m_gtkClipboard, *m_dataObject, pasteboardContent.canSmartCopyOrDelete ? PasteboardHelper::IncludeSmartPaste : PasteboardHelper::DoNotIncludeSmartPaste, pasteboardContent.callback.get());
</del><ins>+ writeToClipboard(pasteboardContent.canSmartCopyOrDelete ? ShouldIncludeSmartPaste::Yes : ShouldIncludeSmartPaste::No);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void Pasteboard::writePasteboard(const Pasteboard& sourcePasteboard)
</span><span class="lines">@@ -208,8 +217,7 @@
</span><span class="cx"> m_dataObject->setUnknownTypeData(it.key, it.value);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (m_gtkClipboard)
- PasteboardHelper::singleton().writeClipboardContents(m_gtkClipboard, *m_dataObject);
</del><ins>+ writeToClipboard();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void Pasteboard::clear()
</span><span class="lines">@@ -219,9 +227,7 @@
</span><span class="cx"> // attribute's list might still not be empty after calling clearData() (it would
</span><span class="cx"> // still contain the "Files" string if any files were included in the drag)."
</span><span class="cx"> m_dataObject->clearAllExceptFilenames();
</span><del>-
- if (m_gtkClipboard)
- PasteboardHelper::singleton().writeClipboardContents(m_gtkClipboard, *m_dataObject);
</del><ins>+ writeToClipboard();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void Pasteboard::clear(const String& type)
</span><span class="lines">@@ -245,13 +251,13 @@
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- if (m_gtkClipboard)
- PasteboardHelper::singleton().writeClipboardContents(m_gtkClipboard, *m_dataObject);
</del><ins>+ writeToClipboard();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool Pasteboard::canSmartReplace()
</span><span class="cx"> {
</span><del>- return m_gtkClipboard && PasteboardHelper::singleton().clipboardContentSupportsSmartReplace(m_gtkClipboard);
</del><ins>+ readFromClipboard();
+ return m_dataObject->canSmartReplace();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(DRAG_SUPPORT)
</span><span class="lines">@@ -262,23 +268,19 @@
</span><span class="cx">
</span><span class="cx"> void Pasteboard::read(PasteboardPlainText& text)
</span><span class="cx"> {
</span><del>- if (m_gtkClipboard)
- PasteboardHelper::singleton().getClipboardContents(m_gtkClipboard, *m_dataObject);
</del><ins>+ readFromClipboard();
</ins><span class="cx"> text.text = m_dataObject->text();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool Pasteboard::hasData()
</span><span class="cx"> {
</span><del>- if (m_gtkClipboard)
- PasteboardHelper::singleton().getClipboardContents(m_gtkClipboard, *m_dataObject);
-
</del><ins>+ readFromClipboard();
</ins><span class="cx"> return m_dataObject->hasText() || m_dataObject->hasMarkup() || m_dataObject->hasURIList() || m_dataObject->hasImage() || m_dataObject->hasUnknownTypeData();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> Vector<String> Pasteboard::types()
</span><span class="cx"> {
</span><del>- if (m_gtkClipboard)
- PasteboardHelper::singleton().getClipboardContents(m_gtkClipboard, *m_dataObject);
</del><ins>+ readFromClipboard();
</ins><span class="cx">
</span><span class="cx"> Vector<String> types;
</span><span class="cx"> if (m_dataObject->hasText()) {
</span><span class="lines">@@ -306,8 +308,7 @@
</span><span class="cx">
</span><span class="cx"> String Pasteboard::readString(const String& type)
</span><span class="cx"> {
</span><del>- if (m_gtkClipboard)
- PasteboardHelper::singleton().getClipboardContents(m_gtkClipboard, *m_dataObject);
</del><ins>+ readFromClipboard();
</ins><span class="cx">
</span><span class="cx"> switch (dataObjectTypeFromHTMLClipboardType(type)) {
</span><span class="cx"> case ClipboardDataTypeURIList:
</span><span class="lines">@@ -329,9 +330,7 @@
</span><span class="cx">
</span><span class="cx"> Vector<String> Pasteboard::readFilenames()
</span><span class="cx"> {
</span><del>- if (m_gtkClipboard)
- PasteboardHelper::singleton().getClipboardContents(m_gtkClipboard, *m_dataObject);
-
</del><ins>+ readFromClipboard();
</ins><span class="cx"> return m_dataObject->filenames();
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkPasteboardHelpercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/gtk/PasteboardHelper.cpp (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/PasteboardHelper.cpp        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebCore/platform/gtk/PasteboardHelper.cpp        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -76,8 +76,6 @@
</span><span class="cx">
</span><span class="cx"> PasteboardHelper::~PasteboardHelper()
</span><span class="cx"> {
</span><del>- for (auto* clipboard : m_gtkClipboards)
- gtk_clipboard_store(clipboard);
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> GtkTargetList* PasteboardHelper::targetList() const
</span><span class="lines">@@ -115,6 +113,8 @@
</span><span class="cx"> gtk_selection_data_free(data);
</span><span class="cx"> }
</span><span class="cx"> }
</span><ins>+
+ dataObject.setCanSmartReplace(gtk_clipboard_wait_is_target_available(clipboard, smartPasteAtom));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PasteboardHelper::fillSelectionData(GtkSelectionData* selectionData, guint info, const DataObjectGtk& dataObject)
</span><span class="lines">@@ -169,7 +169,7 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-GRefPtr<GtkTargetList> PasteboardHelper::targetListForDataObject(const DataObjectGtk& dataObject, SmartPasteInclusion shouldInludeSmartPaste)
</del><ins>+GRefPtr<GtkTargetList> PasteboardHelper::targetListForDataObject(const DataObjectGtk& dataObject)
</ins><span class="cx"> {
</span><span class="cx"> GRefPtr<GtkTargetList> list = adoptGRef(gtk_target_list_new(nullptr, 0));
</span><span class="cx">
</span><span class="lines">@@ -190,7 +190,7 @@
</span><span class="cx"> if (dataObject.hasUnknownTypeData())
</span><span class="cx"> gtk_target_list_add(list.get(), unknownAtom, 0, TargetTypeUnknown);
</span><span class="cx">
</span><del>- if (shouldInludeSmartPaste == IncludeSmartPaste)
</del><ins>+ if (dataObject.canSmartReplace())
</ins><span class="cx"> gtk_target_list_add(list.get(), smartPasteAtom, 0, TargetTypeSmartPaste);
</span><span class="cx">
</span><span class="cx"> return list;
</span><span class="lines">@@ -257,9 +257,9 @@
</span><span class="cx"> static DataObjectGtk* settingClipboardDataObject = 0;
</span><span class="cx">
</span><span class="cx"> struct ClipboardSetData {
</span><del>- ClipboardSetData(DataObjectGtk* dataObject, GClosure* callback)
</del><ins>+ ClipboardSetData(DataObjectGtk* dataObject, std::function<void()>&& selectionClearedCallback)
</ins><span class="cx"> : dataObject(dataObject)
</span><del>- , callback(callback)
</del><ins>+ , selectionClearedCallback(WTFMove(selectionClearedCallback))
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -268,7 +268,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> RefPtr<DataObjectGtk> dataObject;
</span><del>- GRefPtr<GClosure> callback;
</del><ins>+ std::function<void()> selectionClearedCallback;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> static void getClipboardContentsCallback(GtkClipboard*, GtkSelectionData *selectionData, guint info, gpointer userData)
</span><span class="lines">@@ -277,7 +277,7 @@
</span><span class="cx"> PasteboardHelper::singleton().fillSelectionData(selectionData, info, *data->dataObject);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void clearClipboardContentsCallback(GtkClipboard* clipboard, gpointer userData)
</del><ins>+static void clearClipboardContentsCallback(GtkClipboard*, gpointer userData)
</ins><span class="cx"> {
</span><span class="cx"> std::unique_ptr<ClipboardSetData> data(static_cast<ClipboardSetData*>(userData));
</span><span class="cx">
</span><span class="lines">@@ -285,18 +285,13 @@
</span><span class="cx"> if (data->dataObject.get() != settingClipboardDataObject)
</span><span class="cx"> data->dataObject->clearAll();
</span><span class="cx">
</span><del>- if (!data->callback)
- return;
-
- GValue firstArgument = {0, {{0}}};
- g_value_init(&firstArgument, G_TYPE_POINTER);
- g_value_set_pointer(&firstArgument, clipboard);
- g_closure_invoke(data->callback.get(), nullptr, 1, &firstArgument, 0);
</del><ins>+ if (data->selectionClearedCallback)
+ data->selectionClearedCallback();
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void PasteboardHelper::writeClipboardContents(GtkClipboard* clipboard, const DataObjectGtk& dataObject, SmartPasteInclusion includeSmartPaste, GClosure* callback)
</del><ins>+void PasteboardHelper::writeClipboardContents(GtkClipboard* clipboard, const DataObjectGtk& dataObject, std::function<void()>&& primarySelectionCleared)
</ins><span class="cx"> {
</span><del>- GRefPtr<GtkTargetList> list = targetListForDataObject(dataObject, includeSmartPaste);
</del><ins>+ GRefPtr<GtkTargetList> list = targetListForDataObject(dataObject);
</ins><span class="cx">
</span><span class="cx"> int numberOfTargets;
</span><span class="cx"> GtkTargetEntry* table = gtk_target_table_new_from_list(list.get(), &numberOfTargets);
</span><span class="lines">@@ -304,7 +299,7 @@
</span><span class="cx"> if (numberOfTargets > 0 && table) {
</span><span class="cx"> settingClipboardDataObject = const_cast<DataObjectGtk*>(&dataObject);
</span><span class="cx">
</span><del>- auto data = std::make_unique<ClipboardSetData>(settingClipboardDataObject, callback);
</del><ins>+ auto data = std::make_unique<ClipboardSetData>(settingClipboardDataObject, WTFMove(primarySelectionCleared));
</ins><span class="cx"> if (gtk_clipboard_set_with_data(clipboard, table, numberOfTargets, getClipboardContentsCallback, clearClipboardContentsCallback, data.get())) {
</span><span class="cx"> gtk_clipboard_set_can_store(clipboard, nullptr, 0);
</span><span class="cx"> // When gtk_clipboard_set_with_data() succeeds clearClipboardContentsCallback takes the ownership of data, so we leak it here.
</span><span class="lines">@@ -319,16 +314,5 @@
</span><span class="cx"> gtk_target_table_free(table, numberOfTargets);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool PasteboardHelper::clipboardContentSupportsSmartReplace(GtkClipboard* clipboard)
-{
- return gtk_clipboard_wait_is_target_available(clipboard, smartPasteAtom);
</del><span class="cx"> }
</span><span class="cx">
</span><del>-void PasteboardHelper::registerClipboard(GtkClipboard* clipboard)
-{
- ASSERT(clipboard);
- m_gtkClipboards.add(clipboard);
-}
-
-}
-
</del></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkPasteboardHelperh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/gtk/PasteboardHelper.h (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/PasteboardHelper.h        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebCore/platform/gtk/PasteboardHelper.h        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -26,7 +26,6 @@
</span><span class="cx"> #define PasteboardHelper_h
</span><span class="cx">
</span><span class="cx"> #include "GRefPtrGtk.h"
</span><del>-#include <wtf/HashSet.h>
</del><span class="cx"> #include <wtf/Noncopyable.h>
</span><span class="cx"> #include <wtf/Vector.h>
</span><span class="cx"> #include <wtf/glib/GRefPtr.h>
</span><span class="lines">@@ -43,24 +42,20 @@
</span><span class="cx"> enum SmartPasteInclusion { IncludeSmartPaste, DoNotIncludeSmartPaste };
</span><span class="cx">
</span><span class="cx"> GtkTargetList* targetList() const;
</span><del>- GRefPtr<GtkTargetList> targetListForDataObject(const DataObjectGtk&, SmartPasteInclusion = DoNotIncludeSmartPaste);
</del><ins>+ GRefPtr<GtkTargetList> targetListForDataObject(const DataObjectGtk&);
</ins><span class="cx"> void fillSelectionData(GtkSelectionData*, guint, const DataObjectGtk&);
</span><span class="cx"> void fillDataObjectFromDropData(GtkSelectionData*, guint, DataObjectGtk&);
</span><span class="cx"> Vector<GdkAtom> dropAtomsForContext(GtkWidget*, GdkDragContext*);
</span><del>- void writeClipboardContents(GtkClipboard*, const DataObjectGtk&, SmartPasteInclusion = DoNotIncludeSmartPaste, GClosure* = 0);
</del><ins>+ void writeClipboardContents(GtkClipboard*, const DataObjectGtk&, std::function<void()>&& primarySelectionCleared = nullptr);
</ins><span class="cx"> void getClipboardContents(GtkClipboard*, DataObjectGtk&);
</span><span class="cx">
</span><span class="cx"> enum PasteboardTargetType { TargetTypeMarkup, TargetTypeText, TargetTypeImage, TargetTypeURIList, TargetTypeNetscapeURL, TargetTypeSmartPaste, TargetTypeUnknown };
</span><del>- bool clipboardContentSupportsSmartReplace(GtkClipboard*);
</del><span class="cx">
</span><del>- void registerClipboard(GtkClipboard*);
-
</del><span class="cx"> private:
</span><span class="cx"> PasteboardHelper();
</span><span class="cx"> ~PasteboardHelper();
</span><span class="cx">
</span><span class="cx"> GRefPtr<GtkTargetList> m_targetList;
</span><del>- HashSet<GtkClipboard*> m_gtkClipboards;
</del><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkPlatformPasteboardGtkcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/gtk/PlatformPasteboardGtk.cpp (0 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/PlatformPasteboardGtk.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/gtk/PlatformPasteboardGtk.cpp        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -0,0 +1,49 @@
</span><ins>+/*
+ * Copyright (C) 2016 Red Hat Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "PlatformPasteboard.h"
+
+#include "Color.h"
+#include "DataObjectGtk.h"
+#include "PasteboardHelper.h"
+#include "SharedBuffer.h"
+#include "URL.h"
+#include <gtk/gtk.h>
+
+namespace WebCore {
+
+PlatformPasteboard::PlatformPasteboard(const String& pasteboardName)
+ : m_clipboard(gtk_clipboard_get(gdk_atom_intern(pasteboardName.utf8().data(), TRUE)))
+{
+ ASSERT(m_clipboard);
+}
+
+void PlatformPasteboard::writeToClipboard(const RefPtr<DataObjectGtk>& dataObject, std::function<void()>&& primarySelectionCleared)
+{
+ PasteboardHelper::singleton().writeClipboardContents(m_clipboard, *dataObject, gtk_clipboard_get(GDK_SELECTION_PRIMARY) == m_clipboard ? WTFMove(primarySelectionCleared) : nullptr);
+}
+
+RefPtr<DataObjectGtk> PlatformPasteboard::readFromClipboard()
+{
+ RefPtr<DataObjectGtk> dataObject = DataObjectGtk::create();
+ PasteboardHelper::singleton().getClipboardContents(m_clipboard, *dataObject);
+ return dataObject;
+}
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebKit2/ChangeLog        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -1,3 +1,68 @@
</span><ins>+2016-09-14 Carlos Garnacho <carlosg@gnome.org>
+
+ [GTK][Wayland] Implement clipboard support
+ https://bugs.webkit.org/show_bug.cgi?id=146574
+
+ Reviewed by Carlos Garcia Campos.
+
+ Add the necessary plumbing for the GTK+ backend to use the
+ PlatformPasteboard in WebCore. All selection data is transmitted
+ at once through the serialization of PasteboardContentGtk/DataObjectGtk.
+
+ * PlatformGTK.cmake: Add PasteboardContentGtk.cpp and
+ WebPasteboardProxyGtk.cpp
+ * Shared/gtk/ArgumentCodersGtk.cpp:
+ (IPC::encode):
+ (IPC::decode): Renamed from encodeDataObject/decodeDataObject
+ and made public.
+ (IPC::ArgumentCoder<DragData>::encode):
+ (IPC::ArgumentCoder<DragData>::decode): Update DataObjectGtk
+ encode/decode callers. Encode the extra canSmartReplace field.
+ * Shared/gtk/ArgumentCodersGtk.h: Expose encode/decode methods for
+ DataObjectGtk.
+ * Shared/gtk/PasteboardContent.cpp: Added. Wraps a DataObjectGtk
+ so it can be serialized on WebProcess/UIProcess messaging.
+ (WebKit::PasteboardContent::PasteboardContent):
+ (WebKit::PasteboardContent::encode):
+ (WebKit::PasteboardContent::decode): Methods to encode/decode a
+ PasteboardContent.
+ * Shared/gtk/PasteboardContent.h: Added.
+ * UIProcess/WebFrameProxy.cpp:
+ (WebKit::WebFrameProxy::collapseSelection): Added plumbing to allow
+ collapsing the global selection from the UI process side.
+ * UIProcess/WebFrameProxy.h:
+ * UIProcess/WebPasteboardProxy.h:
+ * UIProcess/WebPasteboardProxy.messages.in: Added plumbing for the
+ GTK+ pasteboard proxy functions.
+ * UIProcess/gtk/WebPageProxyGtk.cpp:
+ (WebKit::WebPageProxy::editorStateChanged):
+ * UIProcess/gtk/WebPasteboardProxyGtk.cpp: Added.
+ (WebKit::WebPasteboardProxy::writeToClipboard):
+ (WebKit::WebPasteboardProxy::readFromClipboard): Implemented functions
+ hooking into the PlatformPasteboard. Per-selection (ie.
+ primary/clipboard) PlatformPasteboards are kept at this level, so those
+ are independently set and dealt with.
+ (WebKit::WebPasteboardProxy::setPrimarySelectionOwner):
+ (WebKit::WebPasteboardProxy::didDestroyFrame): Implemented functions
+ to manage the frame currently being currently interacted, so we can
+ signal back when the global selection has been replaced.
+ * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
+ (WebKit::WebPlatformStrategies::writeToClipboard):
+ (WebKit::WebPlatformStrategies::readFromClipboard): Added methods to
+ send the WebProcess->UIProcess messages.
+ * WebProcess/WebCoreSupport/WebPlatformStrategies.h:
+ * WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:
+ (WebKit::WebEditorClient::updateGlobalSelection): Remove GClosure to
+ get notifications about changes in global selection ownership. This
+ is done through a WebPage message now, as the UI process manages the
+ clipboard.
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+ * WebProcess/WebPage/gtk/WebPageGtk.cpp:
+ (WebKit::WebPage::collapseSelectionInFrame): Added methods to send
+ the UIProcess->WebProcess notification that the global selection has
+ been replaced.
+
</ins><span class="cx"> 2016-09-13 Tim Horton <timothy_horton@apple.com>
</span><span class="cx">
</span><span class="cx"> Provide a mechanism to specify the maximum size of WKThumbnailView snapshots
</span></span></pre></div>
<a id="trunkSourceWebKit2PlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/PlatformGTK.cmake (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/PlatformGTK.cmake        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebKit2/PlatformGTK.cmake        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -71,6 +71,7 @@
</span><span class="cx"> Shared/gtk/NativeWebMouseEventGtk.cpp
</span><span class="cx"> Shared/gtk/NativeWebTouchEventGtk.cpp
</span><span class="cx"> Shared/gtk/NativeWebWheelEventGtk.cpp
</span><ins>+ Shared/gtk/PasteboardContent.cpp
</ins><span class="cx"> Shared/gtk/PrintInfoGtk.cpp
</span><span class="cx"> Shared/gtk/ProcessExecutablePathGtk.cpp
</span><span class="cx"> Shared/gtk/WebContextMenuItemGtk.cpp
</span><span class="lines">@@ -313,6 +314,7 @@
</span><span class="cx"> UIProcess/gtk/WebInspectorClientGtk.cpp
</span><span class="cx"> UIProcess/gtk/WebInspectorProxyGtk.cpp
</span><span class="cx"> UIProcess/gtk/WebPageProxyGtk.cpp
</span><ins>+ UIProcess/gtk/WebPasteboardProxyGtk.cpp
</ins><span class="cx"> UIProcess/gtk/WebPopupMenuProxyGtk.cpp
</span><span class="cx"> UIProcess/gtk/WebPreferencesGtk.cpp
</span><span class="cx"> UIProcess/gtk/WebProcessPoolGtk.cpp
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedgtkArgumentCodersGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.cpp (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.cpp        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.cpp        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -82,7 +82,7 @@
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void encodeDataObject(Encoder& encoder, const DataObjectGtk* dataObject)
</del><ins>+void encode(Encoder& encoder, const DataObjectGtk* dataObject)
</ins><span class="cx"> {
</span><span class="cx"> bool hasText = dataObject->hasText();
</span><span class="cx"> encoder << hasText;
</span><span class="lines">@@ -113,9 +113,12 @@
</span><span class="cx"> encoder << hasUnknownTypeData;
</span><span class="cx"> if (hasUnknownTypeData)
</span><span class="cx"> encoder << dataObject->unknownTypes();
</span><ins>+
+ bool canSmartReplace = dataObject->canSmartReplace();
+ encoder << canSmartReplace;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static bool decodeDataObject(Decoder& decoder, RefPtr<DataObjectGtk>& dataObject)
</del><ins>+bool decode(Decoder& decoder, RefPtr<DataObjectGtk>& dataObject)
</ins><span class="cx"> {
</span><span class="cx"> RefPtr<DataObjectGtk> data = DataObjectGtk::create();
</span><span class="cx">
</span><span class="lines">@@ -182,6 +185,11 @@
</span><span class="cx"> data->setUnknownTypeData(it->key, it->value);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ bool canSmartReplace;
+ if (!decoder.decode(canSmartReplace))
+ return false;
+ data->setCanSmartReplace(canSmartReplace);
+
</ins><span class="cx"> dataObject = data;
</span><span class="cx">
</span><span class="cx"> return true;
</span><span class="lines">@@ -198,7 +206,7 @@
</span><span class="cx"> DataObjectGtk* platformData = dragData.platformData();
</span><span class="cx"> encoder << static_cast<bool>(platformData);
</span><span class="cx"> if (platformData)
</span><del>- encodeDataObject(encoder, platformData);
</del><ins>+ IPC::encode(encoder, platformData);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool ArgumentCoder<DragData>::decode(Decoder& decoder, DragData& dragData)
</span><span class="lines">@@ -225,7 +233,7 @@
</span><span class="cx">
</span><span class="cx"> RefPtr<DataObjectGtk> platformData;
</span><span class="cx"> if (hasPlatformData) {
</span><del>- if (!decodeDataObject(decoder, platformData))
</del><ins>+ if (!IPC::decode(decoder, platformData))
</ins><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedgtkArgumentCodersGtkh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.h (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.h        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebKit2/Shared/gtk/ArgumentCodersGtk.h        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -52,6 +52,9 @@
</span><span class="cx"> void encode(Encoder&, GtkPageSetup*);
</span><span class="cx"> bool decode(Decoder&, GRefPtr<GtkPageSetup>&);
</span><span class="cx">
</span><ins>+void encode(Encoder&, const WebCore::DataObjectGtk*);
+bool decode(Decoder&, RefPtr<WebCore::DataObjectGtk>&);
+
</ins><span class="cx"> } // namespace IPC
</span><span class="cx">
</span><span class="cx"> #endif // ArgumentCodersGtk_h
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedgtkPasteboardContentcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/Shared/gtk/PasteboardContent.cpp (0 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/gtk/PasteboardContent.cpp         (rev 0)
+++ trunk/Source/WebKit2/Shared/gtk/PasteboardContent.cpp        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -0,0 +1,46 @@
</span><ins>+/*
+ * Copyright (C) 2016 Red Hat Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "PasteboardContent.h"
+
+#include "ArgumentCodersGtk.h"
+#include "DataObjectGtk.h"
+#include "Decoder.h"
+#include "Encoder.h"
+#include <wtf/RetainPtr.h>
+
+namespace WebKit {
+
+PasteboardContent::PasteboardContent(const RefPtr<WebCore::DataObjectGtk>& data)
+ : dataObject(data)
+{
+ ASSERT(dataObject);
+}
+
+void PasteboardContent::encode(IPC::Encoder& encoder) const
+{
+ IPC::encode(encoder, dataObject.get());
+}
+
+bool PasteboardContent::decode(IPC::Decoder& decoder, PasteboardContent& pasteboardContent)
+{
+ return IPC::decode(decoder, pasteboardContent.dataObject);
+}
+
+} // namespace WebKit
</ins></span></pre></div>
<a id="trunkSourceWebKit2SharedgtkPasteboardContenth"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/Shared/gtk/PasteboardContent.h (0 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/gtk/PasteboardContent.h         (rev 0)
+++ trunk/Source/WebKit2/Shared/gtk/PasteboardContent.h        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -0,0 +1,43 @@
</span><ins>+/*
+ * Copyright (C) 2016 Red Hat Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef PasteboardContent_h
+#define PasteboardContent_h
+
+#include "DataObjectGtk.h"
+
+namespace IPC {
+class Decoder;
+class Encoder;
+}
+
+namespace WebKit {
+
+struct PasteboardContent {
+ PasteboardContent() = default;
+ explicit PasteboardContent(const RefPtr<WebCore::DataObjectGtk>&);
+
+ RefPtr<WebCore::DataObjectGtk> dataObject;
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, PasteboardContent&);
+};
+
+} // namespace WebKit
+
+#endif // PasteboardContent_h
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebFrameProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebFrameProxy.cpp (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebFrameProxy.cpp        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebKit2/UIProcess/WebFrameProxy.cpp        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #include "WebFramePolicyListenerProxy.h"
</span><span class="cx"> #include "WebPageMessages.h"
</span><span class="cx"> #include "WebPageProxy.h"
</span><ins>+#include "WebPasteboardProxy.h"
</ins><span class="cx"> #include "WebProcessPool.h"
</span><span class="cx"> #include <WebCore/Image.h>
</span><span class="cx"> #include <WebCore/MIMETypeRegistry.h>
</span><span class="lines">@@ -52,6 +53,9 @@
</span><span class="cx"> WebFrameProxy::~WebFrameProxy()
</span><span class="cx"> {
</span><span class="cx"> WebProcessPool::statistics().wkFrameCount--;
</span><ins>+#if PLATFORM(GTK)
+ WebPasteboardProxy::singleton().didDestroyFrame(this);
+#endif
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void WebFrameProxy::webProcessWillShutDown()
</span><span class="lines">@@ -254,4 +258,14 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if PLATFORM(GTK)
+void WebFrameProxy::collapseSelection()
+{
+ if (!m_page)
+ return;
+
+ m_page->process().send(Messages::WebPage::CollapseSelectionInFrame(m_frameID), m_page->pageID());
+}
+#endif
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebFrameProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebFrameProxy.h (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebFrameProxy.h        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebKit2/UIProcess/WebFrameProxy.h        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -124,6 +124,10 @@
</span><span class="cx"> bool didHandleContentFilterUnblockNavigation(const WebCore::ResourceRequest&);
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if PLATFORM(GTK)
+ void collapseSelection();
+#endif
+
</ins><span class="cx"> private:
</span><span class="cx"> WebFrameProxy(WebPageProxy* page, uint64_t frameID);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPasteboardProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPasteboardProxy.h (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPasteboardProxy.h        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebKit2/UIProcess/WebPasteboardProxy.h        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -40,8 +40,13 @@
</span><span class="cx">
</span><span class="cx"> namespace WebKit {
</span><span class="cx">
</span><ins>+class WebFrameProxy;
</ins><span class="cx"> class WebProcessProxy;
</span><span class="cx">
</span><ins>+#if PLATFORM(GTK)
+class PasteboardContent;
+#endif
+
</ins><span class="cx"> class WebPasteboardProxy : public IPC::MessageReceiver {
</span><span class="cx"> WTF_MAKE_NONCOPYABLE(WebPasteboardProxy);
</span><span class="cx"> friend class LazyNeverDestroyed<WebPasteboardProxy>;
</span><span class="lines">@@ -50,6 +55,11 @@
</span><span class="cx">
</span><span class="cx"> void addWebProcessProxy(WebProcessProxy&);
</span><span class="cx">
</span><ins>+#if PLATFORM(GTK)
+ void setPrimarySelectionOwner(WebFrameProxy*);
+ void didDestroyFrame(WebFrameProxy*);
+#endif
+
</ins><span class="cx"> private:
</span><span class="cx"> WebPasteboardProxy();
</span><span class="cx">
</span><span class="lines">@@ -81,6 +91,13 @@
</span><span class="cx"> void setPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, const String&, uint64_t& newChangeCount);
</span><span class="cx"> void setPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle&, uint64_t size, uint64_t& newChangeCount);
</span><span class="cx"> #endif
</span><ins>+#if PLATFORM(GTK)
+ void writeToClipboard(const String& pasteboardName, const PasteboardContent&);
+ void readFromClipboard(const String& pasteboardName, PasteboardContent&);
+
+ WebFrameProxy* m_primarySelectionOwner { nullptr };
+ WebFrameProxy* m_frameWritingToClipboard { nullptr };
+#endif // PLATFORM(GTK)
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPasteboardProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPasteboardProxy.messages.in (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPasteboardProxy.messages.in        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebKit2/UIProcess/WebPasteboardProxy.messages.in        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -48,4 +48,9 @@
</span><span class="cx"> SetPasteboardStringForType(String pasteboardName, String pasteboardType, String string) -> (uint64_t changeCount)
</span><span class="cx"> SetPasteboardBufferForType(String pasteboardName, String pasteboardType, WebKit::SharedMemory::Handle handle, uint64_t size) -> (uint64_t changeCount)
</span><span class="cx"> #endif
</span><ins>+
+#if PLATFORM(GTK)
+ WriteToClipboard(String pasteboardName, struct WebKit::PasteboardContent pasteboardContent)
+ ReadFromClipboard(String pasteboardName) -> (struct WebKit::PasteboardContent pasteboardContent)
+#endif
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkWebPageProxyGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #include "PageClientImpl.h"
</span><span class="cx"> #include "WebKitWebViewBasePrivate.h"
</span><span class="cx"> #include "WebPageMessages.h"
</span><ins>+#include "WebPasteboardProxy.h"
</ins><span class="cx"> #include "WebProcessProxy.h"
</span><span class="cx"> #include "WebsiteDataStore.h"
</span><span class="cx"> #include <WebCore/UserAgentGtk.h>
</span><span class="lines">@@ -79,6 +80,8 @@
</span><span class="cx">
</span><span class="cx"> if (editorState.shouldIgnoreCompositionSelectionChange)
</span><span class="cx"> return;
</span><ins>+ if (m_editorState.selectionIsRange)
+ WebPasteboardProxy::singleton().setPrimarySelectionOwner(focusedFrame());
</ins><span class="cx"> m_pageClient.selectionDidChange();
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessgtkWebPasteboardProxyGtkcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/gtk/WebPasteboardProxyGtk.cpp (0 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/gtk/WebPasteboardProxyGtk.cpp         (rev 0)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebPasteboardProxyGtk.cpp        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -0,0 +1,73 @@
</span><ins>+/*
+ * Copyright (C) 2016 Red Hat Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebPasteboardProxy.h"
+
+#include "PasteboardContent.h"
+#include "WebFrameProxy.h"
+#include <WebCore/PlatformPasteboard.h>
+#include <wtf/HashMap.h>
+#include <wtf/NeverDestroyed.h>
+#include <wtf/TemporaryChange.h>
+#include <wtf/text/StringHash.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebPasteboardProxy::writeToClipboard(const String& pasteboardName, const PasteboardContent& pasteboardContent)
+{
+ TemporaryChange<WebFrameProxy*> frameWritingToClipboard(m_frameWritingToClipboard, m_primarySelectionOwner);
+ PlatformPasteboard(pasteboardName).writeToClipboard(pasteboardContent.dataObject, [this] {
+ if (m_frameWritingToClipboard == m_primarySelectionOwner)
+ return;
+ setPrimarySelectionOwner(nullptr);
+ });
+}
+
+void WebPasteboardProxy::readFromClipboard(const String& pasteboardName, PasteboardContent& pasteboardContent)
+{
+ pasteboardContent = PasteboardContent(PlatformPasteboard(pasteboardName).readFromClipboard().get());
+}
+
+void WebPasteboardProxy::setPrimarySelectionOwner(WebFrameProxy* frame)
+{
+ if (m_primarySelectionOwner == frame)
+ return;
+
+ if (m_primarySelectionOwner)
+ m_primarySelectionOwner->collapseSelection();
+
+ m_primarySelectionOwner = frame;
+}
+
+void WebPasteboardProxy::didDestroyFrame(WebFrameProxy* frame)
+{
+ if (frame == m_primarySelectionOwner)
+ m_primarySelectionOwner = nullptr;
+}
+
+} // namespace WebKit
</ins></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebPlatformStrategiescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -69,6 +69,10 @@
</span><span class="cx"> #include "StringUtilities.h"
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+#if PLATFORM(GTK)
+#include "PasteboardContent.h"
+#endif
+
</ins><span class="cx"> using namespace WebCore;
</span><span class="cx">
</span><span class="cx"> namespace WebKit {
</span><span class="lines">@@ -339,4 +343,22 @@
</span><span class="cx">
</span><span class="cx"> #endif // PLATFORM(COCOA)
</span><span class="cx">
</span><ins>+#if PLATFORM(GTK)
+// PasteboardStrategy
+
+void WebPlatformStrategies::writeToClipboard(const String& pasteboardName, const RefPtr<WebCore::DataObjectGtk>& dataObject)
+{
+ PasteboardContent pasteboardContent = PasteboardContent(dataObject.get());
+ WebProcess::singleton().parentProcessConnection()->send(Messages::WebPasteboardProxy::WriteToClipboard(pasteboardName, pasteboardContent), 0);
+}
+
+RefPtr<WebCore::DataObjectGtk> WebPlatformStrategies::readFromClipboard(const String& pasteboardName)
+{
+ PasteboardContent pasteboardContent;
+ WebProcess::singleton().parentProcessConnection()->sendSync(Messages::WebPasteboardProxy::ReadFromClipboard(pasteboardName), Messages::WebPasteboardProxy::ReadFromClipboard::Reply(pasteboardContent), 0);
+ return pasteboardContent.dataObject;
+}
+
+#endif // PLATFORM(GTK)
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebPlatformStrategiesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -86,7 +86,10 @@
</span><span class="cx"> long setPathnamesForType(const Vector<String>&, const String& pasteboardType, const String& pasteboardName) override;
</span><span class="cx"> long setStringForType(const String&, const String& pasteboardType, const String& pasteboardName) override;
</span><span class="cx"> #endif
</span><del>-
</del><ins>+#if PLATFORM(GTK)
+ void writeToClipboard(const String& pasteboardName, const RefPtr<WebCore::DataObjectGtk>&) override;
+ RefPtr<WebCore::DataObjectGtk> readFromClipboard(const String& pasteboardName) override;
+#endif
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportgtkWebEditorClientGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -119,45 +119,6 @@
</span><span class="cx"> event->setDefaultHandled();
</span><span class="cx"> }
</span><span class="cx">
</span><del>-class EditorClientFrameDestructionObserver : FrameDestructionObserver {
-public:
- EditorClientFrameDestructionObserver(Frame* frame, GClosure* closure)
- : FrameDestructionObserver(frame)
- , m_closure(closure)
- {
- g_closure_add_finalize_notifier(m_closure, this, destroyOnClosureFinalization);
- }
-
- void frameDestroyed()
- {
- g_closure_invalidate(m_closure);
- FrameDestructionObserver::frameDestroyed();
- }
-private:
- GClosure* m_closure;
-
- static void destroyOnClosureFinalization(gpointer data, GClosure*)
- {
- // Calling delete void* will free the memory but won't invoke
- // the destructor, something that is a must for us.
- EditorClientFrameDestructionObserver* observer = static_cast<EditorClientFrameDestructionObserver*>(data);
- delete observer;
- }
-};
-
-static Frame* frameSettingClipboard;
-
-static void collapseSelection(GtkClipboard*, Frame* frame)
-{
- if (frameSettingClipboard && frameSettingClipboard == frame)
- return;
-
- // Collapse the selection without clearing it.
- ASSERT(frame);
- const VisibleSelection& selection = frame->selection().selection();
- frame->selection().setBase(selection.extent(), selection.affinity());
-}
-
</del><span class="cx"> void WebEditorClient::updateGlobalSelection(Frame* frame)
</span><span class="cx"> {
</span><span class="cx"> if (!frame->selection().isRange())
</span><span class="lines">@@ -166,21 +127,11 @@
</span><span class="cx"> if (!range)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- frameSettingClipboard = frame;
- GRefPtr<GClosure> callback = adoptGRef(g_cclosure_new(G_CALLBACK(collapseSelection), frame, nullptr));
- // This observer will be self-destroyed on closure finalization,
- // that will happen either after closure execution or after
- // closure invalidation.
- new EditorClientFrameDestructionObserver(frame, callback.get());
- g_closure_set_marshal(callback.get(), g_cclosure_marshal_VOID__VOID);
-
</del><span class="cx"> PasteboardWebContent pasteboardContent;
</span><span class="cx"> pasteboardContent.canSmartCopyOrDelete = false;
</span><span class="cx"> pasteboardContent.text = range->text();
</span><span class="cx"> pasteboardContent.markup = createMarkup(*range, nullptr, AnnotateForInterchange, false, ResolveNonLocalURLs);
</span><del>- pasteboardContent.callback = callback;
</del><span class="cx"> Pasteboard::createForGlobalSelection()->write(pasteboardContent);
</span><del>- frameSettingClipboard = nullptr;
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool WebEditorClient::shouldShowUnicodeMenu()
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -646,6 +646,8 @@
</span><span class="cx"> void setComposition(const String& text, const Vector<WebCore::CompositionUnderline>& underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeLength);
</span><span class="cx"> void confirmComposition(const String& text, int64_t selectionStart, int64_t selectionLength);
</span><span class="cx"> void cancelComposition();
</span><ins>+
+ void collapseSelectionInFrame(uint64_t frameID);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if PLATFORM (GTK) && HAVE(GTK_GESTURES)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -340,6 +340,8 @@
</span><span class="cx"> SetComposition(String text, Vector<WebCore::CompositionUnderline> underlines, uint64_t selectionStart, uint64_t selectionEnd, uint64_t replacementRangeStart, uint64_t replacementRangeEnd)
</span><span class="cx"> ConfirmComposition(String text, int64_t selectionStart, int64_t selectionLength)
</span><span class="cx"> CancelComposition()
</span><ins>+
+ CollapseSelectionInFrame(uint64_t frameID)
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if PLATFORM (GTK) && HAVE(GTK_GESTURES)
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagegtkWebPageGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp (205908 => 205909)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp        2016-09-14 16:40:13 UTC (rev 205908)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/WebPageGtk.cpp        2016-09-14 16:45:48 UTC (rev 205909)
</span><span class="lines">@@ -31,8 +31,10 @@
</span><span class="cx"> #include "EditorState.h"
</span><span class="cx"> #include "NotImplemented.h"
</span><span class="cx"> #include "WebEvent.h"
</span><ins>+#include "WebFrame.h"
</ins><span class="cx"> #include "WebPageAccessibilityObject.h"
</span><span class="cx"> #include "WebPageProxyMessages.h"
</span><ins>+#include "WebProcess.h"
</ins><span class="cx"> #include "WindowsKeyboardCodes.h"
</span><span class="cx"> #include <WebCore/BackForwardController.h>
</span><span class="cx"> #include <WebCore/EventHandler.h>
</span><span class="lines">@@ -216,4 +218,15 @@
</span><span class="cx"> send(Messages::WebPageProxy::SetInputMethodState(enabled));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebPage::collapseSelectionInFrame(uint64_t frameID)
+{
+ WebFrame* frame = WebProcess::singleton().webFrame(frameID);
+ if (!frame || !frame->coreFrame())
+ return;
+
+ // Collapse the selection without clearing it.
+ const VisibleSelection& selection = frame->coreFrame()->selection().selection();
+ frame->coreFrame()->selection().setBase(selection.extent(), selection.affinity());
+}
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre>
</div>
</div>
</body>
</html>