Changeset 212428 in webkit
- Timestamp:
- Feb 16, 2017 4:08:53 AM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r212420 r212428 1 2017-02-16 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Images are never read from the clipboard 4 https://bugs.webkit.org/show_bug.cgi?id=168419 5 6 Reviewed by Sergio Villar Senin. 7 8 We write images in the clipboard, but we don't read them. 9 10 Fixes: editing/pasteboard/paste-image-using-image-data.html 11 12 * editing/Editor.cpp: 13 (WebCore::Editor::createFragmentForImageAndURL): Moved from EditorMac.mm since it's cross-platform code. 14 * editing/Editor.h: 15 * editing/gtk/EditorGtk.cpp: 16 (WebCore::createFragmentFromPasteboardData): Check if there's an image in the selection, and use 17 Editor::createFragmentForImageAndURL in that case. 18 * editing/mac/EditorMac.mm: 19 (WebCore::Editor::createFragmentForImageAndURL): Deleted. 20 * platform/gtk/PasteboardHelper.cpp: 21 (WebCore::PasteboardHelper::getClipboardContents): Check also if there's an image in the clipboard. 22 1 23 2017-02-15 Jer Noble <jer.noble@apple.com> 2 24 -
trunk/Source/WebCore/editing/Editor.cpp
r211964 r212428 3741 3741 } 3742 3742 3743 Ref<DocumentFragment> Editor::createFragmentForImageAndURL(const String& url) 3744 { 3745 auto imageElement = HTMLImageElement::create(*m_frame.document()); 3746 imageElement->setAttributeWithoutSynchronization(HTMLNames::srcAttr, url); 3747 3748 auto fragment = document().createDocumentFragment(); 3749 fragment->appendChild(imageElement); 3750 3751 return fragment; 3752 } 3743 3753 3744 3754 } // namespace WebCore -
trunk/Source/WebCore/editing/Editor.h
r210845 r212428 484 484 bool isGettingDictionaryPopupInfo() const { return m_isGettingDictionaryPopupInfo; } 485 485 486 Ref<DocumentFragment> createFragmentForImageAndURL(const String&); 487 486 488 private: 487 489 class WebContentReader; … … 523 525 RefPtr<SharedBuffer> imageInWebArchiveFormat(Element&); 524 526 RefPtr<DocumentFragment> createFragmentForImageResourceAndAddResource(RefPtr<ArchiveResource>&&); 525 Ref<DocumentFragment> createFragmentForImageAndURL(const String&);526 527 RefPtr<DocumentFragment> createFragmentAndAddResources(NSAttributedString *); 527 528 FragmentAndResources createFragment(NSAttributedString *); -
trunk/Source/WebCore/editing/gtk/EditorGtk.cpp
r210109 r212428 28 28 #include "Editor.h" 29 29 30 #include "Blob.h" 30 31 #include "CachedImage.h" 32 #include "DOMURL.h" 31 33 #include "DocumentFragment.h" 32 34 #include "Frame.h" … … 55 57 56 58 const auto& selection = pasteboard.selectionData(); 59 if (selection.hasImage()) { 60 Vector<uint8_t> buffer; 61 auto status = cairo_surface_write_to_png_stream(selection.image()->nativeImage().get(), [](void* output, const unsigned char* data, unsigned size) { 62 if (!reinterpret_cast<Vector<uint8_t>*>(output)->tryAppend(data, size)) 63 return CAIRO_STATUS_WRITE_ERROR; 64 return CAIRO_STATUS_SUCCESS; 65 }, &buffer); 66 if (status == CAIRO_STATUS_SUCCESS) { 67 auto blob = Blob::create(WTFMove(buffer), "image/png"); 68 return frame.editor().createFragmentForImageAndURL(DOMURL::createObjectURL(*frame.document(), blob)); 69 } 70 } 71 57 72 if (selection.hasMarkup() && frame.document()) 58 73 return createFragmentFromMarkup(*frame.document(), selection.markup(), emptyString(), DisallowScriptingAndPluginContent); -
trunk/Source/WebCore/editing/mac/EditorMac.mm
r211438 r212428 487 487 } 488 488 489 Ref<DocumentFragment> Editor::createFragmentForImageAndURL(const String& url)490 {491 auto imageElement = HTMLImageElement::create(*m_frame.document());492 imageElement->setAttributeWithoutSynchronization(HTMLNames::srcAttr, url);493 494 auto fragment = document().createDocumentFragment();495 fragment->appendChild(imageElement);496 497 return fragment;498 }499 500 489 void Editor::applyFontStyles(const String& fontFamily, double fontSize, unsigned fontTraits) 501 490 { -
trunk/Source/WebCore/platform/gtk/PasteboardHelper.cpp
r208841 r212428 24 24 #include "PasteboardHelper.h" 25 25 26 #include "BitmapImage.h" 26 27 #include "GtkVersioning.h" 27 28 #include "SelectionData.h" … … 113 114 } 114 115 } 116 117 #ifndef GTK_API_VERSION_2 118 if (gtk_clipboard_wait_is_image_available(clipboard)) { 119 if (GRefPtr<GdkPixbuf> pixbuf = adoptGRef(gtk_clipboard_wait_for_image(clipboard))) { 120 RefPtr<cairo_surface_t> surface = adoptRef(gdk_cairo_surface_create_from_pixbuf(pixbuf.get(), 1, nullptr)); 121 Ref<Image> image = BitmapImage::create(WTFMove(surface)); 122 selection.setImage(image.ptr()); 123 } 124 } 125 #endif 115 126 116 127 selection.setCanSmartReplace(gtk_clipboard_wait_is_target_available(clipboard, smartPasteAtom));
Note: See TracChangeset
for help on using the changeset viewer.