summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@digia.com>2014-03-10 16:45:25 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-12 17:40:36 +0100
commit6fcbaf8ad330ec7dfb597392dbddd16b8b4fe770 (patch)
tree92d7e71e22443dde986ef04ce38542c4aef32d5a
parent3821c879bdc4b496df2894b6edb4c739be0ba978 (diff)
downloadqtwebkit-6fcbaf8ad330ec7dfb597392dbddd16b8b4fe770.tar.gz
Fix dragging of selections
A regression from (r151091) broke drag and drop of selections. This patch restores the maintenance of the m_writableData which is used by DragClientQt. Task-number: QTBUG-37314 Change-Id: I9afa193daec53d8d5affa560b8f225bb7dc79470 Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
-rw-r--r--Source/WebCore/platform/qt/PasteboardQt.cpp46
1 files changed, 27 insertions, 19 deletions
diff --git a/Source/WebCore/platform/qt/PasteboardQt.cpp b/Source/WebCore/platform/qt/PasteboardQt.cpp
index a35809f48..cb67d158c 100644
--- a/Source/WebCore/platform/qt/PasteboardQt.cpp
+++ b/Source/WebCore/platform/qt/PasteboardQt.cpp
@@ -115,24 +115,26 @@ Pasteboard* Pasteboard::generalPasteboard()
void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete, Frame* frame, ShouldSerializeSelectedTextForClipboard shouldSerializeSelectedTextForClipboard)
{
- QMimeData* md = new QMimeData;
+ if (!m_writableData)
+ m_writableData = new QMimeData;
QString text = shouldSerializeSelectedTextForClipboard == IncludeImageAltTextForClipboard ? frame->editor().selectedTextForClipboard() : frame->editor().selectedText();
text.replace(QChar(0xa0), QLatin1Char(' '));
- md->setText(text);
+ m_writableData->setText(text);
QString markup = createMarkup(selectedRange, 0, AnnotateForInterchange, false, ResolveNonLocalURLs);
#ifdef Q_OS_MAC
markup.prepend(QLatin1String("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" /></head><body>"));
markup.append(QLatin1String("</body></html>"));
- md->setData(QLatin1String("text/html"), markup.toUtf8());
+ m_writableData->setData(QLatin1String("text/html"), markup.toUtf8());
#else
- md->setHtml(markup);
+ m_writableData->setHtml(markup);
#endif
if (canSmartCopyOrDelete)
- md->setData(QLatin1String("application/vnd.qtwebkit.smartpaste"), QByteArray());
+ m_writableData->setData(QLatin1String("application/vnd.qtwebkit.smartpaste"), QByteArray());
#ifndef QT_NO_CLIPBOARD
- QGuiApplication::clipboard()->setMimeData(md, m_selectionMode ? QClipboard::Selection : QClipboard::Clipboard);
+ if (isForCopyAndPaste())
+ QGuiApplication::clipboard()->setMimeData(m_writableData, m_selectionMode ? QClipboard::Selection : QClipboard::Clipboard);
#endif
}
@@ -148,10 +150,12 @@ bool Pasteboard::canSmartReplace()
String Pasteboard::plainText(Frame*)
{
#ifndef QT_NO_CLIPBOARD
- return QGuiApplication::clipboard()->text(m_selectionMode ? QClipboard::Selection : QClipboard::Clipboard);
-#else
- return String();
+ if (isForCopyAndPaste())
+ return QGuiApplication::clipboard()->text(m_selectionMode ? QClipboard::Selection : QClipboard::Clipboard);
#endif
+ if (const QMimeData* data = readData())
+ return data->text();
+ return String();
}
PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefPtr<Range> context,
@@ -184,14 +188,16 @@ PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefP
void Pasteboard::writePlainText(const String& text, SmartReplaceOption smartReplaceOption)
{
-#ifndef QT_NO_CLIPBOARD
- QMimeData* md = new QMimeData;
+ if (!m_writableData)
+ m_writableData = new QMimeData;
QString qtext = text;
qtext.replace(QChar(0xa0), QLatin1Char(' '));
- md->setText(qtext);
+ m_writableData->setText(qtext);
if (smartReplaceOption == CanSmartReplace)
- md->setData(QLatin1String("application/vnd.qtwebkit.smartpaste"), QByteArray());
- QGuiApplication::clipboard()->setMimeData(md, m_selectionMode ? QClipboard::Selection : QClipboard::Clipboard);
+ m_writableData->setData(QLatin1String("application/vnd.qtwebkit.smartpaste"), QByteArray());
+#ifndef QT_NO_CLIPBOARD
+ if (isForCopyAndPaste())
+ QGuiApplication::clipboard()->setMimeData(m_writableData, m_selectionMode ? QClipboard::Selection : QClipboard::Clipboard);
#endif
}
@@ -199,12 +205,14 @@ void Pasteboard::writeURL(const KURL& url, const String&, Frame*)
{
ASSERT(!url.isEmpty());
-#ifndef QT_NO_CLIPBOARD
- QMimeData* md = new QMimeData;
+ if (!m_writableData)
+ m_writableData = new QMimeData;
QString urlString = url.string();
- md->setText(urlString);
- md->setUrls(QList<QUrl>() << url);
- QGuiApplication::clipboard()->setMimeData(md, m_selectionMode ? QClipboard::Selection : QClipboard::Clipboard);
+ m_writableData->setText(urlString);
+ m_writableData->setUrls(QList<QUrl>() << url);
+#ifndef QT_NO_CLIPBOARD
+ if (isForCopyAndPaste())
+ QGuiApplication::clipboard()->setMimeData(m_writableData, m_selectionMode ? QClipboard::Selection : QClipboard::Clipboard);
#endif
}