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::writeURL(const KURL& url, const String& label, Frame* frame) { if (url.isEmpty()) return; GtkClipboard* clipboard = m_helper->getClipboard(frame); DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard); dataObject->setURL(url, label); m_helper->writeClipboardContents(clipboard); }
void Pasteboard::writeURL(const KURL& url, const String& label, Frame* frame) { if (url.isEmpty()) return; PasteboardHelper* helper = PasteboardHelper::defaultPasteboardHelper(); GtkClipboard* clipboard = helper->getCurrentClipboard(frame); DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard); dataObject->clearAll(); dataObject->setURL(url, label); helper->writeClipboardContents(clipboard); }