Changeset 261792 in webkit
- Timestamp:
- May 17, 2020 1:35:41 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r261785 r261792 1 2020-05-17 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Move to new Pasteboard API 4 https://bugs.webkit.org/show_bug.cgi?id=177633 5 6 Reviewed by Adrian Perez de Castro. 7 8 Update text expectations. 9 10 * platform/gtk/TestExpectations: 11 * platform/gtk/editing/pasteboard/data-transfer-get-data-on-paste-rich-text-expected.txt: Added. 12 1 13 2020-05-16 Andy Estes <aestes@apple.com> 2 14 -
trunk/LayoutTests/platform/gtk/TestExpectations
r261744 r261792 1076 1076 webkit.org/b/180370 fast/images/animated-image-mp4-crash.html [ Skip ] 1077 1077 1078 # GTK ought to support the new modern pasteboard API 1079 webkit.org/b/177633 editing/pasteboard/copy-without-selection.html [ Failure ] 1080 webkit.org/b/177633 editing/pasteboard/copying-html-strips-javascript-url-and-event-handler.html [ Failure ] 1081 webkit.org/b/177633 editing/pasteboard/data-transfer-get-data-on-copying-pasting-malformed-url-in-same-document.html [ Failure ] 1082 webkit.org/b/177633 editing/pasteboard/data-transfer-get-data-on-paste-custom.html [ Failure ] 1083 webkit.org/b/177633 editing/pasteboard/data-transfer-get-data-on-paste-plain-text.html [ Failure ] 1084 webkit.org/b/177633 editing/pasteboard/data-transfer-get-data-on-paste-rich-text.html [ Failure ] 1085 webkit.org/b/177633 editing/pasteboard/data-transfer-get-data-on-pasting-html-uses-blob-url.html [ Failure ] 1086 webkit.org/b/177633 editing/pasteboard/data-transfer-items-add-custom-data.html [ Failure ] 1087 webkit.org/b/177633 editing/pasteboard/data-transfer-set-data-ignore-copied-malformed-url-in-null-origin.html [ Failure ] 1088 webkit.org/b/177633 editing/pasteboard/data-transfer-set-data-sanitize-url-when-copying-in-null-origin.html [ Failure ] 1089 webkit.org/b/177633 editing/pasteboard/data-transfer-set-data-sanitizes-html-when-copying-in-null-origin.html [ Failure ] 1090 webkit.org/b/177633 editing/pasteboard/data-transfer-set-data-sanitizes-html-when-copying.html [ Failure ] 1091 webkit.org/b/177633 editing/pasteboard/datatransfer-items-paste-plaintext.html [ Skip ] 1092 webkit.org/b/177633 editing/pasteboard/dataTransfer-types-pasting-plaintext.html [ Failure ] 1093 webkit.org/b/177633 editing/pasteboard/onpaste-text-html-types.html [ Failure ] 1094 webkit.org/b/177633 editing/pasteboard/pasting-empty-html-falls-back-to-text.html [ Failure ] 1095 webkit.org/b/177633 http/tests/security/clipboard/copy-paste-html-cross-origin-iframe-across-origin.html [ Skip ] 1096 webkit.org/b/177633 http/tests/security/clipboard/copy-paste-html-cross-origin-iframe-in-same-origin.html [ Skip ] 1097 webkit.org/b/177633 http/tests/security/clipboard/copy-paste-html-across-origin-sanitizes-html.html [ Failure ] 1098 webkit.org/b/177633 http/tests/security/clipboard/copy-paste-url-across-origin-sanitizes-url.html [ Failure ] 1099 webkit.org/b/177633 http/tests/security/clipboard/copy-paste-html-across-origin-strips-mso-list.html [ Failure ] 1100 webkit.org/b/177633 editing/pasteboard/copy-paste-across-shadow-boundaries-with-style-2.html [ Crash ] 1101 webkit.org/b/177633 editing/pasteboard/paste-text-with-style.html [ Failure Pass ] 1102 webkit.org/b/177633 editing/pasteboard/paste-without-nesting.html [ Failure Pass ] 1103 webkit.org/b/177633 editing/async-clipboard/clipboard-change-data-while-writing.html [ Failure ] 1104 webkit.org/b/177633 editing/async-clipboard/clipboard-read-text-from-platform.html [ Failure ] 1105 webkit.org/b/177633 editing/async-clipboard/clipboard-change-data-while-getting-type.html [ Timeout ] 1106 webkit.org/b/177633 editing/async-clipboard/clipboard-change-data-while-reading.html [ Timeout ] 1107 webkit.org/b/177633 editing/async-clipboard/clipboard-get-type-with-old-items.html [ Timeout ] 1108 webkit.org/b/177633 editing/async-clipboard/clipboard-read-basic.html [ Timeout ] 1109 webkit.org/b/177633 editing/async-clipboard/clipboard-read-text-same-origin.html [ Timeout ] 1110 webkit.org/b/177633 editing/async-clipboard/clipboard-write-basic.html [ Timeout ] 1111 webkit.org/b/177633 editing/async-clipboard/clipboard-write-items-twice.html [ Timeout ] 1112 webkit.org/b/177633 editing/async-clipboard/clipboard-write-text.html [ Timeout ] 1113 webkit.org/b/177633 editing/async-clipboard/clipboard-item-get-type-basic.html [ Failure ] 1114 webkit.org/b/177633 editing/async-clipboard/clipboard-read-text.html [ Failure ] 1115 webkit.org/b/177633 editing/async-clipboard/sanitize-when-reading-markup.html [ Failure ] 1078 # GTK ought to support async clipboard 1079 webkit.org/b/211979 editing/async-clipboard/clipboard-change-data-while-writing.html [ Failure ] 1080 webkit.org/b/211979 editing/async-clipboard/clipboard-read-text-from-platform.html [ Failure ] 1081 webkit.org/b/211979 editing/async-clipboard/clipboard-change-data-while-getting-type.html [ Timeout ] 1082 webkit.org/b/211979 editing/async-clipboard/clipboard-change-data-while-reading.html [ Timeout ] 1083 webkit.org/b/211979 editing/async-clipboard/clipboard-get-type-with-old-items.html [ Timeout ] 1084 webkit.org/b/211979 editing/async-clipboard/clipboard-read-basic.html [ Timeout ] 1085 webkit.org/b/211979 editing/async-clipboard/clipboard-read-text-same-origin.html [ Timeout ] 1086 webkit.org/b/211979 editing/async-clipboard/clipboard-write-basic.html [ Timeout ] 1087 webkit.org/b/211979 editing/async-clipboard/clipboard-write-items-twice.html [ Timeout ] 1088 webkit.org/b/211979 editing/async-clipboard/clipboard-write-text.html [ Timeout ] 1089 webkit.org/b/211979 editing/async-clipboard/clipboard-item-get-type-basic.html [ Failure ] 1090 webkit.org/b/211979 editing/async-clipboard/clipboard-read-text.html [ Failure ] 1091 webkit.org/b/211979 editing/async-clipboard/sanitize-when-reading-markup.html [ Failure ] 1092 webkit.org/b/211979 editing/async-clipboard/sanitize-when-writing-image.html [ Failure ] 1116 1093 1117 1094 webkit.org/b/180062 fast/text/user-installed-fonts [ Skip ] … … 1193 1170 # Server cookie not handled with platform WebSockets API 1194 1171 webkit.org/b/200165 imported/w3c/web-platform-tests/websockets/cookies/007.html [ Failure ] 1195 1196 # No Mac system fonts in WebKitGTK1197 editing/pasteboard/paste-cocoa-writer-markup-with-system-fonts.html [ Failure ]1198 1199 # We don't use Cocoa1200 editing/pasteboard/paste-cocoa-writer-markup-with-webkit-standard-font-family.html [ Failure ]1201 1172 1202 1173 webkit.org/b/205857 media/encrypted-media/mock-MediaKeySession-generateRequest.html [ Skip ] … … 1522 1493 webkit.org/b/210926 fast/mediastream/getDisplayMedia-max-constraints2.html [ Skip ] 1523 1494 webkit.org/b/210926 fast/mediastream/getDisplayMedia-max-constraints3.html [ Skip ] 1495 1496 webkit.org/b/199224 editing/pasteboard/copy-paste-across-shadow-boundaries-with-style-2.html [ Crash ] 1524 1497 1525 1498 #//////////////////////////////////////////////////////////////////////////////////////// … … 3633 3606 webkit.org/b/74282 editing/pasteboard/emacs-ctrl-k-with-move.html [ Failure ] 3634 3607 3635 webkit.org/b/81320 editing/pasteboard/copy-two-pasteboard-types-both-work.html [ Failure ]3636 3637 3608 webkit.org/b/84679 css3/zoom-coords.xhtml [ Failure ] 3638 3609 … … 4290 4261 webkit.org/b/189564 http/tests/xmlhttprequest/url-with-credentials.html [ Failure ] 4291 4262 4292 webkit.org/b/189737 editing/pasteboard/4930986-1-paste-as-quotation.html [ Failure ]4293 webkit.org/b/189737 editing/pasteboard/4930986-2-paste-as-quotation.html [ Failure ]4294 webkit.org/b/189737 editing/pasteboard/4930986-3-paste-as-quotation.html [ Failure ]4295 4296 4263 webkit.org/b/189739 svg/gradients/spreadMethodClose2.svg [ ImageOnlyFailure ] 4297 4264 … … 4598 4565 webkit.org/b/207678 imported/w3c/web-platform-tests/url/a-element-xhtml.xhtml [ Failure ] 4599 4566 webkit.org/b/207678 imported/w3c/web-platform-tests/url/a-element.html [ Failure ] 4567 4568 webkit.org/b/211981 editing/pasteboard/data-transfer-get-data-on-pasting-html-uses-blob-url.html [ Failure ] 4600 4569 4601 4570 #//////////////////////////////////////////////////////////////////////////////////////// -
trunk/Source/WebCore/ChangeLog
r261791 r261792 1 2020-05-17 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Move to new Pasteboard API 4 https://bugs.webkit.org/show_bug.cgi?id=177633 5 6 Reviewed by Adrian Perez de Castro. 7 8 Add support for custom data and remove the support for unknown data types that is currently unused. 9 10 * editing/gtk/EditorGtk.cpp: 11 (WebCore::Editor::writeSelectionToPasteboard): Set the contentOrigin. 12 * editing/gtk/WebContentReaderGtk.cpp: 13 (WebCore::shouldReplaceSubresourceURL): Helper to decide whether to replace the subresource URL. 14 (WebCore::WebContentMarkupReader::readHTML): Create a fragment for HTML sanitizing it if needed. 15 * platform/Pasteboard.h: 16 * platform/PasteboardCustomData.h: 17 (WebCore::PasteboardCustomData::gtkType): Mime type name for GTK custom pasteboard data. 18 * platform/SharedBuffer.h: 19 * platform/glib/SharedBufferGlib.cpp: 20 (WebCore::SharedBuffer::createGBytes const): Create a GBytes wrapping the SharedBuffer data. 21 * platform/gtk/PasteboardGtk.cpp: 22 (WebCore::Pasteboard::writeString): 23 (WebCore::Pasteboard::write): 24 (WebCore::Pasteboard::read): 25 (WebCore::Pasteboard::hasData): 26 (WebCore::Pasteboard::typesSafeForBindings): 27 (WebCore::Pasteboard::typesForLegacyUnsafeBindings): 28 (WebCore::Pasteboard::readOrigin): 29 (WebCore::Pasteboard::readString): 30 (WebCore::Pasteboard::readStringInCustomData): 31 (WebCore::Pasteboard::fileContentState): 32 (WebCore::Pasteboard::writeCustomData): 33 * platform/gtk/SelectionData.cpp: 34 (WebCore::SelectionData::clearAllExceptFilenames): 35 * platform/gtk/SelectionData.h: 36 (WebCore::SelectionData::setCustomData): 37 (WebCore::SelectionData::customData const): 38 (WebCore::SelectionData::hasCustomData const): 39 (WebCore::SelectionData::clearCustomData): 40 1 41 2020-05-16 Simon Fraser <simon.fraser@apple.com> 2 42 -
trunk/Source/WebCore/editing/gtk/EditorGtk.cpp
r261554 r261792 111 111 pasteboardContent.markup = serializePreservingVisualAppearance(m_document.selection().selection(), ResolveURLs::YesExcludingLocalFileURLsForPrivacy, 112 112 m_document.settings().selectionAcrossShadowBoundariesEnabled() ? SerializeComposedTree::Yes : SerializeComposedTree::No); 113 pasteboardContent.contentOrigin = m_document.originIdentifierForPasteboard(); 113 114 pasteboard.write(pasteboardContent); 114 115 } -
trunk/Source/WebCore/editing/gtk/WebContentReaderGtk.cpp
r261684 r261792 86 86 } 87 87 88 bool WebContentMarkupReader::readHTML(const String&)88 static bool shouldReplaceSubresourceURL(const URL& url) 89 89 { 90 return false; 90 return !(url.protocolIsInHTTPFamily() || url.protocolIsData()); 91 } 92 93 bool WebContentMarkupReader::readHTML(const String& string) 94 { 95 if (!frame.document()) 96 return false; 97 98 if (shouldSanitize()) { 99 markup = sanitizeMarkup(string, MSOListQuirks::Disabled, Function<void(DocumentFragment&)> { [](DocumentFragment& fragment) { 100 removeSubresourceURLAttributes(fragment, [](const URL& url) { 101 return shouldReplaceSubresourceURL(url); 102 }); 103 } }); 104 } else 105 markup = string; 106 107 return !markup.isEmpty(); 91 108 } 92 109 -
trunk/Source/WebCore/platform/Pasteboard.h
r261554 r261792 88 88 #endif 89 89 #if PLATFORM(GTK) 90 String contentOrigin; 90 91 bool canSmartCopyOrDelete; 91 92 String text; -
trunk/Source/WebCore/platform/PasteboardCustomData.h
r251100 r261792 76 76 #if PLATFORM(COCOA) 77 77 WEBCORE_EXPORT static const char* cocoaType(); 78 #elif PLATFORM(GTK) 79 static const char* gtkType() { return "org.webkitgtk.WebKit.custom-pasteboard-data"; } 78 80 #endif 79 81 -
trunk/Source/WebCore/platform/SharedBuffer.h
r256223 r261792 97 97 #if USE(GLIB) 98 98 static Ref<SharedBuffer> create(GBytes*); 99 GRefPtr<GBytes> createGBytes() const; 99 100 #endif 100 101 -
trunk/Source/WebCore/platform/glib/SharedBufferGlib.cpp
r240437 r261792 39 39 } 40 40 41 GRefPtr<GBytes> SharedBuffer::createGBytes() const 42 { 43 ref(); 44 GRefPtr<GBytes> bytes = adoptGRef(g_bytes_new_with_free_func(data(), size(), [](gpointer data) { 45 static_cast<SharedBuffer*>(data)->deref(); 46 }, const_cast<SharedBuffer*>(this))); 47 return bytes; 48 } 49 41 50 RefPtr<SharedBuffer> SharedBuffer::createFromReadingFile(const String& filePath) 42 51 { -
trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp
r261554 r261792 117 117 break; 118 118 case ClipboardDataTypeUnknown: 119 m_selectionData->setUnknownTypeData(type, data);120 break;121 119 case ClipboardDataTypeImage: 122 120 break; … … 188 186 data.setMarkup(pasteboardContent.markup); 189 187 data.setCanSmartReplace(pasteboardContent.canSmartCopyOrDelete); 188 PasteboardCustomData customData; 189 customData.setOrigin(pasteboardContent.contentOrigin); 190 data.setCustomData(customData.createSharedBuffer()); 190 191 platformStrategies()->pasteboardStrategy()->writeToClipboard(m_name, WTFMove(data)); 191 192 } … … 264 265 return; 265 266 } 267 268 reader.contentOrigin = readOrigin(); 266 269 267 270 auto types = platformStrategies()->pasteboardStrategy()->types(m_name); … … 307 310 { 308 311 if (m_selectionData) 309 return m_selectionData->hasText() || m_selectionData->hasMarkup() || m_selectionData->hasURIList() || m_selectionData->hasImage() || m_selectionData->hasUnknownTypeData();312 return m_selectionData->hasText() || m_selectionData->hasMarkup() || m_selectionData->hasURIList() || m_selectionData->hasImage(); 310 313 return !platformStrategies()->pasteboardStrategy()->types(m_name).isEmpty(); 311 314 } 312 315 313 Vector<String> Pasteboard::typesSafeForBindings(const String&) 314 { 315 notImplemented(); // webkit.org/b/177633: [GTK] Move to new Pasteboard API 316 return { }; 316 Vector<String> Pasteboard::typesSafeForBindings(const String& origin) 317 { 318 if (m_selectionData) 319 return { }; 320 321 return platformStrategies()->pasteboardStrategy()->typesSafeForDOMToReadAndWrite(m_name, origin); 317 322 } 318 323 … … 337 342 } 338 343 339 for (auto& key : m_selectionData->unknownTypes().keys())340 types.append(key);341 342 344 return types; 343 345 } … … 345 347 String Pasteboard::readOrigin() 346 348 { 347 notImplemented(); // webkit.org/b/177633: [GTK] Move to new Pasteboard API 349 if (m_selectionData) 350 return { }; 351 352 // FIXME: cache custom data? 353 if (auto buffer = platformStrategies()->pasteboardStrategy()->readBufferFromClipboard(m_name, PasteboardCustomData::gtkType())) 354 return PasteboardCustomData::fromSharedBuffer(*buffer).origin(); 355 348 356 return { }; 349 357 } … … 369 377 return m_selectionData->text(); 370 378 case ClipboardDataTypeUnknown: 371 return m_selectionData->unknownTypeData(type);372 379 case ClipboardDataTypeImage: 373 380 break; … … 377 384 } 378 385 379 String Pasteboard::readStringInCustomData(const String&) 380 { 381 notImplemented(); // webkit.org/b/177633: [GTK] Move to new Pasteboard API 386 String Pasteboard::readStringInCustomData(const String& type) 387 { 388 if (m_selectionData) 389 return { }; 390 391 // FIXME: cache custom data? 392 if (auto buffer = platformStrategies()->pasteboardStrategy()->readBufferFromClipboard(m_name, PasteboardCustomData::gtkType())) 393 return PasteboardCustomData::fromSharedBuffer(*buffer).readStringInCustomData(type); 394 382 395 return { }; 383 396 } … … 389 402 390 403 auto types = platformStrategies()->pasteboardStrategy()->types(m_name); 391 if (types.contains("text/uri-list"_s)) 392 return FileContentState::MayContainFilePaths; 404 if (types.contains("text/uri-list"_s)) { 405 auto filePaths = platformStrategies()->pasteboardStrategy()->readFilePathsFromClipboard(m_name); 406 if (!filePaths.isEmpty()) 407 return FileContentState::MayContainFilePaths; 408 } 393 409 394 410 auto result = types.findMatching([](const String& type) { … … 402 418 } 403 419 404 void Pasteboard::writeCustomData(const Vector<PasteboardCustomData>&) 405 { 420 void Pasteboard::writeCustomData(const Vector<PasteboardCustomData>& data) 421 { 422 if (m_selectionData) 423 return; 424 425 platformStrategies()->pasteboardStrategy()->writeCustomData(data, m_name); 406 426 } 407 427 -
trunk/Source/WebCore/platform/gtk/SelectionData.cpp
r261554 r261792 121 121 clearURL(); 122 122 clearImage(); 123 clearCustomData(); 123 124 124 m_unknownTypeData.clear();125 125 m_canSmartReplace = false; 126 126 } -
trunk/Source/WebCore/platform/gtk/SelectionData.h
r238771 r261792 20 20 21 21 #include "Image.h" 22 #include "SharedBuffer.h" 22 23 #include <wtf/HashMap.h> 23 24 #include <wtf/RefCounted.h> … … 63 64 void clearImage() { m_image = nullptr; } 64 65 65 void setUnknownTypeData(const String& type, const String& data) { m_unknownTypeData.set(type, data); }66 String unknownTypeData(const String& type) const { return m_unknownTypeData.get(type); }67 const HashMap<String, String>& unknownTypes() const { return m_unknownTypeData; }68 bool hasUnknownTypeData() const { return !m_unknownTypeData.isEmpty(); }69 70 66 void setCanSmartReplace(bool canSmartReplace) { m_canSmartReplace = canSmartReplace; } 71 67 bool canSmartReplace() const { return m_canSmartReplace; } 68 69 void setCustomData(Ref<SharedBuffer>&& buffer) { m_customData = WTFMove(buffer); } 70 SharedBuffer* customData() const { return m_customData.get(); } 71 bool hasCustomData() const { return !!m_customData; } 72 void clearCustomData() { m_customData = nullptr; } 72 73 73 74 void clearAll(); … … 81 82 Vector<String> m_filenames; 82 83 RefPtr<Image> m_image; 83 HashMap<String, String> m_unknownTypeData;84 84 bool m_canSmartReplace { false }; 85 RefPtr<SharedBuffer> m_customData; 85 86 }; 86 87 -
trunk/Source/WebKit/ChangeLog
r261785 r261792 1 2020-05-17 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Move to new Pasteboard API 4 https://bugs.webkit.org/show_bug.cgi?id=177633 5 6 Reviewed by Adrian Perez de Castro. 7 8 Enable custom pasteboard data. 9 10 * Shared/WebPreferencesDefaultValues.h: 11 * Shared/gtk/ArgumentCodersGtk.cpp: 12 (IPC::ArgumentCoder<SelectionData>::encode): 13 (IPC::ArgumentCoder<SelectionData>::decode): 14 * UIProcess/WebPasteboardProxy.cpp: 15 * UIProcess/gtk/ClipboardGtk3.cpp: 16 (WebKit::Clipboard::write): Add support for writing URI list and custom data. 17 * UIProcess/gtk/ClipboardGtk4.cpp: 18 (WebKit::Clipboard::write): Ditto. 19 * UIProcess/gtk/WebPasteboardProxyGtk.cpp: 20 (WebKit::WebPasteboardProxy::typesSafeForDOMToReadAndWrite): 21 (WebKit::WebPasteboardProxy::writeCustomData): 22 1 23 2020-05-16 Andy Estes <aestes@apple.com> 2 24 -
trunk/Source/WebKit/Shared/WebPreferencesDefaultValues.h
r261599 r261792 239 239 #endif 240 240 241 #if PLATFORM(COCOA) 241 #if PLATFORM(COCOA) || PLATFORM(GTK) 242 242 #define DEFAULT_CUSTOM_PASTEBOARD_DATA_ENABLED true 243 #else 244 #define DEFAULT_CUSTOM_PASTEBOARD_DATA_ENABLED false 245 #endif 246 247 #if PLATFORM(COCOA) 243 248 #define DEFAULT_ASYNC_CLIPBOARD_API_ENABLED true 244 249 #else 245 #define DEFAULT_CUSTOM_PASTEBOARD_DATA_ENABLED false246 250 #define DEFAULT_ASYNC_CLIPBOARD_API_ENABLED false 247 251 #endif -
trunk/Source/WebKit/Shared/gtk/ArgumentCodersGtk.cpp
r260025 r261792 93 93 encodeImage(encoder, *selection.image()); 94 94 95 bool has UnknownTypeData = selection.hasUnknownTypeData();96 encoder << has UnknownTypeData;97 if (has UnknownTypeData)98 encoder << selection.unknownTypes();95 bool hasCustomData = selection.hasCustomData(); 96 encoder << hasCustomData; 97 if (hasCustomData) 98 encoder << RefPtr<SharedBuffer>(selection.customData()); 99 99 100 100 bool canSmartReplace = selection.canSmartReplace(); … … 156 156 } 157 157 158 bool hasUnknownTypeData; 159 if (!decoder.decode(hasUnknownTypeData)) 160 return false; 161 if (hasUnknownTypeData) { 162 HashMap<String, String> unknownTypes; 163 if (!decoder.decode(unknownTypes)) 164 return false; 165 166 auto end = unknownTypes.end(); 167 for (auto it = unknownTypes.begin(); it != end; ++it) 168 selection.setUnknownTypeData(it->key, it->value); 158 bool hasCustomData; 159 if (!decoder.decode(hasCustomData)) 160 return false; 161 if (hasCustomData) { 162 RefPtr<SharedBuffer> buffer; 163 if (!decoder.decode(buffer)) 164 return false; 165 selection.setCustomData(Ref<SharedBuffer>(*buffer)); 169 166 } 170 167 -
trunk/Source/WebKit/UIProcess/WebPasteboardProxy.cpp
r260793 r261792 80 80 #if !PLATFORM(COCOA) 81 81 82 #if !PLATFORM(GTK) 82 83 void WebPasteboardProxy::typesSafeForDOMToReadAndWrite(IPC::Connection&, const String&, const String&, CompletionHandler<void(Vector<String>&&)>&& completionHandler) 83 84 { … … 89 90 completionHandler(0); 90 91 } 92 #endif 91 93 92 94 void WebPasteboardProxy::allPasteboardItemInfo(IPC::Connection&, const String&, int64_t, CompletionHandler<void(Optional<Vector<WebCore::PasteboardItemInfo>>&&)>&& completionHandler) -
trunk/Source/WebKit/UIProcess/gtk/ClipboardGtk3.cpp
r261554 r261792 31 31 #include "WebPasteboardProxy.h" 32 32 #include <WebCore/GRefPtrGtk.h> 33 #include <WebCore/PasteboardCustomData.h> 33 34 #include <WebCore/SelectionData.h> 34 35 #include <WebCore/SharedBuffer.h> … … 156 157 }; 157 158 158 enum ClipboardTargetType { Markup, Text, Image, SmartPaste};159 enum ClipboardTargetType { Markup, Text, Image, URIList, SmartPaste, Custom }; 159 160 160 161 void Clipboard::write(Ref<WebCore::SelectionData>&& selectionData) … … 163 164 164 165 GRefPtr<GtkTargetList> list = adoptGRef(gtk_target_list_new(nullptr, 0)); 166 if (selectionData->hasURIList()) 167 gtk_target_list_add(list.get(), gdk_atom_intern_static_string("text/uri-list"), 0, ClipboardTargetType::URIList); 165 168 if (selectionData->hasMarkup()) 166 169 gtk_target_list_add(list.get(), gdk_atom_intern_static_string("text/html"), 0, ClipboardTargetType::Markup); … … 171 174 if (selectionData->canSmartReplace()) 172 175 gtk_target_list_add(list.get(), gdk_atom_intern_static_string("application/vnd.webkitgtk.smartpaste"), 0, ClipboardTargetType::SmartPaste); 176 if (selectionData->hasCustomData()) 177 gtk_target_list_add(list.get(), gdk_atom_intern_static_string(WebCore::PasteboardCustomData::gtkType()), 0, ClipboardTargetType::Custom); 173 178 174 179 int numberOfTargets; … … 200 205 break; 201 206 } 207 case ClipboardTargetType::URIList: { 208 CString uriList = selectionData.uriList().utf8(); 209 gtk_selection_data_set(selection, gdk_atom_intern_static_string("text/uri-list"), 8, reinterpret_cast<const guchar*>(uriList.data()), uriList.length()); 210 break; 211 } 202 212 case ClipboardTargetType::SmartPaste: 203 213 gtk_selection_data_set_text(selection, "", -1); 214 break; 215 case ClipboardTargetType::Custom: 216 if (selectionData.hasCustomData()) { 217 auto* buffer = selectionData.customData(); 218 gtk_selection_data_set(selection, gdk_atom_intern_static_string(WebCore::PasteboardCustomData::gtkType()), 8, reinterpret_cast<const guchar*>(buffer->data()), buffer->size()); 219 } 204 220 break; 205 221 } -
trunk/Source/WebKit/UIProcess/gtk/ClipboardGtk4.cpp
r261555 r261792 30 30 31 31 #include "WebPasteboardProxy.h" 32 #include <WebCore/PasteboardCustomData.h> 32 33 #include <WebCore/SelectionData.h> 33 34 #include <WebCore/SharedBuffer.h> … … 165 166 } 166 167 168 if (selectionData->hasURIList()) { 169 CString uriList = selectionData->uriList().utf8(); 170 GRefPtr<GBytes> bytes = adoptGRef(g_bytes_new(uriList.data(), uriList.length())); 171 providers.append(gdk_content_provider_new_for_bytes("text/uri-list", bytes.get())); 172 } 173 167 174 if (selectionData->hasImage()) { 168 175 GRefPtr<GdkPixbuf> pixbuf = adoptGRef(selectionData->image()->getGdkPixbuf()); … … 178 185 } 179 186 187 if (selectionData->hasCustomData()) { 188 GRefPtr<GBytes> bytes = selectionData->customData()->createGBytes(); 189 providers.append(gdk_content_provider_new_for_bytes(WebCore::PasteboardCustomData::gtkType(), bytes.get())); 190 } 191 180 192 if (providers.isEmpty()) { 181 193 clear(); -
trunk/Source/WebKit/UIProcess/gtk/WebPasteboardProxyGtk.cpp
r261554 r261792 31 31 #include "WebFrameProxy.h" 32 32 #include "WebSelectionData.h" 33 #include <WebCore/Pasteboard.h> 34 #include <WebCore/PasteboardCustomData.h> 35 #include <WebCore/PasteboardItemInfo.h> 33 36 #include <WebCore/PlatformPasteboard.h> 34 37 #include <WebCore/SharedBuffer.h> 38 #include <wtf/ListHashSet.h> 35 39 #include <wtf/SetForScope.h> 36 40 … … 85 89 } 86 90 91 void WebPasteboardProxy::typesSafeForDOMToReadAndWrite(IPC::Connection&, const String& pasteboardName, const String& origin, CompletionHandler<void(Vector<String>&&)>&& completionHandler) 92 { 93 auto& clipboard = Clipboard::get(pasteboardName); 94 clipboard.readBuffer(PasteboardCustomData::gtkType(), [&clipboard, origin, completionHandler = WTFMove(completionHandler)](IPC::SharedBufferDataReference&& buffer) mutable { 95 ListHashSet<String> domTypes; 96 if (auto dataBuffer = buffer.buffer()) { 97 auto customData = PasteboardCustomData::fromSharedBuffer(*dataBuffer); 98 if (customData.origin() == origin) { 99 for (auto& type : customData.orderedTypes()) 100 domTypes.add(type); 101 } 102 } 103 104 clipboard.formats([domTypes = WTFMove(domTypes), completionHandler = WTFMove(completionHandler)](Vector<String>&& formats) mutable { 105 for (const auto& format : formats) { 106 if (format == PasteboardCustomData::gtkType()) 107 continue; 108 109 if (Pasteboard::isSafeTypeForDOMToReadAndWrite(format)) 110 domTypes.add(format); 111 } 112 113 completionHandler(copyToVector(domTypes)); 114 }); 115 }); 116 } 117 118 void WebPasteboardProxy::writeCustomData(IPC::Connection&, const Vector<PasteboardCustomData>& data, const String& pasteboardName, CompletionHandler<void(int64_t)>&& completionHandler) 119 { 120 if (data.isEmpty() || data.size() > 1) { 121 // We don't support more than one custom item in the clipboard. 122 completionHandler(0); 123 return; 124 } 125 126 auto selectionData = SelectionData::create(); 127 const auto& customData = data[0]; 128 customData.forEachPlatformStringOrBuffer([&selectionData] (auto& type, auto& stringOrBuffer) { 129 if (WTF::holds_alternative<String>(stringOrBuffer)) { 130 if (type == "text/plain"_s) 131 selectionData->setText(WTF::get<String>(stringOrBuffer)); 132 else if (type == "text/html"_s) 133 selectionData->setMarkup(WTF::get<String>(stringOrBuffer)); 134 else if (type == "text/uri-list"_s) 135 selectionData->setURIList(WTF::get<String>(stringOrBuffer)); 136 } 137 }); 138 139 if (customData.hasSameOriginCustomData() || !customData.origin().isEmpty()) 140 selectionData->setCustomData(customData.createSharedBuffer()); 141 142 Clipboard::get(pasteboardName).write(WTFMove(selectionData)); 143 completionHandler(0); 144 } 145 87 146 } // namespace WebKit
Note: See TracChangeset
for help on using the changeset viewer.