Changeset 146910 in webkit


Ignore:
Timestamp:
Mar 26, 2013 11:10:05 AM (11 years ago)
Author:
allan.jensen@digia.com
Message:

[Qt] editing/pasteboard/can-read-in-dragstart-event.html and /can-read-in-copy-and-cut-events.html are crashing
https://bugs.webkit.org/show_bug.cgi?id=113126

Reviewed by Jocelyn Turcotte.

Source/WebCore:

Make it possible to read from a writable Clipboard.

Test: editing/pasteboard/can-read-in-copy-and-cut-events.html

  • platform/qt/ClipboardQt.cpp:

(WebCore::ClipboardQt::getData):
(WebCore::ClipboardQt::types):
(WebCore::ClipboardQt::files):
(WebCore::ClipboardQt::readClipboardData):
(WebCore::ClipboardQt::hasData):
(WebCore::ClipboardQt::items):

  • platform/qt/ClipboardQt.h:

(ClipboardQt):

LayoutTests:

Unskip now working editing/pasteboard/can-read-in-copy-and-cut-events.html.
The other test still needs better drag-and-drop support in DRT.

  • platform/qt/TestExpectations:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r146907 r146910  
     12013-03-26  Allan Sandfeld Jensen  <allan.jensen@digia.com>
     2
     3        [Qt] editing/pasteboard/can-read-in-dragstart-event.html and /can-read-in-copy-and-cut-events.html are crashing
     4        https://bugs.webkit.org/show_bug.cgi?id=113126
     5
     6        Reviewed by Jocelyn Turcotte.
     7
     8        Unskip now working editing/pasteboard/can-read-in-copy-and-cut-events.html.
     9        The other test still needs better drag-and-drop support in DRT.
     10
     11        * platform/qt/TestExpectations:
     12
    1132013-03-26  Sergio Villar Senin  <svillar@igalia.com>
    214
  • trunk/LayoutTests/platform/qt/TestExpectations

    r146876 r146910  
    584584webkit.org/b/111853 editing/pasteboard/cleanup-on-move.html [ Skip ]
    585585webkit.org/b/111853 editing/pasteboard/drag-list-item.html [ Skip ]
     586
     587webkit.org/b/113126 editing/pasteboard/can-read-in-dragstart-event.html [ Skip ]
    586588
    587589# =========================================================================== #
     
    27162718# Feature not implemented
    27172719webkit.org/b/91611 [ Mac Win ] media/media-higher-prio-audio-stream.html [ Skip ]
    2718 
    2719 webkit.org/b/113126 editing/pasteboard/can-read-in-dragstart-event.html [ Skip ]
    2720 webkit.org/b/113126 editing/pasteboard/can-read-in-copy-and-cut-events.html [ Skip ]
  • trunk/Source/WebCore/ChangeLog

    r146909 r146910  
     12013-03-26  Allan Sandfeld Jensen  <allan.jensen@digia.com>
     2
     3        [Qt] editing/pasteboard/can-read-in-dragstart-event.html and /can-read-in-copy-and-cut-events.html are crashing
     4        https://bugs.webkit.org/show_bug.cgi?id=113126
     5
     6        Reviewed by Jocelyn Turcotte.
     7
     8        Make it possible to read from a writable Clipboard.
     9
     10        Test: editing/pasteboard/can-read-in-copy-and-cut-events.html
     11
     12        * platform/qt/ClipboardQt.cpp:
     13        (WebCore::ClipboardQt::getData):
     14        (WebCore::ClipboardQt::types):
     15        (WebCore::ClipboardQt::files):
     16        (WebCore::ClipboardQt::readClipboardData):
     17        (WebCore::ClipboardQt::hasData):
     18        (WebCore::ClipboardQt::items):
     19        * platform/qt/ClipboardQt.h:
     20        (ClipboardQt):
     21
    1222013-03-26  Brent Fulgham  <bfulgham@webkit.org>
    223
  • trunk/Source/WebCore/platform/qt/ClipboardQt.cpp

    r146835 r146910  
    5656#include <QTextCodec>
    5757#include <QUrl>
    58 #include <qdebug.h>
    59 
    60 #define methodDebug() qDebug("ClipboardQt: %s", __FUNCTION__)
    6158
    6259namespace WebCore {
     
    146143String ClipboardQt::getData(const String& type) const
    147144{
    148 
    149     if (!canReadData())
     145    const QMimeData* data = readData();
     146    if (!canReadData() || !data)
    150147        return String();
    151148
    152     if (isHtmlMimeType(type) && m_readableData->hasHtml())
    153         return m_readableData->html();
    154 
    155     if (isTextMimeType(type) && m_readableData->hasText())
    156         return m_readableData->text();
    157 
    158     // FIXME: Per the spec, reading the clipboard in dragstart events should also be allowed.
    159     // See https://bugs.webkit.org/show_bug.cgi?id=113126.
    160     if (!m_readableData)
    161         return String();
    162 
    163     QByteArray rawData = m_readableData->data(type);
    164     QString data = QTextCodec::codecForName("UTF-16")->toUnicode(rawData);
    165     return data;
     149    if (isHtmlMimeType(type) && data->hasHtml())
     150        return data->html();
     151
     152    if (isTextMimeType(type) && data->hasText())
     153        return data->text();
     154
     155    QByteArray rawData = data->data(type);
     156    QString stringData = QTextCodec::codecForName("UTF-16")->toUnicode(rawData);
     157    return stringData;
    166158}
    167159
     
    189181ListHashSet<String> ClipboardQt::types() const
    190182{
    191     if (!canReadTypes())
     183    const QMimeData* data = readData();
     184    if (!canReadTypes() || !data)
    192185        return ListHashSet<String>();
    193186
    194     // FIXME: Per the spec, reading the clipboard in dragstart events should also be allowed.
    195     // See https://bugs.webkit.org/show_bug.cgi?id=113126.
    196     if (!m_readableData)
    197         return ListHashSet<String>();
    198 
    199187    ListHashSet<String> result;
    200     QStringList formats = m_readableData->formats();
     188    QStringList formats = data->formats();
    201189    for (int i = 0; i < formats.count(); ++i)
    202190        result.add(formats.at(i));
     
    206194PassRefPtr<FileList> ClipboardQt::files() const
    207195{
    208     // FIXME: Per the spec, reading the clipboard in dragstart events should also be allowed.
    209     // See https://bugs.webkit.org/show_bug.cgi?id=113126.
    210     if (!canReadData() || !m_readableData || !m_readableData->hasUrls())
     196    const QMimeData* data = readData();
     197    if (!canReadData() || !data || !data->hasUrls())
    211198        return FileList::create();
    212199
    213200    RefPtr<FileList> fileList = FileList::create();
    214     QList<QUrl> urls = m_readableData->urls();
     201    QList<QUrl> urls = data->urls();
    215202
    216203    for (int i = 0; i < urls.size(); i++) {
     
    260247    return 0;
    261248}
    262 
    263249
    264250static CachedImage* getCachedImage(Element* element)
     
    350336}
    351337
     338const QMimeData* ClipboardQt::readData() const
     339{
     340    ASSERT(!(m_readableData && m_writableData));
     341    ASSERT(m_readableData || m_writableData || canWriteData());
     342    return m_readableData ? m_readableData : m_writableData;
     343}
     344
    352345bool ClipboardQt::hasData()
    353346{
    354     const QMimeData *data = m_readableData ? m_readableData : m_writableData;
     347    const QMimeData *data = readData();
    355348    if (!data)
    356349        return false;
     
    361354PassRefPtr<DataTransferItemList> ClipboardQt::items()
    362355{
    363 
    364356    if (!m_frame && !m_frame->document())
    365357        return 0;
     
    367359    RefPtr<DataTransferItemListQt> items = DataTransferItemListQt::create(this, m_frame->document()->scriptExecutionContext());
    368360
    369     if (!m_readableData)
    370         return items;
    371 
    372     if (isForCopyAndPaste() && canReadData()) {
    373         const QStringList types = m_readableData->formats();
     361    const QMimeData* readableData = readData();
     362    if (readableData && isForCopyAndPaste() && canReadData()) {
     363        const QStringList types = readableData->formats();
    374364        for (int i = 0; i < types.count(); ++i)
    375365            items->addPasteboardItem(types.at(i));
  • trunk/Source/WebCore/platform/qt/ClipboardQt.h

    r142170 r146910  
    8787    void setDragImage(CachedImage*, Node*, const IntPoint& loc);
    8888
     89    const QMimeData* readData() const;
     90
    8991    const QMimeData* m_readableData;
    9092    QMimeData* m_writableData;
Note: See TracChangeset for help on using the changeset viewer.