void Pasteboard::writeImage(Node* node, const KURL&, const String& title) { ASSERT(node); if (!(node->renderer() && node->renderer()->isImage())) return; RenderImage* renderer = toRenderImage(node->renderer()); CachedImage* cachedImage = renderer->cachedImage(); if (!cachedImage || cachedImage->errorOccurred()) return; Image* image = cachedImage->imageForRenderer(renderer); ASSERT(image); GtkClipboard* clipboard = gtk_clipboard_get_for_display(gdk_display_get_default(), GDK_SELECTION_CLIPBOARD); DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard); KURL url = getURLForImageNode(node); if (!url.isEmpty()) { dataObject->setURL(url, title); dataObject->setMarkup(createMarkup(static_cast<Element*>(node), IncludeNode, 0, ResolveAllURLs)); } GRefPtr<GdkPixbuf> pixbuf = adoptGRef(image->getGdkPixbuf()); dataObject->setImage(pixbuf.get()); PasteboardHelper::defaultPasteboardHelper()->writeClipboardContents(clipboard); }
void Pasteboard::writeImage(Node* node, const KURL&, const String&) { GtkClipboard* clipboard = gtk_clipboard_get_for_display(gdk_display_get_default(), GDK_SELECTION_CLIPBOARD); ASSERT(node && node->renderer() && node->renderer()->isImage()); RenderImage* renderer = toRenderImage(node->renderer()); CachedImage* cachedImage = renderer->cachedImage(); if (!cachedImage || cachedImage->errorOccurred()) return; Image* image = cachedImage->image(); ASSERT(image); PlatformRefPtr<GdkPixbuf> pixbuf = adoptPlatformRef(image->getGdkPixbuf()); DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard); dataObject->setImage(pixbuf.get()); m_helper->writeClipboardContents(clipboard); }
void Pasteboard::writeImage(Node* node, const KURL&, const String&) { ASSERT(node && node->renderer() && node->renderer()->isImage()); RenderImage* renderer = toRenderImage(node->renderer()); CachedImage* cachedImage = renderer->cachedImage(); ASSERT(cachedImage); Image* image = cachedImage->image(); ASSERT(image); ASSERT(node->document()); GtkClipboard* clipboard = PasteboardHelper::clipboardForFrame(node->document()->frame()); ASSERT(clipboard); DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard); ASSERT(dataObject); GdkPixbuf* pixbuf = image->getGdkPixbuf(); dataObject->setImage(pixbuf); g_object_unref(pixbuf); PasteboardHelper::helper()->writeClipboardContents(clipboard); }