<!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>[173687] 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/173687">173687</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2014-09-17 00:05:45 -0700 (Wed, 17 Sep 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>[GTK] Fix layering violations in PasteboardGtk
https://bugs.webkit.org/show_bug.cgi?id=136802
Reviewed by Darin Adler.
Source/WebCore:
Refactor the Pasteboard code moving the WebCore parts to the Editor.
* PlatformGTK.cmake: Add new file to compilation.
* editing/Editor.cpp:
(WebCore::Editor::performCutOrCopy):
(WebCore::Editor::copyImage):
* editing/Editor.h:
* editing/gtk/EditorGtk.cpp: Added.
(WebCore::createFragmentFromPasteBoardData):
(WebCore::Editor::pasteWithPasteboard):
(WebCore::getImageAndURLForElement):
(WebCore::Editor::writeImageToPasteboard):
(WebCore::Editor::writeSelectionToPasteboard):
* page/DragController.cpp:
(WebCore::DragController::startDrag):
* page/gtk/DragControllerGtk.cpp:
(WebCore::DragController::declareAndWriteDragImage):
* platform/Pasteboard.h:
* platform/gtk/DataObjectGtk.cpp: Remove range member, the caller
should call setText() + setMarkup() intead.
(WebCore::DataObjectGtk::setText):
(WebCore::DataObjectGtk::setMarkup):
(WebCore::DataObjectGtk::clearText):
(WebCore::DataObjectGtk::clearMarkup):
(WebCore::DataObjectGtk::clearAllExceptFilenames):
* platform/gtk/DataObjectGtk.h:
(WebCore::DataObjectGtk::hasText):
(WebCore::DataObjectGtk::hasMarkup):
(WebCore::DataObjectGtk::clearImage):
(WebCore::DataObjectGtk::text):
(WebCore::DataObjectGtk::markup):
(WebCore::DataObjectGtk::setRange): Deleted.
* platform/gtk/GtkDragAndDropHelper.h:
* platform/gtk/PasteboardGtk.cpp:
(WebCore::PasteboardImage::PasteboardImage):
(WebCore::PasteboardImage::~PasteboardImage):
(WebCore::Pasteboard::write):
(WebCore::Pasteboard::writeSelection): Deleted.
(WebCore::getURLForImageElement): Deleted.
(WebCore::Pasteboard::writeImage): Deleted.
(WebCore::Pasteboard::documentFragment): Deleted.
* platform/gtk/PasteboardHelper.cpp:
(WebCore::displayFromFrame): Deleted.
(WebCore::PasteboardHelper::getPrimarySelectionClipboard): Deleted.
* platform/gtk/PasteboardHelper.h:
Source/WebKit2:
* WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:
(WebKit::WebEditorClient::updateGlobalSelection): Use new API to
update the global selection.</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="#trunkSourceWebCoreeditingEditorcpp">trunk/Source/WebCore/editing/Editor.cpp</a></li>
<li><a href="#trunkSourceWebCoreeditingEditorh">trunk/Source/WebCore/editing/Editor.h</a></li>
<li><a href="#trunkSourceWebCorepageDragControllercpp">trunk/Source/WebCore/page/DragController.cpp</a></li>
<li><a href="#trunkSourceWebCorepagegtkDragControllerGtkcpp">trunk/Source/WebCore/page/gtk/DragControllerGtk.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformPasteboardh">trunk/Source/WebCore/platform/Pasteboard.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="#trunkSourceWebCoreplatformgtkGtkDragAndDropHelperh">trunk/Source/WebCore/platform/gtk/GtkDragAndDropHelper.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="#trunkSourceWebKit2WebProcessWebCoreSupportgtkWebEditorClientGtkcpp">trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li>trunk/Source/WebCore/editing/gtk/</li>
<li><a href="#trunkSourceWebCoreeditinggtkEditorGtkcpp">trunk/Source/WebCore/editing/gtk/EditorGtk.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (173686 => 173687)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-09-17 06:27:46 UTC (rev 173686)
+++ trunk/Source/WebCore/ChangeLog        2014-09-17 07:05:45 UTC (rev 173687)
</span><span class="lines">@@ -1,5 +1,58 @@
</span><span class="cx"> 2014-09-16 Carlos Garcia Campos <cgarcia@igalia.com>
</span><span class="cx">
</span><ins>+ [GTK] Fix layering violations in PasteboardGtk
+ https://bugs.webkit.org/show_bug.cgi?id=136802
+
+ Reviewed by Darin Adler.
+
+ Refactor the Pasteboard code moving the WebCore parts to the Editor.
+
+ * PlatformGTK.cmake: Add new file to compilation.
+ * editing/Editor.cpp:
+ (WebCore::Editor::performCutOrCopy):
+ (WebCore::Editor::copyImage):
+ * editing/Editor.h:
+ * editing/gtk/EditorGtk.cpp: Added.
+ (WebCore::createFragmentFromPasteBoardData):
+ (WebCore::Editor::pasteWithPasteboard):
+ (WebCore::getImageAndURLForElement):
+ (WebCore::Editor::writeImageToPasteboard):
+ (WebCore::Editor::writeSelectionToPasteboard):
+ * page/DragController.cpp:
+ (WebCore::DragController::startDrag):
+ * page/gtk/DragControllerGtk.cpp:
+ (WebCore::DragController::declareAndWriteDragImage):
+ * platform/Pasteboard.h:
+ * platform/gtk/DataObjectGtk.cpp: Remove range member, the caller
+ should call setText() + setMarkup() intead.
+ (WebCore::DataObjectGtk::setText):
+ (WebCore::DataObjectGtk::setMarkup):
+ (WebCore::DataObjectGtk::clearText):
+ (WebCore::DataObjectGtk::clearMarkup):
+ (WebCore::DataObjectGtk::clearAllExceptFilenames):
+ * platform/gtk/DataObjectGtk.h:
+ (WebCore::DataObjectGtk::hasText):
+ (WebCore::DataObjectGtk::hasMarkup):
+ (WebCore::DataObjectGtk::clearImage):
+ (WebCore::DataObjectGtk::text):
+ (WebCore::DataObjectGtk::markup):
+ (WebCore::DataObjectGtk::setRange): Deleted.
+ * platform/gtk/GtkDragAndDropHelper.h:
+ * platform/gtk/PasteboardGtk.cpp:
+ (WebCore::PasteboardImage::PasteboardImage):
+ (WebCore::PasteboardImage::~PasteboardImage):
+ (WebCore::Pasteboard::write):
+ (WebCore::Pasteboard::writeSelection): Deleted.
+ (WebCore::getURLForImageElement): Deleted.
+ (WebCore::Pasteboard::writeImage): Deleted.
+ (WebCore::Pasteboard::documentFragment): Deleted.
+ * platform/gtk/PasteboardHelper.cpp:
+ (WebCore::displayFromFrame): Deleted.
+ (WebCore::PasteboardHelper::getPrimarySelectionClipboard): Deleted.
+ * platform/gtk/PasteboardHelper.h:
+
+2014-09-16 Carlos Garcia Campos <cgarcia@igalia.com>
+
</ins><span class="cx"> DragData should not depend on Clipboard, DocumentFragment, and Document
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=21358
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformGTK.cmake (173686 => 173687)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformGTK.cmake        2014-09-17 06:27:46 UTC (rev 173686)
+++ trunk/Source/WebCore/PlatformGTK.cmake        2014-09-17 07:05:45 UTC (rev 173687)
</span><span class="lines">@@ -180,6 +180,7 @@
</span><span class="cx"> accessibility/atk/WebKitAccessibleWrapperAtk.cpp
</span><span class="cx">
</span><span class="cx"> editing/atk/FrameSelectionAtk.cpp
</span><ins>+ editing/gtk/EditorGtk.cpp
</ins><span class="cx">
</span><span class="cx"> page/gtk/DragControllerGtk.cpp
</span><span class="cx"> page/gtk/EventHandlerGtk.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingEditorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/Editor.cpp (173686 => 173687)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/Editor.cpp        2014-09-17 06:27:46 UTC (rev 173686)
+++ trunk/Source/WebCore/editing/Editor.cpp        2014-09-17 07:05:45 UTC (rev 173687)
</span><span class="lines">@@ -562,7 +562,7 @@
</span><span class="cx">
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-#if !PLATFORM(COCOA) && !PLATFORM(EFL)
</del><ins>+#if !PLATFORM(COCOA) && !PLATFORM(EFL) && !PLATFORM(GTK)
</ins><span class="cx"> void Editor::pasteWithPasteboard(Pasteboard* pasteboard, bool allowPlainText, MailBlockquoteHandling mailBlockquoteHandling)
</span><span class="cx"> {
</span><span class="cx"> RefPtr<Range> range = selectedRange();
</span><span class="lines">@@ -1324,13 +1324,13 @@
</span><span class="cx"> imageElement = imageElementFromImageDocument(document());
</span><span class="cx">
</span><span class="cx"> if (imageElement) {
</span><del>-#if PLATFORM(COCOA) || PLATFORM(EFL)
</del><ins>+#if PLATFORM(COCOA) || PLATFORM(EFL) || PLATFORM(GTK)
</ins><span class="cx"> writeImageToPasteboard(*Pasteboard::createForCopyAndPaste(), *imageElement, document().url(), document().title());
</span><span class="cx"> #else
</span><span class="cx"> Pasteboard::createForCopyAndPaste()->writeImage(*imageElement, document().url(), document().title());
</span><span class="cx"> #endif
</span><span class="cx"> } else {
</span><del>-#if PLATFORM(COCOA) || PLATFORM(EFL)
</del><ins>+#if PLATFORM(COCOA) || PLATFORM(EFL) || PLATFORM(GTK)
</ins><span class="cx"> writeSelectionToPasteboard(*Pasteboard::createForCopyAndPaste());
</span><span class="cx"> #else
</span><span class="cx"> // FIXME: Convert all other platforms to match Mac and delete this.
</span><span class="lines">@@ -1436,7 +1436,7 @@
</span><span class="cx"> if (url.isEmpty())
</span><span class="cx"> url = result.absoluteImageURL();
</span><span class="cx">
</span><del>-#if PLATFORM(COCOA) || PLATFORM(EFL)
</del><ins>+#if PLATFORM(COCOA) || PLATFORM(EFL) || PLATFORM(GTK)
</ins><span class="cx"> writeImageToPasteboard(*Pasteboard::createForCopyAndPaste(), *element, url, result.altDisplayString());
</span><span class="cx"> #else
</span><span class="cx"> Pasteboard::createForCopyAndPaste()->writeImage(*element, url, result.altDisplayString());
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingEditorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/Editor.h (173686 => 173687)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/Editor.h        2014-09-17 06:27:46 UTC (rev 173686)
+++ trunk/Source/WebCore/editing/Editor.h        2014-09-17 07:05:45 UTC (rev 173687)
</span><span class="lines">@@ -443,7 +443,7 @@
</span><span class="cx"> #endif // !PLATFORM(IOS)
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-#if PLATFORM(COCOA) || PLATFORM(EFL)
</del><ins>+#if PLATFORM(COCOA) || PLATFORM(EFL) || PLATFORM(GTK)
</ins><span class="cx"> WEBCORE_EXPORT void writeSelectionToPasteboard(Pasteboard&);
</span><span class="cx"> WEBCORE_EXPORT void writeImageToPasteboard(Pasteboard&, Element& imageElement, const URL&, const String& title);
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreeditinggtkEditorGtkcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/editing/gtk/EditorGtk.cpp (0 => 173687)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/gtk/EditorGtk.cpp         (rev 0)
+++ trunk/Source/WebCore/editing/gtk/EditorGtk.cpp        2014-09-17 07:05:45 UTC (rev 173687)
</span><span class="lines">@@ -0,0 +1,132 @@
</span><ins>+/*
+ * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * 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. ``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
+ * 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 "Editor.h"
+
+#include "CachedImage.h"
+#include "DataObjectGtk.h"
+#include "DocumentFragment.h"
+#include "Frame.h"
+#include "HTMLImageElement.h"
+#include "HTMLInputElement.h"
+#include "HTMLNames.h"
+#include "HTMLParserIdioms.h"
+#include "Pasteboard.h"
+#include "RenderImage.h"
+#include "SVGElement.h"
+#include "XLinkNames.h"
+#include "markup.h"
+
+namespace WebCore {
+
+static PassRefPtr<DocumentFragment> createFragmentFromPasteboardData(Pasteboard& pasteboard, Frame& frame, Range& range, bool allowPlainText, bool& chosePlainText)
+{
+ chosePlainText = false;
+
+ if (!pasteboard.hasData())
+ return nullptr;
+
+ RefPtr<DataObjectGtk> dataObject = pasteboard.dataObject();
+ if (dataObject->hasMarkup() && frame.document()) {
+ if (RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(*frame.document(), dataObject->markup(), emptyString(), DisallowScriptingAndPluginContent))
+ return fragment.release();
+ }
+
+ if (!allowPlainText)
+ return nullptr;
+
+ if (dataObject->hasText()) {
+ chosePlainText = true;
+ if (RefPtr<DocumentFragment> fragment = createFragmentFromText(range, dataObject->text()))
+ return fragment.release();
+ }
+
+ return nullptr;
+}
+
+void Editor::pasteWithPasteboard(Pasteboard* pasteboard, bool allowPlainText, MailBlockquoteHandling mailBlockquoteHandling)
+{
+ RefPtr<Range> range = selectedRange();
+ if (!range)
+ return;
+
+ bool chosePlainText;
+ RefPtr<DocumentFragment> fragment = createFragmentFromPasteboardData(*pasteboard, m_frame, *range, allowPlainText, chosePlainText);
+ if (fragment && shouldInsertFragment(fragment, range, EditorInsertActionPasted))
+ pasteAsFragment(fragment, canSmartReplaceWithPasteboard(*pasteboard), chosePlainText, mailBlockquoteHandling);
+}
+
+static const AtomicString& elementURL(Element& element)
+{
+ if (isHTMLImageElement(element) || isHTMLInputElement(element))
+ return element.fastGetAttribute(HTMLNames::srcAttr);
+ if (isSVGImageElement(element))
+ return element.fastGetAttribute(XLinkNames::hrefAttr);
+ if (isHTMLEmbedElement(element) || isHTMLObjectElement(element))
+ return element.imageSourceURL();
+ return nullAtom;
+}
+
+static bool getImageForElement(Element& element, RefPtr<Image>& image)
+{
+ auto renderer = element.renderer();
+ if (!renderer || !renderer->isRenderImage())
+ return false;
+
+ CachedImage* cachedImage = toRenderImage(*renderer).cachedImage();
+ if (!cachedImage || cachedImage->errorOccurred())
+ return false;
+
+ image = cachedImage->imageForRenderer(renderer);
+ return image;
+}
+
+void Editor::writeImageToPasteboard(Pasteboard& pasteboard, Element& imageElement, const URL&, const String& title)
+{
+ PasteboardImage pasteboardImage;
+
+ if (!getImageForElement(imageElement, pasteboardImage.image))
+ return;
+ ASSERT(pasteboardImage.image);
+
+ pasteboardImage.url.url = imageElement.document().completeURL(stripLeadingAndTrailingHTMLSpaces(elementURL(imageElement)));
+ pasteboardImage.url.title = title;
+ pasteboardImage.url.markup = createMarkup(imageElement, IncludeNode, nullptr, ResolveAllURLs);
+ pasteboard.write(pasteboardImage);
+}
+
+void Editor::writeSelectionToPasteboard(Pasteboard& pasteboard)
+{
+ PasteboardWebContent pasteboardContent;
+ pasteboardContent.canSmartCopyOrDelete = canSmartCopyOrDelete();
+ pasteboardContent.text = selectedTextForDataTransfer();
+ pasteboardContent.markup = createMarkup(*selectedRange(), nullptr, AnnotateForInterchange, false, ResolveNonLocalURLs);
+ pasteboardContent.callback = nullptr;
+ pasteboard.write(pasteboardContent);
+}
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCorepageDragControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/DragController.cpp (173686 => 173687)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/DragController.cpp        2014-09-17 06:27:46 UTC (rev 173686)
+++ trunk/Source/WebCore/page/DragController.cpp        2014-09-17 07:05:45 UTC (rev 173687)
</span><span class="lines">@@ -783,7 +783,7 @@
</span><span class="cx"> if (enclosingTextFormControl(src.selection().selection().start()))
</span><span class="cx"> dataTransfer.pasteboard().writePlainText(src.editor().selectedTextForDataTransfer(), Pasteboard::CannotSmartReplace);
</span><span class="cx"> else {
</span><del>-#if PLATFORM(COCOA) || PLATFORM(EFL)
</del><ins>+#if PLATFORM(COCOA) || PLATFORM(EFL) || PLATFORM(GTK)
</ins><span class="cx"> src.editor().writeSelectionToPasteboard(dataTransfer.pasteboard());
</span><span class="cx"> #else
</span><span class="cx"> // FIXME: Convert all other platforms to match Mac and delete this.
</span></span></pre></div>
<a id="trunkSourceWebCorepagegtkDragControllerGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/gtk/DragControllerGtk.cpp (173686 => 173687)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/gtk/DragControllerGtk.cpp        2014-09-17 06:27:46 UTC (rev 173686)
+++ trunk/Source/WebCore/page/gtk/DragControllerGtk.cpp        2014-09-17 07:05:45 UTC (rev 173687)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> #include "Document.h"
</span><span class="cx"> #include "DocumentFragment.h"
</span><span class="cx"> #include "DragData.h"
</span><ins>+#include "Editor.h"
</ins><span class="cx"> #include "Element.h"
</span><span class="cx"> #include "Frame.h"
</span><span class="cx"> #include "FrameView.h"
</span><span class="lines">@@ -75,7 +76,9 @@
</span><span class="cx">
</span><span class="cx"> void DragController::declareAndWriteDragImage(DataTransfer& dataTransfer, Element& element, const URL& url, const String& label)
</span><span class="cx"> {
</span><del>- dataTransfer.pasteboard().writeImage(element, url, label);
</del><ins>+ Frame* frame = element.document().frame();
+ ASSERT(frame);
+ frame->editor().writeImageToPasteboard(dataTransfer.pasteboard(), element, url, label);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> PassRefPtr<DocumentFragment> DragController::createFragmentFromDragData(DragData& dragData, Frame& frame, Range&, bool /*allowPlainText*/, bool& /*chosePlainText*/)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformPasteboardh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/Pasteboard.h (173686 => 173687)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/Pasteboard.h        2014-09-17 06:27:46 UTC (rev 173686)
+++ trunk/Source/WebCore/platform/Pasteboard.h        2014-09-17 07:05:45 UTC (rev 173687)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(GTK)
</span><span class="cx"> typedef struct _GtkClipboard GtkClipboard;
</span><ins>+#include <wtf/gobject/GRefPtr.h>
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="lines">@@ -78,6 +79,12 @@
</span><span class="cx"> Vector<String> clientTypes;
</span><span class="cx"> Vector<RefPtr<SharedBuffer>> clientData;
</span><span class="cx"> #endif
</span><ins>+#if PLATFORM(GTK)
+ bool canSmartCopyOrDelete;
+ String text;
+ String markup;
+ GRefPtr<GClosure> callback;
+#endif
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> struct PasteboardURL {
</span><span class="lines">@@ -86,14 +93,19 @@
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> String userVisibleForm;
</span><span class="cx"> #endif
</span><ins>+#if PLATFORM(GTK)
+ String markup;
+#endif
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> struct PasteboardImage {
</span><span class="cx"> WEBCORE_EXPORT PasteboardImage();
</span><span class="cx"> WEBCORE_EXPORT ~PasteboardImage();
</span><span class="cx"> RefPtr<Image> image;
</span><ins>+#if !(PLATFORM(EFL) || PLATFORM(WIN))
+ PasteboardURL url;
+#endif
</ins><span class="cx"> #if !(PLATFORM(EFL) || PLATFORM(GTK) || PLATFORM(WIN))
</span><del>- PasteboardURL url;
</del><span class="cx"> RefPtr<SharedBuffer> resourceData;
</span><span class="cx"> String resourceMIMEType;
</span><span class="cx"> #endif
</span><span class="lines">@@ -162,7 +174,7 @@
</span><span class="cx"> void setDragImage(DragImageRef, const IntPoint& hotSpot);
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-#if PLATFORM(GTK) || PLATFORM(WIN)
</del><ins>+#if PLATFORM(WIN)
</ins><span class="cx"> PassRefPtr<DocumentFragment> documentFragment(Frame&, Range&, bool allowPlainText, bool& chosePlainText); // FIXME: Layering violation.
</span><span class="cx"> void writeImage(Element&, const URL&, const String& title); // FIXME: Layering violation.
</span><span class="cx"> void writeSelection(Range&, bool canSmartCopyOrDelete, Frame&, ShouldSerializeSelectedTextForDataTransfer = DefaultSelectedTextType); // FIXME: Layering violation.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkDataObjectGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/gtk/DataObjectGtk.cpp (173686 => 173687)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/DataObjectGtk.cpp        2014-09-17 06:27:46 UTC (rev 173686)
+++ trunk/Source/WebCore/platform/gtk/DataObjectGtk.cpp        2014-09-17 07:05:45 UTC (rev 173687)
</span><span class="lines">@@ -19,9 +19,9 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "DataObjectGtk.h"
</span><span class="cx">
</span><del>-#include "markup.h"
</del><span class="cx"> #include <gtk/gtk.h>
</span><span class="cx"> #include <wtf/gobject/GUniquePtr.h>
</span><ins>+#include <wtf/text/CString.h>
</ins><span class="cx"> #include <wtf/text/StringBuilder.h>
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -33,23 +33,6 @@
</span><span class="cx"> str.replace(NonBreakingSpaceCharacter, SpaceCharacter);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-String DataObjectGtk::text() const
-{
- if (m_range) {
- String text = m_range->text();
- replaceNonBreakingSpaceWithSpace(text);
- return text;
- }
- return m_text;
-}
-
-String DataObjectGtk::markup() const
-{
- if (m_range)
- return createMarkup(*m_range, 0, AnnotateForInterchange, false, ResolveNonLocalURLs);
- return m_markup;
-}
-
</del><span class="cx"> HashMap<String, String> DataObjectGtk::unknownTypes() const
</span><span class="cx"> {
</span><span class="cx"> return m_unknownTypeData;
</span><span class="lines">@@ -57,14 +40,12 @@
</span><span class="cx">
</span><span class="cx"> void DataObjectGtk::setText(const String& newText)
</span><span class="cx"> {
</span><del>- m_range = 0;
</del><span class="cx"> m_text = newText;
</span><span class="cx"> replaceNonBreakingSpaceWithSpace(m_text);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void DataObjectGtk::setMarkup(const String& newMarkup)
</span><span class="cx"> {
</span><del>- m_range = 0;
</del><span class="cx"> m_markup = newMarkup;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -131,14 +112,12 @@
</span><span class="cx">
</span><span class="cx"> void DataObjectGtk::clearText()
</span><span class="cx"> {
</span><del>- m_range = 0;
- m_text = "";
</del><ins>+ m_text = emptyString();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void DataObjectGtk::clearMarkup()
</span><span class="cx"> {
</span><del>- m_range = 0;
- m_markup = "";
</del><ins>+ m_markup = emptyString();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> String DataObjectGtk::urlLabel() const
</span><span class="lines">@@ -154,12 +133,11 @@
</span><span class="cx">
</span><span class="cx"> void DataObjectGtk::clearAllExceptFilenames()
</span><span class="cx"> {
</span><del>- m_text = "";
- m_markup = "";
- m_uriList = "";
</del><ins>+ m_text = emptyString();
+ m_markup = emptyString();
+ m_uriList = emptyString();
</ins><span class="cx"> m_url = URL();
</span><del>- m_image = 0;
- m_range = 0;
</del><ins>+ m_image = nullptr;
</ins><span class="cx"> m_unknownTypeData.clear();
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkDataObjectGtkh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/gtk/DataObjectGtk.h (173686 => 173687)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/DataObjectGtk.h        2014-09-17 06:27:46 UTC (rev 173686)
+++ trunk/Source/WebCore/platform/gtk/DataObjectGtk.h        2014-09-17 07:05:45 UTC (rev 173687)
</span><span class="lines">@@ -21,10 +21,8 @@
</span><span class="cx">
</span><span class="cx"> #include "FileList.h"
</span><span class="cx"> #include "URL.h"
</span><del>-#include "Range.h"
</del><span class="cx"> #include <wtf/RefCounted.h>
</span><span class="cx"> #include <wtf/gobject/GRefPtr.h>
</span><del>-#include <wtf/text/CString.h>
</del><span class="cx"> #include <wtf/text/StringHash.h>
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="lines">@@ -40,22 +38,21 @@
</span><span class="cx"> const String& uriList() const { return m_uriList; }
</span><span class="cx"> const Vector<String>& filenames() const { return m_filenames; }
</span><span class="cx"> GdkPixbuf* image() const { return m_image.get(); }
</span><del>- void setRange(PassRefPtr<Range> newRange) { m_range = newRange; }
</del><span class="cx"> void setImage(GdkPixbuf* newImage) { m_image = newImage; }
</span><span class="cx"> void setURL(const URL&, const String&);
</span><span class="cx"> bool hasUnknownTypeData() const { return !m_unknownTypeData.isEmpty(); }
</span><del>- bool hasText() const { return m_range || !m_text.isEmpty(); }
- bool hasMarkup() const { return m_range || !m_markup.isEmpty(); }
</del><ins>+ bool hasText() const { return !m_text.isEmpty(); }
+ bool hasMarkup() const { return !m_markup.isEmpty(); }
</ins><span class="cx"> bool hasURIList() const { return !m_uriList.isEmpty(); }
</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><span class="cx"> void clearURIList() { m_uriList = ""; }
</span><span class="cx"> void clearURL() { m_url = URL(); }
</span><del>- void clearImage() { m_image = 0; }
</del><ins>+ void clearImage() { m_image = nullptr; }
</ins><span class="cx">
</span><del>- String text() const;
- String markup() const;
</del><ins>+ String text() const { return m_text; }
+ String markup() const { return m_markup; }
</ins><span class="cx"> String unknownTypeData(const String& type) const { return m_unknownTypeData.get(type); }
</span><span class="cx"> HashMap<String, String> unknownTypes() const;
</span><span class="cx"> void setText(const String&);
</span><span class="lines">@@ -78,7 +75,6 @@
</span><span class="cx"> String m_uriList;
</span><span class="cx"> Vector<String> m_filenames;
</span><span class="cx"> GRefPtr<GdkPixbuf> m_image;
</span><del>- RefPtr<Range> m_range;
</del><span class="cx"> HashMap<String, String> m_unknownTypeData;
</span><span class="cx"> };
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkGtkDragAndDropHelperh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/gtk/GtkDragAndDropHelper.h (173686 => 173687)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/GtkDragAndDropHelper.h        2014-09-17 06:27:46 UTC (rev 173686)
+++ trunk/Source/WebCore/platform/gtk/GtkDragAndDropHelper.h        2014-09-17 07:05:45 UTC (rev 173687)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx">
</span><span class="cx"> struct DroppingContext;
</span><span class="cx"> class DragData;
</span><ins>+class IntPoint;
</ins><span class="cx">
</span><span class="cx"> typedef void (*DragExitedCallback)(GtkWidget*, DragData&, bool dropHappened);
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkPasteboardGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp (173686 => 173687)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp        2014-09-17 06:27:46 UTC (rev 173686)
+++ trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp        2014-09-17 07:05:45 UTC (rev 173687)
</span><span class="lines">@@ -20,27 +20,14 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "Pasteboard.h"
</span><span class="cx">
</span><del>-#include "CachedImage.h"
</del><span class="cx"> #include "DataObjectGtk.h"
</span><del>-#include "DocumentFragment.h"
</del><span class="cx"> #include "DragData.h"
</span><del>-#include "Editor.h"
-#include "Frame.h"
-#include "HTMLImageElement.h"
-#include "HTMLInputElement.h"
-#include "HTMLNames.h"
-#include "HTMLParserIdioms.h"
</del><span class="cx"> #include "Image.h"
</span><span class="cx"> #include "URL.h"
</span><span class="cx"> #include "PasteboardHelper.h"
</span><del>-#include "RenderImage.h"
-#include "SVGElement.h"
-#include "SVGNames.h"
-#include "XLinkNames.h"
-#include "markup.h"
</del><span class="cx"> #include <gtk/gtk.h>
</span><ins>+#include <wtf/PassOwnPtr.h>
</ins><span class="cx">
</span><del>-
</del><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> enum ClipboardDataType {
</span><span class="lines">@@ -89,6 +76,15 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><ins>+// Making this non-inline so that WebKit 2's decoding doesn't have to include Image.h.
+PasteboardImage::PasteboardImage()
+{
+}
+
+PasteboardImage::~PasteboardImage()
+{
+}
+
</ins><span class="cx"> Pasteboard::Pasteboard(PassRefPtr<DataObjectGtk> dataObject)
</span><span class="cx"> : m_dataObject(dataObject)
</span><span class="cx"> , m_gtkClipboard(0)
</span><span class="lines">@@ -156,16 +152,6 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void Pasteboard::writeSelection(Range& selectedRange, bool canSmartCopyOrDelete, Frame& frame, ShouldSerializeSelectedTextForDataTransfer shouldSerializeSelectedTextForDataTransfer)
-{
- m_dataObject->clearAll();
- m_dataObject->setText(shouldSerializeSelectedTextForDataTransfer == IncludeImageAltTextForDataTransfer ? frame.editor().selectedTextForDataTransfer() : frame.editor().selectedText());
- m_dataObject->setMarkup(createMarkup(selectedRange, 0, AnnotateForInterchange, false, ResolveNonLocalURLs));
-
- if (m_gtkClipboard)
- PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(m_gtkClipboard, canSmartCopyOrDelete ? PasteboardHelper::IncludeSmartPaste : PasteboardHelper::DoNotIncludeSmartPaste);
-}
-
</del><span class="cx"> void Pasteboard::writePlainText(const String& text, SmartReplaceOption smartReplaceOption)
</span><span class="cx"> {
</span><span class="cx"> m_dataObject->clearAll();
</span><span class="lines">@@ -186,46 +172,30 @@
</span><span class="cx"> PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(m_gtkClipboard);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static URL getURLForImageElement(Element& element)
</del><ins>+void Pasteboard::write(const PasteboardImage& pasteboardImage)
</ins><span class="cx"> {
</span><del>- // FIXME: Later this code should be shared with Chromium somehow. Chances are all platforms want it.
- AtomicString urlString;
- if (isHTMLImageElement(element) || isHTMLInputElement(element))
- urlString = element.getAttribute(HTMLNames::srcAttr);
- else if (element.hasTagName(SVGNames::imageTag))
- urlString = element.getAttribute(XLinkNames::hrefAttr);
- else if (element.hasTagName(HTMLNames::embedTag) || isHTMLObjectElement(element))
- urlString = element.imageSourceURL();
</del><ins>+ m_dataObject->clearAll();
+ if (!pasteboardImage.url.url.isEmpty()) {
+ m_dataObject->setURL(pasteboardImage.url.url, pasteboardImage.url.title);
+ m_dataObject->setMarkup(pasteboardImage.url.markup);
+ }
</ins><span class="cx">
</span><del>- return urlString.isEmpty() ? URL() : element.document().completeURL(stripLeadingAndTrailingHTMLSpaces(urlString));
</del><ins>+ GRefPtr<GdkPixbuf> pixbuf = adoptGRef(pasteboardImage.image->getGdkPixbuf());
+ if (pixbuf)
+ m_dataObject->setImage(pixbuf.get());
+
+ if (m_gtkClipboard)
+ PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(m_gtkClipboard);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void Pasteboard::writeImage(Element& element, const URL&, const String& title)
</del><ins>+void Pasteboard::write(const PasteboardWebContent& pasteboardContent)
</ins><span class="cx"> {
</span><del>- if (!(element.renderer() && element.renderer()->isRenderImage()))
- return;
-
- RenderImage* renderer = toRenderImage(element.renderer());
- CachedImage* cachedImage = renderer->cachedImage();
- if (!cachedImage || cachedImage->errorOccurred())
- return;
- Image* image = cachedImage->imageForRenderer(renderer);
- ASSERT(image);
-
</del><span class="cx"> m_dataObject->clearAll();
</span><ins>+ m_dataObject->setText(pasteboardContent.text);
+ m_dataObject->setMarkup(pasteboardContent.markup);
</ins><span class="cx">
</span><del>- URL url = getURLForImageElement(element);
- if (!url.isEmpty()) {
- m_dataObject->setURL(url, title);
-
- m_dataObject->setMarkup(createMarkup(element, IncludeNode, 0, ResolveAllURLs));
- }
-
- GRefPtr<GdkPixbuf> pixbuf = adoptGRef(image->getGdkPixbuf());
- m_dataObject->setImage(pixbuf.get());
-
</del><span class="cx"> if (m_gtkClipboard)
</span><del>- PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(m_gtkClipboard);
</del><ins>+ PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(m_gtkClipboard, pasteboardContent.canSmartCopyOrDelete ? PasteboardHelper::IncludeSmartPaste : PasteboardHelper::DoNotIncludeSmartPaste, pasteboardContent.callback.get());
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void Pasteboard::writePasteboard(const Pasteboard& sourcePasteboard)
</span><span class="lines">@@ -302,34 +272,6 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame& frame, Range& context, bool allowPlainText, bool& chosePlainText)
-{
- if (m_gtkClipboard)
- PasteboardHelper::defaultPasteboardHelper()->getClipboardContents(m_gtkClipboard);
-
- chosePlainText = false;
-
- if (m_dataObject->hasMarkup()) {
- if (frame.document()) {
- RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(*frame.document(), m_dataObject->markup(), emptyString(), DisallowScriptingAndPluginContent);
- if (fragment)
- return fragment.release();
- }
- }
-
- if (!allowPlainText)
- return 0;
-
- if (m_dataObject->hasText()) {
- chosePlainText = true;
- RefPtr<DocumentFragment> fragment = createFragmentFromText(context, m_dataObject->text());
- if (fragment)
- return fragment.release();
- }
-
- return 0;
-}
-
</del><span class="cx"> void Pasteboard::read(PasteboardPlainText& text)
</span><span class="cx"> {
</span><span class="cx"> if (m_gtkClipboard)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkPasteboardHelpercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/gtk/PasteboardHelper.cpp (173686 => 173687)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/PasteboardHelper.cpp        2014-09-17 06:27:46 UTC (rev 173686)
+++ trunk/Source/WebCore/platform/gtk/PasteboardHelper.cpp        2014-09-17 07:05:45 UTC (rev 173687)
</span><span class="lines">@@ -23,16 +23,14 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "PasteboardHelper.h"
</span><span class="cx">
</span><del>-#include "Chrome.h"
</del><span class="cx"> #include "DataObjectGtk.h"
</span><del>-#include "Frame.h"
</del><span class="cx"> #include "GRefPtrGtk.h"
</span><span class="cx"> #include "GtkVersioning.h"
</span><del>-#include "Page.h"
</del><span class="cx"> #include "Pasteboard.h"
</span><span class="cx"> #include "TextResourceDecoder.h"
</span><span class="cx"> #include <gtk/gtk.h>
</span><span class="cx"> #include <wtf/gobject/GUniquePtr.h>
</span><ins>+#include <wtf/text/CString.h>
</ins><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="lines">@@ -95,20 +93,6 @@
</span><span class="cx"> gtk_target_list_unref(m_targetList);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static inline GdkDisplay* displayFromFrame(Frame* frame)
-{
- ASSERT(frame);
- Page* page = frame->page();
- ASSERT(page);
- PlatformPageClient client = page->chrome().platformPageClient();
- return client ? gtk_widget_get_display(client) : gdk_display_get_default();
-}
-
-GtkClipboard* PasteboardHelper::getPrimarySelectionClipboard(Frame* frame) const
-{
- return gtk_clipboard_get_for_display(displayFromFrame(frame), GDK_SELECTION_PRIMARY);
-}
-
</del><span class="cx"> GtkTargetList* PasteboardHelper::targetList() const
</span><span class="cx"> {
</span><span class="cx"> return m_targetList;
</span><span class="lines">@@ -309,12 +293,11 @@
</span><span class="cx"> if (!data)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- GClosure* callback = static_cast<GClosure*>(data);
</del><ins>+ GRefPtr<GClosure> callback = adoptGRef(static_cast<GClosure*>(data));
</ins><span class="cx"> GValue firstArgument = {0, {{0}}};
</span><span class="cx"> g_value_init(&firstArgument, G_TYPE_POINTER);
</span><span class="cx"> g_value_set_pointer(&firstArgument, clipboard);
</span><del>- g_closure_invoke(callback, 0, 1, &firstArgument, 0);
- g_closure_unref(callback);
</del><ins>+ g_closure_invoke(callback.get(), nullptr, 1, &firstArgument, 0);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PasteboardHelper::writeClipboardContents(GtkClipboard* clipboard, SmartPasteInclusion includeSmartPaste, GClosure* callback)
</span><span class="lines">@@ -328,11 +311,14 @@
</span><span class="cx"> if (numberOfTargets > 0 && table) {
</span><span class="cx"> settingClipboardDataObject = dataObject;
</span><span class="cx">
</span><del>- gtk_clipboard_set_with_data(clipboard, table, numberOfTargets,
- getClipboardContentsCallback, clearClipboardContentsCallback, callback);
- gtk_clipboard_set_can_store(clipboard, 0, 0);
</del><ins>+ if (gtk_clipboard_set_with_data(clipboard, table, numberOfTargets, getClipboardContentsCallback, clearClipboardContentsCallback, g_closure_ref(callback)))
+ gtk_clipboard_set_can_store(clipboard, nullptr, 0);
+ else {
+ // When gtk_clipboard_set_with_data fails the callbacks are ignored, so we need to release the reference we were passing to clearClipboardContentsCallback.
+ g_closure_unref(callback);
+ }
</ins><span class="cx">
</span><del>- settingClipboardDataObject = 0;
</del><ins>+ settingClipboardDataObject = nullptr;
</ins><span class="cx">
</span><span class="cx"> } else
</span><span class="cx"> gtk_clipboard_clear(clipboard);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgtkPasteboardHelperh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/gtk/PasteboardHelper.h (173686 => 173687)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/gtk/PasteboardHelper.h        2014-09-17 06:27:46 UTC (rev 173686)
+++ trunk/Source/WebCore/platform/gtk/PasteboardHelper.h        2014-09-17 07:05:45 UTC (rev 173687)
</span><span class="lines">@@ -25,8 +25,8 @@
</span><span class="cx"> #ifndef PasteboardHelper_h
</span><span class="cx"> #define PasteboardHelper_h
</span><span class="cx">
</span><del>-#include "Frame.h"
</del><span class="cx"> #include <glib-object.h>
</span><ins>+#include <wtf/Vector.h>
</ins><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="lines">@@ -40,7 +40,6 @@
</span><span class="cx">
</span><span class="cx"> enum SmartPasteInclusion { IncludeSmartPaste, DoNotIncludeSmartPaste };
</span><span class="cx">
</span><del>- GtkClipboard* getPrimarySelectionClipboard(Frame*) const;
</del><span class="cx"> GtkTargetList* targetList() const;
</span><span class="cx"> GtkTargetList* targetListForDataObject(DataObjectGtk*, SmartPasteInclusion = DoNotIncludeSmartPaste);
</span><span class="cx"> void fillSelectionData(GtkSelectionData*, guint, DataObjectGtk*);
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (173686 => 173687)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-09-17 06:27:46 UTC (rev 173686)
+++ trunk/Source/WebKit2/ChangeLog        2014-09-17 07:05:45 UTC (rev 173687)
</span><span class="lines">@@ -1,5 +1,16 @@
</span><span class="cx"> 2014-09-16 Carlos Garcia Campos <cgarcia@igalia.com>
</span><span class="cx">
</span><ins>+ [GTK] Fix layering violations in PasteboardGtk
+ https://bugs.webkit.org/show_bug.cgi?id=136802
+
+ Reviewed by Darin Adler.
+
+ * WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:
+ (WebKit::WebEditorClient::updateGlobalSelection): Use new API to
+ update the global selection.
+
+2014-09-16 Carlos Garcia Campos <cgarcia@igalia.com>
+
</ins><span class="cx"> DragData should not depend on Clipboard, DocumentFragment, and Document
</span><span class="cx"> https://bugs.webkit.org/show_bug.cgi?id=21358
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportgtkWebEditorClientGtkcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp (173686 => 173687)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp        2014-09-17 06:27:46 UTC (rev 173686)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp        2014-09-17 07:05:45 UTC (rev 173687)
</span><span class="lines">@@ -20,17 +20,19 @@
</span><span class="cx"> #include "config.h"
</span><span class="cx"> #include "WebEditorClient.h"
</span><span class="cx">
</span><del>-#include "Frame.h"
-#include "FrameDestructionObserver.h"
</del><span class="cx"> #include "PlatformKeyboardEvent.h"
</span><span class="cx"> #include "WebPage.h"
</span><span class="cx"> #include "WebPageProxyMessages.h"
</span><span class="cx"> #include "WebProcess.h"
</span><span class="cx"> #include <WebCore/DataObjectGtk.h>
</span><span class="cx"> #include <WebCore/Document.h>
</span><ins>+#include <WebCore/Frame.h>
+#include <WebCore/FrameDestructionObserver.h>
</ins><span class="cx"> #include <WebCore/KeyboardEvent.h>
</span><del>-#include <WebCore/PasteboardHelper.h>
</del><ins>+#include <WebCore/Pasteboard.h>
</ins><span class="cx"> #include <WebCore/WindowsKeyboardCodes.h>
</span><ins>+#include <WebCore/markup.h>
+#include <wtf/gobject/GRefPtr.h>
</ins><span class="cx">
</span><span class="cx"> using namespace WebCore;
</span><span class="cx">
</span><span class="lines">@@ -175,24 +177,25 @@
</span><span class="cx"> void WebEditorClient::updateGlobalSelection(Frame* frame)
</span><span class="cx"> {
</span><span class="cx"> #if PLATFORM(X11)
</span><del>- GtkClipboard* clipboard = PasteboardHelper::defaultPasteboardHelper()->getPrimarySelectionClipboard(frame);
- DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard);
-
</del><span class="cx"> if (!frame->selection().isRange())
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- dataObject->clearAll();
- dataObject->setRange(frame->selection().toNormalizedRange());
-
</del><span class="cx"> frameSettingClipboard = frame;
</span><del>- GClosure* callback = g_cclosure_new(G_CALLBACK(collapseSelection), frame, 0);
</del><ins>+ GRefPtr<GClosure> callback = adoptGRef(g_cclosure_new(G_CALLBACK(collapseSelection), frame, nullptr));
</ins><span class="cx"> // This observer will be self-destroyed on closure finalization,
</span><span class="cx"> // that will happen either after closure execution or after
</span><span class="cx"> // closure invalidation.
</span><del>- new EditorClientFrameDestructionObserver(frame, callback);
- g_closure_set_marshal(callback, g_cclosure_marshal_VOID__VOID);
- PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(clipboard, PasteboardHelper::DoNotIncludeSmartPaste, callback);
- frameSettingClipboard = 0;
</del><ins>+ new EditorClientFrameDestructionObserver(frame, callback.get());
+ g_closure_set_marshal(callback.get(), g_cclosure_marshal_VOID__VOID);
+
+ RefPtr<Range> range = frame->selection().toNormalizedRange();
+ PasteboardWebContent pasteboardContent;
+ pasteboardContent.canSmartCopyOrDelete = false;
+ pasteboardContent.text = range->text();
+ pasteboardContent.markup = createMarkup(*range, nullptr, AnnotateForInterchange, false, ResolveNonLocalURLs);
+ pasteboardContent.callback = callback;
+ Pasteboard::createForGlobalSelection()->write(pasteboardContent);
+ frameSettingClipboard = nullptr;
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>