PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefPtr<Range> context, bool allowPlainText, bool& chosePlainText) { GtkClipboard* clipboard = PasteboardHelper::clipboardForFrame(frame); ASSERT(clipboard); DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard); ASSERT(dataObject); PasteboardHelper::helper()->getClipboardContents(clipboard); if (dataObject->hasMarkup()) { chosePlainText = false; String markup(dataObject->markup()); if (!markup.isEmpty()) { RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), markup, ""); if (fragment) return fragment.release(); } } if (!allowPlainText || !dataObject->hasText()) return 0; chosePlainText = true; String text(dataObject->text()); RefPtr<DocumentFragment> fragment = createFragmentFromText(context.get(), text); if (fragment) return fragment.release(); return 0; }
static RefPtr<DocumentFragment> createFragmentFromPasteboardData(Pasteboard& pasteboard, Frame& frame, Range& range, bool allowPlainText, bool& chosePlainText) { chosePlainText = false; if (!pasteboard.hasData()) return nullptr; DataObjectGtk* dataObject = pasteboard.dataObject(); if (dataObject->hasMarkup() && frame.document()) return createFragmentFromMarkup(*frame.document(), dataObject->markup(), emptyString(), DisallowScriptingAndPluginContent); if (!allowPlainText) return nullptr; if (dataObject->hasText()) { chosePlainText = true; return createFragmentFromText(range, dataObject->text()); } return nullptr; }
PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefPtr<Range> context, bool allowPlainText, bool& chosePlainText) { PasteboardHelper* helper = PasteboardHelper::defaultPasteboardHelper(); GtkClipboard* clipboard = helper->getCurrentClipboard(frame); DataObjectGtk* dataObject = DataObjectGtk::forClipboard(clipboard); helper->getClipboardContents(clipboard); chosePlainText = false; if (dataObject->hasMarkup()) { RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), dataObject->markup(), "", FragmentScriptingNotAllowed); if (fragment) return fragment.release(); } if (!allowPlainText) return 0; if (dataObject->hasText()) { chosePlainText = true; RefPtr<DocumentFragment> fragment = createFragmentFromText(context.get(), dataObject->text()); if (fragment) return fragment.release(); } return 0; }