Diff
Modified: trunk/LayoutTests/ChangeLog (261791 => 261792)
--- trunk/LayoutTests/ChangeLog 2020-05-17 04:55:40 UTC (rev 261791)
+++ trunk/LayoutTests/ChangeLog 2020-05-17 08:35:41 UTC (rev 261792)
@@ -1,3 +1,15 @@
+2020-05-17 Carlos Garcia Campos <[email protected]>
+
+ [GTK] Move to new Pasteboard API
+ https://bugs.webkit.org/show_bug.cgi?id=177633
+
+ Reviewed by Adrian Perez de Castro.
+
+ Update text expectations.
+
+ * platform/gtk/TestExpectations:
+ * platform/gtk/editing/pasteboard/data-transfer-get-data-on-paste-rich-text-expected.txt: Added.
+
2020-05-16 Andy Estes <[email protected]>
REGRESSION (r260717): installmentConfiguration member is no longer available on ApplePayPaymentRequest
Modified: trunk/LayoutTests/platform/gtk/TestExpectations (261791 => 261792)
--- trunk/LayoutTests/platform/gtk/TestExpectations 2020-05-17 04:55:40 UTC (rev 261791)
+++ trunk/LayoutTests/platform/gtk/TestExpectations 2020-05-17 08:35:41 UTC (rev 261792)
@@ -1075,44 +1075,21 @@
webkit.org/b/180370 http/tests/images/image-supports-video.html [ Skip ]
webkit.org/b/180370 fast/images/animated-image-mp4-crash.html [ Skip ]
-# GTK ought to support the new modern pasteboard API
-webkit.org/b/177633 editing/pasteboard/copy-without-selection.html [ Failure ]
-webkit.org/b/177633 editing/pasteboard/copying-html-strips-_javascript_-url-and-event-handler.html [ Failure ]
-webkit.org/b/177633 editing/pasteboard/data-transfer-get-data-on-copying-pasting-malformed-url-in-same-document.html [ Failure ]
-webkit.org/b/177633 editing/pasteboard/data-transfer-get-data-on-paste-custom.html [ Failure ]
-webkit.org/b/177633 editing/pasteboard/data-transfer-get-data-on-paste-plain-text.html [ Failure ]
-webkit.org/b/177633 editing/pasteboard/data-transfer-get-data-on-paste-rich-text.html [ Failure ]
-webkit.org/b/177633 editing/pasteboard/data-transfer-get-data-on-pasting-html-uses-blob-url.html [ Failure ]
-webkit.org/b/177633 editing/pasteboard/data-transfer-items-add-custom-data.html [ Failure ]
-webkit.org/b/177633 editing/pasteboard/data-transfer-set-data-ignore-copied-malformed-url-in-null-origin.html [ Failure ]
-webkit.org/b/177633 editing/pasteboard/data-transfer-set-data-sanitize-url-when-copying-in-null-origin.html [ Failure ]
-webkit.org/b/177633 editing/pasteboard/data-transfer-set-data-sanitizes-html-when-copying-in-null-origin.html [ Failure ]
-webkit.org/b/177633 editing/pasteboard/data-transfer-set-data-sanitizes-html-when-copying.html [ Failure ]
-webkit.org/b/177633 editing/pasteboard/datatransfer-items-paste-plaintext.html [ Skip ]
-webkit.org/b/177633 editing/pasteboard/dataTransfer-types-pasting-plaintext.html [ Failure ]
-webkit.org/b/177633 editing/pasteboard/onpaste-text-html-types.html [ Failure ]
-webkit.org/b/177633 editing/pasteboard/pasting-empty-html-falls-back-to-text.html [ Failure ]
-webkit.org/b/177633 http/tests/security/clipboard/copy-paste-html-cross-origin-iframe-across-origin.html [ Skip ]
-webkit.org/b/177633 http/tests/security/clipboard/copy-paste-html-cross-origin-iframe-in-same-origin.html [ Skip ]
-webkit.org/b/177633 http/tests/security/clipboard/copy-paste-html-across-origin-sanitizes-html.html [ Failure ]
-webkit.org/b/177633 http/tests/security/clipboard/copy-paste-url-across-origin-sanitizes-url.html [ Failure ]
-webkit.org/b/177633 http/tests/security/clipboard/copy-paste-html-across-origin-strips-mso-list.html [ Failure ]
-webkit.org/b/177633 editing/pasteboard/copy-paste-across-shadow-boundaries-with-style-2.html [ Crash ]
-webkit.org/b/177633 editing/pasteboard/paste-text-with-style.html [ Failure Pass ]
-webkit.org/b/177633 editing/pasteboard/paste-without-nesting.html [ Failure Pass ]
-webkit.org/b/177633 editing/async-clipboard/clipboard-change-data-while-writing.html [ Failure ]
-webkit.org/b/177633 editing/async-clipboard/clipboard-read-text-from-platform.html [ Failure ]
-webkit.org/b/177633 editing/async-clipboard/clipboard-change-data-while-getting-type.html [ Timeout ]
-webkit.org/b/177633 editing/async-clipboard/clipboard-change-data-while-reading.html [ Timeout ]
-webkit.org/b/177633 editing/async-clipboard/clipboard-get-type-with-old-items.html [ Timeout ]
-webkit.org/b/177633 editing/async-clipboard/clipboard-read-basic.html [ Timeout ]
-webkit.org/b/177633 editing/async-clipboard/clipboard-read-text-same-origin.html [ Timeout ]
-webkit.org/b/177633 editing/async-clipboard/clipboard-write-basic.html [ Timeout ]
-webkit.org/b/177633 editing/async-clipboard/clipboard-write-items-twice.html [ Timeout ]
-webkit.org/b/177633 editing/async-clipboard/clipboard-write-text.html [ Timeout ]
-webkit.org/b/177633 editing/async-clipboard/clipboard-item-get-type-basic.html [ Failure ]
-webkit.org/b/177633 editing/async-clipboard/clipboard-read-text.html [ Failure ]
-webkit.org/b/177633 editing/async-clipboard/sanitize-when-reading-markup.html [ Failure ]
+# GTK ought to support async clipboard
+webkit.org/b/211979 editing/async-clipboard/clipboard-change-data-while-writing.html [ Failure ]
+webkit.org/b/211979 editing/async-clipboard/clipboard-read-text-from-platform.html [ Failure ]
+webkit.org/b/211979 editing/async-clipboard/clipboard-change-data-while-getting-type.html [ Timeout ]
+webkit.org/b/211979 editing/async-clipboard/clipboard-change-data-while-reading.html [ Timeout ]
+webkit.org/b/211979 editing/async-clipboard/clipboard-get-type-with-old-items.html [ Timeout ]
+webkit.org/b/211979 editing/async-clipboard/clipboard-read-basic.html [ Timeout ]
+webkit.org/b/211979 editing/async-clipboard/clipboard-read-text-same-origin.html [ Timeout ]
+webkit.org/b/211979 editing/async-clipboard/clipboard-write-basic.html [ Timeout ]
+webkit.org/b/211979 editing/async-clipboard/clipboard-write-items-twice.html [ Timeout ]
+webkit.org/b/211979 editing/async-clipboard/clipboard-write-text.html [ Timeout ]
+webkit.org/b/211979 editing/async-clipboard/clipboard-item-get-type-basic.html [ Failure ]
+webkit.org/b/211979 editing/async-clipboard/clipboard-read-text.html [ Failure ]
+webkit.org/b/211979 editing/async-clipboard/sanitize-when-reading-markup.html [ Failure ]
+webkit.org/b/211979 editing/async-clipboard/sanitize-when-writing-image.html [ Failure ]
webkit.org/b/180062 fast/text/user-installed-fonts [ Skip ]
@@ -1193,12 +1170,6 @@
# Server cookie not handled with platform WebSockets API
webkit.org/b/200165 imported/w3c/web-platform-tests/websockets/cookies/007.html [ Failure ]
-# No Mac system fonts in WebKitGTK
-editing/pasteboard/paste-cocoa-writer-markup-with-system-fonts.html [ Failure ]
-
-# We don't use Cocoa
-editing/pasteboard/paste-cocoa-writer-markup-with-webkit-standard-font-family.html [ Failure ]
-
webkit.org/b/205857 media/encrypted-media/mock-MediaKeySession-generateRequest.html [ Skip ]
webkit.org/b/205860 media/encrypted-media/mock-MediaKeySession-remove.html [ Skip ]
@@ -1522,6 +1493,8 @@
webkit.org/b/210926 fast/mediastream/getDisplayMedia-max-constraints2.html [ Skip ]
webkit.org/b/210926 fast/mediastream/getDisplayMedia-max-constraints3.html [ Skip ]
+webkit.org/b/199224 editing/pasteboard/copy-paste-across-shadow-boundaries-with-style-2.html [ Crash ]
+
#////////////////////////////////////////////////////////////////////////////////////////
# End of Crashing tests
#////////////////////////////////////////////////////////////////////////////////////////
@@ -3632,8 +3605,6 @@
webkit.org/b/74282 editing/pasteboard/emacs-ctrl-k-with-move.html [ Failure ]
-webkit.org/b/81320 editing/pasteboard/copy-two-pasteboard-types-both-work.html [ Failure ]
-
webkit.org/b/84679 css3/zoom-coords.xhtml [ Failure ]
webkit.org/b/84694 fast/events/selectstart-by-double-triple-clicks.html [ Failure ]
@@ -4289,10 +4260,6 @@
webkit.org/b/189564 http/tests/xmlhttprequest/url-with-credentials.html [ Failure ]
-webkit.org/b/189737 editing/pasteboard/4930986-1-paste-as-quotation.html [ Failure ]
-webkit.org/b/189737 editing/pasteboard/4930986-2-paste-as-quotation.html [ Failure ]
-webkit.org/b/189737 editing/pasteboard/4930986-3-paste-as-quotation.html [ Failure ]
-
webkit.org/b/189739 svg/gradients/spreadMethodClose2.svg [ ImageOnlyFailure ]
webkit.org/b/189994 fast/files/xhr-response-blob.html [ Failure ]
@@ -4598,6 +4565,8 @@
webkit.org/b/207678 imported/w3c/web-platform-tests/url/a-element-xhtml.xhtml [ Failure ]
webkit.org/b/207678 imported/w3c/web-platform-tests/url/a-element.html [ Failure ]
+webkit.org/b/211981 editing/pasteboard/data-transfer-get-data-on-pasting-html-uses-blob-url.html [ Failure ]
+
#////////////////////////////////////////////////////////////////////////////////////////
# End of non-crashing, non-flaky tests failing
#////////////////////////////////////////////////////////////////////////////////////////
Added: trunk/LayoutTests/platform/gtk/editing/pasteboard/data-transfer-get-data-on-paste-rich-text-expected.txt (0 => 261792)
--- trunk/LayoutTests/platform/gtk/editing/pasteboard/data-transfer-get-data-on-paste-rich-text-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/gtk/editing/pasteboard/data-transfer-get-data-on-paste-rich-text-expected.txt 2020-05-17 08:35:41 UTC (rev 261792)
@@ -0,0 +1,7 @@
+Rich text
+{
+ "paste": {
+ "text/html": "<span style=\"...\"\">Rich text</span>",
+ "text/plain": "Rich text"
+ }
+}
Modified: trunk/Source/WebCore/ChangeLog (261791 => 261792)
--- trunk/Source/WebCore/ChangeLog 2020-05-17 04:55:40 UTC (rev 261791)
+++ trunk/Source/WebCore/ChangeLog 2020-05-17 08:35:41 UTC (rev 261792)
@@ -1,3 +1,43 @@
+2020-05-17 Carlos Garcia Campos <[email protected]>
+
+ [GTK] Move to new Pasteboard API
+ https://bugs.webkit.org/show_bug.cgi?id=177633
+
+ Reviewed by Adrian Perez de Castro.
+
+ Add support for custom data and remove the support for unknown data types that is currently unused.
+
+ * editing/gtk/EditorGtk.cpp:
+ (WebCore::Editor::writeSelectionToPasteboard): Set the contentOrigin.
+ * editing/gtk/WebContentReaderGtk.cpp:
+ (WebCore::shouldReplaceSubresourceURL): Helper to decide whether to replace the subresource URL.
+ (WebCore::WebContentMarkupReader::readHTML): Create a fragment for HTML sanitizing it if needed.
+ * platform/Pasteboard.h:
+ * platform/PasteboardCustomData.h:
+ (WebCore::PasteboardCustomData::gtkType): Mime type name for GTK custom pasteboard data.
+ * platform/SharedBuffer.h:
+ * platform/glib/SharedBufferGlib.cpp:
+ (WebCore::SharedBuffer::createGBytes const): Create a GBytes wrapping the SharedBuffer data.
+ * platform/gtk/PasteboardGtk.cpp:
+ (WebCore::Pasteboard::writeString):
+ (WebCore::Pasteboard::write):
+ (WebCore::Pasteboard::read):
+ (WebCore::Pasteboard::hasData):
+ (WebCore::Pasteboard::typesSafeForBindings):
+ (WebCore::Pasteboard::typesForLegacyUnsafeBindings):
+ (WebCore::Pasteboard::readOrigin):
+ (WebCore::Pasteboard::readString):
+ (WebCore::Pasteboard::readStringInCustomData):
+ (WebCore::Pasteboard::fileContentState):
+ (WebCore::Pasteboard::writeCustomData):
+ * platform/gtk/SelectionData.cpp:
+ (WebCore::SelectionData::clearAllExceptFilenames):
+ * platform/gtk/SelectionData.h:
+ (WebCore::SelectionData::setCustomData):
+ (WebCore::SelectionData::customData const):
+ (WebCore::SelectionData::hasCustomData const):
+ (WebCore::SelectionData::clearCustomData):
+
2020-05-16 Simon Fraser <[email protected]>
Some color-related cleanup
Modified: trunk/Source/WebCore/editing/gtk/EditorGtk.cpp (261791 => 261792)
--- trunk/Source/WebCore/editing/gtk/EditorGtk.cpp 2020-05-17 04:55:40 UTC (rev 261791)
+++ trunk/Source/WebCore/editing/gtk/EditorGtk.cpp 2020-05-17 08:35:41 UTC (rev 261792)
@@ -110,6 +110,7 @@
pasteboardContent.text = selectedTextForDataTransfer();
pasteboardContent.markup = serializePreservingVisualAppearance(m_document.selection().selection(), ResolveURLs::YesExcludingLocalFileURLsForPrivacy,
m_document.settings().selectionAcrossShadowBoundariesEnabled() ? SerializeComposedTree::Yes : SerializeComposedTree::No);
+ pasteboardContent.contentOrigin = m_document.originIdentifierForPasteboard();
pasteboard.write(pasteboardContent);
}
Modified: trunk/Source/WebCore/editing/gtk/WebContentReaderGtk.cpp (261791 => 261792)
--- trunk/Source/WebCore/editing/gtk/WebContentReaderGtk.cpp 2020-05-17 04:55:40 UTC (rev 261791)
+++ trunk/Source/WebCore/editing/gtk/WebContentReaderGtk.cpp 2020-05-17 08:35:41 UTC (rev 261792)
@@ -85,9 +85,26 @@
return false;
}
-bool WebContentMarkupReader::readHTML(const String&)
+static bool shouldReplaceSubresourceURL(const URL& url)
{
- return false;
+ return !(url.protocolIsInHTTPFamily() || url.protocolIsData());
}
+bool WebContentMarkupReader::readHTML(const String& string)
+{
+ if (!frame.document())
+ return false;
+
+ if (shouldSanitize()) {
+ markup = sanitizeMarkup(string, MSOListQuirks::Disabled, Function<void(DocumentFragment&)> { [](DocumentFragment& fragment) {
+ removeSubresourceURLAttributes(fragment, [](const URL& url) {
+ return shouldReplaceSubresourceURL(url);
+ });
+ } });
+ } else
+ markup = string;
+
+ return !markup.isEmpty();
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/Pasteboard.h (261791 => 261792)
--- trunk/Source/WebCore/platform/Pasteboard.h 2020-05-17 04:55:40 UTC (rev 261791)
+++ trunk/Source/WebCore/platform/Pasteboard.h 2020-05-17 08:35:41 UTC (rev 261792)
@@ -87,6 +87,7 @@
Vector<RefPtr<SharedBuffer>> clientData;
#endif
#if PLATFORM(GTK)
+ String contentOrigin;
bool canSmartCopyOrDelete;
String text;
String markup;
Modified: trunk/Source/WebCore/platform/PasteboardCustomData.h (261791 => 261792)
--- trunk/Source/WebCore/platform/PasteboardCustomData.h 2020-05-17 04:55:40 UTC (rev 261791)
+++ trunk/Source/WebCore/platform/PasteboardCustomData.h 2020-05-17 08:35:41 UTC (rev 261792)
@@ -75,6 +75,8 @@
#if PLATFORM(COCOA)
WEBCORE_EXPORT static const char* cocoaType();
+#elif PLATFORM(GTK)
+ static const char* gtkType() { return "org.webkitgtk.WebKit.custom-pasteboard-data"; }
#endif
void forEachType(Function<void(const String&)>&&) const;
Modified: trunk/Source/WebCore/platform/SharedBuffer.h (261791 => 261792)
--- trunk/Source/WebCore/platform/SharedBuffer.h 2020-05-17 04:55:40 UTC (rev 261791)
+++ trunk/Source/WebCore/platform/SharedBuffer.h 2020-05-17 08:35:41 UTC (rev 261792)
@@ -96,6 +96,7 @@
#if USE(GLIB)
static Ref<SharedBuffer> create(GBytes*);
+ GRefPtr<GBytes> createGBytes() const;
#endif
#if USE(GSTREAMER)
Modified: trunk/Source/WebCore/platform/glib/SharedBufferGlib.cpp (261791 => 261792)
--- trunk/Source/WebCore/platform/glib/SharedBufferGlib.cpp 2020-05-17 04:55:40 UTC (rev 261791)
+++ trunk/Source/WebCore/platform/glib/SharedBufferGlib.cpp 2020-05-17 08:35:41 UTC (rev 261792)
@@ -38,6 +38,15 @@
return adoptRef(*new SharedBuffer(bytes));
}
+GRefPtr<GBytes> SharedBuffer::createGBytes() const
+{
+ ref();
+ GRefPtr<GBytes> bytes = adoptGRef(g_bytes_new_with_free_func(data(), size(), [](gpointer data) {
+ static_cast<SharedBuffer*>(data)->deref();
+ }, const_cast<SharedBuffer*>(this)));
+ return bytes;
+}
+
RefPtr<SharedBuffer> SharedBuffer::createFromReadingFile(const String& filePath)
{
if (filePath.isEmpty())
Modified: trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp (261791 => 261792)
--- trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp 2020-05-17 04:55:40 UTC (rev 261791)
+++ trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp 2020-05-17 08:35:41 UTC (rev 261792)
@@ -116,8 +116,6 @@
m_selectionData->setText(data);
break;
case ClipboardDataTypeUnknown:
- m_selectionData->setUnknownTypeData(type, data);
- break;
case ClipboardDataTypeImage:
break;
}
@@ -187,6 +185,9 @@
data.setText(pasteboardContent.text);
data.setMarkup(pasteboardContent.markup);
data.setCanSmartReplace(pasteboardContent.canSmartCopyOrDelete);
+ PasteboardCustomData customData;
+ customData.setOrigin(pasteboardContent.contentOrigin);
+ data.setCustomData(customData.createSharedBuffer());
platformStrategies()->pasteboardStrategy()->writeToClipboard(m_name, WTFMove(data));
}
}
@@ -264,6 +265,8 @@
return;
}
+ reader.contentOrigin = readOrigin();
+
auto types = platformStrategies()->pasteboardStrategy()->types(m_name);
if (types.contains("text/html"_s)) {
auto buffer = platformStrategies()->pasteboardStrategy()->readBufferFromClipboard(m_name, "text/html"_s);
@@ -306,14 +309,16 @@
bool Pasteboard::hasData()
{
if (m_selectionData)
- return m_selectionData->hasText() || m_selectionData->hasMarkup() || m_selectionData->hasURIList() || m_selectionData->hasImage() || m_selectionData->hasUnknownTypeData();
+ return m_selectionData->hasText() || m_selectionData->hasMarkup() || m_selectionData->hasURIList() || m_selectionData->hasImage();
return !platformStrategies()->pasteboardStrategy()->types(m_name).isEmpty();
}
-Vector<String> Pasteboard::typesSafeForBindings(const String&)
+Vector<String> Pasteboard::typesSafeForBindings(const String& origin)
{
- notImplemented(); // webkit.org/b/177633: [GTK] Move to new Pasteboard API
- return { };
+ if (m_selectionData)
+ return { };
+
+ return platformStrategies()->pasteboardStrategy()->typesSafeForDOMToReadAndWrite(m_name, origin);
}
Vector<String> Pasteboard::typesForLegacyUnsafeBindings()
@@ -336,15 +341,18 @@
types.append("URL"_s);
}
- for (auto& key : m_selectionData->unknownTypes().keys())
- types.append(key);
-
return types;
}
String Pasteboard::readOrigin()
{
- notImplemented(); // webkit.org/b/177633: [GTK] Move to new Pasteboard API
+ if (m_selectionData)
+ return { };
+
+ // FIXME: cache custom data?
+ if (auto buffer = platformStrategies()->pasteboardStrategy()->readBufferFromClipboard(m_name, PasteboardCustomData::gtkType()))
+ return PasteboardCustomData::fromSharedBuffer(*buffer).origin();
+
return { };
}
@@ -368,7 +376,6 @@
case ClipboardDataTypeText:
return m_selectionData->text();
case ClipboardDataTypeUnknown:
- return m_selectionData->unknownTypeData(type);
case ClipboardDataTypeImage:
break;
}
@@ -376,9 +383,15 @@
return { };
}
-String Pasteboard::readStringInCustomData(const String&)
+String Pasteboard::readStringInCustomData(const String& type)
{
- notImplemented(); // webkit.org/b/177633: [GTK] Move to new Pasteboard API
+ if (m_selectionData)
+ return { };
+
+ // FIXME: cache custom data?
+ if (auto buffer = platformStrategies()->pasteboardStrategy()->readBufferFromClipboard(m_name, PasteboardCustomData::gtkType()))
+ return PasteboardCustomData::fromSharedBuffer(*buffer).readStringInCustomData(type);
+
return { };
}
@@ -388,8 +401,11 @@
return m_selectionData->filenames().isEmpty() ? FileContentState::NoFileOrImageData : FileContentState::MayContainFilePaths;
auto types = platformStrategies()->pasteboardStrategy()->types(m_name);
- if (types.contains("text/uri-list"_s))
- return FileContentState::MayContainFilePaths;
+ if (types.contains("text/uri-list"_s)) {
+ auto filePaths = platformStrategies()->pasteboardStrategy()->readFilePathsFromClipboard(m_name);
+ if (!filePaths.isEmpty())
+ return FileContentState::MayContainFilePaths;
+ }
auto result = types.findMatching([](const String& type) {
return MIMETypeRegistry::isSupportedImageMIMEType(type);
@@ -401,8 +417,12 @@
{
}
-void Pasteboard::writeCustomData(const Vector<PasteboardCustomData>&)
+void Pasteboard::writeCustomData(const Vector<PasteboardCustomData>& data)
{
+ if (m_selectionData)
+ return;
+
+ platformStrategies()->pasteboardStrategy()->writeCustomData(data, m_name);
}
void Pasteboard::write(const Color&)
Modified: trunk/Source/WebCore/platform/gtk/SelectionData.cpp (261791 => 261792)
--- trunk/Source/WebCore/platform/gtk/SelectionData.cpp 2020-05-17 04:55:40 UTC (rev 261791)
+++ trunk/Source/WebCore/platform/gtk/SelectionData.cpp 2020-05-17 08:35:41 UTC (rev 261792)
@@ -120,8 +120,8 @@
clearURIList();
clearURL();
clearImage();
+ clearCustomData();
- m_unknownTypeData.clear();
m_canSmartReplace = false;
}
Modified: trunk/Source/WebCore/platform/gtk/SelectionData.h (261791 => 261792)
--- trunk/Source/WebCore/platform/gtk/SelectionData.h 2020-05-17 04:55:40 UTC (rev 261791)
+++ trunk/Source/WebCore/platform/gtk/SelectionData.h 2020-05-17 08:35:41 UTC (rev 261792)
@@ -19,6 +19,7 @@
#pragma once
#include "Image.h"
+#include "SharedBuffer.h"
#include <wtf/HashMap.h>
#include <wtf/RefCounted.h>
#include <wtf/URL.h>
@@ -62,14 +63,14 @@
bool hasImage() const { return m_image; }
void clearImage() { m_image = nullptr; }
- void setUnknownTypeData(const String& type, const String& data) { m_unknownTypeData.set(type, data); }
- String unknownTypeData(const String& type) const { return m_unknownTypeData.get(type); }
- const HashMap<String, String>& unknownTypes() const { return m_unknownTypeData; }
- bool hasUnknownTypeData() const { return !m_unknownTypeData.isEmpty(); }
-
void setCanSmartReplace(bool canSmartReplace) { m_canSmartReplace = canSmartReplace; }
bool canSmartReplace() const { return m_canSmartReplace; }
+ void setCustomData(Ref<SharedBuffer>&& buffer) { m_customData = WTFMove(buffer); }
+ SharedBuffer* customData() const { return m_customData.get(); }
+ bool hasCustomData() const { return !!m_customData; }
+ void clearCustomData() { m_customData = nullptr; }
+
void clearAll();
void clearAllExceptFilenames();
@@ -80,8 +81,8 @@
String m_uriList;
Vector<String> m_filenames;
RefPtr<Image> m_image;
- HashMap<String, String> m_unknownTypeData;
bool m_canSmartReplace { false };
+ RefPtr<SharedBuffer> m_customData;
};
} // namespace WebCore
Modified: trunk/Source/WebKit/ChangeLog (261791 => 261792)
--- trunk/Source/WebKit/ChangeLog 2020-05-17 04:55:40 UTC (rev 261791)
+++ trunk/Source/WebKit/ChangeLog 2020-05-17 08:35:41 UTC (rev 261792)
@@ -1,3 +1,25 @@
+2020-05-17 Carlos Garcia Campos <[email protected]>
+
+ [GTK] Move to new Pasteboard API
+ https://bugs.webkit.org/show_bug.cgi?id=177633
+
+ Reviewed by Adrian Perez de Castro.
+
+ Enable custom pasteboard data.
+
+ * Shared/WebPreferencesDefaultValues.h:
+ * Shared/gtk/ArgumentCodersGtk.cpp:
+ (IPC::ArgumentCoder<SelectionData>::encode):
+ (IPC::ArgumentCoder<SelectionData>::decode):
+ * UIProcess/WebPasteboardProxy.cpp:
+ * UIProcess/gtk/ClipboardGtk3.cpp:
+ (WebKit::Clipboard::write): Add support for writing URI list and custom data.
+ * UIProcess/gtk/ClipboardGtk4.cpp:
+ (WebKit::Clipboard::write): Ditto.
+ * UIProcess/gtk/WebPasteboardProxyGtk.cpp:
+ (WebKit::WebPasteboardProxy::typesSafeForDOMToReadAndWrite):
+ (WebKit::WebPasteboardProxy::writeCustomData):
+
2020-05-16 Andy Estes <[email protected]>
REGRESSION (r260717): installmentConfiguration member is no longer available on ApplePayPaymentRequest
Modified: trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h (261791 => 261792)
--- trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h 2020-05-17 04:55:40 UTC (rev 261791)
+++ trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h 2020-05-17 08:35:41 UTC (rev 261792)
@@ -238,11 +238,15 @@
#define DEFAULT_DATALIST_ELEMENT_ENABLED true
#endif
+#if PLATFORM(COCOA) || PLATFORM(GTK)
+#define DEFAULT_CUSTOM_PASTEBOARD_DATA_ENABLED true
+#else
+#define DEFAULT_CUSTOM_PASTEBOARD_DATA_ENABLED false
+#endif
+
#if PLATFORM(COCOA)
-#define DEFAULT_CUSTOM_PASTEBOARD_DATA_ENABLED true
#define DEFAULT_ASYNC_CLIPBOARD_API_ENABLED true
#else
-#define DEFAULT_CUSTOM_PASTEBOARD_DATA_ENABLED false
#define DEFAULT_ASYNC_CLIPBOARD_API_ENABLED false
#endif
Modified: trunk/Source/WebKit/Shared/gtk/ArgumentCodersGtk.cpp (261791 => 261792)
--- trunk/Source/WebKit/Shared/gtk/ArgumentCodersGtk.cpp 2020-05-17 04:55:40 UTC (rev 261791)
+++ trunk/Source/WebKit/Shared/gtk/ArgumentCodersGtk.cpp 2020-05-17 08:35:41 UTC (rev 261792)
@@ -92,10 +92,10 @@
if (hasImage)
encodeImage(encoder, *selection.image());
- bool hasUnknownTypeData = selection.hasUnknownTypeData();
- encoder << hasUnknownTypeData;
- if (hasUnknownTypeData)
- encoder << selection.unknownTypes();
+ bool hasCustomData = selection.hasCustomData();
+ encoder << hasCustomData;
+ if (hasCustomData)
+ encoder << RefPtr<SharedBuffer>(selection.customData());
bool canSmartReplace = selection.canSmartReplace();
encoder << canSmartReplace;
@@ -155,17 +155,14 @@
selection.setImage(image.get());
}
- bool hasUnknownTypeData;
- if (!decoder.decode(hasUnknownTypeData))
+ bool hasCustomData;
+ if (!decoder.decode(hasCustomData))
return false;
- if (hasUnknownTypeData) {
- HashMap<String, String> unknownTypes;
- if (!decoder.decode(unknownTypes))
+ if (hasCustomData) {
+ RefPtr<SharedBuffer> buffer;
+ if (!decoder.decode(buffer))
return false;
-
- auto end = unknownTypes.end();
- for (auto it = unknownTypes.begin(); it != end; ++it)
- selection.setUnknownTypeData(it->key, it->value);
+ selection.setCustomData(Ref<SharedBuffer>(*buffer));
}
bool canSmartReplace;
Modified: trunk/Source/WebKit/UIProcess/WebPasteboardProxy.cpp (261791 => 261792)
--- trunk/Source/WebKit/UIProcess/WebPasteboardProxy.cpp 2020-05-17 04:55:40 UTC (rev 261791)
+++ trunk/Source/WebKit/UIProcess/WebPasteboardProxy.cpp 2020-05-17 08:35:41 UTC (rev 261792)
@@ -79,6 +79,7 @@
#if !PLATFORM(COCOA)
+#if !PLATFORM(GTK)
void WebPasteboardProxy::typesSafeForDOMToReadAndWrite(IPC::Connection&, const String&, const String&, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
{
completionHandler({ });
@@ -88,6 +89,7 @@
{
completionHandler(0);
}
+#endif
void WebPasteboardProxy::allPasteboardItemInfo(IPC::Connection&, const String&, int64_t, CompletionHandler<void(Optional<Vector<WebCore::PasteboardItemInfo>>&&)>&& completionHandler)
{
Modified: trunk/Source/WebKit/UIProcess/gtk/ClipboardGtk3.cpp (261791 => 261792)
--- trunk/Source/WebKit/UIProcess/gtk/ClipboardGtk3.cpp 2020-05-17 04:55:40 UTC (rev 261791)
+++ trunk/Source/WebKit/UIProcess/gtk/ClipboardGtk3.cpp 2020-05-17 08:35:41 UTC (rev 261792)
@@ -30,6 +30,7 @@
#include "WebPasteboardProxy.h"
#include <WebCore/GRefPtrGtk.h>
+#include <WebCore/PasteboardCustomData.h>
#include <WebCore/SelectionData.h>
#include <WebCore/SharedBuffer.h>
#include <gtk/gtk.h>
@@ -155,7 +156,7 @@
Clipboard& clipboard;
};
-enum ClipboardTargetType { Markup, Text, Image, SmartPaste };
+enum ClipboardTargetType { Markup, Text, Image, URIList, SmartPaste, Custom };
void Clipboard::write(Ref<WebCore::SelectionData>&& selectionData)
{
@@ -162,6 +163,8 @@
SetForScope<WebFrameProxy*> frameWritingToClipboard(m_frameWritingToClipboard, WebPasteboardProxy::singleton().primarySelectionOwner());
GRefPtr<GtkTargetList> list = adoptGRef(gtk_target_list_new(nullptr, 0));
+ if (selectionData->hasURIList())
+ gtk_target_list_add(list.get(), gdk_atom_intern_static_string("text/uri-list"), 0, ClipboardTargetType::URIList);
if (selectionData->hasMarkup())
gtk_target_list_add(list.get(), gdk_atom_intern_static_string("text/html"), 0, ClipboardTargetType::Markup);
if (selectionData->hasImage())
@@ -170,6 +173,8 @@
gtk_target_list_add_text_targets(list.get(), ClipboardTargetType::Text);
if (selectionData->canSmartReplace())
gtk_target_list_add(list.get(), gdk_atom_intern_static_string("application/vnd.webkitgtk.smartpaste"), 0, ClipboardTargetType::SmartPaste);
+ if (selectionData->hasCustomData())
+ gtk_target_list_add(list.get(), gdk_atom_intern_static_string(WebCore::PasteboardCustomData::gtkType()), 0, ClipboardTargetType::Custom);
int numberOfTargets;
GtkTargetEntry* table = gtk_target_table_new_from_list(list.get(), &numberOfTargets);
@@ -199,9 +204,20 @@
}
break;
}
+ case ClipboardTargetType::URIList: {
+ CString uriList = selectionData.uriList().utf8();
+ gtk_selection_data_set(selection, gdk_atom_intern_static_string("text/uri-list"), 8, reinterpret_cast<const guchar*>(uriList.data()), uriList.length());
+ break;
+ }
case ClipboardTargetType::SmartPaste:
gtk_selection_data_set_text(selection, "", -1);
break;
+ case ClipboardTargetType::Custom:
+ if (selectionData.hasCustomData()) {
+ auto* buffer = selectionData.customData();
+ gtk_selection_data_set(selection, gdk_atom_intern_static_string(WebCore::PasteboardCustomData::gtkType()), 8, reinterpret_cast<const guchar*>(buffer->data()), buffer->size());
+ }
+ break;
}
},
[](GtkClipboard* clipboard, gpointer userData) {
Modified: trunk/Source/WebKit/UIProcess/gtk/ClipboardGtk4.cpp (261791 => 261792)
--- trunk/Source/WebKit/UIProcess/gtk/ClipboardGtk4.cpp 2020-05-17 04:55:40 UTC (rev 261791)
+++ trunk/Source/WebKit/UIProcess/gtk/ClipboardGtk4.cpp 2020-05-17 08:35:41 UTC (rev 261792)
@@ -29,6 +29,7 @@
#if USE(GTK4)
#include "WebPasteboardProxy.h"
+#include <WebCore/PasteboardCustomData.h>
#include <WebCore/SelectionData.h>
#include <WebCore/SharedBuffer.h>
#include <gtk/gtk.h>
@@ -164,6 +165,12 @@
providers.append(gdk_content_provider_new_for_bytes("text/html", bytes.get()));
}
+ if (selectionData->hasURIList()) {
+ CString uriList = selectionData->uriList().utf8();
+ GRefPtr<GBytes> bytes = adoptGRef(g_bytes_new(uriList.data(), uriList.length()));
+ providers.append(gdk_content_provider_new_for_bytes("text/uri-list", bytes.get()));
+ }
+
if (selectionData->hasImage()) {
GRefPtr<GdkPixbuf> pixbuf = adoptGRef(selectionData->image()->getGdkPixbuf());
providers.append(gdk_content_provider_new_typed(GDK_TYPE_PIXBUF, pixbuf.get()));
@@ -177,6 +184,11 @@
providers.append(gdk_content_provider_new_for_bytes("application/vnd.webkitgtk.smartpaste", bytes.get()));
}
+ if (selectionData->hasCustomData()) {
+ GRefPtr<GBytes> bytes = selectionData->customData()->createGBytes();
+ providers.append(gdk_content_provider_new_for_bytes(WebCore::PasteboardCustomData::gtkType(), bytes.get()));
+ }
+
if (providers.isEmpty()) {
clear();
return;
Modified: trunk/Source/WebKit/UIProcess/gtk/WebPasteboardProxyGtk.cpp (261791 => 261792)
--- trunk/Source/WebKit/UIProcess/gtk/WebPasteboardProxyGtk.cpp 2020-05-17 04:55:40 UTC (rev 261791)
+++ trunk/Source/WebKit/UIProcess/gtk/WebPasteboardProxyGtk.cpp 2020-05-17 08:35:41 UTC (rev 261792)
@@ -30,8 +30,12 @@
#include "SharedBufferDataReference.h"
#include "WebFrameProxy.h"
#include "WebSelectionData.h"
+#include <WebCore/Pasteboard.h>
+#include <WebCore/PasteboardCustomData.h>
+#include <WebCore/PasteboardItemInfo.h>
#include <WebCore/PlatformPasteboard.h>
#include <WebCore/SharedBuffer.h>
+#include <wtf/ListHashSet.h>
#include <wtf/SetForScope.h>
namespace WebKit {
@@ -84,4 +88,59 @@
m_primarySelectionOwner = nullptr;
}
+void WebPasteboardProxy::typesSafeForDOMToReadAndWrite(IPC::Connection&, const String& pasteboardName, const String& origin, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
+{
+ auto& clipboard = Clipboard::get(pasteboardName);
+ clipboard.readBuffer(PasteboardCustomData::gtkType(), [&clipboard, origin, completionHandler = WTFMove(completionHandler)](IPC::SharedBufferDataReference&& buffer) mutable {
+ ListHashSet<String> domTypes;
+ if (auto dataBuffer = buffer.buffer()) {
+ auto customData = PasteboardCustomData::fromSharedBuffer(*dataBuffer);
+ if (customData.origin() == origin) {
+ for (auto& type : customData.orderedTypes())
+ domTypes.add(type);
+ }
+ }
+
+ clipboard.formats([domTypes = WTFMove(domTypes), completionHandler = WTFMove(completionHandler)](Vector<String>&& formats) mutable {
+ for (const auto& format : formats) {
+ if (format == PasteboardCustomData::gtkType())
+ continue;
+
+ if (Pasteboard::isSafeTypeForDOMToReadAndWrite(format))
+ domTypes.add(format);
+ }
+
+ completionHandler(copyToVector(domTypes));
+ });
+ });
+}
+
+void WebPasteboardProxy::writeCustomData(IPC::Connection&, const Vector<PasteboardCustomData>& data, const String& pasteboardName, CompletionHandler<void(int64_t)>&& completionHandler)
+{
+ if (data.isEmpty() || data.size() > 1) {
+ // We don't support more than one custom item in the clipboard.
+ completionHandler(0);
+ return;
+ }
+
+ auto selectionData = SelectionData::create();
+ const auto& customData = data[0];
+ customData.forEachPlatformStringOrBuffer([&selectionData] (auto& type, auto& stringOrBuffer) {
+ if (WTF::holds_alternative<String>(stringOrBuffer)) {
+ if (type == "text/plain"_s)
+ selectionData->setText(WTF::get<String>(stringOrBuffer));
+ else if (type == "text/html"_s)
+ selectionData->setMarkup(WTF::get<String>(stringOrBuffer));
+ else if (type == "text/uri-list"_s)
+ selectionData->setURIList(WTF::get<String>(stringOrBuffer));
+ }
+ });
+
+ if (customData.hasSameOriginCustomData() || !customData.origin().isEmpty())
+ selectionData->setCustomData(customData.createSharedBuffer());
+
+ Clipboard::get(pasteboardName).write(WTFMove(selectionData));
+ completionHandler(0);
+}
+
} // namespace WebKit